From bc44d8dd600004e51100c79923101906b8e65675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 13 Dec 2024 15:58:59 +0800 Subject: [PATCH] =?UTF-8?q?unitAttrs.lua=20=E6=94=B9=E4=B8=BA=E7=9B=91?= =?UTF-8?q?=E6=8E=A7=E9=A1=B9=E7=9B=AE=E7=9B=AE=E5=BD=95=E4=B8=8B=E7=9A=84?= =?UTF-8?q?=20json=20=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/customDefine/unitAttrs.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/customDefine/unitAttrs.ts b/src/customDefine/unitAttrs.ts index e308326..c123a74 100644 --- a/src/customDefine/unitAttrs.ts +++ b/src/customDefine/unitAttrs.ts @@ -1,7 +1,8 @@ import { RelativePattern } from "vscode"; import { env } from "../env"; -import * as tools from '../tools'; import { BaseDefine } from "./baseDefine"; +import * as vscode from 'vscode'; +import * as y3 from 'y3-helper'; const filePath = 'attr.json'; @@ -22,23 +23,20 @@ export class UnitAttrs extends BaseDefine { private _attrsCache?: Attr[]; get watchPattern() { - if (!env.mapUri) { + if (!env.projectUri) { return; } - return new RelativePattern(env.mapUri, filePath); + return new RelativePattern(env.projectUri, filePath); } private async loadAttrs() { let attrs: Attr[] = []; try { - if (!env.mapUri) { + if (!env.projectUri) { return attrs; } - let jsonFile = await tools.fs.readFile(env.mapUri, filePath); - if (!jsonFile) { - return attrs; - } - let json = JSON.parse(jsonFile.string); + let context = await vscode.workspace.fs.readFile(y3.uri(env.projectUri, filePath)); + let json = JSON.parse(context.toString()); if (typeof json !== 'object') { return attrs; } @@ -65,6 +63,8 @@ export class UnitAttrs extends BaseDefine { } } } + } catch (e) { + y3.log.warn(`${filePath} 解析失败: ${e}`); } finally { return attrs; }