@94ai/nf-microphone 6.1.30 → 8.0.1

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,8 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
7
7
  agentTag?: string | undefined;
8
8
  appKey?: string | undefined;
9
9
  appSecret?: string | undefined;
10
+ timestamp?: string | number | undefined;
11
+ sign?: string | undefined;
10
12
  extStatus?: string | undefined;
11
13
  origin?: string | undefined;
12
14
  ancestorOrigin?: string | undefined;
@@ -95,6 +97,8 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
95
97
  origin: string;
96
98
  ancestorOrigin: string;
97
99
  destinationOrigin: string;
100
+ timestamp: undefined;
101
+ sign: undefined;
98
102
  callShow: string;
99
103
  transferToLaborShow: string;
100
104
  restShow: string;
@@ -109,7 +113,10 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
109
113
  isOem: boolean;
110
114
  accessMode: string;
111
115
  numberKeyBoard: boolean;
112
- sgOpen: string;
116
+ sgOpen: undefined;
117
+ sgDomain: undefined;
118
+ sgBase: undefined;
119
+ sgGateway: undefined;
113
120
  open: string;
114
121
  }>, {
115
122
  connect: () => void;
@@ -131,6 +138,9 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
131
138
  "softphone-session-state-change": (event: any) => void;
132
139
  "softphone-incoming": (event: any) => void;
133
140
  "softphone-connect-registered": (event: any) => void;
141
+ "softphone-sign-overdued": (event: any) => void;
142
+ "update:sign": (event: any) => void;
143
+ "update:timestamp": (event: any) => void;
134
144
  }, string, Readonly<import("vue-demi").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
135
145
  mode?: "qiankun" | "wujie" | undefined;
136
146
  envMap?: Partial<Record<Env, Record<string, any>>> | undefined;
@@ -139,6 +149,8 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
139
149
  agentTag?: string | undefined;
140
150
  appKey?: string | undefined;
141
151
  appSecret?: string | undefined;
152
+ timestamp?: string | number | undefined;
153
+ sign?: string | undefined;
142
154
  extStatus?: string | undefined;
143
155
  origin?: string | undefined;
144
156
  ancestorOrigin?: string | undefined;
@@ -227,6 +239,8 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
227
239
  origin: string;
228
240
  ancestorOrigin: string;
229
241
  destinationOrigin: string;
242
+ timestamp: undefined;
243
+ sign: undefined;
230
244
  callShow: string;
231
245
  transferToLaborShow: string;
232
246
  restShow: string;
@@ -241,12 +255,17 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
241
255
  isOem: boolean;
242
256
  accessMode: string;
243
257
  numberKeyBoard: boolean;
244
- sgOpen: string;
258
+ sgOpen: undefined;
259
+ sgDomain: undefined;
260
+ sgBase: undefined;
261
+ sgGateway: undefined;
245
262
  open: string;
246
263
  }>>>, {
247
264
  mode: 'qiankun' | 'wujie';
248
265
  envMap: Partial<Record<Env, Record<string, any>>>;
249
266
  env: Env;
267
+ timestamp: string | number;
268
+ sign: string;
250
269
  extStatus: string;
251
270
  origin: string;
252
271
  ancestorOrigin: string;
@@ -265,8 +284,11 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
265
284
  isOem: boolean;
266
285
  numberKeyBoard: boolean;
267
286
  accessMode: 'mobile' | 'pc';
287
+ sgGateway: string;
268
288
  open: string;
269
289
  sgOpen: string;
290
+ sgDomain: string;
291
+ sgBase: string;
270
292
  }>;
271
293
  export default _default;
272
294
  declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
