From d690b932c55e8fb5fc4d7d4e3f9610ee74e2e306 Mon Sep 17 00:00:00 2001 From: jack ning Date: Fri, 10 Jan 2025 11:21:29 +0800 Subject: [PATCH] update --- .../resources/static/embed/bytedesk-web.js | 10 +-- .../static/embed/bytedesk-web.umd.js | 12 ++-- .../static/embed/core/BytedeskWeb/index.js | 68 +++++++++---------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/starter/src/main/resources/static/embed/bytedesk-web.js b/starter/src/main/resources/static/embed/bytedesk-web.js index eb03838e52..e7b35c3341 100644 --- a/starter/src/main/resources/static/embed/bytedesk-web.js +++ b/starter/src/main/resources/static/embed/bytedesk-web.js @@ -1,4 +1,4 @@ -var BytedeskWeb=function(){"use strict";var v=Object.defineProperty;var C=(f,p,t)=>p in f?v(f,p,{enumerable:!0,configurable:!0,writable:!0,value:t}):f[p]=t;var g=(f,p,t)=>C(f,typeof p!="symbol"?p+"":p,t);class f{constructor(t){g(this,"config");g(this,"bubble",null);g(this,"window",null);g(this,"inviteDialog",null);g(this,"isVisible",!1);g(this,"isDragging",!1);g(this,"windowState","normal");g(this,"loopCount",0);g(this,"loopTimer",null);this.config={...this.getDefaultConfig(),...t}}getDefaultConfig(){return{baseUrl:"https://www.weiyuai.cn/chat",placement:"bottom-right",marginBottom:20,marginSide:20,autoPopup:!1,tabsConfig:{home:!1,messages:!0,help:!1,news:!1},bubbleConfig:{show:!0,icon:"👋",title:"需要帮助吗?",subtitle:"点击开始对话"},showSupport:!0,chatParams:{org:"df_org_uid",t:"2",sid:"df_rt_uid"},animation:{enabled:!0,duration:300,type:"ease"},theme:{mode:"system",textColor:"#ffffff",backgroundColor:"#0066FF"},window:{width:380,height:640},draggable:!1,locale:"zh-cn"}}init(){var t;this.createBubble(),this.createInviteDialog(),this.setupMessageListener(),this.setupResizeListener(),this.preload(),this.config.autoPopup&&setTimeout(()=>{this.showChat()},this.config.autoPopupDelay||1e3),(t=this.config.inviteParams)!=null&&t.show&&setTimeout(()=>{this.showInviteDialog()},this.config.inviteParams.delay||3e3)}createBubble(){var o,s,r,n,d;const t=document.createElement("div");t.style.cssText=` +var BytedeskWeb=function(){"use strict";var v=Object.defineProperty;var C=(f,m,t)=>m in f?v(f,m,{enumerable:!0,configurable:!0,writable:!0,value:t}):f[m]=t;var p=(f,m,t)=>C(f,typeof m!="symbol"?m+"":m,t);class f{constructor(t){p(this,"config");p(this,"bubble",null);p(this,"window",null);p(this,"inviteDialog",null);p(this,"isVisible",!1);p(this,"isDragging",!1);p(this,"windowState","normal");p(this,"loopCount",0);p(this,"loopTimer",null);this.config={...this.getDefaultConfig(),...t}}getDefaultConfig(){return{baseUrl:"https://www.weiyuai.cn/chat",placement:"bottom-right",marginBottom:20,marginSide:20,autoPopup:!1,tabsConfig:{home:!1,messages:!0,help:!1,news:!1},bubbleConfig:{show:!0,icon:"👋",title:"需要帮助吗?",subtitle:"点击开始对话"},showSupport:!0,chatParams:{org:"df_org_uid",t:"2",sid:"df_rt_uid"},animation:{enabled:!0,duration:300,type:"ease"},theme:{mode:"system",textColor:"#ffffff",backgroundColor:"#0066FF"},window:{width:380,height:640},draggable:!1,locale:"zh-cn"}}init(){var t;this.createBubble(),this.createInviteDialog(),this.setupMessageListener(),this.setupResizeListener(),this.preload(),this.config.autoPopup&&setTimeout(()=>{this.showChat()},this.config.autoPopupDelay||1e3),(t=this.config.inviteParams)!=null&&t.show&&setTimeout(()=>{this.showInviteDialog()},this.config.inviteParams.delay||3e3)}createBubble(){var o,s,r,n,d;const t=document.createElement("div");t.style.cssText=` position: fixed; ${this.config.placement==="bottom-left"?"left":"right"}: ${this.config.marginSide}px; bottom: ${this.config.marginBottom}px; @@ -22,7 +22,7 @@ var BytedeskWeb=function(){"use strict";var v=Object.defineProperty;var C=(f,p,t display: flex; align-items: center; gap: 8px; - `;const h=document.createElement("span");h.textContent=((s=this.config.bubbleConfig)==null?void 0:s.icon)||"",h.style.fontSize="20px",l.appendChild(h);const c=document.createElement("div"),m=document.createElement("div");m.textContent=((r=this.config.bubbleConfig)==null?void 0:r.title)||"",m.style.fontWeight="bold",m.style.marginBottom="4px",c.appendChild(m);const a=document.createElement("div");a.textContent=((n=this.config.bubbleConfig)==null?void 0:n.subtitle)||"",a.style.fontSize="0.9em",a.style.opacity="0.8",c.appendChild(a),l.appendChild(c),e.appendChild(l);const b=document.createElement("div");b.style.cssText=` + `;const h=document.createElement("span");h.textContent=((s=this.config.bubbleConfig)==null?void 0:s.icon)||"",h.style.fontSize="20px",l.appendChild(h);const c=document.createElement("div"),g=document.createElement("div");g.textContent=((r=this.config.bubbleConfig)==null?void 0:r.title)||"",g.style.fontWeight="bold",g.style.marginBottom="4px",c.appendChild(g);const a=document.createElement("div");a.textContent=((n=this.config.bubbleConfig)==null?void 0:n.subtitle)||"",a.style.fontSize="0.9em",a.style.opacity="0.8",c.appendChild(a),l.appendChild(c),e.appendChild(l);const b=document.createElement("div");b.style.cssText=` position: absolute; bottom: -6px; ${this.config.placement==="bottom-left"?"left: 24px":"right: 24px"}; @@ -62,7 +62,7 @@ var BytedeskWeb=function(){"use strict";var v=Object.defineProperty;var C=(f,p,t display: flex; align-items: center; justify-content: center; - `,this.bubble.appendChild(i),this.bubble.addEventListener("mouseenter",()=>{this.bubble.style.transform="scale(1.1)"}),this.bubble.addEventListener("mouseleave",()=>{this.bubble.style.transform="scale(1)"}),t.appendChild(this.bubble),this.config.draggable){let l=0,h=0,c=0,m=0;this.bubble.addEventListener("mousedown",a=>{a.button===0&&(this.isDragging=!0,l=a.clientX,h=a.clientY,c=t.offsetLeft,m=t.offsetTop,t.style.transition="none")}),document.addEventListener("mousemove",a=>{if(!this.isDragging)return;a.preventDefault();const b=a.clientX-l,u=a.clientY-h,w=c+b,x=m+u,y=window.innerHeight-t.offsetHeight;w<=window.innerWidth/2?(t.style.left=`${Math.max(0,w)}px`,t.style.right="auto",this.config.placement="bottom-left"):(t.style.right=`${Math.max(0,window.innerWidth-w-t.offsetWidth)}px`,t.style.left="auto",this.config.placement="bottom-right"),t.style.bottom=`${Math.min(Math.max(0,window.innerHeight-x-t.offsetHeight),y)}px`}),document.addEventListener("mouseup",()=>{this.isDragging&&(this.isDragging=!1,t.style.transition="all 0.3s ease",this.config.marginSide=parseInt(this.config.placement==="bottom-left"?t.style.left:t.style.right)||20,this.config.marginBottom=parseInt(t.style.bottom||"20"))})}this.bubble.addEventListener("click",()=>{if(!this.isDragging){console.log("bubble click");const l=this.bubble.messageElement;l instanceof HTMLElement&&(l.style.display="none"),this.showChat()}}),this.bubble.messageElement=e,document.body.appendChild(t)}getSupportText(){const t=this.config.locale||"zh-cn",e={"zh-cn":"微语技术支持",en:"Powered by Weiyuai","ja-JP":"Weiyuaiによる技術支援","ko-KR":"Weiyuai 기술 지원"};return e[t]||e["zh-cn"]}createChatWindow(){var n,d,l,h,c,m;this.window=document.createElement("div");const t=window.innerWidth<=768,e=window.innerWidth,i=window.innerHeight,o=Math.min(((n=this.config.window)==null?void 0:n.width)||e*.9,e*.9),s=Math.min(((d=this.config.window)==null?void 0:d.height)||i*.9,i*.9);t?this.window.style.cssText=` + `,this.bubble.appendChild(i),this.bubble.addEventListener("mouseenter",()=>{this.bubble.style.transform="scale(1.1)"}),this.bubble.addEventListener("mouseleave",()=>{this.bubble.style.transform="scale(1)"}),t.appendChild(this.bubble),this.config.draggable){let l=0,h=0,c=0,g=0;this.bubble.addEventListener("mousedown",a=>{a.button===0&&(this.isDragging=!0,l=a.clientX,h=a.clientY,c=t.offsetLeft,g=t.offsetTop,t.style.transition="none")}),document.addEventListener("mousemove",a=>{if(!this.isDragging)return;a.preventDefault();const b=a.clientX-l,u=a.clientY-h,w=c+b,x=g+u,y=window.innerHeight-t.offsetHeight;w<=window.innerWidth/2?(t.style.left=`${Math.max(0,w)}px`,t.style.right="auto",this.config.placement="bottom-left"):(t.style.right=`${Math.max(0,window.innerWidth-w-t.offsetWidth)}px`,t.style.left="auto",this.config.placement="bottom-right"),t.style.bottom=`${Math.min(Math.max(0,window.innerHeight-x-t.offsetHeight),y)}px`}),document.addEventListener("mouseup",()=>{this.isDragging&&(this.isDragging=!1,t.style.transition="all 0.3s ease",this.config.marginSide=parseInt(this.config.placement==="bottom-left"?t.style.left:t.style.right)||20,this.config.marginBottom=parseInt(t.style.bottom||"20"))})}this.bubble.addEventListener("click",()=>{if(!this.isDragging){console.log("bubble click");const l=this.bubble.messageElement;l instanceof HTMLElement&&(l.style.display="none"),this.showChat()}}),this.bubble.messageElement=e,document.body.appendChild(t)}getSupportText(){const t=this.config.locale||"zh-cn",e={"zh-cn":"微语技术支持",en:"Powered by Weiyuai","ja-JP":"Weiyuaiによる技術支援","ko-KR":"Weiyuai 기술 지원"};return e[t]||e["zh-cn"]}createChatWindow(){var n,d,l,h,c,g;this.window=document.createElement("div");const t=window.innerWidth<=768,e=window.innerWidth,i=window.innerHeight,o=Math.min(((n=this.config.window)==null?void 0:n.width)||e*.9,e*.9),s=Math.min(((d=this.config.window)==null?void 0:d.height)||i*.9,i*.9);t?this.window.style.cssText=` position: fixed; left: 0; bottom: 0; @@ -85,7 +85,7 @@ var BytedeskWeb=function(){"use strict";var v=Object.defineProperty;var C=(f,p,t display: none; overflow: hidden; z-index: 10000; - transition: all ${(c=this.config.animation)==null?void 0:c.duration}ms ${(m=this.config.animation)==null?void 0:m.type}; + transition: all ${(c=this.config.animation)==null?void 0:c.duration}ms ${(g=this.config.animation)==null?void 0:g.type}; `;const r=document.createElement("iframe");if(r.style.cssText=` width: 100%; height: ${this.config.showSupport?"calc(100% - 30px)":"100%"}; @@ -110,7 +110,7 @@ var BytedeskWeb=function(){"use strict";var v=Object.defineProperty;var C=(f,p,t "> ${this.getSupportText()} - `,this.window.appendChild(a)}document.body.appendChild(this.window)}generateChatUrl(t=!1,e="messages"){console.log("this.config: ",this.config,e);const i=new URLSearchParams;return Object.entries(this.config.chatParams||{}).forEach(([o,s])=>{i.append(o,String(s))}),Object.entries(this.config.browseParams||{}).forEach(([o,s])=>{i.append(o,String(s))}),Object.entries(this.config.theme||{}).forEach(([o,s])=>{i.append(o,String(s))}),i.append("lang",this.config.locale||"zh-cn"),t&&i.append("preload","1"),`${this.config.baseUrl}?${i.toString()}`}setupMessageListener(){window.addEventListener("message",t=>{switch(t.data.type){case"CLOSE_CHAT_WINDOW":this.hideChat();break;case"MAXIMIZE_WINDOW":this.toggleMaximize();break;case"MINIMIZE_WINDOW":this.minimizeWindow();break;case"RECEIVE_MESSAGE":console.log("RECEIVE_MESSAGE");break;case"INVITE_VISITOR":console.log("INVITE_VISITOR");break;case"INVITE_VISITOR_ACCEPT":console.log("INVITE_VISITOR_ACCEPT");break;case"INVITE_VISITOR_REJECT":console.log("INVITE_VISITOR_REJECT");break}})}preload(){console.log("preload");const t=this.generateChatUrl(!0);console.log("preLoadUrl: ",t);const e=document.createElement("iframe");e.src=t,e.style.display="none",document.body.appendChild(e)}showChat(){if(this.window||this.createChatWindow(),this.window){const t=window.innerWidth<=768;if(this.window.style.display="block",this.setupResizeListener(),t&&this.window&&(this.window.style.transform="translateY(100%)",requestAnimationFrame(()=>{this.window&&(this.window.style.transform="translateY(0)")})),this.isVisible=!0,this.bubble){this.bubble.style.display="none";const e=this.bubble.messageElement;e instanceof HTMLElement&&(e.style.display="none")}}this.hideInviteDialog()}hideChat(){var t;if(this.window&&(window.innerWidth<=768?(this.window.style.transform="translateY(100%)",setTimeout(()=>{this.window&&(this.window.style.display="none")},((t=this.config.animation)==null?void 0:t.duration)||300)):this.window.style.display="none",this.isVisible=!1,this.bubble)){this.bubble.style.display="inline-flex";const i=this.bubble.messageElement;i instanceof HTMLElement&&(i.style.display="block")}}minimizeWindow(){this.window&&(this.windowState="minimized",this.window.style.display="none")}toggleMaximize(){!this.window||window.innerWidth<=768||(this.windowState=this.windowState==="maximized"?"normal":"maximized",this.setupResizeListener())}setupResizeListener(){const t=()=>{var r,n;if(!this.window||!this.isVisible)return;const i=window.innerWidth<=768,o=window.innerWidth,s=window.innerHeight;if(i)Object.assign(this.window.style,{left:"0",bottom:"0",width:"100%",height:"90vh",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0",borderBottomRightRadius:"0"});else{let d=this.windowState==="maximized"?o:Math.min(((r=this.config.window)==null?void 0:r.width)||o*.9,o*.9),l=this.windowState==="maximized"?s:Math.min(((n=this.config.window)==null?void 0:n.height)||s*.9,s*.9);const h=this.config.placement==="bottom-right"?this.config.marginSide:void 0,c=this.config.placement==="bottom-left"?this.config.marginSide:void 0;Object.assign(this.window.style,{width:`${d}px`,height:`${l}px`,right:h?`${h}px`:"auto",left:c?`${c}px`:"auto",bottom:`${this.config.marginBottom}px`,borderRadius:this.windowState==="maximized"?"0":"12px"})}};let e;window.addEventListener("resize",()=>{clearTimeout(e),e=window.setTimeout(t,100)}),t()}destroy(){var e;const t=(e=this.bubble)==null?void 0:e.parentElement;t&&document.body.contains(t)&&(document.body.removeChild(t),this.bubble=null),this.window&&document.body.contains(this.window)&&(document.body.removeChild(this.window),this.window=null),window.removeEventListener("resize",this.setupResizeListener.bind(this)),this.loopTimer&&(window.clearTimeout(this.loopTimer),this.loopTimer=null),this.inviteDialog&&document.body.contains(this.inviteDialog)&&(document.body.removeChild(this.inviteDialog),this.inviteDialog=null)}createInviteDialog(){var s,r;if(!((s=this.config.inviteParams)!=null&&s.show))return;if(this.inviteDialog=document.createElement("div"),this.inviteDialog.style.cssText=` + `,this.window.appendChild(a)}document.body.appendChild(this.window)}generateChatUrl(t=!1,e="messages"){console.log("this.config: ",this.config,e);const i=new URLSearchParams;return Object.entries(this.config.chatParams||{}).forEach(([o,s])=>{i.append(o,String(s))}),Object.entries(this.config.browseParams||{}).forEach(([o,s])=>{i.append(o,String(s))}),Object.entries(this.config.theme||{}).forEach(([o,s])=>{i.append(o,String(s))}),i.append("lang",this.config.locale||"zh-cn"),t&&i.append("preload","1"),`${this.config.baseUrl}?${i.toString()}`}setupMessageListener(){window.addEventListener("message",t=>{switch(t.data.type){case"CLOSE_CHAT_WINDOW":this.hideChat();break;case"MAXIMIZE_WINDOW":this.toggleMaximize();break;case"MINIMIZE_WINDOW":this.minimizeWindow();break;case"RECEIVE_MESSAGE":console.log("RECEIVE_MESSAGE");break;case"INVITE_VISITOR":console.log("INVITE_VISITOR");break;case"INVITE_VISITOR_ACCEPT":console.log("INVITE_VISITOR_ACCEPT");break;case"INVITE_VISITOR_REJECT":console.log("INVITE_VISITOR_REJECT");break}})}preload(){console.log("preload");const t=this.generateChatUrl(!0);console.log("preLoadUrl: ",t);const e=document.createElement("iframe");e.src=t,e.style.display="none",document.body.appendChild(e)}showChat(){if(this.window||this.createChatWindow(),this.window){const t=window.innerWidth<=768;if(this.window.style.display="block",this.setupResizeListener(),t&&this.window&&(this.window.style.transform="translateY(100%)",requestAnimationFrame(()=>{this.window&&(this.window.style.transform="translateY(0)")})),this.isVisible=!0,this.bubble){this.bubble.style.display="none";const e=this.bubble.messageElement;e instanceof HTMLElement&&(e.style.display="none")}}this.hideInviteDialog()}hideChat(){var t;if(this.window&&(window.innerWidth<=768?(this.window.style.transform="translateY(100%)",setTimeout(()=>{this.window&&(this.window.style.display="none")},((t=this.config.animation)==null?void 0:t.duration)||300)):this.window.style.display="none",this.isVisible=!1,this.bubble)){this.bubble.style.display="inline-flex";const i=this.bubble.messageElement;i instanceof HTMLElement&&(i.style.display="block")}}minimizeWindow(){this.window&&(this.windowState="minimized",this.window.style.display="none")}toggleMaximize(){this.window&&window.open(this.generateChatUrl(),"_blank")}setupResizeListener(){const t=()=>{var r,n;if(!this.window||!this.isVisible)return;const i=window.innerWidth<=768,o=window.innerWidth,s=window.innerHeight;if(i)Object.assign(this.window.style,{left:"0",bottom:"0",width:"100%",height:"90vh",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0",borderBottomRightRadius:"0"});else{let d=this.windowState==="maximized"?o:Math.min(((r=this.config.window)==null?void 0:r.width)||o*.9,o*.9),l=this.windowState==="maximized"?s:Math.min(((n=this.config.window)==null?void 0:n.height)||s*.9,s*.9);const h=this.config.placement==="bottom-right"?this.config.marginSide:void 0,c=this.config.placement==="bottom-left"?this.config.marginSide:void 0;Object.assign(this.window.style,{width:`${d}px`,height:`${l}px`,right:h?`${h}px`:"auto",left:c?`${c}px`:"auto",bottom:`${this.config.marginBottom}px`,borderRadius:this.windowState==="maximized"?"0":"12px"})}};let e;window.addEventListener("resize",()=>{clearTimeout(e),e=window.setTimeout(t,100)}),t()}destroy(){var e;const t=(e=this.bubble)==null?void 0:e.parentElement;t&&document.body.contains(t)&&(document.body.removeChild(t),this.bubble=null),this.window&&document.body.contains(this.window)&&(document.body.removeChild(this.window),this.window=null),window.removeEventListener("resize",this.setupResizeListener.bind(this)),this.loopTimer&&(window.clearTimeout(this.loopTimer),this.loopTimer=null),this.inviteDialog&&document.body.contains(this.inviteDialog)&&(document.body.removeChild(this.inviteDialog),this.inviteDialog=null)}createInviteDialog(){var s,r;if(!((s=this.config.inviteParams)!=null&&s.show))return;if(this.inviteDialog=document.createElement("div"),this.inviteDialog.style.cssText=` position: fixed; top: 50%; left: 50%; diff --git a/starter/src/main/resources/static/embed/bytedesk-web.umd.js b/starter/src/main/resources/static/embed/bytedesk-web.umd.js index 12ca98fff6..8c0c9e74a9 100644 --- a/starter/src/main/resources/static/embed/bytedesk-web.umd.js +++ b/starter/src/main/resources/static/embed/bytedesk-web.umd.js @@ -1,4 +1,4 @@ -(function(p,h){typeof exports=="object"&&typeof module<"u"?module.exports=h():typeof define=="function"&&define.amd?define(h):(p=typeof globalThis<"u"?globalThis:p||self,p.BytedeskWeb=h())})(this,function(){"use strict";var v=Object.defineProperty;var C=(p,h,t)=>h in p?v(p,h,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[h]=t;var f=(p,h,t)=>C(p,typeof h!="symbol"?h+"":h,t);class p{constructor(t){f(this,"config");f(this,"bubble",null);f(this,"window",null);f(this,"inviteDialog",null);f(this,"isVisible",!1);f(this,"isDragging",!1);f(this,"windowState","normal");f(this,"loopCount",0);f(this,"loopTimer",null);this.config={...this.getDefaultConfig(),...t}}getDefaultConfig(){return{baseUrl:"https://www.weiyuai.cn/chat",placement:"bottom-right",marginBottom:20,marginSide:20,autoPopup:!1,tabsConfig:{home:!1,messages:!0,help:!1,news:!1},bubbleConfig:{show:!0,icon:"👋",title:"需要帮助吗?",subtitle:"点击开始对话"},showSupport:!0,chatParams:{org:"df_org_uid",t:"2",sid:"df_rt_uid"},animation:{enabled:!0,duration:300,type:"ease"},theme:{mode:"system",textColor:"#ffffff",backgroundColor:"#0066FF"},window:{width:380,height:640},draggable:!1,locale:"zh-cn"}}init(){var t;this.createBubble(),this.createInviteDialog(),this.setupMessageListener(),this.setupResizeListener(),this.preload(),this.config.autoPopup&&setTimeout(()=>{this.showChat()},this.config.autoPopupDelay||1e3),(t=this.config.inviteParams)!=null&&t.show&&setTimeout(()=>{this.showInviteDialog()},this.config.inviteParams.delay||3e3)}createBubble(){var o,s,d,n,r;const t=document.createElement("div");t.style.cssText=` +(function(g,h){typeof exports=="object"&&typeof module<"u"?module.exports=h():typeof define=="function"&&define.amd?define(h):(g=typeof globalThis<"u"?globalThis:g||self,g.BytedeskWeb=h())})(this,function(){"use strict";var v=Object.defineProperty;var C=(g,h,t)=>h in g?v(g,h,{enumerable:!0,configurable:!0,writable:!0,value:t}):g[h]=t;var f=(g,h,t)=>C(g,typeof h!="symbol"?h+"":h,t);class g{constructor(t){f(this,"config");f(this,"bubble",null);f(this,"window",null);f(this,"inviteDialog",null);f(this,"isVisible",!1);f(this,"isDragging",!1);f(this,"windowState","normal");f(this,"loopCount",0);f(this,"loopTimer",null);this.config={...this.getDefaultConfig(),...t}}getDefaultConfig(){return{baseUrl:"https://www.weiyuai.cn/chat",placement:"bottom-right",marginBottom:20,marginSide:20,autoPopup:!1,tabsConfig:{home:!1,messages:!0,help:!1,news:!1},bubbleConfig:{show:!0,icon:"👋",title:"需要帮助吗?",subtitle:"点击开始对话"},showSupport:!0,chatParams:{org:"df_org_uid",t:"2",sid:"df_rt_uid"},animation:{enabled:!0,duration:300,type:"ease"},theme:{mode:"system",textColor:"#ffffff",backgroundColor:"#0066FF"},window:{width:380,height:640},draggable:!1,locale:"zh-cn"}}init(){var t;this.createBubble(),this.createInviteDialog(),this.setupMessageListener(),this.setupResizeListener(),this.preload(),this.config.autoPopup&&setTimeout(()=>{this.showChat()},this.config.autoPopupDelay||1e3),(t=this.config.inviteParams)!=null&&t.show&&setTimeout(()=>{this.showInviteDialog()},this.config.inviteParams.delay||3e3)}createBubble(){var o,s,d,n,r;const t=document.createElement("div");t.style.cssText=` position: fixed; ${this.config.placement==="bottom-left"?"left":"right"}: ${this.config.marginSide}px; bottom: ${this.config.marginBottom}px; @@ -22,7 +22,7 @@ display: flex; align-items: center; gap: 8px; - `;const c=document.createElement("span");c.textContent=((s=this.config.bubbleConfig)==null?void 0:s.icon)||"",c.style.fontSize="20px",l.appendChild(c);const m=document.createElement("div"),g=document.createElement("div");g.textContent=((d=this.config.bubbleConfig)==null?void 0:d.title)||"",g.style.fontWeight="bold",g.style.marginBottom="4px",m.appendChild(g);const a=document.createElement("div");a.textContent=((n=this.config.bubbleConfig)==null?void 0:n.subtitle)||"",a.style.fontSize="0.9em",a.style.opacity="0.8",m.appendChild(a),l.appendChild(m),e.appendChild(l);const b=document.createElement("div");b.style.cssText=` + `;const c=document.createElement("span");c.textContent=((s=this.config.bubbleConfig)==null?void 0:s.icon)||"",c.style.fontSize="20px",l.appendChild(c);const p=document.createElement("div"),m=document.createElement("div");m.textContent=((d=this.config.bubbleConfig)==null?void 0:d.title)||"",m.style.fontWeight="bold",m.style.marginBottom="4px",p.appendChild(m);const a=document.createElement("div");a.textContent=((n=this.config.bubbleConfig)==null?void 0:n.subtitle)||"",a.style.fontSize="0.9em",a.style.opacity="0.8",p.appendChild(a),l.appendChild(p),e.appendChild(l);const b=document.createElement("div");b.style.cssText=` position: absolute; bottom: -6px; ${this.config.placement==="bottom-left"?"left: 24px":"right: 24px"}; @@ -62,7 +62,7 @@ display: flex; align-items: center; justify-content: center; - `,this.bubble.appendChild(i),this.bubble.addEventListener("mouseenter",()=>{this.bubble.style.transform="scale(1.1)"}),this.bubble.addEventListener("mouseleave",()=>{this.bubble.style.transform="scale(1)"}),t.appendChild(this.bubble),this.config.draggable){let l=0,c=0,m=0,g=0;this.bubble.addEventListener("mousedown",a=>{a.button===0&&(this.isDragging=!0,l=a.clientX,c=a.clientY,m=t.offsetLeft,g=t.offsetTop,t.style.transition="none")}),document.addEventListener("mousemove",a=>{if(!this.isDragging)return;a.preventDefault();const b=a.clientX-l,u=a.clientY-c,w=m+b,x=g+u,y=window.innerHeight-t.offsetHeight;w<=window.innerWidth/2?(t.style.left=`${Math.max(0,w)}px`,t.style.right="auto",this.config.placement="bottom-left"):(t.style.right=`${Math.max(0,window.innerWidth-w-t.offsetWidth)}px`,t.style.left="auto",this.config.placement="bottom-right"),t.style.bottom=`${Math.min(Math.max(0,window.innerHeight-x-t.offsetHeight),y)}px`}),document.addEventListener("mouseup",()=>{this.isDragging&&(this.isDragging=!1,t.style.transition="all 0.3s ease",this.config.marginSide=parseInt(this.config.placement==="bottom-left"?t.style.left:t.style.right)||20,this.config.marginBottom=parseInt(t.style.bottom||"20"))})}this.bubble.addEventListener("click",()=>{if(!this.isDragging){console.log("bubble click");const l=this.bubble.messageElement;l instanceof HTMLElement&&(l.style.display="none"),this.showChat()}}),this.bubble.messageElement=e,document.body.appendChild(t)}getSupportText(){const t=this.config.locale||"zh-cn",e={"zh-cn":"微语技术支持",en:"Powered by Weiyuai","ja-JP":"Weiyuaiによる技術支援","ko-KR":"Weiyuai 기술 지원"};return e[t]||e["zh-cn"]}createChatWindow(){var n,r,l,c,m,g;this.window=document.createElement("div");const t=window.innerWidth<=768,e=window.innerWidth,i=window.innerHeight,o=Math.min(((n=this.config.window)==null?void 0:n.width)||e*.9,e*.9),s=Math.min(((r=this.config.window)==null?void 0:r.height)||i*.9,i*.9);t?this.window.style.cssText=` + `,this.bubble.appendChild(i),this.bubble.addEventListener("mouseenter",()=>{this.bubble.style.transform="scale(1.1)"}),this.bubble.addEventListener("mouseleave",()=>{this.bubble.style.transform="scale(1)"}),t.appendChild(this.bubble),this.config.draggable){let l=0,c=0,p=0,m=0;this.bubble.addEventListener("mousedown",a=>{a.button===0&&(this.isDragging=!0,l=a.clientX,c=a.clientY,p=t.offsetLeft,m=t.offsetTop,t.style.transition="none")}),document.addEventListener("mousemove",a=>{if(!this.isDragging)return;a.preventDefault();const b=a.clientX-l,u=a.clientY-c,w=p+b,x=m+u,y=window.innerHeight-t.offsetHeight;w<=window.innerWidth/2?(t.style.left=`${Math.max(0,w)}px`,t.style.right="auto",this.config.placement="bottom-left"):(t.style.right=`${Math.max(0,window.innerWidth-w-t.offsetWidth)}px`,t.style.left="auto",this.config.placement="bottom-right"),t.style.bottom=`${Math.min(Math.max(0,window.innerHeight-x-t.offsetHeight),y)}px`}),document.addEventListener("mouseup",()=>{this.isDragging&&(this.isDragging=!1,t.style.transition="all 0.3s ease",this.config.marginSide=parseInt(this.config.placement==="bottom-left"?t.style.left:t.style.right)||20,this.config.marginBottom=parseInt(t.style.bottom||"20"))})}this.bubble.addEventListener("click",()=>{if(!this.isDragging){console.log("bubble click");const l=this.bubble.messageElement;l instanceof HTMLElement&&(l.style.display="none"),this.showChat()}}),this.bubble.messageElement=e,document.body.appendChild(t)}getSupportText(){const t=this.config.locale||"zh-cn",e={"zh-cn":"微语技术支持",en:"Powered by Weiyuai","ja-JP":"Weiyuaiによる技術支援","ko-KR":"Weiyuai 기술 지원"};return e[t]||e["zh-cn"]}createChatWindow(){var n,r,l,c,p,m;this.window=document.createElement("div");const t=window.innerWidth<=768,e=window.innerWidth,i=window.innerHeight,o=Math.min(((n=this.config.window)==null?void 0:n.width)||e*.9,e*.9),s=Math.min(((r=this.config.window)==null?void 0:r.height)||i*.9,i*.9);t?this.window.style.cssText=` position: fixed; left: 0; bottom: 0; @@ -85,7 +85,7 @@ display: none; overflow: hidden; z-index: 10000; - transition: all ${(m=this.config.animation)==null?void 0:m.duration}ms ${(g=this.config.animation)==null?void 0:g.type}; + transition: all ${(p=this.config.animation)==null?void 0:p.duration}ms ${(m=this.config.animation)==null?void 0:m.type}; `;const d=document.createElement("iframe");if(d.style.cssText=` width: 100%; height: ${this.config.showSupport?"calc(100% - 30px)":"100%"}; @@ -110,7 +110,7 @@ "> ${this.getSupportText()} - `,this.window.appendChild(a)}document.body.appendChild(this.window)}generateChatUrl(t=!1,e="messages"){console.log("this.config: ",this.config,e);const i=new URLSearchParams;return Object.entries(this.config.chatParams||{}).forEach(([o,s])=>{i.append(o,String(s))}),Object.entries(this.config.browseParams||{}).forEach(([o,s])=>{i.append(o,String(s))}),Object.entries(this.config.theme||{}).forEach(([o,s])=>{i.append(o,String(s))}),i.append("lang",this.config.locale||"zh-cn"),t&&i.append("preload","1"),`${this.config.baseUrl}?${i.toString()}`}setupMessageListener(){window.addEventListener("message",t=>{switch(t.data.type){case"CLOSE_CHAT_WINDOW":this.hideChat();break;case"MAXIMIZE_WINDOW":this.toggleMaximize();break;case"MINIMIZE_WINDOW":this.minimizeWindow();break;case"RECEIVE_MESSAGE":console.log("RECEIVE_MESSAGE");break;case"INVITE_VISITOR":console.log("INVITE_VISITOR");break;case"INVITE_VISITOR_ACCEPT":console.log("INVITE_VISITOR_ACCEPT");break;case"INVITE_VISITOR_REJECT":console.log("INVITE_VISITOR_REJECT");break}})}preload(){console.log("preload");const t=this.generateChatUrl(!0);console.log("preLoadUrl: ",t);const e=document.createElement("iframe");e.src=t,e.style.display="none",document.body.appendChild(e)}showChat(){if(this.window||this.createChatWindow(),this.window){const t=window.innerWidth<=768;if(this.window.style.display="block",this.setupResizeListener(),t&&this.window&&(this.window.style.transform="translateY(100%)",requestAnimationFrame(()=>{this.window&&(this.window.style.transform="translateY(0)")})),this.isVisible=!0,this.bubble){this.bubble.style.display="none";const e=this.bubble.messageElement;e instanceof HTMLElement&&(e.style.display="none")}}this.hideInviteDialog()}hideChat(){var t;if(this.window&&(window.innerWidth<=768?(this.window.style.transform="translateY(100%)",setTimeout(()=>{this.window&&(this.window.style.display="none")},((t=this.config.animation)==null?void 0:t.duration)||300)):this.window.style.display="none",this.isVisible=!1,this.bubble)){this.bubble.style.display="inline-flex";const i=this.bubble.messageElement;i instanceof HTMLElement&&(i.style.display="block")}}minimizeWindow(){this.window&&(this.windowState="minimized",this.window.style.display="none")}toggleMaximize(){!this.window||window.innerWidth<=768||(this.windowState=this.windowState==="maximized"?"normal":"maximized",this.setupResizeListener())}setupResizeListener(){const t=()=>{var d,n;if(!this.window||!this.isVisible)return;const i=window.innerWidth<=768,o=window.innerWidth,s=window.innerHeight;if(i)Object.assign(this.window.style,{left:"0",bottom:"0",width:"100%",height:"90vh",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0",borderBottomRightRadius:"0"});else{let r=this.windowState==="maximized"?o:Math.min(((d=this.config.window)==null?void 0:d.width)||o*.9,o*.9),l=this.windowState==="maximized"?s:Math.min(((n=this.config.window)==null?void 0:n.height)||s*.9,s*.9);const c=this.config.placement==="bottom-right"?this.config.marginSide:void 0,m=this.config.placement==="bottom-left"?this.config.marginSide:void 0;Object.assign(this.window.style,{width:`${r}px`,height:`${l}px`,right:c?`${c}px`:"auto",left:m?`${m}px`:"auto",bottom:`${this.config.marginBottom}px`,borderRadius:this.windowState==="maximized"?"0":"12px"})}};let e;window.addEventListener("resize",()=>{clearTimeout(e),e=window.setTimeout(t,100)}),t()}destroy(){var e;const t=(e=this.bubble)==null?void 0:e.parentElement;t&&document.body.contains(t)&&(document.body.removeChild(t),this.bubble=null),this.window&&document.body.contains(this.window)&&(document.body.removeChild(this.window),this.window=null),window.removeEventListener("resize",this.setupResizeListener.bind(this)),this.loopTimer&&(window.clearTimeout(this.loopTimer),this.loopTimer=null),this.inviteDialog&&document.body.contains(this.inviteDialog)&&(document.body.removeChild(this.inviteDialog),this.inviteDialog=null)}createInviteDialog(){var s,d;if(!((s=this.config.inviteParams)!=null&&s.show))return;if(this.inviteDialog=document.createElement("div"),this.inviteDialog.style.cssText=` + `,this.window.appendChild(a)}document.body.appendChild(this.window)}generateChatUrl(t=!1,e="messages"){console.log("this.config: ",this.config,e);const i=new URLSearchParams;return Object.entries(this.config.chatParams||{}).forEach(([o,s])=>{i.append(o,String(s))}),Object.entries(this.config.browseParams||{}).forEach(([o,s])=>{i.append(o,String(s))}),Object.entries(this.config.theme||{}).forEach(([o,s])=>{i.append(o,String(s))}),i.append("lang",this.config.locale||"zh-cn"),t&&i.append("preload","1"),`${this.config.baseUrl}?${i.toString()}`}setupMessageListener(){window.addEventListener("message",t=>{switch(t.data.type){case"CLOSE_CHAT_WINDOW":this.hideChat();break;case"MAXIMIZE_WINDOW":this.toggleMaximize();break;case"MINIMIZE_WINDOW":this.minimizeWindow();break;case"RECEIVE_MESSAGE":console.log("RECEIVE_MESSAGE");break;case"INVITE_VISITOR":console.log("INVITE_VISITOR");break;case"INVITE_VISITOR_ACCEPT":console.log("INVITE_VISITOR_ACCEPT");break;case"INVITE_VISITOR_REJECT":console.log("INVITE_VISITOR_REJECT");break}})}preload(){console.log("preload");const t=this.generateChatUrl(!0);console.log("preLoadUrl: ",t);const e=document.createElement("iframe");e.src=t,e.style.display="none",document.body.appendChild(e)}showChat(){if(this.window||this.createChatWindow(),this.window){const t=window.innerWidth<=768;if(this.window.style.display="block",this.setupResizeListener(),t&&this.window&&(this.window.style.transform="translateY(100%)",requestAnimationFrame(()=>{this.window&&(this.window.style.transform="translateY(0)")})),this.isVisible=!0,this.bubble){this.bubble.style.display="none";const e=this.bubble.messageElement;e instanceof HTMLElement&&(e.style.display="none")}}this.hideInviteDialog()}hideChat(){var t;if(this.window&&(window.innerWidth<=768?(this.window.style.transform="translateY(100%)",setTimeout(()=>{this.window&&(this.window.style.display="none")},((t=this.config.animation)==null?void 0:t.duration)||300)):this.window.style.display="none",this.isVisible=!1,this.bubble)){this.bubble.style.display="inline-flex";const i=this.bubble.messageElement;i instanceof HTMLElement&&(i.style.display="block")}}minimizeWindow(){this.window&&(this.windowState="minimized",this.window.style.display="none")}toggleMaximize(){this.window&&window.open(this.generateChatUrl(),"_blank")}setupResizeListener(){const t=()=>{var d,n;if(!this.window||!this.isVisible)return;const i=window.innerWidth<=768,o=window.innerWidth,s=window.innerHeight;if(i)Object.assign(this.window.style,{left:"0",bottom:"0",width:"100%",height:"90vh",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0",borderBottomRightRadius:"0"});else{let r=this.windowState==="maximized"?o:Math.min(((d=this.config.window)==null?void 0:d.width)||o*.9,o*.9),l=this.windowState==="maximized"?s:Math.min(((n=this.config.window)==null?void 0:n.height)||s*.9,s*.9);const c=this.config.placement==="bottom-right"?this.config.marginSide:void 0,p=this.config.placement==="bottom-left"?this.config.marginSide:void 0;Object.assign(this.window.style,{width:`${r}px`,height:`${l}px`,right:c?`${c}px`:"auto",left:p?`${p}px`:"auto",bottom:`${this.config.marginBottom}px`,borderRadius:this.windowState==="maximized"?"0":"12px"})}};let e;window.addEventListener("resize",()=>{clearTimeout(e),e=window.setTimeout(t,100)}),t()}destroy(){var e;const t=(e=this.bubble)==null?void 0:e.parentElement;t&&document.body.contains(t)&&(document.body.removeChild(t),this.bubble=null),this.window&&document.body.contains(this.window)&&(document.body.removeChild(this.window),this.window=null),window.removeEventListener("resize",this.setupResizeListener.bind(this)),this.loopTimer&&(window.clearTimeout(this.loopTimer),this.loopTimer=null),this.inviteDialog&&document.body.contains(this.inviteDialog)&&(document.body.removeChild(this.inviteDialog),this.inviteDialog=null)}createInviteDialog(){var s,d;if(!((s=this.config.inviteParams)!=null&&s.show))return;if(this.inviteDialog=document.createElement("div"),this.inviteDialog.style.cssText=` position: fixed; top: 50%; left: 50%; @@ -147,4 +147,4 @@ border: none; border-radius: 4px; cursor: pointer; - `,o.onclick=()=>{var n,r;this.hideInviteDialog(),(r=(n=this.config.inviteParams)==null?void 0:n.onReject)==null||r.call(n),this.handleInviteLoop()},e.appendChild(i),e.appendChild(o),this.inviteDialog.appendChild(e),document.body.appendChild(this.inviteDialog)}handleInviteLoop(){const{loop:t,loopDelay:e=3e3,loopCount:i=1/0}=this.config.inviteParams||{};!t||this.loopCount>=i-1||(this.loopTimer&&window.clearTimeout(this.loopTimer),this.loopTimer=window.setTimeout(()=>{this.loopCount++,this.showInviteDialog()},e))}showInviteDialog(){var t,e;this.inviteDialog&&(this.inviteDialog.style.display="block",(e=(t=this.config.inviteParams)==null?void 0:t.onOpen)==null||e.call(t))}hideInviteDialog(){var t,e;this.inviteDialog&&(this.inviteDialog.style.display="none",(e=(t=this.config.inviteParams)==null?void 0:t.onClose)==null||e.call(t))}}return p}); + `,o.onclick=()=>{var n,r;this.hideInviteDialog(),(r=(n=this.config.inviteParams)==null?void 0:n.onReject)==null||r.call(n),this.handleInviteLoop()},e.appendChild(i),e.appendChild(o),this.inviteDialog.appendChild(e),document.body.appendChild(this.inviteDialog)}handleInviteLoop(){const{loop:t,loopDelay:e=3e3,loopCount:i=1/0}=this.config.inviteParams||{};!t||this.loopCount>=i-1||(this.loopTimer&&window.clearTimeout(this.loopTimer),this.loopTimer=window.setTimeout(()=>{this.loopCount++,this.showInviteDialog()},e))}showInviteDialog(){var t,e;this.inviteDialog&&(this.inviteDialog.style.display="block",(e=(t=this.config.inviteParams)==null?void 0:t.onOpen)==null||e.call(t))}hideInviteDialog(){var t,e;this.inviteDialog&&(this.inviteDialog.style.display="none",(e=(t=this.config.inviteParams)==null?void 0:t.onClose)==null||e.call(t))}}return g}); diff --git a/starter/src/main/resources/static/embed/core/BytedeskWeb/index.js b/starter/src/main/resources/static/embed/core/BytedeskWeb/index.js index 49aed81768..a57750714a 100644 --- a/starter/src/main/resources/static/embed/core/BytedeskWeb/index.js +++ b/starter/src/main/resources/static/embed/core/BytedeskWeb/index.js @@ -1,17 +1,17 @@ var y = Object.defineProperty; -var v = (p, t, e) => t in p ? y(p, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : p[t] = e; -var g = (p, t, e) => v(p, typeof t != "symbol" ? t + "" : t, e); +var v = (m, t, e) => t in m ? y(m, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : m[t] = e; +var p = (m, t, e) => v(m, typeof t != "symbol" ? t + "" : t, e); class E { constructor(t) { - g(this, "config"); - g(this, "bubble", null); - g(this, "window", null); - g(this, "inviteDialog", null); - g(this, "isVisible", !1); - g(this, "isDragging", !1); - g(this, "windowState", "normal"); - g(this, "loopCount", 0); - g(this, "loopTimer", null); + p(this, "config"); + p(this, "bubble", null); + p(this, "window", null); + p(this, "inviteDialog", null); + p(this, "isVisible", !1); + p(this, "isDragging", !1); + p(this, "windowState", "normal"); + p(this, "loopCount", 0); + p(this, "loopTimer", null); this.config = { ...this.getDefaultConfig(), ...t @@ -69,7 +69,7 @@ class E { }, this.config.inviteParams.delay || 3e3); } createBubble() { - var o, s, d, n, r; + var o, s, r, n, d; const t = document.createElement("div"); t.style.cssText = ` position: fixed; @@ -103,8 +103,8 @@ class E { `; const h = document.createElement("span"); h.textContent = ((s = this.config.bubbleConfig) == null ? void 0 : s.icon) || "", h.style.fontSize = "20px", l.appendChild(h); - const c = document.createElement("div"), m = document.createElement("div"); - m.textContent = ((d = this.config.bubbleConfig) == null ? void 0 : d.title) || "", m.style.fontWeight = "bold", m.style.marginBottom = "4px", c.appendChild(m); + const c = document.createElement("div"), g = document.createElement("div"); + g.textContent = ((r = this.config.bubbleConfig) == null ? void 0 : r.title) || "", g.style.fontWeight = "bold", g.style.marginBottom = "4px", c.appendChild(g); const a = document.createElement("div"); a.textContent = ((n = this.config.bubbleConfig) == null ? void 0 : n.subtitle) || "", a.style.fontSize = "0.9em", a.style.opacity = "0.8", c.appendChild(a), l.appendChild(c), e.appendChild(l); const f = document.createElement("div"); @@ -131,7 +131,7 @@ class E { }, 500); } this.bubble = document.createElement("button"), this.bubble.style.cssText = ` - background-color: ${(r = this.config.theme) == null ? void 0 : r.backgroundColor}; + background-color: ${(d = this.config.theme) == null ? void 0 : d.backgroundColor}; width: 60px; height: 60px; border-radius: 30px; @@ -161,13 +161,13 @@ class E { }), this.bubble.addEventListener("mouseleave", () => { this.bubble.style.transform = "scale(1)"; }), t.appendChild(this.bubble), this.config.draggable) { - let l = 0, h = 0, c = 0, m = 0; + let l = 0, h = 0, c = 0, g = 0; this.bubble.addEventListener("mousedown", (a) => { - a.button === 0 && (this.isDragging = !0, l = a.clientX, h = a.clientY, c = t.offsetLeft, m = t.offsetTop, t.style.transition = "none"); + a.button === 0 && (this.isDragging = !0, l = a.clientX, h = a.clientY, c = t.offsetLeft, g = t.offsetTop, t.style.transition = "none"); }), document.addEventListener("mousemove", (a) => { if (!this.isDragging) return; a.preventDefault(); - const f = a.clientX - l, b = a.clientY - h, u = c + f, w = m + b, x = window.innerHeight - t.offsetHeight; + const f = a.clientX - l, b = a.clientY - h, u = c + f, w = g + b, x = window.innerHeight - t.offsetHeight; u <= window.innerWidth / 2 ? (t.style.left = `${Math.max(0, u)}px`, t.style.right = "auto", this.config.placement = "bottom-left") : (t.style.right = `${Math.max(0, window.innerWidth - u - t.offsetWidth)}px`, t.style.left = "auto", this.config.placement = "bottom-right"), t.style.bottom = `${Math.min(Math.max(0, window.innerHeight - w - t.offsetHeight), x)}px`; }), document.addEventListener("mouseup", () => { this.isDragging && (this.isDragging = !1, t.style.transition = "all 0.3s ease", this.config.marginSide = parseInt( @@ -193,9 +193,9 @@ class E { return e[t] || e["zh-cn"]; } createChatWindow() { - var n, r, l, h, c, m; + var n, d, l, h, c, g; this.window = document.createElement("div"); - const t = window.innerWidth <= 768, e = window.innerWidth, i = window.innerHeight, o = Math.min(((n = this.config.window) == null ? void 0 : n.width) || e * 0.9, e * 0.9), s = Math.min(((r = this.config.window) == null ? void 0 : r.height) || i * 0.9, i * 0.9); + const t = window.innerWidth <= 768, e = window.innerWidth, i = window.innerHeight, o = Math.min(((n = this.config.window) == null ? void 0 : n.width) || e * 0.9, e * 0.9), s = Math.min(((d = this.config.window) == null ? void 0 : d.height) || i * 0.9, i * 0.9); t ? this.window.style.cssText = ` position: fixed; left: 0; @@ -219,14 +219,14 @@ class E { display: none; overflow: hidden; z-index: 10000; - transition: all ${(c = this.config.animation) == null ? void 0 : c.duration}ms ${(m = this.config.animation) == null ? void 0 : m.type}; + transition: all ${(c = this.config.animation) == null ? void 0 : c.duration}ms ${(g = this.config.animation) == null ? void 0 : g.type}; `; - const d = document.createElement("iframe"); - if (d.style.cssText = ` + const r = document.createElement("iframe"); + if (r.style.cssText = ` width: 100%; height: ${this.config.showSupport ? "calc(100% - 30px)" : "100%"}; border: none; - `, d.src = this.generateChatUrl(), console.log("iframe.src: ", d.src), this.window.appendChild(d), this.config.showSupport) { + `, r.src = this.generateChatUrl(), console.log("iframe.src: ", r.src), this.window.appendChild(r), this.config.showSupport) { const a = document.createElement("div"); a.style.cssText = ` height: 20px; @@ -324,11 +324,11 @@ class E { this.window && (this.windowState = "minimized", this.window.style.display = "none"); } toggleMaximize() { - !this.window || window.innerWidth <= 768 || (this.windowState = this.windowState === "maximized" ? "normal" : "maximized", this.setupResizeListener()); + this.window && window.open(this.generateChatUrl(), "_blank"); } setupResizeListener() { const t = () => { - var d, n; + var r, n; if (!this.window || !this.isVisible) return; const i = window.innerWidth <= 768, o = window.innerWidth, s = window.innerHeight; if (i) @@ -343,10 +343,10 @@ class E { borderBottomRightRadius: "0" }); else { - let r = this.windowState === "maximized" ? o : Math.min(((d = this.config.window) == null ? void 0 : d.width) || o * 0.9, o * 0.9), l = this.windowState === "maximized" ? s : Math.min(((n = this.config.window) == null ? void 0 : n.height) || s * 0.9, s * 0.9); + let d = this.windowState === "maximized" ? o : Math.min(((r = this.config.window) == null ? void 0 : r.width) || o * 0.9, o * 0.9), l = this.windowState === "maximized" ? s : Math.min(((n = this.config.window) == null ? void 0 : n.height) || s * 0.9, s * 0.9); const h = this.config.placement === "bottom-right" ? this.config.marginSide : void 0, c = this.config.placement === "bottom-left" ? this.config.marginSide : void 0; Object.assign(this.window.style, { - width: `${r}px`, + width: `${d}px`, height: `${l}px`, right: h ? `${h}px` : "auto", left: c ? `${c}px` : "auto", @@ -366,7 +366,7 @@ class E { t && document.body.contains(t) && (document.body.removeChild(t), this.bubble = null), this.window && document.body.contains(this.window) && (document.body.removeChild(this.window), this.window = null), window.removeEventListener("resize", this.setupResizeListener.bind(this)), this.loopTimer && (window.clearTimeout(this.loopTimer), this.loopTimer = null), this.inviteDialog && document.body.contains(this.inviteDialog) && (document.body.removeChild(this.inviteDialog), this.inviteDialog = null); } createInviteDialog() { - var s, d; + var s, r; if (!((s = this.config.inviteParams) != null && s.show)) return; if (this.inviteDialog = document.createElement("div"), this.inviteDialog.style.cssText = ` position: fixed; @@ -402,14 +402,14 @@ class E { const i = document.createElement("button"); i.textContent = "开始对话", i.style.cssText = ` padding: 8px 16px; - background: ${((d = this.config.theme) == null ? void 0 : d.backgroundColor) || "#0066FF"}; + background: ${((r = this.config.theme) == null ? void 0 : r.backgroundColor) || "#0066FF"}; color: white; border: none; border-radius: 4px; cursor: pointer; `, i.onclick = () => { - var n, r; - this.hideInviteDialog(), this.showChat(), (r = (n = this.config.inviteParams) == null ? void 0 : n.onAccept) == null || r.call(n); + var n, d; + this.hideInviteDialog(), this.showChat(), (d = (n = this.config.inviteParams) == null ? void 0 : n.onAccept) == null || d.call(n); }; const o = document.createElement("button"); o.textContent = "稍后再说", o.style.cssText = ` @@ -420,8 +420,8 @@ class E { border-radius: 4px; cursor: pointer; `, o.onclick = () => { - var n, r; - this.hideInviteDialog(), (r = (n = this.config.inviteParams) == null ? void 0 : n.onReject) == null || r.call(n), this.handleInviteLoop(); + var n, d; + this.hideInviteDialog(), (d = (n = this.config.inviteParams) == null ? void 0 : n.onReject) == null || d.call(n), this.handleInviteLoop(); }, e.appendChild(i), e.appendChild(o), this.inviteDialog.appendChild(e), document.body.appendChild(this.inviteDialog); } handleInviteLoop() {