mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-17 10:08:14 +08:00
♻️ 部分分区动态获取,重构部分调用
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* @file web/constant/TGConstant.ts
|
||||
* @description 常量
|
||||
* @since Beta v0.6.3
|
||||
*/
|
||||
|
||||
import { BBS_UA_MOBILE, BBS_VERSION, CHANNEL_LIST } from "./bbs.js";
|
||||
|
||||
const TGConstant = {
|
||||
BBS: { VERSION: BBS_VERSION, UA_MOBILE: BBS_UA_MOBILE, CHANNELS: CHANNEL_LIST },
|
||||
};
|
||||
|
||||
export default TGConstant;
|
||||
@@ -1,75 +0,0 @@
|
||||
/**
|
||||
* @file web/constant/bbs.ts
|
||||
* @description 常量-应用数据
|
||||
* @since Beta v0.6.8
|
||||
*/
|
||||
|
||||
export const BBS_VERSION: Readonly<string> = "2.80.1";
|
||||
export const BBS_UA_MOBILE: Readonly<string> = `Mozilla/5.0 (Linux; Android 12) Mobile miHoYoBBS/${BBS_VERSION}`;
|
||||
|
||||
/**
|
||||
* @description 频道列表
|
||||
* @since Beta v0.6.5
|
||||
* @interface ToChannelItem
|
||||
* @property {string} title - 频道名称
|
||||
* @property {string} icon - 频道图标
|
||||
* @property {string} gid - 频道 gid
|
||||
* @property {string} mini - 频道简称
|
||||
* @return ToChannelItem
|
||||
*/
|
||||
export interface ToChannelItem {
|
||||
title: string;
|
||||
icon: string;
|
||||
gid: string;
|
||||
mini: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 渠道列表
|
||||
* @since Beta v0.6.5
|
||||
* @type {Array<ToChannelItem>}
|
||||
*/
|
||||
export const CHANNEL_LIST: Readonly<Array<ToChannelItem>> = [
|
||||
{
|
||||
title: "原神",
|
||||
icon: "/platforms/mhy/ys.webp",
|
||||
gid: "2",
|
||||
mini: "ys",
|
||||
},
|
||||
{
|
||||
title: "崩坏:星穹铁道",
|
||||
icon: "/platforms/mhy/sr.webp",
|
||||
gid: "6",
|
||||
mini: "sr",
|
||||
},
|
||||
{
|
||||
title: "绝区零",
|
||||
icon: "/platforms/mhy/zzz.webp",
|
||||
gid: "8",
|
||||
mini: "zzz",
|
||||
},
|
||||
{
|
||||
title: "崩坏3",
|
||||
icon: "/platforms/mhy/bh3.webp",
|
||||
gid: "1",
|
||||
mini: "bh3",
|
||||
},
|
||||
{
|
||||
title: "崩坏2",
|
||||
icon: "/platforms/mhy/bh2.webp",
|
||||
gid: "3",
|
||||
mini: "bh2",
|
||||
},
|
||||
{
|
||||
title: "未定事件簿",
|
||||
icon: "/platforms/mhy/wd.webp",
|
||||
gid: "4",
|
||||
mini: "wd",
|
||||
},
|
||||
{
|
||||
title: "大别野",
|
||||
icon: "/platforms/mhy/dby.webp",
|
||||
gid: "5",
|
||||
mini: "dby",
|
||||
},
|
||||
];
|
||||
@@ -26,6 +26,20 @@ async function getAllGamesForums(): Promise<Array<TGApp.BBS.Forum.GameForum>> {
|
||||
).data.list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取所有分区
|
||||
* @since Beta v0.6.8
|
||||
* @return {Promise<Array<TGApp.BBS.Game.Item>>}
|
||||
*/
|
||||
async function getGameList(): Promise<Array<TGApp.BBS.Game.Item>> {
|
||||
return (
|
||||
await TGHttp<TGApp.BBS.Game.ListResp>(`${Mahwbu}getGameList`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json", referer: Referer },
|
||||
})
|
||||
).data.list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取投票信息
|
||||
* @since Beta v0.6.2
|
||||
@@ -80,6 +94,7 @@ const apiHubReq = {
|
||||
vote: { info: getVotes, result: getVoteResult },
|
||||
home: homeNew,
|
||||
forum: getAllGamesForums,
|
||||
game: getGameList,
|
||||
};
|
||||
|
||||
export default apiHubReq;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/**
|
||||
* @file web/request/otherReq.ts
|
||||
* @description Other API
|
||||
* @since Beta v0.6.3
|
||||
* @since Beta v0.6.8
|
||||
*/
|
||||
|
||||
import TGBbs from "@/utils/TGBbs.js";
|
||||
import TGHttp from "@/utils/TGHttp.js";
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import { getInitDeviceInfo } from "@/utils/toolFunc.js";
|
||||
import TGConstant from "@/web/constant/TGConstant.js";
|
||||
|
||||
/**
|
||||
* @description 获取设备指纹
|
||||
@@ -85,8 +85,8 @@ async function getDeviceFp(
|
||||
device_fp: info.device_fp,
|
||||
};
|
||||
const header: Record<string, string> = {
|
||||
"user-agent": TGConstant.BBS.UA_MOBILE,
|
||||
"x-rpc-app_version": TGConstant.BBS.VERSION,
|
||||
"user-agent": TGBbs.ua,
|
||||
"x-rpc-app_version": TGBbs.version,
|
||||
"x-rpc-client_type": "5",
|
||||
"x-requested-with": "com.mihoyo.hyperion",
|
||||
Referer: "https://webstatic.mihoyo.com/",
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
import Md5 from "js-md5";
|
||||
|
||||
import TGBbs from "@/utils/TGBbs.js";
|
||||
import { getDeviceInfo, getRandomString } from "@/utils/toolFunc.js";
|
||||
import { BBS_VERSION } from "@/web/constant/bbs.js";
|
||||
|
||||
/**
|
||||
* @description salt 类型
|
||||
@@ -34,7 +34,7 @@ const Salt: Readonly<Record<keyof typeof SaltType, string>> = {
|
||||
X6: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
|
||||
PROD: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
|
||||
};
|
||||
const UserAgent: Readonly<string> = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) miHoYoBBS/${BBS_VERSION}`;
|
||||
const UserAgent: Readonly<string> = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) miHoYoBBS/${TGBbs.version}`;
|
||||
|
||||
/**
|
||||
* @description 获取随机数
|
||||
@@ -126,7 +126,7 @@ export function getRequestHeader(
|
||||
): Record<string, string> {
|
||||
return {
|
||||
"user-agent": UserAgent,
|
||||
"x-rpc-app_version": BBS_VERSION,
|
||||
"x-rpc-app_version": TGBbs.version,
|
||||
"x-rpc-client_type": "5",
|
||||
"x-requested-with": "com.mihoyo.hyperion",
|
||||
referer: "https://webstatic.mihoyo.com",
|
||||
|
||||
Reference in New Issue
Block a user