♻️ 姑且能跑 dev,尚需调试功能

This commit is contained in:
目棃
2024-07-02 23:05:33 +08:00
parent 1214501691
commit 367307029b
66 changed files with 12626 additions and 2887 deletions

View File

@@ -1,12 +1,10 @@
/**
* @file plugins/Mys/utils/doGameLogin
* @file plugins/Mys/request/doGameLogin
* @description 获取 gameToken曲线获取 stoken
* @since Beta v0.4.4
* @since Beta v0.5.0
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import TGHttp from "../../../utils/TGHttp.js";
import { getDeviceInfo } from "../../../utils/toolFunc.js";
import { getRequestHeader } from "../../../web/utils/getRequestHeader.js";
@@ -14,7 +12,7 @@ const APP_ID = 8;
/**
* @description 获取登录二维码
* @since Beta v0.4.4
* @since Beta v0.5.0
* @returns {Promise<TGApp.Plugins.Mys.GameLogin.GetLoginQrData|TGApp.BBS.Response.Base>}
*/
export async function getLoginQr(): Promise<
@@ -24,19 +22,20 @@ export async function getLoginQr(): Promise<
const device = getDeviceInfo("device_id");
const data = { app_id: APP_ID, device };
const header = getRequestHeader({}, "POST", data, "common");
return await http
.fetch(url, { headers: header, method: "POST", body: http.Body.json(data) })
.then(
(res: Response<TGApp.Plugins.Mys.GameLogin.GetLoginQrResponse | TGApp.BBS.Response.Base>) => {
if (res.data.retcode === 0) return res.data.data;
return <TGApp.BBS.Response.Base>res.data;
},
);
const resp = await TGHttp<
TGApp.Plugins.Mys.GameLogin.GetLoginQrResponse | TGApp.BBS.Response.Base
>(url, {
method: "POST",
headers: header,
body: JSON.stringify(data),
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data;
}
/**
* @description 获取登录状态
* @since Beta v0.4.4
* @since Beta v0.5.0
* @param {string} ticket 二维码 ticket
* @returns {Promise<TGApp.Plugins.Mys.GameLogin.GetLoginStatusData | TGApp.BBS.Response.Base>}
*/
@@ -47,14 +46,13 @@ export async function getLoginStatus(
const device = getDeviceInfo("device_id");
const data = { app_id: APP_ID, device, ticket };
const header = getRequestHeader({}, "POST", data, "common");
return await http
.fetch(url, { headers: header, method: "POST", body: http.Body.json(data) })
.then(
(
res: Response<TGApp.Plugins.Mys.GameLogin.GetLoginStatusResponse | TGApp.BBS.Response.Base>,
) => {
if (res.data.retcode === 0) return res.data.data;
return <TGApp.BBS.Response.Base>res.data;
},
);
const resp = await TGHttp<
TGApp.Plugins.Mys.GameLogin.GetLoginStatusResponse | TGApp.BBS.Response.Base
>(url, {
method: "POST",
headers: header,
body: JSON.stringify(data),
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data;
}

View File

@@ -1,17 +1,15 @@
/**
* @file plugins/Mys/request/getCollectionPosts.ts
* @description Mys 获取合集帖子
* @since Beta v0.4.5
* @since Beta v0.5.0
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import TGHttp from "../../../utils/TGHttp.js";
import MysApi from "../api/index.js";
/**
* @description 获取合集信息
* @since Beta v0.4.5
* @since Beta v0.5.0
* @todo invalid request
* @param {number} collectionId 合集 ID
* @returns {Promise<TGApp.Plugins.Mys.Collection.ResponseData>} 合集信息
@@ -20,24 +18,18 @@ export async function getCollectionData(
collectionId: number,
): Promise<TGApp.Plugins.Mys.Collection.ResponseData> {
const url = "https://bbs-api.miyoushe.com/collection/wapi/collection/detail";
const params = {
id: collectionId.toString(),
};
return await http
.fetch(url, {
method: "GET",
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
})
.then((res: Response<TGApp.Plugins.Mys.Collection.Response>) => {
console.log(res.data);
return res.data.data;
});
const params = { id: collectionId.toString() };
const resp = await TGHttp<TGApp.Plugins.Mys.Collection.Response>(url, {
method: "GET",
query: params,
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
});
return resp.data;
}
/**
* @description 获取合集帖子
* @since Beta v0.4.5
* @since Beta v0.5.0
* @param {string} collectionId 合集 ID
* @returns {Promise<TGApp.Plugins.Mys.Post.FullData[]>}
*/
@@ -46,11 +38,10 @@ export async function getCollectionPosts(
): Promise<TGApp.Plugins.Mys.Collection.Data[]> {
const url = "https://bbs-api.miyoushe.com/post/wapi/getPostFullInCollection";
const params = { collection_id: collectionId };
return await http
.fetch(url, {
method: "GET",
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
})
.then((res: Response<TGApp.Plugins.Mys.Collection.ResponsePosts>) => res.data.data.posts);
const resp = await TGHttp<TGApp.Plugins.Mys.Collection.ResponsePosts>(url, {
method: "GET",
query: params,
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
});
return resp.data.posts;
}

View File

@@ -1,31 +1,27 @@
/**
* @file plugins/Mys/request/getEmojis.ts
* @description Mys 表情包请求函数集合
* @since Beta v0.3.0
* @since Beta v0.5.0
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 获取表情包列表
* @since Beta v0.3.0
* @since Beta v0.5.0
* @return {Promise<Record<string,string>|TGApp.BBS.Response.Base>}
*/
export async function getEmojis(): Promise<Record<string, string> | TGApp.BBS.Response.Base> {
const url = "https://bbs-api-static.miyoushe.com/misc/api/emoticon_set";
return await http
.fetch(url)
.then((res: Response<TGApp.Plugins.Mys.Emoji.Response | TGApp.BBS.Response.Base>) => {
if (res.data.retcode === 0) {
const emojis: Record<string, string> = {};
res.data.data.list.forEach((series) => {
series.list.forEach((emoji) => {
emojis[emoji.name] = emoji.icon;
});
});
return emojis;
}
return res.data;
const resp = await TGHttp<TGApp.Plugins.Mys.Emoji.Response | TGApp.BBS.Response.Base>(url, {
method: "GET",
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
const emojis: Record<string, string> = {};
resp.data.list.forEach((series) => {
series.list.forEach((emoji) => {
emojis[emoji.name] = emoji.icon;
});
});
return emojis;
}

View File

@@ -1,15 +1,14 @@
/**
* @file plugins/Mys/request/getForumList.ts
* @description Mys 插件特定论坛请求
* @since Beta v0.4.5
* @since Beta v0.5.0
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 获取特定论坛列表
* @since Beta v0.4.5
* @since Beta v0.5.0
* @param {number} forumId 特定论坛 ID
* @param {number} type 排序方式: 0-按热度排序1-最新回复2-按时间排序
* @return {Promise<TGApp.Plugins.Mys.Forum.FullData>}
@@ -20,9 +19,11 @@ async function getForumList(
): Promise<TGApp.Plugins.Mys.Forum.FullData> {
const url = "https://bbs-api.miyoushe.com/post/wapi/getForumPostList";
const params = { forum_id: forumId.toString(), sort_type: type.toString() };
return await http
.fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, query: params })
.then((res: Response<TGApp.Plugins.Mys.Forum.Response>) => res.data.data);
const resp = await TGHttp<TGApp.Plugins.Mys.Forum.Response>(url, {
method: "GET",
query: params,
});
return resp.data;
}
export default getForumList;

View File

@@ -4,19 +4,20 @@
* @since Beta v0.4.5
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 获取卡池信息
* @since Beta v0.4.5
* @since Beta v0.5.0
* @return {Promise<TGApp.Plugins.Mys.Gacha.Data[]>}
*/
async function getGachaData(): Promise<TGApp.Plugins.Mys.Gacha.Data[]> {
const url = "https://api-takumi.mihoyo.com/common/blackboard/ys_obc/v1/gacha_pool?app_sn=ys_obc";
return await http
.fetch(url, { method: "GET", headers: { "Content-Type": "application/json" } })
.then((res: Response<TGApp.Plugins.Mys.Gacha.Response>) => res.data.data.list);
const resp = await TGHttp<TGApp.Plugins.Mys.Gacha.Response>(url, {
method: "GET",
headers: { "Content-Type": "application/json" },
});
return resp.data.list;
}
export default getGachaData;

View File

@@ -1,24 +1,26 @@
/**
* @file plugins/Mys/request/getHomeNavigator.ts
* @description Mys 插件首页导航请求
* @since Beta v0.4.5
* @since Beta v0.5.0
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 获取首页导航列表
* @since Beta v0.4.5
* @since Beta v0.5.0
* @param {number} gid GID
* @return {Promise<TGApp.BBS.Navigator.Navigator[]>}
*/
async function getHomeNavigator(gid: number = 2): Promise<TGApp.BBS.Navigator.Navigator[]> {
const url = "https://bbs-api.miyoushe.com/apihub/api/home/new";
const params = { gids: gid.toString() };
return await http
.fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, query: params })
.then((res: Response<TGApp.BBS.Navigator.HomeResponse>) => res.data.data.navigator);
const resp = await TGHttp<TGApp.BBS.Navigator.HomeResponse>(url, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: params,
});
return resp.data.navigator;
}
export default getHomeNavigator;

View File

@@ -1,15 +1,14 @@
/**
* @file plugins/Mys/request/getLotteryData.ts
* @description Mys 插件抽奖接口
* @since Beta v0.4.5
* @since Beta v0.5.0
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 获取抽奖信息
* @since Beta v0.4.5
* @since Beta v0.5.0
* @param {string} lotteryId 抽奖 ID
* @return {Promise<TGApp.BBS.Response.Base|TGApp.Plugins.Mys.Lottery.FullData>}
*/
@@ -18,12 +17,13 @@ async function getLotteryData(
): Promise<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.Lottery.FullData> {
const url = "https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show";
const params = { id: lotteryId };
return await http
.fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, query: params })
.then((res: Response<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.Lottery.Response>) => {
if (res.data.retcode !== 0) return <TGApp.BBS.Response.Base>res.data;
return res.data.data.show_lottery;
});
const resp = await TGHttp<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.Lottery.Response>(url, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: params,
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data.show_lottery;
}
export default getLotteryData;

View File

@@ -1,15 +1,14 @@
/**
* @file plugins/Mys/request/getNewsList.ts
* @description Mys 插件咨讯请求
* @since Beta v0.4.5
* @since Beta v0.5.0
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 获取 News 列表
* @since Beta v0.4.5
* @since Beta v0.5.0
* @param {string} gid GID
* @param {string} newsType 咨讯类型: 1 为公告2 为活动3 为咨讯
* @param {number} pageSize 返回数量
@@ -29,9 +28,12 @@ async function getNewsList(
type: newsType,
last_id: lastId.toString(),
};
return await http
.fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, query: params })
.then((res: Response<TGApp.Plugins.Mys.News.Response>) => res.data.data);
const resp = await TGHttp<TGApp.Plugins.Mys.News.Response>(url, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: params,
});
return resp.data;
}
export default getNewsList;

View File

@@ -1,11 +1,10 @@
/**
* @file plugins/Mys/request/getPositionData.ts
* @description Mys 插件热点追踪请求
* @since Beta v0.4.5
* @since Beta v0.5.0
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 深度优先遍历
@@ -28,14 +27,16 @@ function DfsObc(list: TGApp.Plugins.Mys.Position.ObcItem[]): TGApp.Plugins.Mys.P
/**
* @description 获取热点追踪信息
* @since Beta v0.4.5
* @since Beta v0.5.0
* @return {Promise<TGApp.Plugins.Mys.Position.Data[]>}
*/
export async function getPositionData(): Promise<TGApp.Plugins.Mys.Position.Data[]> {
const url =
"https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/home/position?app_sn=ys_obc";
const res = await http
.fetch(url, { method: "GET", headers: { "Content-Type": "application/json" } })
.then((res: Response<TGApp.Plugins.Mys.Position.Response>) => res.data.data.list);
return DfsObc(res);
const resp = await TGHttp<TGApp.Plugins.Mys.Position.Response>(url, {
method: "GET",
headers: { "Content-Type": "application/json" },
});
const data = resp.data.list;
return DfsObc(data);
}

View File

@@ -1,32 +1,27 @@
/**
* @file plugins Mys request getPostData.ts
* @description Mys帖子请求
* @since Beta v0.4.5
* @since Beta v0.5.0
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import TGHttp from "../../../utils/TGHttp.js";
import MysApi from "../api/index.js";
/**
* @description 获取帖子信息
* @since Beta v0.4.5
* @since Beta v0.5.0
* @param {number} postId 帖子 ID
* @return {Promise<TGApp.Plugins.Mys.Post.FullData>}
*/
async function getPostData(postId: number): Promise<TGApp.Plugins.Mys.Post.FullData> {
const url = "https://bbs-api.mihoyo.com/post/wapi/getPostFull";
const params = {
post_id: postId.toString(),
};
return await http
.fetch(url, {
method: "GET",
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
})
.then((res: Response<TGApp.Plugins.Mys.Post.Response>) => res.data.data.post);
const params = { post_id: postId.toString() };
const resp = await TGHttp<TGApp.Plugins.Mys.Post.Response>(url, {
method: "GET",
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
});
return resp.data.post;
}
export default getPostData;

View File

@@ -1,17 +1,15 @@
/**
* @file plugins/Mys/request/getVoteData.ts
* @description Mys 插件投票请求
* @since Beta v0.4.5
* @since Beta v0.5.0
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import TGHttp from "../../../utils/TGHttp.js";
import MysApi from "../api/index.js";
/**
* @description 获取投票信息
* @since Beta v0.4.5
* @since Beta v0.5.0
* @param {string} id 投票 ID
* @param {string} uid 用户 ID
* @return {Promise<TGApp.Plugins.Mys.Vote.Info>}
@@ -19,18 +17,17 @@ import MysApi from "../api/index.js";
export async function getVoteInfo(id: string, uid: string): Promise<TGApp.Plugins.Mys.Vote.Info> {
const url = "https://bbs-api.miyoushe.com/apihub/api/getVotes";
const params = { owner_uid: uid, vote_ids: id };
return await http
.fetch(url, {
method: "GET",
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
})
.then((res: Response<TGApp.Plugins.Mys.Vote.InfoResponse>) => res.data.data.data[0]);
const resp = await TGHttp<TGApp.Plugins.Mys.Vote.InfoResponse>(url, {
method: "GET",
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
});
return resp.data.data[0];
}
/**
* @description 获取投票结果
* @since Beta v0.4.5
* @since Beta v0.5.0
* @param {string} id 投票 ID
* @param {string} uid 用户 ID
* @return {Promise<TGApp.Plugins.Mys.Vote.Result>}
@@ -41,11 +38,10 @@ export async function getVoteResult(
): Promise<TGApp.Plugins.Mys.Vote.Result> {
const url = "https://bbs-api.miyoushe.com/apihub/api/getVotesResult";
const params = { owner_uid: uid, vote_ids: id };
return await http
.fetch(url, {
method: "GET",
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
})
.then((res: Response<TGApp.Plugins.Mys.Vote.ResultResponse>) => res.data.data.data[0]);
const resp = await TGHttp<TGApp.Plugins.Mys.Vote.ResultResponse>(url, {
method: "GET",
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
});
return resp.data.data[0];
}

View File

@@ -1,15 +1,14 @@
/**
* @file plugins/Mys/request/searchPost.ts
* @description 帖子搜索
* @since Beta v0.4.5
* @since Beta v0.5.0
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 搜索帖子
* @since Beta v0.4.5
* @since Beta v0.5.0
* @param {string} gid 游戏分区 ID
* @param {string} keyword 关键词
* @param {string} last_id 最后一条帖子 ID
@@ -22,9 +21,12 @@ async function searchPosts(
): Promise<TGApp.Plugins.Mys.Search.PostsResponseData> {
const url = "https://bbs-api.miyoushe.com/post/wapi/searchPosts";
const params = { gids: gid, keyword, last_id, size: "20" };
return await http
.fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, query: params })
.then((res: Response<TGApp.Plugins.Mys.Search.PostsResponse>) => res.data.data);
const resp = await TGHttp<TGApp.Plugins.Mys.Search.PostsResponse>(url, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: params,
});
return resp.data;
}
export default searchPosts;

View File

@@ -1,12 +1,12 @@
/**
* @file plugins/Mys/utils/getPositionCard.ts
* @description Mys 插件热点追踪工具
* @since Beta v0.4.10
* @since Beta v0.5.0
*/
/**
* @description 根据热点追踪信息转为渲染用的数据
* @since Beta v0.4.10
* @since Beta v0.5.0
* @param {TGApp.Plugins.Mys.Position.Data[]} positionData 列表
* @returns {TGApp.Plugins.Mys.Position.RenderCard[]} 返回列表
*/