|
|
|
@ -1,5 +1,4 @@
|
|
|
|
|
import { ref, onMounted, onBeforeUnmount } from 'vue';
|
|
|
|
|
|
|
|
|
|
export function useAdaptation(handleChange) {
|
|
|
|
|
const mediaQuery = '(max-width: 768px)';
|
|
|
|
|
const currentDevice = ref(window.matchMedia(mediaQuery).matches ? 'mobile' : 'pc');
|
|
|
|
@ -12,8 +11,8 @@ export function useAdaptation(handleChange) {
|
|
|
|
|
|
|
|
|
|
const mediaQueryChangeHandler = event => {
|
|
|
|
|
const newDevice = event.matches ? 'mobile' : 'pc';
|
|
|
|
|
changeHandler(newDevice); // 使用钩子函数
|
|
|
|
|
currentDevice.value = newDevice; // 更新currentDevice值
|
|
|
|
|
changeHandler(newDevice);
|
|
|
|
|
currentDevice.value = newDevice;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let mediaQueryList;
|
|
|
|
|