add vConsole trigger for login index
This commit is contained in:
@@ -48,7 +48,7 @@ import { SettingAPI } from "timi-web-api";
|
|||||||
import Logo from "@/pages/user/component/Logo.vue";
|
import Logo from "@/pages/user/component/Logo.vue";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { toggleVConsole } from "@/utils/vConsole";
|
import { createVConsoleClickHandler, toggleVConsole } from "@/utils/vConsole";
|
||||||
|
|
||||||
type AgreementItem = {
|
type AgreementItem = {
|
||||||
icon: string;
|
icon: string;
|
||||||
@@ -67,29 +67,7 @@ const router = useRouter();
|
|||||||
const agreementItemList = ref<AgreementItem[]>([]);
|
const agreementItemList = ref<AgreementItem[]>([]);
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
|
||||||
let debugClickCount = 0;
|
const handleLogoClick = createVConsoleClickHandler(toggleVConsole);
|
||||||
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> {
|
async function openAgreement(item: AgreementItem): Promise<void> {
|
||||||
await router.push({
|
await router.push({
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div class="login-page diselect">
|
<div class="login-page diselect">
|
||||||
<section class="login-panel">
|
<section class="login-panel">
|
||||||
<div class="brand">
|
<div class="brand">
|
||||||
<logo v-entrance-transition />
|
<logo v-entrance-transition @click="handleLogoClick" />
|
||||||
<h1 v-entrance-transition>糕店客户管理</h1>
|
<h1 v-entrance-transition>糕店客户管理</h1>
|
||||||
</div>
|
</div>
|
||||||
<t-segmented
|
<t-segmented
|
||||||
@@ -23,6 +23,7 @@ import PasswordLogin from "@/pages/user/component/PasswordLogin.vue";
|
|||||||
import SmsLogin from "@/pages/user/component/SmsLogin.vue";
|
import SmsLogin from "@/pages/user/component/SmsLogin.vue";
|
||||||
import Logo from "@/pages/user/component/Logo.vue";
|
import Logo from "@/pages/user/component/Logo.vue";
|
||||||
import UserAgreement from "@/pages/user/component/UserAgreement.vue";
|
import UserAgreement from "@/pages/user/component/UserAgreement.vue";
|
||||||
|
import { createVConsoleClickHandler, enableVConsole } from "@/utils/vConsole";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "LoginIndex"
|
name: "LoginIndex"
|
||||||
@@ -36,6 +37,10 @@ const loginTypeOptions = [
|
|||||||
{ value: "password" as LoginType, label: "密码登录" },
|
{ value: "password" as LoginType, label: "密码登录" },
|
||||||
{ value: "sms" as LoginType, label: "短信登录" }
|
{ value: "sms" as LoginType, label: "短信登录" }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// ---------- 调试控制台 ----------
|
||||||
|
const handleLogoClick = createVConsoleClickHandler(enableVConsole);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|||||||
+31
-1
@@ -13,7 +13,14 @@ export async function toggleVConsole(): Promise<void> {
|
|||||||
console.warn("[调试] vConsole 已关闭");
|
console.warn("[调试] vConsole 已关闭");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isVConsoleLoading) {
|
await enableVConsole();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用移动端调试控制台。
|
||||||
|
*/
|
||||||
|
export async function enableVConsole(): Promise<void> {
|
||||||
|
if (vConsoleInstance || isVConsoleLoading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,3 +35,26 @@ export async function toggleVConsole(): Promise<void> {
|
|||||||
isVConsoleLoading = false;
|
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