mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
32 lines
706 B
TypeScript
32 lines
706 B
TypeScript
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
|
|
}
|
|
}
|