From b504f043b45d2588a86cee7d07c0d8da69e0882b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Wed, 12 Mar 2025 17:47:04 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20comboToken?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/pageConfig/tc-userBadge.vue | 6 +- src/components/pageConfig/tco-gameLogin.vue | 107 +++++++++++++++++--- src/pages/User/Scripts.vue | 31 ++++-- src/types/Game/Login.d.ts | 27 +++++ src/web/request/hk4eReq.ts | 8 +- src/web/request/takumiReq.ts | 35 ++----- src/web/utils/getRequestHeader.ts | 2 +- 7 files changed, 159 insertions(+), 57 deletions(-) diff --git a/src/components/pageConfig/tc-userBadge.vue b/src/components/pageConfig/tc-userBadge.vue index d75ea40f..d6122b10 100644 --- a/src/components/pageConfig/tc-userBadge.vue +++ b/src/components/pageConfig/tc-userBadge.vue @@ -107,9 +107,12 @@ launcher - + 扫码登录(游戏) 使用米游社扫码登录 + @@ -571,5 +574,6 @@ async function clearUser(user: TGApp.App.Account.User): Promise { .menu-icon { width: 24px; height: 24px; + border-radius: 4px; } diff --git a/src/components/pageConfig/tco-gameLogin.vue b/src/components/pageConfig/tco-gameLogin.vue index cdde2f53..c3d8f659 100644 --- a/src/components/pageConfig/tco-gameLogin.vue +++ b/src/components/pageConfig/tco-gameLogin.vue @@ -3,7 +3,20 @@
请使用米游社进行扫码操作
+
+
+ icon +
+
+
void; +type ToGameLoginSelect = { title: string; value: number; icon: string }; + +const selects: Array = [ + { + title: "未定事件簿", + value: 2, + icon: "/platforms/mhy/wd.webp", + }, + { + title: "崩坏学园2", + value: 7, + icon: "/platforms/mhy/bh2.webp", + }, +]; // eslint-disable-next-line no-undef let cycleTimer: NodeJS.Timeout | null = null; @@ -42,6 +69,7 @@ let cycleTimer: NodeJS.Timeout | null = null; const model = defineModel({ default: false }); const isLauncherCode = defineModel("launcher", { default: true }); const emits = defineEmits(); +const codeGid = ref(7); const codeUrl = ref(); const codeTicket = ref(""); @@ -55,7 +83,7 @@ watch( cycleTimer = null; } if (isLauncherCode.value) cycleTimer = setInterval(cycleGetDataLauncher, 1000); - else cycleTimer = setInterval(cycleGetDataGame, 5000); + else cycleTimer = setInterval(cycleGetDataGame, 1000); } else { if (cycleTimer) clearInterval(cycleTimer); cycleTimer = null; @@ -63,6 +91,16 @@ watch( }, ); +watch( + () => codeGid.value, + async () => { + if (isLauncherCode.value) return; + await freshQr(); + if (cycleTimer) clearInterval(cycleTimer); + cycleTimer = setInterval(cycleGetDataGame, 1000); + }, +); + async function share(): Promise { const shareDom = document.querySelector(".tog-box"); if (shareDom === null) { @@ -83,7 +121,7 @@ async function freshQr(): Promise { codeTicket.value = resp.ticket; return; } - const resp = await hk4eReq.loginQr.create(); + const resp = await hk4eReq.loginQr.create(codeGid.value); if ("retcode" in resp) { showSnackbar.error(`[${resp.retcode}] ${resp.message}`); return; @@ -125,7 +163,7 @@ async function cycleGetDataLauncher(): Promise { } async function cycleGetDataGame(): Promise { - const res = await hk4eReq.loginQr.state(codeTicket.value); + const res = await hk4eReq.loginQr.state(codeTicket.value, codeGid.value); console.log(res); if ("retcode" in res) { showSnackbar.error(`[${res.retcode}] ${res.message}`); @@ -150,23 +188,22 @@ async function cycleGetDataGame(): Promise { const statusRaw: TGApp.Game.Login.StatusPayloadRaw = JSON.parse(res.payload.raw); await showLoading.start("正在获取SToken"); const stResp = await takumiReq.game.stoken(statusRaw); - console.log(stResp); await showLoading.end(); if ("retcode" in stResp) { showSnackbar.error(`[${stResp.retcode}] ${stResp.message}`); model.value = false; return; } - // const ck: TGApp.App.Account.Cookie = { - // account_id: statusRaw.uid, - // ltuid: statusRaw.uid, - // stuid: statusRaw.uid, - // mid: res.user_info.mid, - // cookie_token: "", - // stoken: res.tokens[0].token, - // ltoken: "", - // }; - // emits("success", ck); + const ck: TGApp.App.Account.Cookie = { + account_id: statusRaw.uid, + ltuid: statusRaw.uid, + stuid: statusRaw.uid, + mid: stResp.user_info.mid, + cookie_token: "", + stoken: stResp.token.token, + ltoken: "", + }; + emits("success", ck); model.value = false; } } @@ -188,8 +225,13 @@ onUnmounted(() => { } .tog-top { - border-bottom: 1px solid var(--common-shadow-4); + position: relative; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; font-family: var(--font-title); + row-gap: 4px; text-align: center; } @@ -198,6 +240,41 @@ onUnmounted(() => { font-size: 20px; } +.tog-select { + position: relative; + display: flex; + align-items: center; + justify-content: center; + column-gap: 4px; +} + +.tog-select-item { + position: relative; + width: 36px; + height: 36px; + box-sizing: border-box; + border-radius: 4px; + cursor: pointer; + + &.active { + border: 3px solid var(--tgc-od-orange); + cursor: default; + } + + img { + width: 100%; + height: 100%; + border-radius: 4px; + object-fit: contain; + } +} + +.tog-divider { + width: 100%; + height: 1px; + background-color: var(--common-shadow-2); +} + .tog-mid { display: flex; width: 100%; diff --git a/src/pages/User/Scripts.vue b/src/pages/User/Scripts.vue index 8d25717a..765fd628 100644 --- a/src/pages/User/Scripts.vue +++ b/src/pages/User/Scripts.vue @@ -48,7 +48,7 @@ @@ -76,6 +76,7 @@ import { onMounted, ref, shallowRef } from "vue"; import { useUserStore } from "@/store/modules/user.js"; import apiHubReq from "@/web/request/apiHubReq.js"; +import miscReq from "@/web/request/miscReq.js"; const { uid, briefInfo, cookie, account } = storeToRefs(useUserStore()); const accounts = shallowRef>([]); @@ -119,21 +120,31 @@ async function tryCkVerify(): Promise { showSnackbar.cancel("已取消验证"); return; } - await showLoading.start("正在验证CK有效性"); const ck = { stoken: cookie.value.stoken, stuid: cookie.value.stuid, mid: cookie.value.mid, }; - const resp = await apiHubReq.sign(ck); - await showLoading.update(`[${resp.retcode}] ${resp.message}`); - if (resp.retcode === -100) { - showSnackbar.error("CK验证失败,请通过验证码登录重新获取CK"); - await showLoading.end(); - return; + let flag = false; + let challenge; + while (!flag) { + await showLoading.start("正在验证CK有效性"); + const resp = await apiHubReq.sign(ck, 2, challenge); + await showLoading.update(`[${resp.retcode}] ${resp.message}`); + if (resp.retcode === -100) { + await showLoading.end(); + break; + } else if (resp.retcode === 1034) { + await showLoading.end(); + const cGet = await miscReq.challenge(ck); + if (cGet !== false) challenge = cGet; + } else { + flag = true; + await showLoading.end(); + } } - await showLoading.end(); - showSnackbar.success("CK验证成功"); + if (!flag) showSnackbar.error("CK验证失败,请通过验证码登录重新获取CK"); + else showSnackbar.success("CK验证成功"); }