Template
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
22 lines
563 B
TypeScript
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);
|
|
});
|
|
}
|