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