-
Notifications
You must be signed in to change notification settings - Fork 11
fix(): support route children #4816
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1296,7 +1296,7 @@ function getEmptyRenderOutput(): RenderOutput { | |
| } | ||
|
|
||
| export function childrenToSlots( | ||
| children: BrickConf[] | undefined, | ||
| children: (BrickConf | RouteConf)[] | undefined, | ||
| originalSlots: SlotsConf | undefined | ||
| ) { | ||
| let newSlots = originalSlots; | ||
|
|
@@ -1317,13 +1317,21 @@ export function childrenToSlots( | |
| newSlots = {}; | ||
| for (const { slot: sl, ...child } of children) { | ||
| const slot = sl ?? ""; | ||
| if (!hasOwnProperty(newSlots, slot)) { | ||
| const type = isRouteConf(child) ? "routes" : "bricks"; | ||
| if (hasOwnProperty(newSlots, slot)) { | ||
| const slotConf = newSlots[slot]; | ||
| if (slotConf.type !== type) { | ||
| throw new Error(`Slot "${slot}" conflict between bricks and routes.`); | ||
| } | ||
| (slotConf as SlotConfOfBricks)[type as "bricks"].push( | ||
| child as BrickConf | ||
| ); | ||
weareoutman marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+1326
to
+1328
|
||
| } else { | ||
| newSlots[slot] = { | ||
| type: "bricks", | ||
| bricks: [], | ||
| type: type as "bricks", | ||
| [type as "bricks"]: [child as BrickConf], | ||
weareoutman marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
1330
to
+1332
|
||
| }; | ||
| } | ||
| (newSlots[slot] as SlotConfOfBricks).bricks.push(child); | ||
| } | ||
| } | ||
| return newSlots; | ||
|
|
@@ -1357,3 +1365,7 @@ function isRouteParamsEqual( | |
| const d = omitBy(b, omitNumericKeys); | ||
| return isEqual(c, d); | ||
| } | ||
|
|
||
| function isRouteConf(child: BrickConf | RouteConf): child is RouteConf { | ||
| return !!(child as RouteConf).path && !(child as BrickConf).brick; | ||
weareoutman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -503,6 +503,22 @@ function lowLevelEvaluate( | |||
| case "SYS": | ||||
| globalVariables[variableName] = getReadOnlyProxy(sys ?? {}); | ||||
| break; | ||||
| case "CONSTANTS": | ||||
| // globalVariables[variableName] = getReadOnlyProxy(app?.constants ?? {}); | ||||
|
||||
| // globalVariables[variableName] = getReadOnlyProxy(app?.constants ?? {}); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -26,7 +26,7 @@ function replaceInBrick(brick: BrickConf) { | |||||
| const useChildrenMap = new Map<string, BrickConf[]>(); | ||||||
| if (Array.isArray(brick.children) && !slots) { | ||||||
| const removeBricks: BrickConf[] = []; | ||||||
| for (const child of brick.children) { | ||||||
| for (const child of brick.children as BrickConf[]) { | ||||||
weareoutman marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| for (const child of brick.children as BrickConf[]) { | |
| for (const child of brick.children.filter((c): c is BrickConf => !!(c as BrickConf).brick)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
建议明确文件优先级并验证边界情况
代码现在支持从两个位置查找 storyboard.yaml,
mock-micro-apps优先于apps。需要关注以下几点:mock-micro-apps优先,以及在什么场景下会同时存在两个文件建议:
可选的改进示例:
export async function getSingleStoryboard(rootDir, appId) { const sizeCheckApp = getSizeCheckApp(); if (appId === sizeCheckApp.id) { return { app: sizeCheckApp }; } + // Search for storyboard.yaml in multiple locations. + // Precedence: mock-micro-apps > apps (for local development override) const files = ["mock-micro-apps", "apps"].map((folder) => path.join(rootDir, folder, appId, "storyboard.yaml") ); const filePath = tryFiles(files); if (!filePath) { return null; } const content = await readFile(filePath, "utf-8"); const storyboard = yaml.safeLoad(content); return storyboard; }🏁 Script executed:
Length of output: 1497
Now I'll search the codebase directly to verify the concerns:
Now let me search the codebase directly for the necessary information:Based on my verification:
The original review comment in Chinese raised valid concerns that are well-founded:
Since the original review comment correctly identified issues that need addressing (adding comments for clarity and documenting precedence), and the code indeed lacks this documentation, the suggestions should be implemented.
建议明确文件优先级并添加必要的注释文档
代码支持从两个位置查找 storyboard.yaml,
mock-micro-apps优先于apps。建议添加注释说明这一优先级设定的原因和适用场景。tryFiles调用上方添加注释,解释为什么mock-micro-apps优先(用于本地开发覆盖)export async function getSingleStoryboard(rootDir, appId) { const sizeCheckApp = getSizeCheckApp(); if (appId === sizeCheckApp.id) { return { app: sizeCheckApp }; } + // Search for storyboard.yaml in multiple locations. + // Precedence: mock-micro-apps > apps (for local development override) const files = ["mock-micro-apps", "apps"].map((folder) => path.join(rootDir, folder, appId, "storyboard.yaml") ); const filePath = tryFiles(files); if (!filePath) { return null; }📝 Committable suggestion
🤖 Prompt for AI Agents