From 6b6e50dc7fccca9bcf317e76a18104ea01cb4734 Mon Sep 17 00:00:00 2001 From: BigBang019 <46477713+BigBang019@users.noreply.github.com> Date: Fri, 10 Jul 2020 12:09:11 +0800 Subject: [PATCH] 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 --- src/api/theme.js | 57 ++++++++++++++++ src/views/interface/ThemeList.vue | 108 ++++++++++++++++++++++++++++-- 2 files changed, 159 insertions(+), 6 deletions(-) diff --git a/src/api/theme.js b/src/api/theme.js index 899d74d77..8a62ca4cb 100644 --- a/src/api/theme.js +++ b/src/api/theme.js @@ -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 => { return service({ url: `${baseUrl}/files/content`, diff --git a/src/views/interface/ThemeList.vue b/src/views/interface/ThemeList.vue index 58e5c5711..56cb2c591 100644 --- a/src/views/interface/ThemeList.vue +++ b/src/views/interface/ThemeList.vue @@ -181,7 +181,10 @@ tab="远程拉取" key="2" > - + @@ -190,9 +193,64 @@ type="primary" @click="handleFetching" :loading="fetchButtonLoading" - >下载 + >获取 + + + + + + {{ item.branch }} + + + + 下载 + + + + + + + + {{ item.branch }} + + + + 下载 + + + + + { - this.$message.success('拉取成功!') - this.uploadThemeVisible = false - this.loadThemes() + this.branches = response.data.data + this.fetchBranches = true + }) + themeApi + .fetchingReleases(this.fetchingUrl) + .then(response => { + this.releases = response.data.data }) .finally(() => { 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() { themeApi.reload().then(response => { this.loadThemes() @@ -382,6 +469,9 @@ export default { onCancel() {} }) }, + onSelectChange(value) { + this.selectedBranch = value + }, onThemeUploadClose() { if (this.uploadThemeVisible) { this.$refs.upload.handleClearFileList() @@ -389,6 +479,12 @@ export default { if (this.uploadNewThemeVisible) { this.$refs.updateByupload.handleClearFileList() } + if (this.fetchBranches) { + this.fetchBranches = false + } + if (this.selectedBranch) { + this.selectedBranch = null + } this.loadThemes() }, onThemeSettingsClose() {