@ibiz-template/vue3-components 0.7.41-alpha.167 → 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.
@@ -460,16 +460,7 @@ class AIChatUtil {
460
460
  editorParams
461
461
  );
462
462
  };
463
- chatOptions.openEmbedView = async (ctx, param, viewId, container, selectedData, callback) => {
464
- await this.openEmbedView(
465
- ctx,
466
- param,
467
- viewId,
468
- container,
469
- selectedData,
470
- callback
471
- );
472
- };
463
+ chatOptions.openEmbedView = this.openEmbedView.bind(this);
473
464
  chatOptions.fetchKnowledgeBaseList = (args2 = {}) => {
474
465
  return this.getKnowledgeBaseList(context, params, editorParams, args2);
475
466
  };
@@ -1248,16 +1239,7 @@ class AIChatUtil {
1248
1239
  } else {
1249
1240
  chatOptions.enableWorkSpace = ibiz.config.common.aiEnableWorkSpace;
1250
1241
  }
1251
- chatOptions.openEmbedView = async (ctx, param, viewId, container, selectedData, callback) => {
1252
- await this.openEmbedView(
1253
- ctx,
1254
- param,
1255
- viewId,
1256
- container,
1257
- selectedData,
1258
- callback
1259
- );
1260
- };
1242
+ chatOptions.openEmbedView = this.openEmbedView.bind(this);
1261
1243
  chatOptions.fetchAgentList = (args2 = {}) => {
1262
1244
  const { query, agentid } = args2;
1263
1245
  return this.getAIAgentList(context, {
@@ -2249,14 +2231,14 @@ class AIChatUtil {
2249
2231
  * @memberof AIChatUtil
2250
2232
  */
2251
2233
  async openEmbedView(context, params, viewId, container, selectedData, callback) {
2252
- render(null, container);
2234
+ const unmount = (result = { ok: false }) => {
2235
+ callback == null ? void 0 : callback(result);
2236
+ render(null, container);
2237
+ };
2253
2238
  const modal = new Modal({
2254
2239
  mode: ViewMode.EMBED,
2255
2240
  viewUsage: 2,
2256
- dismiss: (result) => {
2257
- callback == null ? void 0 : callback(result);
2258
- render(null, container);
2259
- }
2241
+ dismiss: (result) => unmount(result)
2260
2242
  });
2261
2243
  const modelData = await ibiz.hub.getAppView(viewId);
2262
2244
  const vNode = createVNode(IBizViewShell, {
@@ -2264,15 +2246,15 @@ class AIChatUtil {
2264
2246
  modelData,
2265
2247
  context,
2266
2248
  params: { ...params, checkstrictly: true },
2267
- style: {
2268
- height: "".concat(modelData.height || 400, "px")
2269
- },
2270
- state: {
2271
- selectedData
2272
- }
2249
+ state: { selectedData }
2273
2250
  });
2274
2251
  vNode.appContext = this.App._context;
2275
2252
  render(vNode, container);
2253
+ return {
2254
+ width: modelData.width,
2255
+ height: modelData.height,
2256
+ unmount
2257
+ };
2276
2258
  }
2277
2259
  /**
2278
2260
  * @description 获取异步行为配置
@@ -462,16 +462,7 @@ class AIChatUtil {
462
462
  editorParams
463
463
  );
464
464
  };
465
- chatOptions.openEmbedView = async (ctx, param, viewId, container, selectedData, callback) => {
466
- await this.openEmbedView(
467
- ctx,
468
- param,
469
- viewId,
470
- container,
471
- selectedData,
472
- callback
473
- );
474
- };
465
+ chatOptions.openEmbedView = this.openEmbedView.bind(this);
475
466
  chatOptions.fetchKnowledgeBaseList = (args2 = {}) => {
476
467
  return this.getKnowledgeBaseList(context, params, editorParams, args2);
477
468
  };
@@ -1250,16 +1241,7 @@ class AIChatUtil {
1250
1241
  } else {
1251
1242
  chatOptions.enableWorkSpace = ibiz.config.common.aiEnableWorkSpace;
1252
1243
  }
1253
- chatOptions.openEmbedView = async (ctx, param, viewId, container, selectedData, callback) => {
1254
- await this.openEmbedView(
1255
- ctx,
1256
- param,
1257
- viewId,
1258
- container,
1259
- selectedData,
1260
- callback
1261
- );
1262
- };
1244
+ chatOptions.openEmbedView = this.openEmbedView.bind(this);
1263
1245
  chatOptions.fetchAgentList = (args2 = {}) => {
1264
1246
  const { query, agentid } = args2;
1265
1247
  return this.getAIAgentList(context, {
@@ -2251,14 +2233,14 @@ class AIChatUtil {
2251
2233
  * @memberof AIChatUtil
2252
2234
  */
2253
2235
  async openEmbedView(context, params, viewId, container, selectedData, callback) {
2254
- vue.render(null, container);
2236
+ const unmount = (result = { ok: false }) => {
2237
+ callback == null ? void 0 : callback(result);
2238
+ vue.render(null, container);
2239
+ };
2255
2240
  const modal = new runtime.Modal({
2256
2241
  mode: runtime.ViewMode.EMBED,
2257
2242
  viewUsage: 2,
2258
- dismiss: (result) => {
2259
- callback == null ? void 0 : callback(result);
2260
- vue.render(null, container);
2261
- }
2243
+ dismiss: (result) => unmount(result)
2262
2244
  });
2263
2245
  const modelData = await ibiz.hub.getAppView(viewId);
2264
2246
  const vNode = vue.createVNode(vue3Util.IBizViewShell, {
@@ -2266,15 +2248,15 @@ class AIChatUtil {
2266
2248
  modelData,
2267
2249
  context,
2268
2250
  params: { ...params, checkstrictly: true },
2269
- style: {
2270
- height: "".concat(modelData.height || 400, "px")
2271
- },
2272
- state: {
2273
- selectedData
2274
- }
2251
+ state: { selectedData }
2275
2252
  });
2276
2253
  vNode.appContext = this.App._context;
2277
2254
  vue.render(vNode, container);
2255
+ return {
2256
+ width: modelData.width,
2257
+ height: modelData.height,
2258
+ unmount
2259
+ };
2278
2260
  }
2279
2261
  /**
2280
2262
  * @description 获取异步行为配置
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template/vue3-components",
3
- "version": "0.7.41-alpha.167",
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,7 +31,7 @@
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.134",
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",
@@ -675,23 +675,7 @@ export class AIChatUtil implements IApiAIChatUtil {
675
675
  );
676
676
  };
677
677
  // 打开视图
678
- chatOptions.openEmbedView = async (
679
- ctx: IContext,
680
- param: IParams,
681
- viewId: string,
682
- container: HTMLElement,
683
- selectedData: IData[],
684
- callback?: (result: IModalData) => void,
685
- ) => {
686
- await this.openEmbedView(
687
- ctx,
688
- param,
689
- viewId,
690
- container,
691
- selectedData,
692
- callback,
693
- );
694
- };
678
+ chatOptions.openEmbedView = this.openEmbedView.bind(this);
695
679
  // 知识库
696
680
  chatOptions.fetchKnowledgeBaseList = (args: IParams = {}) => {
697
681
  return this.getKnowledgeBaseList(context, params, editorParams, args);
@@ -1672,23 +1656,7 @@ export class AIChatUtil implements IApiAIChatUtil {
1672
1656
  chatOptions.enableWorkSpace = ibiz.config.common.aiEnableWorkSpace;
1673
1657
  }
1674
1658
  // 打开视图
1675
- chatOptions.openEmbedView = async (
1676
- ctx: IContext,
1677
- param: IParams,
1678
- viewId: string,
1679
- container: HTMLElement,
1680
- selectedData: IData[],
1681
- callback?: (result: IModalData) => void,
1682
- ) => {
1683
- await this.openEmbedView(
1684
- ctx,
1685
- param,
1686
- viewId,
1687
- container,
1688
- selectedData,
1689
- callback,
1690
- );
1691
- };
1659
+ chatOptions.openEmbedView = this.openEmbedView.bind(this);
1692
1660
  // 智能体选项(由内部获取,优化打开速度)
1693
1661
  chatOptions.fetchAgentList = (args: IParams = {}) => {
1694
1662
  const { query, agentid } = args;
@@ -2981,18 +2949,21 @@ export class AIChatUtil implements IApiAIChatUtil {
2981
2949
  container: HTMLElement,
2982
2950
  selectedData: IData[],
2983
2951
  callback?: (result: IModalData) => void,
2984
- ): Promise<void> {
2985
- // 1. 先安全卸载之前的视图
2986
- render(null, container);
2987
- // 2. 绘制视图
2952
+ ): Promise<{
2953
+ width: number | undefined;
2954
+ height: number | undefined;
2955
+ unmount: (result?: IModalData) => void;
2956
+ }> {
2957
+ // 卸载:只卸载内容,不负责移除 container
2958
+ const unmount = (result: IModalData = { ok: false }) => {
2959
+ callback?.(result);
2960
+ render(null, container);
2961
+ };
2962
+ // 1. 绘制视图
2988
2963
  const modal = new Modal({
2989
2964
  mode: ViewMode.EMBED,
2990
2965
  viewUsage: 2,
2991
- dismiss: (result: IModalData) => {
2992
- callback?.(result);
2993
- // 视图关闭时卸载
2994
- render(null, container);
2995
- },
2966
+ dismiss: result => unmount(result),
2996
2967
  });
2997
2968
  const modelData = await ibiz.hub.getAppView(viewId);
2998
2969
  const vNode = createVNode(IBizViewShell, {
@@ -3000,17 +2971,18 @@ export class AIChatUtil implements IApiAIChatUtil {
3000
2971
  modelData,
3001
2972
  context,
3002
2973
  params: { ...params, checkstrictly: true },
3003
- style: {
3004
- height: `${modelData.height || 400}px`,
3005
- },
3006
- state: {
3007
- selectedData,
3008
- },
2974
+ state: { selectedData },
3009
2975
  });
3010
- // 3. 设置应用上下文
2976
+ // 2. 设置应用上下文
3011
2977
  vNode.appContext = this.App._context;
3012
- // 4. 挂载视图
2978
+ // 3. 挂载视图
3013
2979
  render(vNode, container);
2980
+ // 4. 返回卸载方式和视图大小,AI内部关闭视图时必须调用卸载方法
2981
+ return {
2982
+ width: modelData.width,
2983
+ height: modelData.height,
2984
+ unmount,
2985
+ };
3014
2986
  }
3015
2987
 
3016
2988
  /**