2121 </div >
2222 </div >
2323 <div class =" flex-1 overflow-hidden" >
24- <CodeEditor v-model =" code" class =" h-full" :language =" currentLanguage" />
24+ <CodeEditor v-model =" code" class =" h-full" :language =" currentLanguage" :editor-config = " editorConfig " :key = " editorConfigKey " />
2525 </div >
2626 </div >
2727
4444 <About v-if =" showAbout" @close =" closeAbout" />
4545
4646 <!-- 设置组件 -->
47- <Settings v-if =" showSettings" @close =" closeSettings" />
47+ <Settings v-if =" showSettings" @close =" closeSettings" @settings-changed = " handleSettingsChanged " />
4848
4949 <!-- 更新组件 -->
5050 <Update v-if =" showUpdate" @close =" closeUpdate" />
5555</template >
5656
5757<script setup lang="ts">
58- import { onMounted , onUnmounted } from ' vue'
58+ import { onMounted , onUnmounted , ref , watch } from ' vue'
5959import AppHeader from ' ./components/AppHeader.vue'
6060import CodeEditor from ' ./components/CodeEditor.vue'
6161import OutputPanel from ' ./components/OutputPanel.vue'
@@ -70,6 +70,7 @@ import { useCodeExecution } from './composables/useCodeExecution'
7070import { useLanguageManager } from ' ./composables/useLanguageManager'
7171import { useEventManager } from ' ./composables/useEventManager'
7272import { useAppState } from ' ./composables/useAppState'
73+ import { useEditorConfig } from ' ./composables/useEditorConfig'
7374import Update from ' ./components/Update.vue'
7475
7576const toast = useToast ()
@@ -109,6 +110,34 @@ const {
109110 closeUpdate
110111} = useAppState ()
111112
113+ // 编辑器配置管理
114+ const {
115+ editorConfig,
116+ loadConfig : loadEditorConfig
117+ } = useEditorConfig ()
118+
119+ // 强制刷新 CodeEditor 组件的 key
120+ const editorConfigKey = ref (0 )
121+
122+ // 处理设置变更
123+ const handleSettingsChanged = (config : any ) => {
124+ console .log (' 主组件接收到设置变更:' , config )
125+ // 延迟一点点再刷新,减少闪烁
126+ setTimeout (() => {
127+ editorConfigKey .value ++
128+ }, 50 )
129+ }
130+
131+ // 监听编辑器配置变化
132+ watch (editorConfig , (newConfig ) => {
133+ if (newConfig ) {
134+ console .log (' 编辑器配置更新,刷新编辑器组件' )
135+ setTimeout (() => {
136+ editorConfigKey .value ++
137+ }, 50 )
138+ }
139+ }, { deep: true })
140+
112141const { initializeEventListeners, cleanupEventListeners } = useEventManager ({
113142 showAbout ,
114143 showSettings ,
@@ -131,6 +160,7 @@ window.addEventListener('contextmenu', (e) => e.preventDefault(), false)
131160
132161onMounted (async () => {
133162 await initialize ()
163+ await loadEditorConfig ()
134164 await initializeEventListeners ()
135165
136166 // 触发 app-ready 事件,通知主进程
0 commit comments