From d50cb960f8dedadda19945f081b4bb287718b28f Mon Sep 17 00:00:00 2001 From: BTMuli Date: Fri, 29 Dec 2023 15:46:24 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E6=89=AB=E7=A0=81=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit *修复暗色模式无法识别二维码的问题 *扫码成功后自动刷新数据 *清除无用代码 --- src/components/overlay/to-gameLogin.vue | 37 ++++++++++--------------- src/pages/common/Config.vue | 7 ++++- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/components/overlay/to-gameLogin.vue b/src/components/overlay/to-gameLogin.vue index 332ef9d3..ae031780 100644 --- a/src/components/overlay/to-gameLogin.vue +++ b/src/components/overlay/to-gameLogin.vue @@ -6,7 +6,13 @@
所需米游社版本 >= 2.57.1
- +
@@ -26,7 +32,10 @@ interface ToWebLoginProps { modelValue: boolean; } -type ToWebLoginEmits = (e: "update:modelValue", value: boolean) => void; +type ToWebLoginEmits = { + (e: "update:modelValue", value: boolean): void; + (e: "success"): void; +}; const props = withDefaults(defineProps(), { modelValue: false, @@ -40,7 +49,6 @@ const visible = computed({ emits("update:modelValue", value); }, }); -const isCycle = ref(false); let cycleTimer: NodeJS.Timeout | null = null; const qrCode = ref(""); @@ -61,7 +69,6 @@ const userStore = storeToRefs(useUserStore()); watch(visible, async (value) => { if (value) { await freshQr(); - isCycle.value = true; cycleTimer = setInterval(cycleGetData, 1000); } }); @@ -97,10 +104,7 @@ async function freshQr(): Promise { } async function cycleGetData() { - if (!isCycle.value) { - if (cycleTimer) clearInterval(cycleTimer); - return; - } + if (cycleTimer === null) return; const res = await Mys.User.getData(ticket.value); console.log(res); if ("retcode" in res) { @@ -113,7 +117,6 @@ async function cycleGetData() { await freshQr(); } else { // 取消轮询 - isCycle.value = false; if (cycleTimer) clearInterval(cycleTimer); visible.value = false; } @@ -124,7 +127,6 @@ async function cycleGetData() { } if (res.stat === "Confirmed") { // 取消轮询 - isCycle.value = false; if (cycleTimer) clearInterval(cycleTimer); const data: TGApp.Plugins.Mys.GameLogin.StatusPayloadRaw = JSON.parse(res.payload.raw); cookie.account_id = data.uid; @@ -137,6 +139,9 @@ async function cycleGetData() { color: "success", }); visible.value = false; + setTimeout(() => { + emits("success"); + }, 1000); } } @@ -160,7 +165,6 @@ async function getTokens(): Promise { } onUnmounted(() => { - isCycle.value = false; if (cycleTimer) clearInterval(cycleTimer); }); @@ -207,15 +211,4 @@ onUnmounted(() => { width: 256px; height: 256px; } - -.tog-bottom { - display: flex; - align-items: center; - justify-content: space-between; -} - -.tog-btn { - background: var(--tgc-btn-1); - color: var(--btn-text); -} diff --git a/src/pages/common/Config.vue b/src/pages/common/Config.vue index 1734e42e..6e13ccd5 100644 --- a/src/pages/common/Config.vue +++ b/src/pages/common/Config.vue @@ -1,6 +1,6 @@