From 9bb58c1bdd55530e4ed0f7c7750c673a53e5c4be Mon Sep 17 00:00:00 2001 From: Wells Date: Thu, 9 May 2024 16:50:47 +0800 Subject: [PATCH] fix: parse module with module alias --- packages/core/src/models/workspace.ts | 13 +++++++++++-- packages/helpers/src/types/prototype.ts | 13 +++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/core/src/models/workspace.ts b/packages/core/src/models/workspace.ts index 4cca11c0..058bfbc0 100644 --- a/packages/core/src/models/workspace.ts +++ b/packages/core/src/models/workspace.ts @@ -1233,8 +1233,17 @@ export class Workspace extends EventTarget implements IWorkspace { let filename: string; this.routeModule?.routes.forEach((route) => { if (isPathnameMatchRoute(routePath, route.path) && route.importPath) { - const absolutePath = route.importPath.replace('.', '/src'); - filename = this.getRealViewFilePath(absolutePath); + if (route.importPath.startsWith('@/')) { + filename = route.importPath; + const alias = this.tangoConfigJson.getValue('sandbox.alias') || {}; + if (alias['@']) { + filename = filename.replace('@', alias['@']); + } + filename = this.getRealViewFilePath(filename); + } else { + const absolutePath = route.importPath.replace('.', '/src'); + filename = this.getRealViewFilePath(absolutePath); + } } }); return filename; diff --git a/packages/helpers/src/types/prototype.ts b/packages/helpers/src/types/prototype.ts index 05eae644..01245b60 100644 --- a/packages/helpers/src/types/prototype.ts +++ b/packages/helpers/src/types/prototype.ts @@ -300,6 +300,19 @@ export interface ITangoConfigJson { * 外部资源,例如 js, css 文件等 */ externalResources?: Record; + /** + * 沙箱配置 + */ + sandbox?: { + /** + * 在沙箱中执行的脚本 + */ + evaluateJavaScript?: string; + /** + * 模块的别名 + */ + alias?: Record; + }; /** * 设计器配置 */