feat: 删除主题时可选是否删除配置 (#262)

pull/263/head
Wh1te 2020-10-12 22:30:45 +08:00 committed by GitHub
parent 9a2d9bb8ea
commit f3f18bd5a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 15 deletions

View File

@ -61,9 +61,12 @@ themeApi.update = themeId => {
}) })
} }
themeApi.delete = key => { themeApi.delete = (key, deleteSettings) => {
return service({ return service({
url: `${baseUrl}/${key}`, url: `${baseUrl}/${key}`,
params: {
deleteSettings: deleteSettings
},
method: 'delete' method: 'delete'
}) })
} }

View File

@ -90,7 +90,7 @@
<a-menu-item <a-menu-item
:key="1" :key="1"
:disabled="item.activated" :disabled="item.activated"
@click="handleConfirmDelete(item)" @click="handleOpenThemeDeleteModal(item)"
> >
<a-icon <a-icon
type="delete" type="delete"
@ -284,6 +284,21 @@
@success="handleUploadSucceed" @success="handleUploadSucceed"
></FilePondUpload> ></FilePondUpload>
</a-modal> </a-modal>
<a-modal
title="提示"
v-model="themeDeleteModal.visible"
:width=416
:closable=false
destroyOnClose
@ok="handleDeleteTheme(themeDeleteModal.selected.id, themeDeleteModal.deleteSettings)"
@cancel="themeDeleteModal.visible = false"
:afterClose="onThemeDeleteModalClose"
>
<p>确定删除{{ themeDeleteModal.selected.name }}主题</p>
<a-checkbox v-model="themeDeleteModal.deleteSettings">
同时删除主题配置
</a-checkbox>
</a-modal>
</page-view> </page-view>
</template> </template>
@ -340,6 +355,12 @@ export default {
selected: {}, selected: {},
}, },
themeDeleteModal: {
visible: false,
deleteSettings: false,
selected: {}
},
themeSettingDrawer: { themeSettingDrawer: {
visible: false, visible: false,
selected: {}, selected: {},
@ -368,11 +389,13 @@ export default {
this.themeSettingDrawer.visible = false this.themeSettingDrawer.visible = false
this.installModal.visible = false this.installModal.visible = false
this.localUpdateModel.visible = false this.localUpdateModel.visible = false
this.themeDeleteModal.visible = false
}, },
beforeRouteLeave(to, from, next) { beforeRouteLeave(to, from, next) {
this.themeSettingDrawer.visible = false this.themeSettingDrawer.visible = false
this.installModal.visible = false this.installModal.visible = false
this.localUpdateModel.visible = false this.localUpdateModel.visible = false
this.themeDeleteModal.visible = false
next() next()
}, },
methods: { methods: {
@ -399,8 +422,9 @@ export default {
this.handleListThemes() this.handleListThemes()
}) })
}, },
handleDeleteTheme(themeId) { handleDeleteTheme(themeId, deleteSettings) {
themeApi.delete(themeId).finally(() => { themeApi.delete(themeId, deleteSettings).finally(() => {
this.themeDeleteModal.visible = false
this.handleListThemes() this.handleListThemes()
}) })
}, },
@ -488,17 +512,9 @@ export default {
this.themeSettingDrawer.selected = theme this.themeSettingDrawer.selected = theme
this.themeSettingDrawer.visible = true this.themeSettingDrawer.visible = true
}, },
handleConfirmDelete(item) { handleOpenThemeDeleteModal(item) {
const _this = this this.themeDeleteModal.visible = true
this.$confirm({ this.themeDeleteModal.selected = item
title: '提示',
maskClosable: true,
content: '确定删除【' + item.name + '】主题?',
onOk() {
_this.handleDeleteTheme(item.id)
},
onCancel() {},
})
}, },
handleConfirmRemoteUpdate(item) { handleConfirmRemoteUpdate(item) {
const _this = this const _this = this
@ -540,6 +556,11 @@ export default {
this.themeSettingDrawer.visible = false this.themeSettingDrawer.visible = false
this.themeSettingDrawer.selected = {} this.themeSettingDrawer.selected = {}
}, },
onThemeDeleteModalClose() {
this.themeDeleteModal.visible = false
this.themeDeleteModal.deleteSettings = false
this.themeDeleteModal.selected = {}
}
}, },
} }
</script> </script>