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
@ -40,6 +40,7 @@
- | 审核插件的通过与驳回功能 | [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)
- | 时间轴接口 | [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)
- | 时间轴页面 | [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)

4
components/Plugin/Plugin.vue

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

61
components/Render/Render.vue

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

Loading…
Cancel
Save