comboToken

This commit is contained in:
目棃
2025-03-12 17:47:04 +08:00
parent f842975f21
commit b504f043b4
7 changed files with 159 additions and 57 deletions

View File

@@ -107,9 +107,12 @@
<img src="/platforms/mhy/launcher.webp" alt="launcher" class="menu-icon" />
</template>
</v-list-item>
<v-list-item @click="tryCodeLogin(false)" append-icon="mdi-qrcode-scan" v-if="false">
<v-list-item @click="tryCodeLogin(false)">
<v-list-item-title>扫码登录(游戏)</v-list-item-title>
<v-list-item-subtitle>使用米游社扫码登录</v-list-item-subtitle>
<template #append>
<img src="/platforms/mhy/mys.webp" alt="launcher" class="menu-icon" />
</template>
</v-list-item>
</v-list>
</v-menu>
@@ -571,5 +574,6 @@ async function clearUser(user: TGApp.App.Account.User): Promise<void> {
.menu-icon {
width: 24px;
height: 24px;
border-radius: 4px;
}
</style>

View File

@@ -3,7 +3,20 @@
<div class="tog-box">
<div class="tog-top">
<div class="tog-title">请使用米游社进行扫码操作</div>
<div class="tog-select" v-if="!isLauncherCode">
<div
class="tog-select-item"
v-for="item in selects"
:key="item.value"
:class="{ active: codeGid === item.value }"
@click="codeGid = item.value"
:title="item.title"
>
<img :src="item.icon" alt="icon" />
</div>
</div>
</div>
<div class="tog-divider" />
<div class="tog-mid">
<qrcode-vue
v-if="codeUrl"
@@ -35,6 +48,20 @@ import passportReq from "@/web/request/passportReq.js";
import takumiReq from "@/web/request/takumiReq.js";
type ToGameLoginEmits = (e: "success", data: TGApp.App.Account.Cookie) => void;
type ToGameLoginSelect = { title: string; value: number; icon: string };
const selects: Array<ToGameLoginSelect> = [
{
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<boolean>({ default: false });
const isLauncherCode = defineModel<boolean>("launcher", { default: true });
const emits = defineEmits<ToGameLoginEmits>();
const codeGid = ref<number>(7);
const codeUrl = ref<string>();
const codeTicket = ref<string>("");
@@ -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<void> {
const shareDom = document.querySelector<HTMLDivElement>(".tog-box");
if (shareDom === null) {
@@ -83,7 +121,7 @@ async function freshQr(): Promise<void> {
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<void> {
}
async function cycleGetDataGame(): Promise<void> {
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<void> {
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%;