fix:修复首页 dashboard echarts 页面变化导致的变性, 修复 vite.config.js 中 proxy 代理 https 时的 bug (#1623)

add : 添加 “@vueuse/core” 的依赖,添加全局 hooks (use-windows-resize)使用方法查看 dashboard 页面
This commit is contained in:
ipanghu
2024-01-15 13:10:42 +08:00
committed by GitHub
parent 756f73bbd2
commit d41394c70a
4 changed files with 45 additions and 12 deletions
+23
View File
@@ -0,0 +1,23 @@
// 监听 window 的 resize 事件,返回当前窗口的宽高
import { shallowRef } from 'vue'
import { tryOnMounted, useEventListener } from '@vueuse/core'
const width = shallowRef(0)
const height = shallowRef(0)
export const useWindowResize = (cb) => {
const onResize = () => {
width.value = window.innerWidth
height.value = window.innerHeight
if (cb && typeof cb === 'function') {
cb(width.value, height.value)
}
}
tryOnMounted(onResize)
useEventListener('resize', onResize, { passive: true })
return {
width,
height,
}
}