From f07337f1a5030d1bd39dadb386dbc38a28c80f24 Mon Sep 17 00:00:00 2001 From: aynakeya Date: Fri, 11 Jul 2025 21:17:22 +0800 Subject: [PATCH 1/2] fix setPages --- packages/amis-core/src/store/app.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/amis-core/src/store/app.ts b/packages/amis-core/src/store/app.ts index 5603f23061b..be65f0e3bbc 100644 --- a/packages/amis-core/src/store/app.ts +++ b/packages/amis-core/src/store/app.ts @@ -86,13 +86,7 @@ export const AppStore = ServiceStore.named('AppStore') let path = item.link || item.url; if (item.schema || item.schemaApi) { - path = - item.url || - `/${paths - .map(item => item.index) - .concat(index) - .map(index => `page-${index + 1}`) - .join('/')}`; + path = item.url || `page-${index + 1}`; if (path && path[0] !== '/') { let parentPath = '/'; From 33d2e80a508e92642e8a202cd09e073d0b7e879e Mon Sep 17 00:00:00 2001 From: aynakeya Date: Sat, 19 Jul 2025 02:22:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dindex=E5=86=B2=E7=AA=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/store/app.ts | 41 +++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/packages/amis-core/src/store/app.ts b/packages/amis-core/src/store/app.ts index be65f0e3bbc..cbeaf470807 100644 --- a/packages/amis-core/src/store/app.ts +++ b/packages/amis-core/src/store/app.ts @@ -82,27 +82,46 @@ export const AppStore = ServiceStore.named('AppStore') return; } - pages = mapTree(pages, (item, index, level, paths) => { + pages = mapTree(pages, (item, index, level, paths, indexes) => { let path = item.link || item.url; if (item.schema || item.schemaApi) { - path = item.url || `page-${index + 1}`; + // get current path either url exist or generated url page-index + let currentPath = item.url || `page-${index + 1}`; - if (path && path[0] !== '/') { - let parentPath = '/'; - let index = paths.length; - while (index > 0) { - const item = paths[index - 1]; + // if start with '/', absolute path, return directly + if (currentPath.startsWith('/')) { + path = item.url; + } else { + let closestIndex = paths.length - 1; + let fullPaths: string[] = [currentPath]; + while (closestIndex >= 0) { + const item = paths[closestIndex]; + // if parent path exists if (item?.path) { - parentPath = item.path + '/'; - break; + fullPaths = fullPaths.concat(item.path); + // if its a scheme, the path might not be generated, so keep moving upwards + if (item.schema || item.schemaApi) { + break; + } + } else { + fullPaths = fullPaths.concat( + `page-${indexes[closestIndex] + 1}` + ); } - index--; + closestIndex--; } - path = parentPath + path; + path = fullPaths.reverse().join('/'); + // maybe add /??, + // if (path && path[0] !== '/') { + // path = `/${path}`; + // } } + } else { + // the above code would be lot cleaner if we set path for no schema node here. + // but there might be other issue. keep as is. } return {