This commit is contained in:
zlwu committed 2026-07-05 10:07:24 +08:00
1 parent 33c038b8d9
commit 54b27a3f0e
253 files changed
+30060 -14298

No files matched your search

@@ -0,0 +1,35 @@
import type { Ref } from 'vue'
export function syncViewRowFromFlatList<T extends { id: string | number }>(
viewRow: Ref<T | null>,
list: T[]
) {
const current = viewRow.value
if (!current?.id) return
const updated = list.find(row => row.id === current.id)
if (updated) viewRow.value = updated
}
export function findNodeInTreeById<T extends { id: string | number; children?: T[] }>(
nodes: T[],
id: string | number
): T | undefined {
for (const node of nodes) {
if (node.id === id) return node
if (node.children?.length) {
const found = findNodeInTreeById(node.children, id)
if (found) return found
}
}
return undefined
}
export function syncViewRowFromTree<T extends { id: string | number; children?: T[] }>(
viewRow: Ref<T | null>,
roots: T[]
) {
const current = viewRow.value
if (!current?.id) return
const updated = findNodeInTreeById(roots, current.id)
if (updated) viewRow.value = updated
}