diff --git a/.eslintrc.yml b/.eslintrc.yml index 2dd2be31..bdf8209f 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -16,6 +16,8 @@ parserOptions: project: - ./tsconfig.json - ./tsconfig.node.json +globals: + BTMuli: readonly plugins: - vue rules: diff --git a/src/components/t-calendar.vue b/src/components/t-calendar.vue index 3a9c8264..2b08dd76 100644 --- a/src/components/t-calendar.vue +++ b/src/components/t-calendar.vue @@ -102,7 +102,6 @@ import { ref, onMounted } from "vue"; // data import { TGAppData } from "../data/index"; // interface -import type TGTypes from "../core/types/TGTypes"; import { OBC_CONTENT_API } from "../plugins/Mys/interface/utils"; import { createTGWindow } from "../utils/TGWindow"; @@ -110,13 +109,13 @@ import { createTGWindow } from "../utils/TGWindow"; const loading = ref(true as boolean); // data -const calendarData = ref(TGAppData.calendar as Record); +const calendarData = ref(TGAppData.calendar as Record); const weekNow = ref(0 as number); const btnNow = ref(0 as number); const dateNow = ref(new Date().toLocaleDateString()); -const calendarNow = ref({} as TGTypes.CalendarData); -const characterCards = ref({} as Record); -const weaponCards = ref({} as Record); +const calendarNow = ref({} as BTMuli.Genshin.Calendar.CalendarData); +const characterCards = ref({} as Record); +const weaponCards = ref({} as Record); const btnText = [ { @@ -172,7 +171,7 @@ function getCalendar (day: number) { return calendarData.value[week]; } -function showContent (material: TGTypes.CalendarMaterial) { +function showContent (material: BTMuli.Genshin.Calendar.Material) { const url = OBC_CONTENT_API.replace("{content_id}", material.content_id.toString()); createTGWindow(url, "素材详情", material.name, 1200, 800, true); } diff --git a/src/core/request/getAnno.ts b/src/core/request/getAnno.ts index 9a7a0be9..d3197035 100644 --- a/src/core/request/getAnno.ts +++ b/src/core/request/getAnno.ts @@ -6,16 +6,15 @@ */ import { http } from "@tauri-apps/api"; -import type TGTypes from "../types/TGTypes"; import TGApi from "../api/TGApi"; /** * @description 获取游戏内公告列表 * @since Alpha v0.1.2 - * @returns {Promise} + * @returns {Promise} */ -export async function getAnnoList (): Promise { - return await http.fetch(`${TGApi.GameAnnoList}${TGApi.GameAnnoQuery}`).then((res) => res.data.data); +export async function getAnnoList (): Promise { + return await http.fetch(`${TGApi.GameAnnoList}${TGApi.GameAnnoQuery}`).then((res) => res.data.data); } /** @@ -24,9 +23,9 @@ export async function getAnnoList (): Promise { * @param {number} annId 公告 ID * @returns {Promise} */ -export async function getAnnoContent (annId: number): Promise { - const annoContents: TGTypes.AnnoContentItem[] = await http - .fetch(`${TGApi.GameAnnoContent}${TGApi.GameAnnoQuery}`) +export async function getAnnoContent (annId: number): Promise { + const annoContents: BTMuli.Genshin.Announcement.ContentItem[] = await http + .fetch(`${TGApi.GameAnnoContent}${TGApi.GameAnnoQuery}`) .then((res) => res.data.data.list); const annoContent = annoContents.find((item) => item.ann_id === annId); if (annoContent) { diff --git a/src/core/types/TGAnno.d.ts b/src/core/types/TGAnno.d.ts deleted file mode 100644 index 63511c34..00000000 --- a/src/core/types/TGAnno.d.ts +++ /dev/null @@ -1,216 +0,0 @@ -/** - * @file core types TGAnnouncement.d.ts - * @description 类型定义,用于定义原神游戏内公告相关类型 - * @author BTMuli - * @since Alpha v0.1.2 - */ - -import type TGBase from "./TGBase"; - -namespace TGAnno { - /** - * @description 原神游戏内公告列表返回 - * @since Alpha v0.1.2 - * @see TGApi.GameAnnoList - * @interface AnnoListResponse - * @extends TGBase.BaseResponse - * @property {AnnoListData} data 公告数据 - * @returns {AnnoListResponse} - */ - export interface AnnoListResponse extends TGBase.BaseResponse { - data: AnnoListData - } - - /** - * @description 原神游戏内公告内容返回 - * @since Alpha v0.1.2 - * @see TGApi.GameAnnoContent - * @interface AnnoContentResponse - * @extends Hk4eResponse - * @property {AnnoContentData} data 公告数据 - * @returns {AnnoContentResponse} - */ - export interface AnnoContentResponse extends Hk4eResponse { - data: AnnoContentData - } - - /** - * @description 公告列表数据 - * @since Alpha v0.1.2 - * @interface AnnoListData - * @property {Announcement[]} list 公告列表 - * @property {number} total 公告总数 - * @property {AnnoTypeList[]} type_list 公告类型列表 - * @property {boolean} alert 是否有紧急公告 - * @property {number} alert_id 紧急公告 ID - * @property {number} time_zone 时区 - * @property {string} t 系统时间 - * @property {unknown[]} pic_list 图片列表 - * @property {number} pic_total 图片总数 - * @property {unknown[]} pic_type_list 图片类型列表 - * @property {boolean} pic_alert 是否有紧急图片 - * @property {number} pic_alert_id 紧急图片 ID - * @property {unknown} static_sign 静态签名 - * @returns {AnnoListData} - */ - export interface AnnoListData { - list: Announcement[] - total: number - type_list: AnnoTypeList[] - alert: boolean - alert_id: number - time_zone: number - t: string - pic_list: unknown[] - pic_total: number - pic_type_list: unknown[] - pic_alert: boolean - pic_alert_id: number - static_sign: unknown - } - - /** - * @description 公告内容数据 - * @since Alpha v0.1.2 - * @interface AnnoContentData - * @property {AnnoContentItem[]} list 公告列表 - * @property {number} total 公告总数 - * @property {unknown[]} pic_list 图片列表 - * @property {number} pic_total 图片总数 - * @returns {AnnoContentData} - */ - export interface AnnoContentData { - list: AnnoContentItem[] - total: number - pic_list: unknown[] - pic_total: number - } - - /** - * @description 公告类型列表 - * @since Alpha v0.1.2 - * @interface AnnoTypeList - * @property {number} id 类型 ID - * @property {string} name 类型名称 - * @property {string} mi18n_name 类型名称 - * @returns {AnnoTypeList} - */ - export interface AnnoTypeList { - id: number - name: string - mi18n_name: string - } - - /** - * @description 公告 - * @since Alpha v0.1.2 - * @interface Announcement - * @property {AnnoListItem[]} list 公告列表 - * @property {number} type_id 类型 ID - * @property {string} type_label 类型标签 - * @returns {Announcement} - */ - export interface Announcement { - list: AnnoListItem[] - type_id: number - type_label: string - } - - /** - * @description 公告列表项 - * @since Alpha v0.1.2 - * @interface AnnoListItem - * @property {number} ann_id 公告 ID - * @property {string} title 公告标题 - * @property {string} subtitle 公告副标题 - * @property {string} banner 公告图片 - * @property {unknown} content 公告内容 - * @property {string} type_label 公告类型标签 - * @property {string} tag_label 公告标签 - * @property {string} tag_icon 公告标签图标 - * @property {number} login_alert 是否登录提示 - * @property {string} lang 公告语言 - * @property {string} start_time 公告开始时间 // "2023-03-01 07:00:00" - * @property {string} end_time 公告结束时间 // "2023-04-12 06:00:00" - * @property {number} type 公告类型 - * @property {number} remind 公告提醒 - * @property {number} alert 公告紧急 - * @property {string} tag_start_time 公告标签开始时间 // "2000-01-02 15:04:05" - * @property {string} tag_end_time 公告标签结束时间 // "2030-01-02 15:04:05" - * @property {number} remind_ver 公告提醒版本 - * @property {boolean} has_content 是否有内容 - * @property {boolean} extra_remind 是否有额外提醒 - * @returns {AnnoListItem} - */ - export interface AnnoListItem { - ann_id: number - title: string - subtitle: string - banner: string - content: unknown - type_label: string - tag_label: string - tag_icon: string - login_alert: number - lang: string - start_time: string - end_time: string - type: number - remind: number - alert: number - tag_start_time: string - tag_end_time: string - remind_ver: number - has_content: boolean - extra_remind: boolean - } - - /** - * @description 公告内容列表 - * @since Alpha v0.1.2 - * @interface AnnoContentItem - * @property {number} ann_id 公告 ID - * @property {string} title 公告标题 - * @property {string} subtitle 公告副标题 - * @property {string} banner 公告图片 - * @property {string} content 公告内容为 HTML - * @property {string} lang 公告语言 - * @returns {AnnoContentItem} - */ - export interface AnnoContentItem { - ann_id: number - title: string - subtitle: string - banner: string - content: string - lang: string - } - - /** - * @description 渲染用公告列表数据 - * @since Alpha v0.1.2 - * @interface AnnoListCard - * @property {number} id 公告 ID - * @property {string} title 公告标题 - * @property {string} subtitle 公告副标题 - * @property {string} banner 公告图片 - * @property {string} typeLabel 公告类型标签 - * @property {string} tagIcon 公告标签图标 - * @property {string} startTime 公告开始时间 - * @property {string} endTime 公告结束时间 - * @returns {AnnoListCard} - */ - export interface AnnoListCard { - id: number - title: string - subtitle: string - banner: string - typeLabel: string - tagIcon: string - startTime: string - endTime: string - } - -} - -export default TGAnno; diff --git a/src/core/types/TGBase.d.ts b/src/core/types/TGBase.d.ts deleted file mode 100644 index ca929c0b..00000000 --- a/src/core/types/TGBase.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @file core types TGBase.d.ts - * @description 类型定义,用于定义一些基础类型 - * @author BTMuli - * @since Alpha v0.1.2 - */ - -namespace TGBase { -/** - * @description 定义 IndexedDB 数据库配置 - * @since Alpha v0.1.2 - * @interface DBConfig - * @property {string} storeName 数据库名称 - * @property {string} keyPath 数据库主键 - * @property {string[]} indexes 数据库索引 - * @returns {DBConfig} - */ - export interface DBConfig { - storeName: string - keyPath: string - indexes: string[] - } - - /** - * @description 定义基础返回数据 - * @since Alpha v0.1.2 - * @interface BaseResponse - * @property {number} retcode 状态码 - * @property {string} message 状态信息 - * @property {any} data 数据 - * @returns {BaseResponse} - */ - export interface BaseResponse { - retcode: number - message: string - data: any - } -} - -export default TGBase; diff --git a/src/core/types/TGCalendar.d.ts b/src/core/types/TGCalendar.d.ts deleted file mode 100644 index 59ec7fef..00000000 --- a/src/core/types/TGCalendar.d.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @file core types TGCalendar.d.ts - * @description 本应用的素材日历类型定义 - * @author BTMuli - * @since Alpha v0.1.2 - */ - -namespace TGCalendar { - /** - * @description 素材日历接口 - * @interface CalendarData - * @since Alpha v0.1.2 - * @property {Record} characters - 该天的角色相关数据 - * @property {Record} weapons - 该天的武器相关数据 - * @returns {CalendarData} - */ - export interface CalendarData { - characters: Record - weapons: Record - } - - /** - * @description 单日单秘境的素材日历接口 - * @interface CalendarItem - * @since Alpha v0.1.2 - * @property {string} title - 地区 秘境名称 - * @property {CalendarMaterial[]} materials - 素材 url - * @property {CalendarMaterial[]} contents - 角色/武器 url - * @returns {CalendarItem} - */ - export interface CalendarItem { - title: string - materials: CalendarMaterial[] - contents: CalendarMaterial[] - } - - /** - * @description 材料类型 - * @interface MiniMaterial - * @since Alpha v0.1.2 - * @property {number} id - 角色/武器的 id - * @property {number} star - 角色/武器的星级 - * @property {number} content_id - 观测枢的 content_id - * @property {string} name - 名称 - * @property {string} icon - 图标 url - */ - export interface CalendarMaterial { - id?: number - star: number - content_id: number - name: string - icon: string - } -} - -export default TGCalendar; diff --git a/src/core/types/TGNameCard.d.ts b/src/core/types/TGNameCard.d.ts deleted file mode 100644 index 8ccb4c72..00000000 --- a/src/core/types/TGNameCard.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file core types TGNameCard.d.ts - * @description 本应用的名片类型定义 - * @author BTMuli - * @since Alpha v0.1.2 - */ - -namespace TGNameCard { - /** - * @description 本应用的名片类型 - * @since Alpha v0.1.2 - * @interface NameCard - * @property {string} name - 名片名称,同时也是文件名 - * @property {string} description - 名片描述 - * @property {string} icon - 名片图标路径 - * @property {string} bg - 名片背景图路径 - * @property {string} profile - 名片 Profile 图路径 - * @property {number} type - 名片类型 (0: 其他,1: 成就,2:角色,3:纪行,4:活动) - * @property {string} source - 名片来源 - * @returns {NameCard} - */ - export interface NameCard { - name: string - description: string - icon: string - bg: string - profile: string - type: number - source: string - } -} - -export default TGNameCard; diff --git a/src/core/types/TGTypes.d.ts b/src/core/types/TGTypes.d.ts deleted file mode 100644 index 4a1f2467..00000000 --- a/src/core/types/TGTypes.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file core types App.d.ts - * @description 本应用的类型定义 - * @author BTMuli - * @since Alpha v0.1.2 - */ - -import type TGAchievement from "./TGAchievement"; -import type TGAnno from "./TGAnno"; -import type TGBase from "./TGBase"; -import type TGCalendar from "./TGCalendar"; -import type TGNameCard from "./TGNameCard"; - -namespace TGTypes { - export type Achievement = TGAchievement.Achievement; - export type AchievementSeries = TGAchievement.AchievementSeries; - export type AnnoListResponse = TGAnno.AnnoListResponse; - export type AnnoContentResponse = TGAnno.AnnoContentResponse; - export type AnnoContentData = TGAnno.AnnoContentData; - export type AnnoContentItem = TGAnno.AnnoContentItem; - export type AnnoListCard = TGAnno.AnnoListCard; - export type AnnoListData = TGAnno.AnnoListData; - export type AnnoListItem = TGAnno.AnnoListItem; - export type AnnoTypeList = TGAnno.AnnoTypeList; - export type Announcement = TGAnno.Announcement; - export type CalendarData = TGCalendar.CalendarData; - export type CalendarItem = TGCalendar.CalendarItem; - export type CalendarMaterial = TGCalendar.CalendarMaterial; - export type DBConfig = TGBase.DBConfig; - export type NameCard = TGNameCard.NameCard; -} - -export default TGTypes; diff --git a/src/core/utils/getAnnoCard.ts b/src/core/utils/getAnnoCard.ts index 43a9c9fd..7c2ce175 100644 --- a/src/core/utils/getAnnoCard.ts +++ b/src/core/utils/getAnnoCard.ts @@ -5,18 +5,16 @@ * @since Alpha v0.1.2 */ -import type TGTypes from "../types/TGTypes"; - /** * @description 将获取到的数据转为渲染用的卡片 * @since Alpha v0.1.2 - * @param {TGTypes.AnnoListData} data 公告数据 + * @param {BTMuli.Genshin.Announcement.ListData} data 公告数据 * @returns {AnnoListCard[]} 渲染用的卡片 */ -export function getAnnoCard (data: TGTypes.AnnoListData): TGTypes.AnnoListCard[] { - const cards: TGTypes.AnnoListCard[] = []; - data.list.map((annoList: TGTypes.Announcement) => { - return annoList.list.map((anno: TGTypes.AnnoListItem) => { +export function getAnnoCard (data: BTMuli.Genshin.Announcement.ListData): BTMuli.Genshin.Announcement.ListCard[] { + const cards: BTMuli.Genshin.Announcement.ListCard[] = []; + data.list.map((annoList: BTMuli.Genshin.Announcement) => { + return annoList.list.map((anno: BTMuli.Genshin.Announcement.ListItem) => { return cards.push({ id: anno.ann_id, title: anno.title, diff --git a/src/data/app/index.ts b/src/data/app/index.ts index 61efb09b..e1e88da4 100644 --- a/src/data/app/index.ts +++ b/src/data/app/index.ts @@ -12,17 +12,16 @@ import GCG from "./GCG.json"; import nameCards from "./nameCards.json"; import calendar from "./calendar.json"; // Interface -import type TGAppTypes from "../../core/types/TGTypes"; import { type BaseCard } from "../../interface/GCG"; export const AppDataList = [ { name: "achievements.json", - data: achievements as Record, + data: achievements as Record, }, { name: "achievementSeries.json", - data: achievementSeries as Record, + data: achievementSeries as Record, }, { name: "GCG.json", @@ -30,18 +29,18 @@ export const AppDataList = [ }, { name: "nameCards.json", - data: nameCards as Record, + data: nameCards as Record, }, { name: "calendar.json", - data: calendar as Record, + data: calendar as Record, }, ]; export const AppData = { - achievements: achievements as Record, - achievementSeries: achievementSeries as Record, + achievements: achievements as Record, + achievementSeries: achievementSeries as Record, GCG: GCG as BaseCard[], - nameCards: nameCards as Record, - calendar: calendar as Record, + nameCards: nameCards as Record, + calendar: calendar as Record, }; diff --git a/src/data/init/GCG.ts b/src/data/init/GCG.ts index fb3223b5..fad2cbaa 100644 --- a/src/data/init/GCG.ts +++ b/src/data/init/GCG.ts @@ -6,15 +6,14 @@ * @since Alpha v0.1.2 */ import { AppData } from "../app"; -import type TGTypes from "../../core/types/TGTypes"; import { type BaseCard } from "../../interface/GCG"; /** * @description 卡牌表参数 * @since Alpha v0.1.2 - * @returns {TGTypes.DBConfig} + * @returns {BTMuli.Genshin.Base.DBConfig} */ -export const Config: TGTypes.DBConfig = { +export const Config: BTMuli.Genshin.Base.DBConfig = { storeName: "GCG", keyPath: "id", // 根据 type 分类 diff --git a/src/data/init/achievementSeries.ts b/src/data/init/achievementSeries.ts index 02d9ee4a..2cd1e74c 100644 --- a/src/data/init/achievementSeries.ts +++ b/src/data/init/achievementSeries.ts @@ -4,15 +4,14 @@ * @author BTMuli * @since Alpha v0.1.2 */ -import type TGTypes from "../../core/types/TGTypes"; import { AppData } from "../app"; /** * @description 成就系列表参数 * @since Alpha v0.1.2 - * @returns {TGTypes.DBConfig} + * @returns {BTMuli.Genshin.Base.DBConfig} */ -export const Config: TGTypes.DBConfig = { +export const Config: BTMuli.Genshin.Base.DBConfig = { storeName: "AchievementSeries", keyPath: "id", indexes: ["order", "name", "card"], @@ -21,10 +20,10 @@ export const Config: TGTypes.DBConfig = { /** * @description 成就系列数据 * @since Alpha v0.1.2 - * @return {TGTypes.AchievementSeries[]} + * @return {BTMuli.Genshin.AchievementSeries[]} */ -export function getData (): TGTypes.AchievementSeries[] { - const data: Record = AppData.achievementSeries; +export function getData (): BTMuli.Genshin.AchievementSeries[] { + const data: Record = AppData.achievementSeries; return Object.keys(data).map((key) => { return data[Number(key)]; }); diff --git a/src/data/init/achievements.ts b/src/data/init/achievements.ts index b659dd24..9eac7d79 100644 --- a/src/data/init/achievements.ts +++ b/src/data/init/achievements.ts @@ -5,14 +5,13 @@ * @since Alpha v0.1.2 */ import { AppData } from "../app"; -import type TGTypes from "../../core/types/TGTypes"; /** * @description 成就表参数 * @since Alpha v0.1.2 - * @returns {TGTypes.DBConfig} + * @returns {BTMuli.Genshin.Base.DBConfig} */ -export const Config: TGTypes.DBConfig = { +export const Config: BTMuli.Genshin.Base.DBConfig = { storeName: "Achievements", keyPath: "id", indexes: ["name", "description", "series", "order", "reward", "version"], @@ -21,10 +20,10 @@ export const Config: TGTypes.DBConfig = { /** * @description 成就数据 * @since Alpha v0.1.2 - * @return {TGTypes.Achievement[]} + * @return {BTMuli.Genshin.Achievement[]} */ -export function getData (): TGTypes.Achievement[] { - const data: Record = AppData.achievements; +export function getData (): BTMuli.Genshin.Achievement[] { + const data: Record = AppData.achievements; return Object.keys(data).map((key) => { return data[Number(key)]; }); diff --git a/src/data/init/nameCard.ts b/src/data/init/nameCard.ts index d928a0cc..55d97acb 100644 --- a/src/data/init/nameCard.ts +++ b/src/data/init/nameCard.ts @@ -6,14 +6,13 @@ */ import { AppData } from "../app"; -import type TGTypes from "../../core/types/TGTypes"; /** * @description 名片表参数 * @since Alpha v0.1.2 - * @returns {TGTypes.DBConfig} + * @returns {BTMuli.Genshin.Base.DBConfig} */ -export const Config: TGTypes.DBConfig = { +export const Config: BTMuli.Genshin.Base.DBConfig = { storeName: "NameCard", keyPath: "name", indexes: ["type"], @@ -22,13 +21,13 @@ export const Config: TGTypes.DBConfig = { /** * @description 名片数据 * @since Alpha v0.1.2 - * @return {TGTypes.NameCard[]} + * @return {BTMuli.Genshin.NameCard[]} */ -export function getData (): TGTypes.NameCard[] { - const data: Record = AppData.nameCards; - const result: TGTypes.NameCard[] = []; +export function getData (): BTMuli.Genshin.NameCard[] { + const data: Record = AppData.nameCards; + const result: BTMuli.Genshin.NameCard[] = []; Object.keys(data).map((key) => { - const cards: TGTypes.NameCard[] = data[Number(key)]; + const cards: BTMuli.Genshin.NameCard[] = data[Number(key)]; return cards.map((card) => result.push(card)); }); return result; diff --git a/src/pages/Achievements.vue b/src/pages/Achievements.vue index 242ba1f3..99926510 100644 --- a/src/pages/Achievements.vue +++ b/src/pages/Achievements.vue @@ -108,7 +108,6 @@ import { dialog, fs } from "@tauri-apps/api"; // Store import { useAchievementsStore } from "../store/modules/achievements"; // Interface -import type TGTypes from "../core/types/TGTypes"; import { Achievements, UiafHeader, UiafAchievement } from "../plugins/UIAF/interface/UIAF"; // Plugins import UiafOper from "../plugins/UIAF"; @@ -125,13 +124,13 @@ const loadingTitle = ref("正在加载数据" as string); // data const title = ref(achievementsStore.title as string); -const CardsInfo = ref([] as TGTypes.NameCard[]); -const getCardInfo = ref({} as TGTypes.NameCard); +const CardsInfo = ref([] as BTMuli.Genshin.NameCard.NameCard[]); +const getCardInfo = ref({} as BTMuli.Genshin.NameCard.NameCard); // series -const seriesList = ref([] as TGTypes.AchievementSeries[]); +const seriesList = ref([] as BTMuli.Genshin.AchievementSeries[]); const selectedIndex = ref(-1 as number); const selectedSeries = ref(-1 as number); -const selectedAchievement = ref([] as TGTypes.Achievement[]); +const selectedAchievement = ref([] as BTMuli.Genshin.Achievement[]); // render const search = ref("" as string); @@ -145,7 +144,7 @@ onMounted(async () => { // 加载数据,数据源:合并后的本地数据 async function loadData () { loadingTitle.value = "正在获取成就系列数据"; - const seriesDB: TGTypes.AchievementSeries[] = await ReadAllTGData("AchievementSeries"); + const seriesDB: BTMuli.Genshin.AchievementSeries[] = await ReadAllTGData("AchievementSeries"); loadingTitle.value = "正在获取成就系列名片数据"; CardsInfo.value = await ReadTGDataByIndex("NameCard", "type", 1); loadingTitle.value = "对成就系列数据进行排序"; @@ -179,11 +178,11 @@ async function selectSeries (index: number) { selectedIndex.value = index; selectedSeries.value = seriesList.value[index].id; loadingTitle.value = "正在查找对应的成就名片"; - let getCard: TGTypes.NameCard; + let getCard: BTMuli.Genshin.NameCard.NameCard; if (selectedSeries.value !== 0 && selectedSeries.value !== 17) { getCard = CardsInfo.value.find((card) => card.name === seriesList.value[index].card)!; } else { - getCard = {} as TGTypes.NameCard; + getCard = {} as BTMuli.Genshin.NameCard.NameCard; } loadingTitle.value = "正在对成就数据进行排序"; getAchievements.sort((a, b) => { @@ -213,7 +212,7 @@ async function searchCard () { } loadingTitle.value = "正在搜索"; loading.value = true; - const res: TGTypes.Achievement[] = []; + const res: BTMuli.Genshin.Achievement[] = []; const allAchievements = await ReadAllTGData("Achievements"); allAchievements.map((achievement) => { if (achievement.name.includes(search.value) || achievement.description.includes(search.value)) { @@ -265,7 +264,7 @@ async function importJson () { await Promise.allSettled( remoteData.list.map(async (data) => { const id = data.id; - const localData: TGTypes.Achievement = (await ReadTGDataByKey("Achievements", [id]))[0]; + const localData: BTMuli.Genshin.Achievement = (await ReadTGDataByKey("Achievements", [id]))[0]; // 获取 timeStamp 2023-03-15 00:00:00 const localTime = localData.completed_time; // 如果本地数据不存在,或者本地数据的 timeStamp 小于远程数据的 timeStamp,更新数据 diff --git a/src/pages/Announcements.vue b/src/pages/Announcements.vue index 76847294..d2348b00 100644 --- a/src/pages/Announcements.vue +++ b/src/pages/Announcements.vue @@ -99,9 +99,6 @@ import TGRequest from "../core/request/TGRequest"; import TGUtils from "../core/utils/TGUtils"; import { createTGWindow } from "../utils/TGWindow"; -// interface -import type TGTypes from "../core/types/TGTypes"; - // store const appStore = useAppStore(); @@ -114,10 +111,10 @@ const router = useRouter(); // 数据 const tab = ref(""); const annoCards = ref({ - activity: [] as TGTypes.AnnoListCard[], - game: [] as TGTypes.AnnoListCard[], + activity: [] as BTMuli.Genshin.Announcement.ListCard[], + game: [] as BTMuli.Genshin.Announcement.ListCard[], }); -const annoData = ref({} as TGTypes.AnnoListData); +const annoData = ref({} as BTMuli.Genshin.Announcement.ListData); onMounted(async () => { loadingTitle.value = "正在获取公告数据"; @@ -138,7 +135,7 @@ async function switchNews () { await router.push("/news"); } -async function toPost (item: TGTypes.AnnoListCard) { +async function toPost (item: BTMuli.Genshin.Announcement.ListCard) { const path = router.resolve({ name: "游戏内公告", params: { @@ -149,7 +146,7 @@ async function toPost (item: TGTypes.AnnoListCard) { createTGWindow(path, "游戏内公告", item.title, 960, 720, false, false); } -async function toJson (item: TGTypes.AnnoListCard) { +async function toJson (item: BTMuli.Genshin.Announcement.ListCard) { const path = router.resolve({ name: "游戏内公告(JSON)", params: { diff --git a/src/core/types/TGAchievement.d.ts b/src/types/Achievement.d.ts similarity index 50% rename from src/core/types/TGAchievement.d.ts rename to src/types/Achievement.d.ts index 227cfbff..9aba6e6f 100644 --- a/src/core/types/TGAchievement.d.ts +++ b/src/types/Achievement.d.ts @@ -5,7 +5,7 @@ * @ since Alpha v0.1.2 */ -namespace TGAchievement { +declare namespace BTMuli.Genshin { /** * @description 本应用的成就类型 * @since Alpha v0.1.2 @@ -35,32 +35,32 @@ namespace TGAchievement { version: string } - /** - * @description 本应用的成就系列类型 - * @since Alpha v0.1.2 - * @interface AchievementSeries - * @property {number} id - 成就系列 ID - * @property {number} order - 成就系列排列顺序,用于展示全部成就系列 - * @property {string} name - 成就系列名称 - * @property {string} version - 成就系列版本 - * @property {number[]} achievements - 成就系列包含的成就 - * @property {number} total_count - 成就系列包含的成就数 - * @property {number} completed_count - 成就系列已完成的成就数 - * @property {string} card - 成就系列对应名片 - * @property {string} icon - 成就系列图标 - * @return AchievementSeries - */ - export interface AchievementSeries { - id: number - order: number - name: string - version: string - achievements: number[] - total_count: number - completed_count: number - card?: string - icon: string + export namespace Achievement { + /** + * @description 本应用的成就系列类型 + * @since Alpha v0.1.2 + * @interface AchievementSeries + * @property {number} id - 成就系列 ID + * @property {number} order - 成就系列排列顺序,用于展示全部成就系列 + * @property {string} name - 成就系列名称 + * @property {string} version - 成就系列版本 + * @property {number[]} achievements - 成就系列包含的成就 + * @property {number} total_count - 成就系列包含的成就数 + * @property {number} completed_count - 成就系列已完成的成就数 + * @property {string} card - 成就系列对应名片 + * @property {string} icon - 成就系列图标 + * @return AchievementSeries + */ + export interface Series { + id: number + order: number + name: string + version: string + achievements: number[] + total_count: number + completed_count: number + card?: string + icon: string + } } } - -export default TGAchievement; diff --git a/src/types/Announcement.d.ts b/src/types/Announcement.d.ts new file mode 100644 index 00000000..e4177bd9 --- /dev/null +++ b/src/types/Announcement.d.ts @@ -0,0 +1,219 @@ +/** + * @file core types TGAnnouncement.d.ts + * @description 类型定义,用于定义原神游戏内公告相关类型 + * @author BTMuli + * @since Alpha v0.1.2 + */ +declare namespace BTMuli.Genshin { + /** + * @description 公告 + * @since Alpha v0.1.2 + * @interface Announcement + * @property {AnnoListItem[]} list 公告列表 + * @property {number} type_id 类型 ID + * @property {string} type_label 类型标签 + * @returns {Announcement} + */ + export interface Announcement { + list: ListItem[] + type_id: number + type_label: string + } + /** + * @file core types TGAnnouncement.d.ts + * @description 类型定义,用于定义原神游戏内公告相关类型 + * @author BTMuli + * @since Alpha v0.1.2 + */ + + export namespace Announcement { + /** + * @description 原神游戏内公告列表返回 + * @since Alpha v0.1.2 + * @see TGApi.GameAnnoList + * @interface AnnoListResponse + * @extends TGBase.BaseResponse + * @property {AnnoListData} data 公告数据 + * @returns {ListResponse} + */ + export interface ListResponse extends Base.Response { + data: ListData + } + + /** + * @description 原神游戏内公告内容返回 + * @since Alpha v0.1.2 + * @see TGApi.GameAnnoContent + * @interface AnnoContentResponse + * @extends Hk4eResponse + * @property {AnnoContentData} data 公告数据 + * @returns {ContentResponse} + */ + export interface ContentResponse extends Hk4eResponse { + data: ContentData + } + + /** + * @description 公告列表数据 + * @since Alpha v0.1.2 + * @interface AnnoListData + * @property {Announcement[]} list 公告列表 + * @property {number} total 公告总数 + * @property {AnnoTypeList[]} type_list 公告类型列表 + * @property {boolean} alert 是否有紧急公告 + * @property {number} alert_id 紧急公告 ID + * @property {number} time_zone 时区 + * @property {string} t 系统时间 + * @property {unknown[]} pic_list 图片列表 + * @property {number} pic_total 图片总数 + * @property {unknown[]} pic_type_list 图片类型列表 + * @property {boolean} pic_alert 是否有紧急图片 + * @property {number} pic_alert_id 紧急图片 ID + * @property {unknown} static_sign 静态签名 + * @returns {ListData} + */ + export interface ListData { + list: Announcement[] + total: number + type_list: TypeList[] + alert: boolean + alert_id: number + time_zone: number + t: string + pic_list: unknown[] + pic_total: number + pic_type_list: unknown[] + pic_alert: boolean + pic_alert_id: number + static_sign: unknown + } + + /** + * @description 公告内容数据 + * @since Alpha v0.1.2 + * @interface AnnoContentData + * @property {AnnoContentItem[]} list 公告列表 + * @property {number} total 公告总数 + * @property {unknown[]} pic_list 图片列表 + * @property {number} pic_total 图片总数 + * @returns {ContentData} + */ + export interface ContentData { + list: ContentItem[] + total: number + pic_list: unknown[] + pic_total: number + } + + /** + * @description 公告类型列表 + * @since Alpha v0.1.2 + * @interface AnnoTypeList + * @property {number} id 类型 ID + * @property {string} name 类型名称 + * @property {string} mi18n_name 类型名称 + * @returns {TypeList} + */ + export interface TypeList { + id: number + name: string + mi18n_name: string + } + + /** + * @description 公告列表项 + * @since Alpha v0.1.2 + * @interface AnnoListItem + * @property {number} ann_id 公告 ID + * @property {string} title 公告标题 + * @property {string} subtitle 公告副标题 + * @property {string} banner 公告图片 + * @property {unknown} content 公告内容 + * @property {string} type_label 公告类型标签 + * @property {string} tag_label 公告标签 + * @property {string} tag_icon 公告标签图标 + * @property {number} login_alert 是否登录提示 + * @property {string} lang 公告语言 + * @property {string} start_time 公告开始时间 // "2023-03-01 07:00:00" + * @property {string} end_time 公告结束时间 // "2023-04-12 06:00:00" + * @property {number} type 公告类型 + * @property {number} remind 公告提醒 + * @property {number} alert 公告紧急 + * @property {string} tag_start_time 公告标签开始时间 // "2000-01-02 15:04:05" + * @property {string} tag_end_time 公告标签结束时间 // "2030-01-02 15:04:05" + * @property {number} remind_ver 公告提醒版本 + * @property {boolean} has_content 是否有内容 + * @property {boolean} extra_remind 是否有额外提醒 + * @returns {ListItem} + */ + export interface ListItem { + ann_id: number + title: string + subtitle: string + banner: string + content: unknown + type_label: string + tag_label: string + tag_icon: string + login_alert: number + lang: string + start_time: string + end_time: string + type: number + remind: number + alert: number + tag_start_time: string + tag_end_time: string + remind_ver: number + has_content: boolean + extra_remind: boolean + } + + /** + * @description 公告内容列表 + * @since Alpha v0.1.2 + * @interface AnnoContentItem + * @property {number} ann_id 公告 ID + * @property {string} title 公告标题 + * @property {string} subtitle 公告副标题 + * @property {string} banner 公告图片 + * @property {string} content 公告内容为 HTML + * @property {string} lang 公告语言 + * @returns {ContentItem} + */ + export interface ContentItem { + ann_id: number + title: string + subtitle: string + banner: string + content: string + lang: string + } + + /** + * @description 渲染用公告列表数据 + * @since Alpha v0.1.2 + * @interface AnnoListCard + * @property {number} id 公告 ID + * @property {string} title 公告标题 + * @property {string} subtitle 公告副标题 + * @property {string} banner 公告图片 + * @property {string} typeLabel 公告类型标签 + * @property {string} tagIcon 公告标签图标 + * @property {string} startTime 公告开始时间 + * @property {string} endTime 公告结束时间 + * @returns {ListCard} + */ + export interface ListCard { + id: number + title: string + subtitle: string + banner: string + typeLabel: string + tagIcon: string + startTime: string + endTime: string + } + + } +} diff --git a/src/types/Base.d.ts b/src/types/Base.d.ts new file mode 100644 index 00000000..80671b7c --- /dev/null +++ b/src/types/Base.d.ts @@ -0,0 +1,40 @@ +/** + * @file core types TGBase.d.ts + * @description 类型定义,用于定义一些基础类型 + * @author BTMuli + * @since Alpha v0.1.2 + */ + +declare namespace BTMuli.Genshin { + export namespace Base { + /** + * @description 定义 IndexedDB 数据库配置 + * @since Alpha v0.1.2 + * @interface DBConfig + * @property {string} storeName 数据库名称 + * @property {string} keyPath 数据库主键 + * @property {string[]} indexes 数据库索引 + * @returns {DBConfig} + */ + export interface DBConfig { + storeName: string + keyPath: string + indexes: string[] + } + + /** + * @description 定义基础返回数据 + * @since Alpha v0.1.2 + * @interface BaseResponse + * @property {number} retcode 状态码 + * @property {string} message 状态信息 + * @property {any} data 数据 + * @returns {Response} + */ + export interface Response { + retcode: number + message: string + data: any + } + } +} diff --git a/src/types/Calendar.d.ts b/src/types/Calendar.d.ts new file mode 100644 index 00000000..3cba91fd --- /dev/null +++ b/src/types/Calendar.d.ts @@ -0,0 +1,56 @@ +/** + * @file core types TGCalendar.d.ts + * @description 本应用的素材日历类型定义 + * @author BTMuli + * @since Alpha v0.1.2 + */ + +declare namespace BTMuli.Genshin { + export namespace Calendar { + /** + * @description 素材日历接口 + * @interface CalendarData + * @since Alpha v0.1.2 + * @property {Record} characters - 该天的角色相关数据 + * @property {Record} weapons - 该天的武器相关数据 + * @returns {Data} + */ + export interface Data { + characters: Record + weapons: Record + } + + /** + * @description 单日单秘境的素材日历接口 + * @interface CalendarItem + * @since Alpha v0.1.2 + * @property {string} title - 地区 秘境名称 + * @property {CalendarMaterial[]} materials - 素材 url + * @property {CalendarMaterial[]} contents - 角色/武器 url + * @returns {Item} + */ + export interface Item { + title: string + materials: Material[] + contents: Material[] + } + + /** + * @description 材料类型 + * @interface MiniMaterial + * @since Alpha v0.1.2 + * @property {number} id - 角色/武器的 id + * @property {number} star - 角色/武器的星级 + * @property {number} content_id - 观测枢的 content_id + * @property {string} name - 名称 + * @property {string} icon - 图标 url + */ + export interface Material { + id?: number + star: number + content_id: number + name: string + icon: string + } + } +} diff --git a/src/types/NameCard.d.ts b/src/types/NameCard.d.ts new file mode 100644 index 00000000..a9e3d46e --- /dev/null +++ b/src/types/NameCard.d.ts @@ -0,0 +1,33 @@ +/** + * @file core types TGNameCard.d.ts + * @description 本应用的名片类型定义 + * @author BTMuli + * @since Alpha v0.1.2 + */ + +declare namespace BTMuli.Genshin { + /** + * @description 本应用的名片类型 + * @since Alpha v0.1.2 + * @interface NameCard + * @property {string} name - 名片名称,同时也是文件名 + * @property {string} description - 名片描述 + * @property {string} icon - 名片图标路径 + * @property {string} bg - 名片背景图路径 + * @property {string} profile - 名片 Profile 图路径 + * @property {number} type - 名片类型 (0: 其他,1: 成就,2:角色,3:纪行,4:活动) + * @property {string} source - 名片来源 + * @returns {NameCard} + */ + export interface NameCard { + name: string + description: string + icon: string + bg: string + profile: string + type: number + source: string + } + export namespace NameCard { + } +} diff --git a/src/views/t-anno-json.vue b/src/views/t-anno-json.vue index ef19c556..22bd4df7 100644 --- a/src/views/t-anno-json.vue +++ b/src/views/t-anno-json.vue @@ -23,8 +23,6 @@ import TLoading from "../components/t-loading.vue"; import { appWindow } from "@tauri-apps/api/window"; // utils import TGRequest from "../core/request/TGRequest"; -// interface -import type TGTypes from "../core/types/TGTypes"; // loading const loading = ref(true as boolean); @@ -47,8 +45,8 @@ onMounted(async () => { // 获取数据 loadingTitle.value = "正在获取数据..."; const listData = await TGRequest.Anno.getList(); - listData.list.map((item: TGTypes.Announcement) => { - return item.list.map((single: TGTypes.AnnoListItem) => { + listData.list.map((item: BTMuli.Genshin.Announcement.Announcement) => { + return item.list.map((single: BTMuli.Genshin.Announcement.ListItem) => { return single.ann_id === annoId ? (jsonList = single) : null; }); }); diff --git a/src/views/t-anno.vue b/src/views/t-anno.vue index f4297f3c..41febcfa 100644 --- a/src/views/t-anno.vue +++ b/src/views/t-anno.vue @@ -24,8 +24,6 @@ import { appWindow } from "@tauri-apps/api/window"; // plugins import TGRequest from "../core/request/TGRequest"; import TGUtils from "../core/utils/TGUtils"; -// interface -import type TGTypes from "../core/types/TGTypes"; // loading const loading = ref(true as boolean); @@ -34,7 +32,7 @@ const loadingEmpty = ref(false as boolean); // 数据 const annoId = Number(useRoute().params.anno_id); -const annoData = ref({} as TGTypes.AnnoContentItem); +const annoData = ref({} as BTMuli.Genshin.Announcement.ContentItem); const annoHtml = ref(""); onMounted(async () => {