diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ca1ba2..a46cead 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# 0.1.0 (2021-07-29) +# 0.1.0 (2021-07-30) ### 🌟 新功能 范围|描述|commitId @@ -53,6 +53,7 @@ ### 🐛 Bug 修复 范围|描述|commitId --|--|-- + plugin | 插件解析机制完善 | 0f5a27d role | 切换角色的逻辑修正完善 | 4ae534f task任务逻辑完善 | 减少初始global及regular的不必要请求 | bd4bd38 - | 上下滑动加载定期任务 | 4090d89 diff --git a/src/components/Plugin/Plugin.vue b/src/components/Plugin/Plugin.vue index 112ac83..1a238d8 100644 --- a/src/components/Plugin/Plugin.vue +++ b/src/components/Plugin/Plugin.vue @@ -67,13 +67,13 @@ export default { }); if (!data || !data.id) return; const reg = /data-root=["|']?(\w+)["|']?/gi; - console.log(data.html); + // console.log(data.html); if (data.html) { // 查有没有data-root=“xxx” 有的话 将xxx替换为 pluginTaskId if (reg.test(data.html)) { const uuid = RegExp.$1; - console.log('uuid: ', uuid, `p${this.pluginTaskId}`); + // console.log('uuid: ', uuid, `p${this.pluginTaskId}`); const str = data.html.replaceAll(uuid, `p${this.pluginTaskId}`); this.pluginContent = str; @@ -81,7 +81,7 @@ export default { this.pluginContent = data.html; } } - console.log(this.pluginContent); + // console.log(this.pluginContent); if (data.js) { if (reg.test(data.js)) { @@ -102,6 +102,7 @@ export default { 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); diff --git a/src/components/Roles/Roles.vue b/src/components/Roles/Roles.vue index b7827d8..3dc6811 100644 --- a/src/components/Roles/Roles.vue +++ b/src/components/Roles/Roles.vue @@ -95,6 +95,9 @@ export default { // 时间基准点不用管 project监听了roleId 里处理了 changeRole(id, index) { try { + // 清除多余的script + this.clearPluginScript(); + this.setRoleId(id); //改变index 即手动点击切换 我在此时将当前元素赋值给左边距 实现自动滚动 this.setCurrentRole(index); @@ -111,6 +114,16 @@ export default { } }, + // 清除插件script + clearPluginScript() { + console.log('clearPluginScript: '); + + const scripts = document.querySelectorAll('script[data-type=plugin]'); + for (let i = 0; i < scripts.length; i++) { + document.body.removeChild(scripts[i]); + } + }, + // 设置文字颜色 setColor(mine, id) { const { roleId } = this; diff --git a/src/components/Title/Title.vue b/src/components/Title/Title.vue index bd30062..89f5534 100644 --- a/src/components/Title/Title.vue +++ b/src/components/Title/Title.vue @@ -1,8 +1,8 @@