fix(desktop): 扩充应用菜单与元数据快捷键

This commit is contained in:
2026-09-08 00:01:03 +08:00
parent acc0ba167d
commit 2b18b8b2a2
9 changed files with 220 additions and 24 deletions
+8 -2
View File
@@ -91,10 +91,13 @@ export const useWorkspaceStore = defineStore('workspace', () => {
isLoading.value = true
try {
const info = await workspaceService.openVault(path)
const tree = await workspaceService.getFileTree()
vaultPath.value = info.path
vaultId.value = info.vault_id
vaultName.value = info.name
fileTree.value = await workspaceService.getFileTree()
fileTree.value = tree
openFiles.value = []
activeFilePath.value = null
hasVault.value = true
localStorage.setItem('last-vault-path', info.path)
} finally {
@@ -107,10 +110,13 @@ export const useWorkspaceStore = defineStore('workspace', () => {
isLoading.value = true
try {
const info = await workspaceService.createVault(path, name)
const tree = await workspaceService.getFileTree()
vaultPath.value = info.path
vaultId.value = info.vault_id
vaultName.value = info.name
fileTree.value = await workspaceService.getFileTree()
fileTree.value = tree
openFiles.value = []
activeFilePath.value = null
hasVault.value = true
localStorage.setItem('last-vault-path', info.path)
} finally {
@@ -18,3 +18,15 @@ it('fetches external entries while keeping folder state and ignoring stale respo
release([]); await old
expect(store.fileTree).toHaveLength(1)
})
it('clears document tabs only after another vault opens successfully', async () => {
const store = useWorkspaceStore()
store.openFile('/old.md')
vi.spyOn(service, 'openVault').mockResolvedValue({ vault_id: 'new-vault', path: 'D:/notes', name: 'notes' })
vi.spyOn(service, 'getFileTree').mockResolvedValue([{ id: 'new', path: '/new.md', name: 'new.md', type: 'file' }])
await store.openVault('D:/notes')
expect(store.openFiles).toEqual([])
expect(store.activeFilePath).toBeNull()
expect(store.fileTree.map(item => item.path)).toEqual(['/new.md'])
})