/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import React, { useState, useEffect } from 'react'; import { Avatar } from '@douyinfe/semi-ui'; import { MessageCircle, ScanLine } from 'lucide-react'; import { API } from '../../helpers'; import { useTranslation } from 'react-i18next'; /** * 登录/注册页面的客服浮窗 * 右上角固定展示客服二维码,始终可见 */ const AuthCustomerServiceFloat = () => { const { t } = useTranslation(); const [agent, setAgent] = useState(null); const [visible, setVisible] = useState(false); const [qrcodeError, setQrcodeError] = useState(false); useEffect(() => { const fetchAgent = async () => { try { const configRes = await API.get('/api/customer-service/config'); if (!configRes.data.success || !configRes.data.data?.enabled) return; const agentRes = await API.get('/api/customer-service/display'); if (agentRes.data.success && agentRes.data.data) { const data = agentRes.data.data; if (data.qrcode_url || data.wecom_url) { setAgent(data); setVisible(true); } } } catch (e) { // 静默处理,不影响登录页 } }; fetchAgent(); }, []); if (!visible || !agent) return null; const hasQrcode = agent.qrcode_url && !qrcodeError; return (
{/* 外层柔光晕 - 增强浮空立体感 */}
{/* 展示面板 - 玻璃拟态立体效果 */}
{/* 内层 aurora - 缓慢漂移品牌色辉光 */}
{/* 顶部渐变装饰线 */}
{/* 顶部高光反射 - 位于装饰线下方,模拟玻璃反光 */}
{/* 客服信息 */}
{agent.avatar ? ( ) : (
)}
{agent.name || t('在线客服')} {t('在线')}
{/* 提示文案 */}

{t('登录遇到问题?扫码咨询客服解决')}

{/* 二维码 - 始终展示 */} {hasQrcode ? (
{t('客服二维码')} setQrcodeError(true)} />
{t('微信扫码添加客服')}
) : agent.wecom_url ? ( ) : null}
); }; export default AuthCustomerServiceFloat;