mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 08:12:49 +08:00
fix: 修改预览页面的报错问题
This commit is contained in:
parent
c35dd6fad9
commit
32762aa8a7
@ -55,8 +55,8 @@ getDataBySession()
|
|||||||
|
|
||||||
// 返回父窗口
|
// 返回父窗口
|
||||||
function back() {
|
function back() {
|
||||||
opener.name = Date.now()
|
window.opener.name = Date.now()
|
||||||
window.open(opener.location.href, opener.name)
|
window.open(window.opener.location.href, window.opener.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导入json文本
|
// 导入json文本
|
||||||
@ -71,7 +71,7 @@ async function importJSON() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 同步 [画布页失去焦点时同步数据到JSON页,JSON页Ctrl+S 时同步数据到画布页]
|
// 同步 [画布页失去焦点时同步数据到JSON页,JSON页Ctrl+S 时同步数据到画布页]
|
||||||
opener.addEventListener(SavePageEnum.CHART, (e: any) => {
|
window.opener.addEventListener(SavePageEnum.CHART, (e: any) => {
|
||||||
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [e.detail])
|
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [e.detail])
|
||||||
content.value = JSON.stringify(e.detail, undefined, 2)
|
content.value = JSON.stringify(e.detail, undefined, 2)
|
||||||
})
|
})
|
||||||
@ -87,14 +87,14 @@ addEventListener('blur', updateSync)
|
|||||||
|
|
||||||
// 同步更新
|
// 同步更新
|
||||||
function updateSync() {
|
function updateSync() {
|
||||||
if (!opener) {
|
if (!window.opener) {
|
||||||
return window['$message'].error('源窗口已关闭,视图同步失败')
|
return window['$message'].error('源窗口已关闭,视图同步失败')
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const detail = JSON.parse(content.value)
|
const detail = JSON.parse(content.value)
|
||||||
delete detail.id
|
delete detail.id
|
||||||
// 保持id不变
|
// 保持id不变
|
||||||
opener.dispatchEvent(new CustomEvent(SavePageEnum.JSON, { detail }))
|
window.opener.dispatchEvent(new CustomEvent(SavePageEnum.JSON, { detail }))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
window['$message'].error('内容格式有误')
|
window['$message'].error('内容格式有误')
|
||||||
console.log(e)
|
console.log(e)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<Preview :key="key"></Preview>
|
<preview :key="key"></preview>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -16,10 +16,10 @@ let localStorageInfo: ChartEditStorageType = getSessionStorageInfo() as ChartEdi
|
|||||||
|
|
||||||
// 数据变更 -> 同步sessionStorage -> reload页面 (重新执行Mounted)
|
// 数据变更 -> 同步sessionStorage -> reload页面 (重新执行Mounted)
|
||||||
;[SavePageEnum.JSON, SavePageEnum.CHART].forEach((saveEvent: string) => {
|
;[SavePageEnum.JSON, SavePageEnum.CHART].forEach((saveEvent: string) => {
|
||||||
opener.addEventListener(saveEvent, (e: any) => {
|
if (!window.opener) return
|
||||||
|
window.opener.addEventListener(saveEvent, (e: any) => {
|
||||||
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [{ ...e.detail, id: localStorageInfo.id }])
|
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [{ ...e.detail, id: localStorageInfo.id }])
|
||||||
key.value = Date.now()
|
key.value = Date.now()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
2
types/global.d.ts
vendored
2
types/global.d.ts
vendored
@ -7,6 +7,8 @@ interface Window {
|
|||||||
$vue: any
|
$vue: any
|
||||||
// 键盘按键记录
|
// 键盘按键记录
|
||||||
$KeyboardActive?: { [T: string]: boolean }
|
$KeyboardActive?: { [T: string]: boolean }
|
||||||
|
// 编辑 JSON 的存储对象
|
||||||
|
opener: any
|
||||||
}
|
}
|
||||||
|
|
||||||
declare type Recordable<T = any> = Record<string, T>
|
declare type Recordable<T = any> = Record<string, T>
|
||||||
|
Loading…
Reference in New Issue
Block a user