Skip to content

Commit

Permalink
fix some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gene9831 committed Jan 6, 2025
1 parent 4a4e25e commit ff9937d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
6 changes: 3 additions & 3 deletions packages/canvas/DesignCanvas/src/DesignCanvas.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<component :is="CanvasLayout">
<template #header>
<component v-if="!isBlock" :is="CanvasRouteBar"></component>
<component v-if="!isBlock()" :is="CanvasRouteBar"></component>
</template>
<template #container>
<component
Expand All @@ -21,7 +21,7 @@
</template>

<script>
import { computed, ref, watch, onUnmounted, onMounted } from 'vue'
import { ref, watch, onUnmounted, onMounted } from 'vue'
import {
useProperties,
useCanvas,
Expand Down Expand Up @@ -77,7 +77,7 @@ export default {
pageState.properties = null
}
const isBlock = computed(() => useCanvas().isBlock())
const isBlock = useCanvas().isBlock
watch(
[() => useCanvas().isSaved(), () => useLayout().layoutState.pageStatus, () => useCanvas().getPageSchema()],
Expand Down
1 change: 1 addition & 0 deletions packages/canvas/route-bar/src/CanvasRouteBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ watch(
pageId,
async (value) => {
if (!value) {
routes.value = []
return
}
const ancestors = await getAncestors(value, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script setup lang="jsx">
import { usePage } from '@opentiny/tiny-engine-meta-register'
import { Select as TinySelect } from '@opentiny/vue'
import { computed, defineEmits, defineProps, reactive, watchEffect } from 'vue'
import { computed, defineEmits, defineProps, reactive, watch } from 'vue'
const props = defineProps({
modelValue: {
Expand All @@ -30,9 +30,12 @@ const state = reactive({
selected: props.modelValue?.name ?? ''
})
watchEffect(() => {
state.selected = props.modelValue?.name ?? ''
})
watch(
() => props.modelValue?.name,
(value) => {
state.selected = value ?? ''
}
)
const { pageSettingState, getPageList, STATIC_PAGE_GROUP_ID } = usePage()
Expand All @@ -50,7 +53,7 @@ const pageToTreeData = (page) => {
}
return {
id,
id: String(id),
name,
isPage,
disabled: !isPage,
Expand Down
19 changes: 10 additions & 9 deletions packages/plugins/page/src/composable/usePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,15 @@ const getPageList = async (appId) => {

/**
* @param {string | number} id
* @param {(string | number)[]} ancestors
* @returns {(string | number)[]}
* @returns {any[]}
*/
const getAncestorsRecursively = (id) => {
const pageNode = pageSettingState.treeDataMapping[id]

if (pageNode.id === pageSettingState.ROOT_ID) {
if (id === pageSettingState.ROOT_ID) {
return []
}

const pageNode = pageSettingState.treeDataMapping[id]

return [pageNode].concat(getAncestorsRecursively(pageNode.parentId))
}

Expand All @@ -245,14 +244,16 @@ const getAncestors = async (id, withFolders) => {
await getPageList()
}

if (!pageSettingState.treeDataMapping[id]) {
return null
}

const ancestorsWithSelf = getAncestorsRecursively(id)
const ancestors = ancestorsWithSelf.slice(1).reverse()

if (withFolders) {
return ancestors.map((item) => item.id)
}
const predicate = withFolders ? () => true : (item) => item.isPage

return ancestors.filter((item) => item.isPage).map((item) => item.id)
return ancestors.filter(predicate).map((item) => item.id)
}

const clearCurrentState = () => {
Expand Down

0 comments on commit ff9937d

Please sign in to comment.