diff --git a/modules/kbase/src/main/java/com/bytedesk/kbase/service_settings/InviteSettings.java b/modules/kbase/src/main/java/com/bytedesk/kbase/service_settings/InviteSettings.java index bcf310801f..8c46a268a6 100644 --- a/modules/kbase/src/main/java/com/bytedesk/kbase/service_settings/InviteSettings.java +++ b/modules/kbase/src/main/java/com/bytedesk/kbase/service_settings/InviteSettings.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2025-01-10 14:59:33 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-01-10 16:06:10 + * @LastEditTime: 2025-01-10 21:35:26 * @Description: bytedesk.com https://github.com/Bytedesk/bytedesk * Please be aware of the BSL license restrictions before installing Bytedesk IM – * selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license. @@ -13,6 +13,8 @@ */ package com.bytedesk.kbase.service_settings; +import java.io.Serializable; + import jakarta.persistence.Column; import jakarta.persistence.Embeddable; import lombok.AllArgsConstructor; @@ -27,7 +29,9 @@ import lombok.experimental.Accessors; @Accessors(chain = true) @AllArgsConstructor @NoArgsConstructor -public class InviteSettings { +public class InviteSettings implements Serializable { + + private static final long serialVersionUID = 1L; /** * 是否显示邀请 diff --git a/starter/src/main/java/com/bytedesk/starter/controller/PageTemplateController.java b/starter/src/main/java/com/bytedesk/starter/controller/PageTemplateController.java index 384479ca86..d25fd737b8 100644 --- a/starter/src/main/java/com/bytedesk/starter/controller/PageTemplateController.java +++ b/starter/src/main/java/com/bytedesk/starter/controller/PageTemplateController.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2024-03-13 12:09:02 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2024-11-26 09:07:44 + * @LastEditTime: 2025-01-10 21:48:59 * @Description: bytedesk.com https://github.com/Bytedesk/bytedesk * Please be aware of the BSL license restrictions before installing Bytedesk IM – * selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license. @@ -34,7 +34,6 @@ import lombok.AllArgsConstructor; @RequestMapping("/temp") public class PageTemplateController { - // private PageTemplateService pageService; /** diff --git a/starter/src/main/resources/static/embed/adapters/index.d.ts b/starter/src/main/resources/static/embed/adapters/index.d.ts deleted file mode 100644 index dd40b2e926..0000000000 --- a/starter/src/main/resources/static/embed/adapters/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { BytedeskReact } from './react'; -export { BytedeskVue } from './vue'; -export { BytedeskSvelte } from './svelte'; diff --git a/starter/src/main/resources/static/embed/adapters/react.d.ts b/starter/src/main/resources/static/embed/adapters/react.d.ts deleted file mode 100644 index a262c89eb6..0000000000 --- a/starter/src/main/resources/static/embed/adapters/react.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { BytedeskConfig } from '../types'; -interface BytedeskReactProps extends BytedeskConfig { - onInit?: () => void; - locale?: string; -} -export declare const BytedeskReact: React.FC; -export {}; diff --git a/starter/src/main/resources/static/embed/adapters/svelte.d.ts b/starter/src/main/resources/static/embed/adapters/svelte.d.ts deleted file mode 100644 index 85e60a7aca..0000000000 --- a/starter/src/main/resources/static/embed/adapters/svelte.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BytedeskConfig } from '../types'; -export declare const BytedeskSvelte: (node: HTMLElement, config: BytedeskConfig & { - locale?: string; -}) => { - destroy(): void; -}; diff --git a/starter/src/main/resources/static/embed/adapters/vue.d.ts b/starter/src/main/resources/static/embed/adapters/vue.d.ts deleted file mode 100644 index be25979c85..0000000000 --- a/starter/src/main/resources/static/embed/adapters/vue.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -export declare const BytedeskVue: import('vue').DefineComponent, () => import('vue').VNode, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly> & Readonly<{}>, { - locale: string; -}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>; diff --git a/starter/src/main/resources/static/embed/bytedesk-web.js b/starter/src/main/resources/static/embed/bytedesk-web.js index f12f538f67..c0fc955187 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,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.inviteSettings)!=null&&t.show&&setTimeout(()=>{this.showInviteDialog()},this.config.inviteSettings.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{isDebug:!1,isPreload:!1,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 n,s,h,o,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; @@ -7,7 +7,7 @@ var BytedeskWeb=function(){"use strict";var v=Object.defineProperty;var C=(f,m,t align-items: ${this.config.placement==="bottom-left"?"flex-start":"flex-end"}; gap: 10px; z-index: 9999; - `;let e=null;if((o=this.config.bubbleConfig)!=null&&o.show){e=document.createElement("div"),e.style.cssText=` + `;let e=null;if((n=this.config.bubbleConfig)!=null&&n.show){e=document.createElement("div"),e.style.cssText=` background: white; padding: 12px 16px; border-radius: 8px; @@ -22,7 +22,7 @@ var BytedeskWeb=function(){"use strict";var v=Object.defineProperty;var C=(f,m,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"),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=` + `;const d=document.createElement("span");d.textContent=((s=this.config.bubbleConfig)==null?void 0:s.icon)||"",d.style.fontSize="20px",l.appendChild(d);const c=document.createElement("div"),g=document.createElement("div");g.textContent=((h=this.config.bubbleConfig)==null?void 0:h.title)||"",g.style.fontWeight="bold",g.style.marginBottom="4px",c.appendChild(g);const a=document.createElement("div");a.textContent=((o=this.config.bubbleConfig)==null?void 0:o.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"}; @@ -39,7 +39,7 @@ var BytedeskWeb=function(){"use strict";var v=Object.defineProperty;var C=(f,m,t height: 12px; background: white; `,e.appendChild(b),e.appendChild(u),t.appendChild(e),setTimeout(()=>{e&&(e.style.opacity="1",e.style.transform="translateY(0)")},500)}this.bubble=document.createElement("button"),this.bubble.style.cssText=` - background-color: ${(d=this.config.theme)==null?void 0:d.backgroundColor}; + background-color: ${(r=this.config.theme)==null?void 0:r.backgroundColor}; width: 60px; height: 60px; border-radius: 30px; @@ -62,7 +62,7 @@ var BytedeskWeb=function(){"use strict";var v=Object.defineProperty;var C=(f,m,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,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=` + `,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,d=0,c=0,g=0;this.bubble.addEventListener("mousedown",a=>{a.button===0&&(this.isDragging=!0,l=a.clientX,d=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-d,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 o,r,l,d,c,g;this.window=document.createElement("div");const t=window.innerWidth<=768,e=window.innerWidth,i=window.innerHeight,n=Math.min(((o=this.config.window)==null?void 0:o.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; @@ -73,12 +73,12 @@ var BytedeskWeb=function(){"use strict";var v=Object.defineProperty;var C=(f,m,t border-top-left-radius: 12px; border-top-right-radius: 12px; overflow: hidden; - transition: all ${(l=this.config.animation)==null?void 0:l.duration}ms ${(h=this.config.animation)==null?void 0:h.type}; + transition: all ${(l=this.config.animation)==null?void 0:l.duration}ms ${(d=this.config.animation)==null?void 0:d.type}; `:this.window.style.cssText=` position: fixed; ${this.config.placement==="bottom-right"?"right":"left"}: ${this.config.marginSide}px; bottom: ${this.config.marginBottom}px; - width: ${o}px; + width: ${n}px; height: ${s}px; border-radius: 12px; box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15); @@ -86,11 +86,11 @@ var BytedeskWeb=function(){"use strict";var v=Object.defineProperty;var C=(f,m,t overflow: hidden; z-index: 10000; 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=` + `;const h=document.createElement("iframe");if(h.style.cssText=` width: 100%; height: ${this.config.showSupport?"calc(100% - 30px)":"100%"}; border: none; - `,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=` + `,h.src=this.generateChatUrl(),console.log("iframe.src: ",h.src),this.window.appendChild(h),this.config.showSupport){const a=document.createElement("div");a.style.cssText=` height: 20px; display: flex; align-items: center; @@ -110,7 +110,7 @@ var BytedeskWeb=function(){"use strict";var v=Object.defineProperty;var C=(f,m,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.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.inviteSettings)!=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(([n,s])=>{i.append(n,String(s))}),Object.entries(this.config.browseParams||{}).forEach(([n,s])=>{i.append(n,String(s))}),Object.entries(this.config.theme||{}).forEach(([n,s])=>{i.append(n,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(){if(console.log("preload"),this.config.isPreload){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(){var t,e;if(this.window||this.createChatWindow(),this.window){const i=window.innerWidth<=768;if(this.window.style.display="block",this.setupResizeListener(),i&&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 n=this.bubble.messageElement;n instanceof HTMLElement&&(n.style.display="none")}}this.hideInviteDialog(),(e=(t=this.config).onShowChat)==null||e.call(t)}hideChat(){var t,e,i;if(this.window){if(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 s=this.bubble.messageElement;s instanceof HTMLElement&&(s.style.display="block")}(i=(e=this.config).onHideChat)==null||i.call(e)}}minimizeWindow(){this.window&&(this.windowState="minimized",this.window.style.display="none",this.hideChat())}toggleMaximize(){this.window&&window.open(this.generateChatUrl(),"_blank")}setupResizeListener(){const t=()=>{var h,o;if(!this.window||!this.isVisible)return;const i=window.innerWidth<=768,n=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"?n:Math.min(((h=this.config.window)==null?void 0:h.width)||n*.9,n*.9),l=this.windowState==="maximized"?s:Math.min(((o=this.config.window)==null?void 0:o.height)||s*.9,s*.9);const d=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`,height:`${l}px`,right:d?`${d}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,h;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%; @@ -123,28 +123,28 @@ var BytedeskWeb=function(){"use strict";var v=Object.defineProperty;var C=(f,m,t display: none; max-width: 300px; text-align: center; - `,this.config.inviteSettings.icon){const n=document.createElement("div");n.style.cssText=` + `,this.config.inviteParams.icon){const o=document.createElement("div");o.style.cssText=` font-size: 32px; margin-bottom: 12px; - `,n.textContent=this.config.inviteSettings.icon,this.inviteDialog.appendChild(n)}const t=document.createElement("div");t.style.cssText=` + `,o.textContent=this.config.inviteParams.icon,this.inviteDialog.appendChild(o)}const t=document.createElement("div");t.style.cssText=` margin-bottom: 16px; color: #333; - `,t.textContent=this.config.inviteSettings.text||"需要帮助吗?点击开始对话",this.inviteDialog.appendChild(t);const e=document.createElement("div");e.style.cssText=` + `,t.textContent=this.config.inviteParams.text||"需要帮助吗?点击开始对话",this.inviteDialog.appendChild(t);const e=document.createElement("div");e.style.cssText=` display: flex; gap: 10px; justify-content: center; `;const i=document.createElement("button");i.textContent="开始对话",i.style.cssText=` padding: 8px 16px; - background: ${((r=this.config.theme)==null?void 0:r.backgroundColor)||"#0066FF"}; + background: ${((h=this.config.theme)==null?void 0:h.backgroundColor)||"#0066FF"}; color: white; border: none; border-radius: 4px; cursor: pointer; - `,i.onclick=()=>{var n,d;this.hideInviteDialog(),this.showChat(),(d=(n=this.config.inviteSettings)==null?void 0:n.onAccept)==null||d.call(n)};const o=document.createElement("button");o.textContent="稍后再说",o.style.cssText=` + `,i.onclick=()=>{var o,r;this.hideInviteDialog(),this.showChat(),(r=(o=this.config.inviteParams)==null?void 0:o.onAccept)==null||r.call(o)};const n=document.createElement("button");n.textContent="稍后再说",n.style.cssText=` padding: 8px 16px; background: #f5f5f5; color: #666; border: none; border-radius: 4px; cursor: pointer; - `,o.onclick=()=>{var n,d;this.hideInviteDialog(),(d=(n=this.config.inviteSettings)==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(){const{loop:t,loopDelay:e=3e3,loopCount:i=1/0}=this.config.inviteSettings||{};!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.inviteSettings)==null?void 0:t.onOpen)==null||e.call(t))}hideInviteDialog(){var t,e;this.inviteDialog&&(this.inviteDialog.style.display="none",(e=(t=this.config.inviteSettings)==null?void 0:t.onClose)==null||e.call(t))}}return f}(); + `,n.onclick=()=>{var o,r;this.hideInviteDialog(),(r=(o=this.config.inviteParams)==null?void 0:o.onReject)==null||r.call(o),this.handleInviteLoop()},e.appendChild(i),e.appendChild(n),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 f}(); 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 18b60501cd..bb2ee61a7a 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(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.inviteSettings)!=null&&t.show&&setTimeout(()=>{this.showInviteDialog()},this.config.inviteSettings.delay||3e3)}createBubble(){var o,s,d,n,r;const t=document.createElement("div");t.style.cssText=` +(function(p,r){typeof exports=="object"&&typeof module<"u"?module.exports=r():typeof define=="function"&&define.amd?define(r):(p=typeof globalThis<"u"?globalThis:p||self,p.BytedeskWeb=r())})(this,function(){"use strict";var v=Object.defineProperty;var C=(p,r,t)=>r in p?v(p,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[r]=t;var f=(p,r,t)=>C(p,typeof r!="symbol"?r+"":r,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{isDebug:!1,isPreload:!1,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 n,s,d,o,h;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; @@ -7,7 +7,7 @@ align-items: ${this.config.placement==="bottom-left"?"flex-start":"flex-end"}; gap: 10px; z-index: 9999; - `;let e=null;if((o=this.config.bubbleConfig)!=null&&o.show){e=document.createElement("div"),e.style.cssText=` + `;let e=null;if((n=this.config.bubbleConfig)!=null&&n.show){e=document.createElement("div"),e.style.cssText=` background: white; padding: 12px 16px; border-radius: 8px; @@ -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 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=` + `;const c=document.createElement("span");c.textContent=((s=this.config.bubbleConfig)==null?void 0:s.icon)||"",c.style.fontSize="20px",l.appendChild(c);const g=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",g.appendChild(m);const a=document.createElement("div");a.textContent=((o=this.config.bubbleConfig)==null?void 0:o.subtitle)||"",a.style.fontSize="0.9em",a.style.opacity="0.8",g.appendChild(a),l.appendChild(g),e.appendChild(l);const b=document.createElement("div");b.style.cssText=` position: absolute; bottom: -6px; ${this.config.placement==="bottom-left"?"left: 24px":"right: 24px"}; @@ -39,7 +39,7 @@ height: 12px; background: white; `,e.appendChild(b),e.appendChild(u),t.appendChild(e),setTimeout(()=>{e&&(e.style.opacity="1",e.style.transform="translateY(0)")},500)}this.bubble=document.createElement("button"),this.bubble.style.cssText=` - background-color: ${(r=this.config.theme)==null?void 0:r.backgroundColor}; + background-color: ${(h=this.config.theme)==null?void 0:h.backgroundColor}; width: 60px; height: 60px; border-radius: 30px; @@ -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,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=` + `,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,g=0,m=0;this.bubble.addEventListener("mousedown",a=>{a.button===0&&(this.isDragging=!0,l=a.clientX,c=a.clientY,g=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=g+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 o,h,l,c,g,m;this.window=document.createElement("div");const t=window.innerWidth<=768,e=window.innerWidth,i=window.innerHeight,n=Math.min(((o=this.config.window)==null?void 0:o.width)||e*.9,e*.9),s=Math.min(((h=this.config.window)==null?void 0:h.height)||i*.9,i*.9);t?this.window.style.cssText=` position: fixed; left: 0; bottom: 0; @@ -78,14 +78,14 @@ position: fixed; ${this.config.placement==="bottom-right"?"right":"left"}: ${this.config.marginSide}px; bottom: ${this.config.marginBottom}px; - width: ${o}px; + width: ${n}px; height: ${s}px; border-radius: 12px; box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15); display: none; overflow: hidden; z-index: 10000; - transition: all ${(p=this.config.animation)==null?void 0:p.duration}ms ${(m=this.config.animation)==null?void 0:m.type}; + transition: all ${(g=this.config.animation)==null?void 0:g.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.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.inviteSettings)!=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(([n,s])=>{i.append(n,String(s))}),Object.entries(this.config.browseParams||{}).forEach(([n,s])=>{i.append(n,String(s))}),Object.entries(this.config.theme||{}).forEach(([n,s])=>{i.append(n,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(){if(console.log("preload"),this.config.isPreload){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(){var t,e;if(this.window||this.createChatWindow(),this.window){const i=window.innerWidth<=768;if(this.window.style.display="block",this.setupResizeListener(),i&&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 n=this.bubble.messageElement;n instanceof HTMLElement&&(n.style.display="none")}}this.hideInviteDialog(),(e=(t=this.config).onShowChat)==null||e.call(t)}hideChat(){var t,e,i;if(this.window){if(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 s=this.bubble.messageElement;s instanceof HTMLElement&&(s.style.display="block")}(i=(e=this.config).onHideChat)==null||i.call(e)}}minimizeWindow(){this.window&&(this.windowState="minimized",this.window.style.display="none",this.hideChat())}toggleMaximize(){this.window&&window.open(this.generateChatUrl(),"_blank")}setupResizeListener(){const t=()=>{var d,o;if(!this.window||!this.isVisible)return;const i=window.innerWidth<=768,n=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 h=this.windowState==="maximized"?n:Math.min(((d=this.config.window)==null?void 0:d.width)||n*.9,n*.9),l=this.windowState==="maximized"?s:Math.min(((o=this.config.window)==null?void 0:o.height)||s*.9,s*.9);const c=this.config.placement==="bottom-right"?this.config.marginSide:void 0,g=this.config.placement==="bottom-left"?this.config.marginSide:void 0;Object.assign(this.window.style,{width:`${h}px`,height:`${l}px`,right:c?`${c}px`:"auto",left:g?`${g}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%; @@ -123,13 +123,13 @@ display: none; max-width: 300px; text-align: center; - `,this.config.inviteSettings.icon){const n=document.createElement("div");n.style.cssText=` + `,this.config.inviteParams.icon){const o=document.createElement("div");o.style.cssText=` font-size: 32px; margin-bottom: 12px; - `,n.textContent=this.config.inviteSettings.icon,this.inviteDialog.appendChild(n)}const t=document.createElement("div");t.style.cssText=` + `,o.textContent=this.config.inviteParams.icon,this.inviteDialog.appendChild(o)}const t=document.createElement("div");t.style.cssText=` margin-bottom: 16px; color: #333; - `,t.textContent=this.config.inviteSettings.text||"需要帮助吗?点击开始对话",this.inviteDialog.appendChild(t);const e=document.createElement("div");e.style.cssText=` + `,t.textContent=this.config.inviteParams.text||"需要帮助吗?点击开始对话",this.inviteDialog.appendChild(t);const e=document.createElement("div");e.style.cssText=` display: flex; gap: 10px; justify-content: center; @@ -140,11 +140,11 @@ border: none; border-radius: 4px; cursor: pointer; - `,i.onclick=()=>{var n,r;this.hideInviteDialog(),this.showChat(),(r=(n=this.config.inviteSettings)==null?void 0:n.onAccept)==null||r.call(n)};const o=document.createElement("button");o.textContent="稍后再说",o.style.cssText=` + `,i.onclick=()=>{var o,h;this.hideInviteDialog(),this.showChat(),(h=(o=this.config.inviteParams)==null?void 0:o.onAccept)==null||h.call(o)};const n=document.createElement("button");n.textContent="稍后再说",n.style.cssText=` padding: 8px 16px; background: #f5f5f5; color: #666; border: none; border-radius: 4px; cursor: pointer; - `,o.onclick=()=>{var n,r;this.hideInviteDialog(),(r=(n=this.config.inviteSettings)==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.inviteSettings||{};!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.inviteSettings)==null?void 0:t.onOpen)==null||e.call(t))}hideInviteDialog(){var t,e;this.inviteDialog&&(this.inviteDialog.style.display="none",(e=(t=this.config.inviteSettings)==null?void 0:t.onClose)==null||e.call(t))}}return g}); + `,n.onclick=()=>{var o,h;this.hideInviteDialog(),(h=(o=this.config.inviteParams)==null?void 0:o.onReject)==null||h.call(o),this.handleInviteLoop()},e.appendChild(i),e.appendChild(n),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}); diff --git a/starter/src/main/resources/static/embed/core/BytedeskWeb.d.ts b/starter/src/main/resources/static/embed/core/BytedeskWeb.d.ts deleted file mode 100644 index 668beca8c6..0000000000 --- a/starter/src/main/resources/static/embed/core/BytedeskWeb.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { BytedeskConfig } from '../types'; -export default class BytedeskWeb { - private config; - private bubble; - private window; - private isVisible; - private isDragging; - private windowState; - constructor(config: BytedeskConfig); - private getDefaultConfig; - init(): void; - private createBubble; - private createChatWindow; - private generateChatUrl; - private setupMessageListener; - showChat(): void; - hideChat(): void; - private minimizeWindow; - private toggleMaximize; - private setupResizeListener; - destroy(): void; -} 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 166de3eec3..bdde045098 100644 --- a/starter/src/main/resources/static/embed/core/BytedeskWeb/index.js +++ b/starter/src/main/resources/static/embed/core/BytedeskWeb/index.js @@ -19,6 +19,8 @@ class E { } getDefaultConfig() { return { + isDebug: !1, + isPreload: !1, baseUrl: "https://www.weiyuai.cn/chat", placement: "bottom-right", marginBottom: 20, @@ -64,12 +66,12 @@ class E { 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.inviteSettings) != null && t.show && setTimeout(() => { + }, this.config.autoPopupDelay || 1e3), (t = this.config.inviteParams) != null && t.show && setTimeout(() => { this.showInviteDialog(); - }, this.config.inviteSettings.delay || 3e3); + }, this.config.inviteParams.delay || 3e3); } createBubble() { - var o, s, r, n, d; + var n, s, h, o, d; const t = document.createElement("div"); t.style.cssText = ` position: fixed; @@ -82,7 +84,7 @@ class E { z-index: 9999; `; let e = null; - if ((o = this.config.bubbleConfig) != null && o.show) { + if ((n = this.config.bubbleConfig) != null && n.show) { e = document.createElement("div"), e.style.cssText = ` background: white; padding: 12px 16px; @@ -101,12 +103,12 @@ class E { 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 r = document.createElement("span"); + r.textContent = ((s = this.config.bubbleConfig) == null ? void 0 : s.icon) || "", r.style.fontSize = "20px", l.appendChild(r); 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); + g.textContent = ((h = this.config.bubbleConfig) == null ? void 0 : h.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); + a.textContent = ((o = this.config.bubbleConfig) == null ? void 0 : o.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"); f.style.cssText = ` position: absolute; @@ -161,13 +163,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, g = 0; + let l = 0, r = 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"); + a.button === 0 && (this.isDragging = !0, l = a.clientX, r = 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 = g + b, x = window.innerHeight - t.offsetHeight; + const f = a.clientX - l, b = a.clientY - r, 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 +195,9 @@ class E { return e[t] || e["zh-cn"]; } createChatWindow() { - var n, d, l, h, c, g; + var o, d, l, r, 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(((d = this.config.window) == null ? void 0 : d.height) || i * 0.9, i * 0.9); + const t = window.innerWidth <= 768, e = window.innerWidth, i = window.innerHeight, n = Math.min(((o = this.config.window) == null ? void 0 : o.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; @@ -207,12 +209,12 @@ class E { border-top-left-radius: 12px; border-top-right-radius: 12px; overflow: hidden; - transition: all ${(l = this.config.animation) == null ? void 0 : l.duration}ms ${(h = this.config.animation) == null ? void 0 : h.type}; + transition: all ${(l = this.config.animation) == null ? void 0 : l.duration}ms ${(r = this.config.animation) == null ? void 0 : r.type}; ` : this.window.style.cssText = ` position: fixed; ${this.config.placement === "bottom-right" ? "right" : "left"}: ${this.config.marginSide}px; bottom: ${this.config.marginBottom}px; - width: ${o}px; + width: ${n}px; height: ${s}px; border-radius: 12px; box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15); @@ -221,12 +223,12 @@ class E { z-index: 10000; 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 = ` + const h = document.createElement("iframe"); + if (h.style.cssText = ` width: 100%; height: ${this.config.showSupport ? "calc(100% - 30px)" : "100%"}; border: none; - `, r.src = this.generateChatUrl(), console.log("iframe.src: ", r.src), this.window.appendChild(r), this.config.showSupport) { + `, h.src = this.generateChatUrl(), console.log("iframe.src: ", h.src), this.window.appendChild(h), this.config.showSupport) { const a = document.createElement("div"); a.style.cssText = ` height: 20px; @@ -255,12 +257,12 @@ class E { 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)); + return Object.entries(this.config.chatParams || {}).forEach(([n, s]) => { + i.append(n, String(s)); + }), Object.entries(this.config.browseParams || {}).forEach(([n, s]) => { + i.append(n, String(s)); + }), Object.entries(this.config.theme || {}).forEach(([n, s]) => { + i.append(n, String(s)); }), i.append("lang", this.config.locale || "zh-cn"), t && i.append("preload", "1"), `${this.config.baseUrl}?${i.toString()}`; } setupMessageListener() { @@ -291,46 +293,51 @@ class E { }); } 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); + if (console.log("preload"), this.config.isPreload) { + 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() { + var t, e; 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(() => { + const i = window.innerWidth <= 768; + if (this.window.style.display = "block", this.setupResizeListener(), i && 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"); + const n = this.bubble.messageElement; + n instanceof HTMLElement && (n.style.display = "none"); } } - this.hideInviteDialog(); + this.hideInviteDialog(), (e = (t = this.config).onShowChat) == null || e.call(t); } 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"); + var t, e, i; + if (this.window) { + if (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 s = this.bubble.messageElement; + s instanceof HTMLElement && (s.style.display = "block"); + } + (i = (e = this.config).onHideChat) == null || i.call(e); } } minimizeWindow() { - this.window && (this.windowState = "minimized", this.window.style.display = "none"); + this.window && (this.windowState = "minimized", this.window.style.display = "none", this.hideChat()); } toggleMaximize() { this.window && window.open(this.generateChatUrl(), "_blank"); } setupResizeListener() { const t = () => { - var r, n; + var h, o; if (!this.window || !this.isVisible) return; - const i = window.innerWidth <= 768, o = window.innerWidth, s = window.innerHeight; + const i = window.innerWidth <= 768, n = window.innerWidth, s = window.innerHeight; if (i) Object.assign(this.window.style, { left: "0", @@ -343,12 +350,12 @@ class E { borderBottomRightRadius: "0" }); else { - 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; + let d = this.windowState === "maximized" ? n : Math.min(((h = this.config.window) == null ? void 0 : h.width) || n * 0.9, n * 0.9), l = this.windowState === "maximized" ? s : Math.min(((o = this.config.window) == null ? void 0 : o.height) || s * 0.9, s * 0.9); + const r = 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", + right: r ? `${r}px` : "auto", left: c ? `${c}px` : "auto", bottom: `${this.config.marginBottom}px`, borderRadius: this.windowState === "maximized" ? "0" : "12px" @@ -366,8 +373,8 @@ 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, r; - if (!((s = this.config.inviteSettings) != null && s.show)) return; + var s, h; + if (!((s = this.config.inviteParams) != null && s.show)) return; if (this.inviteDialog = document.createElement("div"), this.inviteDialog.style.cssText = ` position: fixed; top: 50%; @@ -381,18 +388,18 @@ class E { display: none; max-width: 300px; text-align: center; - `, this.config.inviteSettings.icon) { - const n = document.createElement("div"); - n.style.cssText = ` + `, this.config.inviteParams.icon) { + const o = document.createElement("div"); + o.style.cssText = ` font-size: 32px; margin-bottom: 12px; - `, n.textContent = this.config.inviteSettings.icon, this.inviteDialog.appendChild(n); + `, o.textContent = this.config.inviteParams.icon, this.inviteDialog.appendChild(o); } const t = document.createElement("div"); t.style.cssText = ` margin-bottom: 16px; color: #333; - `, t.textContent = this.config.inviteSettings.text || "需要帮助吗?点击开始对话", this.inviteDialog.appendChild(t); + `, t.textContent = this.config.inviteParams.text || "需要帮助吗?点击开始对话", this.inviteDialog.appendChild(t); const e = document.createElement("div"); e.style.cssText = ` display: flex; @@ -402,41 +409,41 @@ class E { const i = document.createElement("button"); i.textContent = "开始对话", i.style.cssText = ` padding: 8px 16px; - background: ${((r = this.config.theme) == null ? void 0 : r.backgroundColor) || "#0066FF"}; + background: ${((h = this.config.theme) == null ? void 0 : h.backgroundColor) || "#0066FF"}; color: white; border: none; border-radius: 4px; cursor: pointer; `, i.onclick = () => { - var n, d; - this.hideInviteDialog(), this.showChat(), (d = (n = this.config.inviteSettings) == null ? void 0 : n.onAccept) == null || d.call(n); + var o, d; + this.hideInviteDialog(), this.showChat(), (d = (o = this.config.inviteParams) == null ? void 0 : o.onAccept) == null || d.call(o); }; - const o = document.createElement("button"); - o.textContent = "稍后再说", o.style.cssText = ` + const n = document.createElement("button"); + n.textContent = "稍后再说", n.style.cssText = ` padding: 8px 16px; background: #f5f5f5; color: #666; border: none; border-radius: 4px; cursor: pointer; - `, o.onclick = () => { - var n, d; - this.hideInviteDialog(), (d = (n = this.config.inviteSettings) == 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); + `, n.onclick = () => { + var o, d; + this.hideInviteDialog(), (d = (o = this.config.inviteParams) == null ? void 0 : o.onReject) == null || d.call(o), this.handleInviteLoop(); + }, e.appendChild(i), e.appendChild(n), this.inviteDialog.appendChild(e), document.body.appendChild(this.inviteDialog); } handleInviteLoop() { - const { loop: t, loopDelay: e = 3e3, loopCount: i = 1 / 0 } = this.config.inviteSettings || {}; + 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.inviteSettings) == null ? void 0 : t.onOpen) == null || e.call(t)); + 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.inviteSettings) == null ? void 0 : t.onClose) == null || e.call(t)); + this.inviteDialog && (this.inviteDialog.style.display = "none", (e = (t = this.config.inviteParams) == null ? void 0 : t.onClose) == null || e.call(t)); } } export { diff --git a/starter/src/main/resources/static/embed/index.js b/starter/src/main/resources/static/embed/index.js deleted file mode 100644 index 8ee86cb0c8..0000000000 --- a/starter/src/main/resources/static/embed/index.js +++ /dev/null @@ -1,329 +0,0 @@ -var m = Object.defineProperty; -var b = (l, t, i) => t in l ? m(l, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : l[t] = i; -var h = (l, t, i) => b(l, typeof t != "symbol" ? t + "" : t, i); -class w { - constructor(t) { - h(this, "config"); - h(this, "bubble", null); - h(this, "window", null); - h(this, "isVisible", !1); - h(this, "isDragging", !1); - h(this, "windowState", "normal"); - this.config = { - ...this.getDefaultConfig(), - ...t - }; - } - getDefaultConfig() { - return { - baseUrl: "http://127.0.0.1:9006", - placement: "bottom-right", - marginBottom: 20, - marginSide: 20, - 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" - }, - navbarPreset: "light", - customColor: "#000000", - navbarColor: "#ffffff", - navbarTextColor: "#333333", - animation: { - enabled: !0, - duration: 300, - type: "ease" - }, - theme: { - primaryColor: "#2e88ff", - secondaryColor: "#ffffff", - textColor: "#333333", - backgroundColor: "#ffffff", - position: "right", - navbar: { - backgroundColor: "#ffffff", - textColor: "#333333" - } - }, - window: { - title: "在线客服", - width: 380, - height: 640, - position: "right" - }, - draggable: !1 - }; - } - init() { - this.createBubble(), this.setupMessageListener(), this.setupResizeListener(); - } - createBubble() { - const t = document.createElement("div"); - if (t.style.cssText = ` - position: fixed; - ${this.config.theme.position === "left" ? "left" : "right"}: ${this.config.marginSide}px; - bottom: ${this.config.marginBottom}px; - display: flex; - flex-direction: column; - align-items: ${this.config.theme.position === "left" ? "flex-start" : "flex-end"}; - gap: 10px; - z-index: 9999; - `, this.config.bubbleConfig.show) { - const n = document.createElement("div"); - n.style.cssText = ` - background: white; - padding: 12px 16px; - border-radius: 8px; - box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1); - max-width: 220px; - margin-bottom: 8px; - opacity: 0; - transform: translateY(10px); - transition: all 0.3s ease; - position: relative; - `; - const o = document.createElement("div"); - o.style.cssText = ` - display: flex; - align-items: center; - gap: 8px; - `; - const a = document.createElement("span"); - a.textContent = this.config.bubbleConfig.icon, a.style.fontSize = "20px", o.appendChild(a); - const s = document.createElement("div"), e = document.createElement("div"); - e.textContent = this.config.bubbleConfig.title, e.style.fontWeight = "bold", e.style.marginBottom = "4px", s.appendChild(e); - const d = document.createElement("div"); - d.textContent = this.config.bubbleConfig.subtitle, d.style.fontSize = "0.9em", d.style.opacity = "0.8", s.appendChild(d), o.appendChild(s), n.appendChild(o); - const r = document.createElement("div"); - r.style.cssText = ` - position: absolute; - bottom: -6px; - ${this.config.theme.position === "left" ? "left: 24px" : "right: 24px"}; - width: 12px; - height: 12px; - background: white; - transform: rotate(45deg); - box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1); - `; - const c = document.createElement("div"); - c.style.cssText = ` - position: absolute; - bottom: 0; - ${this.config.theme.position === "left" ? "left: 18px" : "right: 18px"}; - width: 24px; - height: 12px; - background: white; - `, n.appendChild(r), n.appendChild(c), t.appendChild(n), setTimeout(() => { - n.style.opacity = "1", n.style.transform = "translateY(0)"; - }, 500); - } - this.bubble = document.createElement("button"), this.bubble.style.cssText = ` - background-color: ${this.config.theme.primaryColor}; - width: 60px; - height: 60px; - border-radius: 30px; - border: none; - cursor: ${this.config.draggable ? "move" : "pointer"}; - display: flex; - align-items: center; - justify-content: center; - box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); - transition: all 0.3s ease; - outline: none; - position: relative; - user-select: none; - `; - const i = document.createElement("div"); - if (i.innerHTML = ` - - - - `, i.style.cssText = ` - 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 n = 0, o = 0, a = 0, s = 0; - this.bubble.addEventListener("mousedown", (e) => { - e.button === 0 && (this.isDragging = !0, n = e.clientX, o = e.clientY, a = t.offsetLeft, s = t.offsetTop, t.style.transition = "none"); - }), document.addEventListener("mousemove", (e) => { - if (!this.isDragging) return; - e.preventDefault(); - const d = e.clientX - n, r = e.clientY - o, c = a + d, g = s + r, f = window.innerHeight - t.offsetHeight; - c <= window.innerWidth / 2 ? (t.style.left = `${Math.max(0, c)}px`, t.style.right = "auto", this.config.theme.position = "left") : (t.style.right = `${Math.max(0, window.innerWidth - c - t.offsetWidth)}px`, t.style.left = "auto", this.config.theme.position = "right"), t.style.bottom = `${Math.min(Math.max(0, window.innerHeight - g - t.offsetHeight), f)}px`; - }), document.addEventListener("mouseup", () => { - this.isDragging && (this.isDragging = !1, t.style.transition = "all 0.3s ease", this.config.marginSide = parseInt( - this.config.theme.position === "left" ? t.style.left : t.style.right - ) || 20, this.config.marginBottom = parseInt(t.style.bottom || "20")); - }); - } - this.bubble.addEventListener("mousedown", () => { - }), this.bubble.addEventListener("mousemove", () => { - }), this.bubble.addEventListener("click", () => { - this.isDragging || this.showChat(); - }), document.body.appendChild(t); - } - createChatWindow() { - this.window = document.createElement("div"); - const t = window.innerWidth <= 768, i = window.innerWidth, n = window.innerHeight, o = Math.min(this.config.window.width, i * 0.9), a = Math.min(this.config.window.height, n * 0.9); - if (t) - this.window.style.cssText = ` - position: fixed; - left: 0; - bottom: 0; - width: 100%; - height: 90vh; - background: ${this.config.theme.backgroundColor}; - display: none; - z-index: 10000; - border-top-left-radius: 12px; - border-top-right-radius: 12px; - overflow: hidden; - transition: all ${this.config.animation.duration}ms ${this.config.animation.type}; - `; - else { - const e = this.config.theme.position || "right"; - this.window.style.cssText = ` - position: fixed; - ${e}: ${this.config.marginSide}px; - bottom: ${this.config.marginBottom}px; - width: ${o}px; - height: ${a}px; - background: ${this.config.theme.backgroundColor}; - border-radius: 12px; - box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15); - display: none; - overflow: hidden; - z-index: 10000; - transition: all ${this.config.animation.duration}ms ${this.config.animation.type}; - `; - } - const s = document.createElement("iframe"); - if (s.style.cssText = ` - width: 100%; - height: ${this.config.showSupport ? "calc(100% - 30px)" : "100%"}; - border: none; - background: ${this.config.theme.backgroundColor}; - `, s.src = this.generateChatUrl(), this.window.appendChild(s), this.config.showSupport) { - const e = document.createElement("div"); - e.style.cssText = ` - height: 30px; - display: flex; - align-items: center; - justify-content: center; - background: ${this.config.theme.backgroundColor}; - color: #666; - font-size: 12px; - border-top: 1px solid #eee; - `, e.innerHTML = ` - - - bytedesk.com - - - `, this.window.appendChild(e); - } - document.body.appendChild(this.window); - } - generateChatUrl(t = "messages") { - const i = new URLSearchParams(); - return i.append("tab", t), i.append("theme", JSON.stringify(this.config.theme)), i.append("window", JSON.stringify(this.config.window)), Object.entries(this.config.chatParams).forEach(([n, o]) => { - i.append(n, String(o)); - }), `${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; - } - }); - } - showChat() { - if (this.window || this.createChatWindow(), this.window) { - const t = window.innerWidth <= 768; - 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"); - } - } - hideChat() { - this.window && (window.innerWidth <= 768 ? (this.window.style.transform = "translateY(100%)", setTimeout(() => { - this.window && (this.window.style.display = "none"); - }, this.config.animation.duration)) : this.window.style.display = "none", this.isVisible = !1, this.bubble && (this.bubble.style.display = "inline-flex")); - } - 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 = () => { - if (!this.window || !this.isVisible) return; - const n = window.innerWidth <= 768, o = window.innerWidth, a = window.innerHeight; - if (n) - Object.assign(this.window.style, { - left: "0", - bottom: "0", - width: "100%", - height: "90vh", - borderTopLeftRadius: "12px", - borderTopRightRadius: "12px", - borderBottomLeftRadius: "0", - borderBottomRightRadius: "0" - }); - else { - let s = this.windowState === "maximized" ? o : Math.min(this.config.window.width, o * 0.9), e = this.windowState === "maximized" ? a : Math.min(this.config.window.height, a * 0.9); - const d = this.config.window.position === "right" ? this.config.marginSide : void 0, r = this.config.window.position === "left" ? this.config.marginSide : void 0; - Object.assign(this.window.style, { - width: `${s}px`, - height: `${e}px`, - right: d ? `${d}px` : "auto", - left: r ? `${r}px` : "auto", - bottom: `${this.config.marginBottom}px`, - borderRadius: this.windowState === "maximized" ? "0" : "12px" - }); - } - }; - let i; - window.addEventListener("resize", () => { - clearTimeout(i), i = window.setTimeout(t, 100); - }), t(); - } - destroy() { - var i; - const t = (i = this.bubble) == null ? void 0 : i.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)); - } -} -export { - w as default -}; diff --git a/starter/src/main/resources/static/embed/locales/index.d.ts b/starter/src/main/resources/static/embed/locales/index.d.ts deleted file mode 100644 index 0ad5138c24..0000000000 --- a/starter/src/main/resources/static/embed/locales/index.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -type Messages = { - [key in 'zh-CN' | 'en-US']: { - title: string; - bubble: { - title: string; - subtitle: string; - }; - tabs: { - home: string; - messages: string; - help: string; - news: string; - }; - settings: { - position: string; - tabs: string; - bubble: string; - navbar: string; - theme: string; - window: string; - margins: string; - animation: string; - other: string; - embed: string; - }; - }; -}; -export declare const messages: Messages; -export {}; diff --git a/starter/src/main/resources/static/embed/main.d.ts b/starter/src/main/resources/static/embed/main.d.ts deleted file mode 100644 index 65370268c7..0000000000 --- a/starter/src/main/resources/static/embed/main.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { default as BytedeskWeb } from './core/BytedeskWeb'; -export type { BytedeskConfig } from './types'; -export default BytedeskWeb; diff --git a/starter/src/main/resources/static/embed/types/index.d.ts b/starter/src/main/resources/static/embed/types/index.d.ts index 9fa0cfaeea..e7c03e81f4 100644 --- a/starter/src/main/resources/static/embed/types/index.d.ts +++ b/starter/src/main/resources/static/embed/types/index.d.ts @@ -1,96 +1,118 @@ declare interface Animation_2 { - enabled: boolean; - duration: number; - type: 'ease' | 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out'; + enabled?: boolean; + duration?: number; + type?: 'ease' | 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out'; } -export { Animation_2 as Animation } -export declare interface BubbleConfig { - show: boolean; - icon: string; - title: string; - subtitle: string; +declare interface BrowseParams { + referrer?: string; + url?: string; + title?: string; + [key: string]: string | number | undefined; +} + +declare interface BubbleConfig { + show?: boolean; + icon?: string; + title?: string; + subtitle?: string; } export declare interface BytedeskConfig { - baseUrl: string; - placement: 'bottom-left' | 'bottom-right'; - marginBottom: number; - marginSide: number; - tabsConfig: TabsConfig; - bubbleConfig: BubbleConfig; - showSupport: boolean; - chatParams: ChatParams; - navbarPreset: string; - customColor: string; - navbarColor: string; - navbarTextColor: string; - animation: Animation_2; - window: WindowConfig; - theme: Theme; + isDebug?: boolean; + isPreload?: boolean; + baseUrl?: string; + placement?: 'bottom-left' | 'bottom-right'; + marginBottom?: number; + marginSide?: number; + autoPopup?: boolean; + autoPopupDelay?: number; + inviteParams?: InviteParams; + tabsConfig?: TabsConfig; + bubbleConfig?: BubbleConfig; + showSupport?: boolean; + chatParams?: ChatParams; + browseParams?: BrowseParams; + animation?: Animation_2; + window?: WindowConfig; + theme?: Theme; draggable?: boolean; locale?: string; + onInit?: () => void; + onShowChat?: () => void; + onHideChat?: () => void; + onMessage?: (message: string, type: string) => void; } -export declare interface ChatParams { +declare class BytedeskWeb { + private config; + private bubble; + private window; + private inviteDialog; + private isVisible; + private isDragging; + private windowState; + private loopCount; + private loopTimer; + constructor(config: BytedeskConfig); + private getDefaultConfig; + init(): void; + private createBubble; + private getSupportText; + private createChatWindow; + private generateChatUrl; + private setupMessageListener; + preload(): void; + showChat(): void; + hideChat(): void; + private minimizeWindow; + private toggleMaximize; + private setupResizeListener; + destroy(): void; + private createInviteDialog; + private handleInviteLoop; + private showInviteDialog; + private hideInviteDialog; +} +export default BytedeskWeb; + +declare interface ChatParams { org: string; t: string; sid: string; - [key: string]: string | number; + [key: string]: string | number | undefined; } -export declare type Language = 'zh-CN' | 'en-US' | 'ja-JP' | 'ko-KR'; - -export declare interface LocaleMessages { - [key: string]: { - title: string; - settings: { - position: string; - tabs: string; - bubble: string; - navbar: string; - theme: string; - window: string; - margins: string; - animation: string; - other: string; - embed: string; - }; - buttons: { - copy: string; - reset: string; - openChat: string; - }; - }; +declare interface InviteParams { + show?: boolean; + text?: string; + icon?: string; + delay?: number; + loop?: boolean; + loopDelay?: number; + loopCount?: number; + onAccept?: () => void; + onReject?: () => void; + onClose?: () => void; + onOpen?: () => void; } -export declare interface NavbarPreset { - backgroundColor: string; - textColor: string; +declare interface TabsConfig { + home?: boolean; + messages?: boolean; + help?: boolean; + news?: boolean; } -export declare interface TabsConfig { - home: boolean; - messages: boolean; - help: boolean; - news: boolean; +declare interface Theme { + mode?: 'light' | 'dark' | 'system'; + textColor?: string; + backgroundColor?: string; } -export declare interface Theme { - mode: 'light' | 'dark' | 'system'; - primaryColor: string; - secondaryColor: string; - textColor: string; - backgroundColor: string; - position?: 'left' | 'right'; - navbar: NavbarPreset; -} - -export declare interface WindowConfig { - width: number; - height: number; - title: string; - position?: 'left' | 'right'; +declare interface WindowConfig { + width?: number; + height?: number; } export { } diff --git a/starter/src/main/resources/static/embed/types/react.d.ts b/starter/src/main/resources/static/embed/types/react.d.ts index 863b9c8048..aa247e36a6 100644 --- a/starter/src/main/resources/static/embed/types/react.d.ts +++ b/starter/src/main/resources/static/embed/types/react.d.ts @@ -1,77 +1,94 @@ +import { JSX as JSX_2 } from 'react/jsx-runtime'; + declare interface Animation_2 { - enabled: boolean; - duration: number; - type: 'ease' | 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out'; + enabled?: boolean; + duration?: number; + type?: 'ease' | 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out'; +} + +declare interface BrowseParams { + referrer?: string; + url?: string; + title?: string; + [key: string]: string | number | undefined; } declare interface BubbleConfig { - show: boolean; - icon: string; - title: string; - subtitle: string; + show?: boolean; + icon?: string; + title?: string; + subtitle?: string; } declare interface BytedeskConfig { - baseUrl: string; - placement: 'bottom-left' | 'bottom-right'; - marginBottom: number; - marginSide: number; - tabsConfig: TabsConfig; - bubbleConfig: BubbleConfig; - showSupport: boolean; - chatParams: ChatParams; - navbarPreset: string; - customColor: string; - navbarColor: string; - navbarTextColor: string; - animation: Animation_2; - window: WindowConfig; - theme: Theme; + isDebug?: boolean; + isPreload?: boolean; + baseUrl?: string; + placement?: 'bottom-left' | 'bottom-right'; + marginBottom?: number; + marginSide?: number; + autoPopup?: boolean; + autoPopupDelay?: number; + inviteParams?: InviteParams; + tabsConfig?: TabsConfig; + bubbleConfig?: BubbleConfig; + showSupport?: boolean; + chatParams?: ChatParams; + browseParams?: BrowseParams; + animation?: Animation_2; + window?: WindowConfig; + theme?: Theme; draggable?: boolean; locale?: string; + onInit?: () => void; + onShowChat?: () => void; + onHideChat?: () => void; + onMessage?: (message: string, type: string) => void; } -export declare const BytedeskReact: React.FC; +export declare const BytedeskReact: ({ locale, ...props }: BytedeskReactProps) => JSX_2.Element; declare interface BytedeskReactProps extends BytedeskConfig { onInit?: () => void; - locale?: string; } declare interface ChatParams { org: string; t: string; sid: string; - [key: string]: string | number; + [key: string]: string | number | undefined; } -declare interface NavbarPreset { - backgroundColor: string; - textColor: string; +declare interface InviteParams { + show?: boolean; + text?: string; + icon?: string; + delay?: number; + loop?: boolean; + loopDelay?: number; + loopCount?: number; + onAccept?: () => void; + onReject?: () => void; + onClose?: () => void; + onOpen?: () => void; } declare interface TabsConfig { - home: boolean; - messages: boolean; - help: boolean; - news: boolean; + home?: boolean; + messages?: boolean; + help?: boolean; + news?: boolean; } declare interface Theme { - mode: 'light' | 'dark' | 'system'; - primaryColor: string; - secondaryColor: string; - textColor: string; - backgroundColor: string; - position?: 'left' | 'right'; - navbar: NavbarPreset; + mode?: 'light' | 'dark' | 'system'; + textColor?: string; + backgroundColor?: string; } declare interface WindowConfig { - width: number; - height: number; - title: string; - position?: 'left' | 'right'; + width?: number; + height?: number; } export { } diff --git a/starter/src/main/resources/static/embed/types/svelte.d.ts b/starter/src/main/resources/static/embed/types/svelte.d.ts index 6166f1bd30..5af8cca739 100644 --- a/starter/src/main/resources/static/embed/types/svelte.d.ts +++ b/starter/src/main/resources/static/embed/types/svelte.d.ts @@ -1,34 +1,47 @@ declare interface Animation_2 { - enabled: boolean; - duration: number; - type: 'ease' | 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out'; + enabled?: boolean; + duration?: number; + type?: 'ease' | 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out'; +} + +declare interface BrowseParams { + referrer?: string; + url?: string; + title?: string; + [key: string]: string | number | undefined; } declare interface BubbleConfig { - show: boolean; - icon: string; - title: string; - subtitle: string; + show?: boolean; + icon?: string; + title?: string; + subtitle?: string; } declare interface BytedeskConfig { - baseUrl: string; - placement: 'bottom-left' | 'bottom-right'; - marginBottom: number; - marginSide: number; - tabsConfig: TabsConfig; - bubbleConfig: BubbleConfig; - showSupport: boolean; - chatParams: ChatParams; - navbarPreset: string; - customColor: string; - navbarColor: string; - navbarTextColor: string; - animation: Animation_2; - window: WindowConfig; - theme: Theme; + isDebug?: boolean; + isPreload?: boolean; + baseUrl?: string; + placement?: 'bottom-left' | 'bottom-right'; + marginBottom?: number; + marginSide?: number; + autoPopup?: boolean; + autoPopupDelay?: number; + inviteParams?: InviteParams; + tabsConfig?: TabsConfig; + bubbleConfig?: BubbleConfig; + showSupport?: boolean; + chatParams?: ChatParams; + browseParams?: BrowseParams; + animation?: Animation_2; + window?: WindowConfig; + theme?: Theme; draggable?: boolean; locale?: string; + onInit?: () => void; + onShowChat?: () => void; + onHideChat?: () => void; + onMessage?: (message: string, type: string) => void; } export declare const BytedeskSvelte: (node: HTMLElement, config: BytedeskConfig & { @@ -41,36 +54,39 @@ declare interface ChatParams { org: string; t: string; sid: string; - [key: string]: string | number; + [key: string]: string | number | undefined; } -declare interface NavbarPreset { - backgroundColor: string; - textColor: string; +declare interface InviteParams { + show?: boolean; + text?: string; + icon?: string; + delay?: number; + loop?: boolean; + loopDelay?: number; + loopCount?: number; + onAccept?: () => void; + onReject?: () => void; + onClose?: () => void; + onOpen?: () => void; } declare interface TabsConfig { - home: boolean; - messages: boolean; - help: boolean; - news: boolean; + home?: boolean; + messages?: boolean; + help?: boolean; + news?: boolean; } declare interface Theme { - mode: 'light' | 'dark' | 'system'; - primaryColor: string; - secondaryColor: string; - textColor: string; - backgroundColor: string; - position?: 'left' | 'right'; - navbar: NavbarPreset; + mode?: 'light' | 'dark' | 'system'; + textColor?: string; + backgroundColor?: string; } declare interface WindowConfig { - width: number; - height: number; - title: string; - position?: 'left' | 'right'; + width?: number; + height?: number; } export { } diff --git a/starter/src/main/resources/static/embed/types/vue.d.ts b/starter/src/main/resources/static/embed/types/vue.d.ts index 0d2c4f4561..c0a7fd1751 100644 --- a/starter/src/main/resources/static/embed/types/vue.d.ts +++ b/starter/src/main/resources/static/embed/types/vue.d.ts @@ -8,19 +8,19 @@ import { RendererNode } from 'vue'; import { VNode } from 'vue'; export declare const BytedeskVue: DefineComponent, () => VNode, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly> & Readonly<{}>, { - locale: string; +locale: string; }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>; export { } diff --git a/starter/src/main/resources/templates/ftl/common/bytedesk.ftl b/starter/src/main/resources/templates/ftl/common/bytedesk.ftl index 4dedea6193..04f63b7d0e 100644 --- a/starter/src/main/resources/templates/ftl/common/bytedesk.ftl +++ b/starter/src/main/resources/templates/ftl/common/bytedesk.ftl @@ -13,6 +13,11 @@ chatUrl: 'https://www.weiyuai.cn/chat?org=df_org_uid&t=1&sid=df_wg_uid&',