add vConsole debug

This commit is contained in:
Timi
2026-09-22 15:41:28 +08:00
parent 5465fb7b27
commit e35a76437b
4 changed files with 86 additions and 1 deletions
+30
View File
@@ -0,0 +1,30 @@
import type VConsole from "vconsole";
let vConsoleInstance: VConsole | undefined;
let isVConsoleLoading = false;
/**
* 切换移动端调试控制台。
*/
export async function toggleVConsole(): Promise<void> {
if (vConsoleInstance) {
vConsoleInstance.destroy();
vConsoleInstance = undefined;
console.warn("[调试] vConsole 已关闭");
return;
}
if (isVConsoleLoading) {
return;
}
isVConsoleLoading = true;
try {
const { default: VConsole } = await import("vconsole");
vConsoleInstance = new VConsole();
console.warn("[调试] vConsole 已启用");
} catch (error) {
console.error("[调试] vConsole 启用失败", error);
} finally {
isVConsoleLoading = false;
}
}