add vConsole debug
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="about-page">
|
||||
<section class="brand" v-entrance-transition>
|
||||
<logo />
|
||||
<logo @click="handleLogoClick" />
|
||||
<h1 v-text="appName" />
|
||||
<p v-text="appDescription" />
|
||||
</section>
|
||||
@@ -37,6 +37,7 @@ import { SettingAPI } from "timi-web-api";
|
||||
import Logo from "@/pages/user/component/Logo.vue";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { Message } from "@/utils/message";
|
||||
import { toggleVConsole } from "@/utils/vConsole";
|
||||
|
||||
type AgreementItem = {
|
||||
icon: string;
|
||||
@@ -55,6 +56,30 @@ const router = useRouter();
|
||||
const agreementItemList = ref<AgreementItem[]>([]);
|
||||
const isLoading = ref(false);
|
||||
|
||||
let debugClickCount = 0;
|
||||
let debugClickTimer: number | undefined;
|
||||
|
||||
async function handleLogoClick(): Promise<void> {
|
||||
debugClickCount++;
|
||||
if (debugClickTimer !== undefined) {
|
||||
window.clearTimeout(debugClickTimer);
|
||||
}
|
||||
debugClickTimer = window.setTimeout(() => {
|
||||
debugClickCount = 0;
|
||||
debugClickTimer = undefined;
|
||||
}, 1_500);
|
||||
|
||||
if (debugClickCount < 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
debugClickCount = 0;
|
||||
window.clearTimeout(debugClickTimer);
|
||||
debugClickTimer = undefined;
|
||||
|
||||
await toggleVConsole();
|
||||
}
|
||||
|
||||
async function openAgreement(item: AgreementItem): Promise<void> {
|
||||
await router.push({
|
||||
name: "Agreement",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user