mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-15 09:48:14 +08:00
🎨 代码格式化
This commit is contained in:
@@ -9,21 +9,22 @@ import { http } from "@tauri-apps/api";
|
||||
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[]> {
|
||||
export async function getGachaData(): Promise<GachaData[]> {
|
||||
return await http
|
||||
.fetch<GachaResponse>(GACHA_POOL_API, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data.list;
|
||||
});
|
||||
|
||||
@@ -9,7 +9,8 @@ import { http } from "@tauri-apps/api";
|
||||
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 获取抽奖信息
|
||||
@@ -17,14 +18,14 @@ const LOTTERY_API = "https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show
|
||||
* @param {string} lotteryId 抽奖 ID
|
||||
* @return {Promise<LotteryData>}
|
||||
*/
|
||||
export async function getLotteryData (lotteryId: string): Promise<LotteryData> {
|
||||
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",
|
||||
},
|
||||
})
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data.show_lottery;
|
||||
});
|
||||
|
||||
@@ -37,7 +37,11 @@ enum NewsType {
|
||||
* @param {number} lastId 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getNoticeList (gid: string = "2", pageSize: number = 20, lastId: number = 0): Promise<NewsData> {
|
||||
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)
|
||||
@@ -53,7 +57,11 @@ export async function getNoticeList (gid: string = "2", pageSize: number = 20, l
|
||||
* @param {number} lastId 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getActivityList (gid: string = "2", pageSize: number = 20, lastId: number = 0): Promise<NewsData> {
|
||||
export async function getActivityList(
|
||||
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.ACTIVITY)
|
||||
@@ -69,7 +77,11 @@ export async function getActivityList (gid: string = "2", pageSize: number = 20,
|
||||
* @param {number} lastId 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getNewsList (gid: string = "2", pageSize: number = 20, lastId: number = 0): Promise<NewsData> {
|
||||
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)
|
||||
|
||||
@@ -10,21 +10,22 @@ 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[]> {
|
||||
export async function getPositionData(): Promise<PositionData[]> {
|
||||
const res = await http
|
||||
.fetch<PositionResponse>(POSITION_API, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data.list;
|
||||
});
|
||||
|
||||
@@ -18,15 +18,15 @@ const POST_REFERER = "https://bbs.mihoyo.com/";
|
||||
* @param {number} postId 帖子 ID
|
||||
* @return {Promise<PostData>}
|
||||
*/
|
||||
export async function getPostData (postId: number): Promise<PostData> {
|
||||
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,
|
||||
},
|
||||
})
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Referer: POST_REFERER,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data.post;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user