From 5c20017c1f314fdee139f49cb1dff7ac3bf3b93d Mon Sep 17 00:00:00 2001
From: wally <18603454788@163.com>
Date: Fri, 30 Jul 2021 09:29:50 +0800
Subject: [PATCH] =?UTF-8?q?fix(project=20title):=20=E9=A1=B9=E7=9B=AE?=
=?UTF-8?q?=E6=A0=87=E9=A2=98=E4=BF=AE=E6=94=B9;=20=E5=88=87=E6=8D=A2?=
=?UTF-8?q?=E8=A7=92=E8=89=B2=E7=A7=BB=E9=99=A4script?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 3 ++-
src/components/Plugin/Plugin.vue | 7 ++++---
src/components/Roles/Roles.vue | 13 +++++++++++++
src/components/Title/Title.vue | 12 +++++-------
src/pages/project/project.vue | 6 +++++-
src/store/project/actions.js | 6 +++---
src/store/project/mutations.js | 2 +-
7 files changed, 33 insertions(+), 16 deletions(-)
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 @@
-
-
- 我是标题
+
+
+ {{ project.name }}
@@ -15,11 +15,9 @@