From 7ddef7096b0d7c1628e3d61ed261b15827ffd685 Mon Sep 17 00:00:00 2001 From: Syngnat Date: Fri, 20 Mar 2026 15:00:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(editor):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DDDL=E8=A7=86=E5=9B=BEstickyScroll=E9=A6=96=E8=A1=8C?= =?UTF-8?q?=E5=86=BB=E7=BB=93=E9=80=8F=E6=98=8E=E8=83=8C=E6=99=AF=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=AD=97=E7=AC=A6=E9=87=8D=E5=8F=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 根因定位:TableDesigner和TriggerViewer中局部主题定义覆盖了全局配置 - 全局主题新增editorStickyScroll.background不透明背景色 - 移除TableDesigner.tsx中重复的透明主题定义(26行) - 移除TriggerViewer.tsx中重复的透明主题定义(26行) - 清理未使用的loader import - refs #274 --- frontend/src/components/TableDesigner.tsx | 26 +-------------------- frontend/src/components/TriggerViewer.tsx | 28 ++--------------------- frontend/src/main.tsx | 4 ++-- 3 files changed, 5 insertions(+), 53 deletions(-) diff --git a/frontend/src/components/TableDesigner.tsx b/frontend/src/components/TableDesigner.tsx index 2697949..8c7924a 100644 --- a/frontend/src/components/TableDesigner.tsx +++ b/frontend/src/components/TableDesigner.tsx @@ -290,31 +290,7 @@ const TableDesigner: React.FC<{ tab: TabData }> = ({ tab }) => { setCommentEditorValue(''); }, []); - // 初始化透明 Monaco Editor 主题 - useEffect(() => { - loader.init().then(monaco => { - monaco.editor.defineTheme('transparent-dark', { - base: 'vs-dark', - inherit: true, - rules: [], - colors: { - 'editor.background': '#00000000', - 'editor.lineHighlightBackground': '#ffffff10', - 'editorGutter.background': '#00000000', - } - }); - monaco.editor.defineTheme('transparent-light', { - base: 'vs', - inherit: true, - rules: [], - colors: { - 'editor.background': '#00000000', - 'editor.lineHighlightBackground': '#00000010', - 'editorGutter.background': '#00000000', - } - }); - }); - }, []); + // 透明 Monaco Editor 主题已在 main.tsx 全局注册(含 stickyScroll 不透明背景) useEffect(() => { if (!containerRef.current) return; diff --git a/frontend/src/components/TriggerViewer.tsx b/frontend/src/components/TriggerViewer.tsx index d0a91be..849a7ca 100644 --- a/frontend/src/components/TriggerViewer.tsx +++ b/frontend/src/components/TriggerViewer.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import Editor, { loader } from '@monaco-editor/react'; +import Editor from '@monaco-editor/react'; import { Spin, Alert } from 'antd'; import { TabData } from '../types'; import { useStore } from '../store'; @@ -18,31 +18,7 @@ const TriggerViewer: React.FC = ({ tab }) => { const theme = useStore(state => state.theme); const darkMode = theme === 'dark'; - // 初始化透明 Monaco Editor 主题 - useEffect(() => { - loader.init().then(monaco => { - monaco.editor.defineTheme('transparent-dark', { - base: 'vs-dark', - inherit: true, - rules: [], - colors: { - 'editor.background': '#00000000', - 'editor.lineHighlightBackground': '#ffffff10', - 'editorGutter.background': '#00000000', - } - }); - monaco.editor.defineTheme('transparent-light', { - base: 'vs', - inherit: true, - rules: [], - colors: { - 'editor.background': '#00000000', - 'editor.lineHighlightBackground': '#00000010', - 'editorGutter.background': '#00000000', - } - }); - }); - }, []); + // 透明 Monaco Editor 主题已在 main.tsx 全局注册(含 stickyScroll 不透明背景) const escapeSQLLiteral = (raw: string): string => String(raw || '').replace(/'/g, "''"); const quoteSqlServerIdentifier = (raw: string): string => `[${String(raw || '').replace(/]/g, ']]')}]`; diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index 7ab4fee..99c8104 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -42,11 +42,11 @@ if (typeof window !== 'undefined' && !(window as any).go) { // 全局注册透明主题,避免每个 Editor 组件 beforeMount 中重复定义 monaco.editor.defineTheme('transparent-dark', { base: 'vs-dark', inherit: true, rules: [], - colors: { 'editor.background': '#00000000', 'editor.lineHighlightBackground': '#ffffff10', 'editorGutter.background': '#00000000' } + colors: { 'editor.background': '#00000000', 'editor.lineHighlightBackground': '#ffffff10', 'editorGutter.background': '#00000000', 'editorStickyScroll.background': '#1e1e1e', 'editorStickyScrollHover.background': '#2a2a2a' } }) monaco.editor.defineTheme('transparent-light', { base: 'vs', inherit: true, rules: [], - colors: { 'editor.background': '#00000000', 'editor.lineHighlightBackground': '#00000010', 'editorGutter.background': '#00000000' } + colors: { 'editor.background': '#00000000', 'editor.lineHighlightBackground': '#00000010', 'editorGutter.background': '#00000000', 'editorStickyScroll.background': '#ffffff', 'editorStickyScrollHover.background': '#f5f5f5' } }) ReactDOM.createRoot(document.getElementById('root')!).render(