Files
yx-react-template/src/utils/vconsole.ts
T
2026-08-18 13:39:42 +08:00

22 lines
563 B
TypeScript

/**
* vconsole 移动端调试工具
* 仅在开发环境的移动端启用
*/
function isMobileDevice() {
const userAgent = navigator.userAgent.toLowerCase();
const isMobileUA = /android|iphone|ipad|ipod|mobile/.test(userAgent);
const hasTouch = "ontouchstart" in window || navigator.maxTouchPoints > 0;
return isMobileUA || hasTouch;
}
if (import.meta.env.DEV && isMobileDevice()) {
void import("vconsole")
.then(({ default: VConsole }) => {
new VConsole();
})
.catch((error) => {
console.warn("[vconsole] failed to load", error);
});
}