perf(X-Pack): 优化整合视图插件demo
This commit is contained in:
parent
9f54efbf82
commit
43fffdee71
@ -3,7 +3,7 @@ import request from '@/config/axios'
|
|||||||
export const load = (key: string) => request.get({ url: `/xpackComponent/content/${key}` })
|
export const load = (key: string) => request.get({ url: `/xpackComponent/content/${key}` })
|
||||||
|
|
||||||
export const loadPluginApi = (key: string) =>
|
export const loadPluginApi = (key: string) =>
|
||||||
request.get({ url: `/xpackComponent/pluginContent/${key}` })
|
request.get({ url: `/xpackComponent/contentPlugin/${key}` })
|
||||||
|
|
||||||
export const loadDistributed = () => request.get({ url: '/DEXPack.umd.js' })
|
export const loadDistributed = () => request.get({ url: '/DEXPack.umd.js' })
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,6 @@ import { activeWatermark } from '@/components/watermark/watermark'
|
|||||||
import { personInfoApi } from '@/api/user'
|
import { personInfoApi } from '@/api/user'
|
||||||
import ComponentHangPopver from '@/custom-component/independent-hang/ComponentHangPopver.vue'
|
import ComponentHangPopver from '@/custom-component/independent-hang/ComponentHangPopver.vue'
|
||||||
|
|
||||||
import { PluginComponent } from '@/components/plugin'
|
|
||||||
const snapshotStore = snapshotStoreWithOut()
|
const snapshotStore = snapshotStoreWithOut()
|
||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
const composeStore = composeStoreWithOut()
|
const composeStore = composeStoreWithOut()
|
||||||
@ -1492,7 +1491,7 @@ defineExpose({
|
|||||||
@linkageSetOpen="linkageSetOpen(item)"
|
@linkageSetOpen="linkageSetOpen(item)"
|
||||||
>
|
>
|
||||||
<!--如果是图表 则动态获取预存的chart-view数据-->
|
<!--如果是图表 则动态获取预存的chart-view数据-->
|
||||||
<PluginComponent
|
<!-- <PluginComponent
|
||||||
v-if="item['isPlugin']"
|
v-if="item['isPlugin']"
|
||||||
:jsname="item['pluginFlag'] || 'L2NvbXBvbmVudC9pbmRleA=='"
|
:jsname="item['pluginFlag'] || 'L2NvbXBvbmVudC9pbmRleA=='"
|
||||||
class="component"
|
class="component"
|
||||||
@ -1509,10 +1508,10 @@ defineExpose({
|
|||||||
@input="handleInput"
|
@input="handleInput"
|
||||||
:dv-info="dvInfo"
|
:dv-info="dvInfo"
|
||||||
:canvas-active="canvasActive"
|
:canvas-active="canvasActive"
|
||||||
/>
|
/> -->
|
||||||
<component
|
<component
|
||||||
:is="findComponent(item.component)"
|
:is="findComponent(item.component)"
|
||||||
v-else-if="item.component === 'UserView'"
|
v-if="item.component === 'UserView' || item['isPlugin']"
|
||||||
class="component"
|
class="component"
|
||||||
:id="'component' + item.id"
|
:id="'component' + item.id"
|
||||||
:active="item.id === curComponentId"
|
:active="item.id === curComponentId"
|
||||||
|
|||||||
@ -34,9 +34,9 @@ const generateRamStr = (len: number) => {
|
|||||||
|
|
||||||
const importProxy = (bytesArray: any[]) => {
|
const importProxy = (bytesArray: any[]) => {
|
||||||
const promise = import(
|
const promise = import(
|
||||||
`../../../../../../../${formatArray(bytesArray[6])}/${formatArray(bytesArray[7])}/${formatArray(
|
`../../../../../../../${formatArray(bytesArray[7])}/${formatArray(bytesArray[8])}/${formatArray(
|
||||||
bytesArray[8]
|
bytesArray[9]
|
||||||
)}/${formatArray(bytesArray[9])}/${formatArray(bytesArray[10])}.vue`
|
)}/${formatArray(bytesArray[10])}/${formatArray(bytesArray[11])}.vue`
|
||||||
)
|
)
|
||||||
promise
|
promise
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
@ -50,7 +50,7 @@ const importProxy = (bytesArray: any[]) => {
|
|||||||
|
|
||||||
const loadComponent = () => {
|
const loadComponent = () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const byteArray = wsCache.get(`de-plugin-proxy`)
|
const byteArray = wsCache.get(`de-plugin-proxy-plugin`)
|
||||||
if (byteArray) {
|
if (byteArray) {
|
||||||
importProxy(JSON.parse(byteArray))
|
importProxy(JSON.parse(byteArray))
|
||||||
loading.value = false
|
loading.value = false
|
||||||
@ -77,7 +77,7 @@ const storeCacheProxy = byteArray => {
|
|||||||
byteArray.forEach(item => {
|
byteArray.forEach(item => {
|
||||||
result.push([...item])
|
result.push([...item])
|
||||||
})
|
})
|
||||||
wsCache.set(`de-plugin-proxy`, JSON.stringify(result))
|
wsCache.set(`de-plugin-proxy-plugin`, JSON.stringify(result))
|
||||||
}
|
}
|
||||||
const pluginProxy = ref(null)
|
const pluginProxy = ref(null)
|
||||||
const invokeMethod = param => {
|
const invokeMethod = param => {
|
||||||
|
|||||||
4
core/core-frontend/src/models/chart/chart-plugin.d.ts
vendored
Normal file
4
core/core-frontend/src/models/chart/chart-plugin.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
declare interface ChartPlugin {
|
||||||
|
isPlugin: boolean
|
||||||
|
pluginResourceId?: string
|
||||||
|
}
|
||||||
@ -56,15 +56,18 @@ declare interface Chart {
|
|||||||
linkageActive: boolean
|
linkageActive: boolean
|
||||||
jumpActive: boolean
|
jumpActive: boolean
|
||||||
aggregate?: boolean
|
aggregate?: boolean
|
||||||
|
plugin?: CustomPlugin
|
||||||
}
|
}
|
||||||
declare type CustomAttr = DeepPartial<ChartAttr> | JSONString<DeepPartial<ChartAttr>>
|
declare type CustomAttr = DeepPartial<ChartAttr> | JSONString<DeepPartial<ChartAttr>>
|
||||||
declare type CustomStyle = DeepPartial<ChartStyle> | JSONString<DeepPartial<ChartStyle>>
|
declare type CustomStyle = DeepPartial<ChartStyle> | JSONString<DeepPartial<ChartStyle>>
|
||||||
declare type CustomSenior = DeepPartial<ChartSenior> | JSONString<DeepPartial<ChartSenior>>
|
declare type CustomSenior = DeepPartial<ChartSenior> | JSONString<DeepPartial<ChartSenior>>
|
||||||
|
declare type CustomPlugin = DeepPartial<ChartPlugin> | JSONString<DeepPartial<ChartPlugin>>
|
||||||
|
|
||||||
declare type ChartObj = Omit<Chart, 'customAttr' | 'customStyle' | 'senior'> & {
|
declare type ChartObj = Omit<Chart, 'customAttr' | 'customStyle' | 'senior' | 'plugin'> & {
|
||||||
customAttr: ChartAttr
|
customAttr: ChartAttr
|
||||||
customStyle: ChartStyle
|
customStyle: ChartStyle
|
||||||
senior: ChartSenior
|
senior: ChartSenior
|
||||||
|
plugin?: ChartPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { cloneDeep } from 'lodash'
|
|||||||
import { XpackComponent } from '@/components/plugin'
|
import { XpackComponent } from '@/components/plugin'
|
||||||
const modules = import.meta.glob('../views/**/*.vue')
|
const modules = import.meta.glob('../views/**/*.vue')
|
||||||
export const Layout = () => import('@/layout/index.vue')
|
export const Layout = () => import('@/layout/index.vue')
|
||||||
const pluginComponent = 'components/plugin'
|
const xpackComName = 'components/plugin'
|
||||||
// 后端控制路由生成
|
// 后端控制路由生成
|
||||||
export const generateRoutesFn2 = (routes: AppCustomRouteRecordRaw[]): AppRouteRecordRaw[] => {
|
export const generateRoutesFn2 = (routes: AppCustomRouteRecordRaw[]): AppRouteRecordRaw[] => {
|
||||||
const res: AppRouteRecordRaw[] = []
|
const res: AppRouteRecordRaw[] = []
|
||||||
@ -17,7 +17,7 @@ export const generateRoutesFn2 = (routes: AppCustomRouteRecordRaw[]): AppRouteRe
|
|||||||
|
|
||||||
if (route.plugin) {
|
if (route.plugin) {
|
||||||
const jsName = route.component
|
const jsName = route.component
|
||||||
route.component = pluginComponent
|
route.component = xpackComName
|
||||||
route.props = {
|
route.props = {
|
||||||
jsname: jsName,
|
jsname: jsName,
|
||||||
inLayout: route.inLayout
|
inLayout: route.inLayout
|
||||||
@ -35,7 +35,7 @@ export const generateRoutesFn2 = (routes: AppCustomRouteRecordRaw[]): AppRouteRe
|
|||||||
|
|
||||||
if (route.component) {
|
if (route.component) {
|
||||||
let comModule = null
|
let comModule = null
|
||||||
if (route.component === pluginComponent) {
|
if (route.component === xpackComName) {
|
||||||
comModule = XpackComponent
|
comModule = XpackComponent
|
||||||
} else {
|
} else {
|
||||||
comModule = modules[`../views/${route.component}/index.vue`]
|
comModule = modules[`../views/${route.component}/index.vue`]
|
||||||
|
|||||||
@ -383,7 +383,11 @@ export const dvMainStore = defineStore('dataVisualization', {
|
|||||||
...defaultConfig,
|
...defaultConfig,
|
||||||
id: component.id,
|
id: component.id,
|
||||||
type: component.innerType,
|
type: component.innerType,
|
||||||
render: component.render
|
render: component.render,
|
||||||
|
plugin: {
|
||||||
|
isPlugin: component.isPlugin,
|
||||||
|
pluginResourceId: component.pluginResourceId
|
||||||
|
}
|
||||||
} as unknown as ChartObj
|
} as unknown as ChartObj
|
||||||
// 处理配置项默认值,不同图表的同一配置项默认值不同
|
// 处理配置项默认值,不同图表的同一配置项默认值不同
|
||||||
const chartViewInstance = chartViewManager.getChartView(newView.render, newView.type)
|
const chartViewInstance = chartViewManager.getChartView(newView.render, newView.type)
|
||||||
|
|||||||
@ -260,6 +260,9 @@ const chartStyleShow = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const chartViewInstance = computed(() => {
|
const chartViewInstance = computed(() => {
|
||||||
|
if (view.value.render === 'highchart') {
|
||||||
|
return chartViewManager.getChartView('antv', view.value.type)
|
||||||
|
}
|
||||||
return chartViewManager.getChartView(view.value.render, view.value.type)
|
return chartViewManager.getChartView(view.value.render, view.value.type)
|
||||||
})
|
})
|
||||||
const showAxis = (axis: AxisType) => chartViewInstance.value?.axis?.includes(axis)
|
const showAxis = (axis: AxisType) => chartViewInstance.value?.axis?.includes(axis)
|
||||||
@ -1599,12 +1602,13 @@ const deleteChartFieldItem = id => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<plugin-component
|
<plugin-component
|
||||||
v-else-if="view?.isPlugin"
|
v-else-if="view.plugin?.isPlugin"
|
||||||
jsname="L2NvbXBvbmVudC9lZGl0b3IvaW5kZXg="
|
jsname="L2NvbXBvbmVudC9lZGl0b3IvaW5kZXg="
|
||||||
:view="view"
|
:view="view"
|
||||||
:dimension="state.dimension"
|
:dimension="state.dimension"
|
||||||
:quota="state.quota"
|
:quota="state.quota"
|
||||||
:themes="themes"
|
:themes="themes"
|
||||||
|
@update-chart-data="updateChartData"
|
||||||
/>
|
/>
|
||||||
<el-tabs
|
<el-tabs
|
||||||
v-else
|
v-else
|
||||||
|
|||||||
@ -754,7 +754,7 @@ const showActionIcons = computed(() => {
|
|||||||
<!--这里去渲染不同图库的图表-->
|
<!--这里去渲染不同图库的图表-->
|
||||||
<div v-if="chartAreaShow" style="flex: 1; overflow: hidden">
|
<div v-if="chartAreaShow" style="flex: 1; overflow: hidden">
|
||||||
<plugin-component
|
<plugin-component
|
||||||
v-if="view?.isPlugin"
|
v-if="view.plugin?.isPlugin"
|
||||||
jsname="L2NvbXBvbmVudC9pbmRleA=="
|
jsname="L2NvbXBvbmVudC9pbmRleA=="
|
||||||
:scale="scale"
|
:scale="scale"
|
||||||
:dynamic-area-id="dynamicAreaId"
|
:dynamic-area-id="dynamicAreaId"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user