mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-15 09:48:14 +08:00
♻️ 稍微改了改结构
This commit is contained in:
@@ -1,35 +1,52 @@
|
||||
/**
|
||||
* @file web request getAnnouncement.ts
|
||||
* @description 获取游戏内公告
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.2
|
||||
* @author BTMuli <bt-muli@outlook.com>
|
||||
* @since Beta v0.3.2
|
||||
*/
|
||||
|
||||
// Tauri
|
||||
import { http } from "@tauri-apps/api";
|
||||
// Tauri.App
|
||||
import TGApi from "../api/TGApi";
|
||||
|
||||
const params = {
|
||||
game: "hk4e",
|
||||
game_biz: "hk4e_cn",
|
||||
lang: "zh-cn",
|
||||
bundle_id: "hk4e_cn",
|
||||
platform: "pc",
|
||||
region: "cn_gf01",
|
||||
level: "60",
|
||||
uid: "500299765",
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 获取游戏内公告列表
|
||||
* @since Alpha v0.1.2
|
||||
* @since Beta v0.3.2
|
||||
* @returns {Promise<TGApp.BBS.Announcement.ListData>}
|
||||
*/
|
||||
export async function getAnnoList(): Promise<TGApp.BBS.Announcement.ListData> {
|
||||
const url = "https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnnList";
|
||||
return await http
|
||||
.fetch<TGApp.BBS.Announcement.ListResponse>(`${TGApi.GameAnnoList}${TGApi.GameAnnoQuery}`)
|
||||
.fetch<TGApp.BBS.Announcement.ListResponse>(url, {
|
||||
method: "GET",
|
||||
query: params,
|
||||
})
|
||||
.then((res) => res.data.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取游戏内公告内容
|
||||
* @since Alpha v0.1.2
|
||||
* @since Beta v0.3.2
|
||||
* @param {number} annId 公告 ID
|
||||
* @returns {Promise<TGApp.BBS.Announcement.ContentItem>}
|
||||
*/
|
||||
export async function getAnnoContent(annId: number): Promise<TGApp.BBS.Announcement.ContentItem> {
|
||||
const url = "https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnnContent";
|
||||
const annoContents: TGApp.BBS.Announcement.ContentItem[] = await http
|
||||
.fetch<TGApp.BBS.Announcement.ContentResponse>(`${TGApi.GameAnnoContent}${TGApi.GameAnnoQuery}`)
|
||||
.fetch<TGApp.BBS.Announcement.ContentResponse>(url, {
|
||||
method: "GET",
|
||||
query: params,
|
||||
})
|
||||
.then((res) => res.data.data.list);
|
||||
const annoContent = annoContents.find((item) => item.ann_id === annId);
|
||||
if (annoContent != null) {
|
||||
|
||||
Reference in New Issue
Block a user