From dc003cd2910cdf0d030e18f97788189f544dca2d Mon Sep 17 00:00:00 2001 From: Frost-ZX <30585462+Frost-ZX@users.noreply.github.com> Date: Thu, 25 Feb 2021 20:32:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E2=80=9C=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E2=80=9D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 3 +++ src/views/Settings.vue | 48 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/src/App.vue b/src/App.vue index c549306..3c23e79 100644 --- a/src/App.vue +++ b/src/App.vue @@ -99,12 +99,14 @@ export default { } }, watch: { + // 路由名称 '$route.name': { handler() { // 切换路由时隐藏下拉菜单 this.showHeaderDropdown = false; } }, + // 更新储存的设置 'config.storage': { handler(obj) { clearTimeout(this.debounce.saveConfig); @@ -115,6 +117,7 @@ export default { }, deep: true }, + // 改变字体大小 'config.storage.fontSize': { handler(value) { clearTimeout(this.debounce.updateConfig); diff --git a/src/views/Settings.vue b/src/views/Settings.vue index bcf6705..33118c1 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -18,6 +18,14 @@ + + 清除设置 + + + + 清除缓存 + + @@ -37,6 +45,46 @@ export default { next(vm => { vm.utils.changeTitle('设置'); }); + }, + methods: { + /** + * 清除数据 + * + * @param {string} type 清除类型(cache、settings) + */ + resetDatas(type) { + this.$confirm('确定要清除吗?', '确认', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + + if (type == 'cache') { + localStorage.removeItem('navLinksCache'); + } else if (type == 'settings') { + localStorage.removeItem('config'); + } else { + return + } + + this.$notify({ + type: 'success', + message: '已清除,2s 后自动刷新' + }); + + setTimeout(() => { + location.reload(); + }, 2000); + + }).catch(() => { + + this.$notify({ + type: 'info', + message: '取消清除' + }); + + }); + } } }