mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
🌱 获取任务完成情况
This commit is contained in:
62
src/types/BBS/Mission.d.ts
vendored
Normal file
62
src/types/BBS/Mission.d.ts
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @file types/BBS/Mission.d.ts
|
||||
* @description BBS 任务相关类型定义文件
|
||||
* @since Beta v0.6.10/v0.7.0
|
||||
*/
|
||||
|
||||
declare namespace TGApp.BBS.Mission {
|
||||
/**
|
||||
* @description 任务信息返回
|
||||
* @interface InfoResp
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @since Beta v0.6.10/v0.7.0
|
||||
* @property {TGApp.BBS.Mission.InfoRes} data 任务信息
|
||||
* @return InfoResp
|
||||
*/
|
||||
type InfoResp = TGApp.BBS.Response.BaseWithData<InfoRes>;
|
||||
|
||||
/**
|
||||
* @description 任务信息
|
||||
* @interface InfoRes
|
||||
* @since Beta v0.6.10/v0.7.0
|
||||
* @property {Array<MissionItem>} missions 任务列表
|
||||
* @property {Array<MissionItem>} more_missions 更多任务列表
|
||||
* @return InfoRes
|
||||
*/
|
||||
type InfoRes = { missions: Array<MissionItem>; more_missions: Array<MissionItem> };
|
||||
|
||||
/**
|
||||
* @description 任务项
|
||||
* @interface MissionItem
|
||||
* @since Beta v0.6.10/v0.7.0
|
||||
* @property {number} id 任务 ID
|
||||
* @property {string} name 任务名称
|
||||
* @property {string} desc 任务描述
|
||||
* @property {number} threshold 任务完成阈值
|
||||
* @property {number} limit 任务限制
|
||||
* @property {number} exp 任务经验
|
||||
* @property {number} points 米游币
|
||||
* @property {number} active_time 任务激活时间,秒级时间戳
|
||||
* @property {number} end_time 任务结束时间
|
||||
* @property {boolean} is_auto_send_award 是否自动发放奖励
|
||||
* @property {number} continuous_cycle_times 连续周期次数
|
||||
* @property {number} next_points 下一次奖励米游币
|
||||
* @property {string} mission_key 任务 key
|
||||
* @return MissionItem
|
||||
*/
|
||||
type MissionItem = {
|
||||
id: number;
|
||||
name: string;
|
||||
desc: string;
|
||||
threshold: number;
|
||||
limit: number;
|
||||
exp: number;
|
||||
points: number;
|
||||
active_time: number;
|
||||
end_time: number;
|
||||
is_auto_send_award: boolean;
|
||||
continuous_cycle_times: number;
|
||||
next_points: number;
|
||||
mission_key: string;
|
||||
};
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
/**
|
||||
* @file web/request/apiHubReq.ts
|
||||
* @description apiHub下的请求
|
||||
* @since Beta v0.6.8
|
||||
* @since Beta v0.6.10/v0.7.0
|
||||
*/
|
||||
|
||||
import TGHttp from "@/utils/TGHttp.js";
|
||||
import { getRequestHeader } from "@/web/utils/getRequestHeader.js";
|
||||
|
||||
// MysApiHubApiBaseUrl => Mahabu
|
||||
const Mahabu: Readonly<string> = "https://bbs-api.miyoushe.com/apihub/api/";
|
||||
// MysApiHubWapiBaseUrl => Mahwbu
|
||||
const Mahwbu: Readonly<string> = "https://bbs-api.miyoushe.com/apihub/wapi/";
|
||||
// MysApiHubBaseUrl => Mahbu
|
||||
const Mahbu: Readonly<string> = "https://bbs-api.miyoushe.com/apihub/";
|
||||
const Referer: Readonly<string> = "https://bbs.mihoyo.com/";
|
||||
|
||||
/**
|
||||
@@ -19,7 +18,7 @@ const Referer: Readonly<string> = "https://bbs.mihoyo.com/";
|
||||
*/
|
||||
async function getAllGamesForums(): Promise<Array<TGApp.BBS.Forum.GameForum>> {
|
||||
return (
|
||||
await TGHttp<TGApp.BBS.Forum.GameForumResp>(`${Mahwbu}getAllGamesForums`, {
|
||||
await TGHttp<TGApp.BBS.Forum.GameForumResp>(`${Mahbu}wapi/getAllGamesForums`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json", referer: Referer },
|
||||
})
|
||||
@@ -33,13 +32,27 @@ async function getAllGamesForums(): Promise<Array<TGApp.BBS.Forum.GameForum>> {
|
||||
*/
|
||||
async function getGameList(): Promise<Array<TGApp.BBS.Game.Item>> {
|
||||
return (
|
||||
await TGHttp<TGApp.BBS.Game.ListResp>(`${Mahwbu}getGameList`, {
|
||||
await TGHttp<TGApp.BBS.Game.ListResp>(`${Mahbu}wapi/getGameList`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json", referer: Referer },
|
||||
})
|
||||
).data.list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取用户米游币任务完成情况
|
||||
* @since Beta v0.6.10/v0.7.0
|
||||
* @param {Record<string,string>} cookie 用户 Cookie
|
||||
* @return {Promise<TGApp.BBS.Mission.InfoRes>}
|
||||
*/
|
||||
async function getMissions(cookie: Record<string, string>): Promise<TGApp.BBS.Mission.InfoResp> {
|
||||
const header = getRequestHeader(cookie, "GET", {});
|
||||
return await TGHttp<TGApp.BBS.Mission.InfoResp>(`${Mahbu}api/getMissions`, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取投票信息
|
||||
* @since Beta v0.6.2
|
||||
@@ -49,7 +62,7 @@ async function getGameList(): Promise<Array<TGApp.BBS.Game.Item>> {
|
||||
*/
|
||||
async function getVotes(id: string, uid: string): Promise<TGApp.BBS.Vote.Info> {
|
||||
return (
|
||||
await TGHttp<TGApp.BBS.Vote.InfoResp>(`${Mahabu}getVotes`, {
|
||||
await TGHttp<TGApp.BBS.Vote.InfoResp>(`${Mahbu}api/getVotes`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json", referer: Referer },
|
||||
query: { owner_uid: uid, vote_ids: id },
|
||||
@@ -66,7 +79,7 @@ async function getVotes(id: string, uid: string): Promise<TGApp.BBS.Vote.Info> {
|
||||
*/
|
||||
async function getVoteResult(id: string, uid: string): Promise<TGApp.BBS.Vote.Result> {
|
||||
return (
|
||||
await TGHttp<TGApp.BBS.Vote.ResultResp>(`${Mahabu}getVotesResult`, {
|
||||
await TGHttp<TGApp.BBS.Vote.ResultResp>(`${Mahbu}api/getVotesResult`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json", referer: Referer },
|
||||
query: { owner_uid: uid, vote_ids: id },
|
||||
@@ -82,7 +95,7 @@ async function getVoteResult(id: string, uid: string): Promise<TGApp.BBS.Vote.Re
|
||||
*/
|
||||
async function homeNew(gid: number = 2): Promise<TGApp.BBS.Navigator.Navigator[]> {
|
||||
return (
|
||||
await TGHttp<TGApp.BBS.Navigator.HomeResponse>(`${Mahabu}home/new`, {
|
||||
await TGHttp<TGApp.BBS.Navigator.HomeResponse>(`${Mahbu}api/home/new`, {
|
||||
method: "GET",
|
||||
headers: { "x-rpc-client_type": "2" },
|
||||
query: { gids: gid },
|
||||
@@ -95,6 +108,7 @@ const apiHubReq = {
|
||||
home: homeNew,
|
||||
forum: getAllGamesForums,
|
||||
game: getGameList,
|
||||
mission: getMissions,
|
||||
};
|
||||
|
||||
export default apiHubReq;
|
||||
|
||||
Reference in New Issue
Block a user