Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: parse module with module alias #147

Merged
merged 1 commit into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/core/src/models/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions packages/helpers/src/types/prototype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,19 @@ export interface ITangoConfigJson {
* 外部资源,例如 js, css 文件等
*/
externalResources?: Record<string, any>;
/**
* 沙箱配置
*/
sandbox?: {
/**
* 在沙箱中执行的脚本
*/
evaluateJavaScript?: string;
/**
* 模块的别名
*/
alias?: Record<string, string>;
};
/**
* 设计器配置
*/
Expand Down
Loading