/*
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 (