mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-15 09:48:14 +08:00
🌈 style(eslint): 第一次过 eslint
姑且先把能过的 ts 文件给过了,明天再过其余的 ts 文件跟 vue Signed-off-by: BTMuli <BT-Muli@outlook.com> (cherry picked from commit b7392bddea895b8b8cc1cad5ba0403d2dc738643)
This commit is contained in:
@@ -6,27 +6,26 @@
|
||||
*/
|
||||
|
||||
import { http } from "@tauri-apps/api";
|
||||
import { CalendarResponse, CalendarData } from "../interface/calendar";
|
||||
import { type CalendarResponse, type CalendarData } from "../interface/calendar";
|
||||
|
||||
// 日历 API
|
||||
const CALENDAR_API =
|
||||
"https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/get_activity_calendar?app_sn=ys_obc";
|
||||
const CALENDAR_API = "https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/get_activity_calendar?app_sn=ys_obc";
|
||||
|
||||
/**
|
||||
* @description 日历请求
|
||||
* @since Alpha v0.1.1
|
||||
* @return {Promise<CalendarData[]>}
|
||||
*/
|
||||
export async function getCalendarData(): Promise<CalendarData[]> {
|
||||
const res = await http
|
||||
.fetch<CalendarResponse>(CALENDAR_API, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
return res.data.data.list;
|
||||
});
|
||||
return res.filter(item => item.kind === "2");
|
||||
export async function getCalendarData (): Promise<CalendarData[]> {
|
||||
const res = await http
|
||||
.fetch<CalendarResponse>(CALENDAR_API, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data.list;
|
||||
});
|
||||
return res.filter((item) => item.kind === "2");
|
||||
}
|
||||
|
||||
@@ -6,26 +6,25 @@
|
||||
*/
|
||||
|
||||
import { http } from "@tauri-apps/api";
|
||||
import { GachaResponse, GachaData } from "../interface/gacha";
|
||||
import { type GachaResponse, type GachaData } from "../interface/gacha";
|
||||
|
||||
// 卡池 API
|
||||
const GACHA_POOL_API =
|
||||
"https://api-takumi.mihoyo.com/common/blackboard/ys_obc/v1/gacha_pool?app_sn=ys_obc";
|
||||
const GACHA_POOL_API = "https://api-takumi.mihoyo.com/common/blackboard/ys_obc/v1/gacha_pool?app_sn=ys_obc";
|
||||
|
||||
/**
|
||||
* @description 获取卡池信息
|
||||
* @since Alpha
|
||||
* @return {Promise<GachaData[]>}
|
||||
*/
|
||||
export async function getGachaData(): Promise<GachaData[]> {
|
||||
return await http
|
||||
.fetch<GachaResponse>(GACHA_POOL_API, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
return res.data.data.list;
|
||||
});
|
||||
export async function getGachaData (): Promise<GachaData[]> {
|
||||
return await http
|
||||
.fetch<GachaResponse>(GACHA_POOL_API, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data.list;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,31 +2,30 @@
|
||||
* @file plugins Mys interface lottery.ts
|
||||
* @description Mys 插件抽奖接口
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.1
|
||||
* @since Alpha v0.1.2
|
||||
*/
|
||||
|
||||
import { http } from "@tauri-apps/api";
|
||||
import { LotteryResponse, LotteryData } from "../interface/lottery";
|
||||
import { type LotteryResponse, type LotteryData } from "../interface/lottery";
|
||||
|
||||
// 抽奖 API
|
||||
const LOTTERY_API =
|
||||
"https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show?gids=2&id={lottery_id}";
|
||||
const LOTTERY_API = "https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show?gids=2&id={lottery_id}";
|
||||
|
||||
/**
|
||||
* @description 获取抽奖信息
|
||||
* @since Alpha v0.1.1
|
||||
* @param {string} lottery_id 抽奖 ID
|
||||
* @since Alpha v0.1.2
|
||||
* @param {string} lotteryId 抽奖 ID
|
||||
* @return {Promise<LotteryData>}
|
||||
*/
|
||||
export async function getLotteryData(lottery_id: string): Promise<LotteryData> {
|
||||
return await http
|
||||
.fetch<LotteryResponse>(LOTTERY_API.replace("{lottery_id}", lottery_id), {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
return res.data.data.show_lottery;
|
||||
});
|
||||
export async function getLotteryData (lotteryId: string): Promise<LotteryData> {
|
||||
return await http
|
||||
.fetch<LotteryResponse>(LOTTERY_API.replace("{lottery_id}", lotteryId), {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data.show_lottery;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
import { http } from "@tauri-apps/api";
|
||||
import { NewsData, NewsResponse } from "../interface/news";
|
||||
import { type NewsData, type NewsResponse } from "../interface/news";
|
||||
|
||||
// 咨讯 API
|
||||
const NEWS_LIST_API =
|
||||
@@ -22,67 +22,61 @@ const NEWS_LIST_API =
|
||||
* @return {NewsType}
|
||||
*/
|
||||
enum NewsType {
|
||||
NOTICE = "1",
|
||||
ACTIVITY = "2",
|
||||
NEWS = "3",
|
||||
NOTICE = "1",
|
||||
ACTIVITY = "2",
|
||||
NEWS = "3",
|
||||
}
|
||||
|
||||
// todo: 考虑使用泛型
|
||||
|
||||
/**
|
||||
* @description 获取 Notice 列表
|
||||
* @since Alpha v0.1.2
|
||||
* @param {string} gid gid: 1 为崩坏3, 2 为原神,3 为崩坏2,4 为未定事件簿,5 为大别野,6 为崩坏:星穹铁道,8 为绝区零
|
||||
* @param {number} page_size 返回数量
|
||||
* @param {number} last_id 上一次请求的最后一条数据的 id
|
||||
* @param {number} pageSize 返回数量
|
||||
* @param {number} lastId 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getNoticeList(
|
||||
gid: string = "2",
|
||||
page_size: number = 20,
|
||||
last_id: number = 0
|
||||
): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString())
|
||||
.replace("{gid}", gid)
|
||||
.replace("{news_type}", NewsType.NOTICE)
|
||||
.replace("{last_id}", last_id.toString());
|
||||
return await http.fetch<NewsResponse>(url).then(res => res.data.data);
|
||||
export async function getNoticeList (gid: string = "2", pageSize: number = 20, lastId: number = 0): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", pageSize.toString())
|
||||
.replace("{gid}", gid)
|
||||
.replace("{news_type}", NewsType.NOTICE)
|
||||
.replace("{last_id}", lastId.toString());
|
||||
return await http.fetch<NewsResponse>(url).then((res) => res.data.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取 Activity 列表
|
||||
* @since Alpha v0.1.2
|
||||
* @param {string} gid gid: 1 为崩坏3, 2 为原神,3 为崩坏2,4 为未定事件簿,5 为大别野,6 为崩坏:星穹铁道,8 为绝区零
|
||||
* @param {number} page_size 返回数量
|
||||
* @param {number} last_id 上一次请求的最后一条数据的 id
|
||||
* @param {number} pageSize 返回数量
|
||||
* @param {number} lastId 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getActivityList(
|
||||
gid: string = "2",
|
||||
page_size: number = 20,
|
||||
last_id: number = 0
|
||||
export async function getActivityList (
|
||||
gid: string = "2",
|
||||
pageSize: number = 20,
|
||||
lastId: number = 0,
|
||||
): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString())
|
||||
.replace("{gid}", gid)
|
||||
.replace("{news_type}", NewsType.ACTIVITY)
|
||||
.replace("{last_id}", last_id.toString());
|
||||
return await http.fetch<NewsResponse>(url).then(res => res.data.data);
|
||||
const url = NEWS_LIST_API.replace("{page_size}", pageSize.toString())
|
||||
.replace("{gid}", gid)
|
||||
.replace("{news_type}", NewsType.ACTIVITY)
|
||||
.replace("{last_id}", lastId.toString());
|
||||
return await http.fetch<NewsResponse>(url).then((res) => res.data.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取 News 列表
|
||||
* @since Alpha v0.1.2
|
||||
* @param {string} gid gid: 1 为崩坏3, 2 为原神,3 为崩坏2,4 为未定事件簿,5 为大别野,6 为崩坏:星穹铁道,8 为绝区零
|
||||
* @param {number} page_size 返回数量
|
||||
* @param {number} last_id 上一次请求的最后一条数据的 id
|
||||
* @param {number} pageSize 返回数量
|
||||
* @param {number} lastId 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getNewsList(
|
||||
gid: string = "2",
|
||||
page_size: number = 20,
|
||||
last_id: number = 0
|
||||
): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString())
|
||||
.replace("{gid}", gid)
|
||||
.replace("{news_type}", NewsType.NEWS)
|
||||
.replace("{last_id}", last_id.toString());
|
||||
return await http.fetch<NewsResponse>(url).then(res => res.data.data);
|
||||
export async function getNewsList (gid: string = "2", pageSize: number = 20, lastId: number = 0): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", pageSize.toString())
|
||||
.replace("{gid}", gid)
|
||||
.replace("{news_type}", NewsType.NEWS)
|
||||
.replace("{last_id}", lastId.toString());
|
||||
return await http.fetch<NewsResponse>(url).then((res) => res.data.data);
|
||||
}
|
||||
|
||||
@@ -2,32 +2,31 @@
|
||||
* @file plugins Mys request position.ts
|
||||
* @description Mys 插件热点追踪请求
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.1
|
||||
* @since Alpha v0.1.2
|
||||
*/
|
||||
|
||||
import { http } from "@tauri-apps/api";
|
||||
import { PositionResponse, PositionData, PositionObc } from "../interface/position";
|
||||
import { type PositionResponse, type PositionData } from "../interface/position";
|
||||
import { dfs } from "../utils/position";
|
||||
|
||||
// 热点追踪 API
|
||||
const POSITION_API =
|
||||
"https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/home/position?app_sn=ys_obc";
|
||||
const POSITION_API = "https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/home/position?app_sn=ys_obc";
|
||||
|
||||
/**
|
||||
* @description 获取热点追踪信息
|
||||
* @since Alpha v0.1.1
|
||||
* @return {Promise<PositionData[]>}
|
||||
*/
|
||||
export async function getPositionData(): Promise<PositionData[]> {
|
||||
const res = await http
|
||||
.fetch<PositionResponse>(POSITION_API, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
return res.data.data.list;
|
||||
});
|
||||
return dfs(res as PositionObc[]);
|
||||
export async function getPositionData (): Promise<PositionData[]> {
|
||||
const res = await http
|
||||
.fetch<PositionResponse>(POSITION_API, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data.list;
|
||||
});
|
||||
return dfs(res);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
import { http } from "@tauri-apps/api";
|
||||
import { PostResponse, PostData } from "../interface/post";
|
||||
import { type PostResponse, type PostData } from "../interface/post";
|
||||
|
||||
// 帖子 API
|
||||
const POST_API = "https://bbs-api.mihoyo.com/post/wapi/getPostFull?post_id={post_id}";
|
||||
@@ -15,19 +15,19 @@ const POST_REFERER = "https://bbs.mihoyo.com/";
|
||||
/**
|
||||
* @description 获取帖子信息
|
||||
* @since Alpha v0.1.2
|
||||
* @param {number} post_id 帖子 ID
|
||||
* @param {number} postId 帖子 ID
|
||||
* @return {Promise<PostData>}
|
||||
*/
|
||||
export async function getPostData(post_id: number): Promise<PostData> {
|
||||
return await http
|
||||
.fetch<PostResponse>(POST_API.replace("{post_id}", post_id.toString()), {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Referer: POST_REFERER,
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
return res.data.data.post;
|
||||
});
|
||||
export async function getPostData (postId: number): Promise<PostData> {
|
||||
return await http
|
||||
.fetch<PostResponse>(POST_API.replace("{post_id}", postId.toString()), {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Referer: POST_REFERER,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data.post;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user