@donglegeyu/company-ui 1.2.48 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/cjs/ai-assistant/AiAssistantProvider.d.ts +20 -3
  2. package/dist/cjs/ai-assistant/AiAssistantProvider.js +35 -8
  3. package/dist/cjs/ai-assistant/AiSessionEngine.d.ts +9 -1
  4. package/dist/cjs/ai-assistant/AiSessionEngine.js +59 -9
  5. package/dist/cjs/ai-assistant/index.d.ts +1 -1
  6. package/dist/cjs/ai-assistant/types.d.ts +30 -1
  7. package/dist/cjs/basic-components/CompanyForm/index.js +2 -2
  8. package/dist/cjs/shared-components/BaseInfoForm/index.scss +3 -2
  9. package/dist/cjs/shared-components/CompanyAiAssistant/index.d.ts +3 -1
  10. package/dist/cjs/shared-components/CompanyAiAssistant/index.js +33 -1
  11. package/dist/cjs/shared-components/CompanyAiAssistant/index.scss +5 -0
  12. package/dist/cjs/shared-components/tableActionColumn.d.ts +23 -0
  13. package/dist/cjs/shared-components/tableActionColumn.js +55 -0
  14. package/dist/cjs/template-components/AdminLayoutTemplate/index.js +4 -0
  15. package/dist/cjs/template-components/AiAssistantDock/index.js +3 -0
  16. package/dist/cjs/template-components/SmartListTemplate/index.js +17 -25
  17. package/dist/cjs/template-components/StatisticsListPage/index.js +14 -9
  18. package/dist/cjs/template-components/StatisticsListPage/index.scss +1 -1
  19. package/dist/es/ai-assistant/AiAssistantProvider.d.ts +20 -3
  20. package/dist/es/ai-assistant/AiAssistantProvider.js +46 -11
  21. package/dist/es/ai-assistant/AiSessionEngine.d.ts +9 -1
  22. package/dist/es/ai-assistant/AiSessionEngine.js +65 -11
  23. package/dist/es/ai-assistant/index.d.ts +1 -1
  24. package/dist/es/ai-assistant/types.d.ts +30 -1
  25. package/dist/es/basic-components/CompanyForm/index.js +2 -1
  26. package/dist/es/shared-components/BaseInfoForm/index.scss +3 -2
  27. package/dist/es/shared-components/CompanyAiAssistant/index.d.ts +3 -1
  28. package/dist/es/shared-components/CompanyAiAssistant/index.js +77 -37
  29. package/dist/es/shared-components/CompanyAiAssistant/index.scss +5 -0
  30. package/dist/es/shared-components/tableActionColumn.d.ts +23 -0
  31. package/dist/es/shared-components/tableActionColumn.js +55 -0
  32. package/dist/es/template-components/AdminLayoutTemplate/index.js +7 -0
  33. package/dist/es/template-components/AiAssistantDock/index.js +3 -0
  34. package/dist/es/template-components/SmartListTemplate/index.js +8 -25
  35. package/dist/es/template-components/StatisticsListPage/index.js +12 -18
  36. package/dist/es/template-components/StatisticsListPage/index.scss +1 -1
  37. package/package.json +3 -2
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode } from "react";
2
- import type { AiPageCapability, AiReference, AiReferenceTab, AiSession, AiSuggestion, AiTransport } from "./types";
2
+ import type { AiContext, AiNavigateTarget, AiNavigationSuggestion, AiPageCapability, AiReference, AiReferenceTab, AiSession, AiSuggestion, AiTransport } from "./types";
3
3
  /** 页签元数据:@ 引用列表数据源(capability 供引用非活动页签时查找能力契约) */
