@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.
@@ -1,10 +1,9 @@
1
1
  import { Env } from './type';
2
2
  declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
+ scrollingText?: string | undefined;
3
4
  scrollview?: string | undefined;
4
5
  envMap?: Partial<Record<Env, string>> | undefined;
5
6
  env?: Env | undefined;
6
- selector?: string | undefined;
7
- el?: string | undefined;
8
7
  agentId?: string | undefined;
9
8
  agentTag?: string | undefined;
10
9
  appKey?: string | undefined;
@@ -12,7 +11,17 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
12
11
  extStatus?: string | undefined;
13
12
  origin?: string | undefined;
14
13
  ancestorOrigin?: string | undefined;
14
+ destinationOrigin?: string | undefined;
15
+ callShow?: "0" | "1" | undefined;
16
+ transferToLaborShow?: "0" | "1" | undefined;
17
+ restShow?: "0" | "1" | undefined;
18
+ networkDetectShow?: "0" | "1" | undefined;
19
+ muteShow?: "0" | "1" | undefined;
20
+ logShow?: "0" | "1" | undefined;
21
+ timingShow?: "0" | "1" | undefined;
22
+ signShow?: "0" | "1" | undefined;
15
23
  }>, {
24
+ scrollingText: string;
16
25
  scrollview: undefined;
17
26
  envMap: () => {
18
27
  test: string;
@@ -22,7 +31,6 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
22
31
  prod: string;
23
32
  };
24
33
  env: string;
25
- selector: undefined;
26
34
  agentId: undefined;
27
35
  agentTag: undefined;
28
36
  appKey: undefined;
@@ -30,6 +38,15 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
30
38
  extStatus: string;
31
39
  origin: string;
32
40
  ancestorOrigin: string;
41
+ destinationOrigin: string;
42
+ callShow: string;
43
+ transferToLaborShow: string;
44
+ restShow: string;
45
+ networkDetectShow: string;
46
+ muteShow: string;
47
+ logShow: string;
48
+ timingShow: string;
49
+ signShow: string;
33
50
  }>, {
34
51
  connect: () => void;
35
52
  disconnect: () => void;
@@ -39,6 +56,8 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
39
56
  hangup: () => void;
40
57
  sendDtmf: () => void;
41
58
  iframeDom: import("vue-demi").Ref<any>;
59
+ iframeContainer: import("vue-demi").Ref<any>;
60
+ container: import("vue-demi").Ref<any>;
42
61
  containerScrolling: import("vue-demi").Ref<any>;
43
62
  }, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {
44
63
  "softphone-connect": (event: any) => void;
@@ -52,11 +71,10 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
52
71
  "softphone-incoming": (event: any) => void;
53
72
  "softphone-connect-registered": (event: any) => void;
54
73
  }, string, Readonly<import("vue-demi").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
74
+ scrollingText?: string | undefined;
55
75
  scrollview?: string | undefined;
56
76
  envMap?: Partial<Record<Env, string>> | undefined;
57
77
  env?: Env | undefined;
58
- selector?: string | undefined;
59
- el?: string | undefined;
60
78
  agentId?: string | undefined;
61
79
  agentTag?: string | undefined;
62
80
  appKey?: string | undefined;
@@ -64,7 +82,17 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
64
82
  extStatus?: string | undefined;
65
83
  origin?: string | undefined;
66
84
  ancestorOrigin?: string | undefined;
