diff --git a/src/plugins/Sqlite/index.ts b/src/plugins/Sqlite/index.ts index 8f254a14..712d0a87 100644 --- a/src/plugins/Sqlite/index.ts +++ b/src/plugins/Sqlite/index.ts @@ -139,6 +139,24 @@ class Sqlite { for (const item of sqlD) { await db.execute(item); } + // 检测是否存在字段 + await this.updateAbyss(); + } + + /** + * @description 更新 SpiralAbyss 表 + * @since Beta v0.6.1 + * @returns {Promise} + */ + public async updateAbyss(): Promise { + const db = await this.getDB(); + try { + await db.select("SELECT skippedFloor FROM SpiralAbyss;"); + } catch (e) { + await TGLogger.Error(JSON.stringify(e)); + const sql = "ALTER TABLE SpiralAbyss ADD skippedFloor TEXT DEFAULT ''"; + await db.execute(sql); + } } /** diff --git a/src/plugins/Sqlite/modules/userAbyss.ts b/src/plugins/Sqlite/modules/userAbyss.ts index 3581eb79..9f456167 100644 --- a/src/plugins/Sqlite/modules/userAbyss.ts +++ b/src/plugins/Sqlite/modules/userAbyss.ts @@ -1,7 +1,7 @@ /** * @file plugins/Sqlite/modules/userAbyss.ts * @description Sqlite-用户深渊模块 - * @since Beta v0.6.0 + * @since Beta v0.6.1 */ import { path } from "@tauri-apps/api"; @@ -50,7 +50,7 @@ function getRestoreSql(data: TGApp.Sqlite.Abyss.SingleTable): string { /** * @description 获取深渊数据的插入更新Sql - * @since Beta v0.6.0 + * @since Beta v0.6.1 * @param {string} uid - 用户UID * @param {TGApp.Game.Abyss.FullData} data -深渊数据 * @returns {string} @@ -66,15 +66,16 @@ function getInsertSql(uid: string, data: TGApp.Game.Abyss.FullData): string { const normalSkillRank = transCharacterData(data.normal_skill_rank); const energySkillRank = transCharacterData(data.energy_skill_rank); const floors = transFloorData(data.floors); + const skippedFloor = data.is_just_skipped_floor ? data.skipped_floor : ""; const timeNow = timestampToDate(new Date().getTime()); return ` - INSERT INTO SpiralAbyss (uid, id, startTime, endTime, totalBattleTimes, totalWinTimes, - maxFloor, totalStar, isUnlock, revealRank, defeatRank, damageRank, - takeDamageRank, normalSkillRank, energySkillRank, floors, updated) + INSERT INTO SpiralAbyss (uid, id, startTime, endTime, totalBattleTimes, totalWinTimes, maxFloor, + totalStar, isUnlock, revealRank, defeatRank, damageRank, takeDamageRank, + normalSkillRank, energySkillRank, floors, skippedFloor, updated) VALUES ('${uid}', ${data.schedule_id}, '${startTime}', '${endTime}', ${data.total_battle_times}, - ${data.total_win_times}, '${data.max_floor}', ${data.total_star}, - ${isUnlock}, '${revealRank}', '${defeatRank}', '${damageRank}', '${takeDamageRank}', - '${normalSkillRank}', '${energySkillRank}', '${floors}', '${timeNow}') + ${data.total_win_times}, '${data.max_floor}', ${data.total_star}, ${isUnlock}, + '${revealRank}', '${defeatRank}', '${damageRank}', '${takeDamageRank}', '${normalSkillRank}', + '${energySkillRank}', '${floors}', '${skippedFloor}', '${timeNow}') ON CONFLICT(uid, id) DO UPDATE SET startTime = '${startTime}', endTime = '${endTime}', @@ -90,6 +91,7 @@ function getInsertSql(uid: string, data: TGApp.Game.Abyss.FullData): string { normalSkillRank = '${normalSkillRank}', energySkillRank = '${energySkillRank}', floors = '${floors}', + skippedFloor = '${skippedFloor}', updated = '${timeNow}'; `; } diff --git a/src/plugins/Sqlite/sql/createTable.sql b/src/plugins/Sqlite/sql/createTable.sql index a8678fd0..565d8d4c 100644 --- a/src/plugins/Sqlite/sql/createTable.sql +++ b/src/plugins/Sqlite/sql/createTable.sql @@ -66,6 +66,7 @@ create table if not exists SpiralAbyss normalSkillRank text, energySkillRank text, floors text, + skippedFloor text, updated text, primary key (uid, id) ); diff --git a/src/types/Game/Abyss.d.ts b/src/types/Game/Abyss.d.ts index b021053e..024aaba2 100644 --- a/src/types/Game/Abyss.d.ts +++ b/src/types/Game/Abyss.d.ts @@ -26,7 +26,7 @@ declare namespace TGApp.Game.Abyss { /** * @description 深渊数据类型 * @interface FullData - * @since Alpha v0.2.0 + * @since Beta v0.6.1 * @property {number} schedule_id - 深渊周期 ID * @property {string} start_time - 深渊开始时间,单位:秒 * @property {string} end_time - 深渊结束时间,单位:秒 @@ -42,6 +42,8 @@ declare namespace TGApp.Game.Abyss { * @property {Floor[]} floors - 深渊各层数据 * @property {number} total_star - 总星数 * @property {boolean} is_unlock - 是否解锁 + * @property {boolean} is_just_skipped_floor - 是否跳过楼层 + * @property {boolean} skipped_floor - 跳过楼层 * @return FullData */ interface FullData { @@ -60,6 +62,8 @@ declare namespace TGApp.Game.Abyss { floors: Floor[]; total_star: number; is_unlock: boolean; + is_just_skipped_floor: boolean; + skipped_floor: string; } /** diff --git a/src/types/Sqlite/Abyss.d.ts b/src/types/Sqlite/Abyss.d.ts index 0e6ca26f..614384dd 100644 --- a/src/types/Sqlite/Abyss.d.ts +++ b/src/types/Sqlite/Abyss.d.ts @@ -1,19 +1,19 @@ /** * @file types/Sqlite/Abyss.d.ts * @description 数据库深境螺旋相关类型定义文件 - * @since Beta v0.3.9 + * @since Beta v0.6.1 */ /** * @description 数据库深渊类型命名 - * @since Beta v0.3.9 + * @since Beta v0.6.1 * @namespace TGApp.Sqlite.Abyss * @memberof TGApp.Sqlite */ declare namespace TGApp.Sqlite.Abyss { /** * @description 数据库-深境螺旋表 - * @since Alpha v0.2.0 + * @since Beta v0.6.1 * @interface SingleTable * @property {string} uid - 用户 UID * @property {number} id - 深境螺旋 ID @@ -32,6 +32,7 @@ declare namespace TGApp.Sqlite.Abyss { * @property {Character[]} normalSkillRank - 元素战技释放数 * @property {Character[]} energySkillRank - 元素爆发次数 * @property {Floor[]} floors - 深境螺旋各层数据 + * @property {string} skippedFloor - 跳过楼层 * @property {string} updated - 更新时间 * @return SingleTable */ @@ -52,6 +53,7 @@ declare namespace TGApp.Sqlite.Abyss { normalSkillRank: string; // Character[] energySkillRank: string; // Character[] floors: string; // Floor[] + skippedFloor: string; updated: string; }