Merge branch 'dev' into dev-commet

This commit is contained in:
tnt group
2022-11-07 08:25:07 +08:00
12 changed files with 104 additions and 36 deletions
@@ -14,7 +14,7 @@
@collapse="collapsedHandle"
@expand="expandHandle"
>
<content-box class="go-content-layers go-boderbox" :show-top="false" :depth="2">
<content-box class="go-content-configurations go-boderbox" :show-top="false" :depth="2">
<!-- 页面配置 -->
<n-tabs v-if="!selectTarget" class="tabs-box" size="small" type="segment">
<n-tab-pane
@@ -160,7 +160,7 @@ const chartsTabList = [
</script>
<style lang="scss" scoped>
@include go(content-layers) {
@include go(content-configurations) {
overflow: hidden;
.tabs-box {
padding: 10px;
@@ -12,14 +12,18 @@
</template>
<script setup lang="ts">
import { ref, toRefs, computed, watch } from 'vue'
import { ref, toRefs, computed, watch, nextTick, onBeforeUnmount } from 'vue'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { useDesignStore } from '@/store/modules/designStore/designStore'
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
const chartEditStore = useChartEditStore()
const chartLayoutStore = useChartLayoutStore()
const designStore = useDesignStore()
const { width, height } = toRefs(chartEditStore.getEditCanvasConfig)
const { scale, lockScale } = toRefs(chartEditStore.getEditCanvas)
const { getLayers, getCharts, getDetails } = toRefs(chartLayoutStore)
const configShow = ref(true)
@@ -49,25 +53,47 @@ const canvasBox = () => {
}
}
const scale = computed(() => {
return chartEditStore.getEditCanvas.scale
})
// 颜色
const themeColor = computed(() => {
return designStore.getAppTheme
})
// 处理标尺重制大小
const ruleChangeHandle = () => {
configShow.value = false
setTimeout(() => {
configShow.value = true
})
}
const ruleChangeHandleTimeOut = () => {
if (lockScale.value) {
setTimeout(() => {
ruleChangeHandle()
}, 500)
}
}
watch(
() => scale.value,
() => {
configShow.value = false
setTimeout(() => {
configShow.value = true
})
}
() => ruleChangeHandle()
)
watch(
() => getLayers.value,
() => ruleChangeHandleTimeOut()
)
watch(
() => getCharts.value,
() => ruleChangeHandleTimeOut()
)
watch(
() => getDetails.value,
() => ruleChangeHandleTimeOut()
)
</script>
<style>
+5 -5
View File
@@ -55,8 +55,8 @@ getDataBySession()
// 返回父窗口
function back() {
opener.name = Date.now()
window.open(opener.location.href, opener.name)
window.opener.name = Date.now()
window.open(window.opener.location.href, window.opener.name)
}
// 导入json文本
@@ -71,7 +71,7 @@ async function importJSON() {
}
// 同步 [画布页失去焦点时同步数据到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])
content.value = JSON.stringify(e.detail, undefined, 2)
})
@@ -87,14 +87,14 @@ addEventListener('blur', updateSync)
// 同步更新
function updateSync() {
if (!opener) {
if (!window.opener) {
return window['$message'].error('源窗口已关闭,视图同步失败')
}
try {
const detail = JSON.parse(content.value)
delete detail.id
// 保持id不变
opener.dispatchEvent(new CustomEvent(SavePageEnum.JSON, { detail }))
window.opener.dispatchEvent(new CustomEvent(SavePageEnum.JSON, { detail }))
} catch (e) {
window['$message'].error('内容格式有误')
console.log(e)
+3 -3
View File
@@ -1,5 +1,5 @@
<template>
<Preview :key="key"></Preview>
<preview :key="key"></preview>
</template>
<script setup lang="ts">
@@ -16,10 +16,10 @@ let localStorageInfo: ChartEditStorageType = getSessionStorageInfo() as ChartEdi
// 数据变更 -> 同步sessionStorage -> reload页面 (重新执行Mounted
;[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 }])
key.value = Date.now()
})
})
</script>