mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
♻️ 稍微改了改结构
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* @file web api Hk4e.ts
|
||||
* @description 定义 Hk4e API
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
*/
|
||||
|
||||
const Hk4eApi = "https://hk4e-api.mihoyo.com"; // 基础 API
|
||||
const Hk4eAnnoApi = `${Hk4eApi}/common/hk4e_cn/announcement/api`; // 公告 API
|
||||
export const Hk4eAnnoListApi = `${Hk4eAnnoApi}/getAnnList?`; // 公告列表 API
|
||||
export const Hk4eAnnoContentApi = `${Hk4eAnnoApi}/getAnnContent?`; // 公告内容 API
|
||||
export const Hk4eAnnoQuery =
|
||||
"game=hk4e&game_biz=hk4e_cn&lang=zh-cn&bundle_id=hk4e_cn&platform=pc®ion=cn_gf01&level=60&uid=500299765"; // 公告 Query
|
||||
@@ -2,12 +2,11 @@
|
||||
* @file web api TGApi.ts
|
||||
* @description 应用用到的 API
|
||||
* @author BTMuli <bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.2
|
||||
* @since Beta v0.3.2
|
||||
*/
|
||||
|
||||
import { BBSUserInfoApi } from "./BBS";
|
||||
import { ENKA_API } from "./ENKA";
|
||||
import { Hk4eAnnoListApi, Hk4eAnnoContentApi, Hk4eAnnoQuery } from "./Hk4e";
|
||||
import { PassportTokenApi, PassportCookieTokenApi, PassportVerifyApi } from "./Passport";
|
||||
import {
|
||||
TakumiTokensApi,
|
||||
@@ -24,9 +23,6 @@ import {
|
||||
|
||||
// 应用 API
|
||||
const TGApi = {
|
||||
GameAnnoList: Hk4eAnnoListApi, // 游戏公告 API
|
||||
GameAnnoContent: Hk4eAnnoContentApi, // 游戏公告内容 API
|
||||
GameAnnoQuery: Hk4eAnnoQuery, // 游戏公告 Query
|
||||
GameEnka: ENKA_API, // 游戏 ENKA API
|
||||
GameTokens: {
|
||||
getTokens: TakumiTokensApi, // 根据 login_ticket 获取游戏 Token
|
||||
|
||||
@@ -2,34 +2,51 @@
|
||||
* @file web request getAnnouncement.ts
|
||||
* @description 获取游戏内公告
|
||||
* @author BTMuli <bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.2
|
||||
* @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