@94ai/nf-softphone 3.3.23 → 3.3.35
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 +264 -44
- package/lib/nf-softphone.cjs.js +328 -104
- package/lib/nf-softphone.esm-bundler.js +329 -105
- package/lib/nf-softphone.vue.d.ts +52 -7
- package/lib/softphone.d.ts +20 -1
- package/lib/type.d.ts +11 -0
- package/package/nf-softphone.vue +97 -48
- package/package/softphone.ts +242 -54
- package/package/type.ts +12 -0
- package/package.json +3 -3
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { defineComponent, ref, getCurrentInstance, onMounted, onUnmounted } from "vue-demi";
|
|
1
|
+
import { defineComponent, ref, getCurrentInstance, onMounted, onUnmounted, 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({
|
|
5
5
|
name: "nf-softphone"
|
|
6
6
|
});
|
|
7
7
|
__sfc_main.props = {
|
|
8
|
+
scrollingText: {
|
|
9
|
+
key: "scrollingText",
|
|
10
|
+
required: false,
|
|
11
|
+
type: String,
|
|
12
|
+
default: "正在滚动中..."
|
|
13
|
+
},
|
|
8
14
|
scrollview: {
|
|
9
15
|
key: "scrollview",
|
|
10
16
|
required: false,
|
|
@@ -29,17 +35,6 @@ __sfc_main.props = {
|
|
|
29
35
|
type: null,
|
|
30
36
|
default: "test"
|
|
31
37
|
},
|
|
32
|
-
selector: {
|
|
33
|
-
key: "selector",
|
|
34
|
-
required: false,
|
|
35
|
-
type: String,
|
|
36
|
-
default: void 0
|
|
37
|
-
},
|
|
38
|
-
el: {
|
|
39
|
-
key: "el",
|
|
40
|
-
required: false,
|
|
41
|
-
type: String
|
|
42
|
-
},
|
|
43
38
|
agentId: {
|
|
44
39
|
key: "agentId",
|
|
45
40
|
required: false,
|
|
@@ -74,13 +69,67 @@ __sfc_main.props = {
|
|
|
74
69
|
key: "origin",
|
|
75
70
|
required: false,
|
|
76
71
|
type: String,
|
|
77
|
-
default: "
|
|
72
|
+
default: "ai-softphone"
|
|
78
73
|
},
|
|
79
74
|
ancestorOrigin: {
|
|
80
75
|
key: "ancestorOrigin",
|
|
81
76
|
required: false,
|
|
82
77
|
type: String,
|
|
83
78
|
default: "nf-softphone"
|
|
79
|
+
},
|
|
80
|
+
destinationOrigin: {
|
|
81
|
+
key: "destinationOrigin",
|
|
82
|
+
required: false,
|
|
83
|
+
type: String,
|
|
84
|
+
default: "*"
|
|
85
|
+
},
|
|
86
|
+
callShow: {
|
|
87
|
+
key: "callShow",
|
|
88
|
+
required: false,
|
|
89
|
+
type: String,
|
|
90
|
+
default: "1"
|
|
91
|
+
},
|
|
92
|
+
transferToLaborShow: {
|
|
93
|
+
key: "transferToLaborShow",
|
|
94
|
+
required: false,
|
|
95
|
+
type: String,
|
|
96
|
+
default: "1"
|
|
97
|
+
},
|
|
98
|
+
restShow: {
|
|
99
|
+
key: "restShow",
|
|
100
|
+
required: false,
|
|
101
|
+
type: String,
|
|
102
|
+
default: "1"
|
|
103
|
+
},
|
|
104
|
+
networkDetectShow: {
|
|
105
|
+
key: "networkDetectShow",
|
|
106
|
+
required: false,
|
|
107
|
+
type: String,
|
|
108
|
+
default: "1"
|
|
109
|
+
},
|
|
110
|
+
muteShow: {
|
|
111
|
+
key: "muteShow",
|
|
112
|
+
required: false,
|
|
113
|
+
type: String,
|
|
114
|
+
default: "1"
|
|
115
|
+
},
|
|
116
|
+
logShow: {
|
|
117
|
+
key: "logShow",
|
|
118
|
+
required: false,
|
|
119
|
+
type: String,
|
|
120
|
+
default: "1"
|
|
121
|
+
},
|
|
122
|
+
timingShow: {
|
|
123
|
+
key: "timingShow",
|
|
124
|
+
required: false,
|
|
125
|
+
type: String,
|
|
126
|
+
default: "1"
|
|
127
|
+
},
|
|
128
|
+
signShow: {
|
|
129
|
+
key: "signShow",
|
|
130
|
+
required: false,
|
|
131
|
+
type: String,
|
|
132
|
+
default: "1"
|
|
84
133
|
}
|
|
85
134
|
};
|
|
86
135
|
__sfc_main.setup = (__props, __ctx) => {
|
|
@@ -90,54 +139,52 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
90
139
|
const container = ref();
|
|
91
140
|
const iframeContainer = ref();
|
|
92
141
|
const iframeDom = ref();
|
|
93
|
-
|
|
94
|
-
const getContextDomElement = (el) => {
|
|
95
|
-
const parent = (instance == null ? void 0 : instance.$el) || document;
|
|
96
|
-
return (props.selector ? parent.querySelector(props.selector) ?? document.querySelector(props.selector) ?? parent : parent).querySelector(el);
|
|
97
|
-
};
|
|
142
|
+
(_a = getCurrentInstance()) == null ? void 0 : _a.proxy;
|
|
98
143
|
const handlingCommunication = (e) => {
|
|
99
|
-
|
|
100
|
-
if (iframe) {
|
|
144
|
+
if (iframeDom.value) {
|
|
101
145
|
let data = {};
|
|
102
146
|
try {
|
|
103
147
|
data = JSON.parse(e.data);
|
|
104
148
|
} catch (e2) {
|
|
105
149
|
}
|
|
106
|
-
if (data.
|
|
107
|
-
if (data.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
150
|
+
if (data.ancestorOrigin === props.ancestorOrigin && data.origin !== props.ancestorOrigin || data.ancestorOrigin === props.origin && data.origin === props.origin) {
|
|
151
|
+
if (data.destinationOrigin === "*" || data.destinationOrigin === props.destinationOrigin) {
|
|
152
|
+
if (data.type === "softphone-expand") {
|
|
153
|
+
if (data.data === "expand") {
|
|
154
|
+
iframeDom.value.setAttribute("style", "position: fixed;z-index:999;");
|
|
155
|
+
} else if (data.data === "shrink") {
|
|
156
|
+
iframeDom.value.removeAttribute("style");
|
|
157
|
+
}
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (data.type === "softphone-connect") {
|
|
161
|
+
emit("softphone-connect", data);
|
|
162
|
+
} else if (data.type === "softphone-call-refresh") {
|
|
163
|
+
emit("softphone-call-refresh", data);
|
|
164
|
+
} else if (data.type === "softphone-seats-status-change") {
|
|
165
|
+
emit("softphone-seats-status-change", data);
|
|
166
|
+
} else if (data.type === "softphone-accept") {
|
|
167
|
+
emit("softphone-accept", data);
|
|
168
|
+
} else if (data.type === "softphone-ignore") {
|
|
169
|
+
emit("softphone-ignore", data);
|
|
170
|
+
} else if (data.type === "softphone-hangup") {
|
|
171
|
+
emit("softphone-hangup", data);
|
|
172
|
+
} else if (data.type === "softphone-session-state-change") {
|
|
173
|
+
emit("softphone-session-state-change", data);
|
|
174
|
+
} else if (data.type === "softphone-incoming") {
|
|
175
|
+
emit("softphone-incoming", data);
|
|
176
|
+
} else if (data.type === "softphone-send-dtmf") {
|
|
177
|
+
emit("softphone-send-dtmf", data);
|
|
178
|
+
} else if (data.type === "softphone-connect-registered") {
|
|
179
|
+
emit("softphone-connect-registered", data);
|
|
180
|
+
}
|
|
135
181
|
}
|
|
136
182
|
}
|
|
137
183
|
}
|
|
138
184
|
};
|
|
139
185
|
let timer;
|
|
140
186
|
const refreshStyle = async () => {
|
|
187
|
+
await nextTick();
|
|
141
188
|
clearTimeout(timer);
|
|
142
189
|
timer = void 0;
|
|
143
190
|
const containerStyle = container.value.getAttribute("style");
|
|
@@ -191,6 +238,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
191
238
|
type: "softphone-scroll",
|
|
192
239
|
origin: props.origin,
|
|
193
240
|
ancestorOrigin: props.ancestorOrigin,
|
|
241
|
+
destinationOrigin: props.destinationOrigin,
|
|
194
242
|
data: {
|
|
195
243
|
paddingTop: top + "px"
|
|
196
244
|
}
|
|
@@ -210,12 +258,30 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
210
258
|
agentId,
|
|
211
259
|
appSecret,
|
|
212
260
|
extStatus,
|
|
213
|
-
appKey
|
|
261
|
+
appKey,
|
|
262
|
+
ancestorOrigin,
|
|
263
|
+
destinationOrigin,
|
|
264
|
+
callShow,
|
|
265
|
+
transferToLaborShow,
|
|
266
|
+
restShow,
|
|
267
|
+
networkDetectShow,
|
|
268
|
+
muteShow,
|
|
269
|
+
logShow,
|
|
270
|
+
timingShow,
|
|
271
|
+
signShow
|
|
214
272
|
} = props;
|
|
215
273
|
let url = `${(envMap == null ? void 0 : envMap[env]) ?? env}/#/?cross=1&open=1`;
|
|
216
274
|
url += agentTag ? `&agentTag=${agentTag}` : "";
|
|
217
275
|
url += agentId ? `&agentId=${agentId}` : "";
|
|
218
|
-
url += `&appKey=${appKey}&appSecret=${appSecret}&extStatus=${extStatus}&paddingTop=${top}px&paddingLeft=${left}px`;
|
|
276
|
+
url += `&appKey=${appKey}&appSecret=${appSecret}&extStatus=${extStatus}&paddingTop=${top}px&paddingLeft=${left}px&ancestorOrigin=${ancestorOrigin}&destinationOrigin=${destinationOrigin}`;
|
|
277
|
+
url += `&callShow=${callShow}`;
|
|
278
|
+
url += `&transferToLaborShow=${transferToLaborShow}`;
|
|
279
|
+
url += `&restShow=${restShow}`;
|
|
280
|
+
url += `&networkDetectShow=${networkDetectShow}`;
|
|
281
|
+
url += `&muteShow=${muteShow}`;
|
|
282
|
+
url += `&logShow=${logShow}`;
|
|
283
|
+
url += `&timingShow=${timingShow}`;
|
|
284
|
+
url += `&signShow=${signShow}`;
|
|
219
285
|
iframeDom.value.src = url;
|
|
220
286
|
window.addEventListener("message", handlingCommunication, false);
|
|
221
287
|
if (props.scrollview) {
|
|
@@ -229,13 +295,16 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
229
295
|
if (props.scrollview) {
|
|
230
296
|
(_a2 = document.querySelector(props.scrollview)) == null ? void 0 : _a2.removeEventListener("scroll", handlingScroll);
|
|
231
297
|
(_b = document.querySelector(props.scrollview)) == null ? void 0 : _b.removeEventListener("scroll", handlingScrollTransparent);
|
|
298
|
+
clearTimeout(timer);
|
|
299
|
+
timer = void 0;
|
|
232
300
|
}
|
|
233
301
|
});
|
|
234
302
|
const postMessageCommunicate = (type, status) => {
|
|
235
303
|
var _a2;
|
|
236
304
|
(_a2 = iframeDom.value) == null ? void 0 : _a2.contentWindow.postMessage(JSON.stringify({
|
|
237
|
-
origin:
|
|
305
|
+
origin: "nf-softphone",
|
|
238
306
|
ancestorOrigin: props.ancestorOrigin,
|
|
307
|
+
destinationOrigin: props.destinationOrigin,
|
|
239
308
|
type,
|
|
240
309
|
data: {
|
|
241
310
|
status,
|
|
@@ -278,6 +347,8 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
278
347
|
hangup,
|
|
279
348
|
sendDtmf,
|
|
280
349
|
iframeDom,
|
|
350
|
+
iframeContainer,
|
|
351
|
+
container,
|
|
281
352
|
containerScrolling
|
|
282
353
|
});
|
|
283
354
|
};
|
|
@@ -311,7 +382,7 @@ var _sfc_render = function render() {
|
|
|
311
382
|
style: {
|
|
312
383
|
"display": _vm.containerScrolling === true ? "block" : "none"
|
|
313
384
|
}
|
|
314
|
-
}, [_vm._v(
|
|
385
|
+
}, [_vm._v(_vm._s(_vm.scrollingText))])]);
|
|
315
386
|
};
|
|
316
387
|
var _sfc_staticRenderFns = [];
|
|
317
388
|
var __component__ = /* @__PURE__ */ normalizeComponent(__sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, null, null, null);
|
|
@@ -319,8 +390,11 @@ const NfSoftphone = __component__.exports;
|
|
|
319
390
|
class SoftphoneManager {
|
|
320
391
|
constructor() {
|
|
321
392
|
this.option = {
|
|
322
|
-
origin: "
|
|
393
|
+
origin: "ai-softphone",
|
|
323
394
|
ancestorOrigin: "nf-softphone",
|
|
395
|
+
destinationOrigin: "*",
|
|
396
|
+
scrollview: void 0,
|
|
397
|
+
scrollingText: "正在滚动中...",
|
|
324
398
|
envMap: {
|
|
325
399
|
test: "http://softphone.test.k8s.com",
|
|
326
400
|
dev: "http://softphone.dev.k8s.com",
|
|
@@ -336,6 +410,14 @@ class SoftphoneManager {
|
|
|
336
410
|
appKey: void 0,
|
|
337
411
|
appSecret: void 0,
|
|
338
412
|
extStatus: "0",
|
|
413
|
+
callShow: "1",
|
|
414
|
+
transferToLaborShow: "1",
|
|
415
|
+
restShow: "1",
|
|
416
|
+
networkDetectShow: "1",
|
|
417
|
+
muteShow: "1",
|
|
418
|
+
logShow: "1",
|
|
419
|
+
timingShow: "1",
|
|
420
|
+
signShow: "1",
|
|
339
421
|
instanceMap: {},
|
|
340
422
|
softphoneConnectCallBack: () => {
|
|
341
423
|
console.log("softphone-connect");
|
|
@@ -369,9 +451,10 @@ class SoftphoneManager {
|
|
|
369
451
|
}
|
|
370
452
|
};
|
|
371
453
|
this.loadCssCode = (code) => {
|
|
372
|
-
|
|
454
|
+
const styleId = "nf-softphone";
|
|
455
|
+
if (!document.getElementById(styleId)) {
|
|
373
456
|
const style = document.createElement("style");
|
|
374
|
-
style.id =
|
|
457
|
+
style.id = styleId;
|
|
375
458
|
style.type = "text/css";
|
|
376
459
|
style.rel = "stylesheet";
|
|
377
460
|
style.appendChild(document.createTextNode(code));
|
|
@@ -380,7 +463,8 @@ class SoftphoneManager {
|
|
|
380
463
|
}
|
|
381
464
|
};
|
|
382
465
|
this.removeCssCode = () => {
|
|
383
|
-
const
|
|
466
|
+
const styleId = "nf-softphone";
|
|
467
|
+
const css = document.getElementById(styleId);
|
|
384
468
|
if (css) {
|
|
385
469
|
if (css.parentNode) {
|
|
386
470
|
css.parentNode.removeChild(css);
|
|
@@ -390,54 +474,91 @@ class SoftphoneManager {
|
|
|
390
474
|
this.getContextDomElement = (el) => {
|
|
391
475
|
return (this.option.selector ? document.querySelector(this.option.selector) ?? document : document).querySelector(el);
|
|
392
476
|
};
|
|
477
|
+
this.getSoftphoneDomElement = (el) => {
|
|
478
|
+
var _a;
|
|
479
|
+
return ((_a = this.getContextDomElement(this.option.el)) == null ? void 0 : _a.querySelector(el)) || this.getContextDomElement(el) || document.querySelector(el);
|
|
480
|
+
};
|
|
393
481
|
this.handlingCommunication = (e) => {
|
|
394
482
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
395
|
-
const iframe = this.
|
|
483
|
+
const iframe = this.getSoftphoneDomElement(".nf-softphone-iframe");
|
|
396
484
|
if (iframe) {
|
|
397
485
|
let data = {};
|
|
398
486
|
try {
|
|
399
487
|
data = JSON.parse(e.data);
|
|
400
488
|
} catch (e2) {
|
|
401
489
|
}
|
|
402
|
-
if (data.
|
|
403
|
-
if (data.
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
490
|
+
if (data.ancestorOrigin === this.option.ancestorOrigin && data.origin !== this.option.ancestorOrigin || data.ancestorOrigin === this.option.origin && data.origin === this.option.origin) {
|
|
491
|
+
if (data.destinationOrigin === "*" || data.destinationOrigin === this.option.destinationOrigin) {
|
|
492
|
+
if (data.type === "softphone-expand") {
|
|
493
|
+
if (data.data === "expand") {
|
|
494
|
+
iframe.setAttribute("style", "position: fixed;z-index:999;");
|
|
495
|
+
} else if (data.data === "shrink") {
|
|
496
|
+
iframe.removeAttribute("style");
|
|
497
|
+
}
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
if (data.type === "softphone-connect") {
|
|
501
|
+
(_b = (_a = this.option).softphoneConnectCallBack) == null ? void 0 : _b.call(_a, data);
|
|
502
|
+
} else if (data.type === "softphone-call-refresh") {
|
|
503
|
+
(_d = (_c = this.option).softphoneCallRefreshCallBack) == null ? void 0 : _d.call(_c, data);
|
|
504
|
+
} else if (data.type === "softphone-seats-status-change") {
|
|
505
|
+
(_f = (_e = this.option).softphoneSeatStatusChangeCallBack) == null ? void 0 : _f.call(_e, data);
|
|
506
|
+
} else if (data.type === "softphone-accept") {
|
|
507
|
+
(_h = (_g = this.option).softphoneAcceptCallBack) == null ? void 0 : _h.call(_g, data);
|
|
508
|
+
} else if (data.type === "softphone-ignore") {
|
|
509
|
+
(_j = (_i = this.option).softphoneIgnoreCallBack) == null ? void 0 : _j.call(_i, data);
|
|
510
|
+
} else if (data.type === "softphone-hangup") {
|
|
511
|
+
(_l = (_k = this.option).softphoneHangupCallBack) == null ? void 0 : _l.call(_k, data);
|
|
512
|
+
} else if (data.type === "softphone-session-state-change") {
|
|
513
|
+
(_n = (_m = this.option).softphoneSessionStateChangeCallBack) == null ? void 0 : _n.call(_m, data);
|
|
514
|
+
} else if (data.type === "softphone-incoming") {
|
|
515
|
+
(_p = (_o = this.option).softphoneIncomingCallBack) == null ? void 0 : _p.call(_o, data);
|
|
516
|
+
} else if (data.type === "softphone-send-dtmf") {
|
|
517
|
+
(_r = (_q = this.option).softphoneSendDtmfCallBack) == null ? void 0 : _r.call(_q, data);
|
|
518
|
+
} else if (data.type === "softphone-connect-registered") {
|
|
519
|
+
(_t = (_s = this.option).softphoneConnectRegisteredCallBack) == null ? void 0 : _t.call(_s, data);
|
|
520
|
+
}
|
|
431
521
|
}
|
|
432
522
|
}
|
|
433
523
|
}
|
|
434
524
|
};
|
|
525
|
+
this.handlingScroll = debounce(async () => {
|
|
526
|
+
var _a, _b;
|
|
527
|
+
const {
|
|
528
|
+
top,
|
|
529
|
+
left
|
|
530
|
+
} = await this.refreshStyle() || {};
|
|
531
|
+
if (top && left) {
|
|
532
|
+
(_b = (_a = this.getSoftphoneDomElement(".nf-softphone-iframe")) == null ? void 0 : _a.contentWindow) == null ? void 0 : _b.postMessage(JSON.stringify({
|
|
533
|
+
type: "softphone-scroll",
|
|
534
|
+
origin: this.option.origin,
|
|
535
|
+
ancestorOrigin: this.option.ancestorOrigin,
|
|
536
|
+
destinationOrigin: this.option.destinationOrigin,
|
|
537
|
+
data: {
|
|
538
|
+
paddingTop: top + "px"
|
|
539
|
+
}
|
|
540
|
+
}), "*");
|
|
541
|
+
}
|
|
542
|
+
}, 500, false);
|
|
435
543
|
this.handlerInteractive = () => {
|
|
544
|
+
var _a, _b;
|
|
436
545
|
window.addEventListener("message", this.handlingCommunication, false);
|
|
546
|
+
if (this.option.scrollview) {
|
|
547
|
+
(_a = document.querySelector(this.option.scrollview)) == null ? void 0 : _a.addEventListener("scroll", this.handlingScroll);
|
|
548
|
+
(_b = document.querySelector(this.option.scrollview)) == null ? void 0 : _b.addEventListener("scroll", this.handlingScrollTransparent);
|
|
549
|
+
}
|
|
437
550
|
this.loadCssCode(`
|
|
438
551
|
body,html {
|
|
439
552
|
overflow: hidden;
|
|
440
553
|
}
|
|
554
|
+
.nf-transparent {
|
|
555
|
+
visibility: hidden;
|
|
556
|
+
}
|
|
557
|
+
.nf-softphone-text {
|
|
558
|
+
text-align: center;
|
|
559
|
+
line-height: 32px;
|
|
560
|
+
margin-top: -32px;
|
|
561
|
+
}
|
|
441
562
|
.nf-softphone-container {
|
|
442
563
|
margin-left: 10px;
|
|
443
564
|
height: 32px;
|
|
@@ -464,14 +585,73 @@ class SoftphoneManager {
|
|
|
464
585
|
}
|
|
465
586
|
});
|
|
466
587
|
};
|
|
467
|
-
this.
|
|
468
|
-
|
|
588
|
+
this.handlingScrollTransparent = () => {
|
|
589
|
+
this.containerScrolling = true;
|
|
590
|
+
};
|
|
591
|
+
this.refreshStyle = async () => {
|
|
592
|
+
clearTimeout(this.timer);
|
|
593
|
+
this.timer = void 0;
|
|
594
|
+
const nfSoftphoneContainer = this.getSoftphoneDomElement(".nf-softphone-container");
|
|
595
|
+
const nfSoftphoneIframeContainer = this.getSoftphoneDomElement(".nf-softphone-iframe-container");
|
|
596
|
+
if (nfSoftphoneContainer && nfSoftphoneIframeContainer) {
|
|
597
|
+
const containerStyle = nfSoftphoneContainer.getAttribute("style");
|
|
598
|
+
const iframeContainerStyle = nfSoftphoneIframeContainer.getAttribute("style");
|
|
599
|
+
nfSoftphoneContainer.removeAttribute("style");
|
|
600
|
+
nfSoftphoneIframeContainer.removeAttribute("style");
|
|
601
|
+
const leftMargin = getComputedStyle(nfSoftphoneContainer).marginLeft;
|
|
602
|
+
const top = nfSoftphoneContainer.getBoundingClientRect().top;
|
|
603
|
+
if (top <= 0) {
|
|
604
|
+
nfSoftphoneContainer.setAttribute("style", containerStyle);
|
|
605
|
+
nfSoftphoneIframeContainer.setAttribute("style", iframeContainerStyle);
|
|
606
|
+
return {
|
|
607
|
+
top: 0,
|
|
608
|
+
left: 0,
|
|
609
|
+
leftMargin
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
const left = nfSoftphoneContainer.getBoundingClientRect().left;
|
|
613
|
+
if (left <= 0) {
|
|
614
|
+
nfSoftphoneContainer.setAttribute("style", containerStyle);
|
|
615
|
+
nfSoftphoneIframeContainer.setAttribute("style", iframeContainerStyle);
|
|
616
|
+
return {
|
|
617
|
+
top: 0,
|
|
618
|
+
left: 0,
|
|
619
|
+
leftMargin
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
nfSoftphoneContainer.setAttribute("style", `margin-top:${top}px;margin-left:${leftMargin};margin-bottom:${top}px;`);
|
|
623
|
+
nfSoftphoneIframeContainer.setAttribute("style", `margin-top:-${2 * top}px;margin-left:-${left}px;`);
|
|
624
|
+
this.timer = setTimeout(() => {
|
|
625
|
+
clearTimeout(this.timer);
|
|
626
|
+
this.timer = void 0;
|
|
627
|
+
this.containerScrolling = false;
|
|
628
|
+
}, 100);
|
|
629
|
+
return {
|
|
630
|
+
leftMargin,
|
|
631
|
+
top,
|
|
632
|
+
left
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
return {
|
|
636
|
+
leftMargin: 0,
|
|
637
|
+
top: 0,
|
|
638
|
+
left: 0
|
|
639
|
+
};
|
|
640
|
+
};
|
|
641
|
+
this.handlerDomGenerater = async () => {
|
|
642
|
+
const nfSoftphone = document.createElement("div");
|
|
643
|
+
const nfSoftphoneText = document.createElement("div");
|
|
644
|
+
nfSoftphoneText.innerText = this.option.scrollingText || "正在滚动中...";
|
|
645
|
+
const nfSoftphoneContainer = document.createElement("div");
|
|
469
646
|
const iframeContainer = document.createElement("div");
|
|
470
647
|
const iframe = document.createElement("iframe");
|
|
471
|
-
const uuid =
|
|
472
|
-
this.option.instanceMap[uuid] =
|
|
473
|
-
|
|
474
|
-
|
|
648
|
+
const uuid = this.id + "-container";
|
|
649
|
+
this.option.instanceMap[uuid] = nfSoftphone;
|
|
650
|
+
nfSoftphone.setAttribute("id", uuid);
|
|
651
|
+
nfSoftphone.setAttribute("class", "nf-softphone");
|
|
652
|
+
nfSoftphoneText.setAttribute("class", "nf-softphone-text");
|
|
653
|
+
nfSoftphoneText.setAttribute("style", "display: none;");
|
|
654
|
+
nfSoftphoneContainer.setAttribute("class", "nf-softphone-container");
|
|
475
655
|
iframeContainer.setAttribute("class", "nf-softphone-iframe-container");
|
|
476
656
|
iframe.setAttribute("class", "nf-softphone-iframe");
|
|
477
657
|
iframe.setAttribute("src", "");
|
|
@@ -479,14 +659,16 @@ class SoftphoneManager {
|
|
|
479
659
|
iframe.setAttribute("scrolling", "no");
|
|
480
660
|
iframe.setAttribute("allow", "camera *; microphone *");
|
|
481
661
|
iframeContainer.appendChild(iframe);
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
662
|
+
nfSoftphoneContainer.appendChild(iframeContainer);
|
|
663
|
+
nfSoftphone.appendChild(nfSoftphoneContainer);
|
|
664
|
+
nfSoftphone.appendChild(nfSoftphoneText);
|
|
665
|
+
const destination = this.option.el ? this.getSoftphoneDomElement(this.option.el) ?? document.body : document.body;
|
|
666
|
+
destination.appendChild(nfSoftphone);
|
|
667
|
+
await nextTick();
|
|
668
|
+
const {
|
|
669
|
+
top,
|
|
670
|
+
left
|
|
671
|
+
} = await this.refreshStyle();
|
|
490
672
|
const {
|
|
491
673
|
envMap,
|
|
492
674
|
env,
|
|
@@ -494,12 +676,30 @@ class SoftphoneManager {
|
|
|
494
676
|
agentId,
|
|
495
677
|
appSecret,
|
|
496
678
|
extStatus,
|
|
497
|
-
appKey
|
|
679
|
+
appKey,
|
|
680
|
+
ancestorOrigin,
|
|
681
|
+
destinationOrigin,
|
|
682
|
+
callShow,
|
|
683
|
+
transferToLaborShow,
|
|
684
|
+
restShow,
|
|
685
|
+
networkDetectShow,
|
|
686
|
+
muteShow,
|
|
687
|
+
logShow,
|
|
688
|
+
timingShow,
|
|
689
|
+
signShow
|
|
498
690
|
} = this.option;
|
|
499
691
|
let url = `${(envMap == null ? void 0 : envMap[env]) ?? env}/#/?cross=1&open=1`;
|
|
500
692
|
url += agentTag ? `&agentTag=${agentTag}` : "";
|
|
501
693
|
url += agentId ? `&agentId=${agentId}` : "";
|
|
502
|
-
url += `&appKey=${appKey}&appSecret=${appSecret}&extStatus=${extStatus}&paddingTop=${top}px&paddingLeft=${left}px`;
|
|
694
|
+
url += `&appKey=${appKey}&appSecret=${appSecret}&extStatus=${extStatus}&paddingTop=${top}px&paddingLeft=${left}px&ancestorOrigin=${ancestorOrigin}&destinationOrigin=${destinationOrigin}`;
|
|
695
|
+
url += `&callShow=${callShow}`;
|
|
696
|
+
url += `&transferToLaborShow=${transferToLaborShow}`;
|
|
697
|
+
url += `&restShow=${restShow}`;
|
|
698
|
+
url += `&networkDetectShow=${networkDetectShow}`;
|
|
699
|
+
url += `&muteShow=${muteShow}`;
|
|
700
|
+
url += `&logShow=${logShow}`;
|
|
701
|
+
url += `&timingShow=${timingShow}`;
|
|
702
|
+
url += `&signShow=${signShow}`;
|
|
503
703
|
iframe.src = url;
|
|
504
704
|
};
|
|
505
705
|
this.initSoftphone = (option) => {
|
|
@@ -509,11 +709,12 @@ class SoftphoneManager {
|
|
|
509
709
|
return this;
|
|
510
710
|
};
|
|
511
711
|
this.postMessageCommunicate = (type, status) => {
|
|
512
|
-
const iframe = this.
|
|
712
|
+
const iframe = this.getSoftphoneDomElement(".nf-softphone-iframe");
|
|
513
713
|
if (iframe) {
|
|
514
714
|
iframe.contentWindow.postMessage(JSON.stringify({
|
|
515
|
-
origin:
|
|
715
|
+
origin: "nf-softphone",
|
|
516
716
|
ancestorOrigin: this.option.ancestorOrigin,
|
|
717
|
+
destinationOrigin: this.option.destinationOrigin,
|
|
517
718
|
type,
|
|
518
719
|
data: {
|
|
519
720
|
status,
|
|
@@ -543,11 +744,34 @@ class SoftphoneManager {
|
|
|
543
744
|
this.sendDtmf = () => {
|
|
544
745
|
this.postMessageCommunicate("softphone-send-dtmf");
|
|
545
746
|
};
|
|
747
|
+
this.removeTimer = () => {
|
|
748
|
+
clearTimeout(this.timer);
|
|
749
|
+
this.timer = void 0;
|
|
750
|
+
};
|
|
546
751
|
this.destroy = () => {
|
|
752
|
+
var _a, _b;
|
|
547
753
|
window.removeEventListener("message", this.handlingCommunication, false);
|
|
754
|
+
if (this.option.scrollview) {
|
|
755
|
+
(_a = document.querySelector(this.option.scrollview)) == null ? void 0 : _a.removeEventListener("scroll", this.handlingScroll);
|
|
756
|
+
(_b = document.querySelector(this.option.scrollview)) == null ? void 0 : _b.removeEventListener("scroll", this.handlingScrollTransparent);
|
|
757
|
+
}
|
|
548
758
|
this.removeCssCode();
|
|
549
759
|
this.handlerDomRemove();
|
|
760
|
+
this.removeTimer();
|
|
550
761
|
};
|
|
762
|
+
this.id = generateUUID();
|
|
763
|
+
}
|
|
764
|
+
get containerScrolling() {
|
|
765
|
+
return this._containerScrolling;
|
|
766
|
+
}
|
|
767
|
+
set containerScrolling(value) {
|
|
768
|
+
if (this.containerScrolling !== value) {
|
|
769
|
+
this._containerScrolling = value;
|
|
770
|
+
const nfSoftphoneContainer = this.getSoftphoneDomElement(".nf-softphone-container");
|
|
771
|
+
const nfSoftphoneText = this.getSoftphoneDomElement(".nf-softphone-text");
|
|
772
|
+
nfSoftphoneContainer == null ? void 0 : nfSoftphoneContainer.setAttribute("class", `nf-softphone-container ${value === true ? "nf-transparent" : ""}`);
|
|
773
|
+
nfSoftphoneText == null ? void 0 : nfSoftphoneText.setAttribute("style", `display: ${value === true ? "block" : "none"}`);
|
|
774
|
+
}
|
|
551
775
|
}
|
|
552
776
|
}
|
|
553
777
|
const softphoneManager = new SoftphoneManager();
|