mirror of https://github.com/veypi/OneAuth.git
feat: vif
parent
d4a57c8cf0
commit
e819b138ae
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* fs.ts
|
||||
* Copyright (C) 2024 veypi <i@veypi.com>
|
||||
* 2024-11-04 17:11
|
||||
* Distributed under terms of the GPL license.
|
||||
*/
|
||||
|
||||
|
||||
import { v } from "../v2dom";
|
||||
import logic from '../logic'
|
||||
import api from "../api";
|
||||
import fstree from "./fstree";
|
||||
|
||||
|
||||
export default () => {
|
||||
return v({
|
||||
class: 'voa-fs',
|
||||
children: [
|
||||
v('voa-fs-header',
|
||||
[
|
||||
v({
|
||||
class: 'voa-item-title',
|
||||
children: ['我的文件'],
|
||||
onclick: () => {
|
||||
logic.goto('/')
|
||||
}
|
||||
}),
|
||||
v({
|
||||
class: 'voa-fs-subtxt', children: '获取密钥', onclick: () => {
|
||||
api.token.Post({
|
||||
refresh: logic.token.refresh.raw(),
|
||||
user_id: logic.token.refresh.uid!
|
||||
}).then(e => {
|
||||
console.log(e)
|
||||
})
|
||||
}
|
||||
})
|
||||
]
|
||||
),
|
||||
v('voa-fs-body', fstree('/'))
|
||||
]
|
||||
})
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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
|
Loading…
Reference in New Issue