diff --git a/src/views/interface/ThemeList.vue b/src/views/interface/ThemeList.vue index 4f6c95a08..deff75e4a 100644 --- a/src/views/interface/ThemeList.vue +++ b/src/views/interface/ThemeList.vue @@ -66,66 +66,6 @@ @close="onThemeSettingsDrawerClose" /> - -
- - - - - - - - - - - - - - - - - - - - - -
-
- + + @@ -146,6 +88,7 @@ import ThemeSettingDrawer from './components/ThemeSettingDrawer' import ThemeDeleteConfirmModal from './components/ThemeDeleteConfirmModal' import ThemeLocalUpgradeModal from './components/ThemeLocalUpgradeModal' +import ThemeInstallModal from './components/ThemeInstallModal.vue' import { PageView } from '@/layouts' import apiClient from '@/utils/api-client' @@ -154,7 +97,8 @@ export default { PageView, ThemeSettingDrawer, ThemeDeleteConfirmModal, - ThemeLocalUpgradeModal + ThemeLocalUpgradeModal, + ThemeInstallModal }, data() { return { @@ -164,21 +108,7 @@ export default { }, installModal: { - visible: false, - local: { - uploadHandler: (file, options) => apiClient.theme.upload(file, options) - }, - - remote: { - url: null, - - fetching: false, - fetchErrored: false, - - rules: { - url: [{ required: true, message: '* 远程地址不能为空', trigger: ['change'] }] - } - } + visible: false }, localUpgradeModel: { @@ -236,35 +166,6 @@ export default { this.handleListThemes() }) }, - handleUploadSucceed() { - this.installModal.visible = false - this.handleListThemes() - }, - handleRemoteFetching() { - this.$refs.remoteInstallForm.validate(valid => { - if (valid) { - this.installModal.remote.fetching = true - apiClient.theme - .fetchTheme(this.installModal.remote.url) - .catch(() => { - this.installModal.remote.fetchErrored = true - }) - .finally(() => { - setTimeout(() => { - this.installModal.remote.fetching = false - }, 400) - }) - } - }) - }, - handleRemoteFetchCallback() { - if (this.installModal.remote.fetchErrored) { - this.installModal.remote.fetchErrored = false - } else { - this.installModal.visible = false - this.handleListThemes() - } - }, handleOpenLocalUpdateModal(item) { this.localUpgradeModel.selected = item this.localUpgradeModel.visible = true @@ -282,27 +183,20 @@ export default { title: '提示', maskClosable: true, content: '确定更新【' + item.name + '】主题?', - onOk() { - const hide = _this.$message.loading('更新中...', 0) - apiClient.theme - .updateThemeByFetching(item.id) - .then(() => { - _this.$message.success('更新成功!') - }) - .finally(() => { - hide() - _this.handleListThemes() - }) + async onOk() { + const hideLoading = _this.$message.loading('更新中...', 0) + try { + await apiClient.theme.updateThemeByFetching(item.id) + _this.$message.success('更新成功!') + } catch (e) { + _this.$log.error('Failed to update theme: ', e) + } finally { + hideLoading() + _this.handleListThemes() + } } }) }, - onThemeInstallModalClose() { - if (this.$refs.upload) { - this.$refs.upload.handleClearFileList() - } - this.installModal.remote.url = null - this.handleListThemes() - }, onThemeSettingsDrawerClose() { this.themeSettingDrawer.visible = false this.themeSettingDrawer.selected = {} diff --git a/src/views/interface/components/ThemeInstallModal.vue b/src/views/interface/components/ThemeInstallModal.vue new file mode 100644 index 000000000..45db1131e --- /dev/null +++ b/src/views/interface/components/ThemeInstallModal.vue @@ -0,0 +1,135 @@ + +