Browse Source

feat: 插件渲染

test2
xuesinan 4 years ago
parent
commit
e15123a542
  1. 3
      CHANGELOG.md
  2. 4
      components/Plugin/Plugin.vue
  3. 61
      components/Render/Render.vue

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 1.0.0 (2022-02-17) # 1.0.0 (2022-02-18)
### 🌟 新功能 ### 🌟 新功能
范围|描述|commitId 范围|描述|commitId
@ -40,6 +40,7 @@
- | 审核插件的通过与驳回功能 | [03a7c35](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/03a7c35) - | 审核插件的通过与驳回功能 | [03a7c35](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/03a7c35)
- | 时间轴调整 | [81d2500](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/81d2500) - | 时间轴调整 | [81d2500](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/81d2500)
- | 时间轴接口 | [a95d005](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/a95d005) - | 时间轴接口 | [a95d005](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/a95d005)
- | 时间轴新策略 | [e736d05](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/e736d05)
- | 时间轴新策略 | [e25218b](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/e25218b) - | 时间轴新策略 | [e25218b](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/e25218b)
- | 时间轴页面 | [e926b75](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/e926b75) - | 时间轴页面 | [e926b75](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/e926b75)
- | 时间轴优化 | [77a137e](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/77a137e) - | 时间轴优化 | [77a137e](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/77a137e)

4
components/Plugin/Plugin.vue

@ -28,7 +28,7 @@
<p-domain-source-manage v-else-if="pluginId === '20'" class="p-2" /> <p-domain-source-manage v-else-if="pluginId === '20'" class="p-2" />
<p-project-version-management v-else-if="pluginId === '21'" class="p-2" /> <p-project-version-management v-else-if="pluginId === '21'" class="p-2" />
<!-- <Render <Render
v-else v-else
:task="task" :task="task"
:pluginId="pluginId" :pluginId="pluginId"
@ -36,7 +36,7 @@
:pluginTaskId="pluginTaskId" :pluginTaskId="pluginTaskId"
:businessPluginId="businessPluginId" :businessPluginId="businessPluginId"
:param="param" :param="param"
/> --> />
<!-- #ifdef H5 --> <!-- #ifdef H5 -->
<!-- #endif --> <!-- #endif -->
</view> </view>

61
components/Render/Render.vue

@ -17,8 +17,7 @@
:data-uid="userId" :data-uid="userId"
:pluginInfo="pluginInfo" :pluginInfo="pluginInfo"
:change:pluginInfo="project.renderDom" :change:pluginInfo="project.renderDom"
:pluginTaskId="pluginTaskId"
:change:pluginTaskId="project.initPluginTaskId"
></view> ></view>
</view> </view>
</template> </template>
@ -39,18 +38,25 @@ export default {
data() { data() {
return { return {
pluginInfo: null, pluginInfo: null,
configInfo: null
}; };
}, },
computed: { computed: {
...mapState(['allPlugin']), ...mapState(['allPlugin', 'businessPlugin']),
...mapState('role', ['roleId']), ...mapState('role', ['roleId']),
...mapState('user', ['token']), ...mapState('user', ['token']),
...mapGetters('project', ['projectId']), ...mapGetters('project', ['projectId']),
...mapGetters('user', ['userId']), ...mapGetters('user', ['userId']),
}, },
mounted() { async mounted() {
this.getPlugin(); await this.getPlugin();
if (this.param && this.pluginInfo) {
let configParam = JSON.parse(this.param);
this.pluginInfo.config = `var p${this.pluginId}_config = ${this.param}`;
} else {
await this.getConfig();
}
}, },
methods: { methods: {
getPlugin() { getPlugin() {
@ -59,8 +65,9 @@ export default {
// //
try { try {
const pluginLists = JSON.parse(allPlugin); const pluginLists = JSON.parse(allPlugin);
// pluginLists find,catch // pluginLists find,catch
const pluginTarget = pluginLists.find(item => item.id === this.pluginId); const pluginTarget = pluginLists.find(item => item.id === this.pluginId);
pluginTarget.pluginTaskId = this.pluginTaskId;
this.pluginInfo = pluginTarget || null; this.pluginInfo = pluginTarget || null;
} catch (error) { } catch (error) {
console.error('error: ', error); console.error('error: ', error);
@ -74,11 +81,39 @@ export default {
console.error('err: ', err); console.error('err: ', err);
this.pluginInfo = null; this.pluginInfo = null;
} else { } else {
res.pluginTaskId = this.pluginTaskId;
this.pluginInfo = res || null; this.pluginInfo = res || null;
} }
}); });
} }
}, },
getConfig() {
const businessPlugin = this.businessPlugin || uni.$storage.getStorageSync('businessPlugin');
if (businessPlugin && JSON.parse(businessPlugin)) {
//
const businessPluginLists = JSON.parse(businessPlugin);
businessPluginLists.forEach(item => {
if (item.pluginConfigs) {
const pluginConfig = item.pluginConfigs.find(plugin => plugin.businessPluginId === this.businessPluginId);
if (pluginConfig && pluginConfig.config && this.pluginInfo) {
this.pluginInfo.config = pluginConfig.config;
}
}
})
} else {
// API
// const params = { businessPluginId: this.businessPluginId };
// uni.$catchReq.getOtherPlugin(params, (err, res) => {
// if (err) {
// console.error('err: ', err);
// this.pluginInfo = null;
// } else {
// this.pluginInfo = res || null;
// }
// });
}
}
}, },
}; };
</script> </script>
@ -99,10 +134,16 @@ export default {
if (res.html) { if (res.html) {
// : 2022130 this.pluginTaskIdAPP // : 2022130 this.pluginTaskIdAPP
// bug // bug
const content = window.document.getElementById(`render-${pluginTaskId}`); const content = window.document.getElementById(`render-${res.pluginTaskId}`);
content.innerHTML = res.html; content.innerHTML = res.html;
} }
if (res.config) {
const script = window.document.createElement('script');
script.innerHTML = res.config;
window.document.body.appendChild(script);
}
if (res.js) { if (res.js) {
const script = window.document.createElement('script'); const script = window.document.createElement('script');
script.innerHTML = res.js; script.innerHTML = res.js;
@ -116,9 +157,9 @@ export default {
* 因为目前这里没办法通过this拿到prop data下的数据 * 因为目前这里没办法通过this拿到prop data下的数据
* @param {string} propsPluginTaskId * @param {string} propsPluginTaskId
*/ */
initPluginTaskId(propsPluginTaskId) { // initPluginTaskId(propsPluginTaskId) {
pluginTaskId = propsPluginTaskId; // pluginTaskId = propsPluginTaskId;
} // }
}, },
}; };
</script> </script>

Loading…
Cancel
Save