File tree Expand file tree Collapse file tree
packages/plugins/materials/src/composable Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -133,18 +133,36 @@ const initPageOrBlock = async () => {
133133 return
134134 }
135135
136- // url 没有 pageid 或 blockid,到当前用户锁定的页面顺位第一位,如果没有则到页面首页 或者 公共页面第一顺位
137- const pageInfo = appSchemaState . pageTree . find (
138- ( page ) => page . componentName === COMPONENT_NAME . Page && globalState . userInfo . id === page ?. meta ?. occupier ?. id
139- ) ||
140- appSchemaState . pageTree . find ( ( page ) => page ?. meta ?. isHome ) ||
141- appSchemaState . pageTree . find (
136+ // url 没有 pageid 或 blockid,页面打开顺序:可访问主页 -> 可访问的第一个页面 -> 不可访问首页 -> 不可访问全页面顺位第一页
137+ const getPageInfo = ( ) => {
138+ // 页面是否被他人锁定
139+ const isPageOccupierd = ( page ) => {
140+ return page . meta ?. occupier && page . meta ?. occupier . id === globalState . userInfo . id
141+ }
142+ // 首页
143+ const homePage = appSchemaState . pageTree . find ( ( page ) => page ?. meta ?. isHome )
144+ // 顺位首个页面
145+ const firstPage = appSchemaState . pageTree . find (
142146 ( page ) => page . componentName === COMPONENT_NAME . Page && page ?. meta ?. group !== 'publicPages'
143- ) || {
147+ )
148+ // 顺位首个可访问页面
149+ const firstUnoccupiedPage = appSchemaState . pageTree . find (
150+ ( page ) =>
151+ page . componentName === COMPONENT_NAME . Page && page ?. meta ?. group !== 'publicPages' && ! isPageOccupierd ( page )
152+ )
153+ // 空页面
154+ const emptyPage = {
144155 page_content : {
145156 componentName : COMPONENT_NAME . Page
146157 }
147158 }
159+ // 可访问主页
160+ if ( homePage && ! isPageOccupierd ( homePage ) ) {
161+ return homePage
162+ }
163+ return firstUnoccupiedPage || homePage || firstPage || emptyPage
164+ }
165+ const pageInfo = getPageInfo ( )
148166
149167 if ( pageInfo . meta ?. id ) {
150168 // 这里重新请求一遍页面详情数据,是因为 appSchemaState 的页面信息存在字段转换,比如 route 被转换成了 router 字段,导致调用页面保存接口的时候报错
You can’t perform that action at this time.
0 commit comments