mirror of https://github.com/halo-dev/halo
feat: add Theme Branches/Releases Control (halo issue 515&592) (halo-dev/console#186)
* halo issue 515&592 * beautify UI Co-authored-by: Ryan Wang <i@ryanc.cc>pull/3445/head
parent
3ab982c7cc
commit
6b6e50dc7f
|
@ -130,6 +130,63 @@ themeApi.fetching = url => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
themeApi.fetchingBranches = url => {
|
||||||
|
return service({
|
||||||
|
url: `${baseUrl}/fetchingBranches`,
|
||||||
|
timeout: 60000,
|
||||||
|
params: {
|
||||||
|
uri: url
|
||||||
|
},
|
||||||
|
method: 'post'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
themeApi.fetchingReleases = url => {
|
||||||
|
return service({
|
||||||
|
url: `${baseUrl}/fetchingReleases`,
|
||||||
|
timeout: 60000,
|
||||||
|
params: {
|
||||||
|
uri: url
|
||||||
|
},
|
||||||
|
method: 'post'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
themeApi.fetchingBranch = (url, branchName) => {
|
||||||
|
return service({
|
||||||
|
url: `${baseUrl}/fetchBranch`,
|
||||||
|
timeout: 60000,
|
||||||
|
params: {
|
||||||
|
uri: url,
|
||||||
|
branch: branchName
|
||||||
|
},
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
themeApi.fetchingLatestRelease = url => {
|
||||||
|
return service({
|
||||||
|
url: `${baseUrl}/fetchLatestRelease`,
|
||||||
|
timeout: 60000,
|
||||||
|
params: {
|
||||||
|
uri: url
|
||||||
|
},
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
themeApi.fetchingRelease = (url, tagName) => {
|
||||||
|
return service({
|
||||||
|
url: `${baseUrl}/fetchingRelease`,
|
||||||
|
timeout: 60000,
|
||||||
|
params: {
|
||||||
|
uri: url,
|
||||||
|
tag: tagName
|
||||||
|
},
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
themeApi.getContent = path => {
|
themeApi.getContent = path => {
|
||||||
return service({
|
return service({
|
||||||
url: `${baseUrl}/files/content`,
|
url: `${baseUrl}/files/content`,
|
||||||
|
|
|
@ -181,7 +181,10 @@
|
||||||
tab="远程拉取"
|
tab="远程拉取"
|
||||||
key="2"
|
key="2"
|
||||||
>
|
>
|
||||||
<a-form layout="vertical">
|
<a-form
|
||||||
|
v-if="!fetchBranches"
|
||||||
|
layout="vertical"
|
||||||
|
>
|
||||||
<a-form-item label="远程地址:">
|
<a-form-item label="远程地址:">
|
||||||
<a-input v-model="fetchingUrl" />
|
<a-input v-model="fetchingUrl" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
@ -190,9 +193,64 @@
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="handleFetching"
|
@click="handleFetching"
|
||||||
:loading="fetchButtonLoading"
|
:loading="fetchButtonLoading"
|
||||||
>下载</a-button>
|
>获取</a-button>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
|
<a-tabs
|
||||||
|
v-else
|
||||||
|
>
|
||||||
|
<a-tab-pane
|
||||||
|
tab="稳定版"
|
||||||
|
key="1"
|
||||||
|
>
|
||||||
|
<a-form layout="vertical">
|
||||||
|
<a-form-item>
|
||||||
|
<a-select
|
||||||
|
style="width: 120px"
|
||||||
|
@change="onSelectChange"
|
||||||
|
>
|
||||||
|
<a-select-option
|
||||||
|
v-for="(item, index) in releases"
|
||||||
|
:key="index"
|
||||||
|
:value="index"
|
||||||
|
>{{ item.branch }}</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item>
|
||||||
|
<a-button
|
||||||
|
type="primary"
|
||||||
|
@click="handleReleaseFetching"
|
||||||
|
>下载</a-button>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-tab-pane>
|
||||||
|
<a-tab-pane
|
||||||
|
tab="开发版"
|
||||||
|
key="2"
|
||||||
|
>
|
||||||
|
<a-form layout="vertical">
|
||||||
|
<a-form-item>
|
||||||
|
<a-select
|
||||||
|
style="width: 120px"
|
||||||
|
@change="onSelectChange"
|
||||||
|
>
|
||||||
|
<a-select-option
|
||||||
|
v-for="(item, index) in branches"
|
||||||
|
:key="index"
|
||||||
|
:value="index"
|
||||||
|
>{{ item.branch }}</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item>
|
||||||
|
<a-button
|
||||||
|
type="primary"
|
||||||
|
@click="handleBranchFetching"
|
||||||
|
>下载</a-button>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-tab-pane>
|
||||||
|
</a-tabs>
|
||||||
|
|
||||||
<a-alert
|
<a-alert
|
||||||
type="info"
|
type="info"
|
||||||
closable
|
closable
|
||||||
|
@ -245,9 +303,13 @@ export default {
|
||||||
uploadThemeVisible: false,
|
uploadThemeVisible: false,
|
||||||
uploadNewThemeVisible: false,
|
uploadNewThemeVisible: false,
|
||||||
fetchButtonLoading: false,
|
fetchButtonLoading: false,
|
||||||
|
fetchBranches: false,
|
||||||
themes: [],
|
themes: [],
|
||||||
|
branches: [],
|
||||||
|
releases: [],
|
||||||
themeSettingVisible: false,
|
themeSettingVisible: false,
|
||||||
selectedTheme: {},
|
selectedTheme: {},
|
||||||
|
selectedBranch: null,
|
||||||
fetchingUrl: null,
|
fetchingUrl: null,
|
||||||
uploadHandler: themeApi.upload,
|
uploadHandler: themeApi.upload,
|
||||||
updateByUploadHandler: themeApi.updateByUpload,
|
updateByUploadHandler: themeApi.updateByUpload,
|
||||||
|
@ -316,6 +378,9 @@ export default {
|
||||||
if (this.uploadNewThemeVisible) {
|
if (this.uploadNewThemeVisible) {
|
||||||
this.uploadNewThemeVisible = false
|
this.uploadNewThemeVisible = false
|
||||||
}
|
}
|
||||||
|
if (this.fetchBranches) {
|
||||||
|
this.fetchBranches = false
|
||||||
|
}
|
||||||
this.loadThemes()
|
this.loadThemes()
|
||||||
},
|
},
|
||||||
handleEditClick(theme) {
|
handleEditClick(theme) {
|
||||||
|
@ -334,16 +399,38 @@ export default {
|
||||||
}
|
}
|
||||||
this.fetchButtonLoading = true
|
this.fetchButtonLoading = true
|
||||||
themeApi
|
themeApi
|
||||||
.fetching(this.fetchingUrl)
|
.fetchingBranches(this.fetchingUrl)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.$message.success('拉取成功!')
|
this.branches = response.data.data
|
||||||
this.uploadThemeVisible = false
|
this.fetchBranches = true
|
||||||
this.loadThemes()
|
})
|
||||||
|
themeApi
|
||||||
|
.fetchingReleases(this.fetchingUrl)
|
||||||
|
.then(response => {
|
||||||
|
this.releases = response.data.data
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.fetchButtonLoading = false
|
this.fetchButtonLoading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
handleBranchFetching() {
|
||||||
|
themeApi
|
||||||
|
.fetchingBranch(this.fetchingUrl, this.branches[this.selectedBranch].branch)
|
||||||
|
.then(response => {
|
||||||
|
this.$message.success('拉取成功')
|
||||||
|
this.uploadThemeVisible = false
|
||||||
|
this.loadThemes()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleReleaseFetching() {
|
||||||
|
themeApi
|
||||||
|
.fetchingRelease(this.fetchingUrl, this.releases[this.selectedBranch].branch)
|
||||||
|
.then(response => {
|
||||||
|
this.$message.success('拉取成功')
|
||||||
|
this.uploadThemeVisible = false
|
||||||
|
this.loadThemes()
|
||||||
|
})
|
||||||
|
},
|
||||||
handleReload() {
|
handleReload() {
|
||||||
themeApi.reload().then(response => {
|
themeApi.reload().then(response => {
|
||||||
this.loadThemes()
|
this.loadThemes()
|
||||||
|
@ -382,6 +469,9 @@ export default {
|
||||||
onCancel() {}
|
onCancel() {}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
onSelectChange(value) {
|
||||||
|
this.selectedBranch = value
|
||||||
|
},
|
||||||
onThemeUploadClose() {
|
onThemeUploadClose() {
|
||||||
if (this.uploadThemeVisible) {
|
if (this.uploadThemeVisible) {
|
||||||
this.$refs.upload.handleClearFileList()
|
this.$refs.upload.handleClearFileList()
|
||||||
|
@ -389,6 +479,12 @@ export default {
|
||||||
if (this.uploadNewThemeVisible) {
|
if (this.uploadNewThemeVisible) {
|
||||||
this.$refs.updateByupload.handleClearFileList()
|
this.$refs.updateByupload.handleClearFileList()
|
||||||
}
|
}
|
||||||
|
if (this.fetchBranches) {
|
||||||
|
this.fetchBranches = false
|
||||||
|
}
|
||||||
|
if (this.selectedBranch) {
|
||||||
|
this.selectedBranch = null
|
||||||
|
}
|
||||||
this.loadThemes()
|
this.loadThemes()
|
||||||
},
|
},
|
||||||
onThemeSettingsClose() {
|
onThemeSettingsClose() {
|
||||||
|
|
Loading…
Reference in New Issue