🐛 Fixed some issues

This commit is contained in:
2025-07-02 12:10:46 +08:00
parent 25e1a98932
commit 81eb2c94ac
14 changed files with 210 additions and 149 deletions

View File

@@ -190,10 +190,15 @@ export const useDocumentStore = defineStore('document', () => {
try {
await updateDocuments();
// 获取第一个文档ID并打开
const firstDocId = await DocumentService.GetFirstDocumentID();
if (firstDocId && documents.value[firstDocId]) {
await openDocument(firstDocId);
// 如果存在持久化的文档ID尝试打开该文档
if (currentDocumentId.value && documents.value[currentDocumentId.value]) {
await openDocument(currentDocumentId.value);
} else {
// 否则获取第一个文档ID并打开
const firstDocId = await DocumentService.GetFirstDocumentID();
if (firstDocId && documents.value[firstDocId]) {
await openDocument(firstDocId);
}
}
} catch (error) {
console.error('Failed to initialize document store:', error);
@@ -221,4 +226,10 @@ export const useDocumentStore = defineStore('document', () => {
closeDialog,
initialize,
};
}, {
persist: {
key: 'voidraft-document',
storage: localStorage,
pick: ['currentDocumentId']
}
});