mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-05-07 00:15:48 +08:00
🏷️ typo
This commit is contained in:
@@ -1,21 +1,13 @@
|
||||
/**
|
||||
* @file web/request/hk4eReq.ts
|
||||
* @description Hk4eApi 请求模块
|
||||
* @since Beta v0.7.0
|
||||
* @since Beta v0.7.2
|
||||
*/
|
||||
|
||||
import TGHttp from "@/utils/TGHttp.js";
|
||||
import { getDeviceInfo } from "@/utils/toolFunc.js";
|
||||
|
||||
export enum AnnoServer {
|
||||
CN_ISLAND = "cn_gf01",
|
||||
CN_TREE = "cn_qd01",
|
||||
OS_USA = "os_usa",
|
||||
OS_EURO = "os_euro",
|
||||
OS_ASIA = "os_asia",
|
||||
OS_CHT = "os_cht",
|
||||
}
|
||||
|
||||
export type AnnoServer = "cn_gf01" | "cn_qd01" | "os_usa" | "os_euro" | "os_asia" | "os_cht";
|
||||
export type AnnoLang = "zh-cn" | "zh-tw" | "en" | "ja";
|
||||
|
||||
const AnnoApi: Readonly<string> = "https://hk4e-ann-api.mihoyo.com/common/hk4e_cn/announcement/api";
|
||||
@@ -25,12 +17,12 @@ const SdkApi: Readonly<string> = "https://hk4e-sdk.mihoyo.com/hk4e_cn/";
|
||||
|
||||
/**
|
||||
* @description 判断是否为国内服务器
|
||||
* @since Beta v0.6.5
|
||||
* @since Beta v0.7.2
|
||||
* @param {AnnoServer} region 服务器
|
||||
* @returns {boolean} 是否为国内服务器
|
||||
*/
|
||||
function isCN(region: AnnoServer): boolean {
|
||||
return region === AnnoServer.CN_ISLAND || region === AnnoServer.CN_TREE;
|
||||
return region.startsWith("cn");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,13 +37,13 @@ function getAnnoApi(region: AnnoServer): string {
|
||||
|
||||
/**
|
||||
* @description 获取游戏内公告参数
|
||||
* @since Beta v0.4.4
|
||||
* @since Beta v0.7.2
|
||||
* @param {AnnoServer} region 服务器
|
||||
* @param {string} lang 语言
|
||||
* @returns {TGApp.BBS.Announcement.Params}
|
||||
*/
|
||||
function getAnnoParams(
|
||||
region: AnnoServer = AnnoServer.CN_ISLAND,
|
||||
region: AnnoServer = "cn_gf01",
|
||||
lang: AnnoLang = "zh-cn",
|
||||
): TGApp.BBS.Announcement.Params {
|
||||
return {
|
||||
@@ -74,7 +66,7 @@ function getAnnoParams(
|
||||
* @returns {Promise<TGApp.BBS.Announcement.ListData>}
|
||||
*/
|
||||
async function getAnnoList(
|
||||
region: AnnoServer = AnnoServer.CN_ISLAND,
|
||||
region: AnnoServer = "cn_gf01",
|
||||
lang: AnnoLang = "zh-cn",
|
||||
): Promise<TGApp.BBS.Announcement.ListData> {
|
||||
const resp = await TGHttp<TGApp.BBS.Announcement.ListResponse>(
|
||||
@@ -94,7 +86,7 @@ async function getAnnoList(
|
||||
*/
|
||||
async function getAnnoContent(
|
||||
annId: number,
|
||||
region: AnnoServer = AnnoServer.CN_ISLAND,
|
||||
region: AnnoServer = "cn_gf01",
|
||||
lang: AnnoLang = "zh-cn",
|
||||
): Promise<TGApp.BBS.Announcement.ContentItem> {
|
||||
const annoResp = await TGHttp<TGApp.BBS.Announcement.ContentResponse>(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file web/utils/getRequestHeader.ts
|
||||
* @description 获取请求头
|
||||
* @since Beta v0.7.0
|
||||
* @since Beta v0.7.2
|
||||
*/
|
||||
|
||||
import Md5 from "js-md5";
|
||||
@@ -11,23 +11,16 @@ import { getDeviceInfo, getRandomString } from "@/utils/toolFunc.js";
|
||||
|
||||
/**
|
||||
* @description salt 类型
|
||||
* @since Beta v0.6.5
|
||||
* @enum {number}
|
||||
* @since Beta v0.7.2
|
||||
*/
|
||||
const enum SaltType {
|
||||
K2,
|
||||
LK2,
|
||||
X4,
|
||||
X6,
|
||||
PROD,
|
||||
}
|
||||
type SaltKey = "K2" | "LK2" | "X4" | "X6" | "PROD";
|
||||
|
||||
/**
|
||||
* @description salt 值
|
||||
* @version 2.82.0
|
||||
* @since Beta v0.7.0
|
||||
*/
|
||||
const Salt: Readonly<Record<keyof typeof SaltType, string>> = {
|
||||
const Salt: Readonly<Record<SaltKey, string>> = {
|
||||
K2: "RGcLwIWYOQwTQPJ8Qw41kioel738ch3Z",
|
||||
LK2: "1M69A7AaPUhTFCdH0D2iMatZ0MTiLmPf",
|
||||
X4: "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs",
|
||||
@@ -53,16 +46,11 @@ function getRandomNumber(min: number, max: number): number {
|
||||
* @version 2.50.1
|
||||
* @param {string} method 请求方法
|
||||
* @param {string} data 请求数据
|
||||
* @param {SaltType} saltType salt 类型
|
||||
* @param {SaltKey} saltType salt 类型
|
||||
* @param {boolean} isSign 是否为签名
|
||||
* @returns {string} ds
|
||||
*/
|
||||
function getDS(
|
||||
method: string,
|
||||
data: string,
|
||||
saltType: keyof typeof SaltType,
|
||||
isSign: boolean,
|
||||
): string {
|
||||
function getDS(method: string, data: string, saltType: SaltKey, isSign: boolean): string {
|
||||
const salt = Salt[saltType];
|
||||
const time = Math.floor(Date.now() / 1000).toString();
|
||||
let random = getRandomNumber(100000, 200000).toString();
|
||||
@@ -113,7 +101,7 @@ function transCookie(cookie: Record<string, string>): string {
|
||||
* @param {Record<string, string>} cookie cookie
|
||||
* @param {string} method 请求方法
|
||||
* @param {Record<string, string | number | boolean | Array<string>> | string} data 请求数据
|
||||
* @param {keyof typeof SaltType} saltType salt 类型
|
||||
* @param {SaltKey} saltType salt 类型
|
||||
* @param {boolean} isSign 是否为签名
|
||||
* @returns {Record<string, string>} 请求头
|
||||
*/
|
||||
@@ -121,7 +109,7 @@ export function getRequestHeader(
|
||||
cookie: Record<string, string>,
|
||||
method: string,
|
||||
data: Record<string, string | number | boolean | Array<string>> | string,
|
||||
saltType: keyof typeof SaltType = "X4",
|
||||
saltType: SaltKey = "X4",
|
||||
isSign: boolean = false,
|
||||
): Record<string, string> {
|
||||
return {
|
||||
@@ -140,26 +128,21 @@ export function getRequestHeader(
|
||||
/**
|
||||
* @description 获取 DS
|
||||
* @since Beta v0.3.9
|
||||
* @param {keyof typeof SaltType} saltType salt 类型
|
||||
* @param {SaltKey} saltType salt 类型
|
||||
* @param {number} dsType ds 类型
|
||||
* @param {Record<string, string|number>|string} body
|
||||
* @param {Record<string, string|number>|string} query
|
||||
* @returns {string} DS
|
||||
*/
|
||||
export function getDS4JS(saltType: SaltKey, dsType: 1, body: undefined, query: undefined): string;
|
||||
export function getDS4JS(
|
||||
saltType: keyof typeof SaltType,
|
||||
dsType: 1,
|
||||
body: undefined,
|
||||
query: undefined,
|
||||
): string;
|
||||
export function getDS4JS(
|
||||
saltType: keyof typeof SaltType,
|
||||
saltType: SaltKey,
|
||||
dsType: 2,
|
||||
body: Record<string, string | number> | string,
|
||||
query: Record<string, string | number> | string,
|
||||
): string;
|
||||
export function getDS4JS(
|
||||
saltType: keyof typeof SaltType,
|
||||
saltType: SaltKey,
|
||||
dsType: 1 | 2,
|
||||
body?: Record<string, string | number> | string,
|
||||
query?: Record<string, string | number> | string,
|
||||
|
||||
Reference in New Issue
Block a user