ソースを参照

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

Co-authored-by: Joel <iamjoel007@gmail.com>
Yuhao 1 年間 前
コミット
2f9de2229f
共有2 個のファイルを変更した4 個の追加3 個の削除を含む
  1. 2 1
      web/public/embed.js
  2. 2 2
      web/public/embed.min.js

+ 2 - 1
web/public/embed.js

@@ -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);
   }

File diff suppressed because it is too large
+ 2 - 2
web/public/embed.min.js