mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
♻️ 返回完整数据
This commit is contained in:
@@ -302,14 +302,20 @@ async function confirmRefreshUser(): Promise<void> {
|
|||||||
failCount++;
|
failCount++;
|
||||||
}
|
}
|
||||||
await TGSqlite.saveAppData("cookie", JSON.stringify(ck));
|
await TGSqlite.saveAppData("cookie", JSON.stringify(ck));
|
||||||
const infoRes = await TGRequest.User.byCookie.getUserInfo(ck.cookie_token, ck.account_id, false);
|
const infoRes = await TGRequest.User.byCookie.getUserInfo(ck.cookie_token, ck.account_id);
|
||||||
if ("retcode" in infoRes) {
|
if ("retcode" in infoRes) {
|
||||||
console.error(infoRes);
|
console.error(infoRes);
|
||||||
loadingTitle.value = "获取失败!正在获取用户游戏账号信息";
|
loadingTitle.value = "获取失败!正在获取用户游戏账号信息";
|
||||||
failCount++;
|
failCount++;
|
||||||
} else {
|
} else {
|
||||||
userStore.setBriefInfo(infoRes);
|
const briefInfo: TGApp.App.Account.BriefInfo = {
|
||||||
await TGSqlite.saveAppData("userInfo", JSON.stringify(infoRes));
|
nickname: infoRes.nickname,
|
||||||
|
uid: infoRes.uid,
|
||||||
|
avatar: infoRes.avatar_url,
|
||||||
|
desc: infoRes.introduce,
|
||||||
|
};
|
||||||
|
userStore.setBriefInfo(briefInfo);
|
||||||
|
await TGSqlite.saveAppData("userInfo", JSON.stringify(briefInfo));
|
||||||
loadingTitle.value = "获取成功!正在获取用户游戏账号信息";
|
loadingTitle.value = "获取成功!正在获取用户游戏账号信息";
|
||||||
}
|
}
|
||||||
const accountRes = await TGRequest.User.byCookie.getAccounts(ck.cookie_token, ck.account_id);
|
const accountRes = await TGRequest.User.byCookie.getAccounts(ck.cookie_token, ck.account_id);
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ class TGClient {
|
|||||||
const user = useUserStore();
|
const user = useUserStore();
|
||||||
const cookieToken = user.cookie.cookie_token;
|
const cookieToken = user.cookie.cookie_token;
|
||||||
const accountId = user.cookie.account_id;
|
const accountId = user.cookie.account_id;
|
||||||
const userInfo = await TGRequest.User.byCookie.getUserInfo(cookieToken, accountId, true);
|
const userInfo = await TGRequest.User.byCookie.getUserInfo(cookieToken, accountId);
|
||||||
if ("retcode" in userInfo) {
|
if ("retcode" in userInfo) {
|
||||||
console.error(`[${callback}] ${userInfo.message}`);
|
console.error(`[${callback}] ${userInfo.message}`);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -12,27 +12,14 @@ import TGUtils from "../utils/TGUtils";
|
|||||||
/**
|
/**
|
||||||
* @description 根据 cookie 获取用户信息
|
* @description 根据 cookie 获取用户信息
|
||||||
* @since Beta v0.3.4
|
* @since Beta v0.3.4
|
||||||
* @todo 完善
|
|
||||||
* @param {string} cookie_token cookie token
|
* @param {string} cookie_token cookie token
|
||||||
* @param {string} account_id 用户 account_id
|
* @param {string} account_id 用户 account_id
|
||||||
* @param {boolean} return_full 是否返回完整信息
|
* @returns {Promise<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.User.Info>}
|
||||||
* @returns {Promise<TGApp.App.Account.BriefInfo | TGApp.Plugins.Mys.User.Info>}
|
|
||||||
*/
|
*/
|
||||||
export async function getUserInfoByCookie(
|
export async function getUserInfoByCookie(
|
||||||
cookie_token: string,
|
cookie_token: string,
|
||||||
account_id: string,
|
account_id: string,
|
||||||
return_full: false,
|
): Promise<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.User.Info> {
|
||||||
): Promise<TGApp.App.Account.BriefInfo | TGApp.BBS.Response.Base>;
|
|
||||||
export async function getUserInfoByCookie(
|
|
||||||
cookie_token: string,
|
|
||||||
account_id: string,
|
|
||||||
return_full: true,
|
|
||||||
): Promise<TGApp.Plugins.Mys.User.Info | TGApp.BBS.Response.Base>;
|
|
||||||
export async function getUserInfoByCookie(
|
|
||||||
cookie_token: string,
|
|
||||||
account_id: string,
|
|
||||||
return_full: boolean = false,
|
|
||||||
): Promise<TGApp.App.Account.BriefInfo | TGApp.BBS.Response.Base | TGApp.Plugins.Mys.User.Info> {
|
|
||||||
const cookie = {
|
const cookie = {
|
||||||
cookie_token,
|
cookie_token,
|
||||||
account_id,
|
account_id,
|
||||||
@@ -48,13 +35,6 @@ export async function getUserInfoByCookie(
|
|||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.data.retcode !== 0) return res.data;
|
if (res.data.retcode !== 0) return res.data;
|
||||||
const info = res.data.data.user_info;
|
return res.data.data.user_info;
|
||||||
if (return_full === undefined || return_full) return info;
|
|
||||||
return {
|
|
||||||
nickname: info.nickname,
|
|
||||||
uid: info.uid,
|
|
||||||
avatar: info.avatar_url,
|
|
||||||
desc: info.introduce,
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user