From f9f9aa9ddea6a0b2153f37e439919a5288675163 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Tue, 10 Dec 2024 14:47:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B5=8C=E5=85=A5?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=BF=87=E5=A4=A7=E6=8C=87=E5=BC=95=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/application/template/embed.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/apps/application/template/embed.js b/apps/application/template/embed.js index f75b590a41c..ec85ed54004 100644 --- a/apps/application/template/embed.js +++ b/apps/application/template/embed.js @@ -67,6 +67,20 @@ const initChat=(root)=>{ const chat_button_img=root.querySelector('.maxkb-chat-button > img') // 对话框元素 const chat_container=root.querySelector('#maxkb-chat-container') + // 引导层 + const mask_content = root.querySelector('.maxkb-mask > .maxkb-content') + const mask_tips = root.querySelector('.maxkb-tips') + chat_button_img.onload=(event)=>{ + if(mask_content){ + mask_content.style.width = chat_button_img.width + 'px' + mask_content.style.height = chat_button_img.height + 'px' + if('{{x_type}}'=='left'){ + mask_tips.style.marginLeft = (chat_button_img.naturalWidth>500?500:chat_button_img.naturalWidth)-64 + 'px' + }else{ + mask_tips.style.marginRight = (chat_button_img.naturalWidth>500?500:chat_button_img.naturalWidth)-64 + 'px' + } + } + } const viewport=root.querySelector('.maxkb-openviewport') const closeviewport=root.querySelector('.maxkb-closeviewport') @@ -90,17 +104,16 @@ const initChat=(root)=>{ } const drag=(e)=>{ if (['touchmove','touchstart'].includes(e.type)) { - chat_button.style.top=(e.touches[0].clientY-25)+'px' - chat_button.style.left=(e.touches[0].clientX-25)+'px' + chat_button.style.top=(e.touches[0].clientY-chat_button_img.naturalHeight/2)+'px' + chat_button.style.left=(e.touches[0].clientX-chat_button_img.naturalWidth/2)+'px' } else { - chat_button.style.top=(e.y-25)+'px' - chat_button.style.left=(e.x-25)+'px' + chat_button.style.top=(e.y-chat_button_img.naturalHeight/2)+'px' + chat_button.style.left=(e.x-chat_button_img.naturalWidth/2)+'px' } chat_button.style.width =chat_button_img.naturalWidth+'px' chat_button.style.height =chat_button_img.naturalHeight+'px' } if({{is_draggable}}){ - console.dir(chat_button_img) chat_button.addEventListener("drag",drag) chat_button.addEventListener("dragover",(e)=>{ e.preventDefault() @@ -155,7 +168,7 @@ function initMaxkbStyle(root){ #maxkb .maxkb-mask { position: fixed; - z-index: 999; + z-index: 10001; background-color: transparent; height: 100%; width: 100%; @@ -242,8 +255,6 @@ function initMaxkbStyle(root){ {{x_type}}: {{x_value}}px; {{y_type}}: {{y_value}}px; cursor: pointer; - max-height:500px; - max-width:500px; z-index:10000; } #maxkb #maxkb-chat-container{ @@ -306,4 +317,4 @@ function embedChatbot() { initMaxkb() } else console.error('invalid parameter') } -window.onload = embedChatbot +window.addEventListener('load',embedChatbot)