mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
fix: 解决保存时候可能数据获取不完整的bug
This commit is contained in:
parent
f348038ff7
commit
55c84f2e39
@ -161,17 +161,17 @@ export const useChartEditStore = defineStore({
|
|||||||
},
|
},
|
||||||
getComponentList(): Array<CreateComponentType | CreateComponentGroupType> {
|
getComponentList(): Array<CreateComponentType | CreateComponentGroupType> {
|
||||||
return this.componentList
|
return this.componentList
|
||||||
},
|
}
|
||||||
// 获取需要存储的数据项
|
},
|
||||||
|
actions: {
|
||||||
|
// * 获取需要存储的数据项
|
||||||
getStorageInfo(): ChartEditStorage {
|
getStorageInfo(): ChartEditStorage {
|
||||||
return {
|
return {
|
||||||
[ChartEditStoreEnum.EDIT_CANVAS_CONFIG]: this.getEditCanvasConfig,
|
[ChartEditStoreEnum.EDIT_CANVAS_CONFIG]: this.getEditCanvasConfig,
|
||||||
[ChartEditStoreEnum.COMPONENT_LIST]: this.getComponentList,
|
[ChartEditStoreEnum.COMPONENT_LIST]: this.getComponentList,
|
||||||
[ChartEditStoreEnum.REQUEST_GLOBAL_CONFIG]: this.getRequestGlobalConfig
|
[ChartEditStoreEnum.REQUEST_GLOBAL_CONFIG]: this.getRequestGlobalConfig
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
|
||||||
actions: {
|
|
||||||
// * 设置 editCanvas 数据项
|
// * 设置 editCanvas 数据项
|
||||||
setEditCanvas<T extends keyof EditCanvasType, K extends EditCanvasType[T]>(key: T, value: K) {
|
setEditCanvas<T extends keyof EditCanvasType, K extends EditCanvasType[T]>(key: T, value: K) {
|
||||||
this.editCanvas[key] = value
|
this.editCanvas[key] = value
|
||||||
|
@ -19,14 +19,14 @@ export const syncData = () => {
|
|||||||
transformOrigin: 'center',
|
transformOrigin: 'center',
|
||||||
onPositiveCallback: () => {
|
onPositiveCallback: () => {
|
||||||
window['$message'].success('正在同步编辑器...')
|
window['$message'].success('正在同步编辑器...')
|
||||||
dispatchEvent(new CustomEvent(SavePageEnum.CHART, { detail: chartEditStore.getStorageInfo }))
|
dispatchEvent(new CustomEvent(SavePageEnum.CHART, { detail: chartEditStore.getStorageInfo() }))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 同步数据到预览页
|
// 同步数据到预览页
|
||||||
export const syncDataToPreview = () => {
|
export const syncDataToPreview = () => {
|
||||||
dispatchEvent(new CustomEvent(SavePageEnum.CHART_TO_PREVIEW, { detail: chartEditStore.getStorageInfo }))
|
dispatchEvent(new CustomEvent(SavePageEnum.CHART_TO_PREVIEW, { detail: chartEditStore.getStorageInfo() }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 侦听器更新
|
// 侦听器更新
|
||||||
|
@ -158,7 +158,7 @@ const editHandle = () => {
|
|||||||
|
|
||||||
// 把内存中的数据同步到SessionStorage 便于传递给新窗口初始化数据
|
// 把内存中的数据同步到SessionStorage 便于传递给新窗口初始化数据
|
||||||
const updateToSession = (id: string) => {
|
const updateToSession = (id: string) => {
|
||||||
const storageInfo = chartEditStore.getStorageInfo
|
const storageInfo = chartEditStore.getStorageInfo()
|
||||||
const sessionStorageInfo = getLocalStorage(StorageEnum.GO_CHART_STORAGE_LIST) || []
|
const sessionStorageInfo = getLocalStorage(StorageEnum.GO_CHART_STORAGE_LIST) || []
|
||||||
|
|
||||||
if (sessionStorageInfo?.length) {
|
if (sessionStorageInfo?.length) {
|
||||||
|
@ -1,41 +1,41 @@
|
|||||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
import { canvasCut, downloadTextFile, JSONStringify } from '@/utils'
|
import { canvasCut, downloadTextFile, JSONStringify } from '@/utils'
|
||||||
const chartEditStore = useChartEditStore()
|
const chartEditStore = useChartEditStore()
|
||||||
|
|
||||||
// 导出
|
// 导出
|
||||||
export const exportHandle = () => {
|
export const exportHandle = () => {
|
||||||
// 取消选中
|
// 取消选中
|
||||||
chartEditStore.setTargetSelectChart(undefined)
|
chartEditStore.setTargetSelectChart(undefined)
|
||||||
|
|
||||||
// 导出数据
|
// 导出数据
|
||||||
downloadTextFile(
|
downloadTextFile(
|
||||||
JSONStringify(chartEditStore.getStorageInfo || []),
|
JSONStringify(chartEditStore.getStorageInfo() || []),
|
||||||
undefined,
|
undefined,
|
||||||
'json'
|
'json'
|
||||||
)
|
)
|
||||||
|
|
||||||
// 导出图片
|
// 导出图片
|
||||||
const range = document.querySelector('.go-edit-range') as HTMLElement
|
const range = document.querySelector('.go-edit-range') as HTMLElement
|
||||||
const watermark = document.getElementById('go-edit-watermark')
|
const watermark = document.getElementById('go-edit-watermark')
|
||||||
// 隐藏边距线
|
// 隐藏边距线
|
||||||
if (!range || !watermark) {
|
if (!range || !watermark) {
|
||||||
window['$message'].error('导出失败!')
|
window['$message'].error('导出失败!')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 记录缩放比例
|
// 记录缩放比例
|
||||||
const scaleTemp = chartEditStore.getEditCanvas.scale
|
const scaleTemp = chartEditStore.getEditCanvas.scale
|
||||||
// 百分百展示页面
|
// 百分百展示页面
|
||||||
chartEditStore.setScale(1, true)
|
chartEditStore.setScale(1, true)
|
||||||
// 展示水印
|
// 展示水印
|
||||||
watermark.style.display = 'block'
|
watermark.style.display = 'block'
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
canvasCut(range, () => {
|
canvasCut(range, () => {
|
||||||
// 隐藏水印
|
// 隐藏水印
|
||||||
if (watermark) watermark.style.display = 'none'
|
if (watermark) watermark.style.display = 'none'
|
||||||
// 还原页面大小
|
// 还原页面大小
|
||||||
chartEditStore.setScale(scaleTemp, true)
|
chartEditStore.setScale(scaleTemp, true)
|
||||||
})
|
})
|
||||||
}, 600)
|
}, 600)
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ const previewHandle = () => {
|
|||||||
const { id } = routerParamsInfo.params
|
const { id } = routerParamsInfo.params
|
||||||
// id 标识
|
// id 标识
|
||||||
const previewId = typeof id === 'string' ? id : id[0]
|
const previewId = typeof id === 'string' ? id : id[0]
|
||||||
const storageInfo = chartEditStore.getStorageInfo
|
const storageInfo = chartEditStore.getStorageInfo()
|
||||||
const sessionStorageInfo = getLocalStorage(StorageEnum.GO_CHART_STORAGE_LIST) || []
|
const sessionStorageInfo = getLocalStorage(StorageEnum.GO_CHART_STORAGE_LIST) || []
|
||||||
|
|
||||||
if (sessionStorageInfo?.length) {
|
if (sessionStorageInfo?.length) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user