4
4
  export interface AiTabMeta extends AiReferenceTab {
5
5
  /** 该页签的能力契约(页面未挂载时其 getContext 可能拿不到实时值) */
@@ -9,7 +9,7 @@ export interface AiTabMeta extends AiReferenceTab {
9
9
  export interface AiAssistantContextValue {
10
10
  /** 面板是否展开(当前页签) */
11
11
  open: boolean;
12
- /** 是否钉住(跨页签常驻;未钉住时切换页签自动收起) */
12
+ /** 是否钉住(跨页签常驻;未钉住时是否随页签切换收起由 autoCollapseOnTabChange 控制) */
13
13
  pinned: boolean;
14
14
  /** 当前活动页签 key(会话隔离键) */
15
15
  activeTabKey: string;
@@ -30,6 +30,10 @@ export interface AiAssistantContextValue {
30
30
  togglePin: () => void;
31
31
  send: (text: string) => void;
32
32
  confirmSuggestion: (suggestion: AiSuggestion) => void;
33
+ /** 确认导航(用户点击「前往」后由面板调用) */
34
+ confirmNavigation: (navigation: AiNavigationSuggestion) => void;
35
+ /** 导航执行入口是否已配置(未配置时导航卡片按钮不可用) */
36
+ canNavigate: boolean;
33
37
  rollback: () => void;
34
38
  validate: () => void;
35
39
  }
@@ -47,6 +51,19 @@ export interface AiAssistantProviderProps {
47
51
  transport?: AiTransport;
48
52
  /** 初始是否展开面板,默认 false */
49
53
  defaultOpen?: boolean;
54
+ /** 初始是否钉住面板(钉住后跨页签常驻),默认 false */
55
+ defaultPinned?: boolean;
56
+ /** 切换页签时是否自动收起面板(仅未钉住时生效),默认 true(保持 1.x 行为) */
57
+ autoCollapseOnTabChange?: boolean;
58
+ /** 系统级上下文:无页面能力契约时随请求发送(默认不启用,scene 仍为 system) */
59
+ systemContext?: AiContext;
60
+ /**
61
+ * 兜底能力契约:无页面能力契约时启用(默认不启用)。
62
+ * 注意:启用后系统级交互会按其 actions 显示系统级动作芯片,并以其 scene 路由请求。
63
+ */
64
+ fallbackCapability?: AiPageCapability;
65
+ /** 导航执行入口:用户点击导航卡片「前往」时调用(默认不启用,仅渲染确认卡片) */
66
+ onNavigate?: (target: AiNavigateTarget) => void;
50
67
  }
51
68
  /**
52
69
  * AI 助手全局状态层:持有面板两态(open/pinned)与按 tabKey 隔离的会话表。
@@ -54,6 +71,6 @@ export interface AiAssistantProviderProps {
54
71
  * - 内部创建 AiSessionEngine 并镜像其会话快照到组件状态
55
72
  * - 未钉住时切换页签自动收起面板;页签关闭经 tabKeys 自动回收会话
56
73
  */
57
- export declare function AiAssistantProvider({ children, activeTabKey, tabKeys, tabs, capability, transport, defaultOpen, }: AiAssistantProviderProps): import("react").JSX.Element;
74
+ export declare function AiAssistantProvider({ children, activeTabKey, tabKeys, tabs, capability, transport, defaultOpen, defaultPinned, autoCollapseOnTabChange, systemContext, fallbackCapability, onNavigate, }: AiAssistantProviderProps): import("react").JSX.Element;
58
75
  /** 读取 AI 助手全局状态(需在 AiAssistantProvider 内使用) */
59
76
  export declare function useAiAssistantContext(): AiAssistantContextValue;
@@ -36,10 +36,15 @@ function AiAssistantProvider({
36
36
  tabs,
37
37
  capability,
38
38
  transport,
39
- defaultOpen = false
39
+ defaultOpen = false,
40
+ defaultPinned = false,
41
+ autoCollapseOnTabChange = true,
42
+ systemContext,
43
+ fallbackCapability,
44
+ onNavigate
40
45
  }) {
41
46
  const [open, setOpen] = (0, import_react.useState)(defaultOpen);
42
- const [pinned, setPinned] = (0, import_react.useState)(false);
47
+ const [pinned, setPinned] = (0, import_react.useState)(defaultPinned);
43
48
  const [sessions, setSessions] = (0, import_react.useState)({});
44
49
  const [reference, setReference] = (0, import_react.useState)(() => {
45
50
  var _a;
@@ -58,6 +63,14 @@ function AiAssistantProvider({
58
63
  tabsRef.current = tabs ?? [];
59
64
  const referenceRef = (0, import_react.useRef)(reference);
60
65
  referenceRef.current = reference;
66
+ const fallbackCapabilityRef = (0, import_react.useRef)(fallbackCapability);
67
+ fallbackCapabilityRef.current = fallbackCapability;
68
+ const systemContextRef = (0, import_react.useRef)(systemContext);
69
+ systemContextRef.current = systemContext;
70
+ const onNavigateRef = (0, import_react.useRef)(onNavigate);
71
+ onNavigateRef.current = onNavigate;
72
+ const autoCollapseRef = (0, import_react.useRef)(autoCollapseOnTabChange);
73
+ autoCollapseRef.current = autoCollapseOnTabChange;
61
74
  const engine = (0, import_react.useMemo)(() => {
62
75
  return new import_AiSessionEngine.AiSessionEngine({
63
76
  transport: transport ?? new import_MockAiTransport.MockAiTransport(),
@@ -68,10 +81,16 @@ function AiAssistantProvider({
68
81
  return void 0;
69
82
  const ref = referenceRef.current;
70
83
  if (!ref)
71
- return void 0;
72
- if (ref.tabKey === activeTabKeyRef.current)
73
- return capabilityRef.current;
84
+ return fallbackCapabilityRef.current;
85
+ if (ref.tabKey === activeTabKeyRef.current) {
86
+ return capabilityRef.current ?? fallbackCapabilityRef.current;
87
+ }
74
88
  return (_a = tabsRef.current.find((tab) => tab.key === ref.tabKey)) == null ? void 0 : _a.capability;
89
+ },
90
+ getSystemContext: () => systemContextRef.current,
91
+ onNavigate: (target) => {
92
+ var _a;
93
+ return (_a = onNavigateRef.current) == null ? void 0 : _a.call(onNavigateRef, target);
75
94
  }
76
95
  });
77
96
  }, []);
@@ -124,13 +143,18 @@ function AiAssistantProvider({
124
143
  mountedRef.current = true;
125
144
  return;
126
145
  }
127
- if (!pinnedRef.current)
128
- setOpen(false);
146
+ if (!autoCollapseRef.current || pinnedRef.current)
147
+ return;
148
+ setOpen(false);
129
149
  }, [activeTabKey]);
130
150
  const togglePin = (0, import_react.useCallback)(() => setPinned((value2) => !value2), []);
131
151
  const session = sessions[activeTabKey] ?? EMPTY_SESSION;
132
- const hasActions = Boolean((capability == null ? void 0 : capability.actions) && Object.keys(capability.actions).length > 0);
152
+ const actionCapability = capability ?? fallbackCapability;
153
+ const hasActions = Boolean(
154
+ (actionCapability == null ? void 0 : actionCapability.actions) && Object.keys(actionCapability.actions).length > 0
155
+ );
133
156
  const canRollback = hasActions ? engine.canRollback(activeTabKey) : false;
157
+ const canNavigate = Boolean(onNavigate);
134
158
  const value = (0, import_react.useMemo)(
135
159
  () => ({
136
160
  open,
@@ -147,6 +171,8 @@ function AiAssistantProvider({
147
171
  togglePin,
148
172
  send: (text) => engine.send(activeTabKey, text),
149
173
  confirmSuggestion: (suggestion) => engine.confirmSuggestion(activeTabKey, suggestion),
174
+ confirmNavigation: (navigation) => engine.confirmNavigation(activeTabKey, navigation),
175
+ canNavigate,
150
176
  rollback: () => engine.rollback(activeTabKey),
151
177
  validate: () => engine.validate(activeTabKey)
152
178
  }),
@@ -158,6 +184,7 @@ function AiAssistantProvider({
158
184
  capability,
159
185
  hasActions,
160
186
  canRollback,
187
+ canNavigate,
161
188
  reference,
162
189
  tabs,
163
190
  engine,
@@ -1,10 +1,14 @@
1
- import type { AiPageCapability, AiSession, AiSuggestion, AiTransport } from "./types";
1
+ import type { AiContext, AiNavigateTarget, AiNavigationSuggestion, AiPageCapability, AiSession, AiSuggestion, AiTransport } from "./types";
2
2
  /** 引擎选项 */
3
3
  export interface AiSessionEngineOptions {
4
4
  /** 流式传输(P1 mock / P2 SSE) */
5
5
  transport: AiTransport;
6
6
  /** 获取指定页签当前注册的能力契约(由 Provider 提供,返回 undefined 表示该页无契约) */
7
7
  getCapability: (tabKey: string) => AiPageCapability | undefined;
8
+ /** 系统级上下文:无页面契约时随请求发送(缺省不启用,避免改变既有 system 场景语义) */
9
+ getSystemContext?: () => AiContext | undefined;
10
+ /** 导航执行入口:用户点击导航卡片「前往」时调用(缺省不启用,卡片按钮不可用) */
11
+ onNavigate?: (target: AiNavigateTarget) => void;
8
12
  /** 版本栈深度,默认 10(超出丢弃最旧) */
9
13
  maxSnapshots?: number;
10
14
  /** 随请求发送的对话历史上限条数,默认 20(不含本轮消息) */
@@ -22,6 +26,8 @@ export declare class AiSessionEngine {
22
26
  private readonly listeners;
23
27
  private readonly transport;
24
28
  private readonly getCapability;
29
+ private readonly getSystemContext;
30
+ private readonly onNavigate;
25
31
  private readonly maxSnapshots;
26
32
  private readonly maxHistory;
27
33
  constructor(options: AiSessionEngineOptions);
@@ -33,6 +39,8 @@ export declare class AiSessionEngine {
33
39
  send(tabKey: string, text: string): void;
34
40
  /** 确认并回填:压栈快照 → 应用补丁 → 标记建议已应用 */
35
41
  confirmSuggestion(tabKey: string, suggestion: AiSuggestion): void;
42
+ /** 确认导航:仅在用户点击「前往」后执行(不压栈、不回填,未配置 onNavigate 时为空操作) */
43
+ confirmNavigation(tabKey: string, navigation: AiNavigationSuggestion): void;
36
44
  /** 撤回到上版:页面自管 rollback 优先,否则内置版本栈出栈并经 backfill 恢复 */
37
45
  rollback(tabKey: string): void;
38
46
  /** 核验表单/配置:报告以消息形式回显在对话流 */
@@ -52,6 +52,8 @@ var AiSessionEngine = class {
52
52
  this.listeners = /* @__PURE__ */ new Set();
53
53
  this.transport = options.transport;
54
54
  this.getCapability = options.getCapability;
55
+ this.getSystemContext = options.getSystemContext;
56
+ this.onNavigate = options.onNavigate;
55
57
  this.maxSnapshots = options.maxSnapshots ?? 10;
56
58
  this.maxHistory = options.maxHistory ?? 20;
57
59
  }
@@ -80,6 +82,7 @@ var AiSessionEngine = class {
80
82
  }
81
83
  /** 发送一轮对话:追加用户消息 + 流式占位助手消息,按帧更新 */
82
84
  send(tabKey, text) {
85
+ var _a;
83
86
  const trimmed = text.trim();
84
87
  if (!trimmed)
85
88
  return;
@@ -93,6 +96,13 @@ var AiSessionEngine = class {
93
96
  } catch {
94
97
  context = void 0;
95
98
  }
99
+ if (!context) {
100
+ try {
101
+ context = (_a = this.getSystemContext) == null ? void 0 : _a.call(this);
102
+ } catch {
103
+ context = void 0;
104
+ }
105
+ }
96
106
  const history = session.messages.filter((item) => item.content.trim().length > 0).slice(-this.maxHistory).map((item) => ({ role: item.role, content: item.content }));
97
107
  this.update(tabKey, {
98
108
  messages: [
@@ -129,15 +139,32 @@ var AiSessionEngine = class {
129
139
  }
130
140
  case "action": {
131
141
  if (isPlaceholder) {
132
- messages[messages.length - 1] = {
133
- ...last,
134
- suggestion: {
135
- type: "backfill",
136
- title: event.title ?? "建议草稿",
137
- items: event.items ?? [],
138
- patch: event.patch
139
- }
140
- };
142
+ if (event.actionType === "backfill") {
143
+ messages[messages.length - 1] = {
144
+ ...last,
145
+ suggestion: {
146
+ type: "backfill",
147
+ title: event.title ?? "建议草稿",
148
+ items: event.items ?? [],
149
+ patch: event.patch
150
+ }
151
+ };
152
+ } else if (event.actionType === "navigate") {
153
+ messages[messages.length - 1] = {
154
+ ...last,
155
+ navigation: {
156
+ type: "navigate",
157
+ title: event.title ?? "建议前往",
158
+ items: event.items ?? [],
159
+ target: event.target
160
+ }
161
+ };
162
+ } else {
163
+ console.warn(
164
+ "[AiSessionEngine] 未知 actionType,已忽略:",
165
+ event.actionType
166
+ );
167
+ }
141
168
  }
142
169
  this.update(tabKey, { messages });
143
170
  break;
@@ -235,6 +262,29 @@ ${reason}` : reason
235
262
  );
236
263
  this.update(tabKey, { snapshots, messages });
237
264
  }
265
+ /** 确认导航:仅在用户点击「前往」后执行(不压栈、不回填,未配置 onNavigate 时为空操作) */
266
+ confirmNavigation(tabKey, navigation) {
267
+ const navigate = this.onNavigate;
268
+ if (!navigate)
269
+ return;
270
+ try {
271
+ navigate(navigation.target);
272
+ } catch (error) {
273
+ console.error("[AiSessionEngine] onNavigate 执行失败:", error);
274
+ return;
275
+ }
276
+ const session = this.getSession(tabKey);
277
+ const messages = session.messages.map(
278
+ (message) => message.navigation === navigation ? { ...message, applied: true } : message
279
+ );
280
+ messages.push(
281
+ createMessage(
282
+ "assistant",
283
+ `已前往「${navigation.target.label ?? navigation.target.tabKey}」。`
284
+ )
285
+ );
286
+ this.update(tabKey, { messages });
287
+ }
238
288
  /** 撤回到上版:页面自管 rollback 优先,否则内置版本栈出栈并经 backfill 恢复 */
239
289
  rollback(tabKey) {
240
290
  var _a, _b;
@@ -1,6 +1,6 @@
1
1
  export * from "./AiActionGuard";
2
2
  export * from "./aiDraft";
3
- export type { AiContext, AiMessage, AiMessageRole, AiPageActions, AiPageCapability, AiReference, AiReferenceTab, AiSession, AiSnapshot, AiStreamEvent, AiSuggestion, AiToolCallStatus, AiToolCallView, AiTransport, AiValidateIssue, AiValidateReport, FormPatch, } from "./types";
3
+ export type { AiContext, AiMessage, AiMessageRole, AiNavigateTarget, AiNavigationSuggestion, AiPageActions, AiPageCapability, AiReference, AiReferenceTab, AiSession, AiSnapshot, AiStreamEvent, AiSuggestion, AiToolCallStatus, AiToolCallView, AiTransport, AiValidateIssue, AiValidateReport, FormPatch, } from "./types";
4
4
  export { AiSessionEngine } from "./AiSessionEngine";
5
5
  export type { AiSessionEngineOptions } from "./AiSessionEngine";
6
6
  export { MockAiTransport } from "./MockAiTransport";
@@ -74,6 +74,26 @@ export interface AiSuggestion {
74
74
  /** 补丁数据:确认后传给 actions.backfill */
75
75
  patch: FormPatch;
76
76
  }
77
+ /** 导航目标(navigate 动作帧携带,由布局侧 onNavigate 执行) */
78
+ export interface AiNavigateTarget {
79
+ /** 目标页签 key(对应布局页签体系) */
80
+ tabKey: string;
81
+ /** 目标页签显示名(卡片与提示文案) */
82
+ label?: string;
83
+ /** 附加参数(菜单参数、路由 query 等,原样透传给 onNavigate) */
84
+ params?: Record<string, unknown>;
85
+ }
86
+ /** 结构化导航建议(navigate 帧携带,用户点击「前往」后才执行) */
87
+ export interface AiNavigationSuggestion {
88
+ /** 建议类型 */
89
+ type: "navigate";
90
+ /** 卡片标题(如「建议前往订单中心」) */
91
+ title: string;
92
+ /** 摘要行(目标说明) */
93
+ items: string[];
94
+ /** 导航目标 */
95
+ target: AiNavigateTarget;
96
+ }
77
97
  /** 工具调用状态 */
78
98
  export type AiToolCallStatus = "pending" | "running" | "succeeded" | "failed" | "skipped";
79
99
  /** 工具调用视图(tool 帧按 callId 归并后的展示结构;面板受控渲染) */
@@ -99,7 +119,9 @@ export interface AiMessage {
99
119
  reasoning?: string;
100
120
  /** 携带的结构化建议(仅 assistant 消息) */
101
121
  suggestion?: AiSuggestion;
102
- /** 建议是否已确认回填(已确认后芯片置为已完成态) */
122
+ /** 携带的导航建议(navigate 帧;用户点击「前往」后才执行) */
123
+ navigation?: AiNavigationSuggestion;
124
+ /** 建议(回填或导航)是否已确认(已确认后卡片置为已完成态;导航仍需用户点击才执行) */
103
125
  applied?: boolean;
104
126
  /** 本轮工具调用(tool 帧按 callId 归并;仅 assistant 消息) */
105
127
  toolCalls?: AiToolCallView[];
@@ -139,6 +161,13 @@ export type AiStreamEvent = {
139
161
  patch: FormPatch;
140
162
  title?: string;
141
163
  items?: string[];
164
+ } | {
165
+ type: "action";
166
+ actionType: "navigate";
167
+ /** 导航目标(仅渲染确认卡片,用户点击后才执行) */
168
+ target: AiNavigateTarget;
169
+ title?: string;
170
+ items?: string[];
142
171
  } | {
143
172
  type: "tool";
144
173
  /** 调用唯一标识(同一 callId 多帧归并为一次调用,后帧覆盖状态与结果) */
@@ -39,10 +39,10 @@ var CompanyFormComponent = ({
39
39
  style,
40
40
  ...restProps
41
41
  }) => {
42
- const mergedStyle = {
42
+ const mergedStyle = layout === "horizontal" ? {
43
43
  ["--company-label-max-width"]: `${labelMaxWidth}em`,
44
44
  ...style
45
- };
45
+ } : { ...style };
46
46
  const mergedRequiredMark = requiredMark !== void 0 ? requiredMark : layout === "vertical" ? requiredMarkRight : true;
47
47
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.ConfigProvider, { theme: import_theme.companyTheme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
48
48
  import_antd.Form,
@@ -9,12 +9,13 @@
9
9
  width: 100%;
10
10
  }
11
11
 
12
- .ant-form-item-label.ant-form-item-label {
12
+ // 仅左右布局限制标签列宽度;上下布局标签独占整行,长标签不换行
13
+ .ant-form-item-horizontal .ant-form-item-label.ant-form-item-label {
13
14
  width: var(--company-label-max-width);
14
15
  flex-shrink: 0;
15
16
  }
16
17
 
17
- .ant-form-item-label > label {
18
+ .ant-form-item-horizontal .ant-form-item-label > label {
18
19
  justify-content: flex-end;
19
20
  white-space: normal;
20
21
  word-break: break-word;
@@ -1,5 +1,5 @@
1
1
  import { type CSSProperties } from "react";
2
- import type { AiMessage, AiReference, AiReferenceTab, AiSuggestion, AiToolCallView } from "../../ai-assistant/types";
2
+ import type { AiMessage, AiNavigationSuggestion, AiReference, AiReferenceTab, AiSuggestion, AiToolCallView } from "../../ai-assistant/types";
3
3
  import "./index.scss";
4
4
  export interface CompanyAiAssistantProps {
5
5
  /** 消息列表(含流式累积中的消息) */
@@ -30,6 +30,8 @@ export interface CompanyAiAssistantProps {
30
30
  onClose?: () => void;
31
31
  /** 确认并回填(参数为最近一条待确认建议) */
32
32
  onBackfill?: (suggestion: AiSuggestion) => void;
33
+ /** 确认导航(用户点击导航卡片「前往」后触发;缺省时按钮禁用) */
34
+ onNavigate?: (navigation: AiNavigationSuggestion) => void;
33
35
  /** 撤回到上版 */
34
36
  onRollback?: () => void;
35
37
  /** 核验表单 */
@@ -61,6 +61,29 @@ function SuggestionCard({
61
61
  )
62
62
  ] });
63
63
  }
64
+ function NavigationCard({
65
+ navigation,
66
+ applied,
67
+ onConfirm
68
+ }) {
69
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-ai-assistant__card", children: [
70
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "company-ai-assistant__card-title", children: navigation.title }),
71
+ navigation.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "company-ai-assistant__card-items", children: navigation.items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: item }, `${navigation.title}-${index}`)) }),
72
+ applied ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "company-ai-assistant__card-done", children: "已前往" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
73
+ "button",
74
+ {
75
+ type: "button",
76
+ className: "company-ai-assistant__card-confirm",
77
+ disabled: !onConfirm,
78
+ onClick: () => onConfirm == null ? void 0 : onConfirm(navigation),
79
+ children: [
80
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SvgIcon.default, { name: "right", size: 12 }),
81
+ "前往"
82
+ ]
83
+ }
84
+ )
85
+ ] });
86
+ }
64
87
  function ActionChip({
65
88
  icon,
66
89
  label,
@@ -152,6 +175,7 @@ function AssistantPanel({
152
175
  onPinToggle,
153
176
  onClose,
154
177
  onBackfill,
178
+ onNavigate,
155
179
  onRollback,
156
180
  onValidate,
157
181
  placeholder = "请输入",
@@ -265,7 +289,7 @@ function AssistantPanel({
265
289
  toolCalls && toolCalls.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolCallChain, { toolCalls }),
266
290
  messages.map((message) => {
267
291
  const isThinking = streaming && message.role === "assistant" && !message.content;
268
- const isStreamingTail = isThinking && !message.reasoning && !message.suggestion;
292
+ const isStreamingTail = isThinking && !message.reasoning && !message.suggestion && !message.navigation;
269
293
  const messageToolCalls = (toolCalls == null ? void 0 : toolCalls.length) ? void 0 : message.toolCalls;
270
294
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
271
295
  "div",
@@ -295,6 +319,14 @@ function AssistantPanel({
295
319
  applied: message.applied,
296
320
  onConfirm: onBackfill
297
321
  }
322
+ ),
323
+ message.navigation && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
324
+ NavigationCard,
325
+ {
326
+ navigation: message.navigation,
327
+ applied: message.applied,
328
+ onConfirm: onNavigate
329
+ }
298
330
  )
299
331
  ] })
300
332
  },
@@ -214,6 +214,11 @@
214
214
  &:hover {
215
215
  opacity: 0.85;
216
216
  }
217
+
218
+ &:disabled {
219
+ cursor: not-allowed;
220
+ opacity: 0.45;
221
+ }
217
222
  }
218
223
 
219
224
  &__card-done {
@@ -0,0 +1,23 @@
1
+ import type { TableColumnsType } from "antd";
2
+ import type { ReactNode } from "react";
3
+ export type TableSize = "small" | "middle" | "large";
4
+ /** 表格密度对应的纵向单元格内边距(宽松 / 默认 / 紧凑) */
5
+ export declare const DENSITY_CELL_PADDING: Record<TableSize, number>;
6
+ /** 单元格统一横向内边距 */
7
+ export declare const TABLE_CELL_INLINE_PADDING = 16;
8
+ /** 操作列默认宽度 */
9
+ export declare const ACTION_COLUMN_WIDTH = 148;
10
+ interface ActionColumnOptions<T> {
11
+ /** 列标题,默认「操作」 */
12
+ title?: string;
13
+ /** 列宽,默认 148 */
14
+ width?: number;
15
+ /** 单元格渲染函数 */
16
+ render?: (record: T, index: number) => ReactNode;
17
+ }
18
+ /**
19
+ * 生成统一的操作列配置(固定右侧、左对齐、表头文案与按钮文字对齐)。
20
+ * SmartListTemplate 与 StatisticsListPage 共用同一份配置,避免两侧操作列漂移。
21
+ */
22
+ export declare function createActionColumn<T extends Record<string, unknown>>(options?: ActionColumnOptions<T>): TableColumnsType<T>[number];
23
+ export {};
@@ -0,0 +1,55 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/shared-components/tableActionColumn.ts
20
+ var tableActionColumn_exports = {};
21
+ __export(tableActionColumn_exports, {
22
+ ACTION_COLUMN_WIDTH: () => ACTION_COLUMN_WIDTH,
23
+ DENSITY_CELL_PADDING: () => DENSITY_CELL_PADDING,
24
+ TABLE_CELL_INLINE_PADDING: () => TABLE_CELL_INLINE_PADDING,
25
+ createActionColumn: () => createActionColumn
26
+ });
27
+ module.exports = __toCommonJS(tableActionColumn_exports);
28
+ var DENSITY_CELL_PADDING = {
29
+ large: 11,
30
+ middle: 7,
31
+ small: 3
32
+ };
33
+ var TABLE_CELL_INLINE_PADDING = 16;
34
+ var ACTION_COLUMN_WIDTH = 148;
35
+ var ACTION_COLUMN_HEADER_STYLE = { paddingLeft: 24, paddingRight: 16 };
36
+ function createActionColumn(options = {}) {
37
+ const { title = "操作", width = ACTION_COLUMN_WIDTH, render } = options;
38
+ return {
39
+ title,
40
+ dataIndex: "action",
41
+ key: "action",
42
+ width,
43
+ fixed: "right",
44
+ align: "left",
45
+ onHeaderCell: () => ({ style: { ...ACTION_COLUMN_HEADER_STYLE } }),
46
+ render: render ? (_, record, index) => render(record, index) : void 0
47
+ };
48
+ }
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ ACTION_COLUMN_WIDTH,
52
+ DENSITY_CELL_PADDING,
53
+ TABLE_CELL_INLINE_PADDING,
54
+ createActionColumn
55
+ });
@@ -151,6 +151,8 @@ var AiAsideBody = (0, import_react.memo)(function AiAsideBody2() {
151
151
  togglePin,
152
152
  send,
153
153
  confirmSuggestion,
154
+ confirmNavigation,
155
+ canNavigate,
154
156
  rollback,
155
157
  validate,
156
158
  reference,
@@ -182,6 +184,7 @@ var AiAsideBody = (0, import_react.memo)(function AiAsideBody2() {
182
184
  onPinToggle: togglePin,
183
185
  onClose: () => setOpen(false),
184
186
  onBackfill: confirmSuggestion,
187
+ onNavigate: canNavigate ? confirmNavigation : void 0,
185
188
  onRollback: rollback,
186
189
  onValidate: validate
187
190
  }
@@ -745,6 +748,7 @@ function AdminLayoutTemplate({
745
748
  capability: aiCapability,
746
749
  transport: aiTransport,
747
750
  defaultOpen: aiAssistantDefaultOpen,
751
+ onNavigate: (target) => openTab(target.tabKey, target.label ?? target.tabKey),
748
752
  children: tree
749
753
  }
750
754
  ) : tree;
@@ -88,6 +88,8 @@ function DockBody({ children, width = 375, className, style }) {
88
88
  togglePin,
89
89
  send,
90
90
  confirmSuggestion,
91
+ confirmNavigation,
92
+ canNavigate,
91
93
  rollback,
92
94
  validate
93
95
  } = (0, import_AiAssistantProvider.useAiAssistantContext)();
@@ -122,6 +124,7 @@ function DockBody({ children, width = 375, className, style }) {
122
124
  onPinToggle: togglePin,
123
125
  onClose: () => setOpen(false),
124
126
  onBackfill: confirmSuggestion,
127
+ onNavigate: canNavigate ? confirmNavigation : void 0,
125
128
  onRollback: rollback,
126
129
  onValidate: validate
127
130
  }
@@ -38,6 +38,7 @@ var import_antd = require("antd");
38
38
  var import_zh_CN = __toESM(require("antd/locale/zh_CN"));
39
39
  var import_FilterForm = __toESM(require("../FilterForm"));
40
40
  var import_shared_components = require("../../shared-components");
41
+ var import_tableActionColumn = require("../../shared-components/tableActionColumn");
41
42
  var import_ColumnSettingsPanel = __toESM(require("../ColumnSettingsPanel"));
42
43
  var import_index = require("./index.scss");
43
44
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -120,12 +121,7 @@ function SmartListTemplate({
120
121
  middle: "默认",
121
122
  large: "宽松"
122
123
  };
123
- const densityPadding = {
124
- large: 11,
125
- middle: 7,
126
- small: 3
127
- };
128
- const currentPadding = densityPadding[effectiveTableSize];
124
+ const currentPadding = import_tableActionColumn.DENSITY_CELL_PADDING[effectiveTableSize];
129
125
  const handleSizeChange = (0, import_react.useCallback)(
130
126
  (newSize) => {
131
127
  if (onSizeChange) {
@@ -282,22 +278,18 @@ function SmartListTemplate({
282
278
  };
283
279
  });
284
280
  if (actionField) {
285
- regularColumns.push({
286
- title: "操作",
287
- dataIndex: actionField.key,
288
- key: "action",
289
- width: actionField.width || 148,
290
- fixed: "right",
291
- align: "left",
292
- onHeaderCell: () => ({ style: { paddingLeft: 24, paddingRight: 16 } }),
293
- render: bodyCell ? (_, record) => {
294
- const result = bodyCell(
295
- { ...actionField, key: actionField.key },
296
- record
297
- );
298
- return result !== null ? result : record[actionField.key];
299
- } : void 0
300
- });
281
+ regularColumns.push(
282
+ (0, import_tableActionColumn.createActionColumn)({
283
+ width: actionField.width || 148,
284
+ render: bodyCell ? (record) => {
285
+ const result = bodyCell(
286
+ { ...actionField, key: actionField.key },
287
+ record
288
+ );
289
+ return result !== null ? result : record[actionField.key];
290
+ } : void 0
291
+ })
292
+ );
301
293
  }
302
294
  return regularColumns;
303
295
  }, [fields, bodyCell, columnFields]);
@@ -821,9 +813,9 @@ function SmartListTemplate({
821
813
  size: effectiveTableSize,
822
814
  cellPaddingBlockMD: currentPadding,
823
815
  cellPaddingBlockSM: currentPadding,
824
- cellPaddingInline: 16,
825
- cellPaddingInlineMD: 16,
826
- cellPaddingInlineSM: 16,
816
+ cellPaddingInline: import_tableActionColumn.TABLE_CELL_INLINE_PADDING,
817
+ cellPaddingInlineMD: import_tableActionColumn.TABLE_CELL_INLINE_PADDING,
818
+ cellPaddingInlineSM: import_tableActionColumn.TABLE_CELL_INLINE_PADDING,
827
819
  rowSelection,
828
820
  rowKey,
829
821
  childrenColumnName: (treeConfig == null ? void 0 : treeConfig.enabled) ? treeConfig.childrenColumnName || "children" : void 0,