tapi/z_ele/src/utils/use-body-resize.ts
u2nyakim 78cbfb21d5 up.
2025-08-22 10:46:24 +08:00

22 lines
475 B
TypeScript

import { watch } from 'vue';
import { storeToRefs } from 'pinia';
import { useThemeStore } from '@/store/modules/theme';
/**
* 主体区尺寸改变hook
* @param hook 改变回调
*/
export function useBodyResize(hook: Function) {
if (!hook) {
return;
}
const themeStore = useThemeStore();
const { contentWidth } = storeToRefs(themeStore);
watch(contentWidth, (value, oldValue) => {
if (value != null && oldValue != null) {
hook();
}
});
}