Browse Source

fix(plugin): 插件解析机制完善

tall
wally 4 years ago
parent
commit
0f5a27de9e
  1. 3
      .gitignore
  2. 1
      CHANGELOG.md
  3. 21244
      package-lock.json
  4. 7
      src/components/Globals/Globals.vue
  5. 41
      src/components/Plugin/Plugin.vue
  6. 1
      src/components/TimeLine/component/TimeBox.vue
  7. 1
      src/pages/project/project.vue

3
.gitignore

@ -12,6 +12,9 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn.lock
package-lock.json
# Editor directories and files
.project
.idea

1
CHANGELOG.md

@ -16,6 +16,7 @@
富文本插件 | 富文本插件demo测试 | ed3d644
- | 引入dayjs | 29b8b93
- | 提交到本地 | 9cbe411
- | 插件参数处理调整 | a3e68d3
- | 插件数据获取 | 5b91bdc
- | 日常任务插件调整 | c1881f9
- | 时间基准线,默认插件 | a33ba1e

21244
package-lock.json

File diff suppressed because it is too large

7
src/components/Globals/Globals.vue

@ -11,10 +11,11 @@
<template class="p-0 u-col-between" v-if="pluginArr.length">
<Plugin
:class="getClass(plugin.col, plugin.row)"
:item="item"
:task="item"
:key="plugin.pluginTaskId"
:pluginId="plugin.pluginId"
:styleType="plugin.styleType || 0"
:plugin-task-id="plugin.pluginTaskId"
:plugin-id="plugin.pluginId"
:style-type="plugin.styleType || 0"
v-for="plugin in pluginArr"
/>
</template>

41
src/components/Plugin/Plugin.vue

@ -1,7 +1,20 @@
<template>
<view class="u-font-14" style="height: 100%">
<view v-if="pluginContent">
<view style="height: 100%" v-html="pluginContent"></view>
<view
style="height: 100%"
:data-uid="userId"
:data-pid="projectId"
:data-did="task.detailId"
:data-rid="roleId"
:data-tid="task.id"
:data-tname="task.name"
:data-pstart="task.planStart"
:data-rstart="task.realStart"
:data-pdu="task.planDuration"
:data-rdu="task.realDuration"
v-html="pluginContent"
></view>
</view>
<view v-else>
@ -19,19 +32,27 @@
</template>
<script>
import { mapGetters, mapState } from 'vuex';
export default {
name: 'Plugin',
props: {
task: { default: () => {}, type: Object },
pluginId: { default: '1', type: String },
styleType: { default: 0, type: Number },
pluginTaskId: { default: '0', type: String },
pluginTaskId: { default: '', type: String },
},
data() {
return { pluginContent: null };
},
computed: {
...mapGetters('user', ['userId']),
...mapGetters('project', ['projectId']),
...mapState('role', ['roleId']),
},
created() {
this.getPlugin();
},
@ -45,19 +66,27 @@ export default {
styleType,
});
if (!data || !data.id) return;
const reg = /data-root=["|']?(\w+)["|']?/gi;
console.log(data.html);
if (data.html) {
// data-root=xxx xxx pluginTaskId
const reg = /data-root="(\w+)"/gi;
if (reg.test(data.html)) {
const str = data.html.replace(RegExp.$1, this.pluginTaskId);
const uuid = RegExp.$1;
console.log('uuid: ', uuid, `p${this.pluginTaskId}`);
const str = data.html.replaceAll(uuid, `p${this.pluginTaskId}`);
this.pluginContent = str;
} else {
this.pluginContent = data.html;
}
}
console.log(this.pluginContent);
if (data.js) {
if (reg.test(data.js)) {
const str = data.js.replace(RegExp.$1, this.pluginTaskId);
const uuid = RegExp.$1;
const str = data.js.replaceAll(uuid, `p${this.pluginTaskId}`);
this.handleDom(str);
} else {
this.handleDom(data.js);
@ -74,7 +103,9 @@ export default {
const scriptDom = document.createElement('script');
scriptDom.id = `p${pluginId}`;
scriptDom.innerHTML = js;
this.$nextTick(() => {
document.body.append(scriptDom);
});
}
},
},

1
src/components/TimeLine/component/TimeBox.vue

@ -38,6 +38,7 @@
:class="getClass(plugin.col, plugin.row)"
:task="task"
:key="plugin.pluginTaskId"
:plugin-task-id="plugin.pluginTaskId"
:pluginId="plugin.pluginId"
:styleType="styleType || 0"
v-for="plugin in row"

1
src/pages/project/project.vue

@ -38,7 +38,6 @@ export default {
* 永久日常任务不发生改变
*/
timeNode(val) {
console.log(val);
if (val && this.roleId) {
//
this.getGlobalData();

Loading…
Cancel
Save