✏️ 修正剩余的import

This commit is contained in:
目棃
2024-07-01 14:17:13 +08:00
parent d48e39e580
commit bdd5e99f95
27 changed files with 162 additions and 310 deletions

View File

@@ -5,9 +5,10 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import { getDeviceInfo } from "../../../utils/toolFunc";
import { getRequestHeader } from "../../../web/utils/getRequestHeader";
import { getDeviceInfo } from "../../../utils/toolFunc.js";
import { getRequestHeader } from "../../../web/utils/getRequestHeader.js";
const APP_ID = 8;
@@ -21,21 +22,16 @@ export async function getLoginQr(): Promise<
> {
const url = "https://hk4e-sdk.mihoyo.com/hk4e_cn/combo/panda/qrcode/fetch";
const device = getDeviceInfo("device_id");
const data = {
app_id: APP_ID,
device,
};
const data = { app_id: APP_ID, device };
const header = getRequestHeader({}, "POST", data, "common");
return await http
.fetch<TGApp.Plugins.Mys.GameLogin.GetLoginQrResponse | TGApp.BBS.Response.Base>(url, {
headers: header,
method: "POST",
body: http.Body.json(data),
})
.then((res) => {
if (res.data.retcode === 0) return res.data.data;
return <TGApp.BBS.Response.Base>res.data;
});
.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;
},
);
}
/**
@@ -52,13 +48,13 @@ export async function getLoginStatus(
const data = { app_id: APP_ID, device, ticket };
const header = getRequestHeader({}, "POST", data, "common");
return await http
.fetch<TGApp.Plugins.Mys.GameLogin.GetLoginStatusResponse | TGApp.BBS.Response.Base>(url, {
headers: header,
method: "POST",
body: http.Body.json(data),
})
.then((res) => {
if (res.data.retcode === 0) return res.data.data;
return <TGApp.BBS.Response.Base>res.data;
});
.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;
},
);
}

View File

@@ -5,8 +5,9 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import MysApi from "../api";
import MysApi from "../api/index.js";
/**
* @description 获取合集信息
@@ -23,15 +24,12 @@ export async function getCollectionData(
id: collectionId.toString(),
};
return await http
.fetch<TGApp.Plugins.Mys.Collection.Response>(url, {
.fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
Referer: MysApi.PostReferer,
},
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
})
.then((res) => {
.then((res: Response<TGApp.Plugins.Mys.Collection.Response>) => {
console.log(res.data);
return res.data.data;
});
@@ -47,19 +45,12 @@ export async function getCollectionPosts(
collectionId: string,
): Promise<TGApp.Plugins.Mys.Collection.Data[]> {
const url = "https://bbs-api.miyoushe.com/post/wapi/getPostFullInCollection";
const params = {
collection_id: collectionId,
};
const params = { collection_id: collectionId };
return await http
.fetch<TGApp.Plugins.Mys.Collection.ResponsePosts>(url, {
.fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
Referer: MysApi.PostReferer,
},
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
})
.then((res) => {
return res.data.data.posts;
});
.then((res: Response<TGApp.Plugins.Mys.Collection.ResponsePosts>) => res.data.data.posts);
}

View File

@@ -5,6 +5,7 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
/**
* @description 获取表情包列表
@@ -14,8 +15,8 @@ import { http } from "@tauri-apps/api";
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<TGApp.Plugins.Mys.Emoji.Response | TGApp.BBS.Response.Base>(url)
.then((res) => {
.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) => {

View File

@@ -5,6 +5,7 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
/**
* @description 获取特定论坛列表
@@ -18,19 +19,10 @@ async function getForumList(
type: number = 0,
): 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(),
};
const params = { forum_id: forumId.toString(), sort_type: type.toString() };
return await http
.fetch<TGApp.Plugins.Mys.Forum.Response>(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
query: params,
})
.then((res) => res.data.data);
.fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, query: params })
.then((res: Response<TGApp.Plugins.Mys.Forum.Response>) => res.data.data);
}
export default getForumList;

View File

@@ -5,6 +5,7 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
/**
* @description 获取卡池信息
@@ -14,15 +15,8 @@ import { http } from "@tauri-apps/api";
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<TGApp.Plugins.Mys.Gacha.Response>(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
})
.then((res) => {
return res.data.data.list;
});
.fetch(url, { method: "GET", headers: { "Content-Type": "application/json" } })
.then((res: Response<TGApp.Plugins.Mys.Gacha.Response>) => res.data.data.list);
}
export default getGachaData;

View File

@@ -5,6 +5,7 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
/**
* @description 获取首页导航列表
@@ -14,18 +15,10 @@ import { http } from "@tauri-apps/api";
*/
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(),
};
const params = { gids: gid.toString() };
return await http
.fetch<TGApp.BBS.Navigator.HomeResponse>(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
query: params,
})
.then((res) => res.data.data.navigator);
.fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, query: params })
.then((res: Response<TGApp.BBS.Navigator.HomeResponse>) => res.data.data.navigator);
}
export default getHomeNavigator;

