🐛 Fixed extension management issues

This commit is contained in:
2025-07-01 23:25:24 +08:00
parent 3e45e6aa9b
commit 1ccee779ae
9 changed files with 290 additions and 197 deletions

View File

@@ -1,11 +1,16 @@
<script setup lang="ts">
import {onBeforeUnmount, onMounted, ref} from 'vue';
import {onBeforeUnmount, onMounted, ref, watch} from 'vue';
import {useEditorStore} from '@/stores/editorStore';
import {useDocumentStore} from '@/stores/documentStore';
import {useConfigStore} from '@/stores/configStore';
import {createWheelZoomHandler} from './basic/wheelZoomExtension';
import Toolbar from '@/components/toolbar/Toolbar.vue';
// 接收路由传入的文档ID
const props = defineProps<{
documentId?: number | null
}>();
const editorStore = useEditorStore();
const documentStore = useDocumentStore();
const configStore = useConfigStore();
@@ -22,6 +27,12 @@ onMounted(async () => {
if (!editorElement.value) return;
await documentStore.initialize();
// 如果有指定文档ID则打开该文档
if (props.documentId) {
await documentStore.openDocument(props.documentId);
}
// 设置编辑器容器
editorStore.setEditorContainer(editorElement.value);
@@ -35,6 +46,13 @@ onBeforeUnmount(() => {
editorElement.value.removeEventListener('wheel', wheelHandler);
}
});
// 监听文档ID变化
watch(() => props.documentId, async (newDocId) => {
if (newDocId && documentStore.currentDocumentId !== newDocId) {
await documentStore.openDocument(newDocId);
}
}, { immediate: true });
</script>
<template>