package/lib/types.d.ts CHANGED
@@ -7,6 +7,8 @@ export declare type Option = {
7
7
  agentTag?: string;
8
8
  appKey?: string;
9
9
  appSecret?: string;
10
+ timestamp?: number | string;
11
+ sign?: string;
10
12
  extStatus?: string;
11
13
  origin?: string;
12
14
  ancestorOrigin?: string;
@@ -73,4 +75,5 @@ export declare type Option = {
73
75
  softphoneIncomingCallBack: Function;
74
76
  softphoneSendDtmfCallBack: Function;
75
77
  softphoneConnectRegisteredCallBack: Function;
78
+ softphoneSignOverduedCallBack: Function;
76
79
  };
@@ -20,7 +20,13 @@ export class SoftphoneManager {
20
20
  isOem: true,
21
21
  accessMode: 'pc',
22
22
  numberKeyBoard: true,
23
- sgOpen: '1',
23
+
24
+ sgGateway: undefined,
25
+ sgBase: undefined,
26
+ sgOpen: undefined,
27
+ sgDomain: undefined,
28
+ timestamp: undefined,
29
+ sign: undefined,
24
30
  open: '1',
25
31
 
26
32
  envMap: {
@@ -78,6 +84,12 @@ export class SoftphoneManager {
78
84
  softphoneIncomingCallBack: () => {console.log('softphone-incoming')},
79
85
  softphoneSendDtmfCallBack: () => {console.log('softphone-send-dtmf')},
80
86
  softphoneConnectRegisteredCallBack: () => {console.log('softphone-connect-registered')},
87
+ softphoneSignOverduedCallBack: (done) => {
88
+ done({
89
+ timestamp: undefined,
90
+ sign: undefined
91
+ })
92
+ },
81
93
  }
82
94
 
83
95
  initSoftphone = (option) => {
@@ -86,12 +98,21 @@ export class SoftphoneManager {
86
98
  }
87
99
  const props = this.option = option ? { ...this.option, ...option } :this.option
88
100
 
101
+ const setUserInfo = (userInfo) => {
102
+ if (userInfo.sign && props.sign && userInfo.sign !== props.sign) {
103
+ this.option.sign = userInfo.sign
104
+ this.option.timestamp = userInfo.timestamp
105
+ }
106
+ }
107
+
89
108
  const getUserInfo = () => {
90
109
  const {
91
110
  agentId,
92
111
  agentTag,
93
112
  appKey,
94
113
  appSecret,
114
+ timestamp,
115
+ sign,
95
116
  extStatus,
96
117
  origin,
97
118
  ancestorOrigin,
@@ -148,6 +169,8 @@ export class SoftphoneManager {
148
169
  agentTag,
149
170
  appKey,
150
171
  appSecret,
172
+ timestamp,
173
+ sign,
151
174
  extStatus,
152
175
  origin,
153
176
  ancestorOrigin,
@@ -291,38 +314,62 @@ export class SoftphoneManager {
291
314
  }
292
315
 
293
316
  getSoftPhoneShowCall () {
294
- return props.callShow
317
+ if (props.callShow === '0') {
318
+ return false
319
+ }
320
+ return true
295
321
  }
296
322
 
297
323
  getSoftPhoneShowTransferToLabor () {
298
- return props.transferToLaborShow
324
+ if (props.transferToLaborShow === '0') {
325
+ return false
326
+ }
327
+ return true
299
328
  }
300
329
 
301
330
  getSoftPhoneShowRest () {
302
- return props.restShow
331
+ if (props.restShow === '0') {
332
+ return false
333
+ }
334
+ return true
303
335
  }
304
336
 
305
337
  getSoftPhoneShowNetworkDetect () {
306
- return props.networkDetectShow
338
+ if (props.networkDetectShow === '0') {
339
+ return false
340
+ }
341
+ return true
307
342
  }
308
343
 
309
344
  getSoftPhoneShowMute () {
310
- return props.muteShow
345
+ if (props.muteShow === '0') {
346
+ return false
347
+ }
348
+ return true
311
349
  }
312
350
 
313
351
  /**
314
352
  * 是否展示对话记录功能
315
353
  */
316
354
  getSoftPhoneShowLog() {
317
- return props.logShow
355
+ if (props.logShow === '0') {
356
+ return false
357
+ }
358
+ return true
318
359
  }
319
360
 
320
361
  getSoftPhoneShowTiming () {
321
- return props.timingShow
362
+ if (props.timingShow === '0') {
363
+ return false
364
+ }
365
+ return true
322
366
  }
323
367
 
324
368
  getSoftPhoneShowSign () {
325
- return props.signShow
369
+ if (props.signShow === '0') {
370
+ return false
371
+ }
372
+ return true
326
373
  }
327
374
 
328
375
  /**
@@ -364,62 +411,6 @@ export class SoftphoneManager {
364
411
  }
365
412
  }
366
413
 
367
- // 通知
368
- class SoftphoneNotity {
369
- communicationList = {
370
- 'softphone-connect-registered': (data) => {
371
- props.softphoneConnectRegisteredCallBack?.(data)
372
- },
373
- 'softphone-session-state-change': (data) => {
374
- props.softphoneSessionStateChangeCallBack?.(data)
375
- },
376
- 'softphone-call-refresh': (data) => {
377
- props.softphoneCallRefreshCallBack?.(data)
378
- },
379
- 'softphone-connect': (data) => {
380
- props.softphoneConnectCallBack?.(data)
381
- },
382
- 'softphone-accept': (data) => {
383
- props.softphoneAcceptCallBack?.(data)
384
- },
385
- 'softphone-seats-status-change': (data) => {
386
- props.softphoneSeatStatusChangeCallBack?.(data)
387
- },
388
- 'softphone-ignore': (data) => {
389
- props.softphoneIgnoreCallBack?.(data)
390
- },
391
- 'softphone-hangup': (data) => {
392
- props.softphoneHangupCallBack?.(data)
393
- },
394
- 'softphone-incoming': (data) => {
395
- props.softphoneIncomingCallBack?.(data)
396
- },
397
- 'softphone-send-dtmf': (data) => {
398
- props.softphoneSendDtmfCallBack?.(data)
399
- },
400
- }
401
- useQinkunSoftphoneNotity = (state) => {
402
- if ((state.ancestorOrigin === props.ancestorOrigin && state.origin !== props.ancestorOrigin) ||
403
- (state.ancestorOrigin === props.origin && state.origin === props.origin)) {
404
- if (state.destinationOrigin === '*' || state.destinationOrigin === props.destinationOrigin) {
405
- this.communicationList[state.type]?.(state.data)
406
- }
407
- }
408
- }
409
- useWujieSoftphoneNotity() {
410
- Object.keys(this.communicationList).forEach(key => {
411
- bus.$on(key, (state) => {
412
- if ((state.ancestorOrigin === props.ancestorOrigin && state.origin !== props.ancestorOrigin) ||
413
- (state.ancestorOrigin === props.origin && state.origin === props.origin)) {
414
- if (state.destinationOrigin === '*' || state.destinationOrigin === props.destinationOrigin) {
415
- this.communicationList[key]?.(state.data)
416
- }
417
- }
418
- })
419
- })
420
- }
421
- }
422
-
423
414
  // 实例+动作管理
424
415
  class MicroManager {
425
416
  showSoftPhone = true
@@ -437,15 +428,21 @@ export class SoftphoneManager {
437
428
  return bus
438
429
  }
439
430
 
440
- microCommunicat(type: string, status?: boolean) {
431
+ microCommunicat(
432
+ type: string,
433
+ data: Record<string, any> = {},
434
+ operationType = 'manual',
435
+ ancestorOrigin = props.ancestorOrigin,
436
+ destinationOrigin = props.destinationOrigin
437
+ ) {
441
438
  const state = {
442
439
  origin: 'nf-softphone',
443
- ancestorOrigin: props.ancestorOrigin,
444
- destinationOrigin: props.destinationOrigin,
440
+ ancestorOrigin: ancestorOrigin || props.ancestorOrigin,
441
+ destinationOrigin: destinationOrigin || props.destinationOrigin,
445
442
  type,
446
443
  data: {
447
- status,
448
- type: 'manual'
444
+ ...data,
445
+ type: operationType
449
446
  }
450
447
  }
451
448
  if (this.mode === 'qiankun') {
@@ -458,15 +455,21 @@ export class SoftphoneManager {
458
455
 
459
456
  // 签入
460
457
  connect() {
461
- this.microCommunicat('softphone-connect', true)
458
+ this.microCommunicat('softphone-connect', {
459
+ status: true
460
+ })
462
461
  }
463
462
 
464
463
  disconnect() {
465
- this.microCommunicat('softphone-connect', false)
464
+ this.microCommunicat('softphone-connect', {
465
+ status: false
466
+ })
466
467
  }
467
468
 
468
469
  seatsStatusChange(status: boolean) {
469
- this.microCommunicat('softphone-connect', status)
470
+ this.microCommunicat('softphone-connect', {
471
+ status
472
+ })
470
473
  }
471
474
  accept() {
472
475
  this.microCommunicat('softphone-connect')
@@ -481,6 +484,10 @@ export class SoftphoneManager {
481
484
  this.microCommunicat('softphone-send-dtmf')
482
485
  }
483
486
 
487
+ signOverdued(data) {
488
+ this.microCommunicat('softphone-sign-overdued', data, 'auto', props.ancestorOrigin, 'ai-softphone')
489
+ }
490
+
484
491
  changeServerToRegister() {
485
492
  this.microCommunicat('softphone-change-server-to-register')
486
493
  }
@@ -562,7 +569,7 @@ export class SoftphoneManager {
562
569
  loadQiankunMicroApps() {
563
570
  const appConfig = this.getMicroAppConfig()[0]
564
571
  appConfig.props.shared.getUserInfo = getUserInfo
565
- appConfig.props.shared.setUserInfo = () => {}
572
+ appConfig.props.shared.setUserInfo = setUserInfo
566
573
  this.initState()
567
574
  this.app = loadMicroApp(appConfig, {
568
575
  sandbox: {
@@ -589,7 +596,7 @@ export class SoftphoneManager {
589
596
  const appConfig = this.getMicroAppConfig()[0]
590
597
  const url = appConfig.entry
591
598
  appConfig.props.shared.getUserInfo = getUserInfo
592
- appConfig.props.shared.setUserInfo = () => {}
599
+ appConfig.props.shared.setUserInfo = setUserInfo
593
600
 
594
601
  setupApp({
595
602
  name: props.name,
@@ -629,7 +636,7 @@ export class SoftphoneManager {
629
636
  registerQiankunMicroApps() {
630
637
  const appConfig = this.getMicroAppConfig()[0]
631
638
  appConfig.props.shared.getUserInfo = getUserInfo
632
- appConfig.props.shared.setUserInfo = () => {}
639
+ appConfig.props.shared.setUserInfo = setUserInfo
633
640
 
634
641
  registerMicroApps([appConfig], {
635
642
  // qiankun 生命周期钩子 - 加载前
@@ -681,7 +688,76 @@ export class SoftphoneManager {
681
688
  }
682
689
  }
683
690
 
684
- this.nfMicrophoneInstance = new MicroManager()
691
+ const nfMicrophoneInstance = this.nfMicrophoneInstance = new MicroManager()
692
+
693
+ // 通知
694
+ class SoftphoneNotity {
695
+ communicationList = {
696
+ 'softphone-connect-registered': (data) => {
697
+ props.softphoneConnectRegisteredCallBack?.(data)
698
+ },
699
+ 'softphone-session-state-change': (data) => {
700
+ props.softphoneSessionStateChangeCallBack?.(data)
701
+ },
702
+ 'softphone-call-refresh': (data) => {
703
+ props.softphoneCallRefreshCallBack?.(data)
704
+ },
705
+ 'softphone-connect': (data) => {
706
+ props.softphoneConnectCallBack?.(data)
707
+ },
708
+ 'softphone-accept': (data) => {
709
+ props.softphoneAcceptCallBack?.(data)
710
+ },
711
+ 'softphone-seats-status-change': (data) => {
712
+ props.softphoneSeatStatusChangeCallBack?.(data)
713
+ },
714
+ 'softphone-ignore': (data) => {
715
+ props.softphoneIgnoreCallBack?.(data)
716
+ },
717
+ 'softphone-hangup': (data) => {
718
+ props.softphoneHangupCallBack?.(data)
719
+ },
720
+ 'softphone-incoming': (data) => {
721
+ props.softphoneIncomingCallBack?.(data)
722
+ },
723
+ 'softphone-send-dtmf': (data) => {
724
+ props.softphoneSendDtmfCallBack?.(data)
725
+ },
726
+ 'softphone-sign-overdued': () => {
727
+ const done = (data) => {
728
+ const {
729
+ sign,
730
+ timestamp
731
+ } = data
732
+ nfMicrophoneInstance.signOverdued({
733
+ sign,
734
+ timestamp
735
+ })
736
+ }
737
+ props.softphoneSignOverduedCallBack?.(done)
738
+ },
739
+ }
740
+ useQinkunSoftphoneNotity = (state) => {
741
+ if ((state.ancestorOrigin === props.ancestorOrigin && state.origin !== props.ancestorOrigin) ||
742
+ (state.ancestorOrigin === props.origin && state.origin === props.origin)) {
743
+ if (state.destinationOrigin === '*' || state.destinationOrigin === props.destinationOrigin) {
744
+ this.communicationList[state.type]?.(state.data)
745
+ }
746
+ }
747
+ }
748
+ useWujieSoftphoneNotity() {
749
+ Object.keys(this.communicationList).forEach(key => {
750
+ bus.$on(key, (state) => {
751
+ if ((state.ancestorOrigin === props.ancestorOrigin && state.origin !== props.ancestorOrigin) ||
752
+ (state.ancestorOrigin === props.origin && state.origin === props.origin)) {
753
+ if (state.destinationOrigin === '*' || state.destinationOrigin === props.destinationOrigin) {
754
+ this.communicationList[key]?.(state.data)
755
+ }
756
+ }
757
+ })
758
+ })
759
+ }
760
+ }
685
761
 
686
762
  // 注册软电话微应用
687
763
  if (this.option.mode === 'qiankun') {