From 5c9dae804e85ce2b25801eaa9df29b2bed9b5975 Mon Sep 17 00:00:00 2001 From: QCQCQC <1220204124@zust.edu.cn> Date: Fri, 17 Oct 2025 14:10:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=B9PropertyAccessExpression?= =?UTF-8?q?=E5=81=9A=E4=BA=86=E4=B8=80=E5=AE=9A=E7=9A=84=E5=AE=B9=E9=94=99?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/entities.ts | 2 +- src/utils/ts-utils.ts | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/utils/entities.ts b/src/utils/entities.ts index f113bf8..d4b77ab 100644 --- a/src/utils/entities.ts +++ b/src/utils/entities.ts @@ -240,7 +240,7 @@ export const analyzeOakAppDomain = async ( entityDictCache[key] = entityDict[key]; }); - console.log('从缓存加载成功'); + console.log('从缓存加载成功,文件路径:', cacheFile); return; } catch (e) { console.error('尝试从缓存读取失败', e); diff --git a/src/utils/ts-utils.ts b/src/utils/ts-utils.ts index 8e84c7b..62d0c1e 100644 --- a/src/utils/ts-utils.ts +++ b/src/utils/ts-utils.ts @@ -387,9 +387,9 @@ export const getWebComponentPropsData = ( if (!ts.isLiteralTypeNode(args![1])) { return undefined; } - + const nameRawTextNode = args![1].literal; - + const nameRawText = args![1].literal.getText(); entityName = { value: nameRawText.substring(1, nameRawText.length - 1), @@ -862,7 +862,20 @@ function evaluateExpression(expr: ts.Expression): any { return null; } else if (ts.isIdentifier(expr)) { return expr.text; // 返回标识符名(例如引用类型或枚举名) + } else if (ts.isPropertyAccessExpression(expr)) { + // const left = evaluateExpression(expr.expression); + // const right = expr.name.text; + + // if (typeof left === "string") { + // return `${left}.${right}`; + // } else if (left && typeof left === "object" && right in left) { + // return left[right]; + // } else { + // return `${left}.${right}`; + // } + return `unresolved`; } else { + console.log("发现不支持的表达式类型:", ts.SyntaxKind[expr.kind], "在文件", expr.getSourceFile().fileName, "位置", expr.getStart(), "-", expr.getEnd()); throw new Error(`Unsupported expression kind: ${ts.SyntaxKind[expr.kind]}`); } } \ No newline at end of file