🚸 1034验证

This commit is contained in:
BTMuli
2026-05-07 21:14:56 +08:00
parent f13e6aab04
commit 845208c180
2 changed files with 72 additions and 21 deletions

View File

@@ -53,6 +53,7 @@
<script lang="ts" setup>
import showSnackbar from "@comp/func/snackbar.js";
import lunaReq from "@req/lunaReq.js";
import miscReq from "@req/miscReq.js";
import recordReq from "@req/recordReq.js";
import TSUserAccount from "@Sqlm/userAccount.js";
import useAppStore from "@store/app.js";
@@ -98,6 +99,61 @@ const signAccounts = ref<Array<SignAccount>>([]);
const currentGameUid = computed(() => account.value?.gameUid || "");
/**
* 构建验证用的签名 Cookie
* @since Beta v0.10.2
*/
function buildSignCookie(): Record<string, string> {
return {
stoken: cookie.value!.stoken,
stuid: cookie.value!.stuid,
mid: cookie.value!.mid,
};
}
/**
* 获取实时便笺数据(含 1034 验证处理)
* @since Beta v0.10.2
* @param acc - 游戏账号
* @param shouldVerifyCaptcha - 是否触发验证(单账号或手动刷新时为 true
* @returns 便笺数据,验证失败或错误时返回 undefined
*/
async function fetchDailyNoteWithCaptcha(
acc: TGApp.Sqlite.Account.Game,
shouldVerifyCaptcha: boolean,
): Promise<TGApp.Game.DailyNote.DnRes | undefined> {
const dataResp = await recordReq.daily(cookie.value!, acc);
if (dataResp.retcode === 0) return dataResp.data;
if (dataResp.retcode !== 1034) {
await TGLogger.Warn(
`[Game Status Card] ${acc.gameBiz}: [${dataResp.retcode}] ${dataResp.message}`,
);
return;
}
if (!shouldVerifyCaptcha) {
showSnackbar.warn(`${acc.nickname} 便笺数据需要验证`);
await TGLogger.Warn(
`[Game Status Card] ${acc.gameBiz}: [1034] 需要验证账号数量大于1跳过验证`,
);
return;
}
await TGLogger.Info("[Game Status Card] Captcha required for daily note");
const challengeGet = await miscReq.challenge(buildSignCookie());
if (challengeGet === false) {
showSnackbar.error("验证码验证失败");
await TGLogger.Warn(`[Game Status Card] ${acc.gameBiz}: [1034] 验证码验证失败`);
return;
}
const retryResp = await recordReq.daily(cookie.value!, acc, challengeGet);
if (retryResp.retcode !== 0) {
await TGLogger.Warn(
`[Game Status Card] ${acc.gameBiz}: [${retryResp.retcode}] ${retryResp.message}`,
);
return;
}
return retryResp.data;
}
const sortedDailyNoteAccounts = computed(() => {
if (!currentGameUid.value) return dailyNoteAccounts.value;
return [...dailyNoteAccounts.value].sort((a, b) => {
@@ -168,21 +224,14 @@ async function loadDailyNoteData(): Promise<void> {
}
loadingDailyNote.value = true;
loadingProgress.value = 0;
const isSingleAccount = genshinAccounts.length === 1;
for (let i = 0; i < genshinAccounts.length; i++) {
const acc = genshinAccounts[i];
loadingText.value = `正在加载 ${acc.gameBiz} - ${acc.regionName} - ${acc.gameUid}...`;
loadingProgress.value = (i / genshinAccounts.length) * 100;
let data: TGApp.Game.DailyNote.DnRes | undefined;
let dataResp: TGApp.Game.DailyNote.DnResp | undefined;
try {
dataResp = await recordReq.daily(cookie.value, acc);
if (dataResp.retcode !== 0) {
await TGLogger.Warn(
`[Note Sign Card] ${acc.gameBiz}: [${dataResp.retcode}] ${dataResp.message}`,
);
} else {
data = dataResp.data;
}
data = await fetchDailyNoteWithCaptcha(acc, isSingleAccount);
} catch (e) {
const errMsg = TGHttps.getErrMsg(e);
await TGLogger.Error(`[Game Status Card] ${acc.gameBiz}: ${errMsg}`);
@@ -264,15 +313,9 @@ async function endLoadSign(): Promise<void> {
}
async function handleRefreshDailyNote(acc: TGApp.Sqlite.Account.Game): Promise<void> {
let dataResp: TGApp.Game.DailyNote.DnResp | undefined;
let data: TGApp.Game.DailyNote.DnRes | undefined;
try {
dataResp = await recordReq.daily(cookie.value!, acc);
console.debug(dataResp);
if (dataResp.retcode !== 0) {
await TGLogger.Warn(`[Game Status Card] [${dataResp.retcode}] ${dataResp.message}`);
showSnackbar.error(`刷新失败:[${dataResp.retcode}] ${dataResp.message}`);
return;
}
data = await fetchDailyNoteWithCaptcha(acc, true);
} catch (e) {
const errMsg = TGHttps.getErrMsg(e);
await TGLogger.Error(`[Game Status Card] 刷新失败:${errMsg}`);
@@ -280,11 +323,15 @@ async function handleRefreshDailyNote(acc: TGApp.Sqlite.Account.Game): Promise<v
showSnackbar.error(`刷新失败:${errMsg}`);
return;
}
if (!data) {
showSnackbar.error("刷新失败");
return;
}
const item = dailyNoteAccounts.value.find(
(i) => i.account.gameUid === acc.gameUid && i.account.gameBiz === acc.gameBiz,
);
if (item) {
item.data = dataResp.data;
item.data = data;
}
showSnackbar.success("刷新成功");
}

View File

@@ -1,6 +1,6 @@
/**
* TakumiRecordGenshinApi 相关请求
* @since Beta v0.10.1
* @since Beta v0.10.2
*/
import gameEnum from "@enum/game.js";
@@ -221,19 +221,23 @@ async function actCalendar(
/**
* 获取实时便笺
* @since Beta v0.10.1
* @since Beta v0.10.2
* @param cookie - Cookie
* @param user - 用户
* @param challenge - 极验验证信息(可选)
* @returns 实时便笺响应数据
*/
async function dailyNote(
cookie: TGApp.App.Account.Cookie,
user: TGApp.Sqlite.Account.Game,
challenge?: string,
): Promise<TGApp.Game.DailyNote.DnResp> {
const ck = { account_id: cookie.account_id, cookie_token: cookie.cookie_token };
const params = { role_id: user.gameUid, server: user.region };
const headers = getRequestHeader(ck, "GET", params);
if (challenge) headers["x-rpc-challenge"] = challenge;
const resp = await TGHttps.get<TGApp.Game.DailyNote.DnResp>(`${trgAbu}dailyNote`, {
headers: getRequestHeader(ck, "GET", params),
headers,
query: params,
});
return resp.data;