mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-08 15:43:42 +08:00
✨ feat(query-editor): 增强 SQL 编辑器 AI 内联补全与独立模型配置
- 新增独立内联补全模型配置与服务端透传 - 优化 SQL 编辑器 Alt+\\ 触发、ghost 延续与对象位补全 - 引入基于已存查询和执行日志的 SQL 记忆补全 - 补充前后端本地化、快捷键与补全回归测试
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React from "react";
|
||||
import { Button, Dropdown, Select, Tooltip, type MenuProps } from "antd";
|
||||
import {
|
||||
DownOutlined,
|
||||
EyeInvisibleOutlined,
|
||||
EyeOutlined,
|
||||
FormatPainterOutlined,
|
||||
@@ -37,6 +38,7 @@ type QueryEditorToolbarProps = {
|
||||
runQueryShortcutBinding: ShortcutPlatformBinding;
|
||||
saveQueryShortcutBinding: ShortcutPlatformBinding;
|
||||
formatSqlShortcutBinding: ShortcutPlatformBinding;
|
||||
triggerSqlAiCompletionShortcutBinding: ShortcutPlatformBinding;
|
||||
toggleQueryResultsPanelShortcutBinding: ShortcutPlatformBinding;
|
||||
activeShortcutPlatform: ShortcutPlatform;
|
||||
isResultPanelVisible: boolean;
|
||||
@@ -54,6 +56,7 @@ type QueryEditorToolbarProps = {
|
||||
onQuickSave: () => void;
|
||||
onFindInEditor: () => void;
|
||||
onFormat: () => void;
|
||||
onTriggerSqlAiCompletion: () => void;
|
||||
onToggleResultPanelVisibility: () => void;
|
||||
onAIAction: (action: "generate" | "explain" | "optimize" | "schema") => void;
|
||||
};
|
||||
@@ -99,6 +102,7 @@ const QueryEditorToolbar: React.FC<QueryEditorToolbarProps> = ({
|
||||
runQueryShortcutBinding,
|
||||
saveQueryShortcutBinding,
|
||||
formatSqlShortcutBinding,
|
||||
triggerSqlAiCompletionShortcutBinding,
|
||||
toggleQueryResultsPanelShortcutBinding,
|
||||
activeShortcutPlatform,
|
||||
isResultPanelVisible,
|
||||
@@ -116,6 +120,7 @@ const QueryEditorToolbar: React.FC<QueryEditorToolbarProps> = ({
|
||||
onQuickSave,
|
||||
onFindInEditor,
|
||||
onFormat,
|
||||
onTriggerSqlAiCompletion,
|
||||
onToggleResultPanelVisibility,
|
||||
onAIAction,
|
||||
}) => {
|
||||
@@ -175,7 +180,22 @@ const QueryEditorToolbar: React.FC<QueryEditorToolbarProps> = ({
|
||||
),
|
||||
},
|
||||
);
|
||||
const triggerSqlAiCompletionLabel =
|
||||
triggerSqlAiCompletionShortcutBinding.enabled &&
|
||||
triggerSqlAiCompletionShortcutBinding.combo
|
||||
? `${t("app.shortcuts.action.triggerSqlAiCompletion.label")} · ${getShortcutDisplayLabel(
|
||||
triggerSqlAiCompletionShortcutBinding.combo,
|
||||
activeShortcutPlatform,
|
||||
)}`
|
||||
: t("app.shortcuts.action.triggerSqlAiCompletion.label");
|
||||
const aiMenuItems: MenuProps["items"] = [
|
||||
{
|
||||
key: "ai-inline-completion",
|
||||
label: triggerSqlAiCompletionLabel,
|
||||
icon: <RobotOutlined />,
|
||||
onClick: onTriggerSqlAiCompletion,
|
||||
},
|
||||
{ type: "divider" as const },
|
||||
{
|
||||
key: "ai-generate",
|
||||
label: t("query_editor.action.ai_text_to_sql_menu"),
|
||||
@@ -359,19 +379,30 @@ const QueryEditorToolbar: React.FC<QueryEditorToolbarProps> = ({
|
||||
{t("query_editor.action.save")}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Dropdown
|
||||
menu={{ items: aiMenuItems }}
|
||||
placement="bottomRight"
|
||||
trigger={["click"]}
|
||||
>
|
||||
<Button
|
||||
className={isV2Ui ? "gn-v2-query-toolbar-ai-action" : undefined}
|
||||
icon={<RobotOutlined />}
|
||||
style={{ color: "#818cf8" }}
|
||||
<div style={{ display: "flex", gap: "4px", alignItems: "center" }}>
|
||||
<Tooltip title={triggerSqlAiCompletionLabel}>
|
||||
<Button
|
||||
className={isV2Ui ? "gn-v2-query-toolbar-ai-action" : undefined}
|
||||
icon={<RobotOutlined />}
|
||||
style={{ color: "#818cf8" }}
|
||||
onMouseDown={onCaptureEditorCursorPosition}
|
||||
onClick={onTriggerSqlAiCompletion}
|
||||
>
|
||||
AI
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Dropdown
|
||||
menu={{ items: aiMenuItems }}
|
||||
placement="bottomRight"
|
||||
trigger={["click"]}
|
||||
>
|
||||
AI
|
||||
</Button>
|
||||
</Dropdown>
|
||||
<Button
|
||||
className={isV2Ui ? "gn-v2-query-toolbar-icon-action" : undefined}
|
||||
icon={<DownOutlined />}
|
||||
aria-label="AI more actions"
|
||||
/>
|
||||
</Dropdown>
|
||||
</div>
|
||||
<Dropdown
|
||||
menu={{ items: moreMenuItems }}
|
||||
placement="bottomRight"
|
||||
|
||||
Reference in New Issue
Block a user