mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
🐛 修复成就验证异常
This commit is contained in:
@@ -348,14 +348,8 @@ async function importJson(): Promise<void> {
|
||||
await TGLogger.Info("[Achievements][importJson] 已取消文件选择");
|
||||
return;
|
||||
}
|
||||
if (!(await verifyUiafData(<string>selectedFile))) {
|
||||
showSnackbar({
|
||||
color: "error",
|
||||
text: "读取 UIAF 数据失败,请检查文件是否符合规范",
|
||||
});
|
||||
await TGLogger.Error("[Achievements][importJson] 读取 UIAF 数据失败,请检查文件是否符合规范");
|
||||
return;
|
||||
}
|
||||
const check = await verifyUiafData(<string>selectedFile);
|
||||
if (!check) return;
|
||||
const remoteRaw = await readUiafData(<string>selectedFile);
|
||||
await TGLogger.Info("[Achievements][importJson] 读取 UIAF 数据成功");
|
||||
await TGLogger.Info(`[Achievements][importJson] 导入来源:${remoteRaw.info.export_app}`);
|
||||
|
||||
@@ -54,7 +54,7 @@ export async function getUiafHeader(): Promise<TGApp.Plugins.UIAF.Export> {
|
||||
*/
|
||||
export async function verifyUiafData(path: string): Promise<boolean> {
|
||||
const fileData: string = await fs.readTextFile(path);
|
||||
const ajv = new Ajv();
|
||||
const ajv = new Ajv({ strict: false });
|
||||
const validate = ajv.compile(UiafSchema);
|
||||
try {
|
||||
const fileJson = JSON.parse(fileData);
|
||||
@@ -65,7 +65,7 @@ export async function verifyUiafData(path: string): Promise<boolean> {
|
||||
color: "error",
|
||||
});
|
||||
await TGLogger.Error(`UIAF 数据验证失败,文件路径:${path}`);
|
||||
await TGLogger.Error(`错误信息 ${validate.errors}`);
|
||||
await TGLogger.Error(`错误信息 ${validate.errors?.toString()}`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user