feat: embed into other site support set custom host (#580)

Co-authored-by: Joel <iamjoel007@gmail.com>
This commit is contained in:
Yuhao
2023-07-19 19:43:07 +08:00
committed by GitHub
parent 34f55739e0
commit 2f9de2229f
2 changed files with 4 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ async function embedChatbot () {
return;
}
const isDev = !!difyChatbotConfig.isDev
const baseUrl = difyChatbotConfig.baseUrl || `https://${isDev ? 'dev.' : ''}udify.app`
const openIcon = `<svg
id="openIcon"
width="24"
@@ -53,7 +54,7 @@ async function embedChatbot () {
iframe.allow = "fullscreen;microphone"
iframe.title = "dify chatbot bubble window"
iframe.id = 'dify-chatbot-bubble-window'
iframe.src = `https://${isDev ? 'dev.' : ''}udify.app/chatbot/${difyChatbotConfig.token}`;
iframe.src = `${baseUrl}/chatbot/${difyChatbotConfig.token}`
iframe.style.cssText = 'border: none; position: fixed; flex-direction: column; justify-content: space-between; box-shadow: rgba(150, 150, 150, 0.2) 0px 10px 30px 0px, rgba(150, 150, 150, 0.2) 0px 0px 0px 1px; bottom: 5rem; right: 1rem; width: 24rem; height: 40rem; border-radius: 0.75rem; display: flex; z-index: 2147483647; overflow: hidden; left: unset; background-color: #F3F4F6;'
document.body.appendChild(iframe);
}