@ibiz-template/vue3-components 0.7.41-alpha.166 → 0.7.41-alpha.168

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.
@@ -4,8 +4,10 @@ var vue = require('vue');
4
4
  var qxUtil = require('qx-util');
5
5
  var runtime = require('@ibiz-template/runtime');
6
6
  var core = require('@ibiz-template/core');
7
+ var vue3Util = require('@ibiz-template/vue3-util');
7
8
  var ramda = require('ramda');
8
9
  var aiFeedback = require('./ai-feedback/ai-feedback.cjs');
10
+ var asyncAction_provider = require('../../panel-component/user-message/async-action/async-action/async-action.provider.cjs');
9
11
 
10
12
  "use strict";
11
13
  var __defProp = Object.defineProperty;
@@ -15,7 +17,13 @@ var __publicField = (obj, key, value) => {
15
17
  return value;
16
18
  };
17
19
  class AIChatUtil {
18
- constructor() {
20
+ /**
21
+ * Creates an instance of AIChatUtil.
22
+ * @param {App} App vue App
23
+ * @memberof AIChatUtil
24
+ */
25
+ constructor(App2) {
26
+ this.App = App2;
19
27
  __publicField(this, "TOPIC_CHAT_PREFIX", "topic");
20
28
  __publicField(this, "INLINE_CHAT_SUFFIX", "inline");
21
29
  __publicField(this, "TEMP_CHAT_SUFFIX", "temp");
@@ -23,10 +31,19 @@ class AIChatUtil {
23
31
  __publicField(this, "PRE_ERROR_MESSAGE", "Expected content-type to be text/event-stream, Actual: application/json;charset=UTF-8");
24
32
  // 无流内容回来
25
33
  __publicField(this, "NONE_ERROR_MESSAGE", "Expected content-type to be text/event-stream, Actual: null");
26
- // 网络中断自动续传的最大重试次数
27
- __publicField(this, "AUTO_RESUME_MAX_RETRY", 3);
28
- // 网络中断自动续传的退避基数(毫秒),按 1s/2s/4s 指数退避
29
- __publicField(this, "AUTO_RESUME_BACKOFF_BASE", 1e3);
34
+ // 各 asyncActionID 对应的回调集合(同一 ID 可能被多处注册不同回调),回调入参为最新异步作业对象
35
+ __publicField(this, "asyncActionCallBackMap", /* @__PURE__ */ new Map());
36
+ ibiz.mc.command.asyncAction.on((msg) => {
37
+ if (!msg.data || msg.subtype !== "ASYNCACTION")
38
+ return;
39
+ const action = msg.data;
40
+ if (action.actiontype === "ASYNCCHATCOMPLETION")
41
+ return;
42
+ const callbacks = this.asyncActionCallBackMap.get(action.asyncacitonid);
43
+ if (callbacks) {
44
+ callbacks.forEach((cb) => cb(action));
45
+ }
46
+ });
30
47
  }
31
48
  /**
32
49
  * @description 创建 AI 聊天 SSE 流式消息处理回调(提问与恢复会话共用)
@@ -95,7 +112,7 @@ class AIChatUtil {
95
112
  };
96
113
  }
97
114
  /**
98
- * @description 网络中断(network error)后按 asyncacitonid 自动续传,指数退避重试;成功返回 true,不可恢复/重试耗尽返回 false 交回调用方走既有错误处理
115
+ * @description 网络中断(network error)后按 asyncacitonid 自动续传一次;成功返回 true,失败返回 false 交回调用方走既有错误处理
99
116
  * @param {any} aiChat 单实例聊天总控
100
117
  * @param {IContext} ctx 上下文
101
118
  * @param {IParams} param 视图参数
@@ -107,49 +124,40 @@ class AIChatUtil {
107
124
  * @memberof AIChatUtil
108
125
  */
109
126
  async autoResumeChat(aiChat, ctx, param, deService, state, resumeInfo, onMsg) {
110
- var _a;
127
+ var _a, _b;
111
128
  (_a = state.abortController) == null ? void 0 : _a.abort();
112
129
  state.abortController = new AbortController();
113
- for (let attempt = 1; attempt <= this.AUTO_RESUME_MAX_RETRY; attempt++) {
114
- try {
115
- await new Promise((resolve) => {
116
- setTimeout(
117
- resolve,
118
- this.AUTO_RESUME_BACKOFF_BASE * 2 ** (attempt - 1)
119
- );
120
- });
121
- const resumeRequestData = {
122
- asyncacitonid: resumeInfo.asyncacitonid
123
- };
124
- if (resumeInfo.sessionid) {
125
- resumeRequestData.sessionid = resumeInfo.sessionid;
126
- }
127
- if (resumeInfo.srfaiagent) {
128
- resumeRequestData.srfaiagent = resumeInfo.srfaiagent;
129
- }
130
- if (resumeInfo.srfproject) {
131
- resumeRequestData.srfproject = resumeInfo.srfproject;
132
- }
133
- await deService.aiResumeSse(
134
- onMsg,
135
- state.abortController,
136
- ctx,
137
- { srfactag: param.srfactag },
138
- { ...resumeRequestData }
139
- );
140
- return true;
141
- } catch (resumeError) {
142
- const resumeMsg = (resumeError == null ? void 0 : resumeError.message) || "";
143
- if ((resumeError == null ? void 0 : resumeError.name) === "AbortError") {
144
- return false;
145
- }
146
- if (resumeMsg === this.NONE_ERROR_MESSAGE) {
147
- aiChat.setActiveAsyncacitonId("");
148
- return false;
149
- }
130
+ try {
131
+ const resumeRequestData = {
132
+ asyncacitonid: resumeInfo.asyncacitonid
133
+ };
134
+ if (resumeInfo.sessionid) {
135
+ resumeRequestData.sessionid = resumeInfo.sessionid;
150
136
  }
137
+ if (resumeInfo.srfaiagent) {
138
+ resumeRequestData.srfaiagent = resumeInfo.srfaiagent;
139
+ }
140
+ if (resumeInfo.srfproject) {
141
+ resumeRequestData.srfproject = resumeInfo.srfproject;
142
+ }
143
+ await deService.aiResumeSse(
144
+ onMsg,
145
+ state.abortController,
146
+ ctx,
147
+ { srfactag: param.srfactag },
148
+ { ...resumeRequestData }
149
+ );
150
+ return true;
151
+ } catch (resumeError) {
152
+ if ((resumeError == null ? void 0 : resumeError.name) === "AbortError") {
153
+ return false;
154
+ }
155
+ (_b = state.abortController) == null ? void 0 : _b.abort();
156
+ if ((resumeError == null ? void 0 : resumeError.message) === this.NONE_ERROR_MESSAGE) {
157
+ aiChat.setActiveAsyncacitonId("");
158
+ }
159
+ return false;
151
160
  }
152
- return false;
153
161
  }
154
162
  /**
155
163
  * 获取AI聊天对象
@@ -335,6 +343,7 @@ class AIChatUtil {
335
343
  locale: ibiz.i18n.getLang(),
336
344
  enableAIProject: editorParams.srfenableaiprojectselect ? editorParams.srfenableaiprojectselect === "true" : ibiz.config.common.enableAIProjectSelect,
337
345
  projectSelectPlaceholder: editorParams.srfprojectselectplaceholder || ibiz.config.common.aiProjectSelectPlaceholder,
346
+ knowledgeBaseView: editorParams.srfaiknowledgebaseview || ibiz.config.common.aiKnowledgeBaseView,
338
347
  selectAIProjectId: editorParams.srfselectaiprojectid
339
348
  };
340
349
  if (editorParams.srfaiappendcurdata) {
@@ -453,6 +462,7 @@ class AIChatUtil {
453
462
  editorParams
454
463
  );
455
464
  };
465
+ chatOptions.openEmbedView = this.openEmbedView.bind(this);
456
466
  chatOptions.fetchKnowledgeBaseList = (args2 = {}) => {
457
467
  return this.getKnowledgeBaseList(context, params, editorParams, args2);
458
468
  };
@@ -486,6 +496,7 @@ class AIChatUtil {
486
496
  }
487
497
  const fileSystemOptions = await this.getAIFileSystemOptions(filePreviewMode);
488
498
  chatOptions.fileSystemOptions = fileSystemOptions;
499
+ chatOptions.asyncActionOptions = await this.getAIAsyncActionOptions();
489
500
  chatOptions.history = async (ctx, param, other) => {
490
501
  const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
491
502
  const historyRequestData = {};
@@ -1083,8 +1094,11 @@ class AIChatUtil {
1083
1094
  locale: ibiz.i18n.getLang(),
1084
1095
  enableAIProject: params.srfenableaiprojectselect ? params.srfenableaiprojectselect === "true" : ibiz.config.common.enableAIProjectSelect,
1085
1096
  projectSelectPlaceholder: params.srfprojectselectplaceholder || ibiz.config.common.aiProjectSelectPlaceholder,
1097
+ knowledgeBaseView: params.srfaiknowledgebaseview || ibiz.config.common.aiKnowledgeBaseView,
1086
1098
  selectAIProjectId: params.srfselectaiprojectid
1087
1099
  };
1100
+ if (params.hasOwnProperty("srfaiknowledgebaseview"))
1101
+ delete params.srfaiknowledgebaseview;
1088
1102
  if (params.hasOwnProperty("srfselectaiprojectid"))
1089
1103
  delete params.srfselectaiprojectid;
1090
1104
  if (params.hasOwnProperty("srfenableaiprojectselect"))
@@ -1227,6 +1241,7 @@ class AIChatUtil {
1227
1241
  } else {
1228
1242
  chatOptions.enableWorkSpace = ibiz.config.common.aiEnableWorkSpace;
1229
1243
  }
1244
+ chatOptions.openEmbedView = this.openEmbedView.bind(this);
1230
1245
  chatOptions.fetchAgentList = (args2 = {}) => {
1231
1246
  const { query, agentid } = args2;
1232
1247
  return this.getAIAgentList(context, {
@@ -1267,6 +1282,7 @@ class AIChatUtil {
1267
1282
  }
1268
1283
  const fileSystemOptions = await this.getAIFileSystemOptions(filePreviewMode);
1269
1284
  chatOptions.fileSystemOptions = fileSystemOptions;
1285
+ chatOptions.asyncActionOptions = await this.getAIAsyncActionOptions();
1270
1286
  chatOptions.history = async (ctx, param, other) => {
1271
1287
  const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
1272
1288
  const historyRequestData = {};
@@ -2204,6 +2220,77 @@ class AIChatUtil {
2204
2220
  };
2205
2221
  return fileSystemOptions;
2206
2222
  }
2223
+ /**
2224
+ * @description 打开嵌入视图
2225
+ * @private
2226
+ * @param {IContext} context 上下文
2227
+ * @param {IParams} params 视图参数
2228
+ * @param {string} viewId 视图标识
2229
+ * @param {HTMLElement} container 视图挂载容器
2230
+ * @param {IData[]} [selectedData] 选中数据
2231
+ * @param {(result: IModalData) => void} [callback] 回调
2232
+ * @returns {*} {Promise<void>}
2233
+ * @memberof AIChatUtil
2234
+ */
2235
+ async openEmbedView(context, params, viewId, container, selectedData, callback) {
2236
+ const unmount = (result = { ok: false }) => {
2237
+ callback == null ? void 0 : callback(result);
2238
+ vue.render(null, container);
2239
+ };
2240
+ const modal = new runtime.Modal({
2241
+ mode: runtime.ViewMode.EMBED,
2242
+ viewUsage: 2,
2243
+ dismiss: (result) => unmount(result)
2244
+ });
2245
+ const modelData = await ibiz.hub.getAppView(viewId);
2246
+ const vNode = vue.createVNode(vue3Util.IBizViewShell, {
2247
+ modal,
2248
+ modelData,
2249
+ context,
2250
+ params: { ...params, checkstrictly: true },
2251
+ state: { selectedData }
2252
+ });
2253
+ vNode.appContext = this.App._context;
2254
+ vue.render(vNode, container);
2255
+ return {
2256
+ width: modelData.width,
2257
+ height: modelData.height,
2258
+ unmount
2259
+ };
2260
+ }
2261
+ /**
2262
+ * @description 获取异步行为配置
2263
+ * @returns {*} {Promise<IData>}
2264
+ * @memberof AIChatUtil
2265
+ */
2266
+ async getAIAsyncActionOptions() {
2267
+ const asyncActionOptions = {};
2268
+ asyncActionOptions.getLastAsyncAction = async (asyncActionID) => {
2269
+ const result = await ibiz.hub.notice.asyncAction.service.get(asyncActionID);
2270
+ if (result.ok && result.data) {
2271
+ return result.data;
2272
+ }
2273
+ return null;
2274
+ };
2275
+ asyncActionOptions.registerCallBack = (asyncActionID, callback) => {
2276
+ let callbacks = this.asyncActionCallBackMap.get(asyncActionID);
2277
+ if (!callbacks) {
2278
+ callbacks = /* @__PURE__ */ new Set();
2279
+ this.asyncActionCallBackMap.set(asyncActionID, callbacks);
2280
+ }
2281
+ callbacks.add(callback);
2282
+ return () => {
2283
+ callbacks.delete(callback);
2284
+ if (!callbacks.size) {
2285
+ this.asyncActionCallBackMap.delete(asyncActionID);
2286
+ }
2287
+ };
2288
+ };
2289
+ asyncActionOptions.onPreview = async (asyncAction, _event) => {
2290
+ return asyncAction_provider.openAsyncActionModal(asyncAction);
2291
+ };
2292
+ return asyncActionOptions;
2293
+ }
2207
2294
  }
2208
2295
 
2209
2296
  exports.AIChatUtil = AIChatUtil;
@@ -91,7 +91,7 @@ async function runApp(plugins, opts) {
91
91
  ibiz.overlay = new overlayController.OverlayController();
92
92
  ibiz.inLineAIUtil = new inlineAiUtil.InLineAIUtil();
93
93
  ibiz.screenShotUtil = new screenShotUtil.ScreenShotUtil();
94
- ibiz.aiChatUtil = new aiChatUtil.AIChatUtil();
94
+ ibiz.aiChatUtil = new aiChatUtil.AIChatUtil(app);
95
95
  ibiz.util.text.format = (value, code) => {
96
96
  return app.config.globalProperties.$textFormat(value, code);
97
97
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template/vue3-components",
3
- "version": "0.7.41-alpha.166",
3
+ "version": "0.7.41-alpha.168",
4
4
  "description": "web端组件库(vue3)",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "es/index.mjs",
@@ -31,16 +31,16 @@
31
31
  "dependencies": {
32
32
  "@amap/amap-jsapi-loader": "^1.0.1",
33
33
  "@floating-ui/dom": "^1.5.3",
34
- "@ibiz-template-plugin/ai-chat": "^0.0.133",
34
+ "@ibiz-template-plugin/ai-chat": "^0.0.135",
35
35
  "@ibiz-template-plugin/gantt": "0.1.8-alpha.468",
36
36
  "@ibiz-template-plugin/bi-report": "0.0.32",
37
37
  "@ibiz-template-plugin/data-view": "0.0.8",
38
38
  "@ibiz-template/core": "0.7.41-alpha.152",
39
39
  "@ibiz-template/devtool": "0.0.18",
40
- "@ibiz-template/model-helper": "0.7.41-alpha.157",
41
- "@ibiz-template/runtime": "0.7.41-alpha.157",
40
+ "@ibiz-template/model-helper": "0.7.41-alpha.158",
41
+ "@ibiz-template/runtime": "0.7.41-alpha.158",
42
42
  "@ibiz-template/theme": "0.7.39",
43
- "@ibiz-template/vue3-util": "0.7.41-alpha.157",
43
+ "@ibiz-template/vue3-util": "0.7.41-alpha.158",
44
44
  "@ibiz-template/web-theme": "3.16.0",
45
45
  "@ibiz/model-core": "^0.1.89",
46
46
  "@imengyu/vue3-context-menu": "^1.3.5",
@@ -7,6 +7,63 @@ import { AsyncActionResult } from '../async-action-result/async-action-result';
7
7
  import { AsyncDataExport } from '../async-data-export/async-data-export';
8
8
  import { AsyncAction } from './async-action';
9
9
 
10
+ /**
11
+ * 打开异步作业详情弹窗,按作业类型选择对应展示组件
12
+ * @author zk
13
+ * @date 2026-11-19
14
+ * @param {IPortalAsyncAction} asyncAction
15
+ * @return {*} {boolean} 是否打开了弹窗
16
+ */
17
+ export async function openAsyncActionModal(
18
+ asyncAction: IPortalAsyncAction,
19
+ ): Promise<boolean> {
20
+ if (
21
+ isNil(asyncAction.actiontype) ||
22
+ asyncAction.actiontype === 'asyncaction'
23
+ ) {
24
+ ibiz.overlay.modal(
25
+ (modal: IModal) => {
26
+ return h(AsyncActionResult, {
27
+ asyncAction,
28
+ modal,
29
+ });
30
+ },
31
+ {},
32
+ { width: '80%', height: '80%' },
33
+ );
34
+ return true;
35
+ }
36
+ // 导出数据
37
+ if (asyncAction.actiontype === 'DEEXPORTDATA') {
38
+ ibiz.overlay.modal(
39
+ (modal: IModal) => {
40
+ return h(AsyncDataExport, {
41
+ asyncAction,
42
+ modal,
43
+ });
44
+ },
45
+ {},
46
+ { width: '80%', height: '80%' },
47
+ );
48
+ return true;
49
+ }
50
+ // 导入数据,actionresult有值且是对象时才能打开详情页面
51
+ if (isObject(asyncAction.actionresult)) {
52
+ ibiz.overlay.modal(
53
+ (modal: IModal) => {
54
+ return h(AsyncActionPreview, {
55
+ asyncAction,
56
+ modal,
57
+ });
58
+ },
59
+ {},
60
+ { width: '80%', height: '80%' },
61
+ );
62
+ return true;
63
+ }
64
+ return false;
65
+ }
66
+
10
67
  export class AsyncActionProvider implements IAsyncActionProvider {
11
68
  component = AsyncAction;
12
69
 
@@ -21,47 +78,6 @@ export class AsyncActionProvider implements IAsyncActionProvider {
21
78
  asyncAction: IPortalAsyncAction,
22
79
  _event: MouseEvent,
23
80
  ): Promise<boolean> {
24
- if (isNil(asyncAction.actiontype)) {
25
- ibiz.overlay.modal(
26
- (modal: IModal) => {
27
- return h(AsyncActionResult, {
28
- asyncAction,
29
- modal,
30
- });
31
- },
32
- {},
33
- { width: '80%', height: '80%' },
34
- );
35
- return true;
36
- }
37
- // 导出数据
38
- if (asyncAction.actiontype === 'DEEXPORTDATA') {
39
- ibiz.overlay.modal(
40
- (modal: IModal) => {
41
- return h(AsyncDataExport, {
42
- asyncAction,
43
- modal,
44
- });
45
- },
46
- {},
47
- { width: '80%', height: '80%' },
48
- );
49
- return true;
50
- }
51
- // 导入数据,actionresult有值且是对象时才能打开详情页面
52
- if (isObject(asyncAction.actionresult)) {
53
- ibiz.overlay.modal(
54
- (modal: IModal) => {
55
- return h(AsyncActionPreview, {
56
- asyncAction,
57
- modal,
58
- });
59
- },
60
- {},
61
- { width: '80%', height: '80%' },
62
- );
63
- return true;
64
- }
65
- return false;
81
+ return openAsyncActionModal(asyncAction);
66
82
  }
67
83
  }