/* 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 from 'react'; import { Card, Button, Typography } from '@douyinfe/semi-ui'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; import { Settings, Server, AlertCircle, WifiOff } from 'lucide-react'; const { Title, Text } = Typography; const DeploymentAccessGuard = ({ children, loading, isEnabled, connectionLoading, connectionOk, connectionError, onRetry, }) => { const { t } = useTranslation(); const navigate = useNavigate(); const handleGoToSettings = () => { navigate('/console/setting?tab=model-deployment'); }; if (loading) { return (
{t('加载设置中...')}
); } if (!isEnabled) { return (
{/* 图标区域 */}
{/* 标题区域 */}
{t('模型部署服务未启用')} {t('访问模型部署功能需要先启用 io.net 部署服务')}
{/* 配置要求区域 */}
{t('需要配置的项目')}
{t('启用 io.net 部署开关')}
{t('配置有效的 io.net API Key')}
{/* 操作链接区域 */}
{ e.target.style.background = 'var(--semi-color-fill-1)'; e.target.style.transform = 'translateY(-1px)'; e.target.style.boxShadow = '0 2px 8px rgba(0, 0, 0, 0.1)'; }} onMouseLeave={(e) => { e.target.style.background = 'var(--semi-color-fill-0)'; e.target.style.transform = 'translateY(0)'; e.target.style.boxShadow = 'none'; }} > {t('前往设置页面')}
{/* 底部提示 */} {t('配置完成后刷新页面即可使用模型部署功能')}
); } if (connectionLoading || (connectionOk === null && !connectionError)) { return (
{t('Checking io.net connection...')}
); } if (connectionOk === false) { const isExpired = connectionError?.type === 'expired'; const title = isExpired ? t('API key expired') : t('io.net connection unavailable'); const description = isExpired ? t('The current API key is expired. Please update it in settings.') : t('Unable to connect to io.net with the current configuration.'); const detail = connectionError?.message || ''; return (
{title} {description} {detail ? ( {detail} ) : null}
{onRetry ? ( ) : null}
); } return children; }; export default DeploymentAccessGuard;