17 lines
604 B
TypeScript
17 lines
604 B
TypeScript
|
|
import { computed } from "vue";
|
|||
|
|
import { useWindowSize } from "@vueuse/core";
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 小于 768px:适配移动设备(如手机)。
|
|||
|
|
* 768px - 1024px:适配平板设备。
|
|||
|
|
* 大于 1024px:适配桌面设备。
|
|||
|
|
* @returns PC窗口isPc, 平板窗口isPad, 移动端窗口isMobile
|
|||
|
|
*/
|
|||
|
|
export const useDevicesSize = () => {
|
|||
|
|
const { width } = useWindowSize();
|
|||
|
|
const isPc = computed(() => width.value > 1024);
|
|||
|
|
const isPad = computed(() => width.value > 768 && width.value <= 1024);
|
|||
|
|
const isMobile = computed(() => width.value <= 768);
|
|||
|
|
return { isPc, isPad, isMobile };
|
|||
|
|
};
|