@gsc-basic/robot-sdk 1.0.0
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/README.md +11 -0
- package/dist/robot-prod.es.js +80 -0
- package/dist/robot-prod.umd.js +80 -0
- package/dist/robot-uat.es.js +80 -0
- package/dist/robot-uat.umd.js +80 -0
- package/package.json +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var a;function H(x,e,v){let _=e;if(!a){a=document.createElement("robot-previewer");let i=document.createElement("style");i.setAttribute("robot-previewer",""),i.setAttribute("type","text/css"),i.innerHTML=`
|
|
2
|
+
robot-previewer {
|
|
3
|
+
display: none;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
-webkit-font-smoothing: antialiased;
|
|
6
|
+
-moz-osx-font-smoothing: grayscale;
|
|
7
|
+
}
|
|
8
|
+
robot-previewer .___previewer-close {
|
|
9
|
+
position: fixed;
|
|
10
|
+
width: 80px;
|
|
11
|
+
height: 80px;
|
|
12
|
+
border-radius: 50%;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
right: -40px;
|
|
15
|
+
top: -40px;
|
|
16
|
+
text-align: center;
|
|
17
|
+
background-color: rgba(0, 0, 0, 0.9);
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
z-index: 100000002;
|
|
20
|
+
}
|
|
21
|
+
robot-previewer .___previewer-close>span {
|
|
22
|
+
position: fixed;
|
|
23
|
+
top: 4px;
|
|
24
|
+
right: 8px;
|
|
25
|
+
font-size: 1.2em;
|
|
26
|
+
}
|
|
27
|
+
robot-previewer .___previewer-prev,
|
|
28
|
+
robot-previewer .___previewer-next {
|
|
29
|
+
position: fixed;
|
|
30
|
+
width: 60px;
|
|
31
|
+
height: 60px;
|
|
32
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
z-index: 100000002;
|
|
35
|
+
top: 50vh;
|
|
36
|
+
margin-top: -30px;
|
|
37
|
+
text-align: center;
|
|
38
|
+
line-height: 56px;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
font-size: 38px;
|
|
41
|
+
}
|
|
42
|
+
robot-previewer .___previewer-prev {
|
|
43
|
+
left: 0
|
|
44
|
+
}
|
|
45
|
+
robot-previewer .___previewer-next {
|
|
46
|
+
right: 0
|
|
47
|
+
}
|
|
48
|
+
robot-previewer .___previewer-close>span,
|
|
49
|
+
robot-previewer .___previewer-prev>span,
|
|
50
|
+
robot-previewer .___previewer-next>span {
|
|
51
|
+
font-weight: bold;
|
|
52
|
+
color: white;
|
|
53
|
+
}
|
|
54
|
+
robot-previewer .___previewer-img {
|
|
55
|
+
margin: auto;
|
|
56
|
+
position: fixed;
|
|
57
|
+
top: 0;
|
|
58
|
+
bottom: 0;
|
|
59
|
+
left: 0;
|
|
60
|
+
right: 0;
|
|
61
|
+
max-height: 90%;
|
|
62
|
+
max-width: 90%;
|
|
63
|
+
z-index: 100000002;
|
|
64
|
+
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.75);
|
|
65
|
+
}
|
|
66
|
+
robot-previewer .___previewer-fade {
|
|
67
|
+
background-color: rgba(0,0,0,0.5);
|
|
68
|
+
position: fixed;
|
|
69
|
+
top: 0;
|
|
70
|
+
left: 0;
|
|
71
|
+
width: 100vw;
|
|
72
|
+
height: 100vh;
|
|
73
|
+
z-index: 100000000;
|
|
74
|
+
}
|
|
75
|
+
`,document.head.appendChild(i),a.innerHTML=`
|
|
76
|
+
<div class="___previewer-fade"></div>
|
|
77
|
+
<img src="" alt="" class="___previewer-img" />
|
|
78
|
+
<div class="___previewer-close"><span>\xD7</span></div>
|
|
79
|
+
`,(v||document.body).appendChild(a),a.querySelector(".___previewer-close").addEventListener("click",d),a.querySelector(".___previewer-fade").addEventListener("click",d);}function d(){a.style.display="none",a.querySelector(".___previewer-img").src="";}a.querySelector(".___previewer-img").src=x[_],a.style.display="block";}var h={prod:"https://scc.lenovo.com/robot",test:"https://sccuat.lenovo.com/robot",local:"http://localhost:5174/robot/"},P={display:"inline-block",position:"fixed",bottom:"8vh",right:"2.5vh",zIndex:"100000",width:"5vh",height:"5vh",userSelect:"none",MozUserSelect:"none",msUserSelect:"none"},W="https://scc.lenovo.com/download/static/public?filename=robot.gif",j={width:"100%",height:"110%",cursor:"pointer",userSelect:"none",MozUserSelect:"none",msUserSelect:"none"},q={display:"none",position:"absolute",backgroundColor:"#fff",color:"black",padding:"0.7vh 0.9vh",width:"auto",top:"-10vh",left:"-13.5vh",borderRadius:"0.8vh",boxShadow:"0 2px 6px #00000014,0 1px 3px -2px #0000001f,0 4px 12px 4px #0000000d",zIndex:"999"},K={color:"#1d2129",fontWeight:"600",fontSize:"16px",marginBottom:"0.5vh",whiteSpace:"nowrap"},C={color:"#4e5969",fontSize:"12px",whiteSpace:"nowrap"},X={width:"0",height:"0",borderLeft:"1vh solid transparent",borderRight:"1vh solid transparent",borderBottom:"1vh solid white",position:"absolute",top:"100%",left:"85%",transform:"translateX(-50%) rotate(180deg)"},F={position:"absolute",top:"-585px",left:"-440px",zIndex:"9999",width:"450px",height:"605px",boxShadow:"0 2px 6px #00000014,0 1px 3px -2px #0000001f,0 4px 12px 4px #0000000d",borderRadius:"10px",display:"none"},k=1,G=["\u3010\u5907\u6CE8\u3011: ","\u3010Comment\u3011: ","\u3010\u5907\u6CE8\u3011:","\u3010Comment\u3011:"],U="robot__iframe";function B({env:x="prod"}={}){let e=document.createElement("iframe"),v=!1,_=!0,d,i;function $(n,s,l=!0){if(v){console.warn("Robot has been initialized, please do not initialize it again.");return}let p=h.prod;x==="prod"?s.env==="test"?p=h.test:s.env==="local"&&(p=h.local):x==="test"&&(p=h.test,s.env==="local"&&(p=h.local)),v=!0,typeof n=="string"?d=document.querySelector(n):n instanceof HTMLElement&&(d=n),i=document.createElement("robot-parent"),i.id=U,Object.assign(i.style,P),(d||document.body).appendChild(i);let c=document.createElement("img");c.src=s.icon||W,c.setAttribute("alt","IT Support"),Object.assign(c.style,j);let o=document.createElement("div");Object.assign(o.style,q);let S=document.createElement("div");S.textContent="\u6280\u672F\u652F\u6301(IT Support)",Object.assign(S.style,K),o.appendChild(S);let T=document.createElement("div");T.textContent="\u63D0\u4EA4\u5DE5\u5355\u4EE5\u83B7\u5F97\u66F4\u591A\u5E2E\u52A9\u3002",Object.assign(T.style,C),o.appendChild(T);let L=document.createElement("div");L.textContent="Open a ticket for more help.",Object.assign(L.style,C),o.appendChild(L);let f=document.createElement("div");Object.assign(f.style,X),o.appendChild(f),c.addEventListener("mouseover",()=>{e.style.display!=="block"&&(o.style.display="block");}),c.addEventListener("mouseout",()=>{o.style.display="none";}),i.appendChild(c),i.appendChild(o);try{let t=Object.fromEntries(Object.entries({appKey:s.robot_appKey,secret:s.robot_secret,userKey:s.robot_userKey,initLang:s.robot_lang,authMethod:s.robot_auth,chatServiceId:s.chat_serviceId,chatEnable:s.chat_enable,ticketEnable:s.ticket_enable,appTitle:s.app_title,appName:s.app_name}).filter(([g,m])=>m!=null)),r=new URLSearchParams(t);e.src=`${p}?${r.toString()}`,e.frameBorder="0",e.id="robot__iframe",e.title="Ticket Assistant",e.scrolling="no",e.allowTransparency="true",e.allow="autoplay",e.display="none",Object.assign(e.style,F);}catch(t){console.error(t);}let N=()=>{i.style.top="",i.style.left="";let t=window.innerHeight;t<700?(o.style.top="-12vh",o.style.left="-18vh"):t<820?o.style.top="-11vh":t<1e3?(o.style.top="-10vh",o.style.left="-13.5vh"):t<1200?(o.style.top="-8vh",o.style.left="-12.5vh"):(o.style.top="-7vh",o.style.left="-11.5vh"),t<600&&(o.style.left="-20vh"),t<790?f.style.left="71%":f.style.left="85%",t<550&&(o.style.left="-22vh",o.style.top="-14vh"),t<500&&(o.style.left="-24vh",f.style.left="77%"),t<500&&(o.style.left="-28vh",f.style.left="79%",o.style.top="-16vh"),t<450?(e.style.transform="scale3d(0.5, 0.5, 1)",e.style.top="-445px",e.style.left="-330px"):t<500?(e.style.transform="scale3d(0.55, 0.55, 1)",e.style.top="-460px",e.style.left="-340px"):t<600?(e.style.transform="scale3d(0.6, 0.6, 1)",e.style.top="-478px",e.style.left="-354px"):t<700?(e.style.transform="scale3d(0.7, 0.7, 1)",e.style.top="-505px",e.style.left="-380px"):t>=700&&t<790?(e.style.transform="scale3d(0.8, 0.8, 1)",e.style.top="-535px",e.style.left="-400px"):t>=790&&t<880?(e.style.transform="scale3d(0.9, 0.9, 1)",e.style.top="-555px",e.style.left="-420px"):(e.style.transform="scale3d(1, 1, 1)",e.style.top="-585px",e.style.left="-440px"),t<760?i.style.right="4.5vh":t<880?i.style.right="3.5vh":i.style.right="2.5vh";};i.appendChild(e);let R=!1;c.addEventListener("click",()=>{R||(e.style.display==="none"?(e.style.display="block",o.style.display="none",_&&(e.contentWindow.postMessage({type:"firstOpen"},"*"),_=!1)):(e.style.display="none",e.contentWindow.postMessage({type:"parentClose"},"*")));}),window.addEventListener("resize",N),N();function ie(t){let r=t,g=!1,m,Y;r.onmousedown=function(E){g=!0,m=E.clientX-r.offsetLeft,Y=E.clientY-r.offsetTop,R=!1;let ne=E.clientX,re=E.clientY;return document.onmousemove=function(y){if(g){let I=y.clientX-m,O=y.clientY-Y;r.style.left=`${I}px`,r.style.top=`${O}px`;let M=Math.abs(y.clientX-ne),w=Math.abs(y.clientY-re);(M>k||w>k)&&(R=!0);}},document.onmouseup=function(){g=!1,document.onmousemove=null,document.onmouseup=null;let y=document.body.clientWidth,I=document.body.clientHeight,O=r.offsetWidth,M=r.offsetHeight,w=0,z=0,A=y-O/2,D=I-M/2,b=Number.parseInt(r.style.left),u=Number.parseInt(r.style.top);b<w?b=w:b>A&&(b=A),u<z?u=z:u>D&&(u=D),r.style.left=`${b}px`,r.style.top=`${u}px`;},!1};}l&&ie(i),window.addEventListener("message",t=>{t.data&&t.data.type==="childClose"&&(e.style.display="none");});}function V(n){e.contentWindow.postMessage({type:"changeRouteKey",routeKey:n},"*");}function J(n,s="",l="",p=G){e.contentWindow.postMessage({type:"quickSubmitTicket",issue:n,issueDescription:s,customData:l,cursorPositionStrArr:p},"*"),e.style.display="block",_=!1;}function Q(n){e.contentWindow.postMessage({type:"changeLang",lang:n},"*");}let Z=()=>{let n=s=>{var p;let{data:l}=s;l.type==="requestToken"?te():l.type==="viewImages"&&H(l.images||[],(p=l.index)!=null?p:0,i);};return window.addEventListener("message",n),()=>{window.removeEventListener("message",n);}},ee=(n,s,l="*")=>{n?n.postMessage(s,l):console.error("postMessage Error: targetWindow is not exist!");},te=()=>{var n,s;e&&ee(e.contentWindow,{type:"basicToken",token:(s=window.__BASIC_COMMON_TOKEN__)!=null?s:(n=window.localStorage)==null?void 0:n.getItem("__BASIC_COMMON_TOKEN__")},"*");};function oe(n){i?i.style.display=n?"inline-block":"none":console.error("Robot isn't initialized yet!");}let se=Z();return {changeRobotLang:Q,destroyTokenListener:se,initRobot:$,quickSubmit:J,setRouteKey:V,toggleRobotVisibility:oe}}var {changeRobotLang:ye,destroyTokenListener:he,initRobot:_e,quickSubmit:me,setRouteKey:be,toggleRobotVisibility:ue}=B({env:"prod"});
|
|
80
|
+
export{ye as changeRobotLang,he as destroyTokenListener,_e as initRobot,me as quickSubmit,be as setRouteKey,ue as toggleRobotVisibility};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var ServerRobot=(function(exports){'use strict';var a;function H(x,e,v){let _=e;if(!a){a=document.createElement("robot-previewer");let i=document.createElement("style");i.setAttribute("robot-previewer",""),i.setAttribute("type","text/css"),i.innerHTML=`
|
|
2
|
+
robot-previewer {
|
|
3
|
+
display: none;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
-webkit-font-smoothing: antialiased;
|
|
6
|
+
-moz-osx-font-smoothing: grayscale;
|
|
7
|
+
}
|
|
8
|
+
robot-previewer .___previewer-close {
|
|
9
|
+
position: fixed;
|
|
10
|
+
width: 80px;
|
|
11
|
+
height: 80px;
|
|
12
|
+
border-radius: 50%;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
right: -40px;
|
|
15
|
+
top: -40px;
|
|
16
|
+
text-align: center;
|
|
17
|
+
background-color: rgba(0, 0, 0, 0.9);
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
z-index: 100000002;
|
|
20
|
+
}
|
|
21
|
+
robot-previewer .___previewer-close>span {
|
|
22
|
+
position: fixed;
|
|
23
|
+
top: 4px;
|
|
24
|
+
right: 8px;
|
|
25
|
+
font-size: 1.2em;
|
|
26
|
+
}
|
|
27
|
+
robot-previewer .___previewer-prev,
|
|
28
|
+
robot-previewer .___previewer-next {
|
|
29
|
+
position: fixed;
|
|
30
|
+
width: 60px;
|
|
31
|
+
height: 60px;
|
|
32
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
z-index: 100000002;
|
|
35
|
+
top: 50vh;
|
|
36
|
+
margin-top: -30px;
|
|
37
|
+
text-align: center;
|
|
38
|
+
line-height: 56px;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
font-size: 38px;
|
|
41
|
+
}
|
|
42
|
+
robot-previewer .___previewer-prev {
|
|
43
|
+
left: 0
|
|
44
|
+
}
|
|
45
|
+
robot-previewer .___previewer-next {
|
|
46
|
+
right: 0
|
|
47
|
+
}
|
|
48
|
+
robot-previewer .___previewer-close>span,
|
|
49
|
+
robot-previewer .___previewer-prev>span,
|
|
50
|
+
robot-previewer .___previewer-next>span {
|
|
51
|
+
font-weight: bold;
|
|
52
|
+
color: white;
|
|
53
|
+
}
|
|
54
|
+
robot-previewer .___previewer-img {
|
|
55
|
+
margin: auto;
|
|
56
|
+
position: fixed;
|
|
57
|
+
top: 0;
|
|
58
|
+
bottom: 0;
|
|
59
|
+
left: 0;
|
|
60
|
+
right: 0;
|
|
61
|
+
max-height: 90%;
|
|
62
|
+
max-width: 90%;
|
|
63
|
+
z-index: 100000002;
|
|
64
|
+
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.75);
|
|
65
|
+
}
|
|
66
|
+
robot-previewer .___previewer-fade {
|
|
67
|
+
background-color: rgba(0,0,0,0.5);
|
|
68
|
+
position: fixed;
|
|
69
|
+
top: 0;
|
|
70
|
+
left: 0;
|
|
71
|
+
width: 100vw;
|
|
72
|
+
height: 100vh;
|
|
73
|
+
z-index: 100000000;
|
|
74
|
+
}
|
|
75
|
+
`,document.head.appendChild(i),a.innerHTML=`
|
|
76
|
+
<div class="___previewer-fade"></div>
|
|
77
|
+
<img src="" alt="" class="___previewer-img" />
|
|
78
|
+
<div class="___previewer-close"><span>\xD7</span></div>
|
|
79
|
+
`,(v||document.body).appendChild(a),a.querySelector(".___previewer-close").addEventListener("click",d),a.querySelector(".___previewer-fade").addEventListener("click",d);}function d(){a.style.display="none",a.querySelector(".___previewer-img").src="";}a.querySelector(".___previewer-img").src=x[_],a.style.display="block";}var h={prod:"https://scc.lenovo.com/robot",test:"https://sccuat.lenovo.com/robot",local:"http://localhost:5174/robot/"},P={display:"inline-block",position:"fixed",bottom:"8vh",right:"2.5vh",zIndex:"100000",width:"5vh",height:"5vh",userSelect:"none",MozUserSelect:"none",msUserSelect:"none"},W="https://scc.lenovo.com/download/static/public?filename=robot.gif",j={width:"100%",height:"110%",cursor:"pointer",userSelect:"none",MozUserSelect:"none",msUserSelect:"none"},q={display:"none",position:"absolute",backgroundColor:"#fff",color:"black",padding:"0.7vh 0.9vh",width:"auto",top:"-10vh",left:"-13.5vh",borderRadius:"0.8vh",boxShadow:"0 2px 6px #00000014,0 1px 3px -2px #0000001f,0 4px 12px 4px #0000000d",zIndex:"999"},K={color:"#1d2129",fontWeight:"600",fontSize:"16px",marginBottom:"0.5vh",whiteSpace:"nowrap"},C={color:"#4e5969",fontSize:"12px",whiteSpace:"nowrap"},X={width:"0",height:"0",borderLeft:"1vh solid transparent",borderRight:"1vh solid transparent",borderBottom:"1vh solid white",position:"absolute",top:"100%",left:"85%",transform:"translateX(-50%) rotate(180deg)"},F={position:"absolute",top:"-585px",left:"-440px",zIndex:"9999",width:"450px",height:"605px",boxShadow:"0 2px 6px #00000014,0 1px 3px -2px #0000001f,0 4px 12px 4px #0000000d",borderRadius:"10px",display:"none"},k=1,G=["\u3010\u5907\u6CE8\u3011: ","\u3010Comment\u3011: ","\u3010\u5907\u6CE8\u3011:","\u3010Comment\u3011:"],U="robot__iframe";function B({env:x="prod"}={}){let e=document.createElement("iframe"),v=!1,_=!0,d,i;function $(n,s,l=!0){if(v){console.warn("Robot has been initialized, please do not initialize it again.");return}let p=h.prod;x==="prod"?s.env==="test"?p=h.test:s.env==="local"&&(p=h.local):x==="test"&&(p=h.test,s.env==="local"&&(p=h.local)),v=!0,typeof n=="string"?d=document.querySelector(n):n instanceof HTMLElement&&(d=n),i=document.createElement("robot-parent"),i.id=U,Object.assign(i.style,P),(d||document.body).appendChild(i);let c=document.createElement("img");c.src=s.icon||W,c.setAttribute("alt","IT Support"),Object.assign(c.style,j);let o=document.createElement("div");Object.assign(o.style,q);let S=document.createElement("div");S.textContent="\u6280\u672F\u652F\u6301(IT Support)",Object.assign(S.style,K),o.appendChild(S);let T=document.createElement("div");T.textContent="\u63D0\u4EA4\u5DE5\u5355\u4EE5\u83B7\u5F97\u66F4\u591A\u5E2E\u52A9\u3002",Object.assign(T.style,C),o.appendChild(T);let L=document.createElement("div");L.textContent="Open a ticket for more help.",Object.assign(L.style,C),o.appendChild(L);let f=document.createElement("div");Object.assign(f.style,X),o.appendChild(f),c.addEventListener("mouseover",()=>{e.style.display!=="block"&&(o.style.display="block");}),c.addEventListener("mouseout",()=>{o.style.display="none";}),i.appendChild(c),i.appendChild(o);try{let t=Object.fromEntries(Object.entries({appKey:s.robot_appKey,secret:s.robot_secret,userKey:s.robot_userKey,initLang:s.robot_lang,authMethod:s.robot_auth,chatServiceId:s.chat_serviceId,chatEnable:s.chat_enable,ticketEnable:s.ticket_enable,appTitle:s.app_title,appName:s.app_name}).filter(([g,m])=>m!=null)),r=new URLSearchParams(t);e.src=`${p}?${r.toString()}`,e.frameBorder="0",e.id="robot__iframe",e.title="Ticket Assistant",e.scrolling="no",e.allowTransparency="true",e.allow="autoplay",e.display="none",Object.assign(e.style,F);}catch(t){console.error(t);}let N=()=>{i.style.top="",i.style.left="";let t=window.innerHeight;t<700?(o.style.top="-12vh",o.style.left="-18vh"):t<820?o.style.top="-11vh":t<1e3?(o.style.top="-10vh",o.style.left="-13.5vh"):t<1200?(o.style.top="-8vh",o.style.left="-12.5vh"):(o.style.top="-7vh",o.style.left="-11.5vh"),t<600&&(o.style.left="-20vh"),t<790?f.style.left="71%":f.style.left="85%",t<550&&(o.style.left="-22vh",o.style.top="-14vh"),t<500&&(o.style.left="-24vh",f.style.left="77%"),t<500&&(o.style.left="-28vh",f.style.left="79%",o.style.top="-16vh"),t<450?(e.style.transform="scale3d(0.5, 0.5, 1)",e.style.top="-445px",e.style.left="-330px"):t<500?(e.style.transform="scale3d(0.55, 0.55, 1)",e.style.top="-460px",e.style.left="-340px"):t<600?(e.style.transform="scale3d(0.6, 0.6, 1)",e.style.top="-478px",e.style.left="-354px"):t<700?(e.style.transform="scale3d(0.7, 0.7, 1)",e.style.top="-505px",e.style.left="-380px"):t>=700&&t<790?(e.style.transform="scale3d(0.8, 0.8, 1)",e.style.top="-535px",e.style.left="-400px"):t>=790&&t<880?(e.style.transform="scale3d(0.9, 0.9, 1)",e.style.top="-555px",e.style.left="-420px"):(e.style.transform="scale3d(1, 1, 1)",e.style.top="-585px",e.style.left="-440px"),t<760?i.style.right="4.5vh":t<880?i.style.right="3.5vh":i.style.right="2.5vh";};i.appendChild(e);let R=!1;c.addEventListener("click",()=>{R||(e.style.display==="none"?(e.style.display="block",o.style.display="none",_&&(e.contentWindow.postMessage({type:"firstOpen"},"*"),_=!1)):(e.style.display="none",e.contentWindow.postMessage({type:"parentClose"},"*")));}),window.addEventListener("resize",N),N();function ie(t){let r=t,g=!1,m,Y;r.onmousedown=function(E){g=!0,m=E.clientX-r.offsetLeft,Y=E.clientY-r.offsetTop,R=!1;let ne=E.clientX,re=E.clientY;return document.onmousemove=function(y){if(g){let I=y.clientX-m,O=y.clientY-Y;r.style.left=`${I}px`,r.style.top=`${O}px`;let M=Math.abs(y.clientX-ne),w=Math.abs(y.clientY-re);(M>k||w>k)&&(R=!0);}},document.onmouseup=function(){g=!1,document.onmousemove=null,document.onmouseup=null;let y=document.body.clientWidth,I=document.body.clientHeight,O=r.offsetWidth,M=r.offsetHeight,w=0,z=0,A=y-O/2,D=I-M/2,b=Number.parseInt(r.style.left),u=Number.parseInt(r.style.top);b<w?b=w:b>A&&(b=A),u<z?u=z:u>D&&(u=D),r.style.left=`${b}px`,r.style.top=`${u}px`;},!1};}l&&ie(i),window.addEventListener("message",t=>{t.data&&t.data.type==="childClose"&&(e.style.display="none");});}function V(n){e.contentWindow.postMessage({type:"changeRouteKey",routeKey:n},"*");}function J(n,s="",l="",p=G){e.contentWindow.postMessage({type:"quickSubmitTicket",issue:n,issueDescription:s,customData:l,cursorPositionStrArr:p},"*"),e.style.display="block",_=!1;}function Q(n){e.contentWindow.postMessage({type:"changeLang",lang:n},"*");}let Z=()=>{let n=s=>{var p;let{data:l}=s;l.type==="requestToken"?te():l.type==="viewImages"&&H(l.images||[],(p=l.index)!=null?p:0,i);};return window.addEventListener("message",n),()=>{window.removeEventListener("message",n);}},ee=(n,s,l="*")=>{n?n.postMessage(s,l):console.error("postMessage Error: targetWindow is not exist!");},te=()=>{var n,s;e&&ee(e.contentWindow,{type:"basicToken",token:(s=window.__BASIC_COMMON_TOKEN__)!=null?s:(n=window.localStorage)==null?void 0:n.getItem("__BASIC_COMMON_TOKEN__")},"*");};function oe(n){i?i.style.display=n?"inline-block":"none":console.error("Robot isn't initialized yet!");}let se=Z();return {changeRobotLang:Q,destroyTokenListener:se,initRobot:$,quickSubmit:J,setRouteKey:V,toggleRobotVisibility:oe}}var {changeRobotLang:ye,destroyTokenListener:he,initRobot:_e,quickSubmit:me,setRouteKey:be,toggleRobotVisibility:ue}=B({env:"prod"});
|
|
80
|
+
exports.changeRobotLang=ye;exports.destroyTokenListener=he;exports.initRobot=_e;exports.quickSubmit=me;exports.setRouteKey=be;exports.toggleRobotVisibility=ue;return exports;})({});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var a;function H(x,e,v){let _=e;if(!a){a=document.createElement("robot-previewer");let i=document.createElement("style");i.setAttribute("robot-previewer",""),i.setAttribute("type","text/css"),i.innerHTML=`
|
|
2
|
+
robot-previewer {
|
|
3
|
+
display: none;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
-webkit-font-smoothing: antialiased;
|
|
6
|
+
-moz-osx-font-smoothing: grayscale;
|
|
7
|
+
}
|
|
8
|
+
robot-previewer .___previewer-close {
|
|
9
|
+
position: fixed;
|
|
10
|
+
width: 80px;
|
|
11
|
+
height: 80px;
|
|
12
|
+
border-radius: 50%;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
right: -40px;
|
|
15
|
+
top: -40px;
|
|
16
|
+
text-align: center;
|
|
17
|
+
background-color: rgba(0, 0, 0, 0.9);
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
z-index: 100000002;
|
|
20
|
+
}
|
|
21
|
+
robot-previewer .___previewer-close>span {
|
|
22
|
+
position: fixed;
|
|
23
|
+
top: 4px;
|
|
24
|
+
right: 8px;
|
|
25
|
+
font-size: 1.2em;
|
|
26
|
+
}
|
|
27
|
+
robot-previewer .___previewer-prev,
|
|
28
|
+
robot-previewer .___previewer-next {
|
|
29
|
+
position: fixed;
|
|
30
|
+
width: 60px;
|
|
31
|
+
height: 60px;
|
|
32
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
z-index: 100000002;
|
|
35
|
+
top: 50vh;
|
|
36
|
+
margin-top: -30px;
|
|
37
|
+
text-align: center;
|
|
38
|
+
line-height: 56px;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
font-size: 38px;
|
|
41
|
+
}
|
|
42
|
+
robot-previewer .___previewer-prev {
|
|
43
|
+
left: 0
|
|
44
|
+
}
|
|
45
|
+
robot-previewer .___previewer-next {
|
|
46
|
+
right: 0
|
|
47
|
+
}
|
|
48
|
+
robot-previewer .___previewer-close>span,
|
|
49
|
+
robot-previewer .___previewer-prev>span,
|
|
50
|
+
robot-previewer .___previewer-next>span {
|
|
51
|
+
font-weight: bold;
|
|
52
|
+
color: white;
|
|
53
|
+
}
|
|
54
|
+
robot-previewer .___previewer-img {
|
|
55
|
+
margin: auto;
|
|
56
|
+
position: fixed;
|
|
57
|
+
top: 0;
|
|
58
|
+
bottom: 0;
|
|
59
|
+
left: 0;
|
|
60
|
+
right: 0;
|
|
61
|
+
max-height: 90%;
|
|
62
|
+
max-width: 90%;
|
|
63
|
+
z-index: 100000002;
|
|
64
|
+
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.75);
|
|
65
|
+
}
|
|
66
|
+
robot-previewer .___previewer-fade {
|
|
67
|
+
background-color: rgba(0,0,0,0.5);
|
|
68
|
+
position: fixed;
|
|
69
|
+
top: 0;
|
|
70
|
+
left: 0;
|
|
71
|
+
width: 100vw;
|
|
72
|
+
height: 100vh;
|
|
73
|
+
z-index: 100000000;
|
|
74
|
+
}
|
|
75
|
+
`,document.head.appendChild(i),a.innerHTML=`
|
|
76
|
+
<div class="___previewer-fade"></div>
|
|
77
|
+
<img src="" alt="" class="___previewer-img" />
|
|
78
|
+
<div class="___previewer-close"><span>\xD7</span></div>
|
|
79
|
+
`,(v||document.body).appendChild(a),a.querySelector(".___previewer-close").addEventListener("click",d),a.querySelector(".___previewer-fade").addEventListener("click",d);}function d(){a.style.display="none",a.querySelector(".___previewer-img").src="";}a.querySelector(".___previewer-img").src=x[_],a.style.display="block";}var h={prod:"https://scc.lenovo.com/robot",test:"https://sccuat.lenovo.com/robot",local:"http://localhost:5174/robot/"},P={display:"inline-block",position:"fixed",bottom:"8vh",right:"2.5vh",zIndex:"100000",width:"5vh",height:"5vh",userSelect:"none",MozUserSelect:"none",msUserSelect:"none"},W="https://scc.lenovo.com/download/static/public?filename=robot.gif",j={width:"100%",height:"110%",cursor:"pointer",userSelect:"none",MozUserSelect:"none",msUserSelect:"none"},q={display:"none",position:"absolute",backgroundColor:"#fff",color:"black",padding:"0.7vh 0.9vh",width:"auto",top:"-10vh",left:"-13.5vh",borderRadius:"0.8vh",boxShadow:"0 2px 6px #00000014,0 1px 3px -2px #0000001f,0 4px 12px 4px #0000000d",zIndex:"999"},K={color:"#1d2129",fontWeight:"600",fontSize:"16px",marginBottom:"0.5vh",whiteSpace:"nowrap"},C={color:"#4e5969",fontSize:"12px",whiteSpace:"nowrap"},X={width:"0",height:"0",borderLeft:"1vh solid transparent",borderRight:"1vh solid transparent",borderBottom:"1vh solid white",position:"absolute",top:"100%",left:"85%",transform:"translateX(-50%) rotate(180deg)"},F={position:"absolute",top:"-585px",left:"-440px",zIndex:"9999",width:"450px",height:"605px",boxShadow:"0 2px 6px #00000014,0 1px 3px -2px #0000001f,0 4px 12px 4px #0000000d",borderRadius:"10px",display:"none"},k=1,G=["\u3010\u5907\u6CE8\u3011: ","\u3010Comment\u3011: ","\u3010\u5907\u6CE8\u3011:","\u3010Comment\u3011:"],U="robot__iframe";function B({env:x="prod"}={}){let e=document.createElement("iframe"),v=!1,_=!0,d,i;function $(n,s,l=!0){if(v){console.warn("Robot has been initialized, please do not initialize it again.");return}let p=h.prod;x==="prod"?s.env==="test"?p=h.test:s.env==="local"&&(p=h.local):x==="test"&&(p=h.test,s.env==="local"&&(p=h.local)),v=!0,typeof n=="string"?d=document.querySelector(n):n instanceof HTMLElement&&(d=n),i=document.createElement("robot-parent"),i.id=U,Object.assign(i.style,P),(d||document.body).appendChild(i);let c=document.createElement("img");c.src=s.icon||W,c.setAttribute("alt","IT Support"),Object.assign(c.style,j);let o=document.createElement("div");Object.assign(o.style,q);let S=document.createElement("div");S.textContent="\u6280\u672F\u652F\u6301(IT Support)",Object.assign(S.style,K),o.appendChild(S);let T=document.createElement("div");T.textContent="\u63D0\u4EA4\u5DE5\u5355\u4EE5\u83B7\u5F97\u66F4\u591A\u5E2E\u52A9\u3002",Object.assign(T.style,C),o.appendChild(T);let L=document.createElement("div");L.textContent="Open a ticket for more help.",Object.assign(L.style,C),o.appendChild(L);let f=document.createElement("div");Object.assign(f.style,X),o.appendChild(f),c.addEventListener("mouseover",()=>{e.style.display!=="block"&&(o.style.display="block");}),c.addEventListener("mouseout",()=>{o.style.display="none";}),i.appendChild(c),i.appendChild(o);try{let t=Object.fromEntries(Object.entries({appKey:s.robot_appKey,secret:s.robot_secret,userKey:s.robot_userKey,initLang:s.robot_lang,authMethod:s.robot_auth,chatServiceId:s.chat_serviceId,chatEnable:s.chat_enable,ticketEnable:s.ticket_enable,appTitle:s.app_title,appName:s.app_name}).filter(([g,m])=>m!=null)),r=new URLSearchParams(t);e.src=`${p}?${r.toString()}`,e.frameBorder="0",e.id="robot__iframe",e.title="Ticket Assistant",e.scrolling="no",e.allowTransparency="true",e.allow="autoplay",e.display="none",Object.assign(e.style,F);}catch(t){console.error(t);}let N=()=>{i.style.top="",i.style.left="";let t=window.innerHeight;t<700?(o.style.top="-12vh",o.style.left="-18vh"):t<820?o.style.top="-11vh":t<1e3?(o.style.top="-10vh",o.style.left="-13.5vh"):t<1200?(o.style.top="-8vh",o.style.left="-12.5vh"):(o.style.top="-7vh",o.style.left="-11.5vh"),t<600&&(o.style.left="-20vh"),t<790?f.style.left="71%":f.style.left="85%",t<550&&(o.style.left="-22vh",o.style.top="-14vh"),t<500&&(o.style.left="-24vh",f.style.left="77%"),t<500&&(o.style.left="-28vh",f.style.left="79%",o.style.top="-16vh"),t<450?(e.style.transform="scale3d(0.5, 0.5, 1)",e.style.top="-445px",e.style.left="-330px"):t<500?(e.style.transform="scale3d(0.55, 0.55, 1)",e.style.top="-460px",e.style.left="-340px"):t<600?(e.style.transform="scale3d(0.6, 0.6, 1)",e.style.top="-478px",e.style.left="-354px"):t<700?(e.style.transform="scale3d(0.7, 0.7, 1)",e.style.top="-505px",e.style.left="-380px"):t>=700&&t<790?(e.style.transform="scale3d(0.8, 0.8, 1)",e.style.top="-535px",e.style.left="-400px"):t>=790&&t<880?(e.style.transform="scale3d(0.9, 0.9, 1)",e.style.top="-555px",e.style.left="-420px"):(e.style.transform="scale3d(1, 1, 1)",e.style.top="-585px",e.style.left="-440px"),t<760?i.style.right="4.5vh":t<880?i.style.right="3.5vh":i.style.right="2.5vh";};i.appendChild(e);let R=!1;c.addEventListener("click",()=>{R||(e.style.display==="none"?(e.style.display="block",o.style.display="none",_&&(e.contentWindow.postMessage({type:"firstOpen"},"*"),_=!1)):(e.style.display="none",e.contentWindow.postMessage({type:"parentClose"},"*")));}),window.addEventListener("resize",N),N();function ie(t){let r=t,g=!1,m,Y;r.onmousedown=function(E){g=!0,m=E.clientX-r.offsetLeft,Y=E.clientY-r.offsetTop,R=!1;let ne=E.clientX,re=E.clientY;return document.onmousemove=function(y){if(g){let I=y.clientX-m,O=y.clientY-Y;r.style.left=`${I}px`,r.style.top=`${O}px`;let M=Math.abs(y.clientX-ne),w=Math.abs(y.clientY-re);(M>k||w>k)&&(R=!0);}},document.onmouseup=function(){g=!1,document.onmousemove=null,document.onmouseup=null;let y=document.body.clientWidth,I=document.body.clientHeight,O=r.offsetWidth,M=r.offsetHeight,w=0,z=0,A=y-O/2,D=I-M/2,b=Number.parseInt(r.style.left),u=Number.parseInt(r.style.top);b<w?b=w:b>A&&(b=A),u<z?u=z:u>D&&(u=D),r.style.left=`${b}px`,r.style.top=`${u}px`;},!1};}l&&ie(i),window.addEventListener("message",t=>{t.data&&t.data.type==="childClose"&&(e.style.display="none");});}function V(n){e.contentWindow.postMessage({type:"changeRouteKey",routeKey:n},"*");}function J(n,s="",l="",p=G){e.contentWindow.postMessage({type:"quickSubmitTicket",issue:n,issueDescription:s,customData:l,cursorPositionStrArr:p},"*"),e.style.display="block",_=!1;}function Q(n){e.contentWindow.postMessage({type:"changeLang",lang:n},"*");}let Z=()=>{let n=s=>{var p;let{data:l}=s;l.type==="requestToken"?te():l.type==="viewImages"&&H(l.images||[],(p=l.index)!=null?p:0,i);};return window.addEventListener("message",n),()=>{window.removeEventListener("message",n);}},ee=(n,s,l="*")=>{n?n.postMessage(s,l):console.error("postMessage Error: targetWindow is not exist!");},te=()=>{var n,s;e&&ee(e.contentWindow,{type:"basicToken",token:(s=window.__BASIC_COMMON_TOKEN__)!=null?s:(n=window.localStorage)==null?void 0:n.getItem("__BASIC_COMMON_TOKEN__")},"*");};function oe(n){i?i.style.display=n?"inline-block":"none":console.error("Robot isn't initialized yet!");}let se=Z();return {changeRobotLang:Q,destroyTokenListener:se,initRobot:$,quickSubmit:J,setRouteKey:V,toggleRobotVisibility:oe}}var {changeRobotLang:ye,destroyTokenListener:he,initRobot:_e,quickSubmit:me,setRouteKey:be,toggleRobotVisibility:ue}=B({env:"test"});
|
|
80
|
+
export{ye as changeRobotLang,he as destroyTokenListener,_e as initRobot,me as quickSubmit,be as setRouteKey,ue as toggleRobotVisibility};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var ServerRobot=(function(exports){'use strict';var a;function H(x,e,v){let _=e;if(!a){a=document.createElement("robot-previewer");let i=document.createElement("style");i.setAttribute("robot-previewer",""),i.setAttribute("type","text/css"),i.innerHTML=`
|
|
2
|
+
robot-previewer {
|
|
3
|
+
display: none;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
-webkit-font-smoothing: antialiased;
|
|
6
|
+
-moz-osx-font-smoothing: grayscale;
|
|
7
|
+
}
|
|
8
|
+
robot-previewer .___previewer-close {
|
|
9
|
+
position: fixed;
|
|
10
|
+
width: 80px;
|
|
11
|
+
height: 80px;
|
|
12
|
+
border-radius: 50%;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
right: -40px;
|
|
15
|
+
top: -40px;
|
|
16
|
+
text-align: center;
|
|
17
|
+
background-color: rgba(0, 0, 0, 0.9);
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
z-index: 100000002;
|
|
20
|
+
}
|
|
21
|
+
robot-previewer .___previewer-close>span {
|
|
22
|
+
position: fixed;
|
|
23
|
+
top: 4px;
|
|
24
|
+
right: 8px;
|
|
25
|
+
font-size: 1.2em;
|
|
26
|
+
}
|
|
27
|
+
robot-previewer .___previewer-prev,
|
|
28
|
+
robot-previewer .___previewer-next {
|
|
29
|
+
position: fixed;
|
|
30
|
+
width: 60px;
|
|
31
|
+
height: 60px;
|
|
32
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
z-index: 100000002;
|
|
35
|
+
top: 50vh;
|
|
36
|
+
margin-top: -30px;
|
|
37
|
+
text-align: center;
|
|
38
|
+
line-height: 56px;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
font-size: 38px;
|
|
41
|
+
}
|
|
42
|
+
robot-previewer .___previewer-prev {
|
|
43
|
+
left: 0
|
|
44
|
+
}
|
|
45
|
+
robot-previewer .___previewer-next {
|
|
46
|
+
right: 0
|
|
47
|
+
}
|
|
48
|
+
robot-previewer .___previewer-close>span,
|
|
49
|
+
robot-previewer .___previewer-prev>span,
|
|
50
|
+
robot-previewer .___previewer-next>span {
|
|
51
|
+
font-weight: bold;
|
|
52
|
+
color: white;
|
|
53
|
+
}
|
|
54
|
+
robot-previewer .___previewer-img {
|
|
55
|
+
margin: auto;
|
|
56
|
+
position: fixed;
|
|
57
|
+
top: 0;
|
|
58
|
+
bottom: 0;
|
|
59
|
+
left: 0;
|
|
60
|
+
right: 0;
|
|
61
|
+
max-height: 90%;
|
|
62
|
+
max-width: 90%;
|
|
63
|
+
z-index: 100000002;
|
|
64
|
+
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.75);
|
|
65
|
+
}
|
|
66
|
+
robot-previewer .___previewer-fade {
|
|
67
|
+
background-color: rgba(0,0,0,0.5);
|
|
68
|
+
position: fixed;
|
|
69
|
+
top: 0;
|
|
70
|
+
left: 0;
|
|
71
|
+
width: 100vw;
|
|
72
|
+
height: 100vh;
|
|
73
|
+
z-index: 100000000;
|
|
74
|
+
}
|
|
75
|
+
`,document.head.appendChild(i),a.innerHTML=`
|
|
76
|
+
<div class="___previewer-fade"></div>
|
|
77
|
+
<img src="" alt="" class="___previewer-img" />
|
|
78
|
+
<div class="___previewer-close"><span>\xD7</span></div>
|
|
79
|
+
`,(v||document.body).appendChild(a),a.querySelector(".___previewer-close").addEventListener("click",d),a.querySelector(".___previewer-fade").addEventListener("click",d);}function d(){a.style.display="none",a.querySelector(".___previewer-img").src="";}a.querySelector(".___previewer-img").src=x[_],a.style.display="block";}var h={prod:"https://scc.lenovo.com/robot",test:"https://sccuat.lenovo.com/robot",local:"http://localhost:5174/robot/"},P={display:"inline-block",position:"fixed",bottom:"8vh",right:"2.5vh",zIndex:"100000",width:"5vh",height:"5vh",userSelect:"none",MozUserSelect:"none",msUserSelect:"none"},W="https://scc.lenovo.com/download/static/public?filename=robot.gif",j={width:"100%",height:"110%",cursor:"pointer",userSelect:"none",MozUserSelect:"none",msUserSelect:"none"},q={display:"none",position:"absolute",backgroundColor:"#fff",color:"black",padding:"0.7vh 0.9vh",width:"auto",top:"-10vh",left:"-13.5vh",borderRadius:"0.8vh",boxShadow:"0 2px 6px #00000014,0 1px 3px -2px #0000001f,0 4px 12px 4px #0000000d",zIndex:"999"},K={color:"#1d2129",fontWeight:"600",fontSize:"16px",marginBottom:"0.5vh",whiteSpace:"nowrap"},C={color:"#4e5969",fontSize:"12px",whiteSpace:"nowrap"},X={width:"0",height:"0",borderLeft:"1vh solid transparent",borderRight:"1vh solid transparent",borderBottom:"1vh solid white",position:"absolute",top:"100%",left:"85%",transform:"translateX(-50%) rotate(180deg)"},F={position:"absolute",top:"-585px",left:"-440px",zIndex:"9999",width:"450px",height:"605px",boxShadow:"0 2px 6px #00000014,0 1px 3px -2px #0000001f,0 4px 12px 4px #0000000d",borderRadius:"10px",display:"none"},k=1,G=["\u3010\u5907\u6CE8\u3011: ","\u3010Comment\u3011: ","\u3010\u5907\u6CE8\u3011:","\u3010Comment\u3011:"],U="robot__iframe";function B({env:x="prod"}={}){let e=document.createElement("iframe"),v=!1,_=!0,d,i;function $(n,s,l=!0){if(v){console.warn("Robot has been initialized, please do not initialize it again.");return}let p=h.prod;x==="prod"?s.env==="test"?p=h.test:s.env==="local"&&(p=h.local):x==="test"&&(p=h.test,s.env==="local"&&(p=h.local)),v=!0,typeof n=="string"?d=document.querySelector(n):n instanceof HTMLElement&&(d=n),i=document.createElement("robot-parent"),i.id=U,Object.assign(i.style,P),(d||document.body).appendChild(i);let c=document.createElement("img");c.src=s.icon||W,c.setAttribute("alt","IT Support"),Object.assign(c.style,j);let o=document.createElement("div");Object.assign(o.style,q);let S=document.createElement("div");S.textContent="\u6280\u672F\u652F\u6301(IT Support)",Object.assign(S.style,K),o.appendChild(S);let T=document.createElement("div");T.textContent="\u63D0\u4EA4\u5DE5\u5355\u4EE5\u83B7\u5F97\u66F4\u591A\u5E2E\u52A9\u3002",Object.assign(T.style,C),o.appendChild(T);let L=document.createElement("div");L.textContent="Open a ticket for more help.",Object.assign(L.style,C),o.appendChild(L);let f=document.createElement("div");Object.assign(f.style,X),o.appendChild(f),c.addEventListener("mouseover",()=>{e.style.display!=="block"&&(o.style.display="block");}),c.addEventListener("mouseout",()=>{o.style.display="none";}),i.appendChild(c),i.appendChild(o);try{let t=Object.fromEntries(Object.entries({appKey:s.robot_appKey,secret:s.robot_secret,userKey:s.robot_userKey,initLang:s.robot_lang,authMethod:s.robot_auth,chatServiceId:s.chat_serviceId,chatEnable:s.chat_enable,ticketEnable:s.ticket_enable,appTitle:s.app_title,appName:s.app_name}).filter(([g,m])=>m!=null)),r=new URLSearchParams(t);e.src=`${p}?${r.toString()}`,e.frameBorder="0",e.id="robot__iframe",e.title="Ticket Assistant",e.scrolling="no",e.allowTransparency="true",e.allow="autoplay",e.display="none",Object.assign(e.style,F);}catch(t){console.error(t);}let N=()=>{i.style.top="",i.style.left="";let t=window.innerHeight;t<700?(o.style.top="-12vh",o.style.left="-18vh"):t<820?o.style.top="-11vh":t<1e3?(o.style.top="-10vh",o.style.left="-13.5vh"):t<1200?(o.style.top="-8vh",o.style.left="-12.5vh"):(o.style.top="-7vh",o.style.left="-11.5vh"),t<600&&(o.style.left="-20vh"),t<790?f.style.left="71%":f.style.left="85%",t<550&&(o.style.left="-22vh",o.style.top="-14vh"),t<500&&(o.style.left="-24vh",f.style.left="77%"),t<500&&(o.style.left="-28vh",f.style.left="79%",o.style.top="-16vh"),t<450?(e.style.transform="scale3d(0.5, 0.5, 1)",e.style.top="-445px",e.style.left="-330px"):t<500?(e.style.transform="scale3d(0.55, 0.55, 1)",e.style.top="-460px",e.style.left="-340px"):t<600?(e.style.transform="scale3d(0.6, 0.6, 1)",e.style.top="-478px",e.style.left="-354px"):t<700?(e.style.transform="scale3d(0.7, 0.7, 1)",e.style.top="-505px",e.style.left="-380px"):t>=700&&t<790?(e.style.transform="scale3d(0.8, 0.8, 1)",e.style.top="-535px",e.style.left="-400px"):t>=790&&t<880?(e.style.transform="scale3d(0.9, 0.9, 1)",e.style.top="-555px",e.style.left="-420px"):(e.style.transform="scale3d(1, 1, 1)",e.style.top="-585px",e.style.left="-440px"),t<760?i.style.right="4.5vh":t<880?i.style.right="3.5vh":i.style.right="2.5vh";};i.appendChild(e);let R=!1;c.addEventListener("click",()=>{R||(e.style.display==="none"?(e.style.display="block",o.style.display="none",_&&(e.contentWindow.postMessage({type:"firstOpen"},"*"),_=!1)):(e.style.display="none",e.contentWindow.postMessage({type:"parentClose"},"*")));}),window.addEventListener("resize",N),N();function ie(t){let r=t,g=!1,m,Y;r.onmousedown=function(E){g=!0,m=E.clientX-r.offsetLeft,Y=E.clientY-r.offsetTop,R=!1;let ne=E.clientX,re=E.clientY;return document.onmousemove=function(y){if(g){let I=y.clientX-m,O=y.clientY-Y;r.style.left=`${I}px`,r.style.top=`${O}px`;let M=Math.abs(y.clientX-ne),w=Math.abs(y.clientY-re);(M>k||w>k)&&(R=!0);}},document.onmouseup=function(){g=!1,document.onmousemove=null,document.onmouseup=null;let y=document.body.clientWidth,I=document.body.clientHeight,O=r.offsetWidth,M=r.offsetHeight,w=0,z=0,A=y-O/2,D=I-M/2,b=Number.parseInt(r.style.left),u=Number.parseInt(r.style.top);b<w?b=w:b>A&&(b=A),u<z?u=z:u>D&&(u=D),r.style.left=`${b}px`,r.style.top=`${u}px`;},!1};}l&&ie(i),window.addEventListener("message",t=>{t.data&&t.data.type==="childClose"&&(e.style.display="none");});}function V(n){e.contentWindow.postMessage({type:"changeRouteKey",routeKey:n},"*");}function J(n,s="",l="",p=G){e.contentWindow.postMessage({type:"quickSubmitTicket",issue:n,issueDescription:s,customData:l,cursorPositionStrArr:p},"*"),e.style.display="block",_=!1;}function Q(n){e.contentWindow.postMessage({type:"changeLang",lang:n},"*");}let Z=()=>{let n=s=>{var p;let{data:l}=s;l.type==="requestToken"?te():l.type==="viewImages"&&H(l.images||[],(p=l.index)!=null?p:0,i);};return window.addEventListener("message",n),()=>{window.removeEventListener("message",n);}},ee=(n,s,l="*")=>{n?n.postMessage(s,l):console.error("postMessage Error: targetWindow is not exist!");},te=()=>{var n,s;e&&ee(e.contentWindow,{type:"basicToken",token:(s=window.__BASIC_COMMON_TOKEN__)!=null?s:(n=window.localStorage)==null?void 0:n.getItem("__BASIC_COMMON_TOKEN__")},"*");};function oe(n){i?i.style.display=n?"inline-block":"none":console.error("Robot isn't initialized yet!");}let se=Z();return {changeRobotLang:Q,destroyTokenListener:se,initRobot:$,quickSubmit:J,setRouteKey:V,toggleRobotVisibility:oe}}var {changeRobotLang:ye,destroyTokenListener:he,initRobot:_e,quickSubmit:me,setRouteKey:be,toggleRobotVisibility:ue}=B({env:"test"});
|
|
80
|
+
exports.changeRobotLang=ye;exports.destroyTokenListener=he;exports.initRobot=_e;exports.quickSubmit=me;exports.setRouteKey=be;exports.toggleRobotVisibility=ue;return exports;})({});
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gsc-basic/robot-sdk",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "GSC Team Ticket Robot SDK",
|
|
6
|
+
"author": "wangll47 <wangll47@lenovo.com>",
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://gitlab.xpaas.lenovo.com/tsd-basic/gsc-frontend-config.git"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"registry": "https://registry.npmjs.com/"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"GSC",
|
|
18
|
+
"Ticket",
|
|
19
|
+
"AI Robot"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/robot-prod.es.js",
|
|
24
|
+
"require": "./dist/robot-prod.umd.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"main": "./dist/robot-prod.es.js",
|
|
28
|
+
"files": [
|
|
29
|
+
"./dist"
|
|
30
|
+
],
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"lodash-es": "^4.17.21"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {},
|
|
35
|
+
"devDependencies": {},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup",
|
|
38
|
+
"outdated": "pnpm outdated",
|
|
39
|
+
"clean": "rimraf ./dist"
|
|
40
|
+
}
|
|
41
|
+
}
|