/*
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, useCallback } from 'react';
import { Modal } from '@/components/ui';
import { X, Shield, Scale, ScrollText, ExternalLink } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import DocumentRenderer from './index';
import { useIsMobile } from '../../../hooks/common/useIsMobile';
const getIconByType = (type) => {
if (type === 'privacy') return Shield;
if (type === 'agreement') return Scale;
return ScrollText;
};
const AGREEMENT_CONFIGS = {
agreement: {
apiEndpoint: '/api/user-agreement',
cacheKey: 'user_agreement',
fullPagePath: '/user-agreement',
titleKey: '服务协议',
emptyKey: '加载服务协议内容失败...',
},
privacy: {
apiEndpoint: '/api/privacy-policy',
cacheKey: 'privacy_policy',
fullPagePath: '/privacy-policy',
titleKey: '隐私政策',
emptyKey: '加载隐私政策内容失败...',
},
};
/**
* 协议预览弹窗(用于登录/注册页内嵌预览)
* @param {boolean} visible
* @param {'agreement'|'privacy'} type
* @param {function} onClose
*/
const AgreementModal = ({ visible, type, onClose }) => {
const { t } = useTranslation();
const isMobile = useIsMobile();
const [progress, setProgress] = useState(0);
const handleProgressChange = useCallback((p) => setProgress(p), []);
const config = type ? AGREEMENT_CONFIGS[type] : null;
if (!config) return null;
const IconComponent = getIconByType(type);
const title = t(config.titleKey);
return (
{/* 阅读进度条 */}
{/* 头部 */}
{/* 内容区 */}
);
};
export default AgreementModal;