View File

@@ -5,6 +5,7 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
/**
* @description 获取抽奖信息
@@ -16,18 +17,10 @@ async function getLotteryData(
lotteryId: string,
): 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,
};
const params = { id: lotteryId };
return await http
.fetch<TGApp.Plugins.Mys.Lottery.Response>(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
query: params,
})
.then((res) => {
.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;
});

View File

@@ -5,6 +5,7 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
/**
* @description 获取 News 列表
@@ -29,14 +30,8 @@ async function getNewsList(
last_id: lastId.toString(),
};
return await http
.fetch<TGApp.Plugins.Mys.News.Response>(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
query: params,
})
.then((res) => res.data.data);
.fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, query: params })
.then((res: Response<TGApp.Plugins.Mys.News.Response>) => res.data.data);
}
export default getNewsList;

View File

@@ -5,6 +5,7 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
/**
* @description 深度优先遍历
@@ -34,14 +35,7 @@ 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<TGApp.Plugins.Mys.Position.Response>(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
})
.then((res) => {
return res.data.data.list;
});
.fetch(url, { method: "GET", headers: { "Content-Type": "application/json" } })
.then((res: Response<TGApp.Plugins.Mys.Position.Response>) => res.data.data.list);
return DfsObc(res);
}

View File

@@ -5,8 +5,9 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import MysApi from "../api";
import MysApi from "../api/index.js";
/**
* @description 获取帖子信息
@@ -20,17 +21,12 @@ async function getPostData(postId: number): Promise<TGApp.Plugins.Mys.Post.FullD
post_id: postId.toString(),
};
return await http
.fetch<TGApp.Plugins.Mys.Post.Response>(url, {
.fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
Referer: MysApi.PostReferer,
},
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
})
.then((res) => {
return res.data.data.post;
});
.then((res: Response<TGApp.Plugins.Mys.Post.Response>) => res.data.data.post);
}
export default getPostData;

View File

@@ -25,9 +25,7 @@ export async function getVoteInfo(id: string, uid: string): Promise<TGApp.Plugin
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
})
.then((res: Response<TGApp.Plugins.Mys.Vote.InfoResponse>) => {
return res.data.data.data[0];
});
.then((res: Response<TGApp.Plugins.Mys.Vote.InfoResponse>) => res.data.data.data[0]);
}
/**
@@ -49,7 +47,5 @@ export async function getVoteResult(
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
})
.then((res: Response<TGApp.Plugins.Mys.Vote.ResultResponse>) => {
return res.data.data.data[0];
});
.then((res: Response<TGApp.Plugins.Mys.Vote.ResultResponse>) => res.data.data.data[0]);
}

View File

@@ -5,6 +5,7 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
/**
* @description 搜索帖子
@@ -20,23 +21,10 @@ async function searchPosts(
last_id: string,
): 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",
};
const params = { gids: gid, keyword, last_id, size: "20" };
return await http
.fetch<TGApp.Plugins.Mys.Search.PostsResponse>(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
query: params,
})
.then((res) => {
return res.data.data;
});
.fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, query: params })
.then((res: Response<TGApp.Plugins.Mys.Search.PostsResponse>) => res.data.data);
}
export default searchPosts;

View File

@@ -4,7 +4,7 @@
* @since Beta v0.4.6
*/
import { AppCharacterData, ArcBirCalendar, ArcBirRole } from "../../../data";
import { AppCharacterData, ArcBirCalendar, ArcBirRole } from "../../../data/index.js";
/**
* @description 判断今天是不是角色生日