mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-04-22 21:59:49 +08:00
♻️ 迁移剩余请求
This commit is contained in:
@@ -461,7 +461,7 @@ async function tryGetTokens(ck: TGApp.App.Account.Cookie): Promise<void> {
|
||||
try {
|
||||
const briefRes = await bbsReq.userInfo(ck);
|
||||
console.debug(briefRes);
|
||||
if ("retcode" in briefRes) {
|
||||
if (briefRes.retcode !== 0) {
|
||||
await showLoading.end();
|
||||
showSnackbar.error(`[${briefRes.retcode}]${briefRes.message}`);
|
||||
await TGLogger.Warn(`获取用户数据失败:${briefRes.retcode}-${briefRes.message}`);
|
||||
@@ -470,10 +470,10 @@ async function tryGetTokens(ck: TGApp.App.Account.Cookie): Promise<void> {
|
||||
}
|
||||
showSnackbar.success("获取用户信息成功");
|
||||
briefInfoGet = {
|
||||
nickname: briefRes.nickname,
|
||||
uid: briefRes.uid,
|
||||
avatar: briefRes.avatar_url,
|
||||
desc: briefRes.introduce,
|
||||
nickname: briefRes.data.user_info.nickname,
|
||||
uid: briefRes.data.user_info.uid,
|
||||
avatar: briefRes.data.user_info.avatar_url,
|
||||
desc: briefRes.data.user_info.introduce,
|
||||
};
|
||||
await showLoading.update("正在保存用户数据");
|
||||
await TSUserAccount.account.saveAccount({
|
||||
@@ -764,7 +764,7 @@ async function addByCookie(): Promise<void> {
|
||||
let briefInfoGet: TGApp.App.Account.BriefInfo | undefined;
|
||||
try {
|
||||
const briefRes = await bbsReq.userInfo(ck);
|
||||
if ("retcode" in briefRes) {
|
||||
if (briefRes.retcode !== 0) {
|
||||
await showLoading.end();
|
||||
showSnackbar.error(`[${briefRes.retcode}]${briefRes.message}`);
|
||||
await TGLogger.Warn(`获取用户数据失败:${briefRes.retcode}-${briefRes.message}`);
|
||||
@@ -772,10 +772,10 @@ async function addByCookie(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
briefInfoGet = {
|
||||
nickname: briefRes.nickname,
|
||||
uid: briefRes.uid,
|
||||
avatar: briefRes.avatar_url,
|
||||
desc: briefRes.introduce,
|
||||
nickname: briefRes.data.user_info.nickname,
|
||||
uid: briefRes.data.user_info.uid,
|
||||
avatar: briefRes.data.user_info.avatar_url,
|
||||
desc: briefRes.data.user_info.introduce,
|
||||
};
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<script lang="ts" setup>
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import bbsReq from "@req/bbsReq.js";
|
||||
import TGHttps from "@utils/TGHttps.js";
|
||||
import { onMounted, onUnmounted, ref, shallowRef, useTemplateRef, watch } from "vue";
|
||||
|
||||
import { LoadingParams } from "./loading.js";
|
||||
@@ -79,16 +80,30 @@ async function getRandomEmoji(): Promise<void> {
|
||||
for (const [k, v] of Object.entries(JSON.parse(emojisRead))) tmpArr.push([`${k}`, `${v}`]);
|
||||
localEmojis.value = tmpArr;
|
||||
} else {
|
||||
const resp = await bbsReq.emojis();
|
||||
if ("retcode" in resp) {
|
||||
console.error(resp);
|
||||
showSnackbar.error("获取表情包失败!");
|
||||
let resp: TGApp.BBS.Emoji.Resp | undefined;
|
||||
try {
|
||||
resp = await bbsReq.emojis();
|
||||
if (resp.retcode !== 0) {
|
||||
console.error(resp);
|
||||
showSnackbar.error("获取表情包失败!");
|
||||
iconUrl.value = defaultIcon;
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showSnackbar.error(`获取表情包失败:${TGHttps.getErrMsg(e)}`);
|
||||
iconUrl.value = defaultIcon;
|
||||
return;
|
||||
}
|
||||
localStorage.setItem("emojis", JSON.stringify(resp));
|
||||
const emojis: Record<string, string> = {};
|
||||
for (const series of resp.data.list) {
|
||||
for (const emoji of series.list) {
|
||||
emojis[emoji.name] = emoji.icon;
|
||||
}
|
||||
}
|
||||
localStorage.setItem("emojis", JSON.stringify(emojis));
|
||||
let tmpArr: Array<EmojiItem> = [];
|
||||
for (const [k, v] of Object.entries(resp)) {
|
||||
for (const [k, v] of Object.entries(emojis)) {
|
||||
tmpArr.push([k, v]);
|
||||
localEmojis.value = tmpArr;
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ async function tryGetTokens(ck: TGApp.App.Account.Cookie): Promise<void> {
|
||||
await showLoading.update("正在获取用户信息");
|
||||
try {
|
||||
const briefRes = await bbsReq.userInfo(ck);
|
||||
if ("retcode" in briefRes) {
|
||||
if (briefRes.retcode !== 0) {
|
||||
await showLoading.end();
|
||||
showSnackbar.error(`[${briefRes.retcode}]${briefRes.message}`);
|
||||
await TGLogger.Warn(`获取用户数据失败:${briefRes.retcode}-${briefRes.message}`);
|
||||
@@ -201,10 +201,10 @@ async function tryGetTokens(ck: TGApp.App.Account.Cookie): Promise<void> {
|
||||
}
|
||||
showSnackbar.success("获取用户信息成功");
|
||||
briefInfoGet = {
|
||||
nickname: briefRes.nickname,
|
||||
uid: briefRes.uid,
|
||||
avatar: briefRes.avatar_url,
|
||||
desc: briefRes.introduce,
|
||||
nickname: briefRes.data.user_info.nickname,
|
||||
uid: briefRes.data.user_info.uid,
|
||||
avatar: briefRes.data.user_info.avatar_url,
|
||||
desc: briefRes.data.user_info.introduce,
|
||||
};
|
||||
await showLoading.update("正在保存用户数据");
|
||||
await TSUserAccount.account.saveAccount({
|
||||
@@ -371,7 +371,7 @@ async function refreshUser(uid: string, full: boolean) {
|
||||
await showLoading.update("正在获取用户信息");
|
||||
try {
|
||||
const infoRes = await bbsReq.userInfo(ck);
|
||||
if ("retcode" in infoRes) {
|
||||
if (infoRes.retcode !== 0) {
|
||||
await showLoading.update("获取用户信息失败");
|
||||
showSnackbar.error(`[${infoRes.retcode}]${infoRes.message}`);
|
||||
await TGLogger.Warn("[tc-userBadge][refreshUserInfo] 获取用户信息失败");
|
||||
@@ -379,10 +379,10 @@ async function refreshUser(uid: string, full: boolean) {
|
||||
} else {
|
||||
await showLoading.update("获取用户信息成功");
|
||||
account.brief = {
|
||||
nickname: infoRes.nickname,
|
||||
uid: infoRes.uid,
|
||||
avatar: infoRes.avatar_url,
|
||||
desc: infoRes.introduce,
|
||||
nickname: infoRes.data.user_info.nickname,
|
||||
uid: infoRes.data.user_info.uid,
|
||||
avatar: infoRes.data.user_info.avatar_url,
|
||||
desc: infoRes.data.user_info.introduce,
|
||||
};
|
||||
await TGLogger.Info("[tc-userBadge][refreshUserInfo] 获取用户信息成功");
|
||||
}
|
||||
@@ -630,17 +630,17 @@ async function addByCookie(): Promise<void> {
|
||||
let briefGet: TGApp.App.Account.BriefInfo | undefined;
|
||||
try {
|
||||
const briefRes = await bbsReq.userInfo(ck);
|
||||
if ("retcode" in briefRes) {
|
||||
if (briefRes.retcode !== 0) {
|
||||
await showLoading.end();
|
||||
showSnackbar.error(`[${briefRes.retcode}]${briefRes.message}`);
|
||||
await TGLogger.Warn(`获取用户数据失败:${briefRes.retcode}-${briefRes.message}`);
|
||||
return;
|
||||
}
|
||||
briefGet = {
|
||||
nickname: briefRes.nickname,
|
||||
uid: briefRes.uid,
|
||||
avatar: briefRes.avatar_url,
|
||||
desc: briefRes.introduce,
|
||||
nickname: briefRes.data.user_info.nickname,
|
||||
uid: briefRes.data.user_info.uid,
|
||||
avatar: briefRes.data.user_info.avatar_url,
|
||||
desc: briefRes.data.user_info.introduce,
|
||||
};
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
|
||||
@@ -118,39 +118,57 @@ async function share(): Promise<void> {
|
||||
}
|
||||
|
||||
async function freshQr(): Promise<void> {
|
||||
const resp = await hk4eReq.loginQr.create(codeGid.value);
|
||||
if ("retcode" in resp) {
|
||||
showSnackbar.error(`[${resp.retcode}] ${resp.message}`);
|
||||
let resp: TGApp.Game.Login.QrResp | undefined;
|
||||
try {
|
||||
resp = await hk4eReq.loginQr.create(codeGid.value);
|
||||
if (resp.retcode !== 0) {
|
||||
showSnackbar.error(`[${resp.retcode}] ${resp.message}`);
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
showSnackbar.error(`创建二维码失败:${errMsg}`);
|
||||
await TGLogger.Error(`[TcoGameLogin][freshQr] 创建二维码异常`);
|
||||
await TGLogger.Error(`[TcoGameLogin][freshQr] ${e}`);
|
||||
return;
|
||||
}
|
||||
codeUrl.value = resp.url;
|
||||
codeUrl.value = resp.data.url;
|
||||
codeTicket.value = new URL(codeUrl.value).searchParams.get("ticket") || "";
|
||||
}
|
||||
|
||||
async function cycleGetDataGame(): Promise<void> {
|
||||
const res = await hk4eReq.loginQr.state(codeTicket.value, codeGid.value);
|
||||
console.log(res);
|
||||
if ("retcode" in res) {
|
||||
showSnackbar.error(`[${res.retcode}] ${res.message}`);
|
||||
if (res.retcode === -106) {
|
||||
await freshQr();
|
||||
} else {
|
||||
if (cycleTimer) clearInterval(cycleTimer);
|
||||
cycleTimer = null;
|
||||
model.value = false;
|
||||
let res: TGApp.Game.Login.StatResp | undefined;
|
||||
try {
|
||||
res = await hk4eReq.loginQr.state(codeTicket.value, codeGid.value);
|
||||
console.log(res);
|
||||
if (res.retcode !== 0) {
|
||||
showSnackbar.error(`[${res.retcode}] ${res.message}`);
|
||||
if (res.retcode === -106) {
|
||||
await freshQr();
|
||||
} else {
|
||||
if (cycleTimer) clearInterval(cycleTimer);
|
||||
cycleTimer = null;
|
||||
model.value = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
showSnackbar.error(`获取登录状态失败:${errMsg}`);
|
||||
await TGLogger.Error(`[TcoGameLogin][cycleGetDataGame] 获取登录状态异常`);
|
||||
await TGLogger.Error(`[TcoGameLogin][cycleGetDataGame] ${e}`);
|
||||
return;
|
||||
}
|
||||
if (res.stat === "Init" || res.stat === "Scanned") return;
|
||||
if (res.stat === "Confirmed") {
|
||||
if (res.data.stat === "Init" || res.data.stat === "Scanned") return;
|
||||
if (res.data.stat === "Confirmed") {
|
||||
if (cycleTimer) clearInterval(cycleTimer);
|
||||
cycleTimer = null;
|
||||
if (res.payload.proto === "Raw") {
|
||||
showSnackbar.error(`返回数据异常:${res.payload}`);
|
||||
if (res.data.payload.proto === "Raw") {
|
||||
showSnackbar.error(`返回数据异常:${res.data.payload}`);
|
||||
model.value = false;
|
||||
return;
|
||||
}
|
||||
const statusRaw: TGApp.Game.Login.StatPayloadRaw = JSON.parse(res.payload.raw);
|
||||
const statusRaw: TGApp.Game.Login.StatPayloadRaw = JSON.parse(res.data.payload.raw);
|
||||
await showLoading.start("正在获取SToken");
|
||||
let stResp: TGApp.Game.Login.StResp | undefined;
|
||||
try {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<div v-else-if="gameAccounts.length === 0" class="sign-not-login">暂无游戏账户</div>
|
||||
<div v-else-if="loading" class="sign-loading">
|
||||
<div class="loading-content">
|
||||
<v-progress-linear color="blue" :model-value="loadingProgress" height="6" rounded />
|
||||
<v-progress-linear :model-value="loadingProgress" color="blue" height="6" rounded />
|
||||
<div class="loading-text">{{ loadingText }}</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -36,6 +36,7 @@ import lunaReq from "@req/lunaReq.js";
|
||||
import TSUserAccount from "@Sqlm/userAccount.js";
|
||||
import useAppStore from "@store/app.js";
|
||||
import useUserStore from "@store/user.js";
|
||||
import TGHttps from "@utils/TGHttps.js";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { onMounted, ref, watch } from "vue";
|
||||
@@ -72,6 +73,15 @@ watch(
|
||||
|
||||
onMounted(async () => await loadData());
|
||||
|
||||
async function endLoad(): Promise<void> {
|
||||
loadingProgress.value = 100;
|
||||
loadingText.value = "加载完成";
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 200));
|
||||
loading.value = false;
|
||||
loadingProgress.value = 0;
|
||||
loadingText.value = "";
|
||||
}
|
||||
|
||||
async function loadData(): Promise<void> {
|
||||
if (!isLogin.value || uid.value === undefined || !cookie.value) {
|
||||
gameAccounts.value = [];
|
||||
@@ -79,51 +89,50 @@ async function loadData(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
signAccounts.value = [];
|
||||
try {
|
||||
const accounts = await TSUserAccount.game.getAccount(uid.value);
|
||||
gameAccounts.value = accounts;
|
||||
if (accounts.length === 0) {
|
||||
await TGLogger.Warn("[Sign Card] No game accounts found");
|
||||
emits("success");
|
||||
return;
|
||||
}
|
||||
const accounts = await TSUserAccount.game.getAccount(uid.value);
|
||||
gameAccounts.value = accounts;
|
||||
if (accounts.length === 0) {
|
||||
await TGLogger.Warn("[Sign Card] No game accounts found");
|
||||
emits("success");
|
||||
loading.value = true;
|
||||
loadingProgress.value = 0;
|
||||
const ck = { cookie_token: cookie.value.cookie_token, account_id: cookie.value.account_id };
|
||||
for (let i = 0; i < accounts.length; i++) {
|
||||
const account = accounts[i];
|
||||
loadingText.value = `正在加载 ${account.gameBiz} - ${account.regionName} - ${account.gameUid}...`;
|
||||
loadingProgress.value = (i / accounts.length) * 100;
|
||||
let info, stat;
|
||||
try {
|
||||
const infoResp = await lunaReq.sign.info(account, ck);
|
||||
if ("retcode" in infoResp) {
|
||||
await TGLogger.Error(
|
||||
`[Sign Card] Failed to get rewards for ${account.gameBiz}: ${infoResp.message}`,
|
||||
);
|
||||
} else info = infoResp;
|
||||
const statResp = await lunaReq.sign.stat(account, ck);
|
||||
if ("retcode" in statResp) {
|
||||
await TGLogger.Error(
|
||||
`[Sign Card] Failed to get status for ${account.gameBiz}: ${statResp.message}`,
|
||||
);
|
||||
} else stat = statResp;
|
||||
} catch (error) {
|
||||
await TGLogger.Error(`[Sign Card] Error loading data for ${account.gameBiz}: ${error}`);
|
||||
}
|
||||
signAccounts.value.push({ account, info, stat });
|
||||
}
|
||||
} catch (error) {
|
||||
await TGLogger.Error(`[Sign Card] Error loading data: ${error}`);
|
||||
} finally {
|
||||
loadingProgress.value = 100;
|
||||
loadingText.value = "加载完成";
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 200));
|
||||
loading.value = false;
|
||||
loadingProgress.value = 0;
|
||||
loadingText.value = "";
|
||||
await endLoad();
|
||||
return;
|
||||
}
|
||||
emits("success");
|
||||
loading.value = true;
|
||||
loadingProgress.value = 0;
|
||||
const ck = { cookie_token: cookie.value.cookie_token, account_id: cookie.value.account_id };
|
||||
for (let i = 0; i < accounts.length; i++) {
|
||||
const account = accounts[i];
|
||||
loadingText.value = `正在加载 ${account.gameBiz} - ${account.regionName} - ${account.gameUid}...`;
|
||||
loadingProgress.value = (i / accounts.length) * 100;
|
||||
let info, stat;
|
||||
let infoResp: TGApp.BBS.Sign.HomeResp | undefined;
|
||||
try {
|
||||
infoResp = await lunaReq.sign.info(account, ck);
|
||||
if (infoResp.retcode !== 0) {
|
||||
await TGLogger.Warn(
|
||||
`[Sign Card] Failed to get rewards for ${account.gameBiz}: [${infoResp.retcode}] ${infoResp.message}`,
|
||||
);
|
||||
} else info = infoResp.data;
|
||||
} catch (error) {
|
||||
const errMsg = TGHttps.getErrMsg(error);
|
||||
await TGLogger.Error(`[Sign Card] Error loading info for ${account.gameBiz}: ${errMsg}`);
|
||||
}
|
||||
let statResp: TGApp.BBS.Sign.InfoResp | undefined;
|
||||
try {
|
||||
statResp = await lunaReq.sign.stat(account, ck);
|
||||
if (statResp.retcode !== 0) {
|
||||
await TGLogger.Warn(
|
||||
`[Sign Card] Failed to get status for ${account.gameBiz}: [${statResp.retcode}] ${statResp.message}`,
|
||||
);
|
||||
} else stat = statResp.data;
|
||||
} catch (error) {
|
||||
const errMsg = TGHttps.getErrMsg(error);
|
||||
await TGLogger.Error(`[Sign Card] Error loading stat for ${account.gameBiz}: ${errMsg}`);
|
||||
}
|
||||
signAccounts.value.push({ account, info, stat });
|
||||
}
|
||||
await endLoad();
|
||||
}
|
||||
|
||||
async function handleUserSwitch(newUid: string): Promise<void> {
|
||||
|
||||
@@ -108,6 +108,7 @@ import lunaReq from "@req/lunaReq.js";
|
||||
import miscReq from "@req/miscReq.js";
|
||||
import useBBSStore from "@store/bbs.js";
|
||||
import useUserStore from "@store/user.js";
|
||||
import TGHttps from "@utils/TGHttps.js";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
import { generateShareImg } from "@utils/TGShare.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
@@ -323,70 +324,74 @@ async function handleSign(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
isSign.value = true;
|
||||
try {
|
||||
const ck = { cookie_token: cookie.value.cookie_token, account_id: cookie.value.account_id };
|
||||
const ckSign = {
|
||||
stoken: cookie.value.stoken,
|
||||
stuid: cookie.value.stuid,
|
||||
mid: cookie.value.mid,
|
||||
};
|
||||
const ck = { cookie_token: cookie.value.cookie_token, account_id: cookie.value.account_id };
|
||||
const ckSign = {
|
||||
stoken: cookie.value.stoken,
|
||||
stuid: cookie.value.stuid,
|
||||
mid: cookie.value.mid,
|
||||
};
|
||||
|
||||
let check = false;
|
||||
let challenge: string | undefined = undefined;
|
||||
let check = false;
|
||||
let challenge: string | undefined = undefined;
|
||||
|
||||
while (!check) {
|
||||
const signResp = await lunaReq.sign.oper(props.account, ck, challenge);
|
||||
if (challenge !== undefined) challenge = undefined;
|
||||
if ("retcode" in signResp) {
|
||||
if (signResp.retcode === 1034) {
|
||||
await TGLogger.Info("[Sign Item] Captcha required");
|
||||
const challengeGet = await miscReq.challenge(ckSign);
|
||||
if (challengeGet === false) {
|
||||
showSnackbar.error("验证码验证失败");
|
||||
break;
|
||||
}
|
||||
challenge = challengeGet;
|
||||
continue;
|
||||
}
|
||||
await TGLogger.Error(`[Sign Item] Sign-in failed: ${signResp.message}`);
|
||||
showSnackbar.error(`签到失败: ${signResp.message}`);
|
||||
break;
|
||||
}
|
||||
|
||||
if (signResp.success === 0) {
|
||||
check = true;
|
||||
} else if (signResp.is_risk) {
|
||||
await TGLogger.Info("[Sign Item] Risk verification required");
|
||||
const gtRes = await showGeetest({
|
||||
gt: signResp.gt,
|
||||
challenge: signResp.challenge,
|
||||
new_captcha: 1,
|
||||
success: 1,
|
||||
});
|
||||
if (gtRes === false) {
|
||||
while (!check) {
|
||||
let signResp: TGApp.BBS.Sign.SignResp | undefined;
|
||||
try {
|
||||
signResp = await lunaReq.sign.oper(props.account, ck, challenge);
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
await TGLogger.Error(`[Sign Item] Sign-in error: ${errMsg}`);
|
||||
showSnackbar.error(`签到失败: ${errMsg}`);
|
||||
isSign.value = false;
|
||||
break;
|
||||
}
|
||||
if (challenge !== undefined) challenge = undefined;
|
||||
if (signResp.retcode !== 0) {
|
||||
if (signResp.retcode === 1034) {
|
||||
await TGLogger.Info("[Sign Item] Captcha required");
|
||||
const challengeGet = await miscReq.challenge(ckSign);
|
||||
if (challengeGet === false) {
|
||||
showSnackbar.error("验证码验证失败");
|
||||
isSign.value = false;
|
||||
break;
|
||||
}
|
||||
challenge = signResp.challenge;
|
||||
} else {
|
||||
challenge = challengeGet;
|
||||
continue;
|
||||
}
|
||||
await TGLogger.Error(`[Sign Item] Sign-in failed: ${signResp.message}`);
|
||||
showSnackbar.error(`签到失败: ${signResp.message}`);
|
||||
isSign.value = false;
|
||||
break;
|
||||
}
|
||||
if (signResp.data.success === 0) {
|
||||
check = true;
|
||||
} else if (signResp.data.is_risk) {
|
||||
await TGLogger.Info("[Sign Item] Risk verification required");
|
||||
const gtRes = await showGeetest({
|
||||
gt: signResp.data.gt,
|
||||
challenge: signResp.data.challenge,
|
||||
new_captcha: 1,
|
||||
success: 1,
|
||||
});
|
||||
if (gtRes === false) {
|
||||
showSnackbar.error("验证码验证失败");
|
||||
break;
|
||||
}
|
||||
challenge = signResp.data.challenge;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
if (check) {
|
||||
showSnackbar.success("签到成功");
|
||||
updateLocalDataAfterSign();
|
||||
// Load resign info only if there are missed days
|
||||
const missedDays = signStat.value?.sign_cnt_missed ?? 0;
|
||||
if (missedDays > 0) {
|
||||
await loadResignInfo();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
await TGLogger.Error(`[Sign Item] Sign-in error: ${error}`);
|
||||
showSnackbar.error("签到失败,请重试");
|
||||
} finally {
|
||||
isSign.value = false;
|
||||
}
|
||||
if (check) {
|
||||
showSnackbar.success("签到成功");
|
||||
updateLocalDataAfterSign();
|
||||
// Load resign info only if there are missed days
|
||||
const missedDays = signStat.value?.sign_cnt_missed ?? 0;
|
||||
if (missedDays > 0) {
|
||||
await loadResignInfo();
|
||||
}
|
||||
}
|
||||
isSign.value = false;
|
||||
}
|
||||
|
||||
async function handleResign(): Promise<void> {
|
||||
@@ -443,30 +448,38 @@ async function handleResign(): Promise<void> {
|
||||
let challenge: string | undefined = undefined;
|
||||
|
||||
while (!check) {
|
||||
const resignResp = await lunaReq.resign.oper(props.account, ck, challenge);
|
||||
if (challenge !== undefined) challenge = undefined;
|
||||
if ("retcode" in resignResp) {
|
||||
if (resignResp.retcode === 1034) {
|
||||
await TGLogger.Info("[Sign Item] Captcha required for resign");
|
||||
const challengeGet = await miscReq.challenge(ckSign);
|
||||
if (challengeGet === false) {
|
||||
showSnackbar.error("验证码验证失败");
|
||||
break;
|
||||
let resignResp: TGApp.BBS.Sign.ResignResp | undefined;
|
||||
try {
|
||||
resignResp = await lunaReq.resign.oper(props.account, ck, challenge);
|
||||
if (challenge !== undefined) challenge = undefined;
|
||||
if (resignResp.retcode !== 0) {
|
||||
if (resignResp.retcode === 1034) {
|
||||
await TGLogger.Info("[Sign Item] Captcha required for resign");
|
||||
const challengeGet = await miscReq.challenge(ckSign);
|
||||
if (challengeGet === false) {
|
||||
showSnackbar.error("验证码验证失败");
|
||||
break;
|
||||
}
|
||||
challenge = challengeGet;
|
||||
continue;
|
||||
}
|
||||
challenge = challengeGet;
|
||||
continue;
|
||||
await TGLogger.Error(`[Sign Item] Resign failed: ${resignResp.message}`);
|
||||
showSnackbar.error(`补签失败: ${resignResp.message}`);
|
||||
break;
|
||||
}
|
||||
await TGLogger.Error(`[Sign Item] Resign failed: ${resignResp.message}`);
|
||||
showSnackbar.error(`补签失败: ${resignResp.message}`);
|
||||
|
||||
// Resign successful
|
||||
check = true;
|
||||
updateLocalDataAfterResign();
|
||||
showSnackbar.success(
|
||||
`补签成功,剩余补签次数${resignCnt - 1}次,剩余米游币${coinCnt - coinCost}`,
|
||||
);
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
await TGLogger.Error(`[Sign Item] Resign error: ${errMsg}`);
|
||||
showSnackbar.error(`补签失败: ${errMsg}`);
|
||||
break;
|
||||
}
|
||||
|
||||
// Resign successful
|
||||
check = true;
|
||||
updateLocalDataAfterResign();
|
||||
showSnackbar.success(
|
||||
`补签成功,剩余补签次数${resignCnt - 1}次,剩余米游币${coinCnt - coinCost}`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
await TGLogger.Error(`[Sign Item] Resign error: ${error}`);
|
||||
|
||||
@@ -241,21 +241,35 @@ async function refreshState(ck: TGApp.App.Account.Cookie, uid: string): Promise<
|
||||
`[签到任务]刷新${item.info.title}-${item.account.regionName}-${item.account.gameUid}`,
|
||||
);
|
||||
if (item.reward === undefined) {
|
||||
const rewardResp = await lunaReq.sign.info(item.account, cookie);
|
||||
console.log("签到奖励", item, rewardResp);
|
||||
if ("retcode" in rewardResp) {
|
||||
await TGLogger.Script(
|
||||
`[签到任务]获取签到奖励失败:${rewardResp.retcode} ${rewardResp.message}`,
|
||||
);
|
||||
showSnackbar.error(`[${rewardResp.retcode}] ${rewardResp.message}`);
|
||||
} else item.reward = rewardResp.awards[dayNow - 1];
|
||||
let rewardResp: TGApp.BBS.Sign.HomeResp | undefined;
|
||||
try {
|
||||
rewardResp = await lunaReq.sign.info(item.account, cookie);
|
||||
console.log("签到奖励", item, rewardResp);
|
||||
if (rewardResp.retcode !== 0) {
|
||||
await TGLogger.Script(
|
||||
`[签到任务]获取签到奖励失败:${rewardResp.retcode} ${rewardResp.message}`,
|
||||
);
|
||||
showSnackbar.error(`[${rewardResp.retcode}] ${rewardResp.message}`);
|
||||
} else item.reward = rewardResp.data.awards[dayNow - 1];
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
await TGLogger.Script(`[签到任务]获取签到奖励异常:${errMsg}`);
|
||||
showSnackbar.error(`获取签到奖励失败:${errMsg}`);
|
||||
}
|
||||
}
|
||||
let statResp: TGApp.BBS.Sign.InfoResp | undefined;
|
||||
try {
|
||||
statResp = await lunaReq.sign.stat(item.account, cookie);
|
||||
console.log("签到状态", item, statResp);
|
||||
if (statResp.retcode !== 0) {
|
||||
await TGLogger.Script(`[签到任务]获取签到状态失败:${statResp.retcode} ${statResp.message}`);
|
||||
showSnackbar.error(`[${statResp.retcode}] ${statResp.message}`);
|
||||
} else item.stat = statResp.data;
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
await TGLogger.Script(`[签到任务]获取签到状态异常:${errMsg}`);
|
||||
showSnackbar.error(`获取签到状态失败:${errMsg}`);
|
||||
}
|
||||
const statResp = await lunaReq.sign.stat(item.account, cookie);
|
||||
console.log("签到状态", item, statResp);
|
||||
if ("retcode" in statResp) {
|
||||
await TGLogger.Script(`[签到任务]获取签到状态失败:${statResp.retcode} ${statResp.message}`);
|
||||
showSnackbar.error(`[${statResp.retcode}] ${statResp.message}`);
|
||||
} else item.stat = statResp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,16 +290,18 @@ async function trySign(
|
||||
let check = false;
|
||||
let challenge: string | undefined = undefined;
|
||||
while (!check) {
|
||||
const signResp = await lunaReq.sign.oper(item.account, cookie, challenge);
|
||||
console.log("签到信息", item, signResp);
|
||||
if (challenge !== undefined) challenge = undefined;
|
||||
if (typeof signResp !== "object") {
|
||||
await TGLogger.Script(
|
||||
`[签到任务]${item.info.title}-${item.account.regionName}-${item.account.gameUid} ${signResp}`,
|
||||
);
|
||||
let signResp: TGApp.BBS.Sign.SignResp | undefined;
|
||||
try {
|
||||
signResp = await lunaReq.sign.oper(item.account, cookie, challenge);
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
await TGLogger.Script(`[签到任务]签到异常:${errMsg}`);
|
||||
showSnackbar.error(`签到失败:${errMsg}`);
|
||||
break;
|
||||
}
|
||||
if ("retcode" in signResp) {
|
||||
console.log("签到信息", item, signResp);
|
||||
if (challenge !== undefined) challenge = undefined;
|
||||
if (signResp.retcode !== 0) {
|
||||
if (signResp.retcode === 1034) {
|
||||
if (skip) {
|
||||
await TGLogger.Script("已设置跳过验证,打卡失败");
|
||||
@@ -308,12 +324,12 @@ async function trySign(
|
||||
showSnackbar.error(`[${signResp.retcode}] ${signResp.message}`);
|
||||
break;
|
||||
}
|
||||
if (signResp.success === 0) check = true;
|
||||
else if (signResp.is_risk) {
|
||||
if (signResp.data.success === 0) check = true;
|
||||
else if (signResp.data.is_risk) {
|
||||
await TGLogger.Script("[签到任务]触发风险验证,开始验证");
|
||||
const gtRes = await showGeetest({
|
||||
gt: signResp.gt,
|
||||
challenge: signResp.challenge,
|
||||
gt: signResp.data.gt,
|
||||
challenge: signResp.data.challenge,
|
||||
new_captcha: 1,
|
||||
success: 1,
|
||||
});
|
||||
@@ -321,7 +337,7 @@ async function trySign(
|
||||
await TGLogger.Script("[签到任务]验证码验证失败");
|
||||
break;
|
||||
}
|
||||
challenge = signResp.challenge;
|
||||
challenge = signResp.data.challenge;
|
||||
} else break;
|
||||
}
|
||||
if (check) {
|
||||
|
||||
@@ -35,6 +35,8 @@ import { isColorSimilar } from "@utils/colorFunc.js";
|
||||
import { parseLink, parsePost } from "@utils/linkParser.js";
|
||||
import { decodeRegExp } from "@utils/toolFunc.js";
|
||||
import { onMounted, ref, shallowRef, StyleValue, toRaw, useTemplateRef } from "vue";
|
||||
import TGHttps from "@utils/TGHttps.js";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
|
||||
export type TpText = {
|
||||
insert: string;
|
||||
@@ -139,14 +141,26 @@ async function copyLink(): Promise<void> {
|
||||
function getEmojiUrl(): string {
|
||||
if (localEmojis.value === null || !JSON.parse(localEmojis.value)[getEmojiName()]) {
|
||||
console.warn("tpEmoji unknown", getEmojiName());
|
||||
bbsReq.emojis().then((res) => {
|
||||
if ("retcode" in res) {
|
||||
console.error(res);
|
||||
return "";
|
||||
}
|
||||
localEmojis.value = JSON.stringify(res);
|
||||
localStorage.setItem("emojis", localEmojis.value);
|
||||
});
|
||||
bbsReq
|
||||
.emojis()
|
||||
.then((res) => {
|
||||
if (res.retcode !== 0) {
|
||||
console.error(res);
|
||||
return "";
|
||||
}
|
||||
const emojis: Record<string, string> = {};
|
||||
for (const series of res.data.list) {
|
||||
for (const emoji of series.list) {
|
||||
emojis[emoji.name] = emoji.icon;
|
||||
}
|
||||
}
|
||||
localEmojis.value = JSON.stringify(emojis);
|
||||
localStorage.setItem("emojis", localEmojis.value);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
await TGLogger.Error(errMsg);
|
||||
});
|
||||
}
|
||||
if (localEmojis.value === null) return "";
|
||||
const emojiName = getEmojiName();
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
:key="index"
|
||||
:class="{ selected: index === props.collection.cur - 1 }"
|
||||
:post
|
||||
@onUserClick="toUserProfile"
|
||||
class="tpoc-item"
|
||||
@onUserClick="toUserProfile"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -57,12 +57,23 @@ watch(
|
||||
onMounted(async () => await Promise.all([refreshInfo(), refreshPosts()]));
|
||||
|
||||
async function refreshInfo(): Promise<void> {
|
||||
const infoResp = await bbsReq.collection(props.collection.collection_id, props.gid);
|
||||
if ("retcode" in infoResp) {
|
||||
// showSnackbar.warn(`[合集信息][${infoResp.retcode}] ${infoResp.message}`);
|
||||
let infoResp: TGApp.BBS.Collection.InfoResp | undefined;
|
||||
try {
|
||||
infoResp = await bbsReq.collection(props.collection.collection_id, props.gid);
|
||||
if (infoResp.retcode !== 0) {
|
||||
// showSnackbar.warn(`[合集信息][${infoResp.retcode}] ${infoResp.message}`);
|
||||
await TGLogger.Warn(
|
||||
`[vp-overlay-collection] 获取合集信息失败:[${infoResp.retcode}] ${infoResp.message}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
showSnackbar.error(`获取合集信息失败:${errMsg}`);
|
||||
await TGLogger.Error(`[vp-overlay-collection] 获取合集信息异常:${errMsg}`);
|
||||
return;
|
||||
}
|
||||
info.value = infoResp;
|
||||
info.value = infoResp.data;
|
||||
console.log(info.value);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
<div class="vp-ou-divider" />
|
||||
<div ref="listRef" class="vp-ou-list">
|
||||
<TPostCard
|
||||
@onUserClick="toUserProfile()"
|
||||
v-for="post in results"
|
||||
:key="post.post.post_id"
|
||||
:post
|
||||
class="vp-ou-item"
|
||||
@onUserClick="toUserProfile()"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -108,12 +108,21 @@ watch(
|
||||
);
|
||||
|
||||
async function loadUser(): Promise<void> {
|
||||
const resp = await bbsReq.otherUserInfo(props.gid.toString(), props.uid);
|
||||
if ("retcode" in resp) {
|
||||
showSnackbar.warn(`[${resp.retcode}] ${resp.message}`);
|
||||
let resp: TGApp.BBS.User.InfoResp | undefined;
|
||||
try {
|
||||
resp = await bbsReq.otherUserInfo(props.gid.toString(), props.uid);
|
||||
if (resp.retcode !== 0) {
|
||||
showSnackbar.warn(`[${resp.retcode}] ${resp.message}`);
|
||||
await TGLogger.Warn(`[vp-overlay-user] 获取用户信息失败:[${resp.retcode}] ${resp.message}`);
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
showSnackbar.error(`获取用户信息失败:${errMsg}`);
|
||||
await TGLogger.Error(`[vp-overlay-user] 获取用户信息异常:${errMsg}`);
|
||||
return;
|
||||
}
|
||||
userInfo.value = resp;
|
||||
userInfo.value = resp.data.user_info;
|
||||
}
|
||||
|
||||
async function toUserProfile(): Promise<void> {
|
||||
|
||||
@@ -602,17 +602,26 @@ async function refreshGachaPool(
|
||||
if (!force) endId = (await TSUserGacha.getGachaCheck(ac.gameUid, type)) ?? "0";
|
||||
while (true) {
|
||||
page++;
|
||||
const gachaRes = await hk4eReq.gacha(authkey.value, type, reqId);
|
||||
if (!Array.isArray(gachaRes)) {
|
||||
showSnackbar.error(`[${type}][${gachaRes.retcode}] ${gachaRes.message}`);
|
||||
await TGLogger.Error(`[Gacha][${ac.gameUid}][refreshGachaPool] 获取祈愿数据失败`);
|
||||
await TGLogger.Error(
|
||||
`[Gacha][${ac.gameUid}][refreshGachaPool] ${gachaRes.retcode} ${gachaRes.message}`,
|
||||
);
|
||||
let gachaRes: TGApp.Game.Gacha.GachaLogResp | undefined;
|
||||
try {
|
||||
gachaRes = await hk4eReq.gacha(authkey.value, type, reqId);
|
||||
if (gachaRes.retcode !== 0) {
|
||||
showSnackbar.error(`[${type}][${gachaRes.retcode}] ${gachaRes.message}`);
|
||||
await TGLogger.Warn(
|
||||
`[Gacha][${ac.gameUid}][refreshGachaPool] 获取祈愿数据失败:[${gachaRes.retcode}] ${gachaRes.message}`,
|
||||
);
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 1000));
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
showSnackbar.error(`[${type}] 获取祈愿数据失败:${errMsg}`);
|
||||
await TGLogger.Error(`[Gacha][${ac.gameUid}][refreshGachaPool] 获取祈愿数据异常:${errMsg}`);
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 1000));
|
||||
break;
|
||||
}
|
||||
if (gachaRes.length === 0) {
|
||||
const gachaList = gachaRes.data.list;
|
||||
if (gachaList.length === 0) {
|
||||
if (force) {
|
||||
await showLoading.update(`正在清理${label}数据`);
|
||||
if (gachaDataMap) {
|
||||
@@ -622,8 +631,8 @@ async function refreshGachaPool(
|
||||
break;
|
||||
}
|
||||
const uigfList: Array<TGApp.Plugins.UIGF.GachaItem> = [];
|
||||
if (force) await showLoading.update(`[${label}] 第${page}页,${gachaRes.length}条`);
|
||||
for (const item of gachaRes) {
|
||||
if (force) await showLoading.update(`[${label}] 第${page}页,${gachaList.length}条`);
|
||||
for (const item of gachaList) {
|
||||
if (!force) {
|
||||
await showLoading.update(`[${item.item_type}][${item.time}] ${item.name}`, { timeout: 0 });
|
||||
}
|
||||
@@ -661,8 +670,8 @@ async function refreshGachaPool(
|
||||
}
|
||||
}
|
||||
await TSUserGacha.mergeUIGF(ac.gameUid, uigfList);
|
||||
if (!force && gachaRes.some((i) => i.id.toString() === endId.toString())) break;
|
||||
reqId = gachaRes[gachaRes.length - 1].id.toString();
|
||||
if (!force && gachaList.some((i) => i.id.toString() === endId.toString())) break;
|
||||
reqId = gachaList[gachaList.length - 1].id.toString();
|
||||
if (force) await new Promise<void>((resolve) => setTimeout(resolve, 1000));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,21 +265,30 @@ async function refreshGachaPool(
|
||||
}
|
||||
while (true) {
|
||||
page++;
|
||||
const gachaRes = await hk4eReq.gachaB(authkey.value, gachaType, reqId);
|
||||
console.log(gachaRes);
|
||||
if (!Array.isArray(gachaRes)) {
|
||||
showSnackbar.error(`[${gachaType}][${gachaRes.retcode}] ${gachaRes.message}`);
|
||||
await TGLogger.Error(`[GachaB][${ac.gameUid}][refreshGachaPool] 获取祈愿数据失败`);
|
||||
await TGLogger.Error(
|
||||
`[GachaB][${ac.gameUid}][refreshGachaPool] ${gachaRes.retcode} ${gachaRes.message}`,
|
||||
);
|
||||
let gachaRes: TGApp.Game.Gacha.GachaBLogResp | undefined;
|
||||
try {
|
||||
gachaRes = await hk4eReq.gachaB(authkey.value, gachaType, reqId);
|
||||
if (gachaRes.retcode !== 0) {
|
||||
showSnackbar.error(`[${gachaType}][${gachaRes.retcode}] ${gachaRes.message}`);
|
||||
await TGLogger.Warn(
|
||||
`[GachaB][${ac.gameUid}][refreshGachaPool] 获取祈愿数据失败:[${gachaRes.retcode}] ${gachaRes.message}`,
|
||||
);
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 1000));
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
showSnackbar.error(`[${gachaType}] 获取祈愿数据失败:${errMsg}`);
|
||||
await TGLogger.Error(`[GachaB][${ac.gameUid}][refreshGachaPool] 获取祈愿数据异常:${errMsg}`);
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 1000));
|
||||
break;
|
||||
}
|
||||
if (gachaRes.length === 0) break;
|
||||
console.log(gachaRes);
|
||||
const gachaList = gachaRes.data.list;
|
||||
if (gachaList.length === 0) break;
|
||||
const uigfList: Array<TGApp.Plugins.UIGF.GachaItemB> = [];
|
||||
if (force) await showLoading.update(`[${gachaName}] 第${page}页,${gachaRes.length}条`);
|
||||
for (const item of gachaRes) {
|
||||
if (force) await showLoading.update(`[${gachaName}] 第${page}页,${gachaList.length}条`);
|
||||
for (const item of gachaList) {
|
||||
if (!force) {
|
||||
await showLoading.update(`[${item.item_type}][${item.time}] ${item.item_name}`);
|
||||
}
|
||||
@@ -296,8 +305,8 @@ async function refreshGachaPool(
|
||||
uigfList.push(tempItem);
|
||||
}
|
||||
await TSUserGachaB.insertGachaList(ac.gameUid, uigfList);
|
||||
if (!force && gachaRes.some((i) => i.id.toString() === endId.toString())) break;
|
||||
reqId = gachaRes[gachaRes.length - 1].id.toString();
|
||||
if (!force && gachaList.some((i) => i.id.toString() === endId.toString())) break;
|
||||
reqId = gachaList[gachaList.length - 1].id.toString();
|
||||
if (force) await new Promise<void>((resolve) => setTimeout(resolve, 1000));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ import TaoIframe from "@comp/pageAnno/tao-iframe.vue";
|
||||
import gameEnum from "@enum/game.js";
|
||||
import hk4eReq from "@req/hk4eReq.js";
|
||||
import useAppStore from "@store/app.js";
|
||||
import TGHttps from "@utils/TGHttps.js";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { onMounted, ref, shallowRef, watch } from "vue";
|
||||
@@ -140,12 +141,51 @@ async function loadData(): Promise<void> {
|
||||
"正在获取公告数据",
|
||||
`服务器:${gameEnum.serverDesc(server.value)},语言:${gameEnum.anno.langDesc(lang.value)}`,
|
||||
);
|
||||
const listResp = await hk4eReq.anno.list(server.value, lang.value);
|
||||
let listResp: TGApp.Game.Anno.ListResp | undefined;
|
||||
try {
|
||||
listResp = await hk4eReq.anno.list(server.value, lang.value);
|
||||
if (listResp.retcode !== 0) {
|
||||
showSnackbar.error(`[${listResp.retcode}] ${listResp.message}`);
|
||||
await TGLogger.Warn(
|
||||
`[PageAnno][loadData] 获取公告列表失败:[${listResp.retcode}] ${listResp.message}`,
|
||||
);
|
||||
await showLoading.end();
|
||||
isReq.value = false;
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
showSnackbar.error(`获取公告列表失败:${errMsg}`);
|
||||
await TGLogger.Error(`[PageAnno][loadData] 获取公告列表异常:${errMsg}`);
|
||||
await showLoading.end();
|
||||
isReq.value = false;
|
||||
return;
|
||||
}
|
||||
console.log("annoList", listResp);
|
||||
annoList.value = listResp;
|
||||
tabList.value = listResp.type_list;
|
||||
annoList.value = listResp.data;
|
||||
tabList.value = listResp.data.type_list;
|
||||
tab.value = tabList.value[0].id;
|
||||
detailList.value = await hk4eReq.anno.detail(server.value, gameEnum.anno.lang.CHS);
|
||||
let detailResp: TGApp.Game.Anno.DetailResp | undefined;
|
||||
try {
|
||||
detailResp = await hk4eReq.anno.detail(server.value, gameEnum.anno.lang.CHS);
|
||||
if (detailResp.retcode !== 0) {
|
||||
showSnackbar.error(`[${detailResp.retcode}] ${detailResp.message}`);
|
||||
await TGLogger.Warn(
|
||||
`[PageAnno][loadData] 获取公告详情失败:[${detailResp.retcode}] ${detailResp.message}`,
|
||||
);
|
||||
await showLoading.end();
|
||||
isReq.value = false;
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
showSnackbar.error(`获取公告详情失败:${errMsg}`);
|
||||
await TGLogger.Error(`[PageAnno][loadData] 获取公告详情异常:${errMsg}`);
|
||||
await showLoading.end();
|
||||
isReq.value = false;
|
||||
return;
|
||||
}
|
||||
detailList.value = detailResp.data.list;
|
||||
await showLoading.end();
|
||||
isReq.value = false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Bili 插件视频请求文件
|
||||
* @since Beta v0.10.0
|
||||
* @since Beta v0.10.1
|
||||
*/
|
||||
|
||||
import { BILI_HEADER, getWrid } from "../utils.js";
|
||||
@@ -8,7 +8,7 @@ import TGHttps from "@utils/TGHttps.js";
|
||||
|
||||
/**
|
||||
* 获取视频播放地址
|
||||
* @since Beta v0.10.0
|
||||
* @since Beta v0.10.1
|
||||
* @todo 完善参数类型
|
||||
* @see https://socialsisteryi.github.io/bilibili-API-collect/docs/video/videostream_url.html#dash%E6%A0%BC%E5%BC%8F
|
||||
* @param bvid - 视频BV号
|
||||
@@ -21,7 +21,6 @@ async function getVideoUrl(cid: number, bvid: string): Promise<TGApp.Plugins.Bil
|
||||
const [wts, w_rid] = await getWrid(params);
|
||||
params = { ...params, wts: wts, w_rid: w_rid };
|
||||
const resp = await TGHttps.get<TGApp.Plugins.Bili.Video.UrlResp>(url, {
|
||||
method: "GET",
|
||||
query: params,
|
||||
headers: BILI_HEADER,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Bili 插件工具函数
|
||||
* @since Beta v0.10.0
|
||||
* @since Beta v0.10.1
|
||||
*/
|
||||
import TGHttps from "@utils/TGHttps.js";
|
||||
import md5 from "js-md5";
|
||||
@@ -14,13 +14,12 @@ export const BILI_HEADER: Readonly<Record<string, string>> = {
|
||||
|
||||
/**
|
||||
* Bili 插件导航请求
|
||||
* @since Beta v0.10.0
|
||||
* @since Beta v0.10.1
|
||||
* @returns Bili 插件导航请求返回
|
||||
*/
|
||||
async function getNavResp(): Promise<TGApp.Plugins.Bili.Nav.Resp> {
|
||||
const url = "https://api.bilibili.com/x/web-interface/nav";
|
||||
const resp = await TGHttps.get<TGApp.Plugins.Bili.Nav.Resp>(url, {
|
||||
method: "GET",
|
||||
headers: BILI_HEADER,
|
||||
});
|
||||
return resp.data;
|
||||
|
||||
@@ -177,17 +177,17 @@ async function updateAccountCk(data: TGApp.App.Account.User): Promise<boolean> {
|
||||
let briefInfo: TGApp.App.Account.BriefInfo | undefined;
|
||||
try {
|
||||
const briefRes = await bbsReq.userInfo(ck);
|
||||
if ("retcode" in briefRes) {
|
||||
if (briefRes.retcode !== 0) {
|
||||
await showLoading.end();
|
||||
showSnackbar.error(`[${briefRes.retcode}]${briefRes.message}`);
|
||||
await TGLogger.Warn(`获取用户数据失败:${briefRes.retcode}-${briefRes.message}`);
|
||||
return false;
|
||||
}
|
||||
briefInfo = {
|
||||
nickname: briefRes.nickname,
|
||||
uid: briefRes.uid,
|
||||
avatar: briefRes.avatar_url,
|
||||
desc: briefRes.introduce,
|
||||
nickname: briefRes.data.user_info.nickname,
|
||||
uid: briefRes.data.user_info.uid,
|
||||
avatar: briefRes.data.user_info.avatar_url,
|
||||
desc: briefRes.data.user_info.introduce,
|
||||
};
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
|
||||
@@ -1,96 +1,76 @@
|
||||
/**
|
||||
* BBS 请求模块
|
||||
* @since Beta v0.7.3
|
||||
* @since Beta v0.10.1
|
||||
*/
|
||||
|
||||
import { getRequestHeader } from "@utils/getRequestHeader.js";
|
||||
import TGHttp from "@utils/TGHttp.js";
|
||||
import TGHttps from "@utils/TGHttps.js";
|
||||
|
||||
/* MysBBSBaseUrl => mbBu */
|
||||
const mbBu: Readonly<string> = "https://bbs-api.miyoushe.com/";
|
||||
|
||||
/**
|
||||
* 获取表情包列表
|
||||
* @since Beta v0.7.3
|
||||
* @returns 转换后的表情包列表
|
||||
* @since Beta v0.10.1
|
||||
* @returns 表情包列表响应数据
|
||||
*/
|
||||
async function getEmoticonSet(): Promise<Record<string, string> | TGApp.BBS.Response.Base> {
|
||||
const resp = await TGHttp<TGApp.BBS.Emoji.Resp>(`${mbBu}misc/api/emoticon_set`, {
|
||||
method: "GET",
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
const emojis: Record<string, string> = {};
|
||||
for (const series of resp.data.list) {
|
||||
for (const emoji of series.list) {
|
||||
emojis[emoji.name] = emoji.icon;
|
||||
}
|
||||
}
|
||||
return emojis;
|
||||
async function getEmoticonSet(): Promise<TGApp.BBS.Emoji.Resp> {
|
||||
const resp = await TGHttps.get<TGApp.BBS.Emoji.Resp>(`${mbBu}misc/api/emoticon_set`, {});
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 cookie 获取用户信息
|
||||
* @since Beta v0.5.0
|
||||
* @since Beta v0.10.1
|
||||
* @param cookie - 账户 cookie
|
||||
* @returns 用户信息
|
||||
* @returns 用户信息响应数据
|
||||
*/
|
||||
async function getUserFullInfo(
|
||||
cookie: TGApp.App.Account.Cookie,
|
||||
): Promise<TGApp.BBS.Response.Base | TGApp.BBS.User.Info> {
|
||||
async function getUserFullInfo(cookie: TGApp.App.Account.Cookie): Promise<TGApp.BBS.User.InfoResp> {
|
||||
const ck = { cookie_token: cookie.cookie_token, account_id: cookie.account_id };
|
||||
const params = { gids: "2" };
|
||||
const resp = await TGHttp<TGApp.BBS.User.InfoResp>(`${mbBu}user/wapi/getUserFullInfo`, {
|
||||
method: "GET",
|
||||
const resp = await TGHttps.get<TGApp.BBS.User.InfoResp>(`${mbBu}user/wapi/getUserFullInfo`, {
|
||||
headers: getRequestHeader(ck, "GET", params, "X4", true),
|
||||
query: params,
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data.user_info;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据gid和id获取用户信息
|
||||
* @since Beta v0.7.2
|
||||
* @since Beta v0.10.1
|
||||
* @param gid - gid
|
||||
* @param userId - 用户 id
|
||||
* @returns 用户信息
|
||||
* @returns 用户信息响应数据
|
||||
*/
|
||||
async function getOtherUserInfo(
|
||||
gid: string,
|
||||
userId: string,
|
||||
): Promise<TGApp.BBS.Response.Base | TGApp.BBS.User.Info> {
|
||||
async function getOtherUserInfo(gid: string, userId: string): Promise<TGApp.BBS.User.InfoResp> {
|
||||
const params = { gids: gid.toString(), uid: userId };
|
||||
const resp = await TGHttp<TGApp.BBS.User.InfoResp>(`${mbBu}user/wapi/getUserFullInfo`, {
|
||||
method: "GET",
|
||||
const resp = await TGHttps.get<TGApp.BBS.User.InfoResp>(`${mbBu}user/wapi/getUserFullInfo`, {
|
||||
headers: getRequestHeader({}, "GET", params, "X4", true),
|
||||
query: params,
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data.user_info;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取合集信息
|
||||
* @since Beta v0.7.3
|
||||
* @since Beta v0.10.1
|
||||
* @TODO salt计算异常
|
||||
* @param cid - 合集 id
|
||||
* @param gid - gid
|
||||
* @returns 合集信息
|
||||
* @returns 合集信息响应数据
|
||||
*/
|
||||
async function getCollectionDetail(
|
||||
cid: string,
|
||||
gid: number,
|
||||
): Promise<TGApp.BBS.Collection.InfoRes | TGApp.BBS.Response.Base> {
|
||||
): Promise<TGApp.BBS.Collection.InfoResp> {
|
||||
const params = { gids: gid, id: cid };
|
||||
const resp = await TGHttp<TGApp.BBS.Collection.InfoResp>(
|
||||
const resp = await TGHttps.get<TGApp.BBS.Collection.InfoResp>(
|
||||
`${mbBu}collection/wapi/collection/detail`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: getRequestHeader({}, "GET", params, "X4", true),
|
||||
query: params,
|
||||
},
|
||||
);
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* Hk4eApi 请求模块
|
||||
* @since Beta v0.8.4
|
||||
* @since Beta v0.10.1
|
||||
*/
|
||||
|
||||
import gameEnum from "@enum/game.js";
|
||||
import TGHttp from "@utils/TGHttp.js";
|
||||
import TGHttps from "@utils/TGHttps.js";
|
||||
import { getDeviceInfo } from "@utils/toolFunc.js";
|
||||
|
||||
const AnnoApi: Readonly<string> = "https://hk4e-ann-api.mihoyo.com/common/hk4e_cn/announcement/api";
|
||||
@@ -63,17 +63,16 @@ function getAnnoParams(
|
||||
|
||||
/**
|
||||
* 获取游戏内公告列表
|
||||
* @since Beta v0.8.0
|
||||
* @since Beta v0.10.1
|
||||
* @param region - 服务器
|
||||
* @param lang - 语言
|
||||
* @returns 公告列表
|
||||
* @returns 公告列表响应数据
|
||||
*/
|
||||
async function getAnnoList(
|
||||
region: TGApp.Game.Base.ServerTypeEnum = gameEnum.server.CN_GF01,
|
||||
lang: TGApp.Game.Anno.AnnoLangEnum = gameEnum.anno.lang.CHS,
|
||||
): Promise<TGApp.Game.Anno.ListRes> {
|
||||
const resp = await TGHttp<TGApp.Game.Anno.ListResp>(`${getAnnoApi(region)}/getAnnList`, {
|
||||
method: "GET",
|
||||
): Promise<TGApp.Game.Anno.ListResp> {
|
||||
const resp = await TGHttps.get<TGApp.Game.Anno.ListResp>(`${getAnnoApi(region)}/getAnnList`, {
|
||||
query: getAnnoParams(region, lang),
|
||||
});
|
||||
return resp.data;
|
||||
@@ -81,35 +80,35 @@ async function getAnnoList(
|
||||
|
||||
/**
|
||||
* 获取游戏内公告内容
|
||||
* @since Beta v0.8.0
|
||||
* @since Beta v0.10.1
|
||||
* @param region - 服务器
|
||||
* @param lang - 语言
|
||||
* @returns 公告详情
|
||||
* @returns 公告详情响应数据
|
||||
*/
|
||||
async function getAnnoDetail(
|
||||
region: TGApp.Game.Base.ServerTypeEnum = gameEnum.server.CN_GF01,
|
||||
lang: TGApp.Game.Anno.AnnoLangEnum = gameEnum.anno.lang.CHS,
|
||||
): Promise<Array<TGApp.Game.Anno.AnnoDetail>> {
|
||||
const resp = await TGHttp<TGApp.Game.Anno.DetailResp>(`${getAnnoApi(region)}/getAnnContent`, {
|
||||
method: "GET",
|
||||
query: getAnnoParams(region, lang),
|
||||
});
|
||||
return resp.data.list;
|
||||
): Promise<TGApp.Game.Anno.DetailResp> {
|
||||
const resp = await TGHttps.get<TGApp.Game.Anno.DetailResp>(
|
||||
`${getAnnoApi(region)}/getAnnContent`,
|
||||
{ query: getAnnoParams(region, lang) },
|
||||
);
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取抽卡记录
|
||||
* @since Beta v0.5.0
|
||||
* @since Beta v0.10.1
|
||||
* @param authKey - authKey
|
||||
* @param gachaType - 抽卡类型
|
||||
* @param endId - 结束 id,默认为 0
|
||||
* @returns 抽卡记录
|
||||
* @returns 抽卡记录响应数据
|
||||
*/
|
||||
async function getGachaLog(
|
||||
authKey: string,
|
||||
gachaType: string,
|
||||
endId: string = "0",
|
||||
): Promise<Array<TGApp.Game.Gacha.GachaItem> | TGApp.BBS.Response.Base> {
|
||||
): Promise<TGApp.Game.Gacha.GachaLogResp> {
|
||||
const params = {
|
||||
lang: "zh-cn",
|
||||
auth_appid: "webview_gacha",
|
||||
@@ -120,27 +119,26 @@ async function getGachaLog(
|
||||
size: "20",
|
||||
end_id: endId,
|
||||
};
|
||||
const resp = await TGHttp<TGApp.Game.Gacha.GachaLogResp | TGApp.BBS.Response.Base>(
|
||||
const resp = await TGHttps.get<TGApp.Game.Gacha.GachaLogResp>(
|
||||
"https://public-operation-hk4e.mihoyo.com/gacha_info/api/getGachaLog",
|
||||
{ method: "GET", query: params },
|
||||
{ query: params },
|
||||
);
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data.list;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取千星奇域抽卡记录
|
||||
* @since Beta v0.8.4
|
||||
* @since Beta v0.10.1
|
||||
* @param authKey - authKey
|
||||
* @param gachaType - 抽卡类型
|
||||
* @param endId - 结束 id,默认为 0
|
||||
* @returns 抽卡记录
|
||||
* @returns 抽卡记录响应数据
|
||||
*/
|
||||
async function getBeyondGachaLog(
|
||||
authKey: string,
|
||||
gachaType: string,
|
||||
endId: string = "0",
|
||||
): Promise<Array<TGApp.Game.Gacha.GachaBItem> | TGApp.BBS.Response.Base> {
|
||||
): Promise<TGApp.Game.Gacha.GachaBLogResp> {
|
||||
const params = {
|
||||
lang: "zh-cn",
|
||||
auth_appid: "webview_gacha",
|
||||
@@ -151,50 +149,40 @@ async function getBeyondGachaLog(
|
||||
size: "5",
|
||||
end_id: endId,
|
||||
};
|
||||
const resp = await TGHttp<TGApp.Game.Gacha.GachaBLogResp | TGApp.BBS.Response.Base>(
|
||||
const resp = await TGHttps.get<TGApp.Game.Gacha.GachaBLogResp>(
|
||||
"https://public-operation-hk4e.mihoyo.com/gacha_info/api/getBeyondGachaLog",
|
||||
{ method: "GET", query: params },
|
||||
{ query: params },
|
||||
);
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data.list;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录二维码
|
||||
* @since Beta v0.7.2
|
||||
* @since Beta v0.10.1
|
||||
* @param appId - 应用 ID
|
||||
* @remarks 目前只有2/7能用
|
||||
* @returns 二维码返回
|
||||
* @returns 二维码响应数据
|
||||
*/
|
||||
async function fetchPandaQr(
|
||||
appId: number,
|
||||
): Promise<TGApp.Game.Login.QrRes | TGApp.BBS.Response.Base> {
|
||||
async function fetchPandaQr(appId: number): Promise<TGApp.Game.Login.QrResp> {
|
||||
const data = { app_id: appId, device: getDeviceInfo("device_id") };
|
||||
const resp = await TGHttp<TGApp.Game.Login.QrResp>(`${SdkApi}combo/panda/qrcode/fetch`, {
|
||||
method: "POST",
|
||||
const resp = await TGHttps.post<TGApp.Game.Login.QrResp>(`${SdkApi}combo/panda/qrcode/fetch`, {
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录状态
|
||||
* @since Beta v0.7.2
|
||||
* @since Beta v0.10.1
|
||||
* @param ticket - 二维码 ticket
|
||||
* @param appId - 应用 ID
|
||||
* @returns 登录状态
|
||||
* @returns 登录状态响应数据
|
||||
*/
|
||||
async function queryPandaQr(
|
||||
ticket: string,
|
||||
appId: number,
|
||||
): Promise<TGApp.BBS.Response.Base | TGApp.Game.Login.StatRes> {
|
||||
async function queryPandaQr(ticket: string, appId: number): Promise<TGApp.Game.Login.StatResp> {
|
||||
const data = { app_id: appId, ticket, device: getDeviceInfo("device_id") };
|
||||
const resp = await TGHttp<TGApp.Game.Login.StatResp>(`${SdkApi}combo/panda/qrcode/query`, {
|
||||
method: "POST",
|
||||
const resp = await TGHttps.post<TGApp.Game.Login.StatResp>(`${SdkApi}combo/panda/qrcode/query`, {
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* 签到模块请求
|
||||
* @since Beta v0.9.0
|
||||
* @since Beta v0.10.1
|
||||
*/
|
||||
import { getRequestHeader } from "@utils/getRequestHeader.js";
|
||||
import TGBbs from "@utils/TGBbs.js";
|
||||
import TGHttp from "@utils/TGHttp.js";
|
||||
import TGHttps from "@utils/TGHttps.js";
|
||||
|
||||
// takumiEventLunaApiBaseUrl => telaBu
|
||||
const telaBu: Readonly<string> = "https://api-takumi.mihoyo.com/event/luna/";
|
||||
@@ -46,18 +46,18 @@ function getActConf(region: string): ReqParam | false {
|
||||
|
||||
/**
|
||||
* 获取签到奖励列表
|
||||
* @since Beta v0.7.2
|
||||
* @since Beta v0.10.1
|
||||
* @param account - 账号信息
|
||||
* @param cookie - cookies
|
||||
* @returns 签到奖励列表或基础响应
|
||||
* @returns 签到奖励列表响应数据
|
||||
*/
|
||||
async function getLunaHome(
|
||||
account: TGApp.Sqlite.Account.Game,
|
||||
cookie: Record<string, string>,
|
||||
): Promise<TGApp.BBS.Sign.HomeRes | TGApp.BBS.Response.Base> {
|
||||
): Promise<TGApp.BBS.Sign.HomeResp> {
|
||||
const conf = getActConf(account.gameBiz);
|
||||
if (conf === false) {
|
||||
return <TGApp.BBS.Response.Base>{ retcode: 1, message: "未知服务器" };
|
||||
throw new Error("未知服务器");
|
||||
}
|
||||
const url = conf.host ? `${telaBu}${conf.host}/home` : `${telaBu}home`;
|
||||
const params = { lang: "zh-cn", act_id: conf.actId };
|
||||
@@ -69,29 +69,27 @@ async function getLunaHome(
|
||||
.join("; "),
|
||||
};
|
||||
if (conf.host) header["x-rpc-signgame"] = conf.host;
|
||||
const resp = await TGHttp<TGApp.BBS.Sign.HomeResp>(url, {
|
||||
method: "GET",
|
||||
const resp = await TGHttps.get<TGApp.BBS.Sign.HomeResp>(url, {
|
||||
query: params,
|
||||
headers: header,
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到信息
|
||||
* @since Beta v0.7.2
|
||||
* @since Beta v0.10.1
|
||||
* @param account - 账号信息
|
||||
* @param cookie - cookies
|
||||
* @returns 签到信息或基础响应
|
||||
* @returns 签到信息响应数据
|
||||
*/
|
||||
async function getLunaInfo(
|
||||
account: TGApp.Sqlite.Account.Game,
|
||||
cookie: Record<string, string>,
|
||||
): Promise<TGApp.BBS.Sign.InfoRes | TGApp.BBS.Response.Base> {
|
||||
): Promise<TGApp.BBS.Sign.InfoResp> {
|
||||
const conf = getActConf(account.gameBiz);
|
||||
if (conf === false) {
|
||||
return <TGApp.BBS.Response.Base>{ retcode: 1, message: "未知服务器" };
|
||||
throw new Error("未知服务器");
|
||||
}
|
||||
const url = conf.host ? `${telaBu}${conf.host}/info` : `${telaBu}info`;
|
||||
const params = {
|
||||
@@ -108,31 +106,29 @@ async function getLunaInfo(
|
||||
.join("; "),
|
||||
};
|
||||
if (conf.host) header["x-rpc-signgame"] = conf.host;
|
||||
const resp = await TGHttp<TGApp.BBS.Sign.InfoResp>(url, {
|
||||
method: "GET",
|
||||
const resp = await TGHttps.get<TGApp.BBS.Sign.InfoResp>(url, {
|
||||
query: params,
|
||||
headers: header,
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 签到
|
||||
* @since Beta v0.9.0
|
||||
* @since Beta v0.10.1
|
||||
* @param account - 账号信息
|
||||
* @param cookie - cookies
|
||||
* @param challenge - 极验信息
|
||||
* @returns 签到结果或基础响应
|
||||
* @returns 签到结果响应数据
|
||||
*/
|
||||
async function lunaSign(
|
||||
account: TGApp.Sqlite.Account.Game,
|
||||
cookie: Record<string, string>,
|
||||
challenge?: string,
|
||||
): Promise<TGApp.BBS.Sign.SignRes | TGApp.BBS.Response.Base> {
|
||||
): Promise<TGApp.BBS.Sign.SignResp> {
|
||||
const conf = getActConf(account.gameBiz);
|
||||
if (conf === false) {
|
||||
return <TGApp.BBS.Response.Base>{ retcode: 1, message: "未知服务器" };
|
||||
throw new Error("未知服务器");
|
||||
}
|
||||
const url = conf.host ? `${telaBu}${conf.host}/sign` : `${telaBu}sign`;
|
||||
const data = {
|
||||
@@ -147,29 +143,27 @@ async function lunaSign(
|
||||
};
|
||||
if (conf.host) header["x-rpc-signgame"] = conf.host;
|
||||
if (challenge) header["x-rpc-challenge"] = challenge;
|
||||
const resp = await TGHttp<TGApp.BBS.Sign.SignResp>(url, {
|
||||
method: "POST",
|
||||
const resp = await TGHttps.post<TGApp.BBS.Sign.SignResp>(url, {
|
||||
headers: header,
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取补签信息
|
||||
* @since Beta v0.9.0
|
||||
* @since Beta v0.10.1
|
||||
* @param account - 账号信息
|
||||
* @param cookie - cookies
|
||||
* @returns 补签信息或基础响应
|
||||
* @returns 补签信息响应数据
|
||||
*/
|
||||
async function getResignInfo(
|
||||
account: TGApp.Sqlite.Account.Game,
|
||||
cookie: Record<string, string>,
|
||||
): Promise<TGApp.BBS.Sign.ResignInfoRes | TGApp.BBS.Response.Base> {
|
||||
): Promise<TGApp.BBS.Sign.ResignInfoResp> {
|
||||
const conf = getActConf(account.gameBiz);
|
||||
if (conf === false) {
|
||||
return <TGApp.BBS.Response.Base>{ retcode: 1, message: "未知服务器" };
|
||||
throw new Error("未知服务器");
|
||||
}
|
||||
const url = conf.host ? `${telaBu}${conf.host}/resign_info` : `${telaBu}info`;
|
||||
const params = {
|
||||
@@ -186,31 +180,29 @@ async function getResignInfo(
|
||||
.join("; "),
|
||||
};
|
||||
if (conf.host) header["x-rpc-signgame"] = conf.host;
|
||||
const resp = await TGHttp<TGApp.BBS.Sign.ResignInfoResp>(url, {
|
||||
method: "GET",
|
||||
const resp = await TGHttps.get<TGApp.BBS.Sign.ResignInfoResp>(url, {
|
||||
query: params,
|
||||
headers: header,
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 补签
|
||||
* @since Beta v0.9.0
|
||||
* @since Beta v0.10.1
|
||||
* @param account - 账号信息
|
||||
* @param cookie - cookies
|
||||
* @param challenge - 极验信息
|
||||
* @returns 补签结果或基础响应
|
||||
* @returns 补签结果响应数据
|
||||
*/
|
||||
async function lunaResign(
|
||||
account: TGApp.Sqlite.Account.Game,
|
||||
cookie: Record<string, string>,
|
||||
challenge?: string,
|
||||
): Promise<TGApp.BBS.Sign.ResignRes | TGApp.BBS.Response.Base> {
|
||||
): Promise<TGApp.BBS.Sign.ResignResp> {
|
||||
const conf = getActConf(account.gameBiz);
|
||||
if (conf === false) {
|
||||
return <TGApp.BBS.Response.Base>{ retcode: 1, message: "未知服务器" };
|
||||
throw new Error("未知服务器");
|
||||
}
|
||||
const url = conf.host ? `${telaBu}${conf.host}/resign` : `${telaBu}sign`;
|
||||
const data = {
|
||||
@@ -225,12 +217,10 @@ async function lunaResign(
|
||||
};
|
||||
if (conf.host) header["x-rpc-signgame"] = conf.host;
|
||||
if (challenge) header["x-rpc-challenge"] = challenge;
|
||||
const resp = await TGHttp<TGApp.BBS.Sign.ResignResp>(url, {
|
||||
method: "POST",
|
||||
const resp = await TGHttps.post<TGApp.BBS.Sign.ResignResp>(url, {
|
||||
headers: header,
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
/**
|
||||
* Misc路径下的请求
|
||||
* @since Beta v0.7.1
|
||||
* @since Beta v0.10.1
|
||||
*/
|
||||
import showGeetest from "@comp/func/geetest.js";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import { getRequestHeader } from "@utils/getRequestHeader.js";
|
||||
import TGHttp from "@utils/TGHttp.js";
|
||||
import TGHttps from "@utils/TGHttps.js";
|
||||
|
||||
// BBSApiMiscBaseUrl => bamBu
|
||||
const bamBu: Readonly<string> = "https://bbs-api.miyoushe.com/misc/api/";
|
||||
|
||||
/**
|
||||
* 创建极验验证
|
||||
* @since Beta v0.7.1
|
||||
* @since Beta v0.10.1
|
||||
* @param cookie - Cookie
|
||||
* @param useK2 - 是否使用 K2
|
||||
* @returns 极验创建结果或基础响应
|
||||
* @returns 极验创建响应数据
|
||||
*/
|
||||
async function createVerification(
|
||||
cookie: Record<string, string>,
|
||||
useK2: boolean = true,
|
||||
): Promise<TGApp.BBS.Response.Base | TGApp.BBS.Geetest.CreateRes> {
|
||||
): Promise<TGApp.BBS.Geetest.CreateResp> {
|
||||
const param = { is_high: true };
|
||||
let header;
|
||||
if (useK2) {
|
||||
@@ -29,28 +29,26 @@ async function createVerification(
|
||||
"x-rpc-client_type": "2",
|
||||
};
|
||||
} else header = getRequestHeader(cookie, "GET", param, "X4", true);
|
||||
const resp = await TGHttp<TGApp.BBS.Geetest.CreateResp>(`${bamBu}createVerification`, {
|
||||
method: "GET",
|
||||
const resp = await TGHttps.get<TGApp.BBS.Geetest.CreateResp>(`${bamBu}createVerification`, {
|
||||
headers: header,
|
||||
query: param,
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证极验验证
|
||||
* @since Beta v0.7.1
|
||||
* @since Beta v0.10.1
|
||||
* @param data - 极验验证数据
|
||||
* @param cookie - Cookie
|
||||
* @param useK2 - 是否使用 K2
|
||||
* @returns 验证结果或基础响应
|
||||
* @returns 验证响应数据
|
||||
*/
|
||||
async function verifyVerification(
|
||||
data: TGApp.BBS.Geetest.GeetestVerifyRes,
|
||||
cookie: Record<string, string>,
|
||||
useK2: boolean = true,
|
||||
): Promise<TGApp.BBS.Response.Base | string> {
|
||||
): Promise<TGApp.BBS.Geetest.VerifyResp> {
|
||||
let header;
|
||||
if (useK2) {
|
||||
header = {
|
||||
@@ -58,18 +56,16 @@ async function verifyVerification(
|
||||
"x-rpc-client_type": "2",
|
||||
};
|
||||
} else header = getRequestHeader(cookie, "POST", JSON.stringify(data), "X4");
|
||||
const resp = await TGHttp<TGApp.BBS.Geetest.VerifyResp>(`${bamBu}verifyVerification`, {
|
||||
method: "POST",
|
||||
const resp = await TGHttps.post<TGApp.BBS.Geetest.VerifyResp>(`${bamBu}verifyVerification`, {
|
||||
headers: header,
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data.challenge;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取极验验证 challenge
|
||||
* @since Beta v0.7.1
|
||||
* @since Beta v0.10.1
|
||||
* @param cookie - Cookie
|
||||
* @param useK2 - 是否使用 K2
|
||||
* @returns challenge 字符串
|
||||
@@ -78,19 +74,33 @@ async function getGeetestChallenge(
|
||||
cookie: Record<string, string>,
|
||||
useK2: boolean = false,
|
||||
): Promise<string | false> {
|
||||
const createResp = await createVerification(cookie, useK2);
|
||||
if ("retcode" in createResp) {
|
||||
showSnackbar.error(`[${createResp.retcode}] ${createResp.message}`);
|
||||
let createResp: TGApp.BBS.Geetest.CreateResp | undefined;
|
||||
try {
|
||||
createResp = await createVerification(cookie, useK2);
|
||||
if (createResp.retcode !== 0) {
|
||||
showSnackbar.error(`[${createResp.retcode}] ${createResp.message}`);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
showSnackbar.error(`创建验证失败:${errMsg}`);
|
||||
return false;
|
||||
}
|
||||
const gtRes = await showGeetest(createResp);
|
||||
const gtRes = await showGeetest(createResp.data);
|
||||
if (!gtRes) return false;
|
||||
const verifyRes = await verifyVerification(gtRes, cookie, useK2);
|
||||
if (typeof verifyRes !== "string") {
|
||||
showSnackbar.error(`[${verifyRes.retcode}] ${verifyRes.message}`);
|
||||
let verifyRes: TGApp.BBS.Geetest.VerifyResp | undefined;
|
||||
try {
|
||||
verifyRes = await verifyVerification(gtRes, cookie, useK2);
|
||||
if (verifyRes.retcode !== 0) {
|
||||
showSnackbar.error(`[${verifyRes.retcode}] ${verifyRes.message}`);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
showSnackbar.error(`验证失败:${errMsg}`);
|
||||
return false;
|
||||
}
|
||||
return verifyRes;
|
||||
return verifyRes.data.challenge;
|
||||
}
|
||||
|
||||
const miscReq = {
|
||||
|
||||
@@ -694,19 +694,25 @@ class Client {
|
||||
|
||||
/**
|
||||
* 获取米游社客户端的用户信息
|
||||
* @since Beta v0.3.9
|
||||
* @since Beta v0.10.1
|
||||
* @param arg - 类型参数
|
||||
* @returns 无返回值
|
||||
*/
|
||||
async getUserInfo(arg: TGApp.Plugins.JSBridge.NullArg): Promise<void> {
|
||||
const user = useUserStore();
|
||||
if (!user.cookie) return;
|
||||
const userInfo = await bbsReq.userInfo(user.cookie);
|
||||
if ("retcode" in userInfo) {
|
||||
console.error(`[${arg.callback}] ${userInfo.message}`);
|
||||
let userInfo: TGApp.BBS.User.InfoResp | undefined;
|
||||
try {
|
||||
userInfo = await bbsReq.userInfo(user.cookie);
|
||||
if (userInfo.retcode !== 0) {
|
||||
console.error(`[${arg.callback}] ${userInfo.message}`);
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`[${arg.callback}] ${TGHttps.getErrMsg(e)}`);
|
||||
return;
|
||||
}
|
||||
await this.callback(arg.callback, userInfo);
|
||||
await this.callback(arg.callback, userInfo.data.user_info);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,6 +76,8 @@ import showLoading from "@comp/func/loading.js";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import hk4eReq from "@req/hk4eReq.js";
|
||||
import useAppStore from "@store/app.js";
|
||||
import TGHttps from "@utils/TGHttps.js";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
import parseAnnoContent from "@utils/annoParser.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, onMounted, shallowRef } from "vue";
|
||||
@@ -102,10 +104,27 @@ onMounted(async () => {
|
||||
return;
|
||||
}
|
||||
await showLoading.update(`公告ID: ${annoId}`);
|
||||
const listResp = await hk4eReq.anno.list(region, lang);
|
||||
let listResp: TGApp.Game.Anno.ListResp | undefined;
|
||||
try {
|
||||
listResp = await hk4eReq.anno.list(region, lang);
|
||||
if (listResp.retcode !== 0) {
|
||||
showSnackbar.error(`[${listResp.retcode}] ${listResp.message}`);
|
||||
await TGLogger.Warn(
|
||||
`[t-anno-json] 获取公告列表失败:[${listResp.retcode}] ${listResp.message}`,
|
||||
);
|
||||
await showLoading.end();
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
showSnackbar.error(`获取公告列表失败:${errMsg}`);
|
||||
await TGLogger.Error(`[t-anno-json] 获取公告列表异常:${errMsg}`);
|
||||
await showLoading.end();
|
||||
return;
|
||||
}
|
||||
console.log("annoList", listResp);
|
||||
// TODO: 动态Type
|
||||
for (const listItem of listResp.list) {
|
||||
for (const listItem of listResp.data.list) {
|
||||
for (const single of listItem.list) {
|
||||
if (single.ann_id === annoId) {
|
||||
jsonList.value = single;
|
||||
@@ -113,10 +132,28 @@ onMounted(async () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
const detailResp = await hk4eReq.anno.detail(region, lang);
|
||||
const find = detailResp.find((item) => item.ann_id === annoId);
|
||||
let detailResp: TGApp.Game.Anno.DetailResp | undefined;
|
||||
try {
|
||||
detailResp = await hk4eReq.anno.detail(region, lang);
|
||||
if (detailResp.retcode !== 0) {
|
||||
showSnackbar.error(`[${detailResp.retcode}] ${detailResp.message}`);
|
||||
await TGLogger.Warn(
|
||||
`[t-anno-json] 获取公告详情失败:[${detailResp.retcode}] ${detailResp.message}`,
|
||||
);
|
||||
await showLoading.end();
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
showSnackbar.error(`获取公告详情失败:${errMsg}`);
|
||||
await TGLogger.Error(`[t-anno-json] 获取公告详情异常:${errMsg}`);
|
||||
await showLoading.end();
|
||||
return;
|
||||
}
|
||||
const find = detailResp.data.list.find((item) => item.ann_id === annoId);
|
||||
if (!find) {
|
||||
showSnackbar.error("未找到公告数据");
|
||||
await showLoading.end();
|
||||
return;
|
||||
}
|
||||
jsonContent.value = find;
|
||||
|
||||
@@ -23,6 +23,7 @@ import TaParser from "@comp/pageAnno/ta-parser.vue";
|
||||
import hk4eReq from "@req/hk4eReq.js";
|
||||
import useAppStore from "@store/app.js";
|
||||
import { app, webviewWindow } from "@tauri-apps/api";
|
||||
import TGHttps from "@utils/TGHttps.js";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
import { createTGWindow } from "@utils/TGWindow.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
@@ -44,16 +45,29 @@ onMounted(async () => {
|
||||
appVersion.value = await app.getVersion();
|
||||
if (!annoId || !region) {
|
||||
await showLoading.empty("未找到数据", "未解析到公告ID或服务器");
|
||||
await TGLogger.Error("[t-anno.vue] 未找到数据");
|
||||
await TGLogger.Error("[t-anno] 未找到数据");
|
||||
return;
|
||||
}
|
||||
await showLoading.update("正在获取数据");
|
||||
const detailResp = await hk4eReq.anno.detail(region, lang);
|
||||
let detailResp: TGApp.Game.Anno.DetailResp | undefined;
|
||||
try {
|
||||
detailResp = await hk4eReq.anno.detail(region, lang);
|
||||
if (detailResp.retcode !== 0) {
|
||||
await showLoading.empty("获取公告失败", `[${detailResp.retcode}] ${detailResp.message}`);
|
||||
await TGLogger.Warn(`[t-anno] 获取公告失败:[${detailResp.retcode}] ${detailResp.message}`);
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
const errMsg = TGHttps.getErrMsg(e);
|
||||
await showLoading.empty("获取公告失败", errMsg);
|
||||
await TGLogger.Error(`[t-anno] 获取公告异常:${errMsg}`);
|
||||
return;
|
||||
}
|
||||
await showLoading.update("正在渲染数据");
|
||||
const find = detailResp.find((item) => item.ann_id === annoId);
|
||||
const find = detailResp.data.list.find((item) => item.ann_id === annoId);
|
||||
if (!find) {
|
||||
await showLoading.empty("未找到数据", "公告不存在或解析失败");
|
||||
await TGLogger.Error(`[t-anno.vue][${annoId}] 未找到公告`);
|
||||
await TGLogger.Error(`[t-anno][${annoId}] 未找到公告`);
|
||||
await webviewWindow.getCurrentWebviewWindow().setTitle(`Anno_${annoId} Not Found`);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user