🌱 完善类型,初步进行正则match #94

This commit is contained in:
目棃
2024-02-24 18:12:05 +08:00
parent c9fbddcf5d
commit 2509b488d2
6 changed files with 78 additions and 25 deletions

View File

@@ -1,10 +1,12 @@
/**
* @file web/request/getAnnouncement.ts
* @description 获取游戏内公告
* @since Beta v0.4.3
* @since Beta v0.4.4
*/
import { http } from "@tauri-apps/api";
import type { AnnoLang } from "../../pages/common/Announcements.vue";
export enum SERVER {
CN_ISLAND = "cn_gf01",
CN_TREE = "cn_qd01",
@@ -16,12 +18,12 @@ export enum SERVER {
/**
* @description 获取游戏内公告参数
* @since Beta v0.4.3
* @since Beta v0.4.4
* @param {SERVER} region 服务器
* @param {string} lang 语言
* @returns {TGApp.BBS.Announcement.Params}
*/
function getAnnoParams(region: SERVER, lang: string = "zh-cn"): TGApp.BBS.Announcement.Params {
function getAnnoParams(region: SERVER, lang: AnnoLang = "zh-cn"): TGApp.BBS.Announcement.Params {
const params: TGApp.BBS.Announcement.Params = {
game: "hk4e",
game_biz: "hk4e_cn",
@@ -44,12 +46,12 @@ function getAnnoParams(region: SERVER, lang: string = "zh-cn"): TGApp.BBS.Announ
* @description 获取游戏内公告列表
* @since Beta v0.4.3
* @param {string} region 服务器
* @param {string} lang 语言
* @param {AnnoLang} lang 语言
* @returns {Promise<TGApp.BBS.Announcement.ListData>}
*/
export async function getAnnoList(
region: SERVER = SERVER.CN_ISLAND,
lang: string = "zh-cn",
lang: AnnoLang = "zh-cn",
): Promise<TGApp.BBS.Announcement.ListData> {
const params: TGApp.BBS.Announcement.Params = getAnnoParams(region, lang);
let url = "https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnnList";
@@ -69,13 +71,13 @@ export async function getAnnoList(
* @since Beta v0.4.3
* @param {number} annId 公告 ID
* @param {SERVER} region 服务器
* @param {string} lang 语言
* @param {AnnoLang} lang 语言
* @returns {Promise<TGApp.BBS.Announcement.ContentItem>}
*/
export async function getAnnoContent(
annId: number,
region: SERVER,
lang: string = "zh-cn",
lang: AnnoLang = "zh-cn",
): Promise<TGApp.BBS.Announcement.ContentItem> {
const params: TGApp.BBS.Announcement.Params = getAnnoParams(region, lang);
let url = "https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnnContent";