diff --git a/src/api/theme.js b/src/api/theme.js index aad62d1fd..68b1427cf 100644 --- a/src/api/theme.js +++ b/src/api/theme.js @@ -41,7 +41,7 @@ themeApi.getActivatedTheme = () => { themeApi.update = themeId => { return service({ - url: `${baseUrl}/${themeId}`, + url: `${baseUrl}/fetching/${themeId}`, timeout: 60000, method: 'put' }) @@ -94,6 +94,17 @@ themeApi.upload = (formData, uploadProgress, cancelToken) => { }) } +themeApi.updateByUpload = (formData, uploadProgress, cancelToken, themeId) => { + return service({ + url: `${baseUrl}/upload/${themeId}`, + timeout: 86400000, // 24 hours + data: formData, // form data + onUploadProgress: uploadProgress, + cancelToken: cancelToken, + method: 'put' + }) +} + themeApi.fetching = url => { return service({ url: `${baseUrl}/fetching`, diff --git a/src/components/Upload/UpdateTheme.vue b/src/components/Upload/UpdateTheme.vue new file mode 100644 index 000000000..fe0b348ff --- /dev/null +++ b/src/components/Upload/UpdateTheme.vue @@ -0,0 +1,110 @@ + + + + + diff --git a/src/components/index.js b/src/components/index.js index 68da16ab1..8b6eb14ce 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -4,11 +4,13 @@ import Vue from 'vue' import Ellipsis from '@/components/Ellipsis' import FooterToolbar from '@/components/FooterToolbar' import Upload from '@/components/Upload/Upload' +import UpdateTheme from '@/components/Upload/UpdateTheme' const _components = { Ellipsis, FooterToolbar, - Upload + Upload, + UpdateTheme } const components = {} diff --git a/src/views/interface/ThemeList.vue b/src/views/interface/ThemeList.vue index d27d45427..799636ecb 100644 --- a/src/views/interface/ThemeList.vue +++ b/src/views/interface/ThemeList.vue @@ -90,7 +90,10 @@ />删除 - + 更新 + />在线更新 + + 从主题包更新 + @@ -278,7 +290,7 @@ 安装主题 @@ -293,7 +305,7 @@ @@ -338,19 +350,39 @@ multiple accept="application/zip" :uploadHandler="uploadHandler" - @change="handleChange" + @change="handleUploadChange" @success="handleUploadSuccess" >

-

点击选择主题或将主题拖拽到此处

+

点击选择主题包或将主题包拖拽到此处

支持单个或批量上传,仅支持 ZIP 格式的文件

+ + +

+ +

+

点击选择主题包或将主题包拖拽到此处

+

请选择最新的主题包,仅支持 ZIP 格式的文件

+
+
@@ -370,7 +402,8 @@ export default { return { themeLoading: false, optionLoading: true, - uploadVisible: false, + uploadThemeVisible: false, + uploadNewThemeVisible: false, fetchButtonLoading: false, wrapperCol: { xl: { span: 12 }, @@ -385,7 +418,9 @@ export default { themeSettings: [], themeProperty: null, fetchingUrl: null, - uploadHandler: themeApi.upload + uploadHandler: themeApi.upload, + updateByUploadHandler: themeApi.updateByUpload, + prepareUpdateTheme: {} } }, computed: { @@ -462,7 +497,7 @@ export default { this.themeConfiguration = [] this.themeProperty = null }, - handleChange(info) { + handleUploadChange(info) { const status = info.file.status if (status === 'done') { this.$message.success(`${info.file.name} 主题上传成功!`) @@ -470,8 +505,21 @@ export default { this.$message.error(`${info.file.name} 主题上传失败!`) } }, + handleNewThemeUploadChange(info) { + const status = info.file.status + if (status === 'done') { + this.$message.success(`${info.file.name} 主题更新成功!`) + } else if (status === 'error') { + this.$message.error(`${info.file.name} 主题更新失败!`) + } + }, handleUploadSuccess() { - this.uploadVisible = false + if (this.uploadThemeVisible) { + this.uploadThemeVisible = false + } + if (this.uploadNewThemeVisible) { + this.uploadNewThemeVisible = false + } this.loadThemes() }, handleEllipsisClick(theme) { @@ -489,7 +537,7 @@ export default { .fetching(this.fetchingUrl) .then(response => { this.$message.success('拉取成功!') - this.uploadVisible = false + this.uploadThemeVisible = false this.loadThemes() }) .finally(() => { @@ -501,6 +549,11 @@ export default { this.loadThemes() this.$message.success('刷新成功!') }) + }, + handleShowUpdateNewThemeModal(item) { + console.log(item) + this.prepareUpdateTheme = item + this.uploadNewThemeVisible = true } } }