mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
🌱 获取用户信息
This commit is contained in:
@@ -23,7 +23,7 @@ import showSnackbar from "@comp/func/snackbar.js";
|
||||
import Mys from "@Mys/index.js";
|
||||
import { computed, onMounted, ref, shallowRef, watch } from "vue";
|
||||
|
||||
import { getGameName } from "@/web/utils/tools.js";
|
||||
import { getGameName } from "@/utils/toolFunc.js";
|
||||
|
||||
type ToPostSearchProps = { modelValue: boolean; gid: string; keyword?: string };
|
||||
type ToPostSearchEmits = (e: "update:modelValue", v: boolean) => void;
|
||||
|
||||
@@ -68,7 +68,7 @@ import { useRoute, useRouter } from "vue-router";
|
||||
import { type NewsType, NewsTypeEnum, useAppStore } from "@/store/modules/app.js";
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import { createPost } from "@/utils/TGWindow.js";
|
||||
import { getGameName } from "@/web/utils/tools.js";
|
||||
import { getGameName } from "@/utils/toolFunc.js";
|
||||
|
||||
type PostData = { [key in NewsType]: Array<TGApp.Plugins.Mys.Post.FullData> };
|
||||
type RawData = { [key in NewsType]: { isLast: boolean; name: string; lastId: number } };
|
||||
|
||||
@@ -26,6 +26,34 @@ async function getUserFullInfo(
|
||||
return resp.data.user_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据gid和id获取用户信息
|
||||
* @since Beta v0.6.7
|
||||
* @param {number} gid - gid
|
||||
* @param {string} userId - 用户 id
|
||||
* @returns {Promise<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.User.Info>}
|
||||
*/
|
||||
async function getOtherUserInfo(
|
||||
gid: number,
|
||||
userId: string,
|
||||
): Promise<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.User.Info> {
|
||||
const params = { gids: gid.toString(), uid: userId };
|
||||
const resp = await TGHttp<TGApp.Plugins.Mys.User.HomeResponse | TGApp.BBS.Response.Base>(
|
||||
"https://bbs-api.miyoushe.com/user/wapi/getUserFullInfo",
|
||||
{ method: "GET", headers: getRequestHeader({}, "GET", params, "X4", true), query: params },
|
||||
);
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data.user_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取用户发布帖子
|
||||
* @since Beta v0.6.7
|
||||
* @param {string} uid - 用户 uid
|
||||
* @param [string] offset - 偏移量
|
||||
* @returns {Promise<TGApp.BBS.Collection.PostRespData|TGApp.BBS.Response.Base>} 用户发布帖子
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description 获取用户收藏帖子
|
||||
* @since Beta v0.6.3
|
||||
@@ -49,6 +77,10 @@ async function userFavouritePost(
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
const BBSApi = { userInfo: getUserFullInfo, lovePost: userFavouritePost };
|
||||
const BBSApi = {
|
||||
userInfo: getUserFullInfo,
|
||||
otherUserInfo: getOtherUserInfo,
|
||||
lovePost: userFavouritePost,
|
||||
};
|
||||
|
||||
export default BBSApi;
|
||||
|
||||
@@ -17,19 +17,20 @@ const tbAbu: Readonly<string> = "https://api-takumi.mihoyo.com/binding/api/";
|
||||
* @param {TGApp.App.Account.Cookie} cookie Cookie
|
||||
* @param {TGApp.Sqlite.Account.Game} user 用户
|
||||
* @param {string} actionType 动作类型
|
||||
* @returns {Promise<TGApp.BBS.Response.getActionTicketBySToken>}
|
||||
* @returns {Promise<ActionTicketByStokenResp>}
|
||||
*/
|
||||
async function getActionTicketBySToken(
|
||||
cookie: TGApp.App.Account.Cookie,
|
||||
user: TGApp.Sqlite.Account.Game,
|
||||
actionType: string,
|
||||
): Promise<TGApp.BBS.Response.getActionTicketBySToken> {
|
||||
): Promise<ActionTicketByStokenResp> {
|
||||
const ck = { stoken: cookie.stoken, mid: cookie.mid };
|
||||
const params = { action_type: actionType, stoken: cookie.stoken, uid: user.gameUid };
|
||||
return await TGHttp<TGApp.BBS.Response.getActionTicketBySToken>(
|
||||
`${taAbu}getActionTicketBySToken`,
|
||||
{ method: "GET", headers: getRequestHeader(ck, "GET", params, "K2"), query: params },
|
||||
);
|
||||
return await TGHttp<ActionTicketByStokenResp>(`${taAbu}getActionTicketBySToken`, {
|
||||
method: "GET",
|
||||
headers: getRequestHeader(ck, "GET", params, "K2"),
|
||||
query: params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,10 +92,11 @@ async function getUserGameRolesByCookie(
|
||||
): Promise<TGApp.BBS.Account.GameAccount[] | TGApp.BBS.Response.Base> {
|
||||
const ck = { account_id: cookie.account_id, cookie_token: cookie.cookie_token };
|
||||
const params = { game_biz: "hk4e_cn" };
|
||||
const resp = await TGHttp<TGApp.BBS.Response.getGameAccounts | TGApp.BBS.Response.Base>(
|
||||
`${tbAbu}getUserGameRolesByCookie`,
|
||||
{ method: "GET", headers: getRequestHeader(ck, "GET", params), query: params },
|
||||
);
|
||||
const resp = await TGHttp<GameAccountsResp>(`${tbAbu}getUserGameRolesByCookie`, {
|
||||
method: "GET",
|
||||
headers: getRequestHeader(ck, "GET", params),
|
||||
query: params,
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data.list;
|
||||
}
|
||||
@@ -105,3 +107,42 @@ const TakumiApi = {
|
||||
};
|
||||
|
||||
export default TakumiApi;
|
||||
|
||||
/// 一些类型 ///
|
||||
type ActionTicketByStokenResp = TGApp.BBS.Response.BaseWithData & {
|
||||
data: {
|
||||
ticket: string;
|
||||
is_verified: boolean;
|
||||
account_info: {
|
||||
is_realname: boolean;
|
||||
mobile: string;
|
||||
safe_mobile: string;
|
||||
account_id: string;
|
||||
account_name: string;
|
||||
email: string;
|
||||
is_email_verify: boolean;
|
||||
area_code: string;
|
||||
safe_area_code: string;
|
||||
real_name: string;
|
||||
identity_code: string;
|
||||
create_time: string;
|
||||
create_ip: string;
|
||||
change_pwd_time: string;
|
||||
nickname: string;
|
||||
user_icon_id: number;
|
||||
safe_level: number;
|
||||
black_endtime: string;
|
||||
black_note: string;
|
||||
gender: number;
|
||||
real_stat: number;
|
||||
apple_name: string;
|
||||
sony_name: string;
|
||||
tap_name: string;
|
||||
reactivate_ticket: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
type GameAccountsResp = TGApp.BBS.Response.BaseWithData & {
|
||||
data: { list: Array<TGApp.BBS.Account.GameAccount> };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user