From 0c1a800f16a79c2c9953354171f9798b36cac338 Mon Sep 17 00:00:00 2001 From: TonyJiangWJ Date: Fri, 15 May 2026 00:09:04 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(snippets):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BB=A3=E7=A0=81=E7=89=87=E6=AE=B5=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 工具中心新增代码片段管理入口,与快捷键管理保持同级展示 - 复用现有 SnippetSettingsModal 打开逻辑,保留查询编辑器原入口 - 补充工具中心入口回归测试,防止菜单入口丢失 --- frontend/src/App.tool-center.test.ts | 21 +++++++++++++++++++++ frontend/src/App.tsx | 12 +++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 frontend/src/App.tool-center.test.ts diff --git a/frontend/src/App.tool-center.test.ts b/frontend/src/App.tool-center.test.ts new file mode 100644 index 0000000..8813531 --- /dev/null +++ b/frontend/src/App.tool-center.test.ts @@ -0,0 +1,21 @@ +import { describe, expect, it } from 'vitest'; +import { readFileSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; + +const appSource = readFileSync( + fileURLToPath(new globalThis.URL('./App.tsx', import.meta.url)), + 'utf8', +); + +describe('tool center menu entries', () => { + it('exposes snippet management next to shortcut management', () => { + expect(appSource).toContain("key: 'snippet-settings'"); + expect(appSource).toContain("title: '代码片段管理'"); + expect(appSource).toContain('setIsSnippetModalOpen(true)'); + + const snippetIndex = appSource.indexOf("key: 'snippet-settings'"); + const shortcutIndex = appSource.indexOf("key: 'shortcut-settings'", snippetIndex); + expect(snippetIndex).toBeGreaterThan(-1); + expect(shortcutIndex).toBeGreaterThan(snippetIndex); + }); +}); diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index f6e8ff3..53d88d0 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,7 +1,7 @@ import React, { useState, useEffect, useMemo, useCallback } from 'react'; import { Layout, Button, ConfigProvider, theme, message, Modal, Spin, Slider, Progress, Switch, Input, InputNumber, Select, Segmented, Tooltip } from 'antd'; import zhCN from 'antd/locale/zh_CN'; -import { PlusOutlined, ConsoleSqlOutlined, UploadOutlined, DownloadOutlined, CloudDownloadOutlined, BugOutlined, ToolOutlined, GlobalOutlined, InfoCircleOutlined, GithubOutlined, SkinOutlined, CheckOutlined, MinusOutlined, BorderOutlined, CloseOutlined, SettingOutlined, LinkOutlined, BgColorsOutlined, AppstoreOutlined, RobotOutlined, FolderOpenOutlined, HddOutlined, SafetyCertificateOutlined, SwitcherOutlined } from '@ant-design/icons'; +import { PlusOutlined, ConsoleSqlOutlined, UploadOutlined, DownloadOutlined, CloudDownloadOutlined, BugOutlined, ToolOutlined, GlobalOutlined, InfoCircleOutlined, GithubOutlined, SkinOutlined, CheckOutlined, MinusOutlined, BorderOutlined, CloseOutlined, SettingOutlined, LinkOutlined, BgColorsOutlined, AppstoreOutlined, RobotOutlined, FolderOpenOutlined, HddOutlined, SafetyCertificateOutlined, SwitcherOutlined, CodeOutlined } from '@ant-design/icons'; import { BrowserOpenURL, Environment, EventsOn, Quit, WindowFullscreen, WindowGetPosition, WindowGetSize, WindowIsFullscreen, WindowIsMaximised, WindowIsMinimised, WindowIsNormal, WindowMaximise, WindowMinimise, WindowSetPosition, WindowSetSize, WindowUnfullscreen, WindowUnmaximise } from '../wailsjs/runtime'; import Sidebar from './components/Sidebar'; import TabManager from './components/TabManager'; @@ -3020,6 +3020,16 @@ function App() { setIsDataRootModalOpen(true); }, }, + { + key: 'snippet-settings', + icon: , + title: '代码片段管理', + description: '管理 SQL 代码片段和前缀补全。', + onClick: () => { + setIsToolsModalOpen(false); + setIsSnippetModalOpen(true); + }, + }, { key: 'shortcut-settings', icon: ,