mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🏷️ feat(UIGF): 添加 Uigf 类型,调整 Uiaf 类型
This commit is contained in:
@@ -113,7 +113,7 @@ import { useAchievementsStore } from "../store/modules/achievements";
|
||||
import { TGAppData } from "../data";
|
||||
import { createTGWindow } from "../utils/TGWindow";
|
||||
import { ReadAllTGData, ReadTGDataByIndex, ReadTGDataByKey, UpdateTGDataByKey } from "../utils/TGIndex";
|
||||
import { getHeader, readUIAF, verifyUIAF } from "../utils/UIAF";
|
||||
import { getUiafHeader, readUiafData, verifyUiafData } from "../utils/UIAF";
|
||||
|
||||
// Store
|
||||
const achievementsStore = useAchievementsStore();
|
||||
@@ -147,11 +147,9 @@ async function loadData () {
|
||||
loadingTitle.value = "正在获取成就系列数据";
|
||||
const seriesDB: BTMuli.Genshin.AchievementSeries[] = await ReadAllTGData("AchievementSeries");
|
||||
CardsInfo.value = TGAppData.nameCards[1];
|
||||
loadingTitle.value = "对成就系列数据进行排序";
|
||||
seriesList.value = seriesDB.sort((a, b) => a.order - b.order);
|
||||
loadingTitle.value = "正在获取成就数据";
|
||||
const getAchievements = await ReadAllTGData("Achievements");
|
||||
loadingTitle.value = "正在对成就数据进行排序";
|
||||
getAchievements.sort((a, b) => {
|
||||
if (a.completed === b.completed) {
|
||||
return a.id - b.id;
|
||||
@@ -159,7 +157,6 @@ async function loadData () {
|
||||
return a.completed ? 1 : -1;
|
||||
}
|
||||
});
|
||||
loadingTitle.value = "正在渲染成就数据";
|
||||
selectedAchievement.value = getAchievements;
|
||||
title.value = achievementsStore.title;
|
||||
loading.value = false;
|
||||
@@ -184,7 +181,6 @@ async function selectSeries (index: number) {
|
||||
} else {
|
||||
getCard = {} as BTMuli.Genshin.NameCard;
|
||||
}
|
||||
loadingTitle.value = "正在对成就数据进行排序";
|
||||
getAchievements.sort((a, b) => {
|
||||
if (a.completed === b.completed) {
|
||||
return a.id - b.id;
|
||||
@@ -192,7 +188,6 @@ async function selectSeries (index: number) {
|
||||
return a.completed ? 1 : -1;
|
||||
}
|
||||
});
|
||||
loadingTitle.value = "正在渲染成就数据";
|
||||
selectedAchievement.value = getAchievements;
|
||||
getCardInfo.value = getCard;
|
||||
loading.value = false;
|
||||
@@ -252,8 +247,8 @@ async function importJson () {
|
||||
},
|
||||
],
|
||||
});
|
||||
if (selectedFile && (await verifyUIAF(<string>selectedFile))) {
|
||||
const remoteRaw: string | false = await readUIAF(<string>selectedFile);
|
||||
if (selectedFile && (await verifyUiafData(<string>selectedFile))) {
|
||||
const remoteRaw: string | false = await readUiafData(<string>selectedFile);
|
||||
if (remoteRaw === false) {
|
||||
snackbarText.value = "读取 UIAF 数据失败,请检查文件是否符合规范";
|
||||
snackbar.value = true;
|
||||
@@ -339,7 +334,7 @@ async function exportJson () {
|
||||
return data.progress !== 0 || data.completed === true;
|
||||
});
|
||||
const UiafData = {
|
||||
info: await getHeader(),
|
||||
info: await getUiafHeader(),
|
||||
list: [] as TGPlugin.UIAF.Achievement[],
|
||||
};
|
||||
// 转换数据
|
||||
|
||||
107
src/types/Gacha.d.ts
vendored
Normal file
107
src/types/Gacha.d.ts
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* @file types Gacha.d.ts
|
||||
* @description 卡池祈愿类型定义
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.3
|
||||
*/
|
||||
|
||||
declare namespace TGPlugin.UIGF {
|
||||
/**
|
||||
* @description UIGF 数据
|
||||
* @since Alpha v1.3.0
|
||||
* @interface BaseData
|
||||
* @property {UigfInfo} info - UIGF 头部信息
|
||||
* @property {UigfGacha[]} list - UIGF 祈愿列表
|
||||
* @return BaseData
|
||||
*/
|
||||
export interface BaseData {
|
||||
info: UigfInfo
|
||||
list: UigfInfo[]
|
||||
}
|
||||
|
||||
/**
|
||||
* @description UIGF 头部信息
|
||||
* @since Alpha v1.3.0
|
||||
* @interface UigfInfo
|
||||
* @property {string} uid - UID
|
||||
* @property {string} lang - 语言
|
||||
* @property {string} uigf_version - UIGF 版本
|
||||
* @property {number} export_timestamp - 导出时间戳(秒)
|
||||
* @property {string} export_time - 导出时间 yyyy-MM-dd HH:mm:ss
|
||||
* @property {string} export_app - 导出应用
|
||||
* @property {string} export_app_version - 导出应用版本
|
||||
* @return UIGF_Info
|
||||
*/
|
||||
export interface UigfInfo {
|
||||
uid: string
|
||||
lang: string
|
||||
uigf_version: string
|
||||
export_timestamp?: number
|
||||
export_time?: string
|
||||
export_app?: string
|
||||
export_app_version?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 祈愿类型
|
||||
* @since Alpha v1.3.0
|
||||
* @enum EnumGachaType
|
||||
* @property {string} CharacterUp - 角色活动祈愿
|
||||
* @property {string} CharacterUp2 - 角色活动祈愿2
|
||||
* @property {string} WeaponUp - 武器活动祈愿
|
||||
* @property {string} Normal - 普通祈愿
|
||||
* @property {string} Newbie - 新手祈愿
|
||||
* @return EnumGachaType
|
||||
*/
|
||||
export enum EnumGachaType {
|
||||
CharacterUp = "301",
|
||||
CharacterUp2 = "400",
|
||||
WeaponUp = "302",
|
||||
Normal = "200",
|
||||
Newbie = "100",
|
||||
}
|
||||
|
||||
/**
|
||||
* @description UIGF 祈愿类型
|
||||
* @since Alpha v1.3.0
|
||||
* @enum EnumUigfGachaType
|
||||
* @property {string} CharacterUp - 角色活动祈愿&角色活动祈愿2
|
||||
* @property {string} WeaponUp - 武器活动祈愿
|
||||
* @property {string} Normal - 普通祈愿
|
||||
* @property {string} Newbie - 新手祈愿
|
||||
* @return EnumUigfGachaType
|
||||
*/
|
||||
export enum EnumUigfGachaType {
|
||||
CharacterUp = "301",
|
||||
WeaponUp = "302",
|
||||
Normal = "200",
|
||||
Newbie = "100",
|
||||
}
|
||||
|
||||
/**
|
||||
* @description UIGF 祈愿列表
|
||||
* @since Alpha v1.3.0
|
||||
* @interface UigfGacha
|
||||
* @property {EnumGachaType} gacha_type - 祈愿类型
|
||||
* @property {string} item_id - 物品ID
|
||||
* @property {string} count - 数量
|
||||
* @property {string} time - 时间 yyyy-MM-dd HH:mm:ss
|
||||
* @property {string} name - 名称
|
||||
* @property {string} item_type - 物品类型
|
||||
* @property {string} rank_type - 稀有度
|
||||
* @property {string} id - ID
|
||||
* @property {EnumUigfGachaType} uigf_gacha_type - UIGF 祈愿类型
|
||||
* @return UIGF_Gacha
|
||||
*/
|
||||
export interface UigfGacha {
|
||||
gacha_type: string
|
||||
item_id?: string
|
||||
count?: string
|
||||
time: string
|
||||
name: string
|
||||
item_type?: string
|
||||
rank_type?: string
|
||||
id: string
|
||||
uigf_gacha_type: string
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
/**
|
||||
* @description 获取 UIAF 头部信息
|
||||
* @since Alpha v0.1.2
|
||||
* @returns {Promise<TGPlugin.UIAF.Header>}
|
||||
* @file utils UIAF.ts
|
||||
* @description UIAF工具类
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.3
|
||||
*/
|
||||
|
||||
import { app, fs } from "@tauri-apps/api";
|
||||
|
||||
/**
|
||||
* @description 获取 UIAF 头部信息
|
||||
* @since Alpha v0.1.2
|
||||
* @since Alpha v0.1.3
|
||||
* @returns {Promise<TGPlugin.UIAF.Header>}
|
||||
*/
|
||||
|
||||
export async function getHeader (): Promise<TGPlugin.UIAF.Header> {
|
||||
export async function getUiafHeader (): Promise<TGPlugin.UIAF.Header> {
|
||||
return {
|
||||
// eslint-disable-next-line camelcase
|
||||
export_app: "Tauri.Genshin",
|
||||
@@ -28,23 +28,23 @@ export async function getHeader (): Promise<TGPlugin.UIAF.Header> {
|
||||
/**
|
||||
* @description 检测是否存在 UIAF 数据
|
||||
* @description 粗略检测,不保证数据完整性
|
||||
* @since Alpha v0.1.2
|
||||
* @since Alpha v0.1.3
|
||||
* @param {string} path - UIAF 数据路径
|
||||
* @returns {Promise<boolean>} 是否存在 UIAF 数据
|
||||
*/
|
||||
export async function verifyUIAF (path: string): Promise<boolean> {
|
||||
export async function verifyUiafData (path: string): Promise<boolean> {
|
||||
const fileData: string = await fs.readTextFile(path);
|
||||
const UIAFData: TGPlugin.UIAF.Header = JSON.parse(fileData).info;
|
||||
return UIAFData.uiaf_version !== undefined;
|
||||
const UiafData: TGPlugin.UIAF.Header = JSON.parse(fileData).info;
|
||||
return UiafData.uiaf_version !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 读取 UIAF 数据
|
||||
* @since Alpha v0.1.2
|
||||
* @since Alpha v0.1.3
|
||||
* @param {string} userPath - UIAF 数据路径
|
||||
* @returns {Promise<string|false>} UIAF 数据
|
||||
*/
|
||||
export async function readUIAF (userPath: string): Promise<string | false> {
|
||||
export async function readUiafData (userPath: string): Promise<string | false> {
|
||||
if (await fs.exists(userPath)) {
|
||||
const fileData = await fs.readTextFile(userPath);
|
||||
if (fileData !== undefined && fileData !== null && fileData !== "" && fileData !== "{}") {
|
||||
|
||||
Reference in New Issue
Block a user