|
|
@@ -14,29 +14,12 @@
|
|
|
<script setup lang="ts">
|
|
|
import { onUnmounted, ref, nextTick, computed } from 'vue'
|
|
|
import { usePreviewScale } from '@/hooks/index'
|
|
|
-import { getLocalStorage, fetchRouteParams } from '@/utils'
|
|
|
-import { StorageEnum } from '@/enums/storageEnum'
|
|
|
import { RenderList } from './components/RenderList/index'
|
|
|
import { ChartEditStorageType } from './index.d'
|
|
|
+import { getLocalStorageInfo } from './utils/index'
|
|
|
|
|
|
const previewRef = ref()
|
|
|
|
|
|
-const getLocalStorageInfo: () => ChartEditStorageType | undefined = () => {
|
|
|
- const routeParamsRes = fetchRouteParams()
|
|
|
- if (!routeParamsRes) return
|
|
|
- const { id } = routeParamsRes
|
|
|
-
|
|
|
- const storageList: ChartEditStorageType[] = getLocalStorage(
|
|
|
- StorageEnum.GO_CHART_STORAGE_LIST
|
|
|
- )
|
|
|
-
|
|
|
- for (let i = 0; i < storageList.length; i++) {
|
|
|
- if (id.toString() === storageList[i]['id']) {
|
|
|
- return storageList[i]
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
const localStorageInfo: ChartEditStorageType = getLocalStorageInfo() as ChartEditStorageType
|
|
|
|
|
|
const width = ref(localStorageInfo?.editCanvasConfig.width)
|
|
|
@@ -45,8 +28,8 @@ const height = ref(localStorageInfo?.editCanvasConfig.height)
|
|
|
const previewRefStyle = computed(() => {
|
|
|
return {
|
|
|
position: 'relative',
|
|
|
- width: width.value? `${width.value || 100}px` : '100%',
|
|
|
- height: height.value? `${height.value}px` : '100%',
|
|
|
+ width: width.value ? `${width.value || 100}px` : '100%',
|
|
|
+ height: height.value ? `${height.value}px` : '100%',
|
|
|
border: '1px solid red'
|
|
|
}
|
|
|
})
|
|
|
@@ -56,7 +39,11 @@ if (!localStorageInfo) {
|
|
|
}
|
|
|
|
|
|
nextTick(() => {
|
|
|
- const { calcRate, windowResize, unWindowResize } = usePreviewScale(width.value as number, height.value as number, previewRef.value)
|
|
|
+ const { calcRate, windowResize, unWindowResize } = usePreviewScale(
|
|
|
+ width.value as number,
|
|
|
+ height.value as number,
|
|
|
+ previewRef.value
|
|
|
+ )
|
|
|
|
|
|
calcRate()
|
|
|
windowResize()
|
|
|
@@ -65,11 +52,10 @@ nextTick(() => {
|
|
|
unWindowResize()
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-@include go("preview") {
|
|
|
+@include go('preview') {
|
|
|
position: relative;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
@@ -77,6 +63,6 @@ nextTick(() => {
|
|
|
height: 100vh;
|
|
|
width: 100vw;
|
|
|
overflow: hidden;
|
|
|
- @include background-image("background-image");
|
|
|
+ @include background-image('background-image');
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|