/** * Bytedesk客服配置文件 * 通过代理访问 Bytedesk 服务器(解决 HTTPS 混合内容问题) - iframe 使用完整域名:https://valuefrontier.cn/bytedesk/chat/ - 使用 HTTPS 协议,解决生产环境 Mixed Content 错误 - 生产:前端 Nginx 代理 /bytedesk → 43.143.189.195 - baseUrl 保持官方 CDN(用于加载 SDK 外部模块) */ export const bytedeskConfig = { // API服务地址(如果 SDK 需要调用 API) apiUrl: '/bytedesk', // 聊天页面地址(使用完整 HTTPS 域名,通过 /bytedesk/ 代理避免 React Router 冲突) htmlUrl: 'https://valuefrontier.cn/chat/', // SDK 资源基础路径(保持 Bytedesk 官方 CDN,用于加载外部模块) baseUrl: 'https://www.weiyuai.cn', // 客服图标位置 placement: 'bottom-right', // bottom-right | bottom-left | top-right | top-left // 边距设置(像素) marginBottom: 20, marginSide: 20, // 自动弹出(不推荐) autoPopup: false, // 语言设置 locale: 'zh-cn', // zh-cn | en | ja | ko // 客服图标配置 bubbleConfig: { show: true, // 是否显示客服图标 icon: '💬', // 图标(emoji或图片URL) title: '在线客服', // 鼠标悬停标题 subtitle: '点击咨询', // 副标题 }, // 主题配置 theme: { mode: 'system', // light | dark | system backgroundColor: '#0066FF', // 主题色 textColor: '#ffffff', // 文字颜色 }, // 聊天配置(必需) chatConfig: { org: 'df_org_uid', // 组织ID t: '1', // 类型: 1=人工客服, 2=机器人 sid: 'df_wg_uid', // 工作组ID }, }; /** * 获取Bytedesk配置(根据环境自动切换) * * @returns {Object} Bytedesk配置对象 */ export const getBytedeskConfig = () => { // 所有环境都使用公网地址(不使用代理) return bytedeskConfig; }; /** * 获取带用户信息的配置 * 用于已登录用户,自动传递用户信息到客服端 * * @param {Object} user - 用户对象 * @param {string} user.id - 用户ID * @param {string} user.name - 用户名 * @param {string} user.email - 用户邮箱 * @param {string} user.mobile - 用户手机号 * @returns {Object} 带用户信息的Bytedesk配置 */ export const getBytedeskConfigWithUser = (user) => { const config = getBytedeskConfig(); if (user && user.id) { return { ...config, chatConfig: { ...config.chatConfig, // 传递用户信息(可选) customParams: { userId: user.id, userName: user.name || 'Guest', userEmail: user.email || '', userMobile: user.mobile || '', source: 'web', // 来源标识 }, }, }; } return config; }; export default { bytedeskConfig, getBytedeskConfig, getBytedeskConfigWithUser, };