mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-06 08:32:51 +08:00
♻️ 调整服务器类型归属
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/enum/anno.ts
|
||||
* @description 游戏内公告相关枚举
|
||||
* @since Beta v0.7.7
|
||||
* @since Beta v0.8.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -35,43 +35,6 @@ export function getAnnoLangDesc(lang: TGApp.BBS.Announcement.AnnoLangEnum): stri
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 公告服务器类型
|
||||
* @since Beta v0.7.7
|
||||
* @const AnnoServerEnum
|
||||
*/
|
||||
export const AnnoServerEnum: typeof TGApp.BBS.Announcement.AnnoServer = {
|
||||
CN_GF01: "cn_gf01",
|
||||
CN_QD01: "cn_qd01",
|
||||
OS_USA: "os_usa",
|
||||
OS_EURO: "os_euro",
|
||||
OS_ASIA: "os_asia",
|
||||
OS_CHT: "os_cht",
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 获取公告服务器描述
|
||||
* @since Beta v0.7.7
|
||||
* @param {TGApp.BBS.Announcement.AnnoServerEnum} server 公告服务器
|
||||
* @return {string} 公告服务器描述
|
||||
*/
|
||||
export function getAnnoServerDesc(server: TGApp.BBS.Announcement.AnnoServerEnum): string {
|
||||
switch (server) {
|
||||
case AnnoServerEnum.CN_GF01:
|
||||
return "国服-官方服";
|
||||
case AnnoServerEnum.CN_QD01:
|
||||
return "国服-渠道服";
|
||||
case AnnoServerEnum.OS_USA:
|
||||
return "国际服-美服";
|
||||
case AnnoServerEnum.OS_EURO:
|
||||
return "国际服-欧服";
|
||||
case AnnoServerEnum.OS_ASIA:
|
||||
return "国际服-亚服";
|
||||
case AnnoServerEnum.OS_CHT:
|
||||
return "国际服-港澳台服";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 公告类型
|
||||
* @since Beta v0.7.7
|
||||
|
||||
42
src/enum/game.ts
Normal file
42
src/enum/game.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @file enum/game.ts
|
||||
* @description 游戏相关枚举
|
||||
* @since Beta v0.8.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description 服务器类型
|
||||
* @since Beta v0.8.0
|
||||
* @const GameServerEnum
|
||||
*/
|
||||
export const GameServerEnum: typeof TGApp.Game.Base.ServerType = {
|
||||
CN_GF01: "cn_gf01",
|
||||
CN_QD01: "cn_qd01",
|
||||
OS_USA: "os_usa",
|
||||
OS_EURO: "os_euro",
|
||||
OS_ASIA: "os_asia",
|
||||
OS_CHT: "os_cht",
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 获取公告服务器描述
|
||||
* @since Beta v0.8.0
|
||||
* @param {TGApp.Game.Base.ServerTypeEnum} server 公告服务器
|
||||
* @return {string} 公告服务器描述
|
||||
*/
|
||||
export function getGameServerDesc(server: TGApp.Game.Base.ServerTypeEnum): string {
|
||||
switch (server) {
|
||||
case GameServerEnum.CN_GF01:
|
||||
return "国服-官方服";
|
||||
case GameServerEnum.CN_QD01:
|
||||
return "国服-渠道服";
|
||||
case GameServerEnum.OS_USA:
|
||||
return "国际服-美服";
|
||||
case GameServerEnum.OS_EURO:
|
||||
return "国际服-欧服";
|
||||
case GameServerEnum.OS_ASIA:
|
||||
return "国际服-亚服";
|
||||
case GameServerEnum.OS_CHT:
|
||||
return "国际服-港澳台服";
|
||||
}
|
||||
}
|
||||
@@ -295,7 +295,7 @@ async function deleteCombat(): Promise<void> {
|
||||
await showLoading.end();
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
<style lang="scss" scoped>
|
||||
.uct-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -45,19 +45,12 @@
|
||||
</v-window-item>
|
||||
</v-window>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import showLoading from "@comp/func/loading.js";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import TaCard from "@comp/pageAnno/ta-card.vue";
|
||||
import {
|
||||
AnnoLangEnum,
|
||||
AnnoServerEnum,
|
||||
AnnoTypeEnum,
|
||||
getAnnoLangDesc,
|
||||
getAnnoServerDesc,
|
||||
getAnnoTypeDesc,
|
||||
} from "@enum/anno.js";
|
||||
import { AnnoLangEnum, AnnoTypeEnum, getAnnoLangDesc, getAnnoTypeDesc } from "@enum/anno.js";
|
||||
import { getGameServerDesc, GameServerEnum } from "@enum/game.js";
|
||||
import hk4eReq from "@req/hk4eReq.js";
|
||||
import useAppStore from "@store/app.js";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
@@ -79,14 +72,14 @@ export type AnnoCard = {
|
||||
};
|
||||
type AnnoList = Record<TGApp.BBS.Announcement.AnnoTypeEnum, Array<AnnoCard>>;
|
||||
|
||||
const serverList: ReadonlyArray<AnnoSelect<TGApp.BBS.Announcement.AnnoServerEnum>> = [
|
||||
AnnoServerEnum.CN_GF01,
|
||||
AnnoServerEnum.CN_QD01,
|
||||
AnnoServerEnum.OS_ASIA,
|
||||
AnnoServerEnum.OS_EURO,
|
||||
AnnoServerEnum.OS_USA,
|
||||
AnnoServerEnum.OS_CHT,
|
||||
].map((i) => ({ text: getAnnoServerDesc(i), value: i }));
|
||||
const serverList: ReadonlyArray<AnnoSelect<TGApp.Game.Base.ServerTypeEnum>> = [
|
||||
GameServerEnum.CN_GF01,
|
||||
GameServerEnum.CN_QD01,
|
||||
GameServerEnum.OS_ASIA,
|
||||
GameServerEnum.OS_EURO,
|
||||
GameServerEnum.OS_USA,
|
||||
GameServerEnum.OS_CHT,
|
||||
].map((i) => ({ text: getGameServerDesc(i), value: i }));
|
||||
const langList: ReadonlyArray<AnnoSelect<TGApp.BBS.Announcement.AnnoLangEnum>> = [
|
||||
AnnoLangEnum.CHS,
|
||||
AnnoLangEnum.CHT,
|
||||
@@ -108,8 +101,8 @@ const isReq = ref<boolean>(false);
|
||||
watch(
|
||||
() => server.value,
|
||||
async () => {
|
||||
const name = getAnnoServerDesc(server.value);
|
||||
await TGLogger.Info(`[Announcements][watch][curRegionName] 切换服务器:${name}`);
|
||||
const name = getGameServerDesc(server.value);
|
||||
await TGLogger.Info(`[Announcements][watch][server] 切换服务器:${name}`);
|
||||
await loadData();
|
||||
showSnackbar.success(`服务器切换为:${name}`);
|
||||
},
|
||||
@@ -135,7 +128,7 @@ async function loadData(): Promise<void> {
|
||||
isReq.value = true;
|
||||
await showLoading.start(
|
||||
"正在获取公告数据",
|
||||
`服务器:${getAnnoServerDesc(server.value)},语言:${getAnnoLangDesc(lang.value)}`,
|
||||
`服务器:${getGameServerDesc(server.value)},语言:${getAnnoLangDesc(lang.value)}`,
|
||||
);
|
||||
const listResp = await hk4eReq.anno.list(server.value, lang.value);
|
||||
const detailResp = await hk4eReq.anno.detail(server.value, AnnoLangEnum.CHS);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/**
|
||||
* @file request/hk4eReq.ts
|
||||
* @description Hk4eApi 请求模块
|
||||
* @since Beta v0.7.7
|
||||
* @since Beta v0.8.0
|
||||
*/
|
||||
|
||||
import { AnnoLangEnum, AnnoServerEnum } from "@enum/anno.js";
|
||||
import { AnnoLangEnum } from "@enum/anno.js";
|
||||
import { GameServerEnum } from "@enum/game.js";
|
||||
import TGHttp from "@utils/TGHttp.js";
|
||||
import { getDeviceInfo } from "@utils/toolFunc.js";
|
||||
|
||||
@@ -15,14 +16,14 @@ const SdkApi: Readonly<string> = "https://hk4e-sdk.mihoyo.com/hk4e_cn/";
|
||||
|
||||
/**
|
||||
* @description 判断是否为国内服务器
|
||||
* @since Beta v0.7.7
|
||||
* @param {TGApp.BBS.Announcement.AnnoServerEnum} region 服务器
|
||||
* @since Beta v0.8.0
|
||||
* @param {TGApp.Game.Base.ServerTypeEnum} region 服务器
|
||||
* @returns {boolean} 是否为国内服务器
|
||||
*/
|
||||
function isCN(region: TGApp.BBS.Announcement.AnnoServerEnum): boolean {
|
||||
function isCN(region: TGApp.Game.Base.ServerTypeEnum): boolean {
|
||||
switch (region) {
|
||||
case AnnoServerEnum.CN_QD01:
|
||||
case AnnoServerEnum.CN_GF01:
|
||||
case GameServerEnum.CN_QD01:
|
||||
case GameServerEnum.CN_GF01:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -31,23 +32,23 @@ function isCN(region: TGApp.BBS.Announcement.AnnoServerEnum): boolean {
|
||||
|
||||
/**
|
||||
* @description 根据服务器获取公告地址
|
||||
* @since Beta v0.7.7
|
||||
* @param {TGApp.BBS.Announcement.AnnoServerEnum} region 服务器
|
||||
* @since Beta v0.8.0
|
||||
* @param {TGApp.Game.Base.ServerTypeEnum} region 服务器
|
||||
* @returns {string} 公告地址
|
||||
*/
|
||||
function getAnnoApi(region: TGApp.BBS.Announcement.AnnoServerEnum): string {
|
||||
function getAnnoApi(region: TGApp.Game.Base.ServerTypeEnum): string {
|
||||
return isCN(region) ? AnnoApi : AnnoApiGlobal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取游戏内公告参数
|
||||
* @since Beta v0.7.7
|
||||
* @param {TGApp.BBS.Announcement.AnnoServerEnum} region 服务器
|
||||
* @since Beta v0.8.0
|
||||
* @param {TGApp.Game.Base.ServerTypeEnum} region 服务器
|
||||
* @param {TGApp.BBS.Announcement.AnnoLangEnum} lang 语言
|
||||
* @returns {TGApp.BBS.Announcement.Params}
|
||||
*/
|
||||
function getAnnoParams(
|
||||
region: TGApp.BBS.Announcement.AnnoServerEnum = AnnoServerEnum.CN_GF01,
|
||||
region: TGApp.Game.Base.ServerTypeEnum = GameServerEnum.CN_GF01,
|
||||
lang: TGApp.BBS.Announcement.AnnoLangEnum = AnnoLangEnum.CHS,
|
||||
): TGApp.BBS.Announcement.Params {
|
||||
return {
|
||||
@@ -64,13 +65,13 @@ function getAnnoParams(
|
||||
|
||||
/**
|
||||
* @description 获取游戏内公告列表
|
||||
* @since Beta v0.7.7
|
||||
* @param {TGApp.BBS.Announcement.AnnoServerEnum} region 服务器
|
||||
* @since Beta v0.8.0
|
||||
* @param {TGApp.Game.Base.ServerTypeEnum} region 服务器
|
||||
* @param {TGApp.BBS.Announcement.AnnoLangEnum} lang 语言
|
||||
* @returns {Promise<TGApp.BBS.Announcement.ListRes>}
|
||||
*/
|
||||
async function getAnnoList(
|
||||
region: TGApp.BBS.Announcement.AnnoServerEnum = AnnoServerEnum.CN_GF01,
|
||||
region: TGApp.Game.Base.ServerTypeEnum = GameServerEnum.CN_GF01,
|
||||
lang: TGApp.BBS.Announcement.AnnoLangEnum = AnnoLangEnum.CHS,
|
||||
): Promise<TGApp.BBS.Announcement.ListRes> {
|
||||
const resp = await TGHttp<TGApp.BBS.Announcement.ListResp>(`${getAnnoApi(region)}/getAnnList`, {
|
||||
@@ -82,13 +83,13 @@ async function getAnnoList(
|
||||
|
||||
/**
|
||||
* @description 获取游戏内公告内容
|
||||
* @since Beta v0.7.7
|
||||
* @param {TGApp.BBS.Announcement.AnnoServerEnum} region 服务器
|
||||
* @since Beta v0.8.0
|
||||
* @param {TGApp.Game.Base.ServerTypeEnum} region 服务器
|
||||
* @param {TGApp.BBS.Announcement.AnnoLangEnum} lang 语言
|
||||
* @returns {Promise<Array<TGApp.BBS.Announcement.AnnoDetail>>}
|
||||
*/
|
||||
async function getAnnoDetail(
|
||||
region: TGApp.BBS.Announcement.AnnoServerEnum = AnnoServerEnum.CN_GF01,
|
||||
region: TGApp.Game.Base.ServerTypeEnum = GameServerEnum.CN_GF01,
|
||||
lang: TGApp.BBS.Announcement.AnnoLangEnum = AnnoLangEnum.CHS,
|
||||
): Promise<Array<TGApp.BBS.Announcement.AnnoDetail>> {
|
||||
const resp = await TGHttp<TGApp.BBS.Announcement.DetailResp>(
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/**
|
||||
* @file store/modules/app.ts
|
||||
* @description App store module
|
||||
* @since Beta v0.7.7
|
||||
* @since Beta v0.8.0
|
||||
*/
|
||||
|
||||
import { AnnoLangEnum, AnnoServerEnum } from "@enum/anno.js";
|
||||
import { AnnoLangEnum } from "@enum/anno.js";
|
||||
import { GameServerEnum } from "@enum/game.js";
|
||||
import { path } from "@tauri-apps/api";
|
||||
import { getInitDeviceInfo } from "@utils/toolFunc.js";
|
||||
import { defineStore } from "pinia";
|
||||
@@ -43,7 +44,7 @@ const useAppStore = defineStore(
|
||||
// 设备信息
|
||||
const deviceInfo = ref<TGApp.App.Device.DeviceInfo>(getInitDeviceInfo());
|
||||
// 服务器
|
||||
const server = ref<TGApp.BBS.Announcement.AnnoServerEnum>(AnnoServerEnum.CN_QD01);
|
||||
const server = ref<TGApp.Game.Base.ServerTypeEnum>(GameServerEnum.CN_QD01);
|
||||
// 语言
|
||||
const lang = ref<TGApp.BBS.Announcement.AnnoLangEnum>(AnnoLangEnum.CHS);
|
||||
// 最近的咨讯类型
|
||||
|
||||
35
src/types/BBS/Announcement.d.ts
vendored
35
src/types/BBS/Announcement.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file types/BBS/Announcement.d.ts
|
||||
* @description 从 BBS 获取到的游戏内公告类型定义文件
|
||||
* @since Beta v0.7.7
|
||||
* @since Beta v0.8.0
|
||||
*/
|
||||
|
||||
declare namespace TGApp.BBS.Announcement {
|
||||
@@ -28,33 +28,6 @@ declare namespace TGApp.BBS.Announcement {
|
||||
*/
|
||||
type AnnoLangEnum = (typeof AnnoLang)[keyof typeof AnnoLang];
|
||||
|
||||
/**
|
||||
* @description 公告服务器类型
|
||||
* @since Beta v0.7.7
|
||||
* @const AnnoServer
|
||||
* @property {string} "cn_gf01" - 国内-国服
|
||||
* @property {string} "cn_qd01" - 国内-渠道服
|
||||
* @property {string} "os_usa" - 海外-美国
|
||||
* @property {string} "os_euro" - 海外-欧洲
|
||||
* @property {string} "os_asia" - 海外-亚洲
|
||||
* @property {string} "os_cht" - 海外-繁体中文
|
||||
*/
|
||||
const AnnoServer = <const>{
|
||||
CN_GF01: "cn_gf01",
|
||||
CN_QD01: "cn_qd01",
|
||||
OS_USA: "os_usa",
|
||||
OS_EURO: "os_euro",
|
||||
OS_ASIA: "os_asia",
|
||||
OS_CHT: "os_cht",
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 公告服务器类型枚举
|
||||
* @since Beta v0.7.7
|
||||
* @enum AnnoServerEnum
|
||||
*/
|
||||
type AnnoServerEnum = (typeof AnnoServer)[keyof typeof AnnoServer];
|
||||
|
||||
/**
|
||||
* @description 公告类型
|
||||
* @since Beta v0.7.7
|
||||
@@ -77,13 +50,13 @@ declare namespace TGApp.BBS.Announcement {
|
||||
/**
|
||||
* @description 需要的参数
|
||||
* @interface Params
|
||||
* @since Beta v0.4.3
|
||||
* @since Beta v0.8.0
|
||||
* @property {string} game - 游戏名称
|
||||
* @property {string} game_biz - 游戏业务名称
|
||||
* @property {string} lang - 语言
|
||||
* @property {string} bundle_id - 包 ID
|
||||
* @property {string} platform - 平台
|
||||
* @property {string} region - 区域
|
||||
* @property {TGApp.Game.Base.ServerTypeEnum} region - 区域
|
||||
* @property {string} level - 等级
|
||||
* @property {string} uid - 用户 ID
|
||||
*/
|
||||
@@ -93,7 +66,7 @@ declare namespace TGApp.BBS.Announcement {
|
||||
lang: AnnoLangEnum;
|
||||
bundle_id: string;
|
||||
platform: string;
|
||||
region: AnnoServerEnum;
|
||||
region: TGApp.Game.Base.ServerTypeEnum;
|
||||
level: string;
|
||||
uid: string;
|
||||
};
|
||||
|
||||
34
src/types/Game/Base.d.ts
vendored
Normal file
34
src/types/Game/Base.d.ts
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @file types/Game/Base.d.ts
|
||||
* @description 游戏相关基础类型定义文件
|
||||
* @since Beta v0.8.0
|
||||
*/
|
||||
|
||||
declare namespace TGApp.Game.Base {
|
||||
/**
|
||||
* @description 服务器类型
|
||||
* @since Beta v0.8.0
|
||||
* @const ServerType
|
||||
* @property {string} "cn_gf01" - 国内-国服
|
||||
* @property {string} "cn_qd01" - 国内-渠道服
|
||||
* @property {string} "os_usa" - 海外-美国
|
||||
* @property {string} "os_euro" - 海外-欧洲
|
||||
* @property {string} "os_asia" - 海外-亚洲
|
||||
* @property {string} "os_cht" - 海外-繁体中文
|
||||
*/
|
||||
const ServerType = <const>{
|
||||
CN_GF01: "cn_gf01",
|
||||
CN_QD01: "cn_qd01",
|
||||
OS_USA: "os_usa",
|
||||
OS_EURO: "os_euro",
|
||||
OS_ASIA: "os_asia",
|
||||
OS_CHT: "os_cht",
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 公告服务器类型枚举
|
||||
* @since Beta v0.8.0
|
||||
* @enum ServerTypeEnum
|
||||
*/
|
||||
type ServerTypeEnum = (typeof ServerType)[keyof typeof ServerType];
|
||||
}
|
||||
@@ -87,7 +87,7 @@ const { theme } = storeToRefs(useAppStore());
|
||||
|
||||
const route = useRoute();
|
||||
const annoId = Number(route.params.anno_id);
|
||||
const region = <TGApp.BBS.Announcement.AnnoServerEnum>route.params.region;
|
||||
const region = <TGApp.Game.Base.ServerTypeEnum>route.params.region;
|
||||
const lang = <TGApp.BBS.Announcement.AnnoLangEnum>route.params.lang;
|
||||
|
||||
const jsonList = shallowRef<TGApp.BBS.Announcement.AnnoSingle>();
|
||||
|
||||
@@ -29,7 +29,7 @@ import { useRoute } from "vue-router";
|
||||
|
||||
const route = useRoute();
|
||||
const annoId = Number(route.params.anno_id);
|
||||
const region = <TGApp.BBS.Announcement.AnnoServerEnum>route.params.region;
|
||||
const region = <TGApp.Game.Base.ServerTypeEnum>route.params.region;
|
||||
const lang = <TGApp.BBS.Announcement.AnnoLangEnum>route.params.lang;
|
||||
const appVersion = ref<string>();
|
||||
const annoData = shallowRef<TGApp.BBS.Announcement.AnnoDetail>();
|
||||
|
||||
Reference in New Issue
Block a user