mirror of
https://gitee.com/dromara/go-view.git
synced 2026-05-12 00:00:01 +08:00
Merge branch 'dev' into master-fetch-dev
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div
|
||||
class="chart-item"
|
||||
v-for="(item, index) in localStorageInfo.componentList"
|
||||
v-for="(item, index) in chartEditStore.componentList"
|
||||
:class="animationsClass(item.styles.animations)"
|
||||
:key="item.id"
|
||||
:style="{
|
||||
@@ -52,30 +52,29 @@ import { useLifeHandler } from '@/hooks'
|
||||
const { initDataPond, clearMittDataPondMap } = useChartDataPondFetch()
|
||||
const chartEditStore = useChartEditStore()
|
||||
|
||||
const props = defineProps({
|
||||
localStorageInfo: {
|
||||
type: Object as PropType<ChartEditStorageType>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
// const props = defineProps({
|
||||
// localStorageInfo: {
|
||||
// type: Object as PropType<ChartEditStorageType>,
|
||||
// required: true
|
||||
// }
|
||||
// })
|
||||
|
||||
// 主题色
|
||||
const themeSetting = computed(() => {
|
||||
const chartThemeSetting = props.localStorageInfo.editCanvasConfig.chartThemeSetting
|
||||
const chartThemeSetting = chartEditStore.editCanvasConfig.chartThemeSetting
|
||||
return chartThemeSetting
|
||||
})
|
||||
|
||||
|
||||
// 配置项
|
||||
const themeColor = computed(() => {
|
||||
const colorCustomMergeData = colorCustomMerge(props.localStorageInfo.editCanvasConfig.chartCustomThemeColorInfo)
|
||||
return colorCustomMergeData[props.localStorageInfo.editCanvasConfig.chartThemeColor]
|
||||
const colorCustomMergeData = colorCustomMerge(chartEditStore.editCanvasConfig.chartCustomThemeColorInfo)
|
||||
return colorCustomMergeData[chartEditStore.editCanvasConfig.chartThemeColor]
|
||||
})
|
||||
|
||||
// 组件渲染结束初始化数据池
|
||||
clearMittDataPondMap()
|
||||
onMounted(() => {
|
||||
initDataPond(props.localStorageInfo.requestGlobalConfig)
|
||||
initDataPond(chartEditStore.requestGlobalConfig)
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
import { ref, onMounted, onUnmounted} from 'vue'
|
||||
import { ref, provide, onMounted, onUnmounted } from 'vue'
|
||||
import { usePreviewFitScale, usePreviewScrollYScale, usePreviewScrollXScale, usePreviewFullScale } from '@/hooks/index'
|
||||
import type { ChartEditStorageType } from '../index.d'
|
||||
import { PreviewScaleEnum } from '@/enums/styleEnum'
|
||||
|
||||
export const SCALE_KEY = 'scale-value'
|
||||
|
||||
export const useScale = (localStorageInfo: ChartEditStorageType) => {
|
||||
|
||||
const entityRef = ref()
|
||||
const previewRef = ref()
|
||||
const width = ref(localStorageInfo.editCanvasConfig.width)
|
||||
const height = ref(localStorageInfo.editCanvasConfig.height)
|
||||
const scaleRef = ref({ width: 1, height: 1 })
|
||||
|
||||
provide(SCALE_KEY, scaleRef);
|
||||
|
||||
const updateScaleRef = (scale: { width: number; height: number }) => {
|
||||
// 这里需要解构,保证赋值给scaleRef的为一个新对象
|
||||
// 因为scale始终为同一引用
|
||||
scaleRef.value = { ...scale }
|
||||
}
|
||||
|
||||
// 屏幕适配
|
||||
onMounted(() => {
|
||||
@@ -18,6 +29,7 @@ export const useScale = (localStorageInfo: ChartEditStorageType) => {
|
||||
width.value as number,
|
||||
height.value as number,
|
||||
previewRef.value,
|
||||
updateScaleRef
|
||||
)
|
||||
calcRate()
|
||||
windowResize()
|
||||
@@ -35,6 +47,7 @@ export const useScale = (localStorageInfo: ChartEditStorageType) => {
|
||||
const dom = entityRef.value
|
||||
dom.style.width = `${width.value * scale.width}px`
|
||||
dom.style.height = `${height.value * scale.height}px`
|
||||
updateScaleRef(scale)
|
||||
}
|
||||
)
|
||||
calcRate()
|
||||
@@ -54,6 +67,7 @@ export const useScale = (localStorageInfo: ChartEditStorageType) => {
|
||||
const dom = entityRef.value
|
||||
dom.style.width = `${width.value * scale.width}px`
|
||||
dom.style.height = `${height.value * scale.height}px`
|
||||
updateScaleRef(scale)
|
||||
}
|
||||
)
|
||||
calcRate()
|
||||
@@ -69,6 +83,7 @@ export const useScale = (localStorageInfo: ChartEditStorageType) => {
|
||||
width.value as number,
|
||||
height.value as number,
|
||||
previewRef.value,
|
||||
updateScaleRef
|
||||
)
|
||||
calcRate()
|
||||
windowResize()
|
||||
@@ -82,6 +97,7 @@ export const useScale = (localStorageInfo: ChartEditStorageType) => {
|
||||
|
||||
return {
|
||||
entityRef,
|
||||
previewRef
|
||||
previewRef,
|
||||
scaleRef
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ResultEnum } from '@/enums/httpEnum'
|
||||
import { StorageEnum } from '@/enums/storageEnum'
|
||||
import { ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
import { fetchProjectApi } from '@/api/path'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
|
||||
const chartEditStore = useChartEditStore()
|
||||
|
||||
export interface ChartEditStorageType extends ChartEditStorage {
|
||||
id: string
|
||||
@@ -31,6 +34,10 @@ export const getSessionStorageInfo = async () => {
|
||||
// 本地读取
|
||||
for (let i = 0; i < storageList.length; i++) {
|
||||
if (id.toString() === storageList[i]['id']) {
|
||||
const { editCanvasConfig, requestGlobalConfig, componentList } = storageList[i]
|
||||
chartEditStore.editCanvasConfig = editCanvasConfig
|
||||
chartEditStore.requestGlobalConfig = requestGlobalConfig
|
||||
chartEditStore.componentList = componentList
|
||||
return storageList[i]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user