diff --git a/src/components/app/to-nameCard.vue b/src/components/app/to-nameCard.vue index ceb462bf..942cef80 100644 --- a/src/components/app/to-nameCard.vue +++ b/src/components/app/to-nameCard.vue @@ -38,21 +38,11 @@ import TOverlay from "./t-overlay.vue"; import { generateShareImg } from "@/utils/TGShare.js"; -enum ToNameCardTypeEnum { - other, - achievement, - role, - record, - activity, - unknown, -} - -type ToNameCardTypeMap = { [key in ToNameCardTypeEnum]: string }; type ToNameCardProps = { data?: TGApp.App.NameCard.Item }; const props = defineProps(); const visible = defineModel(); -const typeMap: ToNameCardTypeMap = { +const typeMap: Record = { 0: "其他", 1: "成就", 2: "角色", @@ -62,10 +52,9 @@ const typeMap: ToNameCardTypeMap = { }; const loading = ref(false); const getType = computed(() => { - if (!props.data) return typeMap[ToNameCardTypeEnum.unknown]; - if (!(props.data.type satisfies ToNameCardTypeEnum)) return typeMap[5]; - const type: ToNameCardTypeEnum = props.data.type; - return typeMap[type]; + if (!props.data) return typeMap[0]; + if (!(props.data.type in typeMap)) return typeMap[5]; + return typeMap[props.data.type]; }); function parseNameCard(desc: string): string { diff --git a/src/pages/WIKI/Abyss.vue b/src/pages/WIKI/Abyss.vue index b7b2c9de..2df4a2f2 100644 --- a/src/pages/WIKI/Abyss.vue +++ b/src/pages/WIKI/Abyss.vue @@ -52,15 +52,8 @@ import { onMounted, reactive, type Ref, ref, shallowRef, watch } from "vue"; import { timestampToDate } from "@/utils/toolFunc.js"; -enum AbyssTabEnum { - use = "角色使用", - up = "角色出场", - team = "队伍出场", - hold = "角色持有", -} - -type AbyssTab = keyof typeof AbyssTabEnum; -type AbyssList = Array<{ label: AbyssTabEnum; value: AbyssTab }>; +type AbyssTab = "use" | "up" | "team" | "hold"; +type AbyssList = Array<{ label: string; value: AbyssTab }>; export type AbyssDataItem = { cur: T; last: T }; export type AbyssDataItemType = T extends "use" ? AbyssDataItem> @@ -74,11 +67,17 @@ export type AbyssDataItemType = T extends "use" type AbyssData = { [key in AbyssTab]: Ref | null> }; const abyssList: Readonly = [ - { label: AbyssTabEnum.use, value: "use" }, - { label: AbyssTabEnum.up, value: "up" }, - { label: AbyssTabEnum.team, value: "team" }, - { label: AbyssTabEnum.hold, value: "hold" }, + { label: "角色使用", value: "use" }, + { label: "角色出场", value: "up" }, + { label: "队伍出场", value: "team" }, + { label: "角色持有", value: "hold" }, ]; +const abyssMap: Readonly> = { + use: "角色使用率", + up: "角色出场率", + team: "队伍出场率", + hold: "角色持有率", +}; const showDialog = ref(false); const tab = shallowRef("use"); const overview = shallowRef>(); @@ -107,7 +106,7 @@ onMounted(async () => { async function refreshData(type: AbyssTab): Promise { if (abyssData && abyssData[type] !== null) return; - await showLoading.start("正在获取深渊数据", `正在获取 ${AbyssTabEnum[type]} 数据`); + await showLoading.start("正在获取深渊数据", `正在获取 ${abyssMap[type]} 数据`); const data = await getData(type); switch (type) { case "use": diff --git a/src/pages/common/PageHome.vue b/src/pages/common/PageHome.vue index 35b9c8a9..c2863e55 100644 --- a/src/pages/common/PageHome.vue +++ b/src/pages/common/PageHome.vue @@ -72,7 +72,7 @@ import { storeToRefs } from "pinia"; import { type Component, computed, onMounted, ref, shallowRef, watch } from "vue"; import { useAppStore } from "@/store/modules/app.js"; -import { ShowItemEnum, useHomeStore } from "@/store/modules/home.js"; +import { useHomeStore } from "@/store/modules/home.js"; import TGLogger from "@/utils/TGLogger.js"; import apiHubReq from "@/web/request/apiHubReq.js"; @@ -87,20 +87,16 @@ type SelectItem = { icon: string; title: string; gid: number }; const { devMode, isLogin } = storeToRefs(useAppStore()); const homeStore = useHomeStore(); -const showItemsAll: Array = [ - ShowItemEnum.calendar, - ShowItemEnum.pool, - ShowItemEnum.position, -]; +const showItemsAll: Array = ["素材日历", "限时祈愿", "近期活动"]; const curGid = ref(2); const gameList = shallowRef>(); -const loadItems = shallowRef>([]); +const loadItems = shallowRef>([]); const components = shallowRef>([]); -const showItems = computed>({ +const showItems = computed>({ get: () => homeStore.getShowItems(), - set: (v: Array) => homeStore.setShowItems(v), + set: (v: Array) => homeStore.setShowItems(v), }); onMounted(async () => { @@ -154,14 +150,14 @@ async function submitHome(): Promise { await loadComp(); } -function getName(name: string): ShowItemEnum | undefined { +function getName(name: string): string | undefined { switch (name) { case "ph-comp-pool": - return ShowItemEnum.pool; + return "限时祈愿"; case "ph-comp-position": - return ShowItemEnum.position; + return "近期活动"; case "ph-comp-calendar": - return ShowItemEnum.calendar; + return "素材日历"; default: return undefined; } diff --git a/src/pages/common/PostNews.vue b/src/pages/common/PostNews.vue index 1db34ecb..832de484 100644 --- a/src/pages/common/PostNews.vue +++ b/src/pages/common/PostNews.vue @@ -72,7 +72,7 @@ import type { Ref } from "vue"; import { computed, onMounted, reactive, ref, shallowRef } from "vue"; import { useRoute, useRouter } from "vue-router"; -import { type NewsType, NewsTypeEnum, useAppStore } from "@/store/modules/app.js"; +import { type NewsType, useAppStore } from "@/store/modules/app.js"; import TGBbs from "@/utils/TGBbs.js"; import TGLogger from "@/utils/TGLogger.js"; import { createPost } from "@/utils/TGWindow.js"; @@ -87,6 +87,7 @@ const { recentNewsType } = storeToRefs(useAppStore()); const { gid } = <{ gid: string }>useRoute().params; const tabValues: Readonly> = ["notice", "activity", "news"]; +const tabMap: Readonly> = { notice: "1", activity: "2", news: "3" }; const gameName = TGBbs.channels.find((v) => v.gid.toString() === gid)?.title || "未知分区"; const loading = ref(false); @@ -123,7 +124,7 @@ async function firstLoad(key: NewsType, refresh: boolean = false): Promise } await showLoading.start(`正在获取${gameName}${rawData[key].name}数据`); document.documentElement.scrollTo({ top: 0, behavior: "smooth" }); - const getData = await painterReq.news(gid, NewsTypeEnum[key]); + const getData = await painterReq.news(gid, tabMap[key]); await showLoading.update(`数量:${getData.list.length},是否最后一页:${getData.is_last}`); rawData[key] = { isLast: getData.is_last, name: rawData[key].name, lastId: getData.list.length }; postData[key] = getData.list; @@ -150,7 +151,7 @@ async function loadMore(key: NewsType): Promise { await showLoading.start(`正在获取${gameName}${rawData[key].name}数据`); const mod = rawData[key].lastId % 20; const pageSize = mod === 0 ? 20 : 20 - mod; - const getData = await painterReq.news(gid, NewsTypeEnum[key], pageSize, rawData[key].lastId); + const getData = await painterReq.news(gid, tabMap[key], pageSize, rawData[key].lastId); await showLoading.update(`数量:${getData.list.length},是否最后一页:${getData.is_last}`); rawData[key].lastId = rawData[key].lastId + getData.list.length; rawData[key].isLast = getData.is_last; diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index e2541577..d7f5609e 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -18,13 +18,7 @@ const dbDataPath: Readonly = `${await path.appConfigDir()}${path.sep()}T // 用于存放日志的路径 const logDataDir: Readonly = await path.appLogDir(); -export enum NewsTypeEnum { - notice = "1", - activity = "2", - news = "3", -} - -export type NewsType = keyof typeof NewsTypeEnum; +export type NewsType = "notice" | "activity" | "news"; export const useAppStore = defineStore( "app", diff --git a/src/store/modules/home.ts b/src/store/modules/home.ts index 3a109550..e8590c18 100644 --- a/src/store/modules/home.ts +++ b/src/store/modules/home.ts @@ -1,29 +1,23 @@ /** * @file store/modules/home.ts * @description Home store module - * @since Beta v0.6.5 + * @since Beta v0.7.2 */ import { defineStore } from "pinia"; import { ref } from "vue"; -export const enum ShowItemEnum { - calendar = "素材日历", - pool = "限时祈愿", - position = "近期活动", -} - -export type ShowItem = { show: boolean; order: number; label: ShowItemEnum }; +export type ShowItem = { show: boolean; order: number; label: string }; export const useHomeStore = defineStore("home", () => { const homeShow = ref>([ - { show: true, order: 1, label: ShowItemEnum.pool }, - { show: true, order: 2, label: ShowItemEnum.position }, - { show: true, order: 3, label: ShowItemEnum.calendar }, + { show: true, order: 1, label: "限时祈愿" }, + { show: true, order: 2, label: "近期活动" }, + { show: true, order: 3, label: "素材日历" }, ]); const poolCover = ref>(); - function getShowItems(): Array { + function getShowItems(): Array { const homeShowLocal = localStorage.getItem("homeShow"); if (homeShowLocal === null || !Array.isArray(JSON.parse(homeShowLocal))) { localStorage.setItem("homeShow", JSON.stringify(homeShow.value)); @@ -37,14 +31,14 @@ export const useHomeStore = defineStore("home", () => { function init(): void { homeShow.value = [ - { show: true, order: 1, label: ShowItemEnum.pool }, - { show: true, order: 2, label: ShowItemEnum.position }, - { show: true, order: 3, label: ShowItemEnum.calendar }, + { show: true, order: 1, label: "限时祈愿" }, + { show: true, order: 2, label: "近期活动" }, + { show: true, order: 3, label: "素材日历" }, ]; localStorage.setItem("homeShow", JSON.stringify(homeShow.value)); } - function setShowItems(items: Array): void { + function setShowItems(items: Array): void { let order = 1; for (const item of items) { const findIdx = homeShow.value.findIndex((i) => i.label === item); diff --git a/src/types/Game/Constant.d.ts b/src/types/Game/Constant.d.ts deleted file mode 100644 index 335417fd..00000000 --- a/src/types/Game/Constant.d.ts +++ /dev/null @@ -1,88 +0,0 @@ -/** - * @file types Game Constant.d.ts - * @description 游戏常量类型定义文件 - * @author BTMuli - * @since Alpha v0.1.5 - */ - -declare namespace TGApp.Game.Constant { - /** - * @description 七元素 - * @since Alpha v0.1.5 - * @enum {string} - * @property {string} pyro - 火元素 - * @property {string} hydro - 水元素 - * @property {string} anemo - 风元素 - * @property {string} electro - 雷元素 - * @property {string} cryo - 冰元素 - * @property {string} geo - 岩元素 - * @property {string} dendro - 草元素 - */ - export enum EnumElement { - pyro = "火元素", - hydro = "水元素", - anemo = "风元素", - electro = "雷元素", - cryo = "冰元素", - geo = "岩元素", - dendro = "草元素", - } - - /** - * @description 七元素-英文 - * @since Alpha v0.2.0 - * @enum {string} - * @property {string} pyro - 火元素 - * @property {string} hydro - 水元素 - * @property {string} anemo - 风元素 - * @property {string} electro - 雷元素 - * @property {string} cryo - 冰元素 - * @property {string} geo - 岩元素 - * @property {string} dendro - 草元素 - */ - export enum EnumElementEn { - pyro = "Pyro", - hydro = "Hydro", - anemo = "Anemo", - electro = "Electro", - cryo = "Cryo", - geo = "Geo", - dendro = "Dendro", - } - - /** - * @description 武器类型 - * @since Alpha v0.1.5 - * @enum {string} - * @property {string} sword - 单手剑 - * @property {string} claymore - 双手剑 - * @property {string} pole - 长柄武器 - * @property {string} bow - 弓 - * @property {string} catalyst - 法器 - */ - export enum EnumWeapon { - sword = "单手剑", - claymore = "双手剑", - pole = "长柄武器", - bow = "弓", - catalyst = "法器", - } - - /** - * @description 圣遗物位置 - * @since Alpha v0.2.0 - * @enum {string} - * @property {string} flower - 生之花 - * @property {string} feather - 死之羽 - * @property {string} sands - 时之沙 - * @property {string} goblet - 空之杯 - * @property {string} circlet - 理之冠 - */ - export enum EnumRelic { - flower = "生之花", - feather = "死之羽", - sands = "时之沙", - goblet = "空之杯", - circlet = "理之冠", - } -} diff --git a/tsconfig.json b/tsconfig.json index 23201a27..7bf71304 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,7 @@ "types": ["vite/client", "node", "color-convert", "js-md5", "uuid"], "allowSyntheticDefaultImports": true, "composite": true, + "erasableSyntaxOnly": true, "baseUrl": ".", "paths": { "@/*": ["src/*"],