From 5e1bd4a7d89e49fd04de5ae37deeb60f84de2c6c Mon Sep 17 00:00:00 2001 From: Frost-ZX <30585462+Frost-ZX@users.noreply.github.com> Date: Sun, 9 May 2021 14:27:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=BB=84=E4=BB=B6=E5=90=8D?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=9D=A5=E6=BA=90=E3=80=81=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Tools.vue | 27 +++++++++++++++------------ src/views/ToolsDetail.vue | 8 +++++--- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/views/Tools.vue b/src/views/Tools.vue index 35c137a..7a6b0ef 100644 --- a/src/views/Tools.vue +++ b/src/views/Tools.vue @@ -84,28 +84,34 @@ export default { * @param {string} toolName 工具名称 */ detailOpen(toolCatrgory, toolName) { + var vm = this; // 当前工具信息 var info = {}; + // 错误提示 + var errMsg = `无法打开该工具(分类:${toolCatrgory} 名称:${toolName})`; try { - info = this.toolList[toolCatrgory]['list'][toolName]; + info = vm.toolList[toolCatrgory]['list'][toolName]; if (info === undefined) { - throw new Error('该分类中不存在工具 ' + toolName); + throw new Error(errMsg); } } catch (err) { - - console.warn(`[打开工具] 无法打开该工具(分类:${toolCatrgory} 名称:${toolName})`); + console.warn('[打开工具]', err); + vm.$message({ + message: errMsg, + type: 'warning' + }); return; } // 禁用 if (!info.enabled) { - this.$message({ + vm.$message({ message: '该工具未启用', type: 'warning' }); @@ -113,25 +119,22 @@ export default { } // 更新页面标题 - this.utils.changeTitle(info.title); + vm.utils.changeTitle(info.title); // 更新 drawer 标题 - this.detail.title = `${info.title} [${info.version}_${info.update}]`; + vm.detail.title = `${info.title} [${info.version}_${info.update}]`; // 路由跳转 // 注:当前路由相同时也进行跳转,以更新 query - this.$router.push({ + vm.$router.push({ name: 'ToolsDetail', params: { category: toolCatrgory, name: toolName - }, - query: { - component: info.component } }).catch((err) => { console.log('[路由跳转]', err.name); }); // 显示 drawer - this.detail.show = true; + vm.detail.show = true; }, /** diff --git a/src/views/ToolsDetail.vue b/src/views/ToolsDetail.vue index cf66fb4..0007878 100644 --- a/src/views/ToolsDetail.vue +++ b/src/views/ToolsDetail.vue @@ -5,22 +5,24 @@