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(