From 7fc6d6b11a1658425a404292209aed581c065070 Mon Sep 17 00:00:00 2001 From: BTMuli Date: Tue, 21 Apr 2026 10:41:54 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E6=AD=A3=E6=B7=B1?= =?UTF-8?q?=E6=B8=8A=E9=AA=8C=E8=AF=81Schema&=E8=BD=AC=E6=8D=A2=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/Hutao/schema/abyss.json | 90 +++++++++++++++++----- src/plugins/Hutao/utils/RawValidator.ts | 7 +- src/plugins/Sqlite/utils/transAbyssData.ts | 21 +++-- src/types/Game/Abyss.d.ts | 12 +-- 4 files changed, 94 insertions(+), 36 deletions(-) diff --git a/src/plugins/Hutao/schema/abyss.json b/src/plugins/Hutao/schema/abyss.json index 84e70a57..574cb9fb 100644 --- a/src/plugins/Hutao/schema/abyss.json +++ b/src/plugins/Hutao/schema/abyss.json @@ -19,12 +19,12 @@ "title": "周期 ID" }, "start_time": { - "type": "string", + "type": ["string", "integer"], "title": "开始时间戳", "description": "秒级时间戳" }, "end_time": { - "type": "string", + "type": ["string", "integer"], "title": "结束时间戳", "description": "秒级时间戳" }, @@ -139,25 +139,63 @@ "items": { "type": "object", "properties": { - "index": { "type": "number" }, - "icon": { "type": "string" }, - "is_unlock": { "type": "boolean" }, - "settle_time": { "type": "string" }, - "star": { "type": "number" }, - "max_star": { "type": "number" }, + "index": { + "type": "number" + }, + "icon": { + "type": "string" + }, + "is_unlock": { + "type": "boolean" + }, + "settle_time": { + "type": ["string", "integer"] + }, + "star": { + "type": "number" + }, + "max_star": { + "type": "number" + }, "ley_line_disorder": { "type": "array", - "items": { "type": "string" } + "items": { + "type": "string" + } + }, + "ley_line_disorder_upper": { + "type": "array", + "items": { + "type": "string" + } + }, + "ley_line_disorder_lower": { + "type": "array", + "items": { + "type": "string" + } }, "settle_date_time": { "type": ["object", "null"], "properties": { - "year": { "type": "number" }, - "month": { "type": "number" }, - "day": { "type": "number" }, - "hour": { "type": "number" }, - "minute": { "type": "number" }, - "second": { "type": "number" } + "year": { + "type": "number" + }, + "month": { + "type": "number" + }, + "day": { + "type": "number" + }, + "hour": { + "type": "number" + }, + "minute": { + "type": "number" + }, + "second": { + "type": "number" + } } }, "levels": { @@ -173,8 +211,12 @@ "items": { "type": "object", "properties": { - "index": { "type": "number" }, - "timestamp": { "type": "string" }, + "index": { + "type": "number" + }, + "timestamp": { + "type": ["string", "integer"] + }, "settle_date_time": { "type": "object", "properties": { @@ -200,7 +242,7 @@ } } }, - "required": ["index", "timestamp", "avatars", "settle_date_time"] + "required": ["index", "timestamp", "avatars"] } }, "top_half_floor_monster": { @@ -220,9 +262,15 @@ "items": { "type": "object", "properties": { - "name": { "type": "string" }, - "icon": { "type": "string" }, - "level": { "type": "number" } + "name": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "level": { + "type": "number" + } }, "required": ["name", "level"] } diff --git a/src/plugins/Hutao/utils/RawValidator.ts b/src/plugins/Hutao/utils/RawValidator.ts index adeed83f..0e35d741 100644 --- a/src/plugins/Hutao/utils/RawValidator.ts +++ b/src/plugins/Hutao/utils/RawValidator.ts @@ -18,14 +18,15 @@ const CombatValidate = ajv.compile(CombatJson); /** * 验证深渊单条数据 - * @since Beta v0.9.9 + * @since Beta v0.10.1 * @param data - 待验证的数据 * @returns 验证是否通过(类型收束) */ function validateAbyss(data: unknown): data is TGApp.Plugins.Hutao.Abyss.ImportData { if (!AbyssValidate(data)) { - const error = AbyssValidate.errors?.[0]; - if (error) { + if (AbyssValidate.errors) { + const error = AbyssValidate.errors[0]; + console.error(AbyssValidate.errors); showSnackbar.error( `深渊数据验证失败:${error.instancePath || error.schemaPath} ${error.message}`, ); diff --git a/src/plugins/Sqlite/utils/transAbyssData.ts b/src/plugins/Sqlite/utils/transAbyssData.ts index ef4fa220..e8494c97 100644 --- a/src/plugins/Sqlite/utils/transAbyssData.ts +++ b/src/plugins/Sqlite/utils/transAbyssData.ts @@ -44,15 +44,17 @@ export function transFloorData(data: Array): string { * @param data - 接口获取楼层数据 * @returns 增益字符串 */ -function transFloorBuff(data: TGApp.Game.Abyss.Floor): Array { +function transFloorBuff(data: TGApp.Game.Abyss.Floor): Array | undefined { const res: Array = []; - if (data.ley_line_disorder_upper.length > 0) { + if (data.ley_line_disorder_upper && data.ley_line_disorder_upper.length > 0) { res.push(`【上半】${data.ley_line_disorder_upper.join(";")}`); } - if (data.ley_line_disorder_lower.length > 0) { + if (data.ley_line_disorder_lower && data.ley_line_disorder_lower.length > 0) { res.push(`【下半】${data.ley_line_disorder_lower.join(";")}`); } - if (data.ley_line_disorder.length > 0) res.push(...data.ley_line_disorder); + if (data.ley_line_disorder && data.ley_line_disorder.length > 0) { + res.push(...data.ley_line_disorder); + } return res; } @@ -69,8 +71,15 @@ function transLevelData(data: TGApp.Game.Abyss.Level): TGApp.Sqlite.Abyss.Level maxStar: data.max_star, }; for (const battle of data.battles) { - if (battle.index === 1) res.upBattle = transBattleData(battle, data.top_half_floor_monster); - else res.downBattle = transBattleData(battle, data.bottom_half_floor_monster); + if (battle.index === 1) { + if (data.top_half_floor_monster) { + res.upBattle = transBattleData(battle, data.top_half_floor_monster); + } + } else { + if (data.bottom_half_floor_monster) { + res.downBattle = transBattleData(battle, data.bottom_half_floor_monster); + } + } } return res; } diff --git a/src/types/Game/Abyss.d.ts b/src/types/Game/Abyss.d.ts index 8c22ca7b..f2a9c8a5 100644 --- a/src/types/Game/Abyss.d.ts +++ b/src/types/Game/Abyss.d.ts @@ -95,16 +95,16 @@ declare namespace TGApp.Game.Abyss { */ settle_date_time: TGApp.Game.Base.DateTime | null; /** 地脉异常 */ - ley_line_disorder: Array; + ley_line_disorder?: Array; /** 地脉异常:上半 */ - ley_line_disorder_upper: Array; + ley_line_disorder_upper?: Array; /** 地脉异常:下半 */ - ley_line_disorder_lower: Array; + ley_line_disorder_lower?: Array; }; /** * 关卡数据 - * @since Beta v0.9.0 + * @since Beta v0.10.1 */ type Level = { /** 关卡索引 */ @@ -116,9 +116,9 @@ declare namespace TGApp.Game.Abyss { /** 战斗数据 */ battles: Array; /** 上半场怪物数据 */ - top_half_floor_monster: Array; + top_half_floor_monster?: Array; /** 下半场怪物数据 */ - bottom_half_floor_monster: Array; + bottom_half_floor_monster?: Array; }; /**