🎨 Optimize code & Upgrade dependencies

This commit is contained in:
2026-01-01 02:27:21 +08:00
parent 9ec22add55
commit 76f6c30b9d
17 changed files with 316 additions and 1247 deletions

View File

@@ -7,7 +7,7 @@
v-for="tab in tabStore.tabs"
:key="tab.documentId"
:tab="tab"
:isActive="tab.documentId === tabStore.currentDocumentId"
:isActive="tab.documentId === documentStore.currentDocumentId"
:canClose="tabStore.canCloseTab"
@click="switchToTab"
@close="closeTab"
@@ -35,8 +35,12 @@ import { ref, onMounted, onUnmounted, watch, nextTick } from 'vue';
import TabItem from './TabItem.vue';
import TabContextMenu from './TabContextMenu.vue';
import { useTabStore } from '@/stores/tabStore';
import { useDocumentStore } from '@/stores/documentStore';
import { useEditorStore } from '@/stores/editorStore';
const tabStore = useTabStore();
const documentStore = useDocumentStore();
const editorStore = useEditorStore();
// DOM 引用
const tabBarRef = ref<HTMLElement>();
@@ -50,8 +54,17 @@ const contextMenuTargetId = ref<number | null>(null);
// 标签页操作
const switchToTab = (documentId: number) => {
tabStore.switchToTabAndDocument(documentId);
const switchToTab = async (documentId: number) => {
await tabStore.switchToTabAndDocument(documentId);
const doc = documentStore.currentDocument;
if (doc && doc.id !== undefined && editorStore.hasContainer) {
await editorStore.loadEditor(doc.id, doc.content || '');
}
if (doc && tabStore.isTabsEnabled) {
tabStore.addOrActivateTab(doc);
}
};
const closeTab = (documentId: number) => {
@@ -150,7 +163,7 @@ onUnmounted(() => {
});
// 监听当前活跃标签页的变化
watch(() => tabStore.currentDocumentId, () => {
watch(() => documentStore.currentDocumentId, () => {
scrollToActiveTab();
});