mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
✏️ 类型修正
This commit is contained in:
@@ -5,8 +5,16 @@
|
||||
:name="`第${props.modelValue.id}间`"
|
||||
mode="level"
|
||||
/>
|
||||
<TuaDetailBattle title="上半" :model-value="props.modelValue.upBattle" />
|
||||
<TuaDetailBattle title="下半" :model-value="props.modelValue.downBattle" />
|
||||
<TuaDetailBattle
|
||||
v-if="props.modelValue.upBattle"
|
||||
title="上半"
|
||||
:model-value="props.modelValue.upBattle"
|
||||
/>
|
||||
<TuaDetailBattle
|
||||
v-if="props.modelValue.downBattle"
|
||||
title="下半"
|
||||
:model-value="props.modelValue.downBattle"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/**
|
||||
* @file plugins Sqlite utils transCharacter.ts
|
||||
* @file plugins/Sqlite/utils/transCharacter.ts
|
||||
* @description Sqlite 数据转换
|
||||
* @author BTMuli <bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
* @since Beta v0.3.9
|
||||
*/
|
||||
|
||||
import { timeToSecond } from "./transTime";
|
||||
@@ -26,7 +25,7 @@ export function transCharacterData(data: TGApp.Game.Abyss.CharacterData[]): stri
|
||||
|
||||
/**
|
||||
* @description 将通过 api 获取到的深渊数据转换为数据库中的数据
|
||||
* @since Alpha v0.2.0
|
||||
* @since Beta v0.3.9
|
||||
* @param {TGApp.Game.Abyss.Floor} data 深渊数据
|
||||
* @returns {string} 转换后的深渊数据
|
||||
*/
|
||||
@@ -37,24 +36,34 @@ export function transFloorData(data: TGApp.Game.Abyss.Floor[]): string {
|
||||
winStar: item.star,
|
||||
maxStar: item.max_star,
|
||||
isUnlock: item.is_unlock ? 1 : 0,
|
||||
levels: item.levels.map((level) => {
|
||||
return {
|
||||
id: level.index,
|
||||
winStar: level.star,
|
||||
maxStar: level.max_star,
|
||||
upBattle: transBattleData(
|
||||
<TGApp.Game.Abyss.Battle>level.battles.find((l) => l.index === 1),
|
||||
),
|
||||
downBattle: transBattleData(
|
||||
<TGApp.Game.Abyss.Battle>level.battles.find((l) => l.index === 2),
|
||||
),
|
||||
};
|
||||
}),
|
||||
levels: item.levels.map((level) => transLevelData(level)),
|
||||
};
|
||||
});
|
||||
return JSON.stringify(floor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 将通过 api 获取到的深渊数据转换为数据库中的数据
|
||||
* @since Beta v0.3.9
|
||||
* @param {TGApp.Game.Abyss.Level} data 深渊数据
|
||||
* @returns {TGApp.Sqlite.Abyss.Level} 转换后的深渊数据
|
||||
*/
|
||||
function transLevelData(data: TGApp.Game.Abyss.Level): TGApp.Sqlite.Abyss.Level {
|
||||
const res: TGApp.Sqlite.Abyss.Level = {
|
||||
id: data.index,
|
||||
winStar: data.star,
|
||||
maxStar: data.max_star,
|
||||
};
|
||||
for (const battle of data.battles) {
|
||||
if (battle.index === 1) {
|
||||
res.upBattle = transBattleData(battle);
|
||||
} else {
|
||||
res.downBattle = transBattleData(battle);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 将通过 api 获取到的深渊数据转换为数据库中的数据
|
||||
* @since Alpha v0.2.0
|
||||
|
||||
29
src/types/Sqlite/Abyss.d.ts
vendored
29
src/types/Sqlite/Abyss.d.ts
vendored
@@ -1,10 +1,15 @@
|
||||
/**
|
||||
* @file types Sqlite Abyss.d.ts
|
||||
* @file types/Sqlite/Abyss.d.ts
|
||||
* @description 数据库深境螺旋相关类型定义文件
|
||||
* @author BTMuli <bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
* @since Beta v0.3.9
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description 数据库深渊类型命名
|
||||
* @since Beta v0.3.9
|
||||
* @namespace TGApp.Sqlite.Abyss
|
||||
* @memberof TGApp.Sqlite
|
||||
*/
|
||||
declare namespace TGApp.Sqlite.Abyss {
|
||||
/**
|
||||
* @description 数据库-深境螺旋表
|
||||
@@ -30,7 +35,7 @@ declare namespace TGApp.Sqlite.Abyss {
|
||||
* @property {string} updated - 更新时间
|
||||
* @return SingleTable
|
||||
*/
|
||||
export interface SingleTable {
|
||||
interface SingleTable {
|
||||
uid: string;
|
||||
id: number;
|
||||
startTime: string;
|
||||
@@ -59,7 +64,7 @@ declare namespace TGApp.Sqlite.Abyss {
|
||||
* @property {number} star - 星级
|
||||
* @return Character
|
||||
*/
|
||||
export interface Character {
|
||||
interface Character {
|
||||
id: number;
|
||||
value: number;
|
||||
star: number;
|
||||
@@ -76,7 +81,7 @@ declare namespace TGApp.Sqlite.Abyss {
|
||||
* @property {Level[]} levels - 关卡数据
|
||||
* @return Floor
|
||||
*/
|
||||
export interface Floor {
|
||||
interface Floor {
|
||||
id: number;
|
||||
winStar: number;
|
||||
maxStar: number;
|
||||
@@ -86,7 +91,7 @@ declare namespace TGApp.Sqlite.Abyss {
|
||||
|
||||
/**
|
||||
* @description 数据库-深境螺旋表-关卡数据
|
||||
* @since Alpha v0.2.0
|
||||
* @since Beta v0.3.9
|
||||
* @interface Level
|
||||
* @property {number} id - 关卡 ID
|
||||
* @property {number} winStar - 获得星数
|
||||
@@ -95,12 +100,12 @@ declare namespace TGApp.Sqlite.Abyss {
|
||||
* @property {Battle} downBattle - 下半场数据
|
||||
* @return Level
|
||||
*/
|
||||
export interface Level {
|
||||
interface Level {
|
||||
id: number;
|
||||
winStar: number;
|
||||
maxStar: number;
|
||||
upBattle: Battle;
|
||||
downBattle: Battle;
|
||||
upBattle?: Battle;
|
||||
downBattle?: Battle;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +116,7 @@ declare namespace TGApp.Sqlite.Abyss {
|
||||
* @property {CharacterInfo[]} characters - 角色数据
|
||||
* @return Battle
|
||||
*/
|
||||
export interface Battle {
|
||||
interface Battle {
|
||||
time: string;
|
||||
characters: CharacterInfo[];
|
||||
}
|
||||
@@ -125,7 +130,7 @@ declare namespace TGApp.Sqlite.Abyss {
|
||||
* @property {number} level - 等级
|
||||
* @return CharacterInfo
|
||||
*/
|
||||
export interface CharacterInfo {
|
||||
interface CharacterInfo {
|
||||
id: number;
|
||||
level: number;
|
||||
star: number;
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/**
|
||||
* @file web utils backupData.ts
|
||||
* @file web/utils/backupData.ts
|
||||
* @description 数据备份
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.5
|
||||
*/
|
||||
|
||||
// tauri
|
||||
import { fs, path } from "@tauri-apps/api";
|
||||
|
||||
/**
|
||||
* @description 备份 Cookie 数据
|
||||
* @since Alpha v0.2.0
|
||||
* @param {Record<string, string>} cookie cookie
|
||||
* @param {TGApp.User.Account.Cookie} cookie cookie
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function backupCookieData(cookie: Record<string, string>): Promise<void> {
|
||||
export async function backupCookieData(cookie: TGApp.User.Account.Cookie): Promise<void> {
|
||||
const savePath = `${await path.appLocalDataDir()}\\userData\\cookie.json`;
|
||||
await fs.writeTextFile(savePath, JSON.stringify(cookie, null, 2));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file web utils restoreData.ts
|
||||
* @file web/utils/restoreData.ts
|
||||
* @description 数据恢复
|
||||
* @since Alpha v0.2.0
|
||||
* @since Beta v0.3.9
|
||||
*/
|
||||
|
||||
import { fs, path } from "@tauri-apps/api";
|
||||
@@ -23,13 +23,15 @@ export async function restoreCookieData(): Promise<boolean> {
|
||||
|
||||
/**
|
||||
* @description 恢复深渊数据
|
||||
* @since Alpha v0.2.0
|
||||
* @since Beta v0.3.9
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
export async function restoreAbyssData(): Promise<boolean> {
|
||||
const abyssPath = `${await path.appLocalDataDir()}\\userData\\abyss.json`;
|
||||
if (!(await fs.exists(abyssPath))) return false;
|
||||
const abyssData = await fs.readTextFile(abyssPath);
|
||||
await TGSqlite.restoreAbyss(JSON.parse(abyssData));
|
||||
const parseData = JSON.parse(abyssData);
|
||||
if (!parseData || !Array.isArray(parseData)) return false;
|
||||
await TGSqlite.restoreAbyss(<TGApp.Sqlite.Abyss.SingleTable[]>parseData);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user