Save tree state

This commit is contained in:
2026-07-18 18:33:06 +02:00
parent 795512b112
commit 55a6bf7636
2 changed files with 12 additions and 4 deletions

View File

@@ -1,14 +1,14 @@
<script setup>
import { ref } from 'vue'
import { useTreeState } from '~/composables/useTreeState'
defineProps({ nodes: Array, depth: { type: Number, default: 0 } })
const router = useRouter()
const collapsed = ref({})
const { collapsed } = useTreeState() // ← shared state, not local ref
function getTitle(node) {
if (node.title == "index") return "Index"
return node.title || node._path?.split('/').pop() || 'Home';
if (node.title === 'index') return 'Index'
return node.title || node._path?.split('/').pop() || 'Home'
}
function navigate(path) {

View File

@@ -0,0 +1,8 @@
const collapsed = ref<Record<string, boolean>>({})
export function useTreeState() {
function resetTree() {
collapsed.value = {}
}
return { collapsed, resetTree }
}