From a6e5a3703bd5b69bb9865a77fa94447cc4d10f09 Mon Sep 17 00:00:00 2001 From: Baobhan Sith <80159437+Heavrnl@users.noreply.github.com> Date: Thu, 17 Apr 2025 09:02:03 +0800 Subject: [PATCH] update --- .../frontend/src/components/MonacoEditor.vue | 20 +++++++++++++++---- packages/frontend/src/locales/en.json | 3 ++- packages/frontend/src/locales/zh.json | 3 ++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/frontend/src/components/MonacoEditor.vue b/packages/frontend/src/components/MonacoEditor.vue index eaf4236..bf63aee 100644 --- a/packages/frontend/src/components/MonacoEditor.vue +++ b/packages/frontend/src/components/MonacoEditor.vue @@ -104,10 +104,14 @@ onMounted(() => { }); // 添加鼠标滚轮缩放功能 - editorContainer.value.addEventListener('wheel', (event: WheelEvent) => { - // 只在按下Ctrl键时才触发缩放 - if (event.ctrlKey) { - event.preventDefault(); // 阻止默认的滚动行为 + if (editorContainer.value) { // 确认容器存在 + console.log('[MonacoEditor] Adding wheel event listener to container.'); // 调试日志 + editorContainer.value.addEventListener('wheel', (event: WheelEvent) => { + console.log('[MonacoEditor] Wheel event detected.'); // 调试日志 + // 只在按下Ctrl键时才触发缩放 + if (event.ctrlKey) { + console.log('[MonacoEditor] Ctrl key pressed during wheel event.'); // 调试日志 + event.preventDefault(); // 阻止默认的滚动行为 // 根据滚轮方向调整字体大小 if (event.deltaY < 0) { @@ -120,11 +124,19 @@ onMounted(() => { // 更新编辑器字体大小 if (editorInstance) { + console.log(`[MonacoEditor] Attempting to update font size to: ${fontSize.value}`); // 调试日志 editorInstance.updateOptions({ fontSize: fontSize.value }); console.log(`[MonacoEditor] Font size changed to: ${fontSize.value}`); // 添加日志 + } else { + console.warn('[MonacoEditor] editorInstance is null, cannot update font size.'); // 调试日志 } + } else { + // console.log('[MonacoEditor] Ctrl key NOT pressed during wheel event.'); // 可选调试日志 } }, { passive: false }); // 设置 passive: false 允许 preventDefault + } else { + console.error('[MonacoEditor] editorContainer.value is null, cannot add wheel listener.'); // 调试日志 + } } }); diff --git a/packages/frontend/src/locales/en.json b/packages/frontend/src/locales/en.json index 785d521..94404d9 100644 --- a/packages/frontend/src/locales/en.json +++ b/packages/frontend/src/locales/en.json @@ -201,7 +201,8 @@ "download": "Download", "cancel": "Cancel", "save": "Save", - "closeTab": "Close Tab" + "closeTab": "Close Tab", + "closeEditor": "Close Editor" }, "headers": { "type": "Type", diff --git a/packages/frontend/src/locales/zh.json b/packages/frontend/src/locales/zh.json index 62b4c91..6579aff 100644 --- a/packages/frontend/src/locales/zh.json +++ b/packages/frontend/src/locales/zh.json @@ -203,7 +203,8 @@ "download": "下载", "cancel": "取消", "save": "保存", - "closeTab": "关闭标签页" + "closeTab": "关闭标签页", + "closeEditor": "关闭编辑器" }, "headers": { "type": "类型",