add vConsole trigger for login index

This commit is contained in:
Timi
2026-11-05 16:51:01 +08:00
parent 59af9763a9
commit a204dd3211
3 changed files with 39 additions and 26 deletions
+31 -1
View File
@@ -13,7 +13,14 @@ export async function toggleVConsole(): Promise<void> {
console.warn("[调试] vConsole 已关闭");
return;
}
if (isVConsoleLoading) {
await enableVConsole();
}
/**
* 启用移动端调试控制台。
*/
export async function enableVConsole(): Promise<void> {
if (vConsoleInstance || isVConsoleLoading) {
return;
}
@@ -28,3 +35,26 @@ export async function toggleVConsole(): Promise<void> {
isVConsoleLoading = false;
}
}
/**
* 创建连续点击五次后执行的处理函数。
*/
export function createVConsoleClickHandler(action: () => Promise<void>): () => Promise<void> {
let clickCount = 0;
let lastClickTime = 0;
return async () => {
const now = Date.now();
if (1_500 < now - lastClickTime) {
clickCount = 0;
}
lastClickTime = now;
clickCount++;
if (clickCount < 5) {
return;
}
clickCount = 0;
await action();
};
}