mirror of
https://gitee.com/dromara/go-view.git
synced 2026-05-12 00:00:01 +08:00
fix: 预览页改成hook写法
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { onUnmounted, ref, nextTick, computed } from 'vue'
|
||||
import { usePreviewScale } from '@/hooks/index'
|
||||
import type { ChartEditStorageType } from '..'
|
||||
|
||||
export const useScale = (localStorageInfo: ChartEditStorageType) => {
|
||||
|
||||
const previewRef = ref()
|
||||
|
||||
const width = ref(localStorageInfo?.editCanvasConfig.width)
|
||||
const height = ref(localStorageInfo?.editCanvasConfig.height)
|
||||
|
||||
// 屏幕适配
|
||||
nextTick(() => {
|
||||
const { calcRate, windowResize, unWindowResize } = usePreviewScale(
|
||||
width.value as number,
|
||||
height.value as number,
|
||||
previewRef.value
|
||||
)
|
||||
|
||||
calcRate()
|
||||
windowResize()
|
||||
|
||||
onUnmounted(() => {
|
||||
unWindowResize()
|
||||
})
|
||||
})
|
||||
|
||||
return {
|
||||
previewRef
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user