mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
feat: 预览采用pinia驱动
This commit is contained in:
parent
ccd5b8f0d0
commit
eccb39acad
@ -5,6 +5,7 @@
|
|||||||
组件 id:
|
组件 id:
|
||||||
<n-text>{{ targetData.id }}</n-text>
|
<n-text>{{ targetData.id }}</n-text>
|
||||||
</n-text>
|
</n-text>
|
||||||
|
<ChartEvebtInteraction></ChartEvebtInteraction>
|
||||||
<chart-event-base-handle></chart-event-base-handle>
|
<chart-event-base-handle></chart-event-base-handle>
|
||||||
<chart-event-advanced-handle></chart-event-advanced-handle>
|
<chart-event-advanced-handle></chart-event-advanced-handle>
|
||||||
</n-collapse>
|
</n-collapse>
|
||||||
@ -12,6 +13,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { ChartEvebtInteraction } from './components/ChartEvebtInteraction'
|
||||||
import { ChartEventAdvancedHandle } from './components/ChartEventAdvancedHandle'
|
import { ChartEventAdvancedHandle } from './components/ChartEventAdvancedHandle'
|
||||||
import { ChartEventBaseHandle } from './components/ChartEventBaseHandle'
|
import { ChartEventBaseHandle } from './components/ChartEventBaseHandle'
|
||||||
import { useTargetData } from '../hooks/useTargetData.hook'
|
import { useTargetData } from '../hooks/useTargetData.hook'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="chart-item"
|
class="chart-item"
|
||||||
v-for="(item, index) in localStorageInfo.componentList"
|
v-for="(item, index) in chartEditStore.componentList"
|
||||||
:class="animationsClass(item.styles.animations)"
|
:class="animationsClass(item.styles.animations)"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:style="{
|
:style="{
|
||||||
@ -52,30 +52,29 @@ import { useLifeHandler } from '@/hooks'
|
|||||||
const { initDataPond, clearMittDataPondMap } = useChartDataPondFetch()
|
const { initDataPond, clearMittDataPondMap } = useChartDataPondFetch()
|
||||||
const chartEditStore = useChartEditStore()
|
const chartEditStore = useChartEditStore()
|
||||||
|
|
||||||
const props = defineProps({
|
// const props = defineProps({
|
||||||
localStorageInfo: {
|
// localStorageInfo: {
|
||||||
type: Object as PropType<ChartEditStorageType>,
|
// type: Object as PropType<ChartEditStorageType>,
|
||||||
required: true
|
// required: true
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
|
|
||||||
// 主题色
|
// 主题色
|
||||||
const themeSetting = computed(() => {
|
const themeSetting = computed(() => {
|
||||||
const chartThemeSetting = props.localStorageInfo.editCanvasConfig.chartThemeSetting
|
const chartThemeSetting = chartEditStore.editCanvasConfig.chartThemeSetting
|
||||||
return chartThemeSetting
|
return chartThemeSetting
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// 配置项
|
// 配置项
|
||||||
const themeColor = computed(() => {
|
const themeColor = computed(() => {
|
||||||
const colorCustomMergeData = colorCustomMerge(props.localStorageInfo.editCanvasConfig.chartCustomThemeColorInfo)
|
const colorCustomMergeData = colorCustomMerge(chartEditStore.editCanvasConfig.chartCustomThemeColorInfo)
|
||||||
return colorCustomMergeData[props.localStorageInfo.editCanvasConfig.chartThemeColor]
|
return colorCustomMergeData[chartEditStore.editCanvasConfig.chartThemeColor]
|
||||||
})
|
})
|
||||||
|
|
||||||
// 组件渲染结束初始化数据池
|
// 组件渲染结束初始化数据池
|
||||||
clearMittDataPondMap()
|
clearMittDataPondMap()
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initDataPond(props.localStorageInfo.requestGlobalConfig)
|
initDataPond(chartEditStore.requestGlobalConfig)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="`go-preview ${localStorageInfo.editCanvasConfig.previewScaleType}`">
|
<div :class="`go-preview ${chartEditStore.editCanvasConfig.previewScaleType}`">
|
||||||
<template v-if="showEntity">
|
<template v-if="showEntity">
|
||||||
<!-- 实体区域 -->
|
<!-- 实体区域 -->
|
||||||
<div ref="entityRef" class="go-preview-entity">
|
<div ref="entityRef" class="go-preview-entity">
|
||||||
@ -8,7 +8,7 @@
|
|||||||
<!-- 展示层 -->
|
<!-- 展示层 -->
|
||||||
<div :style="previewRefStyle" v-if="show">
|
<div :style="previewRefStyle" v-if="show">
|
||||||
<!-- 渲染层 -->
|
<!-- 渲染层 -->
|
||||||
<preview-render-list :localStorageInfo="localStorageInfo"></preview-render-list>
|
<preview-render-list></preview-render-list>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -19,7 +19,7 @@
|
|||||||
<!-- 展示层 -->
|
<!-- 展示层 -->
|
||||||
<div :style="previewRefStyle" v-if="show">
|
<div :style="previewRefStyle" v-if="show">
|
||||||
<!-- 渲染层 -->
|
<!-- 渲染层 -->
|
||||||
<preview-render-list :localStorageInfo="localStorageInfo"></preview-render-list>
|
<preview-render-list></preview-render-list>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -36,25 +36,30 @@ import { useScale } from './hooks/useScale.hook'
|
|||||||
import { useStore } from './hooks/useStore.hook'
|
import { useStore } from './hooks/useStore.hook'
|
||||||
import { PreviewScaleEnum } from '@/enums/styleEnum'
|
import { PreviewScaleEnum } from '@/enums/styleEnum'
|
||||||
import type { ChartEditStorageType } from './index.d'
|
import type { ChartEditStorageType } from './index.d'
|
||||||
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
|
|
||||||
const localStorageInfo: ChartEditStorageType = getSessionStorageInfo() as ChartEditStorageType
|
// const localStorageInfo: ChartEditStorageType = getSessionStorageInfo() as ChartEditStorageType
|
||||||
setTitle(`预览-${localStorageInfo.editCanvasConfig.projectName}`)
|
|
||||||
|
const chartEditStore = useChartEditStore() as unknown as ChartEditStorageType
|
||||||
|
getSessionStorageInfo()
|
||||||
|
|
||||||
|
setTitle(`预览-${chartEditStore.editCanvasConfig.projectName}`)
|
||||||
|
|
||||||
const previewRefStyle = computed(() => {
|
const previewRefStyle = computed(() => {
|
||||||
return {
|
return {
|
||||||
...getEditCanvasConfigStyle(localStorageInfo.editCanvasConfig),
|
...getEditCanvasConfigStyle(chartEditStore.editCanvasConfig),
|
||||||
...getFilterStyle(localStorageInfo.editCanvasConfig)
|
...getFilterStyle(chartEditStore.editCanvasConfig)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const showEntity = computed(() => {
|
const showEntity = computed(() => {
|
||||||
const type = localStorageInfo.editCanvasConfig.previewScaleType
|
const type = chartEditStore.editCanvasConfig.previewScaleType
|
||||||
return type === PreviewScaleEnum.SCROLL_Y || type === PreviewScaleEnum.SCROLL_X
|
return type === PreviewScaleEnum.SCROLL_Y || type === PreviewScaleEnum.SCROLL_X
|
||||||
})
|
})
|
||||||
|
|
||||||
useStore(localStorageInfo)
|
useStore(chartEditStore)
|
||||||
const { entityRef, previewRef } = useScale(localStorageInfo)
|
const { entityRef, previewRef } = useScale(chartEditStore)
|
||||||
const { show } = useComInstall(localStorageInfo)
|
const { show } = useComInstall(chartEditStore)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import { getSessionStorage } from '@/utils'
|
import { getSessionStorage } from '@/utils'
|
||||||
import { StorageEnum } from '@/enums/storageEnum'
|
import { StorageEnum } from '@/enums/storageEnum'
|
||||||
import { ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d'
|
import { ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||||
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
|
|
||||||
|
const chartEditStore = useChartEditStore()
|
||||||
export interface ChartEditStorageType extends ChartEditStorage {
|
export interface ChartEditStorageType extends ChartEditStorage {
|
||||||
id: string
|
id: string
|
||||||
}
|
}
|
||||||
@ -16,11 +18,14 @@ export const getSessionStorageInfo = () => {
|
|||||||
StorageEnum.GO_CHART_STORAGE_LIST
|
StorageEnum.GO_CHART_STORAGE_LIST
|
||||||
)
|
)
|
||||||
|
|
||||||
if(!storageList) return
|
if (storageList) {
|
||||||
|
for (let i = 0; i < storageList.length; i++) {
|
||||||
for (let i = 0; i < storageList.length; i++) {
|
if (id.toString() === storageList[i]['id']) {
|
||||||
if (id.toString() === storageList[i]['id']) {
|
const { editCanvasConfig, requestGlobalConfig, componentList } = storageList[i]
|
||||||
return storageList[i]
|
chartEditStore.editCanvasConfig = editCanvasConfig
|
||||||
|
chartEditStore.requestGlobalConfig = requestGlobalConfig
|
||||||
|
chartEditStore.componentList = componentList
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user