add vConsole trigger for login index
This commit is contained in:
+31
-1
@@ -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();
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user