🐛 fix(ui): 修复命令面板新建查询无响应

- 补充 gonavi:create-query-tab 全局事件监听
- 统一复用 handleNewQuery 创建查询标签页
- 恢复起始工作台与命令面板的新建查询入口
- 增加事件监听回归断言避免后续再次丢失
This commit is contained in:
Syngnat
2026-05-27 19:56:23 +08:00
parent ccd12742d3
commit e069ddf8fa
2 changed files with 17 additions and 0 deletions

View File

@@ -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', () => {

View File

@@ -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;