feat: update AGENTS.md with new components and API details; enhance FileContent.vue with Plyr video support; add VideoPlayer.vue for video playback; improve MilkdownEditor.vue for video file handling; refine TTSPlayer.vue volume controls; optimize settings store for localStorage; implement video upload support in uploadBlock.js; create utility functions for Plyr player management.

This commit is contained in:
“ydy0615”
2026-06-13 11:03:40 +08:00
parent 2283020e51
commit 4813196b0a
16 changed files with 767 additions and 275 deletions
+19 -64
View File
@@ -216,17 +216,13 @@ export function useFileSystem() {
return nextRecord
}
// --- Async operations with unified error handling ---
async function load() {
loading.value = true
try {
records.value = await fetchDocNodes()
error.value = null
} catch (err) {
error.value = err instanceof Error && err.message ? err.message : '读取文档空间失败,请稍后重试'
records.value = []
} finally {
loading.value = false
}
loading.value = true; records.value = []
try { records.value = await fetchDocNodes() }
catch (err) { error.value = err?.message || '读取文档空间失败,请稍后重试' }
finally { loading.value = false }
}
async function createFile(parentId, name, content = '') {
@@ -236,47 +232,21 @@ export function useFileSystem() {
}
try {
const node = await createDocTextFile(name, parentId || null, content)
upsertRecord(node)
if (parentId) {
const next = new Set(expandedIds.value)
next.add(parentId)
expandedIds.value = next
}
selectedId.value = node.id
error.value = null
upsertRecord(node); selectedId.value = node.id
if (parentId) { expandedIds.value = new Set([...expandedIds.value, parentId]) }
return true
} catch (err) {
error.value = err instanceof Error && err.message ? err.message : '创建文件失败'
return false
}
} catch (err) { error.value = err?.message || '创建文件失败'; return false }
}
async function updateFile(id, nextValue, options = {}) {
const file = records.value.find((item) => item.id === id && item.type === 'file')
if (!file) return false
try {
let node
if (nextValue instanceof Blob) {
const filename = options.name || file.name
const upload = nextValue instanceof File
? nextValue
: new File([nextValue], filename, { type: options.mimeType || nextValue.type || file.mimeType || '' })
node = await replaceDocBlob(id, upload)
} else {
const content = String(options.content ?? nextValue ?? '')
node = await updateDocNode(id, {
name: options.name || file.name,
content,
})
}
upsertRecord(node)
clearBlobCache(id)
error.value = null
return true
} catch (err) {
error.value = err instanceof Error && err.message ? err.message : '保存文件失败'
return false
}
const node = nextValue instanceof Blob
? await replaceDocBlob(id, nextValue instanceof File ? nextValue : new File([nextValue], options.name || file.name, { type: options.mimeType || nextValue.type || '' }))
: await updateDocNode(id, { name: options.name || file.name, content: String(options.content ?? nextValue) })
upsertRecord(node); clearBlobCache(id); return true
} catch (err) { error.value = err?.message || '保存文件失败'; return false }
}
async function createFolder(parentId, name) {
@@ -286,19 +256,10 @@ export function useFileSystem() {
}
try {
const node = await createDocFolder(name, parentId || null)
upsertRecord(node)
if (parentId) {
const next = new Set(expandedIds.value)
next.add(parentId)
expandedIds.value = next
}
selectedId.value = node.id
error.value = null
upsertRecord(node); selectedId.value = node.id
if (parentId) expandedIds.value = new Set([...expandedIds.value, parentId])
return true
} catch (err) {
error.value = err instanceof Error && err.message ? err.message : '创建文件夹失败'
return false
}
} catch (err) { error.value = err?.message || '创建文件夹失败'; return false }
}
async function rename(id, newName) {
@@ -306,14 +267,8 @@ export function useFileSystem() {
if (!node) return false
try {
const updated = await updateDocNode(id, { name: newName })
upsertRecord(updated)
clearBlobCache(id)
error.value = null
return true
} catch (err) {
error.value = err instanceof Error && err.message ? err.message : '重命名失败'
return false
}
upsertRecord(updated); clearBlobCache(id); return true
} catch (err) { error.value = err?.message || '重命名失败'; return false }
}
function collectDescendantIds(id) {