mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-06 08:32:51 +08:00
🏷️ typo
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
"debug": "tauri build --debug",
|
||||
"dev": "tauri dev --exit-on-panic",
|
||||
"eslint:pre": "pnpx @eslint/config-inspector@latest",
|
||||
"oxlint": "oxlint",
|
||||
"lint": "concurrently \"pnpm:lint:*(!fix)\"",
|
||||
"lint:fix": "concurrently \"pnpm:lint:*:fix\"",
|
||||
"lint-vue": "vue-tsc --noEmit",
|
||||
|
||||
@@ -94,7 +94,6 @@ type TPostCardEmits = {
|
||||
(e: "onSelected", v: string): void;
|
||||
(e: "onUserClick", v: TGApp.BBS.Post.User): void;
|
||||
};
|
||||
type TPostStatus = RenderStatus & { stat: ActStat };
|
||||
type RenderForum = { name: string; icon: string; id: number };
|
||||
type RenderStatus = { stat: number; label: string; color: string };
|
||||
type RenderData = { mark: number; forward: number; like: number; reply: number; view: number };
|
||||
@@ -111,18 +110,11 @@ export type RenderCard = {
|
||||
reasons: Array<TGApp.BBS.Post.RecommendTags>;
|
||||
};
|
||||
|
||||
enum ActStat {
|
||||
UNKNOWN,
|
||||
STARTED,
|
||||
FINISHED,
|
||||
SELECTION,
|
||||
}
|
||||
|
||||
const stats: Readonly<Array<TPostStatus>> = [
|
||||
{ stat: ActStat.UNKNOWN, label: "未知", color: "var(--tgc-od-red)" },
|
||||
{ stat: ActStat.STARTED, label: "进行中", color: "var(--tgc-od-green)" },
|
||||
{ stat: ActStat.FINISHED, label: "已结束", color: "var(--tgc-od-white)" },
|
||||
{ stat: ActStat.SELECTION, label: "评选中", color: "var(--tgc-od-orange)" },
|
||||
const stats: Readonly<Array<RenderStatus>> = [
|
||||
{ stat: 0, label: "未知", color: "var(--tgc-od-red)" },
|
||||
{ stat: 1, label: "进行中", color: "var(--tgc-od-green)" },
|
||||
{ stat: 2, label: "已结束", color: "var(--tgc-od-white)" },
|
||||
{ stat: 3, label: "评选中", color: "var(--tgc-od-orange)" },
|
||||
];
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@@ -156,11 +148,9 @@ async function toPost(): Promise<void> {
|
||||
}
|
||||
|
||||
function getActivityStatus(status: number): RenderStatus {
|
||||
if (status satisfies ActStat) {
|
||||
const stat: ActStat = status;
|
||||
return stats[stat];
|
||||
}
|
||||
return stats[ActStat.UNKNOWN];
|
||||
let idx = stats.findIndex((v) => v.stat === status);
|
||||
if (idx === -1) idx = 0;
|
||||
return stats[idx];
|
||||
}
|
||||
|
||||
function getPostCover(item: TGApp.BBS.Post.FullData): string {
|
||||
|
||||
@@ -91,7 +91,7 @@ watch(
|
||||
);
|
||||
|
||||
async function loadUser(): Promise<void> {
|
||||
const resp = await bbsReq.otherUserInfo(props.gid, props.uid);
|
||||
const resp = await bbsReq.otherUserInfo(props.gid.toString(), props.uid);
|
||||
if ("retcode" in resp) {
|
||||
showSnackbar.warn(`[${resp.retcode}] ${resp.message}`);
|
||||
return;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<template #prepend>
|
||||
<v-tabs v-model="tab" align-tabs="start" class="anno-tab">
|
||||
<v-tab v-for="(value, index) in tabValues" :key="index" :value="value">
|
||||
{{ AnnoType[value] }}
|
||||
{{ annoMap[value] }}
|
||||
</v-tab>
|
||||
</v-tabs>
|
||||
<div class="anno-selects">
|
||||
@@ -63,10 +63,10 @@ import { useRouter } from "vue-router";
|
||||
import { useAppStore } from "@/store/modules/app.js";
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import { decodeRegExp } from "@/utils/toolFunc.js";
|
||||
import Hk4eApi, { type AnnoLang, AnnoServer } from "@/web/request/hk4eReq.js";
|
||||
import Hk4eApi, { type AnnoLang, type AnnoServer } from "@/web/request/hk4eReq.js";
|
||||
|
||||
type AnnoSelect = { text: string; value: string };
|
||||
type AnnoKey = keyof typeof AnnoType;
|
||||
type AnnoSelect<T = string> = { text: string; value: T };
|
||||
type AnnoKey = "activity" | "game";
|
||||
export type AnnoCard = {
|
||||
id: number;
|
||||
title: string;
|
||||
@@ -79,13 +79,13 @@ export type AnnoCard = {
|
||||
};
|
||||
type AnnoList = { [key in AnnoKey]: Array<AnnoCard> };
|
||||
|
||||
const annoServerList: Array<AnnoSelect> = [
|
||||
{ text: "国服-官方服", value: AnnoServer.CN_ISLAND },
|
||||
{ text: "国服-渠道服", value: AnnoServer.CN_TREE },
|
||||
{ text: "国际服-亚服", value: AnnoServer.OS_ASIA },
|
||||
{ text: "国际服-欧服", value: AnnoServer.OS_EURO },
|
||||
{ text: "国际服-美服", value: AnnoServer.OS_USA },
|
||||
{ text: "国际服-港澳台服", value: AnnoServer.OS_CHT },
|
||||
const annoServerList: Array<AnnoSelect<AnnoServer>> = [
|
||||
{ text: "国服-官方服", value: "cn_gf01" },
|
||||
{ text: "国服-渠道服", value: "cn_qd01" },
|
||||
{ text: "国际服-亚服", value: "os_asia" },
|
||||
{ text: "国际服-欧服", value: "os_euro" },
|
||||
{ text: "国际服-美服", value: "os_usa" },
|
||||
{ text: "国际服-港澳台服", value: "os_cht" },
|
||||
];
|
||||
const annoLangList: Array<AnnoSelect> = [
|
||||
{ text: "简体中文", value: "zh-cn" },
|
||||
@@ -93,11 +93,7 @@ const annoLangList: Array<AnnoSelect> = [
|
||||
{ text: "English", value: "en" },
|
||||
{ text: "日本語", value: "ja" },
|
||||
];
|
||||
|
||||
enum AnnoType {
|
||||
activity = "活动公告",
|
||||
game = "游戏公告",
|
||||
}
|
||||
const annoMap: Readonly<Record<AnnoKey, string>> = { activity: "活动公告", game: "游戏公告" };
|
||||
|
||||
const { server, lang } = storeToRefs(useAppStore());
|
||||
const router = useRouter();
|
||||
@@ -142,15 +138,15 @@ async function loadData(): Promise<void> {
|
||||
const listCards = annoData.list.map((list) => list.list.map((anno) => getAnnoCard(anno))).flat();
|
||||
await showLoading.update("", { title: "正在解析游戏内公告时间" });
|
||||
for (const item of listCards) {
|
||||
if (item.typeLabel === AnnoType.game) continue;
|
||||
if (item.typeLabel === "game") continue;
|
||||
const detail = await Hk4eApi.anno.content(item.id, server.value, "zh-cn");
|
||||
const timeStr = getAnnoTime(detail.content);
|
||||
if (timeStr !== false) item.timeStr = timeStr;
|
||||
await showLoading.update(`[${item.id}]${item.subtitle}:${item.timeStr}`);
|
||||
}
|
||||
annoCards.value = {
|
||||
activity: listCards.filter((item) => item.typeLabel === AnnoType.activity),
|
||||
game: listCards.filter((item) => item.typeLabel === AnnoType.game),
|
||||
activity: listCards.filter((item) => item.typeLabel === "activity"),
|
||||
game: listCards.filter((item) => item.typeLabel === "game"),
|
||||
};
|
||||
await showLoading.end();
|
||||
isReq.value = false;
|
||||
@@ -181,7 +177,7 @@ function getAnnoCard(anno: TGApp.BBS.Announcement.AnnoSingle): AnnoCard {
|
||||
title: anno.title,
|
||||
subtitle: anno.subtitle.replace(/<br \/>/g, " "),
|
||||
banner: anno.banner,
|
||||
typeLabel: anno.type === 2 ? "游戏公告" : "活动公告",
|
||||
typeLabel: anno.type === 2 ? "game" : "activity",
|
||||
tagIcon: anno.tag_icon,
|
||||
tagLabel: getAnnoTag(anno.tag_label),
|
||||
timeStr: time,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file store/modules/app.ts
|
||||
* @description App store module
|
||||
* @since Beta v0.6.8
|
||||
* @since Beta v0.7.2
|
||||
*/
|
||||
|
||||
import { path } from "@tauri-apps/api";
|
||||
@@ -9,7 +9,7 @@ import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
|
||||
import { getInitDeviceInfo } from "@/utils/toolFunc.js";
|
||||
import { type AnnoLang, AnnoServer } from "@/web/request/hk4eReq.js";
|
||||
import type { AnnoLang, AnnoServer } from "@/web/request/hk4eReq.js";
|
||||
|
||||
// 用于存储用户数据的路径
|
||||
const userDataDir: Readonly<string> = `${await path.appLocalDataDir()}${path.sep()}userData`;
|
||||
@@ -44,7 +44,7 @@ export const useAppStore = defineStore(
|
||||
// 设备信息
|
||||
const deviceInfo = ref<TGApp.App.Device.DeviceInfo>(getInitDeviceInfo());
|
||||
// 服务器
|
||||
const server = ref<AnnoServer>(AnnoServer.CN_ISLAND);
|
||||
const server = ref<AnnoServer>("cn_gf01");
|
||||
// 语言
|
||||
const lang = ref<AnnoLang>("zh-cn");
|
||||
// 最近的咨讯类型
|
||||
@@ -64,7 +64,7 @@ export const useAppStore = defineStore(
|
||||
theme.value = "default";
|
||||
isLogin.value = false;
|
||||
sidebar.value.collapse = true;
|
||||
server.value = AnnoServer.CN_ISLAND;
|
||||
server.value = "cn_gf01";
|
||||
lang.value = "zh-cn";
|
||||
recentNewsType.value = "notice";
|
||||
needResize.value = "true";
|
||||
|
||||
@@ -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