diff --git a/frontend/src/components/canvas/components/Editor/Preview.vue b/frontend/src/components/canvas/components/Editor/Preview.vue index 5e693c977d..869e38d02c 100644 --- a/frontend/src/components/canvas/components/Editor/Preview.vue +++ b/frontend/src/components/canvas/components/Editor/Preview.vue @@ -256,13 +256,15 @@ export default { }) // 监听画布div变动事件 const tempCanvas = document.getElementById('canvasInfoTemp') - erd.listenTo(document.getElementById('canvasInfoTemp'), element => { - _this.$nextTick(() => { - // 将mainHeight 修改为px 临时解决html2canvas 截图不全的问题 - _this.mainHeight = tempCanvas.scrollHeight + 'px!important' - this.$emit('mainHeightChange', _this.mainHeight) + if (tempCanvas) { + erd.listenTo(document.getElementById('canvasInfoTemp'), element => { + _this.$nextTick(() => { + // 将mainHeight 修改为px 临时解决html2canvas 截图不全的问题 + _this.mainHeight = tempCanvas.scrollHeight + 'px!important' + this.$emit('mainHeightChange', _this.mainHeight) + }) }) - }) + } eventBus.$on('openChartDetailsDialog', this.openChartDetailsDialog) _this.$store.commit('clearLinkageSettingInfo', false) _this.canvasStyleDataInit() diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index f5a17a6d1f..98eb050ce5 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -125,7 +125,8 @@ const data = { changeProperties: { customStyle: {}, customAttr: {} - } + }, + allViewRender: [] }, mutations: { ...animation.mutations, @@ -550,7 +551,7 @@ const data = { // get view base info const viewBaseInfo = state.componentViewsData[id] // get properties - const viewConfig = TYPE_CONFIGS.filter(item => item.render === viewBaseInfo.render && item.value === viewBaseInfo.type) + const viewConfig = state.allViewRender.filter(item => item.render === viewBaseInfo.render && item.value === viewBaseInfo.type) const viewProperties = viewConfig ? viewConfig[0].properties : [] if (state.mixProperties.length > 0) { // If it exists , taking the intersection @@ -641,6 +642,12 @@ const data = { customStyle: {}, customAttr: {} } + }, + initViewRender(state, pluginViews) { + pluginViews.forEach(plugin => { + plugin.isPlugin = true + }) + state.allViewRender = [...TYPE_CONFIGS, ...pluginViews] } }, modules: { diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index 0df0e9a70d..f0f1952b0c 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -652,7 +652,7 @@ item.render === _this.chart.render && item.value === _this.chart.type) + const viewConfig = this.allViewRender.filter(item => item.render === _this.chart.render && item.value === _this.chart.type) if (viewConfig && viewConfig.length) { return viewConfig[0].properties } else { @@ -1188,7 +1188,8 @@ export default { }, ...mapState([ 'curComponent', - 'panelViewEditInfo' + 'panelViewEditInfo', + 'allViewRender' ]) /* pluginRenderOptions() { const plugins = localStorage.getItem('plugin-views') && JSON.parse(localStorage.getItem('plugin-views')) || [] diff --git a/frontend/src/views/panel/list/PanelMain.vue b/frontend/src/views/panel/list/PanelMain.vue index 90f0ed7338..a335a232c7 100644 --- a/frontend/src/views/panel/list/PanelMain.vue +++ b/frontend/src/views/panel/list/PanelMain.vue @@ -30,6 +30,7 @@ import PanelList from '../list/PanelList' import PanelViewShow from '../list/PanelViewShow' import ShareTree from '../GrantAuth/shareTree' import Enshrine from '../enshrine/index' +import { pluginTypes } from '@/api/chart/chart' export default { name: 'PanelMain', @@ -59,6 +60,20 @@ export default { } }, mounted() { + // init all views (include plugins) base info + const plugins = localStorage.getItem('plugin-views') && JSON.parse(localStorage.getItem('plugin-views')) + if (plugins) { + this.$store.commit('initViewRender', plugins) + } else { + pluginTypes().then(res => { + const plugins = res.data + localStorage.setItem('plugin-views', JSON.stringify(plugins)) + this.$store.commit('initViewRender', plugins) + }).catch(e => { + localStorage.setItem('plugin-views', null) + this.$store.commit('initViewRender', plugins) + }) + } this.clear() }, methods: {