mirror of https://github.com/veypi/OneAuth.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
3 weeks ago
|
/*
|
||
|
* fstree.ts
|
||
|
* Copyright (C) 2024 veypi <i@veypi.com>
|
||
|
* 2024-11-04 17:18
|
||
|
* Distributed under terms of the GPL license.
|
||
|
*/
|
||
|
|
||
|
import v, { proxy, vfor } from "../v2dom"
|
||
|
import fs, { FileStat } from '../fs'
|
||
|
import { vif } from "../v2dom/v2dom"
|
||
|
|
||
|
const dirTree = (url: string) => {
|
||
|
let treeItems = proxy.Watch([] as FileStat[])
|
||
|
let expand = proxy.Watch({ value: false })
|
||
|
let child = v('',
|
||
|
() =>
|
||
|
expand.value && treeItems.length ? vfor(treeItems, (item) => v('div', item.basename), undefined, '123') : [])
|
||
|
return v('fsdir', [
|
||
|
v({
|
||
|
class: 'fsdir-header',
|
||
|
children: [v('div', () => expand.value + ''), v('div', url)],
|
||
|
onclick: () => {
|
||
|
expand.value = !expand.value
|
||
|
if (expand.value) {
|
||
|
fs.user.getDirectoryContents(url).then((e: any) => {
|
||
|
treeItems.splice(0)
|
||
|
treeItems.push(...e)
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
}),
|
||
|
vif([() => expand.value && treeItems.length, () => child], [1, () => v('div', 123)])
|
||
|
])
|
||
|
}
|
||
|
|
||
|
|
||
|
export default dirTree
|