Browse Source

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

develop
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-debug.log*
yarn-error.log* yarn-error.log*
yarn.lock
package-lock.json
# Editor directories and files # Editor directories and files
.project .project
.idea .idea

1
CHANGELOG.md

@ -16,6 +16,7 @@
富文本插件 | 富文本插件demo测试 | ed3d644 富文本插件 | 富文本插件demo测试 | ed3d644
- | 引入dayjs | 29b8b93 - | 引入dayjs | 29b8b93
- | 提交到本地 | 9cbe411 - | 提交到本地 | 9cbe411
- | 插件参数处理调整 | a3e68d3
- | 插件数据获取 | 5b91bdc - | 插件数据获取 | 5b91bdc
- | 日常任务插件调整 | c1881f9 - | 日常任务插件调整 | c1881f9
- | 时间基准线,默认插件 | a33ba1e - | 时间基准线,默认插件 | 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"> <template class="p-0 u-col-between" v-if="pluginArr.length">
<Plugin <Plugin
:class="getClass(plugin.col, plugin.row)" :class="getClass(plugin.col, plugin.row)"
:item="item" :task="item"
:key="plugin.pluginTaskId" :key="plugin.pluginTaskId"
:pluginId="plugin.pluginId" :plugin-task-id="plugin.pluginTaskId"
:styleType="plugin.styleType || 0" :plugin-id="plugin.pluginId"
:style-type="plugin.styleType || 0"
v-for="plugin in pluginArr" v-for="plugin in pluginArr"
/> />
</template> </template>

41
src/components/Plugin/Plugin.vue

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

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

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

1
src/pages/project/project.vue

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

Loading…
Cancel
Save