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 @@
-
+
@@ -263,6 +263,11 @@ async function confirmRefreshUser(): Promise {
});
return;
}
+ await refreshUser();
+}
+
+// 刷新用户信息
+async function refreshUser(): Promise {
const ck = userStore.cookie.value;
if (ck === undefined || JSON.stringify(ck) === "{}") {
showSnackbar({