@94ai/nf-softphone 8.3.10 → 8.3.11
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/nf-softphone.cjs.js +2 -2
- package/lib/nf-softphone.esm-bundler.js +2 -2
- package/lib/softphone-pure.d.ts +90 -90
- package/package/html/softphone.html +76 -0
- package/package/{softphone-pure.html → html/softphone.js} +2 -204
- package/package/html/util.js +124 -0
- package/package/nf-softphone.vue +1 -1
- package/package/softphone-pure.ts +1 -1
- package/package/softphone.ts +1 -1
- package/package.json +3 -3
package/lib/nf-softphone.cjs.js
CHANGED
|
@@ -50,7 +50,7 @@ __sfc_main.props = {
|
|
|
50
50
|
default: () => ({
|
|
51
51
|
test: "http://softphone.test.k8s.com",
|
|
52
52
|
dev: "http://softphone.dev.k8s.com",
|
|
53
|
-
sg: "https://
|
|
53
|
+
sg: "https://seat.teleai.com",
|
|
54
54
|
gray: "http://softphone.gray.94ai.com",
|
|
55
55
|
prod: "https://seat.94ai.com"
|
|
56
56
|
})
|
|
@@ -470,7 +470,7 @@ class SoftphoneManager {
|
|
|
470
470
|
envMap: {
|
|
471
471
|
test: "http://softphone.test.k8s.com",
|
|
472
472
|
dev: "http://softphone.dev.k8s.com",
|
|
473
|
-
sg: "https://
|
|
473
|
+
sg: "https://seat.teleai.com",
|
|
474
474
|
gray: "http://softphone.gray.94ai.com",
|
|
475
475
|
prod: "https://seat.94ai.com"
|
|
476
476
|
},
|
|
@@ -48,7 +48,7 @@ __sfc_main.props = {
|
|
|
48
48
|
default: () => ({
|
|
49
49
|
test: "http://softphone.test.k8s.com",
|
|
50
50
|
dev: "http://softphone.dev.k8s.com",
|
|
51
|
-
sg: "https://
|
|
51
|
+
sg: "https://seat.teleai.com",
|
|
52
52
|
gray: "http://softphone.gray.94ai.com",
|
|
53
53
|
prod: "https://seat.94ai.com"
|
|
54
54
|
})
|
|
@@ -468,7 +468,7 @@ class SoftphoneManager {
|
|
|
468
468
|
envMap: {
|
|
469
469
|
test: "http://softphone.test.k8s.com",
|
|
470
470
|
dev: "http://softphone.dev.k8s.com",
|
|
471
|
-
sg: "https://
|
|
471
|
+
sg: "https://seat.teleai.com",
|
|
472
472
|
gray: "http://softphone.gray.94ai.com",
|
|
473
473
|
prod: "https://seat.94ai.com"
|
|
474
474
|
},
|
package/lib/softphone-pure.d.ts
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
declare type Option = {
|
|
2
|
-
origin: string;
|
|
3
|
-
ancestorOrigin: string;
|
|
4
|
-
destinationOrigin: string;
|
|
5
|
-
scrollingText: string;
|
|
6
|
-
scrollview: string;
|
|
7
|
-
envMap: Record<Env, string>;
|
|
8
|
-
env: string;
|
|
9
|
-
selector: string;
|
|
10
|
-
el: string;
|
|
11
|
-
agentTag: string;
|
|
12
|
-
agentId: string;
|
|
13
|
-
appKey: string;
|
|
14
|
-
appSecret: string;
|
|
15
|
-
timestamp: string | number;
|
|
16
|
-
sign: string;
|
|
17
|
-
sgGateway: string;
|
|
18
|
-
sgBase: string;
|
|
19
|
-
sgOpen: string;
|
|
20
|
-
sgDomain: string;
|
|
21
|
-
extStatus: '0' | '1';
|
|
22
|
-
instanceMap: Record<string, any>;
|
|
23
|
-
callShow: '0' | '1';
|
|
24
|
-
transferToLaborShow: '0' | '1';
|
|
25
|
-
restShow: '0' | '1';
|
|
26
|
-
networkDetectShow: '0' | '1';
|
|
27
|
-
muteShow: '0' | '1';
|
|
28
|
-
logShow: '0' | '1';
|
|
29
|
-
timingShow: '0' | '1';
|
|
30
|
-
signShow: '0' | '1';
|
|
31
|
-
softphoneConnectCallBack: Function;
|
|
32
|
-
softphoneCallRefreshCallBack: Function;
|
|
33
|
-
softphoneSeatStatusChangeCallBack: Function;
|
|
34
|
-
softphoneAcceptCallBack: Function;
|
|
35
|
-
softphoneIgnoreCallBack: Function;
|
|
36
|
-
softphoneHangupCallBack: Function;
|
|
37
|
-
softphoneSessionStateChangeCallBack: Function;
|
|
38
|
-
softphoneIncomingCallBack: Function;
|
|
39
|
-
softphoneSendDtmfCallBack: Function;
|
|
40
|
-
softphoneConnectRegisteredCallBack: Function;
|
|
41
|
-
softphoneSignOverduedCallBack: Function;
|
|
42
|
-
};
|
|
43
|
-
declare type Env = 'test' | 'dev' | 'sg' | 'gray' | 'prod';
|
|
44
|
-
export declare class SoftphoneManager {
|
|
45
|
-
id: any;
|
|
46
|
-
timer: any;
|
|
47
|
-
constructor();
|
|
48
|
-
option: Partial<Option>;
|
|
49
|
-
loadCssCode: (code: any) => void;
|
|
50
|
-
removeCssCode: () => void;
|
|
51
|
-
getContextDomElement: (el: string) => Element | null;
|
|
52
|
-
getSoftphoneDomElement: (el: string) => Element | null;
|
|
53
|
-
signOverdued: (data: {
|
|
54
|
-
sign: string;
|
|
55
|
-
timestamp: string | number;
|
|
56
|
-
}) => void;
|
|
57
|
-
handlingCommunication: (e: {
|
|
1
|
+
declare type Option = {
|
|
2
|
+
origin: string;
|
|
3
|
+
ancestorOrigin: string;
|
|
4
|
+
destinationOrigin: string;
|
|
5
|
+
scrollingText: string;
|
|
6
|
+
scrollview: string;
|
|
7
|
+
envMap: Record<Env, string>;
|
|
8
|
+
env: string;
|
|
9
|
+
selector: string;
|
|
10
|
+
el: string;
|
|
11
|
+
agentTag: string;
|
|
12
|
+
agentId: string;
|
|
13
|
+
appKey: string;
|
|
14
|
+
appSecret: string;
|
|
15
|
+
timestamp: string | number;
|
|
16
|
+
sign: string;
|
|
17
|
+
sgGateway: string;
|
|
18
|
+
sgBase: string;
|
|
19
|
+
sgOpen: string;
|
|
20
|
+
sgDomain: string;
|
|
21
|
+
extStatus: '0' | '1';
|
|
22
|
+
instanceMap: Record<string, any>;
|
|
23
|
+
callShow: '0' | '1';
|
|
24
|
+
transferToLaborShow: '0' | '1';
|
|
25
|
+
restShow: '0' | '1';
|
|
26
|
+
networkDetectShow: '0' | '1';
|
|
27
|
+
muteShow: '0' | '1';
|
|
28
|
+
logShow: '0' | '1';
|
|
29
|
+
timingShow: '0' | '1';
|
|
30
|
+
signShow: '0' | '1';
|
|
31
|
+
softphoneConnectCallBack: Function;
|
|
32
|
+
softphoneCallRefreshCallBack: Function;
|
|
33
|
+
softphoneSeatStatusChangeCallBack: Function;
|
|
34
|
+
softphoneAcceptCallBack: Function;
|
|
35
|
+
softphoneIgnoreCallBack: Function;
|
|
36
|
+
softphoneHangupCallBack: Function;
|
|
37
|
+
softphoneSessionStateChangeCallBack: Function;
|
|
38
|
+
softphoneIncomingCallBack: Function;
|
|
39
|
+
softphoneSendDtmfCallBack: Function;
|
|
40
|
+
softphoneConnectRegisteredCallBack: Function;
|
|
41
|
+
softphoneSignOverduedCallBack: Function;
|
|
42
|
+
};
|
|
43
|
+
declare type Env = 'test' | 'dev' | 'sg' | 'gray' | 'prod';
|
|
44
|
+
export declare class SoftphoneManager {
|
|
45
|
+
id: any;
|
|
46
|
+
timer: any;
|
|
47
|
+
constructor();
|
|
48
|
+
option: Partial<Option>;
|
|
49
|
+
loadCssCode: (code: any) => void;
|
|
50
|
+
removeCssCode: () => void;
|
|
51
|
+
getContextDomElement: (el: string) => Element | null;
|
|
52
|
+
getSoftphoneDomElement: (el: string) => Element | null;
|
|
53
|
+
signOverdued: (data: {
|
|
54
|
+
sign: string;
|
|
55
|
+
timestamp: string | number;
|
|
56
|
+
}) => void;
|
|
57
|
+
handlingCommunication: (e: {
|
|
58
58
|
data: `{
|
|
59
59
|
type: string,
|
|
60
60
|
ancestorOrigin: string,
|
|
61
61
|
origin: string,
|
|
62
62
|
data: 'expand' | 'shrink'
|
|
63
|
-
}` | string;
|
|
64
|
-
}) => void;
|
|
65
|
-
handlingScroll: (...args: any[]) => any;
|
|
66
|
-
handlerInteractive: () => void;
|
|
67
|
-
handlerDomRemove: () => void;
|
|
68
|
-
_containerScrolling: any;
|
|
69
|
-
get containerScrolling(): boolean;
|
|
70
|
-
set containerScrolling(value: boolean);
|
|
71
|
-
handlingScrollTransparent: () => void;
|
|
72
|
-
refreshStyle: () => Promise<{
|
|
73
|
-
top: number;
|
|
74
|
-
left: number;
|
|
75
|
-
leftMargin: string;
|
|
76
|
-
} | {
|
|
77
|
-
leftMargin: number;
|
|
78
|
-
top: number;
|
|
79
|
-
left: number;
|
|
80
|
-
}>;
|
|
81
|
-
handlerDomGenerater: () => Promise<void>;
|
|
82
|
-
initSoftphone: (option: any) => this;
|
|
83
|
-
postMessageCommunicate: (type: any, status?: boolean | undefined) => void;
|
|
84
|
-
connect: () => void;
|
|
85
|
-
disconnect: () => void;
|
|
86
|
-
seatsStatusChange: (status: boolean) => void;
|
|
87
|
-
accept: () => void;
|
|
88
|
-
ignore: () => void;
|
|
89
|
-
hangup: () => void;
|
|
90
|
-
sendDtmf: () => void;
|
|
91
|
-
removeTimer: () => void;
|
|
92
|
-
destroy: () => void;
|
|
93
|
-
}
|
|
94
|
-
declare const softphoneManager: SoftphoneManager;
|
|
95
|
-
export default softphoneManager;
|
|
63
|
+
}` | string;
|
|
64
|
+
}) => void;
|
|
65
|
+
handlingScroll: (...args: any[]) => any;
|
|
66
|
+
handlerInteractive: () => void;
|
|
67
|
+
handlerDomRemove: () => void;
|
|
68
|
+
_containerScrolling: any;
|
|
69
|
+
get containerScrolling(): boolean;
|
|
70
|
+
set containerScrolling(value: boolean);
|
|
71
|
+
handlingScrollTransparent: () => void;
|
|
72
|
+
refreshStyle: () => Promise<{
|
|
73
|
+
top: number;
|
|
74
|
+
left: number;
|
|
75
|
+
leftMargin: string;
|
|
76
|
+
} | {
|
|
77
|
+
leftMargin: number;
|
|
78
|
+
top: number;
|
|
79
|
+
left: number;
|
|
80
|
+
}>;
|
|
81
|
+
handlerDomGenerater: () => Promise<void>;
|
|
82
|
+
initSoftphone: (option: any) => this;
|
|
83
|
+
postMessageCommunicate: (type: any, status?: boolean | undefined) => void;
|
|
84
|
+
connect: () => void;
|
|
85
|
+
disconnect: () => void;
|
|
86
|
+
seatsStatusChange: (status: boolean) => void;
|
|
87
|
+
accept: () => void;
|
|
88
|
+
ignore: () => void;
|
|
89
|
+
hangup: () => void;
|
|
90
|
+
sendDtmf: () => void;
|
|
91
|
+
removeTimer: () => void;
|
|
92
|
+
destroy: () => void;
|
|
93
|
+
}
|
|
94
|
+
declare const softphoneManager: SoftphoneManager;
|
|
95
|
+
export default softphoneManager;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport"
|
|
6
|
+
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
|
|
7
|
+
<title>softphone</title>
|
|
8
|
+
<style>
|
|
9
|
+
.nf-transparent {
|
|
10
|
+
visibility: hidden;
|
|
11
|
+
}
|
|
12
|
+
.nf-softphone-text {
|
|
13
|
+
text-align: center;
|
|
14
|
+
line-height: 32px;
|
|
15
|
+
margin-top: -32px;
|
|
16
|
+
}
|
|
17
|
+
.nf-softphone-container {
|
|
18
|
+
margin-left: 10px;
|
|
19
|
+
height: 32px;
|
|
20
|
+
min-width: 600px;
|
|
21
|
+
}
|
|
22
|
+
.nf-softphone-iframe-container {
|
|
23
|
+
height: 32px;
|
|
24
|
+
width: 100%;
|
|
25
|
+
overflow: visible;
|
|
26
|
+
}
|
|
27
|
+
.nf-softphone-iframe {
|
|
28
|
+
width: 100vw;
|
|
29
|
+
height: 100vh;
|
|
30
|
+
top: 0;
|
|
31
|
+
left: 0;
|
|
32
|
+
}
|
|
33
|
+
</style>
|
|
34
|
+
</head>
|
|
35
|
+
<body>
|
|
36
|
+
<div id='softpone-context1' style='overflow: hidden'>
|
|
37
|
+
<div style="display: flex;height: 32px;">
|
|
38
|
+
<div style="min-width: 600px;width: 600px;" id='softphone1'></div>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
<script src="./util.js"></script>
|
|
42
|
+
<script src="./softphone.js"></script>
|
|
43
|
+
<script>
|
|
44
|
+
const agentTag1 = 'zoujh-test'
|
|
45
|
+
const appKey1 = '032d44009bff1752'
|
|
46
|
+
const appSecret1 = '4c7304c94c5e8725613516d4d6db679b'
|
|
47
|
+
/**
|
|
48
|
+
👈 拿到实例后可以手动触发软电话实例的各种动作,如签入,签出,接听,忽略,挂断等等,注意这个实例不是软电话实例,是链接软电话通讯的实例
|
|
49
|
+
*/
|
|
50
|
+
const nfSoftPhone1 = (new SoftphoneManager()).initSoftphone({ // 👈 当多实例时使用类创建新实例
|
|
51
|
+
el: '#softphone1', // 👈 软电话容器
|
|
52
|
+
selector: '#softpone-context1', // 👈 软电话容器查询上下文,用于多实例隔离软电话dom的查询环境
|
|
53
|
+
ancestorOrigin: 'nf-softphone1', // origin,ancestorOrigin,destinationOrigin具体含义参见下文,如果是单实例,可以写死origin=ai-softphone&destinationOrigin=nf-softphone&ancestorOrigin=nf-softphone
|
|
54
|
+
destinationOrigin: 'nf-softphone1',
|
|
55
|
+
|
|
56
|
+
agentTag: agentTag1, // 👈 坐席唯一标志
|
|
57
|
+
appKey: appKey1, // 👈 企业appKey
|
|
58
|
+
appSecret: appSecret1,
|
|
59
|
+
extStatus: '1', // 👈 初始化是否处于小休状态, 非1 小休 1 在线
|
|
60
|
+
|
|
61
|
+
softphoneConnectCallBack: (data) => {
|
|
62
|
+
console.log('softphone-connect')
|
|
63
|
+
}, // 👈 签入签出回调
|
|
64
|
+
softphoneCallRefreshCallBack: (data) => {console.log('softphone-call-refresh')}, // 👈 来电刷新来电记录列表回调
|
|
65
|
+
softphoneSeatStatusChangeCallBack: (data) => {console.log('softphone-seats-status-change')},// 👈 小休和在线切换回调
|
|
66
|
+
softphoneAcceptCallBack: (data) => {console.log('softphone-accept')},// 👈 接听回调
|
|
67
|
+
softphoneIgnoreCallBack: (data) => {console.log('softphone-ignore')},// 👈 忽略回调
|
|
68
|
+
softphoneHangupCallBack: (data) => {console.log('softphone-hangup')},// 👈 挂断回调
|
|
69
|
+
softphoneSessionStateChangeCallBack: (data) => {console.log('softphone-session-state-change')},// 👈 会话状态改变回调
|
|
70
|
+
softphoneIncomingCallBack: (data) => {console.log('softphone-incoming')},// 👈 来电回调
|
|
71
|
+
softphoneSendDtmfCallBack: (data) => {console.log('softphone-send-dtmf')},// 👈 转人工回调
|
|
72
|
+
softphoneConnectRegisteredCallBack: (data) => {console.log('softphone-connect-registered')},// 👈 动态绑定动作完成回调(在这之后才能执行动作类总线通讯)
|
|
73
|
+
});
|
|
74
|
+
</script>
|
|
75
|
+
</body>
|
|
76
|
+
</html>
|
|
@@ -1,170 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport"
|
|
6
|
-
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
|
|
7
|
-
<title>softphone</title>
|
|
8
|
-
<style>
|
|
9
|
-
.nf-transparent {
|
|
10
|
-
visibility: hidden;
|
|
11
|
-
}
|
|
12
|
-
.nf-softphone-text {
|
|
13
|
-
text-align: center;
|
|
14
|
-
line-height: 32px;
|
|
15
|
-
margin-top: -32px;
|
|
16
|
-
}
|
|
17
|
-
.nf-softphone-container {
|
|
18
|
-
margin-left: 10px;
|
|
19
|
-
height: 32px;
|
|
20
|
-
min-width: 600px;
|
|
21
|
-
}
|
|
22
|
-
.nf-softphone-iframe-container {
|
|
23
|
-
height: 32px;
|
|
24
|
-
width: 100%;
|
|
25
|
-
overflow: visible;
|
|
26
|
-
}
|
|
27
|
-
.nf-softphone-iframe {
|
|
28
|
-
width: 100vw;
|
|
29
|
-
height: 100vh;
|
|
30
|
-
top: 0;
|
|
31
|
-
left: 0;
|
|
32
|
-
}
|
|
33
|
-
</style>
|
|
34
|
-
</head>
|
|
35
|
-
<body>
|
|
36
|
-
<div id='softpone-context1' style='overflow: hidden'>
|
|
37
|
-
<div style="display: flex;height: 32px;">
|
|
38
|
-
<div style="min-width: 600px;width: 600px;" id='softphone1'></div>
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
<script>
|
|
42
|
-
function generateUUID() { // Public Domain/MIT
|
|
43
|
-
let d = Date.now();
|
|
44
|
-
if (typeof performance !== 'undefined' && typeof performance.now === 'function'){
|
|
45
|
-
d += performance.now(); //use high-precision timer if available
|
|
46
|
-
}
|
|
47
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
48
|
-
const r = (d + Math.random() * 16) % 16 | 0;
|
|
49
|
-
d = Math.floor(d / 16);
|
|
50
|
-
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function debounce(func, wait, immediate) {
|
|
55
|
-
let timeout, args, context, timestamp, result
|
|
56
|
-
|
|
57
|
-
const later = function() {
|
|
58
|
-
// 据上一次触发时间间隔
|
|
59
|
-
const last = +new Date() - timestamp
|
|
60
|
-
|
|
61
|
-
// 上次被包装函数被调用时间间隔last小于设定时间间隔wait
|
|
62
|
-
if (last < wait && last > 0) {
|
|
63
|
-
timeout = setTimeout(later, wait - last)
|
|
64
|
-
} else {
|
|
65
|
-
timeout = null
|
|
66
|
-
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
|
67
|
-
if (!immediate) {
|
|
68
|
-
result = func.apply(context, args)
|
|
69
|
-
if (!timeout) context = args = null
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return function(...args) {
|
|
75
|
-
// @ts-ignore
|
|
76
|
-
context = this
|
|
77
|
-
timestamp = +new Date()
|
|
78
|
-
const callNow = immediate && !timeout
|
|
79
|
-
// 如果延时不存在,重新设定延时
|
|
80
|
-
if (!timeout) timeout = setTimeout(later, wait)
|
|
81
|
-
if (callNow) {
|
|
82
|
-
result = func.apply(context, args)
|
|
83
|
-
// @ts-ignore
|
|
84
|
-
context = args = null
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return result
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// 用于存储传入 nextTick 的回调函数
|
|
92
|
-
const callbacks = [];
|
|
93
|
-
// 标记是否已经安排了回调函数的执行
|
|
94
|
-
let pending = false;
|
|
95
|
-
|
|
96
|
-
// 执行队列中的所有回调函数
|
|
97
|
-
function flushCallbacks() {
|
|
98
|
-
pending = false;
|
|
99
|
-
// 复制一份当前的回调队列,避免在执行过程中添加新的回调影响循环
|
|
100
|
-
const copies = callbacks.slice(0);
|
|
101
|
-
callbacks.length = 0;
|
|
102
|
-
// 依次执行每个回调函数,并处理可能出现的异常
|
|
103
|
-
for (let i = 0; i < copies.length; i++) {
|
|
104
|
-
try {
|
|
105
|
-
copies[i]();
|
|
106
|
-
} catch (e) {
|
|
107
|
-
console.error('Error in nextTick callback:', e);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// 根据浏览器支持情况选择合适的异步执行方式
|
|
113
|
-
let timerFunc;
|
|
114
|
-
if (typeof Promise !== 'undefined') {
|
|
115
|
-
// 如果支持 Promise,使用 Promise 的 then 方法创建微任务
|
|
116
|
-
const p = Promise.resolve();
|
|
117
|
-
timerFunc = () => {
|
|
118
|
-
p.then(flushCallbacks);
|
|
119
|
-
};
|
|
120
|
-
} else if (typeof MutationObserver !== 'undefined') {
|
|
121
|
-
// 如果支持 MutationObserver,使用它创建微任务
|
|
122
|
-
let counter = 1;
|
|
123
|
-
const observer = new MutationObserver(flushCallbacks);
|
|
124
|
-
const textNode = document.createTextNode(String(counter));
|
|
125
|
-
observer.observe(textNode, {
|
|
126
|
-
characterData: true
|
|
127
|
-
});
|
|
128
|
-
timerFunc = () => {
|
|
129
|
-
counter = (counter + 1) % 2;
|
|
130
|
-
textNode.data = String(counter);
|
|
131
|
-
};
|
|
132
|
-
} else if (typeof setImmediate !== 'undefined') {
|
|
133
|
-
// 如果支持 setImmediate,使用它创建宏任务
|
|
134
|
-
timerFunc = () => {
|
|
135
|
-
setImmediate(flushCallbacks);
|
|
136
|
-
};
|
|
137
|
-
} else {
|
|
138
|
-
// 最后使用 setTimeout 作为兜底方案创建宏任务
|
|
139
|
-
timerFunc = () => {
|
|
140
|
-
setTimeout(flushCallbacks, 0);
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// 实现 nextTick 函数,支持传入回调函数或返回 Promise
|
|
145
|
-
async function nextTick(cb) {
|
|
146
|
-
return new Promise((resolve) => {
|
|
147
|
-
// 将回调函数和 resolve 函数封装成一个新的回调
|
|
148
|
-
callbacks.push(() => {
|
|
149
|
-
if (cb) {
|
|
150
|
-
try {
|
|
151
|
-
cb();
|
|
152
|
-
} catch (e) {
|
|
153
|
-
console.error('Error in nextTick callback:', e);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
// 当回调执行完毕后,resolve Promise
|
|
157
|
-
resolve(true);
|
|
158
|
-
});
|
|
159
|
-
// 如果当前没有正在执行的回调安排,安排一次新的执行
|
|
160
|
-
if (!pending) {
|
|
161
|
-
pending = true;
|
|
162
|
-
timerFunc();
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
class SoftphoneManager {
|
|
1
|
+
class SoftphoneManager {
|
|
168
2
|
|
|
169
3
|
id
|
|
170
4
|
timer
|
|
@@ -187,7 +21,7 @@ async function nextTick(cb) {
|
|
|
187
21
|
envMap: {
|
|
188
22
|
test: 'http://softphone.test.k8s.com',
|
|
189
23
|
dev: 'http://softphone.dev.k8s.com',
|
|
190
|
-
sg: 'https://
|
|
24
|
+
sg: 'https://seat.teleai.com',
|
|
191
25
|
gray: 'http://softphone.gray.94ai.com',
|
|
192
26
|
prod: 'https://seat.94ai.com',
|
|
193
27
|
},
|
|
@@ -629,39 +463,3 @@ async function nextTick(cb) {
|
|
|
629
463
|
}
|
|
630
464
|
|
|
631
465
|
const softphoneManager = new SoftphoneManager()
|
|
632
|
-
|
|
633
|
-
const agentTag1 = 'zoujh-test'
|
|
634
|
-
const appKey1 = '032d44009bff1752'
|
|
635
|
-
const appSecret1 = '4c7304c94c5e8725613516d4d6db679b'
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
/**
|
|
639
|
-
👈 拿到实例后可以手动触发软电话实例的各种动作,如签入,签出,接听,忽略,挂断等等,注意这个实例不是软电话实例,是链接软电话通讯的实例
|
|
640
|
-
*/
|
|
641
|
-
const nfSoftPhone1 = (new SoftphoneManager()).initSoftphone({ // 👈 当多实例时使用类创建新实例
|
|
642
|
-
el: '#softphone1', // 👈 软电话容器
|
|
643
|
-
selector: '#softpone-context1', // 👈 软电话容器查询上下文,用于多实例隔离软电话dom的查询环境
|
|
644
|
-
ancestorOrigin: 'nf-softphone1', // origin,ancestorOrigin,destinationOrigin具体含义参见下文,如果是单实例,可以写死origin=ai-softphone&destinationOrigin=nf-softphone&ancestorOrigin=nf-softphone
|
|
645
|
-
destinationOrigin: 'nf-softphone1',
|
|
646
|
-
|
|
647
|
-
agentTag: agentTag1, // 👈 坐席唯一标志
|
|
648
|
-
appKey: appKey1, // 👈 企业appKey
|
|
649
|
-
appSecret: appSecret1,
|
|
650
|
-
extStatus: '1', // 👈 初始化是否处于小休状态, 非1 小休 1 在线
|
|
651
|
-
|
|
652
|
-
softphoneConnectCallBack: (data) => {
|
|
653
|
-
console.log('softphone-connect')
|
|
654
|
-
}, // 👈 签入签出回调
|
|
655
|
-
softphoneCallRefreshCallBack: (data) => {console.log('softphone-call-refresh')}, // 👈 来电刷新来电记录列表回调
|
|
656
|
-
softphoneSeatStatusChangeCallBack: (data) => {console.log('softphone-seats-status-change')},// 👈 小休和在线切换回调
|
|
657
|
-
softphoneAcceptCallBack: (data) => {console.log('softphone-accept')},// 👈 接听回调
|
|
658
|
-
softphoneIgnoreCallBack: (data) => {console.log('softphone-ignore')},// 👈 忽略回调
|
|
659
|
-
softphoneHangupCallBack: (data) => {console.log('softphone-hangup')},// 👈 挂断回调
|
|
660
|
-
softphoneSessionStateChangeCallBack: (data) => {console.log('softphone-session-state-change')},// 👈 会话状态改变回调
|
|
661
|
-
softphoneIncomingCallBack: (data) => {console.log('softphone-incoming')},// 👈 来电回调
|
|
662
|
-
softphoneSendDtmfCallBack: (data) => {console.log('softphone-send-dtmf')},// 👈 转人工回调
|
|
663
|
-
softphoneConnectRegisteredCallBack: (data) => {console.log('softphone-connect-registered')},// 👈 动态绑定动作完成回调(在这之后才能执行动作类总线通讯)
|
|
664
|
-
});
|
|
665
|
-
</script>
|
|
666
|
-
</body>
|
|
667
|
-
</html>
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
function generateUUID() { // Public Domain/MIT
|
|
2
|
+
let d = Date.now();
|
|
3
|
+
if (typeof performance !== 'undefined' && typeof performance.now === 'function'){
|
|
4
|
+
d += performance.now(); //use high-precision timer if available
|
|
5
|
+
}
|
|
6
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
7
|
+
const r = (d + Math.random() * 16) % 16 | 0;
|
|
8
|
+
d = Math.floor(d / 16);
|
|
9
|
+
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function debounce(func, wait, immediate) {
|
|
14
|
+
let timeout, args, context, timestamp, result
|
|
15
|
+
|
|
16
|
+
const later = function() {
|
|
17
|
+
// 据上一次触发时间间隔
|
|
18
|
+
const last = +new Date() - timestamp
|
|
19
|
+
|
|
20
|
+
// 上次被包装函数被调用时间间隔last小于设定时间间隔wait
|
|
21
|
+
if (last < wait && last > 0) {
|
|
22
|
+
timeout = setTimeout(later, wait - last)
|
|
23
|
+
} else {
|
|
24
|
+
timeout = null
|
|
25
|
+
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
|
26
|
+
if (!immediate) {
|
|
27
|
+
result = func.apply(context, args)
|
|
28
|
+
if (!timeout) context = args = null
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return function(...args) {
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
context = this
|
|
36
|
+
timestamp = +new Date()
|
|
37
|
+
const callNow = immediate && !timeout
|
|
38
|
+
// 如果延时不存在,重新设定延时
|
|
39
|
+
if (!timeout) timeout = setTimeout(later, wait)
|
|
40
|
+
if (callNow) {
|
|
41
|
+
result = func.apply(context, args)
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
context = args = null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return result
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 用于存储传入 nextTick 的回调函数
|
|
51
|
+
const callbacks = [];
|
|
52
|
+
// 标记是否已经安排了回调函数的执行
|
|
53
|
+
let pending = false;
|
|
54
|
+
|
|
55
|
+
// 执行队列中的所有回调函数
|
|
56
|
+
function flushCallbacks() {
|
|
57
|
+
pending = false;
|
|
58
|
+
// 复制一份当前的回调队列,避免在执行过程中添加新的回调影响循环
|
|
59
|
+
const copies = callbacks.slice(0);
|
|
60
|
+
callbacks.length = 0;
|
|
61
|
+
// 依次执行每个回调函数,并处理可能出现的异常
|
|
62
|
+
for (let i = 0; i < copies.length; i++) {
|
|
63
|
+
try {
|
|
64
|
+
copies[i]();
|
|
65
|
+
} catch (e) {
|
|
66
|
+
console.error('Error in nextTick callback:', e);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 根据浏览器支持情况选择合适的异步执行方式
|
|
72
|
+
let timerFunc;
|
|
73
|
+
if (typeof Promise !== 'undefined') {
|
|
74
|
+
// 如果支持 Promise,使用 Promise 的 then 方法创建微任务
|
|
75
|
+
const p = Promise.resolve();
|
|
76
|
+
timerFunc = () => {
|
|
77
|
+
p.then(flushCallbacks);
|
|
78
|
+
};
|
|
79
|
+
} else if (typeof MutationObserver !== 'undefined') {
|
|
80
|
+
// 如果支持 MutationObserver,使用它创建微任务
|
|
81
|
+
let counter = 1;
|
|
82
|
+
const observer = new MutationObserver(flushCallbacks);
|
|
83
|
+
const textNode = document.createTextNode(String(counter));
|
|
84
|
+
observer.observe(textNode, {
|
|
85
|
+
characterData: true
|
|
86
|
+
});
|
|
87
|
+
timerFunc = () => {
|
|
88
|
+
counter = (counter + 1) % 2;
|
|
89
|
+
textNode.data = String(counter);
|
|
90
|
+
};
|
|
91
|
+
} else if (typeof setImmediate !== 'undefined') {
|
|
92
|
+
// 如果支持 setImmediate,使用它创建宏任务
|
|
93
|
+
timerFunc = () => {
|
|
94
|
+
setImmediate(flushCallbacks);
|
|
95
|
+
};
|
|
96
|
+
} else {
|
|
97
|
+
// 最后使用 setTimeout 作为兜底方案创建宏任务
|
|
98
|
+
timerFunc = () => {
|
|
99
|
+
setTimeout(flushCallbacks, 0);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 实现 nextTick 函数,支持传入回调函数或返回 Promise
|
|
104
|
+
async function nextTick(cb) {
|
|
105
|
+
return new Promise((resolve) => {
|
|
106
|
+
// 将回调函数和 resolve 函数封装成一个新的回调
|
|
107
|
+
callbacks.push(() => {
|
|
108
|
+
if (cb) {
|
|
109
|
+
try {
|
|
110
|
+
cb();
|
|
111
|
+
} catch (e) {
|
|
112
|
+
console.error('Error in nextTick callback:', e);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// 当回调执行完毕后,resolve Promise
|
|
116
|
+
resolve(true);
|
|
117
|
+
});
|
|
118
|
+
// 如果当前没有正在执行的回调安排,安排一次新的执行
|
|
119
|
+
if (!pending) {
|
|
120
|
+
pending = true;
|
|
121
|
+
timerFunc();
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
package/package/nf-softphone.vue
CHANGED
|
@@ -74,7 +74,7 @@ const props = withDefaults(defineProps<{
|
|
|
74
74
|
envMap: () => ({
|
|
75
75
|
test: 'http://softphone.test.k8s.com',
|
|
76
76
|
dev: 'http://softphone.dev.k8s.com',
|
|
77
|
-
sg: 'https://
|
|
77
|
+
sg: 'https://seat.teleai.com',
|
|
78
78
|
gray: 'http://softphone.gray.94ai.com',
|
|
79
79
|
prod: 'https://seat.94ai.com',
|
|
80
80
|
}),
|
|
@@ -194,7 +194,7 @@ export class SoftphoneManager {
|
|
|
194
194
|
envMap: {
|
|
195
195
|
test: 'http://softphone.test.k8s.com',
|
|
196
196
|
dev: 'http://softphone.dev.k8s.com',
|
|
197
|
-
sg: 'https://
|
|
197
|
+
sg: 'https://seat.teleai.com',
|
|
198
198
|
gray: 'http://softphone.gray.94ai.com',
|
|
199
199
|
prod: 'https://seat.94ai.com',
|
|
200
200
|
},
|
package/package/softphone.ts
CHANGED
|
@@ -28,7 +28,7 @@ export class SoftphoneManager {
|
|
|
28
28
|
envMap: {
|
|
29
29
|
test: 'http://softphone.test.k8s.com',
|
|
30
30
|
dev: 'http://softphone.dev.k8s.com',
|
|
31
|
-
sg: 'https://
|
|
31
|
+
sg: 'https://seat.teleai.com',
|
|
32
32
|
gray: 'http://softphone.gray.94ai.com',
|
|
33
33
|
prod: 'https://seat.94ai.com',
|
|
34
34
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@94ai/nf-softphone",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.11",
|
|
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.11",
|
|
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": "bcc31174ac00de980e870e1d5dfdac988acd2978"
|
|
34
34
|
}
|