From 1944f2c55be9bf7cc801ea117a1e56fa8a328a15 Mon Sep 17 00:00:00 2001 From: BTMuli Date: Wed, 25 Mar 2026 17:06:46 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20=E4=BC=98=E5=8C=96=20Aj?= =?UTF-8?q?v=20=E5=AF=BC=E5=85=A5=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/UIAF.ts | 15 ++++++--------- src/utils/UIGF.ts | 13 ++++++------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/utils/UIAF.ts b/src/utils/UIAF.ts index 5a86bb49..b59d2dc0 100644 --- a/src/utils/UIAF.ts +++ b/src/utils/UIAF.ts @@ -1,13 +1,12 @@ /** * UIAF工具类 - * @since Beta v0.9.2 + * @since Beta v0.9.9 */ import showSnackbar from "@comp/func/snackbar.js"; import { app } from "@tauri-apps/api"; import { readTextFile } from "@tauri-apps/plugin-fs"; -import Ajv from "ajv"; -import type { ErrorObject } from "ajv/lib/types/index.js"; +import Ajv, { type ErrorObject } from "ajv"; import TGLogger from "./TGLogger.js"; @@ -29,14 +28,13 @@ export async function getUiafHeader(): Promise { /** * 检测是否存在 UIAF 数据,采用 ajv 验证 schema - * @since Beta v0.9.1 + * @since Beta v0.9.9 * @param path - UIAF 数据路径 * @returns 是否存在 UIAF 数据 */ export async function verifyUiafData(path: string): Promise { const fileData: string = await readTextFile(path); - // @ts-expect-error-next-line - const ajv = new Ajv(); + const ajv = new Ajv.Ajv(); const validate = ajv.compile(UiafSchema); try { const fileJson = JSON.parse(fileData); @@ -59,13 +57,12 @@ export async function verifyUiafData(path: string): Promise { /** * 验证UIAF数据-剪贴板 - * @since Beta v0.9.2 + * @since Beta v0.9.9 * @param data - 剪贴板文本 * @returns 是否验证通过 */ export async function verifyUiafDataClipboard(data: string): Promise { - // @ts-expect-error-next-line - const ajv = new Ajv(); + const ajv = new Ajv.Ajv(); const validate = ajv.compile(UiafSchema); try { const fileJson = JSON.parse(data); diff --git a/src/utils/UIGF.ts b/src/utils/UIGF.ts index cf965a6e..b176a991 100644 --- a/src/utils/UIGF.ts +++ b/src/utils/UIGF.ts @@ -1,6 +1,6 @@ /** * UIGF工具类 - * @since Beta v0.9.5 + * @since Beta v0.9.9 */ import showLoading from "@comp/func/loading.js"; @@ -9,8 +9,7 @@ import TSUserGacha from "@Sqlm/userGacha.js"; import TSUserGachaB from "@Sqlm/userGachaB.js"; import { app, path } from "@tauri-apps/api"; import { exists, mkdir, readDir, readTextFile, writeTextFile } from "@tauri-apps/plugin-fs"; -import { Ajv } from "ajv"; -import type { ErrorObject } from "ajv/lib/types/index.js"; +import Ajv, { type ErrorObject } from "ajv"; import TGLogger from "./TGLogger.js"; import { timestampToDate } from "./toolFunc.js"; @@ -181,12 +180,12 @@ export async function verifyUigfData(path: string, isVersion4: boolean = false): /** * 验证 UIGF 数据 - * @since Beta v0.5.1 + * @since Beta v0.9.9 * @param data - UIGF 数据 * @returns 是否验证通过 */ function validateUigfData(data: object): boolean { - const ajv = new Ajv(); + const ajv = new Ajv.Ajv(); const validate = ajv.compile(UigfSchema); if (!validate(data)) { if (!validate.errors || validate.errors.length === 0) return false; @@ -204,12 +203,12 @@ function validateUigfData(data: object): boolean { /** * 验证 UIGF v4.2 数据 - * @since Beta v0.5.0 + * @since Beta v0.9.9 * @param data - UIGF 数据 * @returns 是否验证通过 */ function validateUigf4Data(data: object): boolean { - const ajv = new Ajv(); + const ajv = new Ajv.Ajv(); const validate4 = ajv.compile(Uigf4Schema); if (validate4(data)) return true; if (!validate4.errors || validate4.errors.length === 0) return false;