From e069ddf8fac7695235f0c7b9109395f74f2c74c8 Mon Sep 17 00:00:00 2001 From: Syngnat Date: Wed, 27 May 2026 19:56:23 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(ui):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E9=9D=A2=E6=9D=BF=E6=96=B0=E5=BB=BA=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=97=A0=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 补充 gonavi:create-query-tab 全局事件监听 - 统一复用 handleNewQuery 创建查询标签页 - 恢复起始工作台与命令面板的新建查询入口 - 增加事件监听回归断言避免后续再次丢失 --- frontend/src/App.tool-center.test.ts | 7 +++++++ frontend/src/App.tsx | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/frontend/src/App.tool-center.test.ts b/frontend/src/App.tool-center.test.ts index 712369d..dbd869d 100644 --- a/frontend/src/App.tool-center.test.ts +++ b/frontend/src/App.tool-center.test.ts @@ -158,6 +158,13 @@ describe('tool center menu entries', () => { expect(appSource).toContain('handleCreateConnection, handleManualResetWindowZoom'); expect(appSource).toContain('setTheme, toggleAIPanel, useNativeMacWindowControls'); }); + + it('listens for command search query-tab events and routes them through handleNewQuery', () => { + expect(appSource).toContain("window.addEventListener('gonavi:create-query-tab', handleCreateQueryTabEvent as EventListener);"); + expect(appSource).toContain("window.removeEventListener('gonavi:create-query-tab', handleCreateQueryTabEvent as EventListener);"); + expect(appSource).toContain('const handleCreateQueryTabEvent = () => {'); + expect(appSource).toContain('handleNewQuery();'); + }); }); describe('global appearance tokens', () => { diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index c0179c6..c7d12ad 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -2665,6 +2665,16 @@ function App() { }; }, []); + useEffect(() => { + const handleCreateQueryTabEvent = () => { + handleNewQuery(); + }; + window.addEventListener('gonavi:create-query-tab', handleCreateQueryTabEvent as EventListener); + return () => { + window.removeEventListener('gonavi:create-query-tab', handleCreateQueryTabEvent as EventListener); + }; + }, [handleNewQuery]); + useEffect(() => { if (!isMacRuntime || !useNativeMacWindowControls) { return;