Skip to content

Commit 09984b3

Browse files
committed
fix(bug-2.8): 修改无pageid时访问页面的顺序
1 parent 36ce6c8 commit 09984b3

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

packages/plugins/materials/src/composable/useResource.ts

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff 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 字段,导致调用页面保存接口的时候报错

0 commit comments

Comments
 (0)