File tree Expand file tree Collapse file tree
packages/design-core/src/preview/src/preview Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ interface IPage {
1414 id : number
1515 name : string
1616 parentId : number | string
17+ isPage : boolean
1718 page_content : {
1819 [ key : string ] : any
1920 componentName : string
@@ -76,7 +77,12 @@ const getPageOrBlockByApi = async (): Promise<{ currentPage: IPage | null; ances
7677 const history = searchParams . get ( 'history' )
7778
7879 if ( pageId ) {
79- let ancestors = ( await getPageRecursively ( pageId ) ) . reverse ( )
80+ let ancestors = ( await getPageRecursively ( pageId ) ) . reverse ( ) . filter ( ( item ) => item . isPage )
81+ // 避免祖先页面第一个为文件夹,导致没有 ROOT_ID,导致设置 Main.vue 失败
82+ if ( ancestors . length && ancestors [ 0 ] ?. parentId !== ROOT_ID ) {
83+ ancestors [ 0 ] . parentId = ROOT_ID
84+ }
85+
8086 let currentPage = await getPageById ( pageId )
8187 if ( history ) {
8288 const historyList : IPage [ ] = await fetchPageHistory ( pageId )
@@ -199,6 +205,13 @@ const getPageAncestryFiles = (
199205 }
200206 }
201207
208+ const hasMainPage = familyPages . some ( ( item ) => item . panelName === 'Main.vue' && item . index )
209+
210+ if ( ! hasMainPage && familyPages . length ) {
211+ familyPages [ 0 ] . index = true
212+ familyPages [ 0 ] . panelName = 'Main.vue'
213+ }
214+
202215 return familyPages
203216}
204217
You can’t perform that action at this time.
0 commit comments