feat(customer-service): 集成 Bytedesk 客服系统并优化 Dify 机器人显示
## 主要变更 ### 1. Dify 机器人优化 **文件**: public/index.html - ✅ 恢复 Dify 机器人代码 - ✅ 添加显示控制逻辑:只在 /home 页面显示 - ✅ 使用 JavaScript 监听路由变化,动态控制显示/隐藏 - ✅ 保留所有样式配置 ### 2. Bytedesk 客服系统集成 **文件**: src/bytedesk-integration/config/bytedesk.config.js - ✅ 配置开发环境使用代理路径(/bytedesk-api) - ✅ 修复 X-Frame-Options 跨域问题 - ✅ 优化 shouldShowCustomerService 逻辑:默认所有页面显示,只在 /login 隐藏 - ✅ 保留白名单模式代码作为备用方案 **文件**: src/components/GlobalComponents.js - ✅ 集成 BytedeskWidget 组件 - ✅ 使用 shouldShowCustomerService 控制显示 ### 3. 客服显示规则 **Dify 机器人**: - ✅ /home 页面 → 显示 - ❌ 其他页面 → 隐藏 **Bytedesk 客服**: - ✅ 所有页面 → 显示 - ❌ /login 页面 → 隐藏 ## 已知问题 - ⚠️ Bytedesk 服务器配置 enabled: false,需要后端修改为 true - ⚠️ 配置接口: /config/bytedesk/properties ## 测试建议 1. 访问 /home 页面,检查 Dify 机器人是否显示 2. 访问其他页面,检查 Dify 是否隐藏 3. 等待后端修改 enabled 后,测试 Bytedesk 客服功能 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -65,6 +65,9 @@
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
<!-- ============================================
|
||||
Dify 机器人配置 - 只在 /home 页面显示
|
||||
============================================ -->
|
||||
<script>
|
||||
window.difyChatbotConfig = {
|
||||
token: 'DwN8qAKtYFQtWskM',
|
||||
@@ -85,6 +88,44 @@
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Dify 机器人显示控制脚本 -->
|
||||
<script>
|
||||
// 控制 Dify 机器人只在 /home 页面显示
|
||||
function controlDifyVisibility() {
|
||||
const currentPath = window.location.pathname;
|
||||
const difyChatButton = document.getElementById('dify-chatbot-bubble-button');
|
||||
|
||||
if (difyChatButton) {
|
||||
// 只在 /home 页面显示
|
||||
if (currentPath === '/home') {
|
||||
difyChatButton.style.display = 'flex';
|
||||
console.log('[Dify] 显示机器人(当前路径: /home)');
|
||||
} else {
|
||||
difyChatButton.style.display = 'none';
|
||||
console.log('[Dify] 隐藏机器人(当前路径:', currentPath, ')');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载完成后执行
|
||||
window.addEventListener('load', function() {
|
||||
console.log('[Dify] 初始化显示控制');
|
||||
|
||||
// 初始检查(延迟执行,等待 Dify 按钮渲染)
|
||||
setTimeout(controlDifyVisibility, 500);
|
||||
setTimeout(controlDifyVisibility, 1500);
|
||||
|
||||
// 监听路由变化(React Router 使用 pushState)
|
||||
const observer = setInterval(controlDifyVisibility, 1000);
|
||||
|
||||
// 清理函数(可选)
|
||||
window.addEventListener('beforeunload', function() {
|
||||
clearInterval(observer);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script
|
||||
src="https://app.valuefrontier.cn/embed.min.js"
|
||||
id="DwN8qAKtYFQtWskM"
|
||||
@@ -166,7 +207,7 @@
|
||||
bottom: 80px !important;
|
||||
left: 10px !important;
|
||||
}
|
||||
|
||||
|
||||
#dify-chatbot-bubble-button {
|
||||
width: 56px !important;
|
||||
height: 56px !important;
|
||||
|
||||
Reference in New Issue
Block a user