fix(desktop): 扩充应用菜单与元数据快捷键
This commit is contained in:
@@ -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'])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user