fix(frontend): 防止切换文件丢稿并修复主题恢复

This commit is contained in:
2026-08-30 00:14:10 +08:00
parent a7772430d5
commit 0dbd32a757
7 changed files with 44 additions and 20 deletions
+1 -1
View File
@@ -41,8 +41,8 @@ watch(() => chatStore.selectedProviderId, async (providerId) => {
function send() { void chatStore.sendMessage(chatStore.inputText) }
async function openCitation(citation: Citation) {
workspaceStore.openFile(citation.file_path)
await editorStore.loadFile(citation.file_path)
workspaceStore.openFile(citation.file_path)
editorStore.highlightBlock(citation.block_id)
await router.push('/workspace')
}
+1 -1
View File
@@ -23,8 +23,8 @@ function submitSearch() {
}
async function openResult(result: SearchResult) {
workspaceStore.openFile(result.file_path)
await editorStore.loadFile(result.file_path)
workspaceStore.openFile(result.file_path)
editorStore.highlightBlock(result.block_id)
await router.push('/workspace')
}
@@ -29,8 +29,8 @@ async function createItem() {
const name = rawName.endsWith('.md') ? rawName : `${rawName}.md`
const file = await workspaceService.createFile(parentPath.value, name, `# ${rawName}\n\n`)
workspaceStore.addFileToTree(parentPath.value, file)
workspaceStore.openFile(file.path)
await editorStore.loadFile(file.path)
workspaceStore.openFile(file.path)
await router.push('/workspace')
} else {
const folder = await workspaceService.createFolder(parentPath.value, rawName)
@@ -42,8 +42,8 @@ async function createItem() {
async function openNode(node: FileNode) {
if (node.type === 'folder') return workspaceStore.toggleFolder(node.path)
workspaceStore.openFile(node.path)
await editorStore.loadFile(node.path)
workspaceStore.openFile(node.path)
await router.push('/workspace')
}
@@ -80,8 +80,8 @@ async function deleteTarget() {
const activeWasRemoved = workspaceStore.closePath(node.path)
workspaceStore.removeFromTree(node.path)
if (activeWasRemoved) {
editorStore.closeFile()
if (workspaceStore.activeFilePath) await editorStore.loadFile(workspaceStore.activeFilePath)
else editorStore.closeFile()
}
closeContextMenu()
}
@@ -13,8 +13,9 @@ onMounted(() => {
// Already loaded
}
if (!workspaceStore.activeFilePath && workspaceStore.fileTree.length === 0) {
workspaceStore.openFile('/欢迎使用知笔知己.md')
editorStore.loadFile('/欢迎使用知笔知己.md')
void editorStore.loadFile('/欢迎使用知笔知己.md').then(() => {
workspaceStore.openFile('/欢迎使用知笔知己.md')
})
}
})
</script>