@94ai/nf-softphone 8.3.19 → 8.3.21

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.
package/lib/index.d.ts CHANGED
@@ -374,6 +374,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
374
374
  default: string;
375
375
  };
376
376
  }>>> & import("vue-demi").ShallowUnwrapRef<{
377
+ requestOpenApi: (param: any) => Promise<unknown>;
377
378
  connect: () => void;
378
379
  disconnect: () => void;
379
380
  seatsStatusChange: (status: any) => void;
@@ -608,6 +609,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
608
609
  default: string;
609
610
  };
610
611
  }>>, {
612
+ requestOpenApi: (param: any) => Promise<unknown>;
611
613
  connect: () => void;
612
614
  disconnect: () => void;
613
615
  seatsStatusChange: (status: any) => void;
@@ -173,12 +173,14 @@ __sfc_main.props = {
173
173
  __sfc_main.setup = (__props, __ctx) => {
174
174
  var _a;
175
175
  const props = __props;
176
+ const requestOpenApiCallBackMap = {};
176
177
  const emit = __ctx.emit;
177
178
  const container = vueDemi.ref();
178
179
  const iframeContainer = vueDemi.ref();
179
180
  const iframeDom = vueDemi.ref();
180
181
  (_a = vueDemi.getCurrentInstance()) == null ? void 0 : _a.proxy;
181
182
  const handlingCommunication = (e) => {
183
+ var _a2;
182
184
  if (iframeDom.value) {
183
185
  let data = {};
184
186
  try {
@@ -197,6 +199,8 @@ __sfc_main.setup = (__props, __ctx) => {
197
199
  }
198
200
  if (data.type === "softphone-connect") {
199
201
  emit("softphone-connect", data);
202
+ } else if (data.type === "softphone-request-open-api") {
203
+ (_a2 = requestOpenApiCallBackMap[data.uuid]) == null ? void 0 : _a2.call(requestOpenApiCallBackMap, data);
200
204
  } else if (data.type === "softphone-call-refresh") {
201
205
  emit("softphone-call-refresh", data);
202
206
  } else if (data.type === "softphone-seats-status-change") {
@@ -239,6 +243,9 @@ __sfc_main.setup = (__props, __ctx) => {
239
243
  await vueDemi.nextTick();
240
244
  clearTimeout(timer);
241
245
  timer = void 0;
246
+ if (!(container.value && iframeContainer.value)) {
247
+ return;
248
+ }
242
249
  const containerStyle = container.value.getAttribute("style");
243
250
  const iframeContainerStyle = iframeContainer.value.getAttribute("style");
244
251
  container.value.removeAttribute("style");
@@ -279,14 +286,14 @@ __sfc_main.setup = (__props, __ctx) => {
279
286
  const handlingScrollTransparent = () => {
280
287
  containerScrolling.value = true;
281
288
  };
289
+ let contentWindow;
282
290
  const handlingScroll = commonUtils.debounce(async () => {
283
- var _a2;
284
291
  const {
285
292
  top,
286
293
  left
287
294
  } = await refreshStyle() || {};
288
295
  if (top && left) {
289
- (_a2 = iframeDom.value) == null ? void 0 : _a2.contentWindow.postMessage(JSON.stringify({
296
+ contentWindow == null ? void 0 : contentWindow.postMessage(JSON.stringify({
290
297
  type: "softphone-scroll",
291
298
  origin: props.origin,
292
299
  ancestorOrigin: props.ancestorOrigin,
@@ -348,14 +355,16 @@ __sfc_main.setup = (__props, __ctx) => {
348
355
  url += `&timingShow=${timingShow}`;
349
356
  url += `&signShow=${signShow}`;
350
357
  iframeDom.value.src = url;
358
+ contentWindow = iframeDom.value.contentWindow;
351
359
  window.addEventListener("message", handlingCommunication, false);
352
360
  if (props.scrollview) {
353
361
  (_a2 = document.querySelector(props.scrollview)) == null ? void 0 : _a2.addEventListener("scroll", handlingScroll);
354
362
  (_b = document.querySelector(props.scrollview)) == null ? void 0 : _b.addEventListener("scroll", handlingScrollTransparent);
355
363
  }
356
364
  });
357
- vueDemi.onUnmounted(() => {
365
+ vueDemi.onBeforeUnmount(async () => {
358
366
  var _a2, _b;
367
+ disconnect();
359
368
  window.removeEventListener("message", handlingCommunication, false);
360
369
  if (props.scrollview) {
361
370
  (_a2 = document.querySelector(props.scrollview)) == null ? void 0 : _a2.removeEventListener("scroll", handlingScroll);
@@ -365,8 +374,7 @@ __sfc_main.setup = (__props, __ctx) => {
365
374
  }
366
375
  });
367
376
  const postMessageCommunicate = (type, data = {}, operationType = "manual", ancestorOrigin = props.ancestorOrigin, destinationOrigin = props.destinationOrigin) => {
368
- var _a2;
369
- (_a2 = iframeDom.value) == null ? void 0 : _a2.contentWindow.postMessage(JSON.stringify({
377
+ contentWindow == null ? void 0 : contentWindow.postMessage(JSON.stringify({
370
378
  origin: "nf-softphone",
371
379
  ancestorOrigin: ancestorOrigin || props.ancestorOrigin,
372
380
  destinationOrigin: destinationOrigin || props.destinationOrigin,
@@ -377,6 +385,25 @@ __sfc_main.setup = (__props, __ctx) => {
377
385
  }
378
386
  }), "*");
379
387
  };
388
+ const requestOpenApi = async (param) => {
389
+ return new Promise((resolve, reject) => {
390
+ const uuid = commonUtils.generateUUID();
391
+ requestOpenApiCallBackMap[uuid] = async (result) => {
392
+ if (result.code === 200) {
393
+ resolve(result.data.res);
394
+ } else {
395
+ reject(result);
396
+ }
397
+ delete requestOpenApiCallBackMap[uuid];
398
+ };
399
+ postMessageCommunicate("softphone-request-open-api", {
400
+ param: {
401
+ uuid,
402
+ param
403
+ }
404
+ });
405
+ });
406
+ };
380
407
  const connect = () => {
381
408
  postMessageCommunicate("softphone-connect", {
382
409
  status: true
@@ -413,6 +440,7 @@ __sfc_main.setup = (__props, __ctx) => {
413
440
  iframeDom,
414
441
  containerScrolling
415
442
  }, {
443
+ requestOpenApi,
416
444
  connect,
417
445
  disconnect,
418
446
  seatsStatusChange,
@@ -499,6 +527,7 @@ class SoftphoneManager {
499
527
  timingShow: "1",
500
528
  signShow: "1",
501
529
  instanceMap: {},
530
+ requestOpenApiCallBackMap: {},
502
531
  softphoneConnectCallBack: () => {
503
532
  console.log("softphone-connect");
504
533
  },
@@ -517,6 +546,9 @@ class SoftphoneManager {
517
546
  softphoneHangupCallBack: () => {
518
547
  console.log("softphone-hangup");
519
548
  },
549
+ softphoneAutoIgnoreCallback: () => {
550
+ console.log("softphone-auto-ignore-callback");
551
+ },
520
552
  softphoneSessionStateChangeCallBack: () => {
521
553
  console.log("softphone-session-state-change");
522
554
  },
@@ -526,9 +558,6 @@ class SoftphoneManager {
526
558
  softphoneSendDtmfCallBack: () => {
527
559
  console.log("softphone-send-dtmf");
528
560
  },
529
- softphoneAutoIgnoreCallback: (data) => {
530
- console.log("softphone-auto-ignore-callback");
531
- },
532
561
  softphoneConnectRegisteredCallBack: () => {
533
562
  console.log("softphone-connect-registered");
534
563
  },
@@ -537,6 +566,10 @@ class SoftphoneManager {
537
566
  timestamp: void 0,
538
567
  sign: void 0
539
568
  });
569
+ },
570
+ softphoneRequestOpenApiCallBack: async (data) => {
571
+ var _a, _b;
572
+ await ((_b = (_a = this.option.requestOpenApiCallBackMap)[data.uuid]) == null ? void 0 : _b.call(_a, data));
540
573
  }
541
574
  };
542
575
  this.loadCssCode = (code) => {
@@ -579,7 +612,7 @@ class SoftphoneManager {
579
612
  }), "*");
580
613
  };
581
614
  this.handlingCommunication = (e) => {
582
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
615
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
583
616
  const iframe = this.getSoftphoneDomElement(".nf-softphone-iframe");
584
617
  if (iframe) {
585
618
  let data = {};
@@ -609,16 +642,18 @@ class SoftphoneManager {
609
642
  (_j = (_i = this.option).softphoneIgnoreCallBack) == null ? void 0 : _j.call(_i, data);
610
643
  } else if (data.type === "softphone-hangup") {
611
644
  (_l = (_k = this.option).softphoneHangupCallBack) == null ? void 0 : _l.call(_k, data);
645
+ } else if (data.type === "softphone-auto-ignore-callback") {
646
+ (_n = (_m = this.option).softphoneAutoIgnoreCallback) == null ? void 0 : _n.call(_m, data);
612
647
  } else if (data.type === "softphone-session-state-change") {
613
- (_n = (_m = this.option).softphoneSessionStateChangeCallBack) == null ? void 0 : _n.call(_m, data);
648
+ (_p = (_o = this.option).softphoneSessionStateChangeCallBack) == null ? void 0 : _p.call(_o, data);
614
649
  } else if (data.type === "softphone-incoming") {
615
- (_p = (_o = this.option).softphoneIncomingCallBack) == null ? void 0 : _p.call(_o, data);
650
+ (_r = (_q = this.option).softphoneIncomingCallBack) == null ? void 0 : _r.call(_q, data);
616
651
  } else if (data.type === "softphone-send-dtmf") {
617
- (_r = (_q = this.option).softphoneSendDtmfCallBack) == null ? void 0 : _r.call(_q, data);
618
- } else if (data.type === "softphone-auto-ignore-callback") {
619
- (_t = (_s = this.option).softphoneAutoIgnoreCallback) == null ? void 0 : _t.call(_s, data);
652
+ (_t = (_s = this.option).softphoneSendDtmfCallBack) == null ? void 0 : _t.call(_s, data);
620
653
  } else if (data.type === "softphone-connect-registered") {
621
654
  (_v = (_u = this.option).softphoneConnectRegisteredCallBack) == null ? void 0 : _v.call(_u, data);
655
+ } else if (data.type === "softphone-request-open-api") {
656
+ (_x = (_w = this.option).softphoneRequestOpenApiCallBack) == null ? void 0 : _x.call(_w, data);
622
657
  } else if (data.type === "softphone-sign-overdued") {
623
658
  const done = (data2) => {
624
659
  const {
@@ -630,7 +665,7 @@ class SoftphoneManager {
630
665
  timestamp
631
666
  });
632
667
  };
633
- (_x = (_w = this.option).softphoneSignOverduedCallBack) == null ? void 0 : _x.call(_w, done);
668
+ (_z = (_y = this.option).softphoneSignOverduedCallBack) == null ? void 0 : _z.call(_y, done);
634
669
  }
635
670
  }
636
671
  }
@@ -692,7 +727,11 @@ class SoftphoneManager {
692
727
  Object.keys(this.option.instanceMap).forEach((key) => {
693
728
  const el = document.getElementById(key);
694
729
  if (el && el.parentNode) {
695
- el.parentNode.removeChild(el);
730
+ if (el instanceof HTMLIFrameElement) {
731
+ el.remove();
732
+ } else {
733
+ el.parentNode.removeChild(el);
734
+ }
696
735
  }
697
736
  });
698
737
  };
@@ -832,7 +871,7 @@ class SoftphoneManager {
832
871
  this.handlerDomGenerater();
833
872
  return this;
834
873
  };
835
- this.postMessageCommunicate = (type, status) => {
874
+ this.postMessageCommunicate = (type, status, param) => {
836
875
  const iframe = this.getSoftphoneDomElement(".nf-softphone-iframe");
837
876
  if (iframe) {
838
877
  iframe.contentWindow.postMessage(JSON.stringify({
@@ -842,7 +881,8 @@ class SoftphoneManager {
842
881
  type,
843
882
  data: {
844
883
  status,
845
- type: "manual"
884
+ type: "manual",
885
+ param
846
886
  }
847
887
  }), "*");
848
888
  }
@@ -868,12 +908,30 @@ class SoftphoneManager {
868
908
  this.sendDtmf = () => {
869
909
  this.postMessageCommunicate("softphone-send-dtmf");
870
910
  };
911
+ this.requestOpenApi = async (param) => {
912
+ return new Promise((resolve, reject) => {
913
+ const uuid = commonUtils.generateUUID();
914
+ this.option.requestOpenApiCallBackMap[uuid] = async (result) => {
915
+ if (result.code === 200) {
916
+ resolve(result.data.res);
917
+ } else {
918
+ reject(result);
919
+ }
920
+ delete this.option.requestOpenApiCallBackMap[uuid];
921
+ };
922
+ this.postMessageCommunicate("softphone-request-open-api", void 0, {
923
+ uuid,
924
+ param
925
+ });
926
+ });
927
+ };
871
928
  this.removeTimer = () => {
872
929
  clearTimeout(this.timer);
873
930
  this.timer = void 0;
874
931
  };
875
932
  this.destroy = () => {
876
933
  var _a, _b;
934
+ this.disconnect();
877
935
  window.removeEventListener("message", this.handlingCommunication, false);
878
936
  if (this.option.scrollview) {
879
937
  (_a = document.querySelector(this.option.scrollview)) == null ? void 0 : _a.removeEventListener("scroll", this.handlingScroll);
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, getCurrentInstance, onMounted, onUnmounted, nextTick } from "vue-demi";
1
+ import { defineComponent, ref, getCurrentInstance, onMounted, onBeforeUnmount, nextTick } from "vue-demi";
2
2
  import { debounce, generateUUID } from "@94ai/common-utils";
3
3
  import { normalizeComponent } from "@94ai/vue2-runtime-helpers";
4
4
  const __sfc_main = defineComponent({
@@ -171,12 +171,14 @@ __sfc_main.props = {
171
171
  __sfc_main.setup = (__props, __ctx) => {
172
172
  var _a;
173
173
  const props = __props;
174
+ const requestOpenApiCallBackMap = {};
174
175
  const emit = __ctx.emit;
175
176
  const container = ref();
176
177
  const iframeContainer = ref();
177
178
  const iframeDom = ref();
178
179
  (_a = getCurrentInstance()) == null ? void 0 : _a.proxy;
179
180
  const handlingCommunication = (e) => {
181
+ var _a2;
180
182
  if (iframeDom.value) {
181
183
  let data = {};
182
184
  try {
@@ -195,6 +197,8 @@ __sfc_main.setup = (__props, __ctx) => {
195
197
  }
196
198
  if (data.type === "softphone-connect") {
197
199
  emit("softphone-connect", data);
200
+ } else if (data.type === "softphone-request-open-api") {
201
+ (_a2 = requestOpenApiCallBackMap[data.uuid]) == null ? void 0 : _a2.call(requestOpenApiCallBackMap, data);
198
202
  } else if (data.type === "softphone-call-refresh") {
199
203
  emit("softphone-call-refresh", data);
200
204
  } else if (data.type === "softphone-seats-status-change") {
@@ -237,6 +241,9 @@ __sfc_main.setup = (__props, __ctx) => {
237
241
  await nextTick();
238
242
  clearTimeout(timer);
239
243
  timer = void 0;
244
+ if (!(container.value && iframeContainer.value)) {
245
+ return;
246
+ }
240
247
  const containerStyle = container.value.getAttribute("style");
241
248
  const iframeContainerStyle = iframeContainer.value.getAttribute("style");
242
249
  container.value.removeAttribute("style");
@@ -277,14 +284,14 @@ __sfc_main.setup = (__props, __ctx) => {
277
284
  const handlingScrollTransparent = () => {
278
285
  containerScrolling.value = true;
279
286
  };
287
+ let contentWindow;
280
288
  const handlingScroll = debounce(async () => {
281
- var _a2;
282
289
  const {
283
290
  top,
284
291
  left
285
292
  } = await refreshStyle() || {};
286
293
  if (top && left) {
287
- (_a2 = iframeDom.value) == null ? void 0 : _a2.contentWindow.postMessage(JSON.stringify({
294
+ contentWindow == null ? void 0 : contentWindow.postMessage(JSON.stringify({
288
295
  type: "softphone-scroll",
289
296
  origin: props.origin,
290
297
  ancestorOrigin: props.ancestorOrigin,
@@ -346,14 +353,16 @@ __sfc_main.setup = (__props, __ctx) => {
346
353
  url += `&timingShow=${timingShow}`;
347
354
  url += `&signShow=${signShow}`;
348
355
  iframeDom.value.src = url;
356
+ contentWindow = iframeDom.value.contentWindow;
349
357
  window.addEventListener("message", handlingCommunication, false);
350
358
  if (props.scrollview) {
351
359
  (_a2 = document.querySelector(props.scrollview)) == null ? void 0 : _a2.addEventListener("scroll", handlingScroll);
352
360
  (_b = document.querySelector(props.scrollview)) == null ? void 0 : _b.addEventListener("scroll", handlingScrollTransparent);
353
361
  }
354
362
  });
355
- onUnmounted(() => {
363
+ onBeforeUnmount(async () => {
356
364
  var _a2, _b;
365
+ disconnect();
357
366
  window.removeEventListener("message", handlingCommunication, false);
358
367
  if (props.scrollview) {
359
368
  (_a2 = document.querySelector(props.scrollview)) == null ? void 0 : _a2.removeEventListener("scroll", handlingScroll);
@@ -363,8 +372,7 @@ __sfc_main.setup = (__props, __ctx) => {
363
372
  }
364
373
  });
365
374
  const postMessageCommunicate = (type, data = {}, operationType = "manual", ancestorOrigin = props.ancestorOrigin, destinationOrigin = props.destinationOrigin) => {
366
- var _a2;
367
- (_a2 = iframeDom.value) == null ? void 0 : _a2.contentWindow.postMessage(JSON.stringify({
375
+ contentWindow == null ? void 0 : contentWindow.postMessage(JSON.stringify({
368
376
  origin: "nf-softphone",
369
377
  ancestorOrigin: ancestorOrigin || props.ancestorOrigin,
370
378
  destinationOrigin: destinationOrigin || props.destinationOrigin,
@@ -375,6 +383,25 @@ __sfc_main.setup = (__props, __ctx) => {
375
383
  }
376
384
  }), "*");
377
385
  };
386
+ const requestOpenApi = async (param) => {
387
+ return new Promise((resolve, reject) => {
388
+ const uuid = generateUUID();
389
+ requestOpenApiCallBackMap[uuid] = async (result) => {
390
+ if (result.code === 200) {
391
+ resolve(result.data.res);
392
+ } else {
393
+ reject(result);
394
+ }
395
+ delete requestOpenApiCallBackMap[uuid];
396
+ };
397
+ postMessageCommunicate("softphone-request-open-api", {
398
+ param: {
399
+ uuid,
400
+ param
401
+ }
402
+ });
403
+ });
404
+ };
378
405
  const connect = () => {
379
406
  postMessageCommunicate("softphone-connect", {
380
407
  status: true
@@ -411,6 +438,7 @@ __sfc_main.setup = (__props, __ctx) => {
411
438
  iframeDom,
412
439
  containerScrolling
413
440
  }, {
441
+ requestOpenApi,
414
442
  connect,
415
443
  disconnect,
416
444
  seatsStatusChange,
@@ -497,6 +525,7 @@ class SoftphoneManager {
497
525
  timingShow: "1",
498
526
  signShow: "1",
499
527
  instanceMap: {},
528
+ requestOpenApiCallBackMap: {},
500
529
  softphoneConnectCallBack: () => {
501
530
  console.log("softphone-connect");
502
531
  },
@@ -515,6 +544,9 @@ class SoftphoneManager {
515
544
  softphoneHangupCallBack: () => {
516
545
  console.log("softphone-hangup");
517
546
  },
547
+ softphoneAutoIgnoreCallback: () => {
548
+ console.log("softphone-auto-ignore-callback");
549
+ },
518
550
  softphoneSessionStateChangeCallBack: () => {
519
551
  console.log("softphone-session-state-change");
520
552
  },
@@ -524,9 +556,6 @@ class SoftphoneManager {
524
556
  softphoneSendDtmfCallBack: () => {
525
557
  console.log("softphone-send-dtmf");
526
558
  },
527
- softphoneAutoIgnoreCallback: (data) => {
528
- console.log("softphone-auto-ignore-callback");
529
- },
530
559
  softphoneConnectRegisteredCallBack: () => {
531
560
  console.log("softphone-connect-registered");
532
561
  },
@@ -535,6 +564,10 @@ class SoftphoneManager {
535
564
  timestamp: void 0,
536
565
  sign: void 0
537
566
  });
567
+ },
568
+ softphoneRequestOpenApiCallBack: async (data) => {
569
+ var _a, _b;
570
+ await ((_b = (_a = this.option.requestOpenApiCallBackMap)[data.uuid]) == null ? void 0 : _b.call(_a, data));
538
571
  }
539
572
  };
540
573
  this.loadCssCode = (code) => {
@@ -577,7 +610,7 @@ class SoftphoneManager {
577
610
  }), "*");
578
611
  };
579
612
  this.handlingCommunication = (e) => {
580
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
613
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
581
614
  const iframe = this.getSoftphoneDomElement(".nf-softphone-iframe");
582
615
  if (iframe) {
583
616
  let data = {};
@@ -607,16 +640,18 @@ class SoftphoneManager {
607
640
  (_j = (_i = this.option).softphoneIgnoreCallBack) == null ? void 0 : _j.call(_i, data);
608
641
  } else if (data.type === "softphone-hangup") {
609
642
  (_l = (_k = this.option).softphoneHangupCallBack) == null ? void 0 : _l.call(_k, data);
643
+ } else if (data.type === "softphone-auto-ignore-callback") {
644
+ (_n = (_m = this.option).softphoneAutoIgnoreCallback) == null ? void 0 : _n.call(_m, data);
610
645
  } else if (data.type === "softphone-session-state-change") {
611
- (_n = (_m = this.option).softphoneSessionStateChangeCallBack) == null ? void 0 : _n.call(_m, data);
646
+ (_p = (_o = this.option).softphoneSessionStateChangeCallBack) == null ? void 0 : _p.call(_o, data);
612
647
  } else if (data.type === "softphone-incoming") {
613
- (_p = (_o = this.option).softphoneIncomingCallBack) == null ? void 0 : _p.call(_o, data);
648
+ (_r = (_q = this.option).softphoneIncomingCallBack) == null ? void 0 : _r.call(_q, data);
614
649
  } else if (data.type === "softphone-send-dtmf") {
615
- (_r = (_q = this.option).softphoneSendDtmfCallBack) == null ? void 0 : _r.call(_q, data);
616
- } else if (data.type === "softphone-auto-ignore-callback") {
617
- (_t = (_s = this.option).softphoneAutoIgnoreCallback) == null ? void 0 : _t.call(_s, data);
650
+ (_t = (_s = this.option).softphoneSendDtmfCallBack) == null ? void 0 : _t.call(_s, data);
618
651
  } else if (data.type === "softphone-connect-registered") {
619
652
  (_v = (_u = this.option).softphoneConnectRegisteredCallBack) == null ? void 0 : _v.call(_u, data);
653
+ } else if (data.type === "softphone-request-open-api") {
654
+ (_x = (_w = this.option).softphoneRequestOpenApiCallBack) == null ? void 0 : _x.call(_w, data);
620
655
  } else if (data.type === "softphone-sign-overdued") {
621
656
  const done = (data2) => {
622
657
  const {
@@ -628,7 +663,7 @@ class SoftphoneManager {
628
663
  timestamp
629
664
  });
630
665
  };
631
- (_x = (_w = this.option).softphoneSignOverduedCallBack) == null ? void 0 : _x.call(_w, done);
666
+ (_z = (_y = this.option).softphoneSignOverduedCallBack) == null ? void 0 : _z.call(_y, done);
632
667
  }
633
668
  }
634
669
  }
@@ -690,7 +725,11 @@ class SoftphoneManager {
690
725
  Object.keys(this.option.instanceMap).forEach((key) => {
691
726
  const el = document.getElementById(key);
692
727
  if (el && el.parentNode) {
693
- el.parentNode.removeChild(el);
728
+ if (el instanceof HTMLIFrameElement) {
729
+ el.remove();
730
+ } else {
731
+ el.parentNode.removeChild(el);
732
+ }
694
733
  }
695
734
  });
696
735
  };
@@ -830,7 +869,7 @@ class SoftphoneManager {
830
869
  this.handlerDomGenerater();
831
870
  return this;
832
871
  };
833
- this.postMessageCommunicate = (type, status) => {
872
+ this.postMessageCommunicate = (type, status, param) => {
834
873
  const iframe = this.getSoftphoneDomElement(".nf-softphone-iframe");
835
874
  if (iframe) {
836
875
  iframe.contentWindow.postMessage(JSON.stringify({
@@ -840,7 +879,8 @@ class SoftphoneManager {
840
879
  type,
841
880
  data: {
842
881
  status,
843
- type: "manual"
882
+ type: "manual",
883
+ param
844
884
  }
845
885
  }), "*");
846
886
  }
@@ -866,12 +906,30 @@ class SoftphoneManager {
866
906
  this.sendDtmf = () => {
867
907
  this.postMessageCommunicate("softphone-send-dtmf");
868
908
  };
909
+ this.requestOpenApi = async (param) => {
910
+ return new Promise((resolve, reject) => {
911
+ const uuid = generateUUID();
912
+ this.option.requestOpenApiCallBackMap[uuid] = async (result) => {
913
+ if (result.code === 200) {
914
+ resolve(result.data.res);
915
+ } else {
916
+ reject(result);
917
+ }
918
+ delete this.option.requestOpenApiCallBackMap[uuid];
919
+ };
920
+ this.postMessageCommunicate("softphone-request-open-api", void 0, {
921
+ uuid,
922
+ param
923
+ });
924
+ });
925
+ };
869
926
  this.removeTimer = () => {
870
927
  clearTimeout(this.timer);
871
928
  this.timer = void 0;
872
929
  };
873
930
  this.destroy = () => {
874
931
  var _a, _b;
932
+ this.disconnect();
875
933
  window.removeEventListener("message", this.handlingCommunication, false);
876
934
  if (this.option.scrollview) {
877
935
  (_a = document.querySelector(this.option.scrollview)) == null ? void 0 : _a.removeEventListener("scroll", this.handlingScroll);
@@ -60,6 +60,7 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
60
60
  timingShow: string;
61
61
  signShow: string;
62
62
  }>, {
63
+ requestOpenApi: (param: any) => Promise<unknown>;
63
64
  connect: () => void;
64
65
  disconnect: () => void;
65
66
  seatsStatusChange: (status: any) => void;
@@ -20,6 +20,7 @@ declare type Option = {
20
20
  sgDomain: string;
21
21
  extStatus: '0' | '1';
22
22
  instanceMap: Record<string, any>;
23
+ requestOpenApiCallBackMap: Record<string, any>;
23
24
  callShow: '0' | '1';
24
25
  transferToLaborShow: '0' | '1';
25
26
  restShow: '0' | '1';
@@ -37,8 +38,10 @@ declare type Option = {
37
38
  softphoneSessionStateChangeCallBack: Function;
38
39
  softphoneIncomingCallBack: Function;
39
40
  softphoneSendDtmfCallBack: Function;
41
+ softphoneAutoIgnoreCallback: Function;
40
42
  softphoneConnectRegisteredCallBack: Function;
41
43
  softphoneSignOverduedCallBack: Function;
44
+ softphoneRequestOpenApiCallBack: Function;
42
45
  };
43
46
  declare type Env = 'test' | 'dev' | 'sg' | 'gray' | 'prod';
44
47
  export declare class SoftphoneManager {
@@ -80,7 +83,7 @@ export declare class SoftphoneManager {
80
83
  }>;
81
84
  handlerDomGenerater: () => Promise<void>;
82
85
  initSoftphone: (option: any) => this;
83
- postMessageCommunicate: (type: any, status?: boolean | undefined) => void;
86
+ postMessageCommunicate: (type: any, status?: boolean | undefined, param?: any) => void;
84
87
  connect: () => void;
85
88
  disconnect: () => void;
86
89
  seatsStatusChange: (status: boolean) => void;
@@ -88,6 +91,7 @@ export declare class SoftphoneManager {
88
91
  ignore: () => void;
89
92
  hangup: () => void;
90
93
  sendDtmf: () => void;
94
+ requestOpenApi: (param: any) => Promise<unknown>;
91
95
  removeTimer: () => void;
92
96
  destroy: () => void;
93
97
  }
@@ -38,7 +38,7 @@ export declare class SoftphoneManager {
38
38
  }>;
39
39
  handlerDomGenerater: () => Promise<void>;
40
40
  initSoftphone: (option: any) => this;
41
- postMessageCommunicate: (type: any, status?: boolean | undefined) => void;
41
+ postMessageCommunicate: (type: any, status?: boolean | undefined, param?: any) => void;
42
42
  connect: () => void;
43
43
  disconnect: () => void;
44
44
  seatsStatusChange: (status: boolean) => void;
@@ -46,6 +46,7 @@ export declare class SoftphoneManager {
46
46
  ignore: () => void;
47
47
  hangup: () => void;
48
48
  sendDtmf: () => void;
49
+ requestOpenApi: (param: any) => Promise<unknown>;
49
50
  removeTimer: () => void;
50
51
  destroy: () => void;
51
52
  }
package/lib/type.d.ts CHANGED
@@ -20,6 +20,7 @@ export declare type Option = {
20
20
  sgDomain: string;
21
21
  extStatus: '0' | '1';
22
22
  instanceMap: Record<string, any>;
23
+ requestOpenApiCallBackMap: Record<string, any>;
23
24
  callShow: '0' | '1';
24
25
  transferToLaborShow: '0' | '1';
25
26
  restShow: '0' | '1';
@@ -40,5 +41,6 @@ export declare type Option = {
40
41
  softphoneAutoIgnoreCallback: Function;
41
42
  softphoneConnectRegisteredCallBack: Function;
42
43
  softphoneSignOverduedCallBack: Function;
44
+ softphoneRequestOpenApiCallBack: Function;
43
45
  };
44
46
  export declare type Env = 'test' | 'dev' | 'sg' | 'gray' | 'prod';
@@ -30,10 +30,13 @@ import {
30
30
  getCurrentInstance,
31
31
  onMounted,
32
32
  ref,
33
- onUnmounted,
33
+ onBeforeUnmount,
34
34
  nextTick
35
35
  } from 'vue-demi'
36
- import { debounce } from '@94ai/common-utils'
36
+ import {
37
+ debounce,
38
+ generateUUID,
39
+ } from '@94ai/common-utils';
37
40
 
38
41
  const props = withDefaults(defineProps<{
39
42
  sgGateway?: string,
@@ -107,6 +110,8 @@ const props = withDefaults(defineProps<{
107
110
  signShow: '1',
108
111
  })
109
112
 
113
+ const requestOpenApiCallBackMap: Record<string, any> = {}
114
+
110
115
  const emit = defineEmits<{
111
116
  (e: 'softphone-connect', event: any): void
112
117
  (e: 'softphone-seats-status-change', event: any): void
@@ -152,6 +157,8 @@ const handlingCommunication = (e: {data: `{
152
157
  }
153
158
  if (data.type === 'softphone-connect') {
154
159
  emit('softphone-connect', data)
160
+ } else if (data.type === 'softphone-request-open-api') {
161
+ requestOpenApiCallBackMap[data.uuid]?.(data)
155
162
  } else if (data.type === 'softphone-call-refresh') {
156
163
  emit('softphone-call-refresh', data)
157
164
  } else if (data.type === 'softphone-seats-status-change') {
@@ -195,6 +202,9 @@ const refreshStyle = async () => {
195
202
  await nextTick()
196
203
  clearTimeout(timer)
197
204
  timer = undefined
205
+ if (!(container.value && iframeContainer.value)) {
206
+ return
207
+ }
198
208
  const containerStyle = container.value.getAttribute('style')
199
209
  const iframeContainerStyle = iframeContainer.value.getAttribute('style')
200
210
  container.value.removeAttribute('style')
@@ -236,13 +246,15 @@ const handlingScrollTransparent = () => {
236
246
  containerScrolling.value = true
237
247
  }
238
248
 
249
+ let contentWindow
250
+
239
251
  const handlingScroll = debounce(async () => {
240
252
  const {
241
253
  top,
242
254
  left,
243
255
  } = (await refreshStyle() || {})
244
256
  if (top && left) {
245
- iframeDom.value?.contentWindow.postMessage(JSON.stringify({
257
+ contentWindow?.postMessage(JSON.stringify({
246
258
  type: 'softphone-scroll',
247
259
  origin: props.origin,
248
260
  ancestorOrigin: props.ancestorOrigin,
@@ -304,6 +316,7 @@ onMounted(async () => {
304
316
  url += `&timingShow=${timingShow}`
305
317
  url += `&signShow=${signShow}`
306
318
  iframeDom.value.src = url
319
+ contentWindow = iframeDom.value.contentWindow
307
320
  window.addEventListener('message', handlingCommunication, false);
308
321
  if (props.scrollview) {
309
322
  document.querySelector(props.scrollview)?.addEventListener('scroll', handlingScroll)
@@ -311,8 +324,9 @@ onMounted(async () => {
311
324
  }
312
325
  })
313
326
 
314
- onUnmounted(() => {
315
- window.removeEventListener('message', handlingCommunication, false);
327
+ onBeforeUnmount(async () => {
328
+ disconnect()
329
+ window.removeEventListener('message', handlingCommunication, false);
316
330
  if (props.scrollview) {
317
331
  document.querySelector(props.scrollview)?.removeEventListener('scroll', handlingScroll)
318
332
  document.querySelector(props.scrollview)?.removeEventListener('scroll', handlingScrollTransparent)
@@ -328,7 +342,7 @@ const postMessageCommunicate = (
328
342
  ancestorOrigin = props.ancestorOrigin,
329
343
  destinationOrigin = props.destinationOrigin
330
344
  ) => {
331
- iframeDom.value?.contentWindow.postMessage(JSON.stringify({
345
+ contentWindow?.postMessage(JSON.stringify({
332
346
  origin: 'nf-softphone',
333
347
  ancestorOrigin: ancestorOrigin || props.ancestorOrigin,
334
348
  destinationOrigin: destinationOrigin || props.destinationOrigin,
@@ -339,6 +353,41 @@ const postMessageCommunicate = (
339
353
  }
340
354
  }), '*')
341
355
  }
356
+
357
+ const requestOpenApi = async (param) => {
358
+ return new Promise(((resolve, reject) => {
359
+ const uuid = generateUUID()
360
+ requestOpenApiCallBackMap[uuid] = async (result) => {
361
+ // result: {
362
+ // origin
363
+ // ancestorOrigin
364
+ // destinationOrigin
365
+ // type: 'softphone-request-open-api'
366
+ // uuid
367
+ // code: 200,
368
+ // message: '成功',
369
+ // data: {
370
+ // type: 'manual',
371
+ // param: {}, // 请求参数
372
+ // res // 响应结果
373
+ // }
374
+ // }
375
+ if (result.code === 200) {
376
+ resolve(result.data.res)
377
+ } else {
378
+ reject(result)
379
+ }
380
+ delete requestOpenApiCallBackMap[uuid]
381
+ }
382
+ postMessageCommunicate('softphone-request-open-api', {
383
+ param: {
384
+ uuid,
385
+ param
386
+ }
387
+ })
388
+ }))
389
+ }
390
+
342
391
  const connect = () => {
343
392
  postMessageCommunicate('softphone-connect', {
344
393
  status: true
@@ -379,6 +428,7 @@ const signOverdued = (data: {
379
428
  }
380
429
 
381
430
  defineExpose({
431
+ requestOpenApi,
382
432
  connect,
383
433
  disconnect,
384
434
  seatsStatusChange,
@@ -21,6 +21,7 @@ type Option = {
21
21
 
22
22
  extStatus: '0' | '1'
23
23
  instanceMap: Record<string, any>,
24
+ requestOpenApiCallBackMap: Record<string, any>,
24
25
 
25
26
  callShow: '0' | '1'
26
27
  transferToLaborShow: '0' | '1'
@@ -40,8 +41,10 @@ type Option = {
40
41
  softphoneSessionStateChangeCallBack: Function
41
42
  softphoneIncomingCallBack: Function
42
43
  softphoneSendDtmfCallBack: Function
44
+ softphoneAutoIgnoreCallback: Function
43
45
  softphoneConnectRegisteredCallBack: Function
44
46
  softphoneSignOverduedCallBack: Function
47
+ softphoneRequestOpenApiCallBack: Function
45
48
  }
46
49
 
47
50
  type Env = 'test' |'dev'| 'sg'| 'gray'| 'prod'
@@ -228,12 +231,15 @@ export class SoftphoneManager {
228
231
 
229
232
  instanceMap: {},
230
233
 
234
+ requestOpenApiCallBackMap: {},
235
+
231
236
  softphoneConnectCallBack: () => {console.log('softphone-connect')},
232
237
  softphoneCallRefreshCallBack: () => {console.log('softphone-call-refresh')},
233
238
  softphoneSeatStatusChangeCallBack: () => {console.log('softphone-seats-status-change')},
234
239
  softphoneAcceptCallBack: () => {console.log('softphone-accept')},
235
240
  softphoneIgnoreCallBack: () => {console.log('softphone-ignore')},
236
241
  softphoneHangupCallBack: () => {console.log('softphone-hangup')},
242
+ softphoneAutoIgnoreCallback: () => {console.log('softphone-auto-ignore-callback')},
237
243
  softphoneSessionStateChangeCallBack: () => {console.log('softphone-session-state-change')},
238
244
  softphoneIncomingCallBack: () => {console.log('softphone-incoming')},
239
245
  softphoneSendDtmfCallBack: () => {console.log('softphone-send-dtmf')},
@@ -244,6 +250,23 @@ export class SoftphoneManager {
244
250
  sign: undefined
245
251
  })
246
252
  },
253
+ softphoneRequestOpenApiCallBack: async (data) => {
254
+ // data: {
255
+ // origin
256
+ // ancestorOrigin
257
+ // destinationOrigin
258
+ // type: 'softphone-request-open-api'
259
+ // uuid
260
+ // code
261
+ // message
262
+ // data: {
263
+ // type: 'manual',
264
+ // param,
265
+ // res
266
+ // }
267
+ // }
268
+ await this.option.requestOpenApiCallBackMap![data.uuid]?.(data)
269
+ },
247
270
  }
248
271
 
249
272
 
@@ -336,6 +359,8 @@ export class SoftphoneManager {
336
359
  this.option.softphoneIgnoreCallBack?.(data)
337
360
  } else if (data.type === 'softphone-hangup') {
338
361
  this.option.softphoneHangupCallBack?.(data)
362
+ } else if (data.type === 'softphone-auto-ignore-callback') {
363
+ this.option.softphoneAutoIgnoreCallback?.(data)
339
364
  } else if (data.type === 'softphone-session-state-change') {
340
365
  this.option.softphoneSessionStateChangeCallBack?.(data)
341
366
  } else if (data.type === 'softphone-incoming') {
@@ -344,6 +369,8 @@ export class SoftphoneManager {
344
369
  this.option.softphoneSendDtmfCallBack?.(data)
345
370
  } else if (data.type === 'softphone-connect-registered') {
346
371
  this.option.softphoneConnectRegisteredCallBack?.(data)
372
+ } else if (data.type === 'softphone-request-open-api') {
373
+ this.option.softphoneRequestOpenApiCallBack?.(data)
347
374
  } else if (data.type === 'softphone-sign-overdued') {
348
375
  const done = (data) => {
349
376
  const {
@@ -422,7 +449,11 @@ export class SoftphoneManager {
422
449
  Object.keys(this.option.instanceMap!).forEach(key => {
423
450
  const el = document.getElementById(key)
424
451
  if (el && el.parentNode) {
425
- el.parentNode.removeChild(el)
452
+ if (el instanceof HTMLIFrameElement) {
453
+ el.remove()
454
+ } else {
455
+ el.parentNode.removeChild(el)
456
+ }
426
457
  }
427
458
  })
428
459
  }
@@ -527,10 +558,10 @@ export class SoftphoneManager {
527
558
  const destination = (this.option.el ? this.getSoftphoneDomElement(this.option.el) ?? document.body : document.body)
528
559
  destination.appendChild(nfSoftphone)
529
560
  await nextTick()
530
- const {
561
+ const {
531
562
  top,
532
563
  left,
533
- } = await this.refreshStyle()
564
+ } = await this.refreshStyle()
534
565
  const {
535
566
  envMap,
536
567
  env,
@@ -585,7 +616,7 @@ export class SoftphoneManager {
585
616
  return this
586
617
  }
587
618
 
588
- postMessageCommunicate = (type, status?: boolean) => {
619
+ postMessageCommunicate = (type, status?: boolean, param?) => {
589
620
  const iframe = this.getSoftphoneDomElement('.nf-softphone-iframe') as HTMLIFrameElement
590
621
  if (iframe) {
591
622
  iframe.contentWindow!.postMessage(JSON.stringify({
@@ -595,7 +626,8 @@ export class SoftphoneManager {
595
626
  type,
596
627
  data: {
597
628
  status,
598
- type: 'manual'
629
+ type: 'manual',
630
+ param
599
631
  }
600
632
  }), '*')
601
633
  }
@@ -626,12 +658,45 @@ export class SoftphoneManager {
626
658
  this.postMessageCommunicate('softphone-send-dtmf')
627
659
  }
628
660
 
661
+ requestOpenApi = async (param) => {
662
+ return new Promise(((resolve, reject) => {
663
+ const uuid = generateUUID()
664
+ this.option.requestOpenApiCallBackMap![uuid] = async (result) => {
665
+ // result: {
666
+ // origin
667
+ // ancestorOrigin
668
+ // destinationOrigin
669
+ // type: 'softphone-request-open-api'
670
+ // uuid
671
+ // code: 200,
672
+ // message: '成功',
673
+ // data: {
674
+ // type: 'manual',
675
+ // param: {}, // 请求参数
676
+ // res // 响应结果
677
+ // }
678
+ // }
679
+ if (result.code === 200) {
680
+ resolve(result.data.res)
681
+ } else {
682
+ reject(result)
683
+ }
684
+ delete this.option.requestOpenApiCallBackMap![uuid]
685
+ }
686
+ this.postMessageCommunicate('softphone-request-open-api', undefined, {
687
+ uuid,
688
+ param
689
+ })
690
+ }))
691
+ }
692
+
629
693
  removeTimer = () => {
630
694
  clearTimeout(this.timer)
631
695
  this.timer = undefined
632
696
  }
633
697
 
634
698
  destroy = () => {
699
+ this.disconnect()
635
700
  window.removeEventListener('message', this.handlingCommunication, false);
636
701
  if (this.option.scrollview) {
637
702
  document.querySelector(this.option.scrollview)?.removeEventListener('scroll', this.handlingScroll)
@@ -62,16 +62,18 @@ export class SoftphoneManager {
62
62
 
63
63
  instanceMap: {},
64
64
 
65
+ requestOpenApiCallBackMap: {},
66
+
65
67
  softphoneConnectCallBack: () => {console.log('softphone-connect')},
66
68
  softphoneCallRefreshCallBack: () => {console.log('softphone-call-refresh')},
67
69
  softphoneSeatStatusChangeCallBack: () => {console.log('softphone-seats-status-change')},
68
70
  softphoneAcceptCallBack: () => {console.log('softphone-accept')},
69
71
  softphoneIgnoreCallBack: () => {console.log('softphone-ignore')},
70
72
  softphoneHangupCallBack: () => {console.log('softphone-hangup')},
73
+ softphoneAutoIgnoreCallback: () => {console.log('softphone-auto-ignore-callback')},
71
74
  softphoneSessionStateChangeCallBack: () => {console.log('softphone-session-state-change')},
72
75
  softphoneIncomingCallBack: () => {console.log('softphone-incoming')},
73
76
  softphoneSendDtmfCallBack: () => {console.log('softphone-send-dtmf')},
74
- softphoneAutoIgnoreCallback: (data) => {console.log('softphone-auto-ignore-callback'), data},
75
77
  softphoneConnectRegisteredCallBack: () => {console.log('softphone-connect-registered')},
76
78
  softphoneSignOverduedCallBack: (done) => {
77
79
  done({
@@ -79,6 +81,23 @@ export class SoftphoneManager {
79
81
  sign: undefined
80
82
  })
81
83
  },
84
+ softphoneRequestOpenApiCallBack: async (data) => {
85
+ // data: {
86
+ // origin
87
+ // ancestorOrigin
88
+ // destinationOrigin
89
+ // type: 'softphone-request-open-api'
90
+ // uuid
91
+ // code
92
+ // message
93
+ // data: {
94
+ // type: 'manual',
95
+ // param,
96
+ // res
97
+ // }
98
+ // }
99
+ await this.option.requestOpenApiCallBackMap![data.uuid]?.(data)
100
+ },
82
101
  }
83
102
 
84
103
 
@@ -171,16 +190,18 @@ export class SoftphoneManager {
171
190
  this.option.softphoneIgnoreCallBack?.(data)
172
191
  } else if (data.type === 'softphone-hangup') {
173
192
  this.option.softphoneHangupCallBack?.(data)
193
+ } else if (data.type === 'softphone-auto-ignore-callback') {
194
+ this.option.softphoneAutoIgnoreCallback?.(data)
174
195
  } else if (data.type === 'softphone-session-state-change') {
175
196
  this.option.softphoneSessionStateChangeCallBack?.(data)
176
197
  } else if (data.type === 'softphone-incoming') {
177
198
  this.option.softphoneIncomingCallBack?.(data)
178
199
  } else if (data.type === 'softphone-send-dtmf') {
179
200
  this.option.softphoneSendDtmfCallBack?.(data)
180
- } else if (data.type === 'softphone-auto-ignore-callback') {
181
- this.option.softphoneAutoIgnoreCallback?.(data)
182
201
  } else if (data.type === 'softphone-connect-registered') {
183
202
  this.option.softphoneConnectRegisteredCallBack?.(data)
203
+ } else if (data.type === 'softphone-request-open-api') {
204
+ this.option.softphoneRequestOpenApiCallBack?.(data)
184
205
  } else if (data.type === 'softphone-sign-overdued') {
185
206
  const done = (data) => {
186
207
  const {
@@ -259,7 +280,11 @@ export class SoftphoneManager {
259
280
  Object.keys(this.option.instanceMap!).forEach(key => {
260
281
  const el = document.getElementById(key)
261
282
  if (el && el.parentNode) {
262
- el.parentNode.removeChild(el)
283
+ if (el instanceof HTMLIFrameElement) {
284
+ el.remove()
285
+ } else {
286
+ el.parentNode.removeChild(el)
287
+ }
263
288
  }
264
289
  })
265
290
  }
@@ -422,7 +447,7 @@ export class SoftphoneManager {
422
447
  return this
423
448
  }
424
449
 
425
- postMessageCommunicate = (type, status?: boolean) => {
450
+ postMessageCommunicate = (type, status?: boolean, param?) => {
426
451
  const iframe = this.getSoftphoneDomElement('.nf-softphone-iframe') as HTMLIFrameElement
427
452
  if (iframe) {
428
453
  iframe.contentWindow!.postMessage(JSON.stringify({
@@ -432,7 +457,8 @@ export class SoftphoneManager {
432
457
  type,
433
458
  data: {
434
459
  status,
435
- type: 'manual'
460
+ type: 'manual',
461
+ param
436
462
  }
437
463
  }), '*')
438
464
  }
@@ -463,12 +489,45 @@ export class SoftphoneManager {
463
489
  this.postMessageCommunicate('softphone-send-dtmf')
464
490
  }
465
491
 
492
+ requestOpenApi = async (param) => {
493
+ return new Promise(((resolve, reject) => {
494
+ const uuid = generateUUID()
495
+ this.option.requestOpenApiCallBackMap![uuid] = async (result) => {
496
+ // result: {
497
+ // origin
498
+ // ancestorOrigin
499
+ // destinationOrigin
500
+ // type: 'softphone-request-open-api'
501
+ // uuid
502
+ // code: 200,
503
+ // message: '成功',
504
+ // data: {
505
+ // type: 'manual',
506
+ // param: {}, // 请求参数
507
+ // res // 响应结果
508
+ // }
509
+ // }
510
+ if (result.code === 200) {
511
+ resolve(result.data.res)
512
+ } else {
513
+ reject(result)
514
+ }
515
+ delete this.option.requestOpenApiCallBackMap![uuid]
516
+ }
517
+ this.postMessageCommunicate('softphone-request-open-api', undefined, {
518
+ uuid,
519
+ param
520
+ })
521
+ }))
522
+ }
523
+
466
524
  removeTimer = () => {
467
525
  clearTimeout(this.timer)
468
526
  this.timer = undefined
469
527
  }
470
528
 
471
529
  destroy = () => {
530
+ this.disconnect()
472
531
  window.removeEventListener('message', this.handlingCommunication, false);
473
532
  if (this.option.scrollview) {
474
533
  document.querySelector(this.option.scrollview)?.removeEventListener('scroll', this.handlingScroll)
package/package/type.ts CHANGED
@@ -21,6 +21,7 @@ export type Option = {
21
21
 
22
22
  extStatus: '0' | '1'
23
23
  instanceMap: Record<string, any>,
24
+ requestOpenApiCallBackMap: Record<string, any>,
24
25
 
25
26
  callShow: '0' | '1'
26
27
  transferToLaborShow: '0' | '1'
@@ -43,6 +44,7 @@ export type Option = {
43
44
  softphoneAutoIgnoreCallback: Function
44
45
  softphoneConnectRegisteredCallBack: Function
45
46
  softphoneSignOverduedCallBack: Function
47
+ softphoneRequestOpenApiCallBack: Function
46
48
  }
47
49
 
48
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-softphone",
3
- "version": "8.3.19",
3
+ "version": "8.3.21",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -14,7 +14,7 @@
14
14
  "url": "http://94ai.gitlab.com/ui/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/nf-theme-chalk": "^8.3.19",
17
+ "@94ai/nf-theme-chalk": "^8.3.21",
18
18
  "vue-demi": "^0.14.5"
19
19
  },
20
20
  "peerDependenciesMeta": {
@@ -30,5 +30,5 @@
30
30
  "types": "lib/index.d.ts",
31
31
  "main": "lib/nf-softphone.cjs.js",
32
32
  "module": "lib/nf-softphone.esm-bundler.js",
33
- "gitHead": "ec206eadc7ca1a279e552ac22b51c29a5e71b326"
33
+ "gitHead": "abcd3b3acc11c65b19771a2bfa37fd8af692f2fd"
34
34
  }