mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
Merge pull request #1657 from sebastian0619/dev
新增Dify对话机器人支持,新增默认docker-compose.yml
This commit is contained in:
@@ -191,7 +191,9 @@ const BLOG = {
|
||||
WEB_WHIZ_ENABLED: process.env.NEXT_PUBLIC_WEB_WHIZ_ENABLED || false, // 是否显示
|
||||
WEB_WHIZ_BASE_URL: process.env.NEXT_PUBLIC_WEB_WHIZ_BASE_URL || 'https://api.webwhiz.ai', // 可以自建服务器
|
||||
WEB_WHIZ_CHAT_BOT_ID: process.env.NEXT_PUBLIC_WEB_WHIZ_CHAT_BOT_ID || null, // 在后台获取ID
|
||||
|
||||
DIFY_CHATBOT_ENABLED: process.env.NEXT_PUBLIC_DIFY_CHATBOT_ENABLED || false,
|
||||
DIFY_CHATBOT_BASE_URL: process.env.NEXT_PUBLIC_DIFY_CHATBOT_BASE_URL || '',
|
||||
DIFY_CHATBOT_TOKEN: process.env.NEXT_PUBLIC_DIFY_CHATBOT_TOKEN || '',
|
||||
// 悬浮挂件
|
||||
WIDGET_PET: process.env.NEXT_PUBLIC_WIDGET_PET || true, // 是否显示宠物挂件
|
||||
WIDGET_PET_LINK:
|
||||
|
||||
32
components/DifyChatbot.js
Normal file
32
components/DifyChatbot.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import { useEffect } from 'react';
|
||||
import { siteConfig } from '@/lib/config';
|
||||
|
||||
export default function DifyChatbot() {
|
||||
useEffect(() => {
|
||||
// 这里使用 siteConfig() 函数调用来获取配置值
|
||||
if (!siteConfig('DIFY_CHATBOT_ENABLED')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 配置 DifyChatbot,同样需要调用 siteConfig() 获取相应的配置值
|
||||
window.difyChatbotConfig = {
|
||||
token: siteConfig('DIFY_CHATBOT_TOKEN'),
|
||||
baseUrl: siteConfig('DIFY_CHATBOT_BASE_URL')
|
||||
};
|
||||
|
||||
// 加载 DifyChatbot 脚本
|
||||
const script = document.createElement('script');
|
||||
script.src = `${siteConfig('DIFY_CHATBOT_BASE_URL')}/embed.min.js`; // 注意调用 siteConfig()
|
||||
script.id = siteConfig('DIFY_CHATBOT_TOKEN'); // 注意调用 siteConfig()
|
||||
script.defer = true;
|
||||
document.body.appendChild(script);
|
||||
|
||||
return () => {
|
||||
// 在组件卸载时清理 script 标签
|
||||
const existingScript = document.getElementById(siteConfig('DIFY_CHATBOT_TOKEN')); // 注意调用 siteConfig()
|
||||
if (existingScript) document.body.removeChild(existingScript);
|
||||
};
|
||||
}, []); // 注意依赖数组为空,意味着脚本将仅在加载页面时执行一次
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -12,6 +12,7 @@ const FlutteringRibbon = dynamic(() => import('@/components/FlutteringRibbon'),
|
||||
const Ribbon = dynamic(() => import('@/components/Ribbon'), { ssr: false })
|
||||
const Sakura = dynamic(() => import('@/components/Sakura'), { ssr: false })
|
||||
const StarrySky = dynamic(() => import('@/components/StarrySky'), { ssr: false })
|
||||
const DifyChatbot = dynamic(() => import('@/components/DifyChatbot'), { ssr: false });
|
||||
const Analytics = dynamic(() => import('@vercel/analytics/react').then(async (m) => { return m.Analytics }), { ssr: false })
|
||||
const MusicPlayer = dynamic(() => import('@/components/Player'), { ssr: false })
|
||||
const Ackee = dynamic(() => import('@/components/Ackee'), { ssr: false })
|
||||
@@ -69,6 +70,7 @@ const ExternalPlugin = (props) => {
|
||||
const MATOMO_SITE_ID = siteConfig('MATOMO_SITE_ID')
|
||||
const ANALYTICS_51LA_ID = siteConfig('ANALYTICS_51LA_ID')
|
||||
const ANALYTICS_51LA_CK = siteConfig('ANALYTICS_51LA_CK')
|
||||
const DIFY_CHATBOT_ENABLED = siteConfig('DIFY_CHATBOT_ENABLED')
|
||||
|
||||
if (DISABLE_PLUGIN) {
|
||||
return null
|
||||
@@ -91,6 +93,7 @@ const ExternalPlugin = (props) => {
|
||||
{FLUTTERINGRIBBON && <FlutteringRibbon />}
|
||||
{COMMENT_TWIKOO_COUNT_ENABLE && <TwikooCommentCounter {...props} />}
|
||||
{RIBBON && <Ribbon />}
|
||||
{DIFY_CHATBOT_ENABLED && <DifyChatbot />}
|
||||
{CUSTOM_RIGHT_CLICK_CONTEXT_MENU && <CustomContextMenu {...props} />}
|
||||
{!CAN_COPY && <DisableCopy />}
|
||||
{WEB_WHIZ_ENABLED && <WebWhiz />}
|
||||
|
||||
Reference in New Issue
Block a user