@94ai/nf-softphone 8.3.17 → 8.3.20
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 +4 -0
- package/lib/nf-softphone.cjs.js +79 -14
- package/lib/nf-softphone.esm-bundler.js +80 -15
- package/lib/nf-softphone.vue.d.ts +2 -0
- package/lib/softphone-pure.d.ts +5 -1
- package/lib/softphone.d.ts +2 -1
- package/lib/type.d.ts +3 -0
- package/package/nf-softphone.vue +59 -6
- package/package/softphone-pure.ts +70 -5
- package/package/softphone.ts +65 -3
- package/package/type.ts +3 -0
- package/package.json +3 -3
package/lib/index.d.ts
CHANGED
|
@@ -234,6 +234,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
234
234
|
"softphone-incoming": (event: any) => void;
|
|
235
235
|
"softphone-connect-registered": (event: any) => void;
|
|
236
236
|
"softphone-sign-overdued": (event: any) => void;
|
|
237
|
+
"softphone-auto-ignore-callback": (event: any) => void;
|
|
237
238
|
}, {
|
|
238
239
|
sgGateway: string;
|
|
239
240
|
sgBase: string;
|
|
@@ -373,6 +374,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
373
374
|
default: string;
|
|
374
375
|
};
|
|
375
376
|
}>>> & import("vue-demi").ShallowUnwrapRef<{
|
|
377
|
+
requestOpenApi: (param: any) => Promise<unknown>;
|
|
376
378
|
connect: () => void;
|
|
377
379
|
disconnect: () => void;
|
|
378
380
|
seatsStatusChange: (status: any) => void;
|
|
@@ -607,6 +609,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
607
609
|
default: string;
|
|
608
610
|
};
|
|
609
611
|
}>>, {
|
|
612
|
+
requestOpenApi: (param: any) => Promise<unknown>;
|
|
610
613
|
connect: () => void;
|
|
611
614
|
disconnect: () => void;
|
|
612
615
|
seatsStatusChange: (status: any) => void;
|
|
@@ -630,6 +633,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
630
633
|
"softphone-incoming": (event: any) => void;
|
|
631
634
|
"softphone-connect-registered": (event: any) => void;
|
|
632
635
|
"softphone-sign-overdued": (event: any) => void;
|
|
636
|
+
"softphone-auto-ignore-callback": (event: any) => void;
|
|
633
637
|
}, string, {
|
|
634
638
|
sgGateway: string;
|
|
635
639
|
sgBase: string;
|
package/lib/nf-softphone.cjs.js
CHANGED
|
@@ -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") {
|
|
@@ -213,6 +217,8 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
213
217
|
emit("softphone-incoming", data);
|
|
214
218
|
} else if (data.type === "softphone-send-dtmf") {
|
|
215
219
|
emit("softphone-send-dtmf", data);
|
|
220
|
+
} else if (data.type === "softphone-auto-ignore-callback") {
|
|
221
|
+
emit("softphone-auto-ignore-callback", data);
|
|
216
222
|
} else if (data.type === "softphone-connect-registered") {
|
|
217
223
|
emit("softphone-connect-registered", data);
|
|
218
224
|
} else if (data.type === "softphone-sign-overdued") {
|
|
@@ -237,6 +243,9 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
237
243
|
await vueDemi.nextTick();
|
|
238
244
|
clearTimeout(timer);
|
|
239
245
|
timer = void 0;
|
|
246
|
+
if (!(container.value && iframeContainer.value)) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
240
249
|
const containerStyle = container.value.getAttribute("style");
|
|
241
250
|
const iframeContainerStyle = iframeContainer.value.getAttribute("style");
|
|
242
251
|
container.value.removeAttribute("style");
|
|
@@ -277,14 +286,14 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
277
286
|
const handlingScrollTransparent = () => {
|
|
278
287
|
containerScrolling.value = true;
|
|
279
288
|
};
|
|
289
|
+
let contentWindow;
|
|
280
290
|
const handlingScroll = commonUtils.debounce(async () => {
|
|
281
|
-
var _a2;
|
|
282
291
|
const {
|
|
283
292
|
top,
|
|
284
293
|
left
|
|
285
294
|
} = await refreshStyle() || {};
|
|
286
295
|
if (top && left) {
|
|
287
|
-
|
|
296
|
+
contentWindow == null ? void 0 : contentWindow.postMessage(JSON.stringify({
|
|
288
297
|
type: "softphone-scroll",
|
|
289
298
|
origin: props.origin,
|
|
290
299
|
ancestorOrigin: props.ancestorOrigin,
|
|
@@ -346,14 +355,16 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
346
355
|
url += `&timingShow=${timingShow}`;
|
|
347
356
|
url += `&signShow=${signShow}`;
|
|
348
357
|
iframeDom.value.src = url;
|
|
358
|
+
contentWindow = iframeDom.value.contentWindow;
|
|
349
359
|
window.addEventListener("message", handlingCommunication, false);
|
|
350
360
|
if (props.scrollview) {
|
|
351
361
|
(_a2 = document.querySelector(props.scrollview)) == null ? void 0 : _a2.addEventListener("scroll", handlingScroll);
|
|
352
362
|
(_b = document.querySelector(props.scrollview)) == null ? void 0 : _b.addEventListener("scroll", handlingScrollTransparent);
|
|
353
363
|
}
|
|
354
364
|
});
|
|
355
|
-
vueDemi.
|
|
365
|
+
vueDemi.onBeforeUnmount(async () => {
|
|
356
366
|
var _a2, _b;
|
|
367
|
+
disconnect();
|
|
357
368
|
window.removeEventListener("message", handlingCommunication, false);
|
|
358
369
|
if (props.scrollview) {
|
|
359
370
|
(_a2 = document.querySelector(props.scrollview)) == null ? void 0 : _a2.removeEventListener("scroll", handlingScroll);
|
|
@@ -363,8 +374,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
363
374
|
}
|
|
364
375
|
});
|
|
365
376
|
const postMessageCommunicate = (type, data = {}, operationType = "manual", ancestorOrigin = props.ancestorOrigin, destinationOrigin = props.destinationOrigin) => {
|
|
366
|
-
|
|
367
|
-
(_a2 = iframeDom.value) == null ? void 0 : _a2.contentWindow.postMessage(JSON.stringify({
|
|
377
|
+
contentWindow == null ? void 0 : contentWindow.postMessage(JSON.stringify({
|
|
368
378
|
origin: "nf-softphone",
|
|
369
379
|
ancestorOrigin: ancestorOrigin || props.ancestorOrigin,
|
|
370
380
|
destinationOrigin: destinationOrigin || props.destinationOrigin,
|
|
@@ -375,6 +385,25 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
375
385
|
}
|
|
376
386
|
}), "*");
|
|
377
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
|
+
};
|
|
378
407
|
const connect = () => {
|
|
379
408
|
postMessageCommunicate("softphone-connect", {
|
|
380
409
|
status: true
|
|
@@ -411,6 +440,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
411
440
|
iframeDom,
|
|
412
441
|
containerScrolling
|
|
413
442
|
}, {
|
|
443
|
+
requestOpenApi,
|
|
414
444
|
connect,
|
|
415
445
|
disconnect,
|
|
416
446
|
seatsStatusChange,
|
|
@@ -497,6 +527,7 @@ class SoftphoneManager {
|
|
|
497
527
|
timingShow: "1",
|
|
498
528
|
signShow: "1",
|
|
499
529
|
instanceMap: {},
|
|
530
|
+
requestOpenApiCallBackMap: {},
|
|
500
531
|
softphoneConnectCallBack: () => {
|
|
501
532
|
console.log("softphone-connect");
|
|
502
533
|
},
|
|
@@ -515,6 +546,9 @@ class SoftphoneManager {
|
|
|
515
546
|
softphoneHangupCallBack: () => {
|
|
516
547
|
console.log("softphone-hangup");
|
|
517
548
|
},
|
|
549
|
+
softphoneAutoIgnoreCallback: () => {
|
|
550
|
+
console.log("softphone-auto-ignore-callback");
|
|
551
|
+
},
|
|
518
552
|
softphoneSessionStateChangeCallBack: () => {
|
|
519
553
|
console.log("softphone-session-state-change");
|
|
520
554
|
},
|
|
@@ -532,6 +566,10 @@ class SoftphoneManager {
|
|
|
532
566
|
timestamp: void 0,
|
|
533
567
|
sign: void 0
|
|
534
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));
|
|
535
573
|
}
|
|
536
574
|
};
|
|
537
575
|
this.loadCssCode = (code) => {
|
|
@@ -574,7 +612,7 @@ class SoftphoneManager {
|
|
|
574
612
|
}), "*");
|
|
575
613
|
};
|
|
576
614
|
this.handlingCommunication = (e) => {
|
|
577
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
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;
|
|
578
616
|
const iframe = this.getSoftphoneDomElement(".nf-softphone-iframe");
|
|
579
617
|
if (iframe) {
|
|
580
618
|
let data = {};
|
|
@@ -604,14 +642,18 @@ class SoftphoneManager {
|
|
|
604
642
|
(_j = (_i = this.option).softphoneIgnoreCallBack) == null ? void 0 : _j.call(_i, data);
|
|
605
643
|
} else if (data.type === "softphone-hangup") {
|
|
606
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);
|
|
607
647
|
} else if (data.type === "softphone-session-state-change") {
|
|
608
|
-
(
|
|
648
|
+
(_p = (_o = this.option).softphoneSessionStateChangeCallBack) == null ? void 0 : _p.call(_o, data);
|
|
609
649
|
} else if (data.type === "softphone-incoming") {
|
|
610
|
-
(
|
|
650
|
+
(_r = (_q = this.option).softphoneIncomingCallBack) == null ? void 0 : _r.call(_q, data);
|
|
611
651
|
} else if (data.type === "softphone-send-dtmf") {
|
|
612
|
-
(
|
|
652
|
+
(_t = (_s = this.option).softphoneSendDtmfCallBack) == null ? void 0 : _t.call(_s, data);
|
|
613
653
|
} else if (data.type === "softphone-connect-registered") {
|
|
614
|
-
(
|
|
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);
|
|
615
657
|
} else if (data.type === "softphone-sign-overdued") {
|
|
616
658
|
const done = (data2) => {
|
|
617
659
|
const {
|
|
@@ -623,7 +665,7 @@ class SoftphoneManager {
|
|
|
623
665
|
timestamp
|
|
624
666
|
});
|
|
625
667
|
};
|
|
626
|
-
(
|
|
668
|
+
(_z = (_y = this.option).softphoneSignOverduedCallBack) == null ? void 0 : _z.call(_y, done);
|
|
627
669
|
}
|
|
628
670
|
}
|
|
629
671
|
}
|
|
@@ -685,7 +727,11 @@ class SoftphoneManager {
|
|
|
685
727
|
Object.keys(this.option.instanceMap).forEach((key) => {
|
|
686
728
|
const el = document.getElementById(key);
|
|
687
729
|
if (el && el.parentNode) {
|
|
688
|
-
|
|
730
|
+
if (el instanceof HTMLIFrameElement) {
|
|
731
|
+
el.remove();
|
|
732
|
+
} else {
|
|
733
|
+
el.parentNode.removeChild(el);
|
|
734
|
+
}
|
|
689
735
|
}
|
|
690
736
|
});
|
|
691
737
|
};
|
|
@@ -825,7 +871,7 @@ class SoftphoneManager {
|
|
|
825
871
|
this.handlerDomGenerater();
|
|
826
872
|
return this;
|
|
827
873
|
};
|
|
828
|
-
this.postMessageCommunicate = (type, status) => {
|
|
874
|
+
this.postMessageCommunicate = (type, status, param) => {
|
|
829
875
|
const iframe = this.getSoftphoneDomElement(".nf-softphone-iframe");
|
|
830
876
|
if (iframe) {
|
|
831
877
|
iframe.contentWindow.postMessage(JSON.stringify({
|
|
@@ -835,7 +881,8 @@ class SoftphoneManager {
|
|
|
835
881
|
type,
|
|
836
882
|
data: {
|
|
837
883
|
status,
|
|
838
|
-
type: "manual"
|
|
884
|
+
type: "manual",
|
|
885
|
+
param
|
|
839
886
|
}
|
|
840
887
|
}), "*");
|
|
841
888
|
}
|
|
@@ -861,12 +908,30 @@ class SoftphoneManager {
|
|
|
861
908
|
this.sendDtmf = () => {
|
|
862
909
|
this.postMessageCommunicate("softphone-send-dtmf");
|
|
863
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
|
+
};
|
|
864
928
|
this.removeTimer = () => {
|
|
865
929
|
clearTimeout(this.timer);
|
|
866
930
|
this.timer = void 0;
|
|
867
931
|
};
|
|
868
932
|
this.destroy = () => {
|
|
869
933
|
var _a, _b;
|
|
934
|
+
this.disconnect();
|
|
870
935
|
window.removeEventListener("message", this.handlingCommunication, false);
|
|
871
936
|
if (this.option.scrollview) {
|
|
872
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,
|
|
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") {
|
|
@@ -211,6 +215,8 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
211
215
|
emit("softphone-incoming", data);
|
|
212
216
|
} else if (data.type === "softphone-send-dtmf") {
|
|
213
217
|
emit("softphone-send-dtmf", data);
|
|
218
|
+
} else if (data.type === "softphone-auto-ignore-callback") {
|
|
219
|
+
emit("softphone-auto-ignore-callback", data);
|
|
214
220
|
} else if (data.type === "softphone-connect-registered") {
|
|
215
221
|
emit("softphone-connect-registered", data);
|
|
216
222
|
} else if (data.type === "softphone-sign-overdued") {
|
|
@@ -235,6 +241,9 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
235
241
|
await nextTick();
|
|
236
242
|
clearTimeout(timer);
|
|
237
243
|
timer = void 0;
|
|
244
|
+
if (!(container.value && iframeContainer.value)) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
238
247
|
const containerStyle = container.value.getAttribute("style");
|
|
239
248
|
const iframeContainerStyle = iframeContainer.value.getAttribute("style");
|
|
240
249
|
container.value.removeAttribute("style");
|
|
@@ -275,14 +284,14 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
275
284
|
const handlingScrollTransparent = () => {
|
|
276
285
|
containerScrolling.value = true;
|
|
277
286
|
};
|
|
287
|
+
let contentWindow;
|
|
278
288
|
const handlingScroll = debounce(async () => {
|
|
279
|
-
var _a2;
|
|
280
289
|
const {
|
|
281
290
|
top,
|
|
282
291
|
left
|
|
283
292
|
} = await refreshStyle() || {};
|
|
284
293
|
if (top && left) {
|
|
285
|
-
|
|
294
|
+
contentWindow == null ? void 0 : contentWindow.postMessage(JSON.stringify({
|
|
286
295
|
type: "softphone-scroll",
|
|
287
296
|
origin: props.origin,
|
|
288
297
|
ancestorOrigin: props.ancestorOrigin,
|
|
@@ -344,14 +353,16 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
344
353
|
url += `&timingShow=${timingShow}`;
|
|
345
354
|
url += `&signShow=${signShow}`;
|
|
346
355
|
iframeDom.value.src = url;
|
|
356
|
+
contentWindow = iframeDom.value.contentWindow;
|
|
347
357
|
window.addEventListener("message", handlingCommunication, false);
|
|
348
358
|
if (props.scrollview) {
|
|
349
359
|
(_a2 = document.querySelector(props.scrollview)) == null ? void 0 : _a2.addEventListener("scroll", handlingScroll);
|
|
350
360
|
(_b = document.querySelector(props.scrollview)) == null ? void 0 : _b.addEventListener("scroll", handlingScrollTransparent);
|
|
351
361
|
}
|
|
352
362
|
});
|
|
353
|
-
|
|
363
|
+
onBeforeUnmount(async () => {
|
|
354
364
|
var _a2, _b;
|
|
365
|
+
disconnect();
|
|
355
366
|
window.removeEventListener("message", handlingCommunication, false);
|
|
356
367
|
if (props.scrollview) {
|
|
357
368
|
(_a2 = document.querySelector(props.scrollview)) == null ? void 0 : _a2.removeEventListener("scroll", handlingScroll);
|
|
@@ -361,8 +372,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
361
372
|
}
|
|
362
373
|
});
|
|
363
374
|
const postMessageCommunicate = (type, data = {}, operationType = "manual", ancestorOrigin = props.ancestorOrigin, destinationOrigin = props.destinationOrigin) => {
|
|
364
|
-
|
|
365
|
-
(_a2 = iframeDom.value) == null ? void 0 : _a2.contentWindow.postMessage(JSON.stringify({
|
|
375
|
+
contentWindow == null ? void 0 : contentWindow.postMessage(JSON.stringify({
|
|
366
376
|
origin: "nf-softphone",
|
|
367
377
|
ancestorOrigin: ancestorOrigin || props.ancestorOrigin,
|
|
368
378
|
destinationOrigin: destinationOrigin || props.destinationOrigin,
|
|
@@ -373,6 +383,25 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
373
383
|
}
|
|
374
384
|
}), "*");
|
|
375
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
|
+
};
|
|
376
405
|
const connect = () => {
|
|
377
406
|
postMessageCommunicate("softphone-connect", {
|
|
378
407
|
status: true
|
|
@@ -409,6 +438,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
409
438
|
iframeDom,
|
|
410
439
|
containerScrolling
|
|
411
440
|
}, {
|
|
441
|
+
requestOpenApi,
|
|
412
442
|
connect,
|
|
413
443
|
disconnect,
|
|
414
444
|
seatsStatusChange,
|
|
@@ -495,6 +525,7 @@ class SoftphoneManager {
|
|
|
495
525
|
timingShow: "1",
|
|
496
526
|
signShow: "1",
|
|
497
527
|
instanceMap: {},
|
|
528
|
+
requestOpenApiCallBackMap: {},
|
|
498
529
|
softphoneConnectCallBack: () => {
|
|
499
530
|
console.log("softphone-connect");
|
|
500
531
|
},
|
|
@@ -513,6 +544,9 @@ class SoftphoneManager {
|
|
|
513
544
|
softphoneHangupCallBack: () => {
|
|
514
545
|
console.log("softphone-hangup");
|
|
515
546
|
},
|
|
547
|
+
softphoneAutoIgnoreCallback: () => {
|
|
548
|
+
console.log("softphone-auto-ignore-callback");
|
|
549
|
+
},
|
|
516
550
|
softphoneSessionStateChangeCallBack: () => {
|
|
517
551
|
console.log("softphone-session-state-change");
|
|
518
552
|
},
|
|
@@ -530,6 +564,10 @@ class SoftphoneManager {
|
|
|
530
564
|
timestamp: void 0,
|
|
531
565
|
sign: void 0
|
|
532
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));
|
|
533
571
|
}
|
|
534
572
|
};
|
|
535
573
|
this.loadCssCode = (code) => {
|
|
@@ -572,7 +610,7 @@ class SoftphoneManager {
|
|
|
572
610
|
}), "*");
|
|
573
611
|
};
|
|
574
612
|
this.handlingCommunication = (e) => {
|
|
575
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
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;
|
|
576
614
|
const iframe = this.getSoftphoneDomElement(".nf-softphone-iframe");
|
|
577
615
|
if (iframe) {
|
|
578
616
|
let data = {};
|
|
@@ -602,14 +640,18 @@ class SoftphoneManager {
|
|
|
602
640
|
(_j = (_i = this.option).softphoneIgnoreCallBack) == null ? void 0 : _j.call(_i, data);
|
|
603
641
|
} else if (data.type === "softphone-hangup") {
|
|
604
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);
|
|
605
645
|
} else if (data.type === "softphone-session-state-change") {
|
|
606
|
-
(
|
|
646
|
+
(_p = (_o = this.option).softphoneSessionStateChangeCallBack) == null ? void 0 : _p.call(_o, data);
|
|
607
647
|
} else if (data.type === "softphone-incoming") {
|
|
608
|
-
(
|
|
648
|
+
(_r = (_q = this.option).softphoneIncomingCallBack) == null ? void 0 : _r.call(_q, data);
|
|
609
649
|
} else if (data.type === "softphone-send-dtmf") {
|
|
610
|
-
(
|
|
650
|
+
(_t = (_s = this.option).softphoneSendDtmfCallBack) == null ? void 0 : _t.call(_s, data);
|
|
611
651
|
} else if (data.type === "softphone-connect-registered") {
|
|
612
|
-
(
|
|
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);
|
|
613
655
|
} else if (data.type === "softphone-sign-overdued") {
|
|
614
656
|
const done = (data2) => {
|
|
615
657
|
const {
|
|
@@ -621,7 +663,7 @@ class SoftphoneManager {
|
|
|
621
663
|
timestamp
|
|
622
664
|
});
|
|
623
665
|
};
|
|
624
|
-
(
|
|
666
|
+
(_z = (_y = this.option).softphoneSignOverduedCallBack) == null ? void 0 : _z.call(_y, done);
|
|
625
667
|
}
|
|
626
668
|
}
|
|
627
669
|
}
|
|
@@ -683,7 +725,11 @@ class SoftphoneManager {
|
|
|
683
725
|
Object.keys(this.option.instanceMap).forEach((key) => {
|
|
684
726
|
const el = document.getElementById(key);
|
|
685
727
|
if (el && el.parentNode) {
|
|
686
|
-
|
|
728
|
+
if (el instanceof HTMLIFrameElement) {
|
|
729
|
+
el.remove();
|
|
730
|
+
} else {
|
|
731
|
+
el.parentNode.removeChild(el);
|
|
732
|
+
}
|
|
687
733
|
}
|
|
688
734
|
});
|
|
689
735
|
};
|
|
@@ -823,7 +869,7 @@ class SoftphoneManager {
|
|
|
823
869
|
this.handlerDomGenerater();
|
|
824
870
|
return this;
|
|
825
871
|
};
|
|
826
|
-
this.postMessageCommunicate = (type, status) => {
|
|
872
|
+
this.postMessageCommunicate = (type, status, param) => {
|
|
827
873
|
const iframe = this.getSoftphoneDomElement(".nf-softphone-iframe");
|
|
828
874
|
if (iframe) {
|
|
829
875
|
iframe.contentWindow.postMessage(JSON.stringify({
|
|
@@ -833,7 +879,8 @@ class SoftphoneManager {
|
|
|
833
879
|
type,
|
|
834
880
|
data: {
|
|
835
881
|
status,
|
|
836
|
-
type: "manual"
|
|
882
|
+
type: "manual",
|
|
883
|
+
param
|
|
837
884
|
}
|
|
838
885
|
}), "*");
|
|
839
886
|
}
|
|
@@ -859,12 +906,30 @@ class SoftphoneManager {
|
|
|
859
906
|
this.sendDtmf = () => {
|
|
860
907
|
this.postMessageCommunicate("softphone-send-dtmf");
|
|
861
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
|
+
};
|
|
862
926
|
this.removeTimer = () => {
|
|
863
927
|
clearTimeout(this.timer);
|
|
864
928
|
this.timer = void 0;
|
|
865
929
|
};
|
|
866
930
|
this.destroy = () => {
|
|
867
931
|
var _a, _b;
|
|
932
|
+
this.disconnect();
|
|
868
933
|
window.removeEventListener("message", this.handlingCommunication, false);
|
|
869
934
|
if (this.option.scrollview) {
|
|
870
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;
|
|
@@ -83,6 +84,7 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
|
|
|
83
84
|
"softphone-incoming": (event: any) => void;
|
|
84
85
|
"softphone-connect-registered": (event: any) => void;
|
|
85
86
|
"softphone-sign-overdued": (event: any) => void;
|
|
87
|
+
"softphone-auto-ignore-callback": (event: any) => void;
|
|
86
88
|
}, string, Readonly<import("vue-demi").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
87
89
|
sgGateway?: string | undefined;
|
|
88
90
|
sgBase?: string | undefined;
|
package/lib/softphone-pure.d.ts
CHANGED
|
@@ -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
|
}
|
package/lib/softphone.d.ts
CHANGED
|
@@ -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';
|
|
@@ -37,7 +38,9 @@ export 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
|
export declare type Env = 'test' | 'dev' | 'sg' | 'gray' | 'prod';
|
package/package/nf-softphone.vue
CHANGED
|
@@ -30,10 +30,13 @@ import {
|
|
|
30
30
|
getCurrentInstance,
|
|
31
31
|
onMounted,
|
|
32
32
|
ref,
|
|
33
|
-
|
|
33
|
+
onBeforeUnmount,
|
|
34
34
|
nextTick
|
|
35
35
|
} from 'vue-demi'
|
|
36
|
-
import {
|
|
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
|
|
@@ -119,6 +124,7 @@ const emit = defineEmits<{
|
|
|
119
124
|
(e: 'softphone-incoming', event: any): void
|
|
120
125
|
(e: 'softphone-connect-registered', event: any): void
|
|
121
126
|
(e: 'softphone-sign-overdued', event: any): void
|
|
127
|
+
(e: 'softphone-auto-ignore-callback', event: any): void
|
|
122
128
|
}>()
|
|
123
129
|
|
|
124
130
|
const container = ref()
|
|
@@ -151,6 +157,8 @@ const handlingCommunication = (e: {data: `{
|
|
|
151
157
|
}
|
|
152
158
|
if (data.type === 'softphone-connect') {
|
|
153
159
|
emit('softphone-connect', data)
|
|
160
|
+
} else if (data.type === 'softphone-request-open-api') {
|
|
161
|
+
requestOpenApiCallBackMap[data.uuid]?.(data)
|
|
154
162
|
} else if (data.type === 'softphone-call-refresh') {
|
|
155
163
|
emit('softphone-call-refresh', data)
|
|
156
164
|
} else if (data.type === 'softphone-seats-status-change') {
|
|
@@ -167,6 +175,8 @@ const handlingCommunication = (e: {data: `{
|
|
|
167
175
|
emit('softphone-incoming', data)
|
|
168
176
|
} else if (data.type === 'softphone-send-dtmf') {
|
|
169
177
|
emit('softphone-send-dtmf', data)
|
|
178
|
+
} else if (data.type === 'softphone-auto-ignore-callback') {
|
|
179
|
+
emit('softphone-auto-ignore-callback', data)
|
|
170
180
|
} else if (data.type === 'softphone-connect-registered') {
|
|
171
181
|
emit('softphone-connect-registered', data)
|
|
172
182
|
} else if (data.type === 'softphone-sign-overdued') {
|
|
@@ -192,6 +202,9 @@ const refreshStyle = async () => {
|
|
|
192
202
|
await nextTick()
|
|
193
203
|
clearTimeout(timer)
|
|
194
204
|
timer = undefined
|
|
205
|
+
if (!(container.value && iframeContainer.value)) {
|
|
206
|
+
return
|
|
207
|
+
}
|
|
195
208
|
const containerStyle = container.value.getAttribute('style')
|
|
196
209
|
const iframeContainerStyle = iframeContainer.value.getAttribute('style')
|
|
197
210
|
container.value.removeAttribute('style')
|
|
@@ -233,13 +246,15 @@ const handlingScrollTransparent = () => {
|
|
|
233
246
|
containerScrolling.value = true
|
|
234
247
|
}
|
|
235
248
|
|
|
249
|
+
let contentWindow
|
|
250
|
+
|
|
236
251
|
const handlingScroll = debounce(async () => {
|
|
237
252
|
const {
|
|
238
253
|
top,
|
|
239
254
|
left,
|
|
240
255
|
} = (await refreshStyle() || {})
|
|
241
256
|
if (top && left) {
|
|
242
|
-
|
|
257
|
+
contentWindow?.postMessage(JSON.stringify({
|
|
243
258
|
type: 'softphone-scroll',
|
|
244
259
|
origin: props.origin,
|
|
245
260
|
ancestorOrigin: props.ancestorOrigin,
|
|
@@ -301,6 +316,7 @@ onMounted(async () => {
|
|
|
301
316
|
url += `&timingShow=${timingShow}`
|
|
302
317
|
url += `&signShow=${signShow}`
|
|
303
318
|
iframeDom.value.src = url
|
|
319
|
+
contentWindow = iframeDom.value.contentWindow
|
|
304
320
|
window.addEventListener('message', handlingCommunication, false);
|
|
305
321
|
if (props.scrollview) {
|
|
306
322
|
document.querySelector(props.scrollview)?.addEventListener('scroll', handlingScroll)
|
|
@@ -308,8 +324,9 @@ onMounted(async () => {
|
|
|
308
324
|
}
|
|
309
325
|
})
|
|
310
326
|
|
|
311
|
-
|
|
312
|
-
|
|
327
|
+
onBeforeUnmount(async () => {
|
|
328
|
+
disconnect()
|
|
329
|
+
window.removeEventListener('message', handlingCommunication, false);
|
|
313
330
|
if (props.scrollview) {
|
|
314
331
|
document.querySelector(props.scrollview)?.removeEventListener('scroll', handlingScroll)
|
|
315
332
|
document.querySelector(props.scrollview)?.removeEventListener('scroll', handlingScrollTransparent)
|
|
@@ -325,7 +342,7 @@ const postMessageCommunicate = (
|
|
|
325
342
|
ancestorOrigin = props.ancestorOrigin,
|
|
326
343
|
destinationOrigin = props.destinationOrigin
|
|
327
344
|
) => {
|
|
328
|
-
|
|
345
|
+
contentWindow?.postMessage(JSON.stringify({
|
|
329
346
|
origin: 'nf-softphone',
|
|
330
347
|
ancestorOrigin: ancestorOrigin || props.ancestorOrigin,
|
|
331
348
|
destinationOrigin: destinationOrigin || props.destinationOrigin,
|
|
@@ -336,6 +353,41 @@ const postMessageCommunicate = (
|
|
|
336
353
|
}
|
|
337
354
|
}), '*')
|
|
338
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
|
+
|
|
339
391
|
const connect = () => {
|
|
340
392
|
postMessageCommunicate('softphone-connect', {
|
|
341
393
|
status: true
|
|
@@ -376,6 +428,7 @@ const signOverdued = (data: {
|
|
|
376
428
|
}
|
|
377
429
|
|
|
378
430
|
defineExpose({
|
|
431
|
+
requestOpenApi,
|
|
379
432
|
connect,
|
|
380
433
|
disconnect,
|
|
381
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
|
-
|
|
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
|
-
|
|
561
|
+
const {
|
|
531
562
|
top,
|
|
532
563
|
left,
|
|
533
|
-
|
|
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)
|
package/package/softphone.ts
CHANGED
|
@@ -62,12 +62,15 @@ 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')},
|
|
@@ -78,6 +81,23 @@ export class SoftphoneManager {
|
|
|
78
81
|
sign: undefined
|
|
79
82
|
})
|
|
80
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
|
+
},
|
|
81
101
|
}
|
|
82
102
|
|
|
83
103
|
|
|
@@ -170,6 +190,8 @@ export class SoftphoneManager {
|
|
|
170
190
|
this.option.softphoneIgnoreCallBack?.(data)
|
|
171
191
|
} else if (data.type === 'softphone-hangup') {
|
|
172
192
|
this.option.softphoneHangupCallBack?.(data)
|
|
193
|
+
} else if (data.type === 'softphone-auto-ignore-callback') {
|
|
194
|
+
this.option.softphoneAutoIgnoreCallback?.(data)
|
|
173
195
|
} else if (data.type === 'softphone-session-state-change') {
|
|
174
196
|
this.option.softphoneSessionStateChangeCallBack?.(data)
|
|
175
197
|
} else if (data.type === 'softphone-incoming') {
|
|
@@ -178,6 +200,8 @@ export class SoftphoneManager {
|
|
|
178
200
|
this.option.softphoneSendDtmfCallBack?.(data)
|
|
179
201
|
} else if (data.type === 'softphone-connect-registered') {
|
|
180
202
|
this.option.softphoneConnectRegisteredCallBack?.(data)
|
|
203
|
+
} else if (data.type === 'softphone-request-open-api') {
|
|
204
|
+
this.option.softphoneRequestOpenApiCallBack?.(data)
|
|
181
205
|
} else if (data.type === 'softphone-sign-overdued') {
|
|
182
206
|
const done = (data) => {
|
|
183
207
|
const {
|
|
@@ -256,7 +280,11 @@ export class SoftphoneManager {
|
|
|
256
280
|
Object.keys(this.option.instanceMap!).forEach(key => {
|
|
257
281
|
const el = document.getElementById(key)
|
|
258
282
|
if (el && el.parentNode) {
|
|
259
|
-
|
|
283
|
+
if (el instanceof HTMLIFrameElement) {
|
|
284
|
+
el.remove()
|
|
285
|
+
} else {
|
|
286
|
+
el.parentNode.removeChild(el)
|
|
287
|
+
}
|
|
260
288
|
}
|
|
261
289
|
})
|
|
262
290
|
}
|
|
@@ -419,7 +447,7 @@ export class SoftphoneManager {
|
|
|
419
447
|
return this
|
|
420
448
|
}
|
|
421
449
|
|
|
422
|
-
postMessageCommunicate = (type, status?: boolean) => {
|
|
450
|
+
postMessageCommunicate = (type, status?: boolean, param?) => {
|
|
423
451
|
const iframe = this.getSoftphoneDomElement('.nf-softphone-iframe') as HTMLIFrameElement
|
|
424
452
|
if (iframe) {
|
|
425
453
|
iframe.contentWindow!.postMessage(JSON.stringify({
|
|
@@ -429,7 +457,8 @@ export class SoftphoneManager {
|
|
|
429
457
|
type,
|
|
430
458
|
data: {
|
|
431
459
|
status,
|
|
432
|
-
type: 'manual'
|
|
460
|
+
type: 'manual',
|
|
461
|
+
param
|
|
433
462
|
}
|
|
434
463
|
}), '*')
|
|
435
464
|
}
|
|
@@ -460,12 +489,45 @@ export class SoftphoneManager {
|
|
|
460
489
|
this.postMessageCommunicate('softphone-send-dtmf')
|
|
461
490
|
}
|
|
462
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
|
+
|
|
463
524
|
removeTimer = () => {
|
|
464
525
|
clearTimeout(this.timer)
|
|
465
526
|
this.timer = undefined
|
|
466
527
|
}
|
|
467
528
|
|
|
468
529
|
destroy = () => {
|
|
530
|
+
this.disconnect()
|
|
469
531
|
window.removeEventListener('message', this.handlingCommunication, false);
|
|
470
532
|
if (this.option.scrollview) {
|
|
471
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'
|
|
@@ -40,8 +41,10 @@ export 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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@94ai/nf-softphone",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.20",
|
|
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.
|
|
17
|
+
"@94ai/nf-theme-chalk": "^8.3.20",
|
|
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": "
|
|
33
|
+
"gitHead": "8c46cefcde3257b6f9a2e455e66b37a4557919b3"
|
|
34
34
|
}
|