/*
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, { useCallback, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Button, Empty, Modal, Space, Tag, Typography } from 'antd';
import { TableRowActions } from '@/components/common/table/TableToolbar';
import { Table } from '@/components/ui';
import { ConsoleAlert as Alert } from '../console/ConsolePrimitives';
import { Plus } from '../common/icons/ActionIcons';
import { copy, showError, showSuccess } from '../../helpers';
import { deleteProfile, listCandidateModels, listProfiles } from './api';
import ProfileEditor from './ProfileEditor';
import SimulateModal from './SimulateModal';
const { Text } = Typography;
const ProfileTable = ({ mode, orgId, canWrite = true, emptyHint }) => {
const { t } = useTranslation();
const [list, setList] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState('');
const [editing, setEditing] = useState(null); // null 关闭;{} 新建;profile 编辑
const [simulating, setSimulating] = useState(null);
const [models, setModels] = useState([]);
const load = useCallback(async () => {
setLoading(true);
setError('');
try {
setList((await listProfiles(mode, orgId)) || []);
} catch (e) {
setError(e?.message || t('加载失败'));
} finally {
setLoading(false);
}
}, [mode, orgId, t]);
useEffect(() => {
load();
}, [load]);
useEffect(() => {
if (!canWrite) return;
listCandidateModels(mode, orgId)
.then(setModels)
.catch(() => setModels([]));
}, [mode, orgId, canWrite]);
const strategyText = (s) =>
({ quality: t('质量优先'), balanced: t('平衡'), cost: t('成本优先') })[s] ||
s;
const columns = [
{
title: t('虚拟模型'),
dataIndex: 'virtual_model',
width: 280,
render: (v, r) => (