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