|
|
@@ -5,64 +5,30 @@
|
|
|
<!-- 展示层 -->
|
|
|
<div :style="previewRefStyle" v-if="show">
|
|
|
<!-- 渲染层 -->
|
|
|
- <preview-render-list :localStorageInfo="localStorageInfo"></preview-render-list>
|
|
|
+ <preview-render-list
|
|
|
+ :localStorageInfo="localStorageInfo"
|
|
|
+ ></preview-render-list>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { onUnmounted, ref, nextTick, computed } from 'vue'
|
|
|
-import { usePreviewScale } from '@/hooks/index'
|
|
|
-import { PreviewRenderList } from './components/PreviewRenderList/index'
|
|
|
-import { ChartEditStorageType } from './index.d'
|
|
|
-import { useEditCanvasConfigStyle, getSessionStorageInfo } from './utils'
|
|
|
-import { CreateComponentType } from '@/packages/index.d'
|
|
|
-import { fetchChartComponent } from '@/packages/index'
|
|
|
-
|
|
|
-const previewRef = ref()
|
|
|
+import { computed } from 'vue'
|
|
|
+import { PreviewRenderList } from './components/PreviewRenderList'
|
|
|
+import { getEditCanvasConfigStyle, getSessionStorageInfo } from './utils'
|
|
|
+import { useComInstall } from './hooks/useComInstall.hook'
|
|
|
+import { useScale } from './hooks/useScale.hook'
|
|
|
+import type { ChartEditStorageType } from './index.d'
|
|
|
|
|
|
const localStorageInfo: ChartEditStorageType = getSessionStorageInfo() as ChartEditStorageType
|
|
|
|
|
|
-const width = ref(localStorageInfo?.editCanvasConfig.width)
|
|
|
-const height = ref(localStorageInfo?.editCanvasConfig.height)
|
|
|
-const show = ref(false)
|
|
|
-
|
|
|
const previewRefStyle: any = computed(() => {
|
|
|
- return useEditCanvasConfigStyle(localStorageInfo.editCanvasConfig)
|
|
|
+ return getEditCanvasConfigStyle(localStorageInfo.editCanvasConfig)
|
|
|
})
|
|
|
|
|
|
-// 注册组件(一开始无法获取window['$vue'])
|
|
|
-const intervalTiming = setInterval(() => {
|
|
|
- if (window['$vue'].component) {
|
|
|
- clearInterval(intervalTiming)
|
|
|
- show.value = true
|
|
|
- localStorageInfo.componentList.forEach(async (e: CreateComponentType) => {
|
|
|
- if (!window['$vue'].component(e.chartConfig.chartKey)) {
|
|
|
- window['$vue'].component(
|
|
|
- e.chartConfig.chartKey,
|
|
|
- fetchChartComponent(e.chartConfig)
|
|
|
- )
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-}, 200)
|
|
|
-
|
|
|
-// 屏幕适配
|
|
|
-nextTick(() => {
|
|
|
- const { calcRate, windowResize, unWindowResize } = usePreviewScale(
|
|
|
- width.value as number,
|
|
|
- height.value as number,
|
|
|
- previewRef.value
|
|
|
- )
|
|
|
-
|
|
|
- calcRate()
|
|
|
- windowResize()
|
|
|
-
|
|
|
- onUnmounted(() => {
|
|
|
- unWindowResize()
|
|
|
- })
|
|
|
-})
|
|
|
+const { previewRef } = useScale(localStorageInfo)
|
|
|
+const { show } = useComInstall(localStorageInfo)
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|