From 940603aa7ff56ae6caa03acb32a2bd76b9b25732 Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Fri, 30 Jul 2021 16:45:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(ID1000343):=20=E8=A7=A3=E5=86=B3=E5=90=91?= =?UTF-8?q?=E4=B8=8B=E9=A2=84=E5=8A=A0=E8=BD=BD=E6=9F=A5=E8=AF=A2=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=97=B6=E9=97=B4=E6=B2=A1+1=E9=A2=97=E7=B2=92?= =?UTF-8?q?=E5=BA=A6;=E4=BB=A5=E5=8F=8A=E6=BB=9A=E5=8A=A8=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E9=A2=97=E7=B2=92=E5=BA=A6=E5=86=99=E6=AD=BB=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #ID1000343 --- CHANGELOG.md | 1 + src/components/Plugin/Plugin.vue | 46 ++++++++++++++++------------ src/components/Roles/Roles.vue | 35 ++++++++++++--------- src/components/TimeLine/TimeLine.vue | 20 ++++++------ src/config/time.js | 24 +++++++-------- src/pages/project/project.vue | 13 ++++++-- src/store/task/getters.js | 15 +++++++-- tailwind.config.js | 2 +- 8 files changed, 92 insertions(+), 64 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a46cead..a5104c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ 范围|描述|commitId --|--|-- plugin | 插件解析机制完善 | 0f5a27d + project title | 项目标题修改; 切换角色移除script | 5c20017 role | 切换角色的逻辑修正完善 | 4ae534f task任务逻辑完善 | 减少初始global及regular的不必要请求 | bd4bd38 - | 上下滑动加载定期任务 | 4090d89 diff --git a/src/components/Plugin/Plugin.vue b/src/components/Plugin/Plugin.vue index 1a238d8..328cb98 100644 --- a/src/components/Plugin/Plugin.vue +++ b/src/components/Plugin/Plugin.vue @@ -68,11 +68,13 @@ export default { if (!data || !data.id) return; const reg = /data-root=["|']?(\w+)["|']?/gi; // console.log(data.html); + let uuid = ''; + // FIXME: 没有兼容只有js 没有html的情况 if (data.html) { // 查有没有data-root=“xxx” 有的话 将xxx替换为 pluginTaskId if (reg.test(data.html)) { - const uuid = RegExp.$1; + uuid = RegExp.$1; // console.log('uuid: ', uuid, `p${this.pluginTaskId}`); const str = data.html.replaceAll(uuid, `p${this.pluginTaskId}`); @@ -80,34 +82,38 @@ export default { } else { this.pluginContent = data.html; } + + const str = data.js.replaceAll(uuid, `p${this.pluginTaskId}`); + this.handleDom(str); } // console.log(this.pluginContent); - if (data.js) { - if (reg.test(data.js)) { - const uuid = RegExp.$1; - const str = data.js.replaceAll(uuid, `p${this.pluginTaskId}`); - this.handleDom(str); - } else { - this.handleDom(data.js); - } - } + // if (data.js) { + // if (reg.test(data.js)) { + // const uuid = RegExp.$1; + // const str = data.js.replaceAll(uuid, `p${this.pluginTaskId}`); + // this.handleDom(str); + // } else { + // this.handleDom(data.js); + // } + // } }, // 创建script dom handleDom(js) { - const { pluginId } = this; + const { pluginTaskId } = this; let domList = Array.from(document.getElementsByTagName('script')); - const index = domList.findIndex(item => item.id === `p${pluginId}`); - if (js && index === -1) { - const scriptDom = document.createElement('script'); - scriptDom.id = `p${pluginId}`; - scriptDom.setAttribute('data-type', 'plugin'); - scriptDom.innerHTML = js; - this.$nextTick(() => { - document.body.append(scriptDom); - }); + const index = domList.findIndex(item => item.id === `p${pluginTaskId}`); + if (index >= 0) { + document.body.removeChild(document.getElementById(`p${pluginTaskId}`)); } + const scriptDom = document.createElement('script'); + scriptDom.id = `p${pluginTaskId}`; + scriptDom.setAttribute('data-type', 'plugin'); + scriptDom.innerHTML = js; + this.$nextTick(() => { + document.body.append(scriptDom); + }); }, }, }; diff --git a/src/components/Roles/Roles.vue b/src/components/Roles/Roles.vue index 3dc6811..d2d1183 100644 --- a/src/components/Roles/Roles.vue +++ b/src/components/Roles/Roles.vue @@ -97,18 +97,19 @@ export default { try { // 清除多余的script this.clearPluginScript(); - - this.setRoleId(id); - //改变index 即手动点击切换 我在此时将当前元素赋值给左边距 实现自动滚动 - this.setCurrentRole(index); - // 清空定期任务数据 - this.setTasks(); - // 清空日常任务的数据 - this.setPermanents([]); - this.setDailyTasks([]); - // 到顶的标志复位 - // 到底的标志复位 - this.clearEndFlag(); + this.$nextTick(() => { + this.setRoleId(id); + //改变index 即手动点击切换 我在此时将当前元素赋值给左边距 实现自动滚动 + this.setCurrentRole(index); + // 清空定期任务数据 + this.setTasks(); + // 清空日常任务的数据 + this.setPermanents([]); + this.setDailyTasks([]); + // 到顶的标志复位 + // 到底的标志复位 + this.clearEndFlag(); + }); } catch (error) { console.log('role.vue changeRole error: ', error); } @@ -117,10 +118,14 @@ export default { // 清除插件script clearPluginScript() { console.log('clearPluginScript: '); + try { + const scripts = document.querySelectorAll('script[data-type=plugin]'); - const scripts = document.querySelectorAll('script[data-type=plugin]'); - for (let i = 0; i < scripts.length; i++) { - document.body.removeChild(scripts[i]); + for (let i = 0; i < scripts.length; i++) { + document.body.removeChild(scripts[i]); + } + } catch (error) { + console.log('clearPluginScript error: ', error); } }, diff --git a/src/components/TimeLine/TimeLine.vue b/src/components/TimeLine/TimeLine.vue index 65b0c4f..92c593f 100644 --- a/src/components/TimeLine/TimeLine.vue +++ b/src/components/TimeLine/TimeLine.vue @@ -23,7 +23,7 @@