85
+ destinationOrigin?: string | undefined;
86
+ callShow?: "0" | "1" | undefined;
87
+ transferToLaborShow?: "0" | "1" | undefined;
88
+ restShow?: "0" | "1" | undefined;
89
+ networkDetectShow?: "0" | "1" | undefined;
90
+ muteShow?: "0" | "1" | undefined;
91
+ logShow?: "0" | "1" | undefined;
92
+ timingShow?: "0" | "1" | undefined;
93
+ signShow?: "0" | "1" | undefined;
67
94
  }>, {
95
+ scrollingText: string;
68
96
  scrollview: undefined;
69
97
  envMap: () => {
70
98
  test: string;
@@ -74,7 +102,6 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
74
102
  prod: string;
75
103
  };
76
104
  env: string;
77
- selector: undefined;
78
105
  agentId: undefined;
79
106
  agentTag: undefined;
80
107
  appKey: undefined;
@@ -82,11 +109,20 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
82
109
  extStatus: string;
83
110
  origin: string;
84
111
  ancestorOrigin: string;
112
+ destinationOrigin: string;
113
+ callShow: string;
114
+ transferToLaborShow: string;
115
+ restShow: string;
116
+ networkDetectShow: string;
117
+ muteShow: string;
118
+ logShow: string;
119
+ timingShow: string;
120
+ signShow: string;
85
121
  }>>>, {
122
+ scrollingText: string;
86
123
  scrollview: string;
87
124
  envMap: Partial<Record<Env, string>>;
88
125
  env: Env;
89
- selector: string;
90
126
  agentId: string;
91
127
  agentTag: string;
92
128
  appKey: string;
@@ -94,6 +130,15 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
94
130
  extStatus: string;
95
131
  origin: string;
96
132
  ancestorOrigin: string;
133
+ destinationOrigin: string;
134
+ callShow: '0' | '1';
135
+ transferToLaborShow: '0' | '1';
136
+ restShow: '0' | '1';
137
+ networkDetectShow: '0' | '1';
138
+ muteShow: '0' | '1';
139
+ logShow: '0' | '1';
140
+ timingShow: '0' | '1';
141
+ signShow: '0' | '1';
97
142
  }>;
98
143
  export default _default;
99
144
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -1,9 +1,13 @@
1
1
  import { Option } from '../..nf-softphone/lib/type';
