Skip to content

Commit

Permalink
fix: Modified based on review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gene9831 committed Jan 2, 2025
1 parent 577ea7d commit 9561922
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 21 deletions.
19 changes: 13 additions & 6 deletions packages/canvas/container/src/components/CanvasMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ export default {
menus.value.unshift({
name: '路由跳转',
code: 'route',
show: () => getCurrent().schema?.componentName === 'RouterLink'
show: () => getCurrent()?.schema?.componentName === 'RouterLink',
check: () => {
const targetPageId = getCurrent().schema.props?.to?.name
return typeof targetPageId === 'number' || targetPageId
}
})
const filteredMenus = computed(() =>
Expand Down Expand Up @@ -222,14 +226,17 @@ export default {
}
},
route() {
const target = getCurrent().schema.props.to?.name
if (target) {
usePage().switchPageWithConfirm(target)
}
// check中验证过了 targetPageId 是有效值
const targetPageId = getCurrent().schema.props.to.name
usePage().switchPageWithConfirm(targetPageId)
}
}
const actionDisabled = (actionItem) => {
if (typeof actionItem.check === 'function' && !actionItem.check()) {
return true
}
const actions = ['del', 'copy', 'addParent']
return actions.includes(actionItem.code) && !getCurrent().schema?.id
}
Expand All @@ -242,7 +249,7 @@ export default {
boxVisibility.value = false
}
const doOperation = (item) => {
if ((item.check && !item.check?.()) || actionDisabled(item)) {
if (actionDisabled(item)) {
return
}
Expand Down
8 changes: 5 additions & 3 deletions packages/canvas/layout/src/CanvasLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import { useCanvas, useLayout } from '@opentiny/tiny-engine-meta-register'
const ROUTE_BAR_HEIGHT = 32
const { isBlock } = useCanvas()
const dimension = useLayout().getDimension()
const siteCanvasStyle = computed(() => {
const { scale } = useLayout().getDimension()
const isBlock = useCanvas().isBlock()
const routeBarHeight = isBlock ? 0 : ROUTE_BAR_HEIGHT
const { scale } = dimension
const routeBarHeight = isBlock() ? 0 : ROUTE_BAR_HEIGHT
return {
height: `calc((100% - var(--base-bottom-panel-height, 30px) - ${36 + routeBarHeight}px) / ${scale})`,
transform: `scale(${scale})`,
Expand Down
33 changes: 21 additions & 12 deletions packages/plugins/page/src/composable/usePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
useLayout,
useBreadcrumb,
useModal,
useNotify,
getMetaApi,
META_SERVICE
} from '@opentiny/tiny-engine-meta-register'
Expand Down Expand Up @@ -288,17 +289,25 @@ const switchPage = (pageId) => {
return
}

return http.fetchPageDetail(pageId).then((data) => {
if (data.isPage) {
// 应该改成让 Breadcrumb 插件去监听变化
useBreadcrumb().setBreadcrumbPage([data.name])
}
return http
.fetchPageDetail(pageId)
.then((data) => {
if (data.isPage) {
// 应该改成让 Breadcrumb 插件去监听变化
useBreadcrumb().setBreadcrumbPage([data.name])
}

updateUrlPageId(pageId)
useLayout().closePlugin()
useLayout().layoutState.pageStatus = getCanvasStatus(data.occupier)
useCanvas().initData(data['page_content'], data)
})
updateUrlPageId(pageId)
useLayout().closePlugin()
useLayout().layoutState.pageStatus = getCanvasStatus(data.occupier)
useCanvas().initData(data['page_content'], data)
})
.catch(() => {
useNotify({
type: 'error',
message: '切换页面失败,目标页面不存在'
})
})
}

const switchPageWithConfirm = (pageId) => {
Expand All @@ -308,6 +317,7 @@ const switchPageWithConfirm = (pageId) => {
return new Promise((resolve) => {
if (isSaved()) {
resolve(true)
return
}

useModal().confirm({
Expand All @@ -332,8 +342,7 @@ const switchPageWithConfirm = (pageId) => {

const getFamily = async (id) => {
if (pageSettingState.pages.length === 0) {
const appId = getMetaApi(META_SERVICE.GlobalService).getBaseInfo().id
await getPageList(appId)
await getPageList()
}

return getAncestorsRecursively(id)
Expand Down

0 comments on commit 9561922

Please sign in to comment.