2
2
  export declare class SoftphoneManager {
3
+ id: any;
4
+ timer: any;
5
+ constructor();
3
6
  option: Partial<Option>;
4
7
  loadCssCode: (code: any) => void;
5
8
  removeCssCode: () => void;
6
9
  getContextDomElement: (el: string) => Element | null;
10
+ getSoftphoneDomElement: (el: string) => Element | null;
7
11
  handlingCommunication: (e: {
8
12
  data: `{
9
13
  type: string,
@@ -12,9 +16,23 @@ export declare class SoftphoneManager {
12
16
  data: 'expand' | 'shrink'
13
17
  }` | string;
14
18
  }) => void;
19
+ handlingScroll: (...args: any[]) => any;
15
20
  handlerInteractive: () => void;
16
21
  handlerDomRemove: () => void;
17
- handlerDomGenerater: () => void;
22
+ _containerScrolling: any;
23
+ get containerScrolling(): boolean;
24
+ set containerScrolling(value: boolean);
25
+ handlingScrollTransparent: () => void;
26
+ refreshStyle: () => Promise<{
27
+ top: number;
28
+ left: number;
29
+ leftMargin: string;
30
+ } | {
31
+ leftMargin: number;
32
+ top: number;
33
+ left: number;
34
+ }>;
35
+ handlerDomGenerater: () => Promise<void>;
18
36
  initSoftphone: (option: any) => this;
19
37
  postMessageCommunicate: (type: any, status?: boolean) => void;
20
38
  connect: () => void;
@@ -24,6 +42,7 @@ export declare class SoftphoneManager {
24
42
  ignore: () => void;
25
43
  hangup: () => void;
26
44
  sendDtmf: () => void;
45
+ removeTimer: () => void;
27
46
  destroy: () => void;
28
47
  }
29
48
  declare const softphoneManager: SoftphoneManager;
package/lib/type.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  export type Option = {
2
2
  origin: string;
3
3
  ancestorOrigin: string;
4
+ destinationOrigin: string;
5
+ scrollingText: string;
6
+ scrollview: string;
4
7
  envMap: Record<Env, string>;
5
8
  env: string;
6
9
  selector: string;
@@ -11,6 +14,14 @@ export type Option = {
11
14
  appSecret: string;
12
15
  extStatus: '0' | '1';
13
16
  instanceMap: Record<string, any>;
17
+ callShow: '0' | '1';
18
+ transferToLaborShow: '0' | '1';
19
+ restShow: '0' | '1';
20
+ networkDetectShow: '0' | '1';
21
+ muteShow: '0' | '1';
22
+ logShow: '0' | '1';
23
+ timingShow: '0' | '1';
24
+ signShow: '0' | '1';
14
25
  softphoneConnectCallBack: Function;
15
26
  softphoneCallRefreshCallBack: Function;
16
27
  softphoneSeatStatusChangeCallBack: Function;
@@ -12,7 +12,7 @@
12
12
  ></iframe>
13
13
  </div>
14
14
  </div>
15
- <div :class="{'nf-softphone-text': true}" :style="{'display': containerScrolling === true ? 'block' : 'none'}">正在滚动中...</div>
15
+ <div :class="{'nf-softphone-text': true}" :style="{'display': containerScrolling === true ? 'block' : 'none'}">{{ scrollingText }}</div>
16
16
  </div>
17
17
  </template>
18
18
 
@@ -30,25 +30,40 @@ import {
30
30
  getCurrentInstance,
31
31
  onMounted,
32
32
  ref,
33
- onUnmounted
33
+ onUnmounted,
34
+ nextTick
34
35
  } from 'vue-demi'
35
36
  import { debounce } from '@94ai/common-utils'
36
37
 
37
38
  const props = withDefaults(defineProps<{
39
+ scrollingText?: string,
38
40
  scrollview?: string,
41
+
39
42
  envMap?: Partial<Record<Env, string>>,
40
43
  env?: Env,
41
- selector?: string,
42
- el?: string,
44
+
43
45
  agentId?: string,
44
46
  agentTag?: string,
45
47
  appKey?: string,
46
48
  appSecret?: string,
47
49
  extStatus?: string,
50
+
48
51
  origin?: string,
49
52
  ancestorOrigin?: string,
53
+ destinationOrigin?: string,
54
+
55
+ callShow?: '0' | '1',
56
+ transferToLaborShow?: '0' | '1',
57
+ restShow?: '0' | '1',
58
+ networkDetectShow?: '0' | '1',
59
+ muteShow?: '0' | '1',
60
+ logShow?: '0' | '1',
61
+ timingShow?: '0' | '1',
62
+ signShow?: '0' | '1',
50
63
  }>(), {
64
+ scrollingText: '正在滚动中...',
51
65
  scrollview: undefined,
66
+
52
67
  envMap: () => ({
53
68
  test: 'http://softphone.test.k8s.com',
54
69
  dev: 'http://softphone.dev.k8s.com',
@@ -57,14 +72,25 @@ const props = withDefaults(defineProps<{
57
72
  prod: 'https://seat.94ai.com',
58
73
  }),
59
74
  env: 'test',
60
- selector: undefined,
75
+
61
76
  agentId: undefined,
62
77
  agentTag: undefined,
63
78
  appKey: undefined,
64
79
  appSecret: undefined,
65
80
  extStatus: '0',
66
- origin: 'nf-softphone',
67
- ancestorOrigin: 'nf-softphone'
81
+
82
+ origin: 'ai-softphone',
83
+ ancestorOrigin: 'nf-softphone',
84
+ destinationOrigin: '*',
85
+
86
+ callShow: '1',
87
+ transferToLaborShow: '1',
88
+ restShow: '1',
89
+ networkDetectShow: '1',
90
+ muteShow: '1',
91
+ logShow: '1',
92
+ timingShow: '1',
93
+ signShow: '1',
68
94
  })
69
95
 
70
96
  const emit = defineEmits<{
@@ -85,59 +111,58 @@ const iframeContainer = ref()
85
111
  const iframeDom = ref()
86
112
  const instance = getCurrentInstance()?.proxy
87
113
 
88
- const getContextDomElement = (el: string) => {
89
- const parent = instance?.$el || document
90
- return (props.selector ? (parent.querySelector(props.selector) ?? document.querySelector(props.selector) ?? parent) : parent).querySelector(el)
91
- }
92
-
93
114
  const handlingCommunication = (e: {data: `{
94
115
  type: string,
95
116
  ancestorOrigin: string,
117
+ destinationOrigin: string,
96
118
  origin: string,
97
119
  data: 'expand' | 'shrink'
98
120
  }` | string}) => {
99
- const iframe = getContextDomElement('.nf-softphone-iframe')
100
- if (iframe) {
121
+ if (iframeDom.value) {
101
122
  let data: Record<string, any> = {}
102
123
  try {
103
124
  data = JSON.parse(e.data)
104
125
  } catch (e) {}
105
- if (data.type === 'softphone-expand') {
106
- if (data.data === 'expand') {
107
- iframe.setAttribute('style', 'position: fixed;z-index:999;');
108
- } else if (data.data === 'shrink') {
109
- iframe.removeAttribute('style');
110
- }
111
- return
112
- }
113
- if (data.origin === 'ai-softphone') {
114
- if (data.type === 'softphone-connect') {
115
- emit('softphone-connect', data)
116
- } else if (data.type === 'softphone-call-refresh') {
117
- emit('softphone-call-refresh', data)
118
- } else if (data.type === 'softphone-seats-status-change') {
119
- emit('softphone-seats-status-change', data)
120
- } else if (data.type === 'softphone-accept') {
121
- emit('softphone-accept', data)
122
- } else if (data.type === 'softphone-ignore') {
123
- emit('softphone-ignore', data)
124
- } else if (data.type === 'softphone-hangup') {
125
- emit('softphone-hangup', data)
126
- } else if (data.type === 'softphone-session-state-change') {
127
- emit('softphone-session-state-change', data)
128
- } else if (data.type === 'softphone-incoming') {
129
- emit('softphone-incoming', data)
130
- } else if (data.type === 'softphone-send-dtmf') {
131
- emit('softphone-send-dtmf', data)
132
- } else if (data.type === 'softphone-connect-registered') {
133
- emit('softphone-connect-registered', data)
134
- }
135
- }
126
+ if ((data.ancestorOrigin === props.ancestorOrigin && data.origin !== props.ancestorOrigin) ||
127
+ (data.ancestorOrigin === props.origin && data.origin === props.origin)) {
128
+ if (data.destinationOrigin === '*' || data.destinationOrigin === props.destinationOrigin) {
129
+ if (data.type === 'softphone-expand') {
130
+ if (data.data === 'expand') {
131
+ iframeDom.value.setAttribute('style', 'position: fixed;z-index:999;');
132
+ } else if (data.data === 'shrink') {
133
+ iframeDom.value.removeAttribute('style');
134
+ }
135
+ return
136
+ }
137
+ if (data.type === 'softphone-connect') {
138
+ emit('softphone-connect', data)
139
+ } else if (data.type === 'softphone-call-refresh') {
140
+ emit('softphone-call-refresh', data)
141
+ } else if (data.type === 'softphone-seats-status-change') {
142
+ emit('softphone-seats-status-change', data)
143
+ } else if (data.type === 'softphone-accept') {
144
+ emit('softphone-accept', data)
145
+ } else if (data.type === 'softphone-ignore') {
146
+ emit('softphone-ignore', data)
147
+ } else if (data.type === 'softphone-hangup') {
148
+ emit('softphone-hangup', data)
149
+ } else if (data.type === 'softphone-session-state-change') {
150
+ emit('softphone-session-state-change', data)
151
+ } else if (data.type === 'softphone-incoming') {
152
+ emit('softphone-incoming', data)
153
+ } else if (data.type === 'softphone-send-dtmf') {
154
+ emit('softphone-send-dtmf', data)
155
+ } else if (data.type === 'softphone-connect-registered') {
156
+ emit('softphone-connect-registered', data)
157
+ }
158
+ }
159
+ }
136
160
  }
137
161
  }
138
162
  let timer
139
163
 
140
164
  const refreshStyle = async () => {
165
+ await nextTick()
141
166
  clearTimeout(timer)
142
167
  timer = undefined
143
168
  const containerStyle = container.value.getAttribute('style')
@@ -191,6 +216,7 @@ const handlingScroll = debounce(async () => {
191
216
  type: 'softphone-scroll',
192
217
  origin: props.origin,
193
218
  ancestorOrigin: props.ancestorOrigin,
219
+ destinationOrigin: props.destinationOrigin,
194
220
  data: {
195
221
  paddingTop: top + 'px',
196
222
  }
@@ -210,12 +236,30 @@ onMounted(async () => {
210
236
  agentId,
211
237
  appSecret,
212
238
  extStatus,
213
- appKey
239
+ appKey,
240
+ ancestorOrigin,
241
+ destinationOrigin,
242
+ callShow,
243
+ transferToLaborShow,
244
+ restShow,
245
+ networkDetectShow,
246
+ muteShow,
247
+ logShow,
248
+ timingShow,
249
+ signShow,
214
250
  } = props
215
251
  let url = `${ envMap?.[env!] ?? env }/#/?cross=1&open=1`
216
252
  url += agentTag ? `&agentTag=${agentTag}` : ''
217
253
  url += agentId ? `&agentId=${agentId}` : ''
218
- url += `&appKey=${appKey}&appSecret=${appSecret}&extStatus=${extStatus}&paddingTop=${top}px&paddingLeft=${left}px`
254
+ url += `&appKey=${appKey}&appSecret=${appSecret}&extStatus=${extStatus}&paddingTop=${top}px&paddingLeft=${left}px&ancestorOrigin=${ancestorOrigin}&destinationOrigin=${destinationOrigin}`
255
+ url += `&callShow=${callShow}`
256
+ url += `&transferToLaborShow=${transferToLaborShow}`
257
+ url += `&restShow=${restShow}`
258
+ url += `&networkDetectShow=${networkDetectShow}`
259
+ url += `&muteShow=${muteShow}`
260
+ url += `&logShow=${logShow}`
261
+ url += `&timingShow=${timingShow}`
262
+ url += `&signShow=${signShow}`
219
263
  iframeDom.value.src = url
220
264
  window.addEventListener('message', handlingCommunication, false);
221
265
  if (props.scrollview) {
@@ -229,13 +273,16 @@ onUnmounted(() => {
229
273
  if (props.scrollview) {
230
274
  document.querySelector(props.scrollview)?.removeEventListener('scroll', handlingScroll)
231
275
  document.querySelector(props.scrollview)?.removeEventListener('scroll', handlingScrollTransparent)
276
+ clearTimeout(timer)
277
+ timer = undefined
232
278
  }
233
279
  })
234
280
 
235
281
  const postMessageCommunicate = (type, status?: boolean) => {
236
282
  iframeDom.value?.contentWindow.postMessage(JSON.stringify({
237
- origin: props.origin,
283
+ origin: 'nf-softphone',
238
284
  ancestorOrigin: props.ancestorOrigin,
285
+ destinationOrigin: props.destinationOrigin,
239
286
  type,
240
287
  data: {
241
288
  status,
@@ -278,6 +325,8 @@ defineExpose({
278
325
  hangup,
279
326
  sendDtmf,
280
327
  iframeDom,
328
+ iframeContainer,
329
+ container,
281
330
  containerScrolling
282
331
  })
283
332