feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面
This commit is contained in:
@@ -21,19 +21,21 @@ import React, { useState } from 'react';
|
||||
import { Card, Table, Progress } from '@/components/ui';
|
||||
import { renderQuota } from '../../helpers';
|
||||
|
||||
const ChannelConsumption = ({ data, title, icon, t }) => {
|
||||
const ChannelConsumption = ({ data, title, icon, t, embedded = false }) => {
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(10);
|
||||
|
||||
if (!data || data.length === 0) {
|
||||
return (
|
||||
<Card
|
||||
className='shadow-sm hover:shadow-md transition-shadow'
|
||||
className={`shadow-sm hover:shadow-md transition-shadow ${embedded ? 'analytics-fold-content' : ''}`}
|
||||
title={
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-brand'>{icon}</span>
|
||||
<span className='font-semibold'>{title}</span>
|
||||
</div>
|
||||
embedded ? undefined : (
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-brand'>{icon}</span>
|
||||
<span className='font-semibold'>{title}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
>
|
||||
@@ -122,19 +124,26 @@ const ChannelConsumption = ({ data, title, icon, t }) => {
|
||||
|
||||
return (
|
||||
<Card
|
||||
className='shadow-sm hover:shadow-md transition-shadow'
|
||||
className={`shadow-sm hover:shadow-md transition-shadow ${embedded ? 'analytics-fold-content' : ''}`}
|
||||
title={
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-brand'>{icon}</span>
|
||||
<span className='font-semibold'>{title}</span>
|
||||
<span className='text-xs text-gray-400 ml-2'>TOP {data.length}</span>
|
||||
</div>
|
||||
embedded ? undefined : (
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-brand'>{icon}</span>
|
||||
<span className='font-semibold'>{title}</span>
|
||||
<span className='text-xs text-gray-400 ml-2'>
|
||||
TOP {data.length}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
bodyStyle={{ padding: '0' }}
|
||||
>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={data}
|
||||
dataSource={data.map((record, index) => ({
|
||||
...record,
|
||||
key: `${record.channel_name}-${index}`,
|
||||
}))}
|
||||
pagination={{
|
||||
currentPage,
|
||||
pageSize,
|
||||
@@ -148,7 +157,7 @@ const ChannelConsumption = ({ data, title, icon, t }) => {
|
||||
},
|
||||
}}
|
||||
size='small'
|
||||
rowKey={(record, index) => `${record.channel_name}-${index}`}
|
||||
rowKey='key'
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { ChevronDown } from 'lucide-react';
|
||||
import './collapsible-panel.css';
|
||||
|
||||
const CollapsibleHeader = ({ icon, title, isOpen, onToggle, extra }) => (
|
||||
<button
|
||||
type='button'
|
||||
aria-expanded={isOpen}
|
||||
className='w-full text-left flex items-center justify-between gap-2 cursor-pointer select-none px-5 py-4 bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all border border-gray-100 dark:border-gray-700'
|
||||
onClick={onToggle}
|
||||
>
|
||||
<span className='flex items-center gap-2 min-w-0 flex-wrap'>
|
||||
<span className='text-brand flex-shrink-0'>{icon}</span>
|
||||
<span className='font-semibold text-gray-800 dark:text-gray-100'>
|
||||
{title}
|
||||
</span>
|
||||
{extra}
|
||||
</span>
|
||||
<ChevronDown
|
||||
aria-hidden='true'
|
||||
className={`w-5 h-5 flex-shrink-0 text-gray-400 transition-transform duration-300 ${isOpen ? 'rotate-180' : ''}`}
|
||||
/>
|
||||
</button>
|
||||
);
|
||||
|
||||
export default CollapsibleHeader;
|
||||
@@ -22,7 +22,7 @@ import { Card, Table, Button } from '@/components/ui';
|
||||
import { IconDownload } from '@/components/ui/icons';
|
||||
import { renderQuota } from '../../helpers';
|
||||
|
||||
const DailyStatsTable = ({ data, title, icon, t }) => {
|
||||
const DailyStatsTable = ({ data, title, icon, t, embedded = false }) => {
|
||||
const columns = [
|
||||
{
|
||||
title: t('日期'),
|
||||
@@ -161,13 +161,29 @@ const DailyStatsTable = ({ data, title, icon, t }) => {
|
||||
|
||||
return (
|
||||
<Card
|
||||
className='shadow-sm hover:shadow-md transition-shadow'
|
||||
className={`shadow-sm hover:shadow-md transition-shadow ${embedded ? 'analytics-fold-content' : ''}`}
|
||||
title={
|
||||
<div className='flex items-center justify-between w-full'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-brand'>{icon}</span>
|
||||
<span className='font-semibold'>{title}</span>
|
||||
embedded ? undefined : (
|
||||
<div className='flex items-center justify-between w-full'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-brand'>{icon}</span>
|
||||
<span className='font-semibold'>{title}</span>
|
||||
</div>
|
||||
<Button
|
||||
icon={<IconDownload />}
|
||||
size='small'
|
||||
onClick={handleExport}
|
||||
disabled={!data || data.length === 0}
|
||||
>
|
||||
{t('导出CSV')}
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
bodyStyle={{ padding: '0' }}
|
||||
>
|
||||
{embedded && (
|
||||
<div className='flex justify-end p-4'>
|
||||
<Button
|
||||
icon={<IconDownload />}
|
||||
size='small'
|
||||
@@ -177,9 +193,7 @@ const DailyStatsTable = ({ data, title, icon, t }) => {
|
||||
{t('导出CSV')}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
bodyStyle={{ padding: '0' }}
|
||||
>
|
||||
)}
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={data || []}
|
||||
|
||||
@@ -34,7 +34,7 @@ import { renderQuota } from '../../helpers';
|
||||
const OverviewCards = ({ overview, t }) => {
|
||||
if (!overview) {
|
||||
return (
|
||||
<div className='grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-6'>
|
||||
<div className='grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4'>
|
||||
{[...Array(6)].map((_, i) => (
|
||||
<Card key={i} className='animate-pulse'>
|
||||
<div className='h-20 bg-gray-200 dark:bg-gray-700 rounded'></div>
|
||||
@@ -124,7 +124,7 @@ const OverviewCards = ({ overview, t }) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-6'>
|
||||
<div className='grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4'>
|
||||
{cards.map((card, index) => (
|
||||
<Card
|
||||
key={index}
|
||||
|
||||
@@ -54,6 +54,7 @@ const RiskControlBanLogs = ({
|
||||
banLogStatus,
|
||||
setBanLogStatus,
|
||||
banLogPage,
|
||||
banLogPageSize,
|
||||
fetchBanLogs,
|
||||
unbanUser,
|
||||
t,
|
||||
@@ -204,12 +205,13 @@ const RiskControlBanLogs = ({
|
||||
rowKey='id'
|
||||
loading={loading}
|
||||
pagination={{
|
||||
pageSize: 20,
|
||||
pageSize: banLogPageSize,
|
||||
showTotal: true,
|
||||
total: banLogTotal,
|
||||
// 受控分页:避免切换状态筛选后 Semi 内部页码与 hook 不同步
|
||||
currentPage: banLogPage,
|
||||
onPageChange: (page) => fetchBanLogs({ page }),
|
||||
onPageSizeChange: (pageSize) => fetchBanLogs({ page: 1, pageSize }),
|
||||
}}
|
||||
empty={t('暂无封号记录')}
|
||||
scroll={{ x: 1400 }}
|
||||
|
||||
@@ -18,19 +18,17 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useMemo, useState, useEffect, useCallback } from 'react';
|
||||
import { Card, Spin, Tag, Progress, Empty } from '@/components/ui';
|
||||
import { Card, Spin, Tag, Progress } from '@/components/ui';
|
||||
import CollapsibleHeader from './CollapsibleHeader';
|
||||
import { VChart } from '@visactor/react-vchart';
|
||||
import { API, showError } from '../../helpers';
|
||||
import {
|
||||
UserCheck,
|
||||
Briefcase,
|
||||
Cpu,
|
||||
Users,
|
||||
TrendingUp,
|
||||
BarChart3,
|
||||
PieChart,
|
||||
ChevronDown,
|
||||
ChevronUp,
|
||||
} from 'lucide-react';
|
||||
|
||||
// 职业类型标签配置
|
||||
@@ -271,314 +269,321 @@ const UserSurveyStats = ({ title, icon, t }) => {
|
||||
surveyStats?.ai_tool_stats?.find((s) => s.ai_tool_usage === 3)?.count || 0;
|
||||
|
||||
return (
|
||||
<Card
|
||||
className='shadow-sm hover:shadow-md transition-shadow'
|
||||
title={
|
||||
<div className='flex items-center justify-between w-full'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-brand'>{icon}</span>
|
||||
<span className='font-semibold'>{title}</span>
|
||||
<div className='analytics-fold-panel'>
|
||||
<CollapsibleHeader
|
||||
icon={icon}
|
||||
title={title}
|
||||
isOpen={!collapsed}
|
||||
onToggle={() => setCollapsed((value) => !value)}
|
||||
extra={
|
||||
<>
|
||||
{totalUsers > 0 && (
|
||||
<Tag color='purple' size='small'>
|
||||
{totalUsers} {t('人已填写')}
|
||||
</Tag>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
onClick={() => setCollapsed(!collapsed)}
|
||||
className='flex items-center gap-1 px-2 py-1 text-sm text-gray-500 hover:text-brand-deep hover:bg-brand/5 dark:hover:bg-brand-deep/20 rounded transition-colors'
|
||||
>
|
||||
<span className='text-xs'>{collapsed ? t('展开') : t('收起')}</span>
|
||||
{collapsed ? <ChevronDown size={16} /> : <ChevronUp size={16} />}
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
bodyStyle={{ padding: collapsed ? '0' : '16px' }}
|
||||
>
|
||||
{!collapsed && (
|
||||
<Spin spinning={loading}>
|
||||
{totalUsers === 0 ? (
|
||||
<Empty
|
||||
image={<UserCheck className='w-16 h-16 text-gray-300' />}
|
||||
description={t('暂无问卷数据')}
|
||||
style={{ padding: '40px 0' }}
|
||||
/>
|
||||
) : (
|
||||
<div className='space-y-6'>
|
||||
{/* 概览统计卡片 */}
|
||||
<div className='grid grid-cols-2 sm:grid-cols-4 gap-4'>
|
||||
<div className='p-4 bg-gradient-to-br from-brand-from/5 to-brand-to/5 dark:from-brand-from/20 dark:to-brand-to/20 rounded-xl'>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<Users className='w-4 h-4 text-brand' />
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400'>
|
||||
{t('总填写')}
|
||||
</span>
|
||||
</div>
|
||||
<div className='text-2xl font-bold text-brand-deep dark:text-brand-from'>
|
||||
{totalUsers}
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<div className={collapsed ? 'hidden' : ''}>
|
||||
<Card
|
||||
className='analytics-fold-content shadow-sm'
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
>
|
||||
{!collapsed && (
|
||||
<Spin spinning={loading}>
|
||||
{totalUsers === 0 ? (
|
||||
<div className='h-[300px] flex items-center justify-center text-gray-400'>
|
||||
{t('暂无数据')}
|
||||
</div>
|
||||
<div className='p-4 bg-gradient-to-br from-blue-50 to-cyan-50 dark:from-blue-900/20 dark:to-cyan-900/20 rounded-xl'>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<Briefcase className='w-4 h-4 text-blue-500' />
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400'>
|
||||
{t('技术岗位')}
|
||||
</span>
|
||||
</div>
|
||||
<div className='text-2xl font-bold text-blue-600 dark:text-blue-400'>
|
||||
{techUsers}
|
||||
</div>
|
||||
<div className='text-xs text-gray-400 mt-1'>
|
||||
{totalUsers > 0
|
||||
? ((techUsers / totalUsers) * 100).toFixed(1)
|
||||
: 0}
|
||||
%
|
||||
</div>
|
||||
</div>
|
||||
<div className='p-4 bg-gradient-to-br from-green-50 to-emerald-50 dark:from-green-900/20 dark:to-emerald-900/20 rounded-xl'>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<Cpu className='w-4 h-4 text-green-500' />
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400'>
|
||||
{t('正在使用AI')}
|
||||
</span>
|
||||
</div>
|
||||
<div className='text-2xl font-bold text-green-600 dark:text-green-400'>
|
||||
{activeAIUsers}
|
||||
</div>
|
||||
<div className='text-xs text-gray-400 mt-1'>
|
||||
{totalUsers > 0
|
||||
? ((activeAIUsers / totalUsers) * 100).toFixed(1)
|
||||
: 0}
|
||||
%
|
||||
</div>
|
||||
</div>
|
||||
<div className='p-4 bg-gradient-to-br from-orange-50 to-amber-50 dark:from-orange-900/20 dark:to-amber-900/20 rounded-xl'>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<TrendingUp className='w-4 h-4 text-orange-500' />
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400'>
|
||||
{t('有兴趣尝试')}
|
||||
</span>
|
||||
</div>
|
||||
<div className='text-2xl font-bold text-orange-600 dark:text-orange-400'>
|
||||
{interestedUsers}
|
||||
</div>
|
||||
<div className='text-xs text-gray-400 mt-1'>
|
||||
{totalUsers > 0
|
||||
? ((interestedUsers / totalUsers) * 100).toFixed(1)
|
||||
: 0}
|
||||
%
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 图表区域 */}
|
||||
<div className='grid grid-cols-1 lg:grid-cols-2 gap-6'>
|
||||
{/* 职业分布 */}
|
||||
<div className='bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4'>
|
||||
<div className='flex items-center gap-2 mb-4'>
|
||||
<PieChart className='w-4 h-4 text-blue-500' />
|
||||
<span className='font-medium text-gray-700 dark:text-gray-300'>
|
||||
{t('职业分布')}
|
||||
</span>
|
||||
</div>
|
||||
{jobTypePieSpec ? (
|
||||
<>
|
||||
<VChart
|
||||
spec={jobTypePieSpec}
|
||||
option={{ mode: 'desktop-browser' }}
|
||||
style={{ height: 180 }}
|
||||
/>
|
||||
<div className='mt-3 space-y-2'>
|
||||
{surveyStats?.job_type_stats?.map((item) => {
|
||||
const config = JOB_TYPE_CONFIG[item.job_type];
|
||||
return (
|
||||
<div
|
||||
key={item.job_type}
|
||||
className='flex items-center justify-between'
|
||||
>
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-lg'>{config?.icon}</span>
|
||||
<span className='text-sm text-gray-600 dark:text-gray-400'>
|
||||
{config?.label}
|
||||
</span>
|
||||
</div>
|
||||
<div className='flex items-center gap-2'>
|
||||
<Progress
|
||||
percent={item.percentage}
|
||||
size='small'
|
||||
style={{ width: 60 }}
|
||||
showInfo={false}
|
||||
stroke={
|
||||
config?.color === 'blue'
|
||||
? '#3b82f6'
|
||||
: config?.color === 'green'
|
||||
? '#10b981'
|
||||
: '#f59e0b'
|
||||
}
|
||||
/>
|
||||
<span className='text-sm font-medium w-12 text-right'>
|
||||
{item.count}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
) : (
|
||||
<div className='space-y-6'>
|
||||
{/* 概览统计卡片 */}
|
||||
<div className='grid grid-cols-2 sm:grid-cols-4 gap-4'>
|
||||
<div className='p-4 bg-gradient-to-br from-brand-from/5 to-brand-to/5 dark:from-brand-from/20 dark:to-brand-to/20 rounded-xl'>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<Users className='w-4 h-4 text-brand' />
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400'>
|
||||
{t('总填写')}
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className='h-[200px] flex items-center justify-center text-gray-400'>
|
||||
{t('暂无数据')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* AI工具使用情况 */}
|
||||
<div className='bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4'>
|
||||
<div className='flex items-center gap-2 mb-4'>
|
||||
<PieChart className='w-4 h-4 text-green-500' />
|
||||
<span className='font-medium text-gray-700 dark:text-gray-300'>
|
||||
{t('AI工具使用情况')}
|
||||
</span>
|
||||
</div>
|
||||
{aiToolPieSpec ? (
|
||||
<>
|
||||
<VChart
|
||||
spec={aiToolPieSpec}
|
||||
option={{ mode: 'desktop-browser' }}
|
||||
style={{ height: 180 }}
|
||||
/>
|
||||
<div className='mt-3 space-y-2'>
|
||||
{surveyStats?.ai_tool_stats?.map((item) => {
|
||||
const config = AI_TOOL_CONFIG[item.ai_tool_usage];
|
||||
const colors = {
|
||||
green: '#10b981',
|
||||
blue: '#3b82f6',
|
||||
orange: '#f59e0b',
|
||||
grey: '#9ca3af',
|
||||
};
|
||||
return (
|
||||
<div
|
||||
key={item.ai_tool_usage}
|
||||
className='flex items-center justify-between'
|
||||
>
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-lg'>{config?.icon}</span>
|
||||
<span className='text-sm text-gray-600 dark:text-gray-400'>
|
||||
{config?.label}
|
||||
</span>
|
||||
</div>
|
||||
<div className='flex items-center gap-2'>
|
||||
<Progress
|
||||
percent={item.percentage}
|
||||
size='small'
|
||||
style={{ width: 60 }}
|
||||
showInfo={false}
|
||||
stroke={colors[config?.color] || '#9ca3af'}
|
||||
/>
|
||||
<span className='text-sm font-medium w-12 text-right'>
|
||||
{item.count}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<div className='text-2xl font-bold text-brand-deep dark:text-brand-from'>
|
||||
{totalUsers}
|
||||
</div>
|
||||
</div>
|
||||
<div className='p-4 bg-gradient-to-br from-blue-50 to-cyan-50 dark:from-blue-900/20 dark:to-cyan-900/20 rounded-xl'>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<Briefcase className='w-4 h-4 text-blue-500' />
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400'>
|
||||
{t('技术岗位')}
|
||||
</span>
|
||||
</div>
|
||||
<div className='text-2xl font-bold text-blue-600 dark:text-blue-400'>
|
||||
{techUsers}
|
||||
</div>
|
||||
<div className='text-xs text-gray-400 mt-1'>
|
||||
{totalUsers > 0
|
||||
? ((techUsers / totalUsers) * 100).toFixed(1)
|
||||
: 0}
|
||||
%
|
||||
</div>
|
||||
</div>
|
||||
<div className='p-4 bg-gradient-to-br from-green-50 to-emerald-50 dark:from-green-900/20 dark:to-emerald-900/20 rounded-xl'>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<Cpu className='w-4 h-4 text-green-500' />
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400'>
|
||||
{t('正在使用AI')}
|
||||
</span>
|
||||
</div>
|
||||
<div className='text-2xl font-bold text-green-600 dark:text-green-400'>
|
||||
{activeAIUsers}
|
||||
</div>
|
||||
<div className='text-xs text-gray-400 mt-1'>
|
||||
{totalUsers > 0
|
||||
? ((activeAIUsers / totalUsers) * 100).toFixed(1)
|
||||
: 0}
|
||||
%
|
||||
</div>
|
||||
</div>
|
||||
<div className='p-4 bg-gradient-to-br from-orange-50 to-amber-50 dark:from-orange-900/20 dark:to-amber-900/20 rounded-xl'>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<TrendingUp className='w-4 h-4 text-orange-500' />
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400'>
|
||||
{t('有兴趣尝试')}
|
||||
</span>
|
||||
</div>
|
||||
<div className='text-2xl font-bold text-orange-600 dark:text-orange-400'>
|
||||
{interestedUsers}
|
||||
</div>
|
||||
<div className='text-xs text-gray-400 mt-1'>
|
||||
{totalUsers > 0
|
||||
? ((interestedUsers / totalUsers) * 100).toFixed(1)
|
||||
: 0}
|
||||
%
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className='h-[200px] flex items-center justify-center text-gray-400'>
|
||||
{t('暂无数据')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 填写趋势 */}
|
||||
<div className='bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4'>
|
||||
<div className='flex items-center gap-2 mb-4'>
|
||||
<BarChart3 className='w-4 h-4 text-brand' />
|
||||
<span className='font-medium text-gray-700 dark:text-gray-300'>
|
||||
{t('近30天填写趋势')}
|
||||
</span>
|
||||
</div>
|
||||
{trendSpec ? (
|
||||
<VChart
|
||||
spec={trendSpec}
|
||||
option={{ mode: 'desktop-browser' }}
|
||||
style={{ height: 200 }}
|
||||
/>
|
||||
) : (
|
||||
<div className='h-[200px] flex items-center justify-center text-gray-400'>
|
||||
{t('暂无数据')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 交叉分析表格 */}
|
||||
{surveyStats?.cross_analysis &&
|
||||
surveyStats.cross_analysis.length > 0 && (
|
||||
{/* 图表区域 */}
|
||||
<div className='grid grid-cols-1 lg:grid-cols-2 gap-6'>
|
||||
{/* 职业分布 */}
|
||||
<div className='bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4'>
|
||||
<div className='flex items-center gap-2 mb-4'>
|
||||
<PieChart className='w-4 h-4 text-blue-500' />
|
||||
<span className='font-medium text-gray-700 dark:text-gray-300'>
|
||||
{t('职业分布')}
|
||||
</span>
|
||||
</div>
|
||||
{jobTypePieSpec ? (
|
||||
<>
|
||||
<VChart
|
||||
spec={jobTypePieSpec}
|
||||
option={{ mode: 'desktop-browser' }}
|
||||
style={{ height: 180 }}
|
||||
/>
|
||||
<div className='mt-3 space-y-2'>
|
||||
{surveyStats?.job_type_stats?.map((item) => {
|
||||
const config = JOB_TYPE_CONFIG[item.job_type];
|
||||
return (
|
||||
<div
|
||||
key={item.job_type}
|
||||
className='flex items-center justify-between'
|
||||
>
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-lg'>
|
||||
{config?.icon}
|
||||
</span>
|
||||
<span className='text-sm text-gray-600 dark:text-gray-400'>
|
||||
{config?.label}
|
||||
</span>
|
||||
</div>
|
||||
<div className='flex items-center gap-2'>
|
||||
<Progress
|
||||
percent={item.percentage}
|
||||
size='small'
|
||||
style={{ width: 60 }}
|
||||
showInfo={false}
|
||||
stroke={
|
||||
config?.color === 'blue'
|
||||
? '#3b82f6'
|
||||
: config?.color === 'green'
|
||||
? '#10b981'
|
||||
: '#f59e0b'
|
||||
}
|
||||
/>
|
||||
<span className='text-sm font-medium w-12 text-right'>
|
||||
{item.count}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className='h-[200px] flex items-center justify-center text-gray-400'>
|
||||
{t('暂无数据')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* AI工具使用情况 */}
|
||||
<div className='bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4'>
|
||||
<div className='flex items-center gap-2 mb-4'>
|
||||
<PieChart className='w-4 h-4 text-green-500' />
|
||||
<span className='font-medium text-gray-700 dark:text-gray-300'>
|
||||
{t('AI工具使用情况')}
|
||||
</span>
|
||||
</div>
|
||||
{aiToolPieSpec ? (
|
||||
<>
|
||||
<VChart
|
||||
spec={aiToolPieSpec}
|
||||
option={{ mode: 'desktop-browser' }}
|
||||
style={{ height: 180 }}
|
||||
/>
|
||||
<div className='mt-3 space-y-2'>
|
||||
{surveyStats?.ai_tool_stats?.map((item) => {
|
||||
const config = AI_TOOL_CONFIG[item.ai_tool_usage];
|
||||
const colors = {
|
||||
green: '#10b981',
|
||||
blue: '#3b82f6',
|
||||
orange: '#f59e0b',
|
||||
grey: '#9ca3af',
|
||||
};
|
||||
return (
|
||||
<div
|
||||
key={item.ai_tool_usage}
|
||||
className='flex items-center justify-between'
|
||||
>
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-lg'>
|
||||
{config?.icon}
|
||||
</span>
|
||||
<span className='text-sm text-gray-600 dark:text-gray-400'>
|
||||
{config?.label}
|
||||
</span>
|
||||
</div>
|
||||
<div className='flex items-center gap-2'>
|
||||
<Progress
|
||||
percent={item.percentage}
|
||||
size='small'
|
||||
style={{ width: 60 }}
|
||||
showInfo={false}
|
||||
stroke={
|
||||
colors[config?.color] || '#9ca3af'
|
||||
}
|
||||
/>
|
||||
<span className='text-sm font-medium w-12 text-right'>
|
||||
{item.count}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className='h-[200px] flex items-center justify-center text-gray-400'>
|
||||
{t('暂无数据')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 填写趋势 */}
|
||||
<div className='bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4'>
|
||||
<div className='flex items-center gap-2 mb-4'>
|
||||
<BarChart3 className='w-4 h-4 text-brand' />
|
||||
<span className='font-medium text-gray-700 dark:text-gray-300'>
|
||||
{t('交叉分析')}
|
||||
{t('近30天填写趋势')}
|
||||
</span>
|
||||
</div>
|
||||
<div className='overflow-x-auto'>
|
||||
<table className='w-full text-sm'>
|
||||
<thead>
|
||||
<tr className='border-b border-gray-200 dark:border-gray-700'>
|
||||
<th className='text-left py-2 px-3 font-medium text-gray-600 dark:text-gray-400'>
|
||||
{t('职业类型')}
|
||||
</th>
|
||||
<th className='text-left py-2 px-3 font-medium text-gray-600 dark:text-gray-400'>
|
||||
{t('AI工具使用')}
|
||||
</th>
|
||||
<th className='text-right py-2 px-3 font-medium text-gray-600 dark:text-gray-400'>
|
||||
{t('人数')}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{surveyStats.cross_analysis.map((item, index) => (
|
||||
<tr
|
||||
key={index}
|
||||
className='border-b border-gray-100 dark:border-gray-700/50 last:border-0'
|
||||
>
|
||||
<td className='py-2 px-3'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<span>
|
||||
{JOB_TYPE_CONFIG[item.job_type]?.icon}
|
||||
</span>
|
||||
<span className='text-gray-700 dark:text-gray-300'>
|
||||
{JOB_TYPE_CONFIG[item.job_type]?.label}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td className='py-2 px-3'>
|
||||
<Tag
|
||||
color={
|
||||
AI_TOOL_CONFIG[item.ai_tool_usage]?.color
|
||||
}
|
||||
size='small'
|
||||
>
|
||||
{AI_TOOL_CONFIG[item.ai_tool_usage]?.label}
|
||||
</Tag>
|
||||
</td>
|
||||
<td className='py-2 px-3 text-right font-medium'>
|
||||
{item.count}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{trendSpec ? (
|
||||
<VChart
|
||||
spec={trendSpec}
|
||||
option={{ mode: 'desktop-browser' }}
|
||||
style={{ height: 200 }}
|
||||
/>
|
||||
) : (
|
||||
<div className='h-[200px] flex items-center justify-center text-gray-400'>
|
||||
{t('暂无数据')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 交叉分析表格 */}
|
||||
{surveyStats?.cross_analysis &&
|
||||
surveyStats.cross_analysis.length > 0 && (
|
||||
<div className='bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4'>
|
||||
<div className='flex items-center gap-2 mb-4'>
|
||||
<BarChart3 className='w-4 h-4 text-brand' />
|
||||
<span className='font-medium text-gray-700 dark:text-gray-300'>
|
||||
{t('交叉分析')}
|
||||
</span>
|
||||
</div>
|
||||
<div className='overflow-x-auto'>
|
||||
<table className='w-full text-sm'>
|
||||
<thead>
|
||||
<tr className='border-b border-gray-200 dark:border-gray-700'>
|
||||
<th className='text-left py-2 px-3 font-medium text-gray-600 dark:text-gray-400'>
|
||||
{t('职业类型')}
|
||||
</th>
|
||||
<th className='text-left py-2 px-3 font-medium text-gray-600 dark:text-gray-400'>
|
||||
{t('AI工具使用')}
|
||||
</th>
|
||||
<th className='text-right py-2 px-3 font-medium text-gray-600 dark:text-gray-400'>
|
||||
{t('人数')}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{surveyStats.cross_analysis.map((item, index) => (
|
||||
<tr
|
||||
key={index}
|
||||
className='border-b border-gray-100 dark:border-gray-700/50 last:border-0'
|
||||
>
|
||||
<td className='py-2 px-3'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<span>
|
||||
{JOB_TYPE_CONFIG[item.job_type]?.icon}
|
||||
</span>
|
||||
<span className='text-gray-700 dark:text-gray-300'>
|
||||
{JOB_TYPE_CONFIG[item.job_type]?.label}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td className='py-2 px-3'>
|
||||
<Tag
|
||||
color={
|
||||
AI_TOOL_CONFIG[item.ai_tool_usage]
|
||||
?.color
|
||||
}
|
||||
size='small'
|
||||
>
|
||||
{
|
||||
AI_TOOL_CONFIG[item.ai_tool_usage]
|
||||
?.label
|
||||
}
|
||||
</Tag>
|
||||
</td>
|
||||
<td className='py-2 px-3 text-right font-medium'>
|
||||
{item.count}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</Spin>
|
||||
)}
|
||||
</Spin>
|
||||
)}
|
||||
</Card>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -20,16 +20,18 @@ import React from 'react';
|
||||
import { Card, Table } from '@/components/ui';
|
||||
import { renderQuota } from '../../helpers';
|
||||
|
||||
const UserTopupRanking = ({ data, title, icon, t }) => {
|
||||
const UserTopupRanking = ({ data, title, icon, t, embedded = false }) => {
|
||||
if (!data || data.length === 0) {
|
||||
return (
|
||||
<Card
|
||||
className='shadow-sm hover:shadow-md transition-shadow'
|
||||
className={`shadow-sm hover:shadow-md transition-shadow ${embedded ? 'analytics-fold-content' : ''}`}
|
||||
title={
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-brand'>{icon}</span>
|
||||
<span className='font-semibold'>{title}</span>
|
||||
</div>
|
||||
embedded ? undefined : (
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-brand'>{icon}</span>
|
||||
<span className='font-semibold'>{title}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
>
|
||||
@@ -123,15 +125,17 @@ const UserTopupRanking = ({ data, title, icon, t }) => {
|
||||
|
||||
return (
|
||||
<Card
|
||||
className='shadow-sm hover:shadow-md transition-shadow'
|
||||
className={`shadow-sm hover:shadow-md transition-shadow ${embedded ? 'analytics-fold-content' : ''}`}
|
||||
title={
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-brand'>{icon}</span>
|
||||
<span className='font-semibold'>{title}</span>
|
||||
<span className='text-xs text-gray-400 ml-2'>
|
||||
{t('共')} {data.length} {t('人')}
|
||||
</span>
|
||||
</div>
|
||||
embedded ? undefined : (
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-brand'>{icon}</span>
|
||||
<span className='font-semibold'>{title}</span>
|
||||
<span className='text-xs text-gray-400 ml-2'>
|
||||
{t('共')} {data.length} {t('人')}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
bodyStyle={{ padding: '0' }}
|
||||
>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
.console-page .analytics-fold-panel {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--console-border);
|
||||
border-radius: 0.75rem;
|
||||
background: var(--console-surface);
|
||||
}
|
||||
|
||||
.console-page .analytics-fold-panel > button {
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
background: transparent;
|
||||
border-bottom-color: var(--console-border);
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.console-page .analytics-fold-panel > button:focus:not(:focus-visible) {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.console-page .analytics-fold-panel > button:focus-visible {
|
||||
outline: 2px solid var(--console-primary);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.console-page .analytics-fold-panel > button[aria-expanded='true'] {
|
||||
border-bottom: 1px solid var(--console-border);
|
||||
}
|
||||
|
||||
.console-page .analytics-fold-panel .analytics-fold-content.ant-card {
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
@@ -39,8 +39,8 @@ export const ReportHeader = ({ report, onExport, t }) => {
|
||||
m.rollup_ready && m.history_floor > 0 && m.prev_start < m.history_floor;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Card className='shadow-sm mb-4' bodyStyle={{ padding: '16px 20px' }}>
|
||||
<div className='flex flex-col gap-4'>
|
||||
<Card className='shadow-sm' bodyStyle={{ padding: '16px 20px' }}>
|
||||
<div className='flex flex-col md:flex-row md:items-center md:justify-between gap-3'>
|
||||
<div className='min-w-0'>
|
||||
<div className='text-xs font-semibold tracking-wider text-brand mb-1'>
|
||||
@@ -68,7 +68,6 @@ export const ReportHeader = ({ report, onExport, t }) => {
|
||||
</Card>
|
||||
{!m.rollup_ready ? (
|
||||
<Banner
|
||||
className='mb-4'
|
||||
type='warning'
|
||||
fullMode={false}
|
||||
closeIcon={null}
|
||||
@@ -80,7 +79,6 @@ export const ReportHeader = ({ report, onExport, t }) => {
|
||||
) : null}
|
||||
{m.rollup_ready && !m.history_ready ? (
|
||||
<Banner
|
||||
className='mb-4'
|
||||
type='info'
|
||||
fullMode={false}
|
||||
closeIcon={null}
|
||||
@@ -92,7 +90,6 @@ export const ReportHeader = ({ report, onExport, t }) => {
|
||||
) : null}
|
||||
{beyondFloor ? (
|
||||
<Banner
|
||||
className='mb-4'
|
||||
type='info'
|
||||
fullMode={false}
|
||||
closeIcon={null}
|
||||
@@ -106,7 +103,6 @@ export const ReportHeader = ({ report, onExport, t }) => {
|
||||
) : null}
|
||||
{stale ? (
|
||||
<Banner
|
||||
className='mb-4'
|
||||
type='warning'
|
||||
fullMode={false}
|
||||
closeIcon={null}
|
||||
@@ -118,7 +114,7 @@ export const ReportHeader = ({ report, onExport, t }) => {
|
||||
)}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -120,11 +120,13 @@ const OrgReportPanel = ({ report, loading, error, onRetry, t }) => {
|
||||
: 'transition-opacity'
|
||||
}
|
||||
>
|
||||
<ReportHeader
|
||||
report={report}
|
||||
onExport={() => exportOrgDetail(report.orgs || [], cny, t)}
|
||||
t={t}
|
||||
/>
|
||||
<div className='pb-2.5'>
|
||||
<ReportHeader
|
||||
report={report}
|
||||
onExport={() => exportOrgDetail(report.orgs || [], cny, t)}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<KeyFindings findings={findings} onJump={jump} t={t} />
|
||||
|
||||
@@ -191,7 +193,7 @@ const OrgReportPanel = ({ report, loading, error, onRetry, t }) => {
|
||||
</div>
|
||||
|
||||
<SectionTitle index={7} title={t('团队与明细')} />
|
||||
<div className='space-y-4 mb-6'>
|
||||
<div className='flex flex-col gap-2.5 mb-6'>
|
||||
<SalesRepTable
|
||||
reps={reps}
|
||||
cny={cny}
|
||||
|
||||
@@ -49,7 +49,7 @@ export const SectionCard = ({
|
||||
export const SectionTitle = ({ id, index, title, desc }) => (
|
||||
<div
|
||||
id={id}
|
||||
className='flex items-baseline gap-2 mb-3 mt-8 flex-wrap scroll-mt-24'
|
||||
className='flex items-baseline gap-2 mb-3 mt-4 flex-wrap scroll-mt-24'
|
||||
>
|
||||
{index ? (
|
||||
<span className='text-xs font-semibold tracking-wider text-brand tabular-nums'>
|
||||
|
||||
@@ -95,8 +95,12 @@ const PasswordResetConfirm = () => {
|
||||
if (success) {
|
||||
let password = res.data.data;
|
||||
setNewPassword(password);
|
||||
await copy(password);
|
||||
showNotice(`${t('密码已重置并已复制到剪贴板:')} ${password}`);
|
||||
if (await copy(password)) {
|
||||
showNotice(`${t('密码已重置并已复制到剪贴板:')} ${password}`);
|
||||
} else {
|
||||
showNotice(t('密码已重置'));
|
||||
showError(t('复制失败,请手动复制'));
|
||||
}
|
||||
} else {
|
||||
showError(message);
|
||||
}
|
||||
@@ -169,9 +173,13 @@ const PasswordResetConfirm = () => {
|
||||
type='tertiary'
|
||||
theme='borderless'
|
||||
onClick={async () => {
|
||||
await copy(newPassword);
|
||||
showNotice(`${t('密码已复制到剪贴板:')} ${newPassword}`,
|
||||
);
|
||||
if (await copy(newPassword)) {
|
||||
showNotice(
|
||||
`${t('密码已复制到剪贴板:')} ${newPassword}`,
|
||||
);
|
||||
} else {
|
||||
showError(t('复制失败,请手动复制'));
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t('复制')}
|
||||
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { writeClipboardText } from '../../../helpers/clipboard';
|
||||
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
||||
import { API, showError } from '../../../helpers';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -361,14 +362,14 @@ const DocumentRenderer = ({
|
||||
a.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const url = `${window.location.origin}${window.location.pathname}#${id}`;
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(url).catch(() => {});
|
||||
}
|
||||
writeClipboardText(url).catch(() => {
|
||||
showError(t('复制失败,请手动复制'));
|
||||
});
|
||||
history.replaceState(null, '', `#${id}`);
|
||||
});
|
||||
h.prepend(a);
|
||||
});
|
||||
}, [isEmbedded, loading, content, processedHtmlContent]);
|
||||
}, [isEmbedded, loading, content, processedHtmlContent, t]);
|
||||
|
||||
// 文档内容样式(prose)—— 同时兼顾浅色与深色
|
||||
const proseClass = `prose prose-base dark:prose-invert max-w-none
|
||||
|
||||
@@ -90,7 +90,11 @@ export default function LobeHubIcon({ iconName, size = 14 }) {
|
||||
if (typeof iconName === 'string') iconName = iconName.trim();
|
||||
// 如果没有图标名称,返回 Avatar
|
||||
if (!iconName) {
|
||||
return <Avatar size='extra-extra-small'>?</Avatar>;
|
||||
return (
|
||||
<Avatar size={size} gap={0} style={{ fontSize: size * 0.65 }}>
|
||||
?
|
||||
</Avatar>
|
||||
);
|
||||
}
|
||||
|
||||
// 解析组件路径与点号链式属性
|
||||
@@ -115,7 +119,11 @@ export default function LobeHubIcon({ iconName, size = 14 }) {
|
||||
(typeof IconComponent !== 'function' && typeof IconComponent !== 'object')
|
||||
) {
|
||||
const firstLetter = String(iconName).charAt(0).toUpperCase();
|
||||
return <Avatar size='extra-extra-small'>{firstLetter}</Avatar>;
|
||||
return (
|
||||
<Avatar size={size} gap={0} style={{ fontSize: size * 0.65 }}>
|
||||
{firstLetter}
|
||||
</Avatar>
|
||||
);
|
||||
}
|
||||
|
||||
// 解析点号链式属性,形如:key={...}、key='...'、key="..."、key=123、key、key=true/false
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { Alert, Button, Checkbox, Modal, Tooltip, theme } from 'antd';
|
||||
import { Settings } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import './column-settings.css';
|
||||
|
||||
const titleText = (title) =>
|
||||
React.Children.toArray(title)
|
||||
.map((child) =>
|
||||
React.isValidElement(child) ? titleText(child.props.children) : child,
|
||||
)
|
||||
.join('');
|
||||
|
||||
const columnOptions = (columns) =>
|
||||
columns.map((column) => ({
|
||||
value: column.key,
|
||||
label: column.label ?? titleText(column.title),
|
||||
disabled: column.disabled,
|
||||
}));
|
||||
|
||||
const selectedKeys = (options, value) =>
|
||||
options
|
||||
.filter((option) => value.includes(option.value))
|
||||
.map((option) => option.value);
|
||||
|
||||
export function ColumnSettingsButton({ onClick, open = false }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Tooltip title={t('列设置')}>
|
||||
<Button
|
||||
className='table-column-settings-trigger'
|
||||
type='text'
|
||||
size='middle'
|
||||
aria-label={t('列设置')}
|
||||
aria-haspopup='dialog'
|
||||
aria-expanded={open}
|
||||
icon={<Settings size={16} />}
|
||||
onClick={onClick}
|
||||
/>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
export function ColumnSettingsModal({
|
||||
open,
|
||||
onCancel,
|
||||
columns,
|
||||
value,
|
||||
defaultValue,
|
||||
onConfirm,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const { token } = theme.useToken();
|
||||
const options = columnOptions(columns);
|
||||
const [session, setSession] = useState({
|
||||
open: false,
|
||||
draft: [],
|
||||
error: false,
|
||||
});
|
||||
|
||||
// Snapshot on opening only: background table refreshes must not reset the draft.
|
||||
if (session.open !== open) {
|
||||
setSession({ open, draft: selectedKeys(options, value), error: false });
|
||||
}
|
||||
const draft = selectedKeys(options, session.draft);
|
||||
const selectable = options.filter((option) => !option.disabled);
|
||||
const checkedCount = selectable.filter((option) =>
|
||||
draft.includes(option.value),
|
||||
).length;
|
||||
const changeDraft = (keys) => setSession({ open, draft: keys, error: false });
|
||||
const confirm = () => {
|
||||
if (!draft.length) {
|
||||
setSession({ ...session, error: true });
|
||||
return;
|
||||
}
|
||||
onConfirm(draft);
|
||||
onCancel();
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
open={open}
|
||||
title={t('列设置')}
|
||||
width={520}
|
||||
rootClassName='table-column-settings'
|
||||
className='table-column-settings-dialog'
|
||||
style={{
|
||||
'--cs-theme-text': token.colorText,
|
||||
'--cs-theme-border': token.colorBorderSecondary,
|
||||
}}
|
||||
onCancel={onCancel}
|
||||
maskClosable
|
||||
keyboard
|
||||
footer={
|
||||
<div className='table-column-settings-footer'>
|
||||
<Button
|
||||
onClick={() => changeDraft(selectedKeys(options, defaultValue))}
|
||||
>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
<Button onClick={onCancel}>{t('取消')}</Button>
|
||||
<Button type='primary' onClick={confirm}>
|
||||
{t('确定')}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className='table-column-settings-all'>
|
||||
<Checkbox
|
||||
checked={selectable.length > 0 && checkedCount === selectable.length}
|
||||
indeterminate={checkedCount > 0 && checkedCount < selectable.length}
|
||||
disabled={!selectable.length}
|
||||
onChange={(event) =>
|
||||
changeDraft(
|
||||
options
|
||||
.filter((option) =>
|
||||
option.disabled
|
||||
? draft.includes(option.value)
|
||||
: event.target.checked,
|
||||
)
|
||||
.map((option) => option.value),
|
||||
)
|
||||
}
|
||||
>
|
||||
{t('全选')}
|
||||
</Checkbox>
|
||||
</div>
|
||||
<Checkbox.Group
|
||||
className='table-column-settings-grid'
|
||||
options={options}
|
||||
value={draft}
|
||||
onChange={changeDraft}
|
||||
/>
|
||||
{session.error && (
|
||||
<Alert
|
||||
className='table-column-settings-error'
|
||||
type='error'
|
||||
showIcon
|
||||
message={t('请至少保留一列')}
|
||||
/>
|
||||
)}
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
export function ColumnVisibilitySettings({
|
||||
showColumnSelector,
|
||||
setShowColumnSelector,
|
||||
columns,
|
||||
visibleColumns,
|
||||
setVisibleColumns,
|
||||
getDefaultColumnVisibility,
|
||||
}) {
|
||||
const defaults = getDefaultColumnVisibility();
|
||||
return (
|
||||
<ColumnSettingsModal
|
||||
open={showColumnSelector}
|
||||
onCancel={() => setShowColumnSelector(false)}
|
||||
columns={columns}
|
||||
value={columns
|
||||
.filter((column) => visibleColumns[column.key])
|
||||
.map((column) => column.key)}
|
||||
defaultValue={columns
|
||||
.filter((column) => defaults[column.key])
|
||||
.map((column) => column.key)}
|
||||
onConfirm={(keys) =>
|
||||
setVisibleColumns((current) => ({
|
||||
...current,
|
||||
...Object.fromEntries(
|
||||
columns.map((column) => [column.key, keys.includes(column.key)]),
|
||||
),
|
||||
}))
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default function TableColumnSettings({
|
||||
columns,
|
||||
value,
|
||||
defaultValue,
|
||||
onChange,
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<ColumnSettingsButton open={open} onClick={() => setOpen(true)} />
|
||||
<ColumnSettingsModal
|
||||
open={open}
|
||||
onCancel={() => setOpen(false)}
|
||||
columns={columns}
|
||||
value={value}
|
||||
defaultValue={defaultValue}
|
||||
onConfirm={onChange}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Button } from 'antd';
|
||||
import { Search } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import './filter-search-button.css';
|
||||
|
||||
export default function FilterSearchButton({
|
||||
loading,
|
||||
htmlType = 'submit',
|
||||
onClick,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Button
|
||||
className='filter-search-button'
|
||||
type='primary'
|
||||
htmlType={htmlType}
|
||||
onClick={onClick}
|
||||
size='middle'
|
||||
loading={loading}
|
||||
icon={<Search size={14} />}
|
||||
>
|
||||
{t('搜索')}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useLayoutEffect, useRef, useState } from 'react';
|
||||
import { Empty } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import './table-empty.css';
|
||||
|
||||
export default function TableEmpty() {
|
||||
const { t } = useTranslation();
|
||||
const ref = useRef(null);
|
||||
const [width, setWidth] = useState(undefined);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const viewport = ref.current?.closest('.ant-table-container');
|
||||
if (!viewport) return;
|
||||
// Keep the empty state centered in the visible area of a wide, scrollable table.
|
||||
const resize = () => setWidth(viewport.clientWidth || undefined);
|
||||
resize();
|
||||
const observer = new ResizeObserver(resize);
|
||||
observer.observe(viewport);
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div ref={ref} className='table-empty-state' style={{ width }}>
|
||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={t('暂无数据')} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import './table-toolbar.css';
|
||||
|
||||
export function TableTitle({ children }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<h2 className='table-toolbar-title'>
|
||||
{typeof children === 'string' ? t(children) : children}
|
||||
</h2>
|
||||
);
|
||||
}
|
||||
|
||||
export default function TableToolbar({ title, children }) {
|
||||
return (
|
||||
<div className='table-toolbar'>
|
||||
<TableTitle>{title}</TableTitle>
|
||||
{children && <div className='table-toolbar-actions'>{children}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
.table-column-settings {
|
||||
--cs-mask: rgba(0, 0, 0, 0.3);
|
||||
--cs-text: rgba(0, 0, 0, 0.88);
|
||||
--cs-border: #e9edf2;
|
||||
--cs-space: 8px;
|
||||
--cs-column-gap: 20px;
|
||||
--cs-row-gap: 16px;
|
||||
}
|
||||
|
||||
html.dark .table-column-settings-dialog {
|
||||
--cs-text: var(--cs-theme-text);
|
||||
--cs-border: var(--cs-theme-border);
|
||||
}
|
||||
|
||||
.table-column-settings .ant-modal-mask {
|
||||
background: var(--cs-mask);
|
||||
backdrop-filter: blur(4px);
|
||||
}
|
||||
|
||||
.table-column-settings-dialog.ant-modal {
|
||||
max-width: calc(100vw - 32px);
|
||||
}
|
||||
|
||||
.table-column-settings-dialog .ant-modal-content {
|
||||
padding: 20px 24px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.table-column-settings-dialog .ant-modal-header {
|
||||
margin-bottom: var(--cs-space);
|
||||
}
|
||||
|
||||
.table-column-settings-dialog .ant-modal-title {
|
||||
color: var(--cs-text);
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
.table-column-settings-dialog .ant-modal-body {
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.table-column-settings-all {
|
||||
padding: 14px 0;
|
||||
margin-bottom: 18px;
|
||||
border-bottom: 1px solid var(--cs-border);
|
||||
}
|
||||
|
||||
.table-column-settings-grid.ant-checkbox-group {
|
||||
display: grid;
|
||||
width: 100%;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--cs-row-gap) var(--cs-column-gap);
|
||||
padding: 4px 0 12px;
|
||||
}
|
||||
|
||||
.table-column-settings-dialog .ant-checkbox-wrapper {
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
color: var(--cs-text);
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.table-column-settings-dialog .ant-checkbox-inner {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.table-column-settings-dialog .ant-modal-footer {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.table-column-settings-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--cs-space);
|
||||
}
|
||||
|
||||
.table-column-settings-footer .ant-btn {
|
||||
height: 34px;
|
||||
margin: 0;
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.table-column-settings-footer .ant-btn-default {
|
||||
color: var(--cs-text);
|
||||
}
|
||||
|
||||
.table-column-settings-error {
|
||||
margin-top: var(--cs-row-gap);
|
||||
}
|
||||
|
||||
.table-column-settings-trigger.ant-btn {
|
||||
flex: 0 0 auto;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
.table-column-toolbar {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
@media (max-width: 575px) {
|
||||
.table-column-settings-grid.ant-checkbox-group {
|
||||
gap: 14px 10px;
|
||||
}
|
||||
|
||||
.table-column-settings-dialog .ant-checkbox-wrapper {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
.console-page .filter-search-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.console-page .filter-search-button > .ant-btn-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.console-page .filter-search-button .lucide {
|
||||
display: block;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/* Match the consumption record's labels, grid and action placement. */
|
||||
.log-filter-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
width: 100%;
|
||||
}
|
||||
.log-filter-wide {
|
||||
grid-column: span 2;
|
||||
}
|
||||
.log-filter-form .ant-form-item {
|
||||
min-width: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.log-filter-form .ant-form-item-label {
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
.log-filter-form .ant-form-item-label > label {
|
||||
height: 21px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
.log-filter-form :is(.ant-picker, .ant-select) {
|
||||
width: 100%;
|
||||
}
|
||||
.log-filter-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
.log-filter-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
width: 100%;
|
||||
}
|
||||
.console-page .console-search-card .log-filter-form {
|
||||
display: block;
|
||||
}
|
||||
.console-page .log-filter-form .ant-form-item-label > label {
|
||||
height: 21px;
|
||||
font-size: 13px;
|
||||
line-height: 21px;
|
||||
}
|
||||
@media (max-width: 1200px) {
|
||||
.log-filter-grid {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
.log-filter-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
.log-filter-wide {
|
||||
grid-column: auto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
.ant-table-wrapper
|
||||
.ant-table
|
||||
.ant-table-tbody
|
||||
> .ant-table-placeholder:has(.table-empty-state)
|
||||
> td.ant-table-cell {
|
||||
padding: 0;
|
||||
height: 172px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.ant-table-wrapper .ant-table-expanded-row-fixed:has(> .table-empty-state) {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.table-empty-state {
|
||||
position: sticky;
|
||||
left: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
height: 172px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.table-empty-state > .ant-empty,
|
||||
.ant-table-wrapper .ant-table-placeholder .table-empty-state > .ant-empty {
|
||||
margin: 0;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
.table-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
min-height: 34px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
h2.table-toolbar-title {
|
||||
flex-shrink: 0;
|
||||
margin: 0;
|
||||
color: var(--console-heading, var(--uc-heading, var(--ui-color-text-0)));
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
line-height: 1.5714;
|
||||
}
|
||||
|
||||
.table-toolbar-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
.console-page .table-toolbar .ant-btn:not(.ant-btn-link):not(.ant-btn-text) {
|
||||
min-height: var(--console-control-height);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.console-list-toolbar .console-list-actions-offset {
|
||||
margin-inline-start: 20px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.console-list-toolbar .console-list-actions-offset {
|
||||
flex-basis: calc(100% - 20px);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,9 @@ import { Card, Divider, Button } from '@/components/ui';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
||||
import { IconEyeOpened, IconEyeClosed } from '@/components/ui/icons';
|
||||
import { useConsolePage } from '../../console/ConsoleContext';
|
||||
import ConsoleCollection from '../../console/ConsoleCollection';
|
||||
import TableToolbar from '../table/TableToolbar';
|
||||
|
||||
/**
|
||||
* CardPro 高级卡片组件
|
||||
@@ -49,6 +52,9 @@ const CardPro = ({
|
||||
tabsArea,
|
||||
actionsArea,
|
||||
searchArea,
|
||||
tableActions,
|
||||
tableTitle,
|
||||
tableActionsOffset = false,
|
||||
paginationArea, // 新增分页区域
|
||||
// 卡片属性
|
||||
shadows,
|
||||
@@ -59,6 +65,7 @@ const CardPro = ({
|
||||
t = (key) => key,
|
||||
...props
|
||||
}) => {
|
||||
const consolePage = useConsolePage();
|
||||
const isMobile = useIsMobile();
|
||||
const [showMobileActions, setShowMobileActions] = useState(false);
|
||||
|
||||
@@ -156,6 +163,24 @@ const CardPro = ({
|
||||
|
||||
const footerContent = renderFooter();
|
||||
|
||||
if (consolePage) {
|
||||
return (
|
||||
<ConsoleCollection
|
||||
statsArea={statsArea}
|
||||
descriptionArea={descriptionArea}
|
||||
tabsArea={tabsArea}
|
||||
actionsArea={actionsArea}
|
||||
searchArea={searchArea}
|
||||
tableActions={tableActions}
|
||||
tableTitle={tableTitle}
|
||||
tableActionsOffset={tableActionsOffset}
|
||||
paginationArea={paginationArea}
|
||||
>
|
||||
{children}
|
||||
</ConsoleCollection>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Card
|
||||
className={`table-scroll-card !rounded-2xl ${className}`}
|
||||
@@ -166,6 +191,11 @@ const CardPro = ({
|
||||
style={style}
|
||||
{...props}
|
||||
>
|
||||
{tableTitle ? (
|
||||
<TableToolbar title={tableTitle}>{tableActions}</TableToolbar>
|
||||
) : tableActions ? (
|
||||
<div className='table-column-toolbar'>{tableActions}</div>
|
||||
) : null}
|
||||
{children}
|
||||
</Card>
|
||||
);
|
||||
@@ -188,6 +218,9 @@ CardPro.propTypes = {
|
||||
PropTypes.arrayOf(PropTypes.node),
|
||||
]),
|
||||
searchArea: PropTypes.node,
|
||||
tableActions: PropTypes.node,
|
||||
tableTitle: PropTypes.node,
|
||||
tableActionsOffset: PropTypes.bool,
|
||||
paginationArea: PropTypes.node,
|
||||
// 表格内容
|
||||
children: PropTypes.node,
|
||||
|
||||
@@ -33,6 +33,7 @@ import { IconChevronDown, IconChevronUp } from '@/components/ui/icons';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
||||
import { useMinimumLoadingTime } from '../../../hooks/common/useMinimumLoadingTime';
|
||||
import { useConsolePage } from '../../console/ConsoleContext';
|
||||
|
||||
/**
|
||||
* CardTable 响应式表格组件
|
||||
@@ -48,6 +49,7 @@ const CardTable = ({
|
||||
hidePagination = false,
|
||||
...tableProps
|
||||
}) => {
|
||||
const consolePage = useConsolePage();
|
||||
const isMobile = useIsMobile();
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -103,7 +105,7 @@ const CardTable = ({
|
||||
selectableKeys.length > 0 &&
|
||||
selectableKeys.every((key) => selectedKeys.includes(key));
|
||||
|
||||
if (!isMobile) {
|
||||
if (!isMobile || consolePage) {
|
||||
const finalTableProps = hidePagination
|
||||
? { ...tableProps, pagination: false }
|
||||
: tableProps;
|
||||
|
||||
@@ -20,7 +20,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Card, Button, Typography, Tag } from '@/components/ui';
|
||||
import { copy, showSuccess } from '../../../helpers';
|
||||
import { copy, showError, showSuccess } from '../../../helpers';
|
||||
|
||||
/**
|
||||
* 解析密钥数据,支持多种格式
|
||||
@@ -95,14 +95,14 @@ const ChannelKeyDisplay = ({
|
||||
const parsedKeys = parseChannelKeys(keyData, t);
|
||||
const isMultipleKeys = parsedKeys.length > 1;
|
||||
|
||||
const handleCopyAll = () => {
|
||||
copy(keyData);
|
||||
showSuccess(t('所有密钥已复制到剪贴板'));
|
||||
const handleCopyAll = async () => {
|
||||
if (await copy(keyData)) showSuccess(t('所有密钥已复制到剪贴板'));
|
||||
else showError(t('复制失败,请手动复制'));
|
||||
};
|
||||
|
||||
const handleCopyKey = (content) => {
|
||||
copy(content);
|
||||
showSuccess(t('密钥已复制到剪贴板'));
|
||||
const handleCopyKey = async (content) => {
|
||||
if (await copy(content)) showSuccess(t('密钥已复制到剪贴板'));
|
||||
else showError(t('复制失败,请手动复制'));
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -21,6 +21,7 @@ import React from 'react';
|
||||
import { Button } from '@/components/ui';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
||||
import { useConsolePage } from '../../console/ConsoleContext';
|
||||
|
||||
/**
|
||||
* 紧凑模式切换按钮组件
|
||||
@@ -37,9 +38,10 @@ const CompactModeToggle = ({
|
||||
...props
|
||||
}) => {
|
||||
const isMobile = useIsMobile();
|
||||
const consolePage = useConsolePage();
|
||||
|
||||
// 在移动端隐藏紧凑列表切换按钮
|
||||
if (isMobile) {
|
||||
// Console lists keep their stored density, but no longer expose a toggle.
|
||||
if (isMobile || consolePage) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ const JSONEditor = ({
|
||||
template,
|
||||
templateLabel,
|
||||
editorType = 'keyValue',
|
||||
objectValueAutoSize,
|
||||
rules = [],
|
||||
formApi = null,
|
||||
...props
|
||||
@@ -368,6 +369,7 @@ const JSONEditor = ({
|
||||
return (
|
||||
<TextArea
|
||||
rows={2}
|
||||
autosize={objectValueAutoSize}
|
||||
value={JSON.stringify(value, null, 2)}
|
||||
onChange={(txt) => {
|
||||
try {
|
||||
@@ -407,7 +409,7 @@ const JSONEditor = ({
|
||||
// 渲染键值对编辑器
|
||||
const renderKeyValueEditor = () => {
|
||||
return (
|
||||
<div className='space-y-1'>
|
||||
<div className='json-editor-pairs space-y-1'>
|
||||
{/* 重复键警告 */}
|
||||
{duplicateKeys.size > 0 && (
|
||||
<Banner
|
||||
@@ -442,7 +444,12 @@ const JSONEditor = ({
|
||||
keyValuePairs.slice(index + 1).every((p) => p.key !== pair.key);
|
||||
|
||||
return (
|
||||
<Row key={pair.id} gutter={8} align='middle'>
|
||||
<Row
|
||||
key={pair.id}
|
||||
gutter={8}
|
||||
align='middle'
|
||||
className='json-editor-pair'
|
||||
>
|
||||
<Col span={10}>
|
||||
<div className='relative'>
|
||||
<Input
|
||||
@@ -486,7 +493,7 @@ const JSONEditor = ({
|
||||
);
|
||||
})}
|
||||
|
||||
<div className='mt-2 flex justify-center'>
|
||||
<div className='json-editor-add mt-2 flex justify-center'>
|
||||
<Button
|
||||
icon={<IconPlus />}
|
||||
type='primary'
|
||||
@@ -568,7 +575,10 @@ const JSONEditor = ({
|
||||
<Tooltip content={t('重复的键名')}>
|
||||
<IconAlertTriangle
|
||||
className='absolute right-2 top-1/2 transform -translate-y-1/2'
|
||||
style={{ color: 'var(--ui-color-warning)', fontSize: '14px' }}
|
||||
style={{
|
||||
color: 'var(--ui-color-warning)',
|
||||
fontSize: '14px',
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
)}
|
||||
@@ -628,8 +638,9 @@ const JSONEditor = ({
|
||||
<Form.Slot label={label}>
|
||||
<Card
|
||||
header={
|
||||
<div className='flex justify-between items-center'>
|
||||
<div className='json-editor-header flex justify-between items-center'>
|
||||
<Tabs
|
||||
className='json-editor-tabs'
|
||||
type='slash'
|
||||
activeKey={editMode}
|
||||
onChange={(key) => {
|
||||
@@ -651,7 +662,9 @@ const JSONEditor = ({
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
headerStyle={{ padding: '12px 16px' }}
|
||||
headerStyle={{
|
||||
padding: 'var(--json-editor-header-padding, 12px 16px)',
|
||||
}}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
className='!rounded-2xl'
|
||||
>
|
||||
@@ -670,6 +683,7 @@ const JSONEditor = ({
|
||||
{renderVisualEditor()}
|
||||
{/* 隐藏的Form字段用于验证和数据绑定 */}
|
||||
<Form.Input
|
||||
className='json-editor-bound-field'
|
||||
field={field}
|
||||
value={value}
|
||||
rules={rules}
|
||||
@@ -689,6 +703,7 @@ const JSONEditor = ({
|
||||
/>
|
||||
{/* 隐藏的Form字段用于验证和数据绑定 */}
|
||||
<Form.Input
|
||||
className='json-editor-bound-field'
|
||||
field={field}
|
||||
value={value}
|
||||
rules={rules}
|
||||
@@ -701,7 +716,7 @@ const JSONEditor = ({
|
||||
|
||||
{/* 额外文本显示在卡片底部 */}
|
||||
{extraText && (
|
||||
<Divider margin='12px' align='center'>
|
||||
<Divider margin='var(--json-editor-note-margin, 12px)' align='center'>
|
||||
<Text type='tertiary' size='small'>
|
||||
{extraText}
|
||||
</Text>
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { Button } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useIsMobile } from '../../hooks/common/useIsMobile';
|
||||
import { ConsoleCard, ConsoleSearchBar } from './ConsolePrimitives';
|
||||
import { TableTitle } from '../common/table/TableToolbar';
|
||||
|
||||
export default function ConsoleCollection({
|
||||
children,
|
||||
statsArea,
|
||||
descriptionArea,
|
||||
tabsArea,
|
||||
actionsArea,
|
||||
searchArea,
|
||||
tableActions,
|
||||
tableTitle,
|
||||
tableActionsOffset = false,
|
||||
paginationArea,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const isMobile = useIsMobile();
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const showSearch = !isMobile || expanded;
|
||||
return (
|
||||
<div className='console-collection'>
|
||||
{statsArea && (
|
||||
<ConsoleCard className='console-stats'>{statsArea}</ConsoleCard>
|
||||
)}
|
||||
{searchArea && (
|
||||
<>
|
||||
{isMobile && (
|
||||
<Button
|
||||
onClick={() => setExpanded(!expanded)}
|
||||
aria-expanded={expanded}
|
||||
>
|
||||
{t(expanded ? '隐藏操作项' : '显示操作项')}
|
||||
</Button>
|
||||
)}
|
||||
<ConsoleSearchBar hidden={!showSearch}>{searchArea}</ConsoleSearchBar>
|
||||
</>
|
||||
)}
|
||||
<ConsoleCard>
|
||||
{tabsArea && <div className='console-list-tabs'>{tabsArea}</div>}
|
||||
{(tableTitle || descriptionArea || actionsArea || tableActions) && (
|
||||
<div className='console-list-toolbar'>
|
||||
{tableTitle && <TableTitle>{tableTitle}</TableTitle>}
|
||||
{actionsArea && (
|
||||
<div
|
||||
className={`console-list-actions${tableActionsOffset ? ' console-list-actions-offset' : ''}`}
|
||||
>
|
||||
{actionsArea}
|
||||
</div>
|
||||
)}
|
||||
{descriptionArea && (
|
||||
<div className='console-list-description'>{descriptionArea}</div>
|
||||
)}
|
||||
{tableActions && (
|
||||
<div className='console-list-table-actions'>{tableActions}</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<div className='console-list-content'>{children}</div>
|
||||
{paginationArea && (
|
||||
<div className='console-pagination'>{paginationArea}</div>
|
||||
)}
|
||||
</ConsoleCard>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { createContext, useContext } from 'react';
|
||||
import { theme } from 'antd';
|
||||
|
||||
export function useConsoleThemeStyle() {
|
||||
const { token } = theme.useToken();
|
||||
return {
|
||||
'--console-surface': token.colorBgContainer,
|
||||
'--console-bg': token.colorBgLayout,
|
||||
'--console-heading': token.colorTextHeading,
|
||||
'--console-text': token.colorText,
|
||||
'--console-muted': token.colorTextSecondary,
|
||||
'--console-border': token.colorBorderSecondary,
|
||||
'--console-fill': token.colorFillAlter,
|
||||
'--console-primary': token.colorPrimary,
|
||||
};
|
||||
}
|
||||
|
||||
export const ConsoleContext = createContext(null);
|
||||
export const useConsolePage = () => useContext(ConsoleContext);
|
||||
export const ConsoleSearchContext = createContext(false);
|
||||
export const useConsoleControlSize = (size) =>
|
||||
useContext(ConsoleSearchContext)
|
||||
? 'middle'
|
||||
: size === 'default'
|
||||
? 'middle'
|
||||
: size;
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useId } from 'react';
|
||||
import { Button } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import FilterSearchButton from '../common/table/FilterSearchButton';
|
||||
import './module-alignment.css';
|
||||
|
||||
// Labels belong to the module; this wrapper only supplies the shared layout.
|
||||
export function ConsoleFilterField({ label, children }) {
|
||||
const id = useId();
|
||||
return (
|
||||
<div className='console-module-field'>
|
||||
<label htmlFor={id}>{label}</label>
|
||||
{React.isValidElement(children)
|
||||
? React.cloneElement(children, { id })
|
||||
: children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function ConsoleFilterActions({ onReset, onSearch, loading }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className='console-module-filter-actions'>
|
||||
<Button onClick={onReset}>{t('重置')}</Button>
|
||||
<FilterSearchButton
|
||||
htmlType={onSearch ? 'button' : 'submit'}
|
||||
onClick={onSearch}
|
||||
loading={loading}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { Breadcrumb } from 'antd';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
ConsoleContext,
|
||||
useConsolePage,
|
||||
useConsoleThemeStyle,
|
||||
} from './ConsoleContext';
|
||||
import { resolveConsolePage } from './consoleRoutes';
|
||||
import './console.css';
|
||||
|
||||
export default function ConsolePageContainer({ children }) {
|
||||
const { pathname } = useLocation();
|
||||
const { t } = useTranslation();
|
||||
const themeStyle = useConsoleThemeStyle();
|
||||
const page = useMemo(() => resolveConsolePage(pathname), [pathname]);
|
||||
const [actionsTarget, setActionsTarget] = useState(null);
|
||||
const context = useMemo(
|
||||
() => ({ page, actionsTarget }),
|
||||
[page, actionsTarget],
|
||||
);
|
||||
|
||||
return (
|
||||
<ConsoleContext.Provider value={context}>
|
||||
<main
|
||||
className={`console-page${page.canvas ? ' console-page--canvas' : ''}`}
|
||||
data-console-page={page.key}
|
||||
style={themeStyle}
|
||||
>
|
||||
<header className='console-page-header'>
|
||||
<Breadcrumb
|
||||
className='console-breadcrumb'
|
||||
items={page.breadcrumbs.map((item, index) => ({
|
||||
key: item.path,
|
||||
title:
|
||||
index === page.breadcrumbs.length - 1 ? (
|
||||
<span aria-current='page'>{t(item.title)}</span>
|
||||
) : (
|
||||
<Link to={item.path}>{t(item.title)}</Link>
|
||||
),
|
||||
}))}
|
||||
/>
|
||||
<div className='console-page-header-main'>
|
||||
<div className='console-page-heading'>
|
||||
<h1 className='console-page-title'>{t(page.title)}</h1>
|
||||
<p className='console-page-description'>
|
||||
{t(`consoleUi.descriptions.${page.description}`)}
|
||||
</p>
|
||||
</div>
|
||||
<div className='console-page-actions' ref={setActionsTarget} />
|
||||
</div>
|
||||
</header>
|
||||
<div className='console-page-body'>{children}</div>
|
||||
</main>
|
||||
</ConsoleContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function ConsolePageActions({ children }) {
|
||||
const context = useConsolePage();
|
||||
if (!context) return <>{children}</>;
|
||||
return context.actionsTarget
|
||||
? createPortal(children, context.actionsTarget)
|
||||
: null;
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { forwardRef } from 'react';
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Card,
|
||||
Drawer,
|
||||
Empty,
|
||||
Form,
|
||||
Modal,
|
||||
Table,
|
||||
Tabs,
|
||||
theme,
|
||||
} from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
ConsoleSearchContext,
|
||||
useConsolePage,
|
||||
useConsoleThemeStyle,
|
||||
} from './ConsoleContext';
|
||||
|
||||
const classes = (base, extra) => [base, extra].filter(Boolean).join(' ');
|
||||
|
||||
export function ConsoleAlert({ className, style, type = 'info', ...props }) {
|
||||
const { token } = theme.useToken();
|
||||
const semantic = type[0].toUpperCase() + type.slice(1);
|
||||
return (
|
||||
<Alert
|
||||
{...props}
|
||||
type={type}
|
||||
showIcon
|
||||
className={classes('console-alert', className)}
|
||||
style={{
|
||||
...style,
|
||||
marginBlock: style?.marginBlock ?? '0 16px',
|
||||
padding: '12px 16px',
|
||||
borderRadius: token.borderRadiusLG,
|
||||
background: token[`color${semantic}Bg`],
|
||||
borderColor: token[`color${semantic}Border`],
|
||||
color: token.colorText,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export const ConsoleCard = forwardRef(function ConsoleCard(
|
||||
{ className, ...props },
|
||||
ref,
|
||||
) {
|
||||
return (
|
||||
<Card {...props} ref={ref} className={classes('console-card', className)} />
|
||||
);
|
||||
});
|
||||
|
||||
// Existing form adapters keep their value and submit contracts inside this layout.
|
||||
export function ConsoleSearchBar({ children, className, formProps, ...props }) {
|
||||
return (
|
||||
<ConsoleCard
|
||||
{...props}
|
||||
className={classes('console-search-card', className)}
|
||||
>
|
||||
<ConsoleSearchContext.Provider value={true}>
|
||||
{formProps ? (
|
||||
<ConsoleForm {...formProps}>{children}</ConsoleForm>
|
||||
) : (
|
||||
children
|
||||
)}
|
||||
</ConsoleSearchContext.Provider>
|
||||
</ConsoleCard>
|
||||
);
|
||||
}
|
||||
|
||||
export function ConsoleSearchActions({
|
||||
onReset,
|
||||
onSearch,
|
||||
loading,
|
||||
searchLabel = '搜索',
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className='console-search-actions'>
|
||||
{onReset && <Button onClick={onReset}>{t('重置')}</Button>}
|
||||
<Button
|
||||
type='primary'
|
||||
htmlType={onSearch ? 'button' : 'submit'}
|
||||
onClick={onSearch}
|
||||
loading={loading}
|
||||
>
|
||||
{t(searchLabel)}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export const ConsoleForm = forwardRef(function ConsoleForm(
|
||||
{ className, layout = 'vertical', ...props },
|
||||
ref,
|
||||
) {
|
||||
const isSettings = useConsolePage()?.page.key === 'setting';
|
||||
return (
|
||||
<Form
|
||||
{...props}
|
||||
ref={ref}
|
||||
layout={isSettings ? 'vertical' : layout}
|
||||
labelCol={isSettings ? undefined : props.labelCol}
|
||||
wrapperCol={isSettings ? undefined : props.wrapperCol}
|
||||
labelAlign={isSettings ? 'left' : props.labelAlign}
|
||||
className={classes(
|
||||
isSettings ? 'console-form settings-system-form' : 'console-form',
|
||||
className,
|
||||
)}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export const ConsoleTable = forwardRef(function ConsoleTable(
|
||||
{ className, scroll, locale, size = 'middle', ...props },
|
||||
ref,
|
||||
) {
|
||||
return (
|
||||
<Table
|
||||
{...props}
|
||||
ref={ref}
|
||||
size={size}
|
||||
scroll={{ x: 'max-content', ...scroll }}
|
||||
locale={{
|
||||
emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />,
|
||||
...locale,
|
||||
}}
|
||||
className={classes('console-table', className)}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export function ConsoleTabs({ className, ...props }) {
|
||||
return <Tabs {...props} className={classes('console-tabs', className)} />;
|
||||
}
|
||||
|
||||
const isFooterButton = (node) =>
|
||||
React.isValidElement(node) &&
|
||||
(node.type === Button || node.type?.render?.name === 'Button');
|
||||
const isPrimaryAction = ({ props }) =>
|
||||
props.theme === 'solid' ||
|
||||
props.danger ||
|
||||
props.type === 'danger' ||
|
||||
(props.type === 'primary' &&
|
||||
!['light', 'outline', 'borderless'].includes(props.theme));
|
||||
|
||||
// Reorder only groups composed entirely of buttons; preserve mixed footer content.
|
||||
function normalizeFooter(footer) {
|
||||
if (!footer || typeof footer === 'function') return footer;
|
||||
const nodes = React.Children.toArray(footer);
|
||||
if (nodes.length > 1 && nodes.every(isFooterButton)) {
|
||||
return [
|
||||
...nodes.filter((node) => !isPrimaryAction(node)),
|
||||
...nodes.filter(isPrimaryAction),
|
||||
];
|
||||
}
|
||||
const normalized = nodes.map((node) =>
|
||||
React.isValidElement(node) && !isFooterButton(node) && node.props.children
|
||||
? React.cloneElement(
|
||||
node,
|
||||
undefined,
|
||||
normalizeFooter(node.props.children),
|
||||
)
|
||||
: node,
|
||||
);
|
||||
return Array.isArray(footer) ? normalized : normalized[0];
|
||||
}
|
||||
|
||||
export function ConsoleModal({
|
||||
rootClassName,
|
||||
style,
|
||||
footer,
|
||||
width = 560,
|
||||
...props
|
||||
}) {
|
||||
const themeStyle = useConsoleThemeStyle();
|
||||
const isSettings = useConsolePage()?.page.key === 'setting';
|
||||
return (
|
||||
<Modal
|
||||
{...props}
|
||||
width={width}
|
||||
style={{ ...themeStyle, ...style }}
|
||||
footer={normalizeFooter(footer)}
|
||||
rootClassName={classes(
|
||||
isSettings ? 'console-overlay settings-form-dialog' : 'console-overlay',
|
||||
rootClassName,
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function ConsoleDrawer({
|
||||
rootClassName,
|
||||
rootStyle,
|
||||
footer,
|
||||
width = 560,
|
||||
...props
|
||||
}) {
|
||||
const themeStyle = useConsoleThemeStyle();
|
||||
const isSettings = useConsolePage()?.page.key === 'setting';
|
||||
return (
|
||||
<Drawer
|
||||
{...props}
|
||||
width={width}
|
||||
rootStyle={{ ...themeStyle, ...rootStyle }}
|
||||
footer={normalizeFooter(footer)}
|
||||
rootClassName={classes(
|
||||
isSettings
|
||||
? 'console-overlay console-drawer settings-form-dialog'
|
||||
: 'console-overlay console-drawer',
|
||||
rootClassName,
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,446 @@
|
||||
.console-page,
|
||||
.console-overlay {
|
||||
--console-space-1: 8px;
|
||||
--console-space-2: 16px;
|
||||
--console-space-3: 24px;
|
||||
--console-gap: var(--console-space-2);
|
||||
--console-radius: 10px;
|
||||
--console-control-height: 34px;
|
||||
}
|
||||
.console-page {
|
||||
min-width: 0;
|
||||
min-height: 100dvh;
|
||||
padding: calc(
|
||||
var(--console-header-offset, 72px) + var(--uc-page-pad-top, 30px)
|
||||
)
|
||||
var(--uc-page-pad-x, 36px) var(--uc-page-pad-bottom, 36px);
|
||||
background: var(--uc-page-bg, var(--console-bg));
|
||||
color: var(--console-text);
|
||||
}
|
||||
.console-page-header {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.console-page .console-breadcrumb.ant-breadcrumb {
|
||||
margin-bottom: var(--console-space-3);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.console-breadcrumb .ant-breadcrumb-separator {
|
||||
margin-inline: 10px;
|
||||
}
|
||||
.console-page .console-breadcrumb :is(ol, li, a, .ant-breadcrumb-link) {
|
||||
line-height: 18px;
|
||||
}
|
||||
.console-page-header-main {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--console-space-2);
|
||||
}
|
||||
.console-page-heading {
|
||||
min-width: 0;
|
||||
}
|
||||
.console-page-title {
|
||||
margin: 0;
|
||||
color: var(--console-heading);
|
||||
font-size: 28px;
|
||||
line-height: 32px;
|
||||
font-weight: 650;
|
||||
letter-spacing: -0.6px;
|
||||
}
|
||||
.console-page-description {
|
||||
margin: 6px 0 0;
|
||||
color: var(--console-muted);
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
}
|
||||
.console-page-actions,
|
||||
.console-list-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--console-space-1);
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
.console-page-actions:empty {
|
||||
display: none;
|
||||
}
|
||||
.console-page-body,
|
||||
.console-content,
|
||||
.console-collection {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--console-gap);
|
||||
min-width: 0;
|
||||
}
|
||||
.console-page-body > *,
|
||||
.console-page .ant-layout,
|
||||
.console-page .ant-layout-content,
|
||||
.console-page .ant-tabs-content-holder,
|
||||
.console-page .ant-tabs-tabpane,
|
||||
.console-page .ant-col,
|
||||
.console-page .ant-space-item {
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
.console-page .console-card.ant-card {
|
||||
border: 1px solid var(--console-border);
|
||||
border-radius: var(--console-radius);
|
||||
background: var(--console-surface);
|
||||
box-shadow: none;
|
||||
}
|
||||
.console-page .console-card > .ant-card-body {
|
||||
padding: var(--console-space-3);
|
||||
}
|
||||
.console-page .console-card > .ant-card-head {
|
||||
min-height: 56px;
|
||||
padding-inline: var(--console-space-3);
|
||||
border-color: var(--console-border);
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.console-list-tabs,
|
||||
.console-list-toolbar {
|
||||
margin-bottom: var(--console-space-2);
|
||||
}
|
||||
.console-list-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--console-space-2);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.console-list-toolbar .console-list-actions {
|
||||
flex: 1;
|
||||
}
|
||||
.console-list-description {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
.console-list-table-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: var(--console-space-1);
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
.console-page
|
||||
.console-list-toolbar
|
||||
.ant-btn:not(.ant-btn-link):not(.ant-btn-text) {
|
||||
min-height: var(--console-control-height);
|
||||
font-size: 14px;
|
||||
}
|
||||
.console-page .console-search-card .usage-logs-filter-form {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
}
|
||||
.console-page .usage-logs-filter-title-icon {
|
||||
display: none;
|
||||
}
|
||||
.console-task-stats {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: var(--console-space-2);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.console-page .usage-record-filter-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: var(--console-space-2);
|
||||
width: 100%;
|
||||
}
|
||||
.console-page .usage-record-filter-wide {
|
||||
grid-column: span 2;
|
||||
}
|
||||
.console-page
|
||||
.usage-record-filter-grid
|
||||
:is(.ant-picker, .ant-select, .ant-input-affix-wrapper) {
|
||||
width: 100%;
|
||||
}
|
||||
.console-page .usage-record-filter-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--console-space-1);
|
||||
width: 100%;
|
||||
}
|
||||
.console-pagination {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
margin-top: var(--console-space-2);
|
||||
gap: var(--console-space-1);
|
||||
}
|
||||
:is(.console-page, .console-overlay) .console-form .ant-form-item {
|
||||
margin-bottom: var(--console-space-3);
|
||||
}
|
||||
:is(.console-page, .console-overlay) .console-form .ant-form-item-label {
|
||||
padding-bottom: var(--console-space-1);
|
||||
}
|
||||
:is(.console-page, .console-overlay)
|
||||
.console-form
|
||||
.ant-form-item-label
|
||||
> label {
|
||||
color: var(--console-muted);
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
}
|
||||
.console-search-card[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.console-page .console-search-card .ant-form,
|
||||
.console-search-fields {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--console-space-2);
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
}
|
||||
.console-search-card .ant-select {
|
||||
width: 100%;
|
||||
}
|
||||
.console-search-fields > .console-search-field {
|
||||
flex: 1 1 200px;
|
||||
min-width: 0;
|
||||
}
|
||||
.console-search-card .ant-form > .flex {
|
||||
width: 100%;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--console-space-2);
|
||||
}
|
||||
.console-page .console-search-card .usage-logs-filter-content {
|
||||
width: 100%;
|
||||
}
|
||||
.console-page .console-search-card .ant-form-item {
|
||||
margin: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
.console-search-card .console-search-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex: 0 0 auto;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--console-space-1);
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
.console-page .console-table .ant-table-thead > tr > th {
|
||||
background: var(--console-fill);
|
||||
color: var(--console-muted);
|
||||
font-weight: 500;
|
||||
}
|
||||
.console-page .console-table .ant-table-cell {
|
||||
border-color: var(--console-border);
|
||||
}
|
||||
.console-page .console-table .ant-table-pagination {
|
||||
margin: var(--console-space-2) 0 0;
|
||||
}
|
||||
.console-page .console-tabs > .ant-tabs-nav {
|
||||
margin-bottom: var(--console-space-2);
|
||||
}
|
||||
.console-page .ant-tabs-tab .lucide,
|
||||
.console-page .ant-btn .lucide {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
:is(.console-page, .console-overlay) .console-create-action.ant-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
:is(.console-page, .console-overlay)
|
||||
.console-create-action.ant-btn
|
||||
.ant-btn-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
:is(.console-page, .console-overlay)
|
||||
.console-create-action.ant-btn
|
||||
.ant-btn-icon
|
||||
svg {
|
||||
display: block;
|
||||
}
|
||||
.console-page .ant-alert,
|
||||
.console-overlay .console-alert {
|
||||
align-items: flex-start;
|
||||
padding: 12px 16px;
|
||||
border-radius: var(--console-radius);
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
}
|
||||
:is(.console-page, .console-overlay) .ant-alert-content {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
:is(.console-page, .console-overlay) .ant-alert-message,
|
||||
:is(.console-page, .console-overlay) .ant-alert-description {
|
||||
color: var(--console-text);
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
}
|
||||
:is(.console-page, .console-overlay) .ant-alert-message {
|
||||
margin-bottom: 0;
|
||||
font-weight: 500;
|
||||
}
|
||||
:is(.console-page, .console-overlay)
|
||||
.ant-alert-message
|
||||
+ .ant-alert-description {
|
||||
margin-top: 4px;
|
||||
}
|
||||
:is(.console-page, .console-overlay) .ant-alert-icon {
|
||||
margin: 3px 10px 0 0;
|
||||
font-size: 16px;
|
||||
}
|
||||
:is(.console-page, .console-overlay) .ant-alert-action {
|
||||
margin-inline-start: 16px;
|
||||
}
|
||||
.console-page .ant-alert + .ant-alert {
|
||||
margin-top: 16px;
|
||||
}
|
||||
.console-page .console-table .ant-btn-link {
|
||||
padding-inline: var(--console-space-1);
|
||||
}
|
||||
.console-page .console-table .ant-empty {
|
||||
margin-block: 32px;
|
||||
}
|
||||
.console-overlay .ant-modal-title,
|
||||
.console-overlay .ant-drawer-title {
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.console-overlay .ant-drawer-body {
|
||||
padding: 24px;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
.console-overlay .ant-drawer-content-wrapper {
|
||||
max-width: 100vw;
|
||||
}
|
||||
.console-overlay .ant-modal-footer,
|
||||
.console-overlay .ant-drawer-footer,
|
||||
.console-dialog-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
.console-overlay .ant-modal-footer > .ant-btn + .ant-btn {
|
||||
margin-inline-start: 0;
|
||||
}
|
||||
.console-page--canvas .console-page-body {
|
||||
height: max(480px, calc(100dvh - var(--console-header-offset, 72px) - 216px));
|
||||
}
|
||||
.console-page .settings-page {
|
||||
overflow: visible;
|
||||
}
|
||||
.console-page .website-settings-page {
|
||||
padding: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
.console-page :is(.console-personal, .console-recharge) {
|
||||
min-height: 0;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
}
|
||||
.console-page .console-personal {
|
||||
--ps-header-bg: var(--console-surface);
|
||||
--ps-preview-bg: var(--console-fill);
|
||||
--ps-card-shadow: none;
|
||||
}
|
||||
.console-page .console-recharge {
|
||||
--rc-wallet-bg: var(--console-surface);
|
||||
--rc-order-bg: var(--console-surface);
|
||||
--rc-card-shadow: none;
|
||||
}
|
||||
.console-page :is(.ui-personal-inner, .ui-recharge-content) {
|
||||
max-width: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.console-page .skill-platform-page,
|
||||
.console-page .expert-platform-page {
|
||||
min-height: 0;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
}
|
||||
.console-page .expert-platform-shell,
|
||||
.console-page .skill-platform-metrics,
|
||||
.console-page .skill-platform-toolbar,
|
||||
.console-page .skill-platform-grid {
|
||||
max-width: none;
|
||||
margin-inline: 0;
|
||||
}
|
||||
.console-page .skill-platform-metrics,
|
||||
.console-page .skill-platform-grid,
|
||||
.console-page .expert-metrics {
|
||||
gap: var(--console-gap);
|
||||
}
|
||||
.console-page .skill-platform-metrics article,
|
||||
.console-page .expert-metric,
|
||||
.console-page .expert-card {
|
||||
border-radius: var(--console-radius);
|
||||
background: var(--console-surface);
|
||||
box-shadow: none;
|
||||
}
|
||||
.console-chat-frame {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 480px;
|
||||
border: 0;
|
||||
border-radius: var(--console-radius);
|
||||
background: var(--console-surface);
|
||||
}
|
||||
.console-chat-loading {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--console-space-1);
|
||||
min-height: 480px;
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
.console-page {
|
||||
--console-space-3: 16px;
|
||||
padding: calc(var(--console-header-offset, 56px) + 16px) 16px 24px;
|
||||
}
|
||||
.console-page .console-breadcrumb.ant-breadcrumb {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.console-page-actions {
|
||||
width: 100%;
|
||||
}
|
||||
.console-search-fields > :not(button),
|
||||
.console-search-card .ant-form > * {
|
||||
max-width: 100%;
|
||||
}
|
||||
.console-search-card .console-search-actions {
|
||||
width: 100%;
|
||||
}
|
||||
.console-pagination .ant-pagination {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 0;
|
||||
}
|
||||
.console-page .usage-record-filter-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
.console-page .usage-record-filter-wide {
|
||||
grid-column: auto;
|
||||
}
|
||||
}
|
||||
.console-overlay .console-detail-header .ant-drawer-header-title {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
.console-overlay .console-detail-header .ant-drawer-close {
|
||||
margin-inline: 12px 0;
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
// Presentation metadata only. Route guards and feature visibility remain in App/SiderBar.
|
||||
export const consolePages = [
|
||||
{
|
||||
key: 'analytics',
|
||||
menuKey: 'detail',
|
||||
title: '数据看板',
|
||||
description: 'analytics',
|
||||
},
|
||||
{ key: 'monitor', title: '监控中心', description: 'monitor' },
|
||||
{ key: 'channel', title: '渠道管理', description: 'channel' },
|
||||
{
|
||||
key: 'token',
|
||||
menuKey: 'admin-token',
|
||||
title: '密钥管理',
|
||||
description: 'token',
|
||||
},
|
||||
{ key: 'models', title: '模型管理', description: 'models' },
|
||||
{ key: 'user', title: '用户管理', description: 'user' },
|
||||
{ key: 'redemption', title: '兑换码管理', description: 'redemption' },
|
||||
{ key: 'topup', title: '钱包管理', description: 'topup' },
|
||||
{ key: 'log', title: '使用日志', description: 'log' },
|
||||
{ key: 'midjourney', title: '绘图日志', description: 'midjourney' },
|
||||
{ key: 'task', title: '任务日志', description: 'task' },
|
||||
{ key: 'organizations', title: '企业管理', description: 'organizations' },
|
||||
{ key: 'order', title: '订单管理', description: 'order' },
|
||||
{ key: 'invoice', title: '发票管理', description: 'invoice' },
|
||||
{ key: 'subscription', title: '会员卡管理', description: 'subscription' },
|
||||
{ key: 'setting', title: '系统设置', description: 'setting' },
|
||||
{ key: 'website-setting', title: '官网设置', description: 'website-setting' },
|
||||
{
|
||||
key: 'demo-reservations',
|
||||
title: '预约演示',
|
||||
description: 'demo-reservations',
|
||||
},
|
||||
{ key: 'personal', title: '个人设置', description: 'personal' },
|
||||
{ key: 'my-commission', title: '我的提成', description: 'my-commission' },
|
||||
{ key: 'partner', title: '合作伙伴', description: 'partner' },
|
||||
{
|
||||
key: 'skill-platform',
|
||||
title: '平台 Skill 中心',
|
||||
description: 'skill-platform',
|
||||
},
|
||||
{
|
||||
key: 'expert-platform',
|
||||
title: '专家与模型能力',
|
||||
description: 'expert-platform',
|
||||
},
|
||||
{
|
||||
key: 'playground',
|
||||
title: '在线调试',
|
||||
description: 'playground',
|
||||
canvas: true,
|
||||
},
|
||||
{
|
||||
key: 'chat',
|
||||
title: '聊天',
|
||||
description: 'chat',
|
||||
canvas: true,
|
||||
dynamicChildTitle: '详情',
|
||||
},
|
||||
].map((page) => ({ ...page, path: `/console/${page.key}` }));
|
||||
|
||||
export function isNavigationPathActive(pathname, prefix) {
|
||||
if (!prefix) return false;
|
||||
if (prefix === '/') return pathname === '/';
|
||||
const normalized = prefix.replace(/\/+$/, '');
|
||||
return pathname === normalized || pathname.startsWith(`${normalized}/`);
|
||||
}
|
||||
|
||||
const normalizePath = (pathname) =>
|
||||
(pathname || '/console').split(/[?#]/)[0].replace(/\/+$/, '') || '/';
|
||||
|
||||
function segmentTitle(segment) {
|
||||
const actions = { edit: '编辑', new: '新建', create: '新建', detail: '详情' };
|
||||
if (actions[segment]) return actions[segment];
|
||||
if (/^\d+$/.test(segment)) return '详情';
|
||||
try {
|
||||
return decodeURIComponent(segment).replace(/[-_]/g, ' ');
|
||||
} catch {
|
||||
return segment;
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveConsolePage(pathname, pages = consolePages) {
|
||||
const path = normalizePath(pathname);
|
||||
const page = [...pages]
|
||||
.sort((a, b) => b.path.length - a.path.length)
|
||||
.find((item) => isNavigationPathActive(path, item.path));
|
||||
const root = { path: '/console', title: '控制台' };
|
||||
const matched = pages
|
||||
.filter((item) => isNavigationPathActive(path, item.path))
|
||||
.sort((a, b) => a.path.length - b.path.length);
|
||||
const breadcrumbs = [
|
||||
root,
|
||||
...matched.map(({ path, title }) => ({ path, title })),
|
||||
];
|
||||
const basePath = page?.path || root.path;
|
||||
const segments = path.slice(basePath.length).split('/').filter(Boolean);
|
||||
let currentPath = basePath;
|
||||
for (const [index, segment] of segments.entries()) {
|
||||
currentPath += `/${segment}`;
|
||||
breadcrumbs.push({
|
||||
path: currentPath,
|
||||
title:
|
||||
index === 0 && page?.dynamicChildTitle
|
||||
? page.dynamicChildTitle
|
||||
: segmentTitle(segment),
|
||||
});
|
||||
}
|
||||
return {
|
||||
...(page || { key: 'fallback', description: 'fallback' }),
|
||||
title: breadcrumbs.at(-1).title,
|
||||
path,
|
||||
breadcrumbs,
|
||||
};
|
||||
}
|
||||
|
||||
export const consoleMenuPaths = Object.fromEntries(
|
||||
consolePages.flatMap((page) =>
|
||||
[...new Set([page.menuKey || page.key, page.key])].map((key) => [
|
||||
key,
|
||||
page.path,
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
||||
export function getConsoleMenuKeys(pathname, paths = consoleMenuPaths) {
|
||||
if (!pathname) return [];
|
||||
const path = normalizePath(pathname);
|
||||
return Object.keys(paths).filter((key) => paths[key] === path);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
export function toConsoleTableChange(pagination, filters, sorter, extra) {
|
||||
const normalize = (value) => ({
|
||||
...value,
|
||||
dataIndex: value?.field,
|
||||
sortOrder: value?.order,
|
||||
});
|
||||
return {
|
||||
pagination,
|
||||
filters,
|
||||
sorter: Array.isArray(sorter) ? sorter.map(normalize) : normalize(sorter),
|
||||
...extra,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
.console-page .console-search-card .console-module-filter-form {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.console-page .console-module-filter-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.console-module-field {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.console-page .console-module-filter-grid .ant-form-item-label > label,
|
||||
.console-module-field > label {
|
||||
color: var(--console-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.console-module-field > label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.console-module-filter-grid .ant-input-number,
|
||||
.console-module-filter-grid .ant-picker,
|
||||
.console-module-filter-grid .ant-select,
|
||||
.console-module-filter-grid .ant-input-affix-wrapper,
|
||||
.console-module-filter-grid .ant-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.console-module-filter-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 16px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.console-module-row-actions {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.console-module-row-actions .ant-btn-link {
|
||||
height: auto;
|
||||
padding: 0 4px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.console-page:is(
|
||||
[data-console-page='channel'],
|
||||
[data-console-page='models'],
|
||||
[data-console-page='user'],
|
||||
[data-console-page='organizations'],
|
||||
[data-console-page='order']
|
||||
)
|
||||
.console-table
|
||||
.ant-table-thead
|
||||
> tr
|
||||
> th {
|
||||
height: 46px;
|
||||
padding-block: 0;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.console-model-drawer .ant-drawer-title > .ant-space {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.console-model-drawer .ant-drawer-title .ant-typography {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.console-model-drawer .ant-drawer-title .ant-tag {
|
||||
margin-inline-end: 0;
|
||||
}
|
||||
|
||||
.console-model-section,
|
||||
.console-channel-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.console-model-section .ant-avatar,
|
||||
.console-channel-section .ant-avatar {
|
||||
flex-shrink: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.console-channel-sections > div + div {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.console-channel-sections > div > .ant-card {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.console-channel-section .ant-avatar svg {
|
||||
display: block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.console-channel-footer .ant-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.console-channel-drawer .ant-form-item-extra > .ant-space,
|
||||
.console-channel-drawer .console-channel-key-actions,
|
||||
.console-channel-drawer .console-channel-model-actions {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.console-channel-drawer .ant-divider-inner-text {
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.console-overlay .console-model-footer,
|
||||
.console-overlay .console-channel-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.console-page .console-module-filter-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.console-page .console-module-filter-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
.console-model-drawer .prefill-management-header .ant-drawer-header-title {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
.console-model-drawer .prefill-management-header .ant-drawer-close {
|
||||
margin-inline: 12px 0;
|
||||
}
|
||||
|
||||
.console-model-drawer .console-model-editor-header .ant-drawer-header-title,
|
||||
.console-channel-drawer
|
||||
.console-channel-editor-header
|
||||
.ant-drawer-header-title {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
.console-model-drawer .console-model-editor-header .ant-drawer-title,
|
||||
.console-channel-drawer .console-channel-editor-header .ant-drawer-title {
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
.console-model-drawer .console-model-editor-header .ant-drawer-close,
|
||||
.console-channel-drawer .console-channel-editor-header .ant-drawer-close {
|
||||
margin-inline: 12px 0;
|
||||
}
|
||||
|
||||
.console-model-drawer .console-model-tag-presets {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
:is(.console-model-endpoints, .console-channel-drawer) .json-editor-pairs {
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
:is(.console-model-endpoints, .console-channel-drawer) .json-editor-pair {
|
||||
align-items: flex-start;
|
||||
margin-top: 0;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
:is(.console-model-endpoints, .console-channel-drawer)
|
||||
.json-editor-pair
|
||||
textarea.ant-input {
|
||||
text-align: start;
|
||||
font: inherit;
|
||||
line-height: 1.5715;
|
||||
}
|
||||
|
||||
:is(.console-model-endpoints, .console-channel-drawer) .json-editor-add {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
:is(.console-model-endpoints, .console-channel-drawer) {
|
||||
--json-editor-header-padding: 8px 16px;
|
||||
--json-editor-note-margin: 8px 0 0;
|
||||
}
|
||||
|
||||
:is(.console-model-endpoints, .console-channel-drawer)
|
||||
.json-editor-header
|
||||
> .json-editor-tabs.ant-tabs,
|
||||
:is(.console-model-endpoints, .console-channel-drawer)
|
||||
.json-editor-tabs
|
||||
> .ant-tabs-nav {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
:is(.console-model-endpoints, .console-channel-drawer)
|
||||
.json-editor-tabs
|
||||
.ant-tabs-tab {
|
||||
padding-block: 8px;
|
||||
}
|
||||
|
||||
:is(.console-model-endpoints, .console-channel-drawer)
|
||||
.json-editor-tabs
|
||||
> .ant-tabs-content-holder,
|
||||
:is(.console-model-endpoints, .console-channel-drawer)
|
||||
.json-editor-bound-field {
|
||||
display: none;
|
||||
}
|
||||
@@ -17,17 +17,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
||||
import { Avatar, Tag, Spin, Empty, Button, Divider, theme } from 'antd';
|
||||
import {
|
||||
Avatar,
|
||||
Tag,
|
||||
Spin,
|
||||
Empty,
|
||||
Button,
|
||||
Tooltip,
|
||||
Divider,
|
||||
theme,
|
||||
} from 'antd';
|
||||
import { X, RefreshCw, Headphones } from 'lucide-react';
|
||||
X,
|
||||
RefreshCw,
|
||||
Headphones,
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
} from 'lucide-react';
|
||||
import { API } from '../../helpers';
|
||||
import { getServerURL } from '../../helpers/config';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -43,6 +40,7 @@ const CustomerServiceFloat = () => {
|
||||
const { t } = useTranslation();
|
||||
const { token } = theme.useToken();
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [isCollapsed, setIsCollapsed] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [currentAgent, setCurrentAgent] = useState(null);
|
||||
const [agentList, setAgentList] = useState([]);
|
||||
@@ -78,8 +76,9 @@ const CustomerServiceFloat = () => {
|
||||
API.post(path).catch(() => {});
|
||||
}, []);
|
||||
|
||||
// 打开客服面板;不再读取或提供边缘收起状态。
|
||||
// 打开面板时恢复完整浮钮,确保关闭后的焦点可以回到触发器。
|
||||
const handleExpand = () => {
|
||||
setIsCollapsed(false);
|
||||
setIsOpen(true);
|
||||
};
|
||||
|
||||
@@ -104,6 +103,7 @@ const CustomerServiceFloat = () => {
|
||||
if (!config.enabled) return undefined;
|
||||
const onOpenRequest = (event) => {
|
||||
event.preventDefault();
|
||||
setIsCollapsed(false);
|
||||
setIsOpen(true);
|
||||
};
|
||||
window.addEventListener(CUSTOMER_SERVICE_OPEN_EVENT, onOpenRequest);
|
||||
@@ -252,7 +252,7 @@ const CustomerServiceFloat = () => {
|
||||
|
||||
return (
|
||||
<div
|
||||
className='customer-service-container'
|
||||
className={`customer-service-container${isCollapsed ? ' customer-service-container-collapsed' : ''}`}
|
||||
ref={containerRef}
|
||||
style={{
|
||||
'--cs-surface': token.colorBgContainer,
|
||||
@@ -262,6 +262,9 @@ const CustomerServiceFloat = () => {
|
||||
'--cs-fill': token.colorFillQuaternary,
|
||||
'--cs-hover': token.colorFillTertiary,
|
||||
'--cs-primary': token.colorPrimary,
|
||||
'--cs-primary-hover': token.colorPrimaryHover,
|
||||
'--cs-primary-active': token.colorPrimaryActive,
|
||||
'--cs-on-primary': token.colorTextLightSolid,
|
||||
'--cs-primary-bg': token.colorPrimaryBg,
|
||||
'--cs-primary-border': token.colorPrimaryBorder,
|
||||
'--cs-primary-text': token.colorPrimaryText,
|
||||
@@ -272,14 +275,54 @@ const CustomerServiceFloat = () => {
|
||||
{isOpen && (
|
||||
<div className='cs-backdrop' onClick={handleClose} aria-hidden='true' />
|
||||
)}
|
||||
<div className='cs-float-wrapper'>
|
||||
<Tooltip title={isOpen ? t('关闭客服') : t('联系客服')}>
|
||||
<div
|
||||
className={`cs-float-wrapper${isCollapsed ? ' cs-float-wrapper-collapsed' : ''}`}
|
||||
>
|
||||
{!isOpen &&
|
||||
(isCollapsed ? (
|
||||
<div className='cs-float-tab'>
|
||||
<Button
|
||||
className='cs-float-tab-action'
|
||||
type='text'
|
||||
title={t('联系客服')}
|
||||
aria-label={t('联系客服')}
|
||||
onClick={handleExpand}
|
||||
icon={<Headphones size={16} strokeWidth={2} />}
|
||||
/>
|
||||
<Button
|
||||
className='cs-float-tab-action'
|
||||
type='text'
|
||||
title={t('展开')}
|
||||
aria-label={t('展开')}
|
||||
aria-expanded={false}
|
||||
onClick={() => setIsCollapsed(false)}
|
||||
icon={<ChevronLeft size={16} strokeWidth={2} />}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<Button
|
||||
className='cs-float-toggle'
|
||||
type='default'
|
||||
title={t('收起')}
|
||||
aria-label={t('收起')}
|
||||
aria-expanded={true}
|
||||
onClick={() => setIsCollapsed(true)}
|
||||
>
|
||||
<ChevronRight size={16} strokeWidth={2} aria-hidden='true' />
|
||||
</Button>
|
||||
))}
|
||||
<div
|
||||
className='cs-float-main'
|
||||
inert={isCollapsed ? '' : undefined}
|
||||
aria-hidden={isCollapsed}
|
||||
>
|
||||
<Button
|
||||
type='primary'
|
||||
shape='circle'
|
||||
className='cs-float-button'
|
||||
onClick={isOpen ? handleClose : handleExpand}
|
||||
ref={triggerRef}
|
||||
title={isOpen ? t('关闭客服') : t('联系客服')}
|
||||
aria-label={isOpen ? t('关闭客服') : t('联系客服')}
|
||||
icon={
|
||||
isOpen ? (
|
||||
@@ -289,7 +332,7 @@ const CustomerServiceFloat = () => {
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className={`cs-panel ${isOpen ? 'cs-panel-open' : ''}`}
|
||||
|
||||
@@ -1,19 +1,161 @@
|
||||
.customer-service-container {
|
||||
--cs-float-right: max(20px, env(safe-area-inset-right, 0px));
|
||||
--cs-float-bottom: 32px;
|
||||
position: fixed;
|
||||
right: 24px;
|
||||
bottom: 24px;
|
||||
right: var(--cs-float-right);
|
||||
bottom: var(--cs-float-bottom);
|
||||
z-index: 1000;
|
||||
color: var(--cs-text);
|
||||
}
|
||||
.customer-service-container.customer-service-container-collapsed {
|
||||
right: env(safe-area-inset-right, 0px);
|
||||
}
|
||||
.cs-float-wrapper {
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
width: 46px;
|
||||
height: 46px;
|
||||
}
|
||||
.cs-float-main {
|
||||
width: 46px;
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
transform-origin: right center;
|
||||
transition:
|
||||
width 220ms ease,
|
||||
opacity 160ms ease,
|
||||
transform 220ms ease;
|
||||
}
|
||||
.cs-float-toggle.ant-btn {
|
||||
position: absolute;
|
||||
right: 13px;
|
||||
bottom: -24px;
|
||||
z-index: 1;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
min-width: 20px;
|
||||
height: 20px;
|
||||
padding: 0;
|
||||
border-radius: 7px;
|
||||
border: 0;
|
||||
color: var(--cs-on-primary);
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
transition:
|
||||
height 220ms ease,
|
||||
width 220ms ease,
|
||||
border-radius 220ms ease,
|
||||
background 160ms ease,
|
||||
transform 160ms ease,
|
||||
opacity 160ms ease;
|
||||
}
|
||||
.cs-float-toggle.ant-btn:not(:disabled):hover,
|
||||
.cs-float-toggle.ant-btn:not(:disabled):active {
|
||||
color: var(--cs-on-primary);
|
||||
background: transparent;
|
||||
}
|
||||
.cs-float-wrapper:not(.cs-float-wrapper-collapsed) .cs-float-toggle.ant-btn {
|
||||
color: var(--cs-on-primary);
|
||||
background: var(--cs-primary);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
.cs-float-wrapper:not(.cs-float-wrapper-collapsed):is(:hover, :focus-within)
|
||||
.cs-float-toggle.ant-btn {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
/* Extend the hit area across the gap without connecting the visible shapes. */
|
||||
.cs-float-wrapper:not(.cs-float-wrapper-collapsed) .cs-float-toggle::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: -5px 0 -1px;
|
||||
}
|
||||
.cs-float-wrapper:not(.cs-float-wrapper-collapsed)
|
||||
.cs-float-toggle.ant-btn:is(:hover, :focus-visible) {
|
||||
color: var(--cs-on-primary);
|
||||
background: var(--cs-primary-active);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
.cs-float-wrapper:not(.cs-float-wrapper-collapsed)
|
||||
.cs-float-toggle.ant-btn:active {
|
||||
background: var(--cs-primary-active);
|
||||
transform: translateY(0);
|
||||
}
|
||||
.cs-float-wrapper-collapsed {
|
||||
width: 23px;
|
||||
}
|
||||
.cs-float-wrapper-collapsed .cs-float-main {
|
||||
width: 0;
|
||||
opacity: 0;
|
||||
transform: scale(0.65);
|
||||
pointer-events: none;
|
||||
visibility: hidden;
|
||||
overflow: hidden;
|
||||
}
|
||||
.cs-float-tab {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
display: grid;
|
||||
grid-template-rows: repeat(2, 1fr);
|
||||
width: 23px;
|
||||
height: 48px;
|
||||
overflow: hidden;
|
||||
border-radius: 10px 0 0 10px;
|
||||
background: var(--cs-primary);
|
||||
}
|
||||
.cs-float-tab .cs-float-tab-action.ant-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 23px;
|
||||
min-width: 23px;
|
||||
height: 24px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
color: var(--cs-on-primary);
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
.cs-float-tab .cs-float-tab-action.ant-btn:not(:disabled):hover,
|
||||
.cs-float-tab .cs-float-tab-action.ant-btn:not(:disabled):active {
|
||||
color: var(--cs-on-primary);
|
||||
background: var(--cs-primary-hover);
|
||||
}
|
||||
.cs-float-tab .cs-float-tab-action.ant-btn:focus-visible {
|
||||
outline: 2px solid var(--cs-on-primary);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
.cs-float-wrapper:not(.cs-float-wrapper-collapsed)
|
||||
.cs-float-toggle:focus-visible {
|
||||
outline-offset: -3px;
|
||||
outline-color: var(--cs-primary);
|
||||
}
|
||||
.cs-float-toggle.ant-btn:focus-visible {
|
||||
outline: 2px solid var(--cs-primary);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.cs-float-main,
|
||||
.cs-float-toggle.ant-btn {
|
||||
transition: none;
|
||||
}
|
||||
.cs-float-wrapper:not(.cs-float-wrapper-collapsed)
|
||||
.cs-float-toggle.ant-btn:is(:hover, :focus-visible) {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
.cs-float-button.ant-btn {
|
||||
width: 46px;
|
||||
height: 46px;
|
||||
box-shadow: none;
|
||||
transition: background 160ms ease;
|
||||
}
|
||||
.customer-service-container .ant-btn-icon {
|
||||
display: inline-flex;
|
||||
@@ -25,8 +167,19 @@
|
||||
bottom: 60px;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
width: 360px;
|
||||
height: min(558px, calc(100dvh - 112px));
|
||||
width: min(
|
||||
360px,
|
||||
calc(
|
||||
100vw - var(--cs-float-right) - max(16px, env(safe-area-inset-left, 0px))
|
||||
)
|
||||
);
|
||||
height: min(
|
||||
558px,
|
||||
calc(
|
||||
100dvh - var(--cs-float-bottom) - 60px -
|
||||
max(16px, env(safe-area-inset-top, 0px))
|
||||
)
|
||||
);
|
||||
overflow: hidden;
|
||||
background: var(--cs-surface);
|
||||
border: 1px solid var(--cs-border);
|
||||
@@ -173,12 +326,10 @@
|
||||
}
|
||||
@media (max-width: 767.98px) {
|
||||
.customer-service-container {
|
||||
right: 16px;
|
||||
bottom: max(16px, env(safe-area-inset-bottom));
|
||||
--cs-float-right: max(16px, env(safe-area-inset-right, 0px));
|
||||
--cs-float-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
|
||||
}
|
||||
.cs-panel {
|
||||
width: min(360px, calc(100vw - 32px));
|
||||
height: min(558px, calc(100dvh - 100px));
|
||||
z-index: 1;
|
||||
}
|
||||
.cs-float-wrapper {
|
||||
@@ -191,9 +342,12 @@
|
||||
background: var(--cs-mask);
|
||||
}
|
||||
body:has(.uc-mobile-nav) .customer-service-container {
|
||||
bottom: calc(72px + env(safe-area-inset-bottom));
|
||||
}
|
||||
body:has(.uc-mobile-nav) .cs-panel {
|
||||
height: min(558px, calc(100dvh - 164px));
|
||||
--cs-float-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
|
||||
}
|
||||
}
|
||||
@media (hover: none) {
|
||||
.cs-float-wrapper:not(.cs-float-wrapper-collapsed) .cs-float-toggle.ant-btn {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@ const CustomerServiceFloat = lazy(() => import('../customer-service'));
|
||||
// 跑马灯公告组件
|
||||
import Marquee from './Marquee';
|
||||
import { useMarquee } from '../../hooks/common/useMarquee';
|
||||
import ConsolePageContainer from '../console/ConsolePageContainer';
|
||||
import { isNavigationPathActive } from '../console/consoleRoutes';
|
||||
|
||||
const { Sider, Content, Header } = Layout;
|
||||
|
||||
@@ -92,13 +94,7 @@ const PageLayout = () => {
|
||||
const [showGiftModal, setShowGiftModal] = useState(false);
|
||||
const [giftQuota, setGiftQuota] = useState(0);
|
||||
|
||||
const shouldInnerPadding =
|
||||
location.pathname.includes('/console') &&
|
||||
!location.pathname.startsWith('/console/chat') &&
|
||||
location.pathname !== '/console/playground' &&
|
||||
location.pathname !== '/console/website-setting';
|
||||
|
||||
const isConsoleRoute = location.pathname.startsWith('/console');
|
||||
const isConsoleRoute = isNavigationPathActive(location.pathname, '/console');
|
||||
const showSider = isConsoleRoute && (!isMobile || drawerOpen);
|
||||
const isHomePage = location.pathname === '/';
|
||||
|
||||
@@ -394,6 +390,11 @@ const PageLayout = () => {
|
||||
)}
|
||||
{showSider && (
|
||||
<Sider
|
||||
width={
|
||||
siderForceExpanded
|
||||
? 'var(--sidebar-width)'
|
||||
: 'var(--sidebar-current-width)'
|
||||
}
|
||||
style={{
|
||||
position: 'fixed',
|
||||
left: 0,
|
||||
@@ -439,15 +440,12 @@ const PageLayout = () => {
|
||||
style={{
|
||||
flex: '1 0 auto',
|
||||
WebkitOverflowScrolling: 'touch',
|
||||
padding: shouldInnerPadding
|
||||
? isMobile
|
||||
? '5px'
|
||||
: '24px 24px 0 24px'
|
||||
: '0',
|
||||
padding: 0,
|
||||
position: 'relative',
|
||||
// 认证页等 min-height:100vh 的独立屏用它抵扣上方跑马灯占位的高度,
|
||||
// 保证「占位 + 容器」总高恰为 100vh(无占位时回退 0px,不影响其他页面)
|
||||
'--content-top-offset': `${marqueeHeight}px`,
|
||||
'--console-header-offset': `${totalHeaderHeight}px`,
|
||||
}}
|
||||
>
|
||||
{/* 跑马灯占位:当跑马灯存在时,为内容区域顶部增加等高间距,防止被固定头部遮挡 */}
|
||||
@@ -458,10 +456,17 @@ const PageLayout = () => {
|
||||
{marqueeHeight > 0 &&
|
||||
!isExperienceCenter &&
|
||||
!isUserCenter &&
|
||||
!isConsoleRoute &&
|
||||
!isOrgPage && (
|
||||
<div style={{ height: marqueeHeight, flexShrink: 0 }} />
|
||||
)}
|
||||
<App />
|
||||
{isConsoleRoute ? (
|
||||
<ConsolePageContainer>
|
||||
<App />
|
||||
</ConsolePageContainer>
|
||||
) : (
|
||||
<App />
|
||||
)}
|
||||
</Content>
|
||||
</Layout>
|
||||
</Layout>
|
||||
|
||||
+110
-228
@@ -17,11 +17,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { consoleMenuPaths, getConsoleMenuKeys } from '../console/consoleRoutes';
|
||||
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { getLucideIcon } from '../../helpers/render';
|
||||
import { ChevronDown, ChevronLeft } from 'lucide-react';
|
||||
import { ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react';
|
||||
import '../../styles/center-layout.css';
|
||||
import { useSidebarCollapsed } from '../../hooks/common/useSidebarCollapsed';
|
||||
import { useSidebar } from '../../hooks/common/useSidebar';
|
||||
import { useMinimumLoadingTime } from '../../hooks/common/useMinimumLoadingTime';
|
||||
@@ -35,37 +37,11 @@ import {
|
||||
import SkeletonWrapper from './components/SkeletonWrapper';
|
||||
import { CLOUD_BRAIN_UI_ENABLED } from '../../config/cloudBrainUi';
|
||||
|
||||
import { Nav, Button } from '@/components/ui';
|
||||
|
||||
const routerMap = {
|
||||
home: '/',
|
||||
channel: '/console/channel',
|
||||
'admin-token': '/console/token',
|
||||
redemption: '/console/redemption',
|
||||
topup: '/console/topup',
|
||||
user: '/console/user',
|
||||
log: '/console/log',
|
||||
midjourney: '/console/midjourney',
|
||||
setting: '/console/setting',
|
||||
'website-setting': '/console/website-setting',
|
||||
'demo-reservations': '/console/demo-reservations',
|
||||
...consoleMenuPaths,
|
||||
about: '/about',
|
||||
detail: '/console',
|
||||
pricing: '/market',
|
||||
task: '/console/task',
|
||||
models: '/console/models',
|
||||
playground: '/console/playground',
|
||||
personal: '/console/personal',
|
||||
monitor: '/console/monitor',
|
||||
analytics: '/console/analytics',
|
||||
'my-commission': '/console/my-commission',
|
||||
partner: '/console/partner',
|
||||
organizations: '/console/organizations',
|
||||
'skill-platform': '/console/skill-platform',
|
||||
'expert-platform': '/console/expert-platform',
|
||||
order: '/console/order',
|
||||
invoice: '/console/invoice',
|
||||
subscription: '/console/subscription',
|
||||
};
|
||||
|
||||
// forceExpanded:手机端抽屉态。抽屉本来就是临时全宽浮层,折叠成 60px 图标条毫无意义,
|
||||
@@ -183,7 +159,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
filteredItems.push({
|
||||
text: t('我的提成'),
|
||||
itemKey: 'my-commission',
|
||||
to: '/console/my-commission',
|
||||
});
|
||||
|
||||
// 合作伙伴:受平台总开关控制(参数设置页可配),开放后对全部登录用户可见
|
||||
@@ -191,7 +166,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
filteredItems.push({
|
||||
text: t('合作伙伴'),
|
||||
itemKey: 'partner',
|
||||
to: '/console/partner',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -207,7 +181,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
{
|
||||
text: t('运营看板'),
|
||||
itemKey: 'analytics',
|
||||
to: '/console/analytics',
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
@@ -219,7 +192,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
{
|
||||
text: t('模型管理'),
|
||||
itemKey: 'models',
|
||||
to: '/console/models',
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
@@ -237,43 +209,36 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
{
|
||||
text: t('会员卡管理'),
|
||||
itemKey: 'subscription',
|
||||
to: '/console/subscription',
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
text: t('密钥管理'),
|
||||
itemKey: 'admin-token',
|
||||
to: '/console/token',
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
text: t('企业管理'),
|
||||
itemKey: 'organizations',
|
||||
to: '/console/organizations',
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
text: t('平台 Skill 中心'),
|
||||
itemKey: 'skill-platform',
|
||||
to: '/console/skill-platform',
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
text: t('平台专家中心'),
|
||||
itemKey: 'expert-platform',
|
||||
to: '/console/expert-platform',
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
text: t('订单管理'),
|
||||
itemKey: 'order',
|
||||
to: '/console/order',
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
text: t('发票管理'),
|
||||
itemKey: 'invoice',
|
||||
to: '/console/invoice',
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
@@ -415,23 +380,21 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
// 根据当前路径设置选中的菜单项
|
||||
useEffect(() => {
|
||||
const currentPath = location.pathname;
|
||||
let matchingKey = Object.keys(routerMapState).find(
|
||||
(key) => routerMapState[key] === currentPath,
|
||||
);
|
||||
let matchingKeys = getConsoleMenuKeys(currentPath, routerMapState);
|
||||
|
||||
// 处理聊天路由
|
||||
if (!matchingKey && currentPath.startsWith('/console/chat/')) {
|
||||
if (!matchingKeys.length && currentPath.startsWith('/console/chat/')) {
|
||||
const chatIndex = currentPath.split('/').pop();
|
||||
if (!isNaN(chatIndex)) {
|
||||
matchingKey = 'chat' + chatIndex;
|
||||
matchingKeys = ['chat' + chatIndex];
|
||||
} else {
|
||||
matchingKey = 'chat';
|
||||
matchingKeys = ['chat'];
|
||||
}
|
||||
}
|
||||
|
||||
// 如果找到匹配的键,更新选中的键
|
||||
if (matchingKey) {
|
||||
setSelectedKeys([matchingKey]);
|
||||
if (matchingKeys.length) {
|
||||
setSelectedKeys(matchingKeys);
|
||||
}
|
||||
}, [location.pathname, routerMapState]);
|
||||
|
||||
@@ -446,121 +409,103 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
}
|
||||
}, [persistedCollapsed, forceExpanded]);
|
||||
|
||||
// 选中高亮颜色(统一)
|
||||
const SELECTED_COLOR = 'var(--ui-color-primary)';
|
||||
const renderMenuIcon = (key) =>
|
||||
React.cloneElement(getLucideIcon(key), {
|
||||
size: 16,
|
||||
strokeWidth: 1.5,
|
||||
color: 'currentColor',
|
||||
className: undefined,
|
||||
'aria-hidden': true,
|
||||
});
|
||||
|
||||
const renderGroup = (key, label, items) => {
|
||||
const folded = foldedGroups.includes(key);
|
||||
return (
|
||||
<Nav.Group
|
||||
itemKey={key}
|
||||
folded={folded}
|
||||
text={
|
||||
<button
|
||||
type='button'
|
||||
className='sidebar-group-toggle'
|
||||
aria-expanded={!folded}
|
||||
onClick={() =>
|
||||
setFoldedGroups((previous) =>
|
||||
previous.includes(key)
|
||||
? previous.filter((group) => group !== key)
|
||||
: [...previous, key],
|
||||
)
|
||||
}
|
||||
>
|
||||
<span className='truncate'>{label}</span>
|
||||
<ChevronDown size={13} className={folded ? '-rotate-90' : ''} />
|
||||
</button>
|
||||
}
|
||||
>
|
||||
{items}
|
||||
</Nav.Group>
|
||||
);
|
||||
};
|
||||
|
||||
// 渲染自定义菜单项
|
||||
const renderNavItem = (item) => {
|
||||
// 跳过隐藏的项目
|
||||
if (item.className === 'tableHiddle') return null;
|
||||
|
||||
const isSelected = selectedKeys.includes(item.itemKey);
|
||||
const textColor = isSelected ? SELECTED_COLOR : 'inherit';
|
||||
|
||||
return (
|
||||
<Nav.Item
|
||||
key={item.itemKey}
|
||||
itemKey={item.itemKey}
|
||||
text={
|
||||
<span
|
||||
className='truncate font-medium text-sm'
|
||||
style={{ color: textColor }}
|
||||
>
|
||||
{item.text}
|
||||
</span>
|
||||
}
|
||||
icon={
|
||||
<div className='sidebar-icon-container flex-shrink-0'>
|
||||
{getLucideIcon(item.itemKey, isSelected)}
|
||||
</div>
|
||||
}
|
||||
className={item.className}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
// 渲染子菜单项
|
||||
const renderSubItem = (item) => {
|
||||
if (item.items && item.items.length > 0) {
|
||||
const isSelected = selectedKeys.includes(item.itemKey);
|
||||
const textColor = isSelected ? SELECTED_COLOR : 'inherit';
|
||||
|
||||
return (
|
||||
<Nav.Sub
|
||||
key={item.itemKey}
|
||||
itemKey={item.itemKey}
|
||||
text={
|
||||
<span
|
||||
className='truncate font-medium text-sm'
|
||||
style={{ color: textColor }}
|
||||
>
|
||||
{item.text}
|
||||
</span>
|
||||
}
|
||||
icon={
|
||||
<div className='sidebar-icon-container flex-shrink-0'>
|
||||
{getLucideIcon(item.itemKey, isSelected)}
|
||||
</div>
|
||||
const renderGroup = (key, label, items) => (
|
||||
<div key={key} className='ui-org-nav-group'>
|
||||
{!collapsed && (
|
||||
<button
|
||||
type='button'
|
||||
className='ui-org-group-toggle'
|
||||
aria-expanded={!foldedGroups.includes(key)}
|
||||
onClick={() =>
|
||||
setFoldedGroups((previous) =>
|
||||
previous.includes(key)
|
||||
? previous.filter((group) => group !== key)
|
||||
: [...previous, key],
|
||||
)
|
||||
}
|
||||
>
|
||||
{item.items.map((subItem) => {
|
||||
const isSubSelected = selectedKeys.includes(subItem.itemKey);
|
||||
const subTextColor = isSubSelected ? SELECTED_COLOR : 'inherit';
|
||||
<span>{label}</span>
|
||||
<ChevronDown
|
||||
size={13}
|
||||
className={foldedGroups.includes(key) ? 'is-folded' : ''}
|
||||
aria-hidden='true'
|
||||
/>
|
||||
</button>
|
||||
)}
|
||||
<div
|
||||
className='ui-org-group-items'
|
||||
hidden={!collapsed && foldedGroups.includes(key)}
|
||||
>
|
||||
{items}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<Nav.Item
|
||||
key={subItem.itemKey}
|
||||
itemKey={subItem.itemKey}
|
||||
text={
|
||||
<span
|
||||
className='truncate font-medium text-sm'
|
||||
style={{ color: subTextColor }}
|
||||
>
|
||||
{subItem.text}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</Nav.Sub>
|
||||
);
|
||||
} else {
|
||||
return renderNavItem(item);
|
||||
}
|
||||
const renderNavItem = (item) => {
|
||||
if (item.className === 'tableHiddle') return null;
|
||||
const active = selectedKeys.includes(item.itemKey);
|
||||
return (
|
||||
<Link
|
||||
key={item.itemKey}
|
||||
to={routerMapState[item.itemKey] || routerMap[item.itemKey] || '#'}
|
||||
onClick={onNavigate}
|
||||
className='ui-center-menu-item'
|
||||
data-active={active || undefined}
|
||||
aria-current={active ? 'page' : undefined}
|
||||
title={collapsed ? item.text : undefined}
|
||||
>
|
||||
{renderMenuIcon(item.itemKey)}
|
||||
{!collapsed && (
|
||||
<span className='ui-center-menu-label'>{item.text}</span>
|
||||
)}
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
|
||||
const renderSubItem = (item) => {
|
||||
if (!item.items?.length) return renderNavItem(item);
|
||||
const open = openedKeys.includes(item.itemKey);
|
||||
return (
|
||||
<div key={item.itemKey}>
|
||||
<button
|
||||
type='button'
|
||||
className='ui-center-menu-item ui-console-submenu-toggle'
|
||||
title={collapsed ? item.text : undefined}
|
||||
aria-label={item.text}
|
||||
aria-expanded={open}
|
||||
onClick={() =>
|
||||
setOpenedKeys((previous) =>
|
||||
previous.includes(item.itemKey)
|
||||
? previous.filter((key) => key !== item.itemKey)
|
||||
: [...previous, item.itemKey],
|
||||
)
|
||||
}
|
||||
>
|
||||
{renderMenuIcon(item.itemKey)}
|
||||
{!collapsed && (
|
||||
<span className='ui-center-menu-label'>{item.text}</span>
|
||||
)}
|
||||
</button>
|
||||
<div className='ui-org-group-items' hidden={!open}>
|
||||
{item.items.map(renderNavItem)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className='sidebar-container'
|
||||
className='ui-console-sidebar ui-center-sidebar'
|
||||
data-collapsed={collapsed}
|
||||
style={{
|
||||
width: forceExpanded
|
||||
? 'var(--sidebar-width)'
|
||||
@@ -575,45 +520,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
collapsed={collapsed}
|
||||
showAdmin={isAdmin()}
|
||||
>
|
||||
<Nav
|
||||
className='sidebar-nav'
|
||||
defaultIsCollapsed={collapsed}
|
||||
isCollapsed={collapsed}
|
||||
onCollapseChange={toggleCollapsed}
|
||||
selectedKeys={selectedKeys}
|
||||
itemStyle='sidebar-nav-item'
|
||||
hoverStyle='sidebar-nav-item:hover'
|
||||
selectedStyle='sidebar-nav-item-selected'
|
||||
renderWrapper={({ itemElement, props }) => {
|
||||
const to =
|
||||
routerMapState[props.itemKey] || routerMap[props.itemKey];
|
||||
|
||||
// 如果没有路由,直接返回元素
|
||||
if (!to) return itemElement;
|
||||
|
||||
return (
|
||||
<Link
|
||||
style={{ textDecoration: 'none' }}
|
||||
to={to}
|
||||
onClick={onNavigate}
|
||||
>
|
||||
{itemElement}
|
||||
</Link>
|
||||
);
|
||||
}}
|
||||
onSelect={(key) => {
|
||||
// 如果点击的是已经展开的子菜单的父项,则收起子菜单
|
||||
if (openedKeys.includes(key.itemKey)) {
|
||||
setOpenedKeys(openedKeys.filter((k) => k !== key.itemKey));
|
||||
}
|
||||
|
||||
setSelectedKeys([key.itemKey]);
|
||||
}}
|
||||
openKeys={openedKeys}
|
||||
onOpenChange={(data) => {
|
||||
setOpenedKeys(data.openKeys);
|
||||
}}
|
||||
>
|
||||
<nav className='ui-center-sidebar-nav'>
|
||||
{/* 聊天区域 */}
|
||||
{hasSectionVisibleModules('chat') &&
|
||||
renderGroup(
|
||||
@@ -645,45 +552,20 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
t('管理员'),
|
||||
adminItems.map(renderNavItem),
|
||||
)}
|
||||
</Nav>
|
||||
</nav>
|
||||
</SkeletonWrapper>
|
||||
|
||||
{/* 底部折叠按钮 —— 抽屉态不提供:收起后抽屉会变成 60px 窄条,等于自废 */}
|
||||
{!forceExpanded && (
|
||||
<div className='sidebar-collapse-button'>
|
||||
<SkeletonWrapper
|
||||
loading={showSkeleton}
|
||||
type='button'
|
||||
width={collapsed ? 36 : 156}
|
||||
height={24}
|
||||
className='w-full'
|
||||
>
|
||||
<Button
|
||||
theme='outline'
|
||||
type='tertiary'
|
||||
size='small'
|
||||
icon={
|
||||
<ChevronLeft
|
||||
size={16}
|
||||
strokeWidth={2.5}
|
||||
color='var(--ui-color-text-2)'
|
||||
style={{
|
||||
transform: collapsed ? 'rotate(180deg)' : 'rotate(0deg)',
|
||||
}}
|
||||
/>
|
||||
}
|
||||
onClick={toggleCollapsed}
|
||||
aria-label={collapsed ? t('展开侧边栏') : t('收起侧边栏')}
|
||||
style={
|
||||
collapsed
|
||||
? { width: 36, height: 24, padding: 0 }
|
||||
: { padding: '4px 12px', width: '100%' }
|
||||
}
|
||||
>
|
||||
{!collapsed ? t('收起侧边栏') : null}
|
||||
</Button>
|
||||
</SkeletonWrapper>
|
||||
</div>
|
||||
<button
|
||||
type='button'
|
||||
className='ui-center-sidebar-collapse'
|
||||
onClick={toggleCollapsed}
|
||||
aria-label={collapsed ? t('展开导航') : t('收起导航')}
|
||||
>
|
||||
{collapsed ? <ChevronRight size={16} /> : <ChevronLeft size={16} />}
|
||||
{!collapsed && <span>{t('收起导航')}</span>}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -21,6 +21,7 @@ import React, { useState } from 'react';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import { Button, Dropdown } from '@/components/ui';
|
||||
import { Compass, ExternalLink } from 'lucide-react';
|
||||
import { isNavigationPathActive } from '../../console/consoleRoutes';
|
||||
|
||||
/**
|
||||
* 移动端主导航入口。
|
||||
@@ -41,14 +42,8 @@ const MobileNavMenu = ({ mainNavLinks, userState, t }) => {
|
||||
}
|
||||
|
||||
// 与 Navigation 一致:按完整路径段匹配,避免 /market 命中 /market-detail
|
||||
const isPathActive = (matchPath) => {
|
||||
if (!matchPath) return false;
|
||||
if (matchPath === '/') return location.pathname === '/';
|
||||
return (
|
||||
location.pathname === matchPath ||
|
||||
location.pathname.startsWith(`${matchPath}/`)
|
||||
);
|
||||
};
|
||||
const isPathActive = (matchPath) =>
|
||||
isNavigationPathActive(location.pathname, matchPath);
|
||||
|
||||
// 与 Navigation 一致:未登录时需要鉴权的入口统一引导到企业登录
|
||||
const resolveTarget = (link) => {
|
||||
@@ -122,7 +117,10 @@ const MobileNavMenu = ({ mainNavLinks, userState, t }) => {
|
||||
: '!text-gray-700 dark:!text-neutral-200'
|
||||
}`}
|
||||
>
|
||||
<span className='flex items-center gap-1.5'>
|
||||
<span
|
||||
className='flex items-center gap-1.5'
|
||||
aria-current={item.active ? 'page' : undefined}
|
||||
>
|
||||
{item.text}
|
||||
{item.externalLink && (
|
||||
<ExternalLink size={12} className='opacity-50' />
|
||||
|
||||
@@ -22,6 +22,7 @@ import { Link, useLocation } from 'react-router-dom';
|
||||
import { Dropdown } from '@/components/ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import SkeletonWrapper from '../components/SkeletonWrapper';
|
||||
import { isNavigationPathActive } from '../../console/consoleRoutes';
|
||||
|
||||
const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
||||
const location = useLocation();
|
||||
@@ -36,13 +37,8 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
||||
const spacingClasses = isMobile ? 'px-2 py-1 text-sm' : 'px-4 py-2';
|
||||
|
||||
// Match on full path segments so /market doesn't light up on /market-detail
|
||||
const isPathActive = (matchPath) => {
|
||||
if (matchPath === '/') return location.pathname === '/';
|
||||
return (
|
||||
location.pathname === matchPath ||
|
||||
location.pathname.startsWith(`${matchPath}/`)
|
||||
);
|
||||
};
|
||||
const isPathActive = (matchPath) =>
|
||||
isNavigationPathActive(location.pathname, matchPath);
|
||||
|
||||
return mainNavLinks.map((link) => {
|
||||
const linkContent = <span className='relative z-10'>{link.text}</span>;
|
||||
@@ -58,7 +54,9 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
||||
|
||||
// Check if active
|
||||
let isActive = false;
|
||||
if (link.items && link.items.length > 0) {
|
||||
if (link.activePrefix) {
|
||||
isActive = isPathActive(link.activePrefix);
|
||||
} else if (link.items && link.items.length > 0) {
|
||||
isActive = link.items.some((subItem) => isPathActive(subItem.to));
|
||||
} else if (!link.isExternal && targetPath) {
|
||||
isActive = isPathActive(link.activePrefix || targetPath);
|
||||
@@ -88,7 +86,10 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
||||
</Dropdown.Menu>
|
||||
}
|
||||
>
|
||||
<div className={`${finalClasses} cursor-pointer`}>
|
||||
<div
|
||||
className={`${finalClasses} cursor-pointer`}
|
||||
aria-current={isActive ? 'page' : undefined}
|
||||
>
|
||||
{linkContent}
|
||||
{/* Dropdown arrow */}
|
||||
<svg
|
||||
@@ -156,7 +157,7 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
||||
className='ui-header-navigation flex flex-1 items-center gap-1 lg:gap-2 mx-1 sm:mx-3 md:mx-6 overflow-x-auto whitespace-nowrap scrollbar-hide min-w-0'
|
||||
>
|
||||
<SkeletonWrapper
|
||||
loading={isLoading}
|
||||
loading={isLoading && mainNavLinks.length === 0}
|
||||
type='navigation'
|
||||
count={4}
|
||||
width={60}
|
||||
|
||||
@@ -147,13 +147,15 @@ const HeaderBar = ({ onMobileMenuToggle, drawerOpen }) => {
|
||||
/>
|
||||
|
||||
{/* 移动端:主导航收进下拉菜单,避免与右侧操作区互相挤压 */}
|
||||
{!isAuthPage && isMobile && !isLoading && (
|
||||
<MobileNavMenu
|
||||
mainNavLinks={mainNavLinks}
|
||||
userState={userState}
|
||||
t={t}
|
||||
/>
|
||||
)}
|
||||
{!isAuthPage &&
|
||||
isMobile &&
|
||||
(!isLoading || mainNavLinks.length > 0) && (
|
||||
<MobileNavMenu
|
||||
mainNavLinks={mainNavLinks}
|
||||
userState={userState}
|
||||
t={t}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{!isAuthPage && !isMobile && (
|
||||
|
||||
@@ -187,13 +187,12 @@ const CodeViewer = ({ content, title, language = 'json' }) => {
|
||||
: content;
|
||||
|
||||
const success = await copy(textToCopy);
|
||||
setCopied(true);
|
||||
Toast.success(t('已复制到剪贴板'));
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
|
||||
if (!success) {
|
||||
throw new Error('Copy operation failed');
|
||||
}
|
||||
setCopied(true);
|
||||
Toast.success(t('已复制到剪贴板'));
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
} catch (err) {
|
||||
Toast.error(t('复制失败'));
|
||||
console.error('Copy failed:', err);
|
||||
|
||||
@@ -106,7 +106,7 @@ const SSEViewer = ({ sseData }) => {
|
||||
)
|
||||
.join('\n\n');
|
||||
|
||||
await copy(allData);
|
||||
if (!(await copy(allData))) throw new Error('Clipboard copy failed');
|
||||
setCopied(true);
|
||||
Toast.success(t('已复制全部数据'));
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
@@ -122,7 +122,7 @@ const SSEViewer = ({ sseData }) => {
|
||||
const textToCopy = item.parsed
|
||||
? JSON.stringify(item.parsed, null, 2)
|
||||
: item.raw;
|
||||
await copy(textToCopy);
|
||||
if (!(await copy(textToCopy))) throw new Error('Clipboard copy failed');
|
||||
Toast.success(t('已复制'));
|
||||
} catch (err) {
|
||||
Toast.error(t('复制失败'));
|
||||
|
||||
@@ -282,21 +282,23 @@ const PromotionPosterModal = ({ visible, onClose }) => {
|
||||
};
|
||||
|
||||
// 复制邀请链接
|
||||
const handleCopyLink = () => {
|
||||
const handleCopyLink = async () => {
|
||||
if (!affLink) {
|
||||
showError(t('邀请链接获取中,请稍后'));
|
||||
return;
|
||||
}
|
||||
copy(affLink, t('邀请链接'));
|
||||
if (await copy(affLink)) showSuccess(t('邀请链接已复制到剪切板'));
|
||||
else showError(t('复制失败,请手动复制'));
|
||||
};
|
||||
|
||||
// 复制邀请码
|
||||
const handleCopyCode = () => {
|
||||
const handleCopyCode = async () => {
|
||||
if (!affCode) {
|
||||
showError(t('邀请码获取中,请稍后'));
|
||||
return;
|
||||
}
|
||||
copy(affCode, t('邀请码'));
|
||||
if (await copy(affCode)) showSuccess(t('复制成功'));
|
||||
else showError(t('复制失败,请手动复制'));
|
||||
};
|
||||
|
||||
// 链接分享模式 - PC友好
|
||||
|
||||
@@ -369,19 +369,20 @@ export default function ContentGuardSetting() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ padding: 20 }}>
|
||||
<div>
|
||||
<Banner
|
||||
fullMode={false}
|
||||
className='mb-4'
|
||||
type='info'
|
||||
description={
|
||||
config.available && config.schema_ready
|
||||
? t(
|
||||
'UGuard 仅作用于同时命中用户和实际调用分组的请求。未命中请求不会调用防护服务。',
|
||||
)
|
||||
: t('运行环境或数据库迁移尚未允许启用内容防护。')
|
||||
}
|
||||
/>
|
||||
<Space vertical align='start' spacing='medium' style={{ width: '100%' }}>
|
||||
<Banner
|
||||
fullMode={false}
|
||||
type={config.available && config.schema_ready ? 'info' : 'warning'}
|
||||
description={
|
||||
config.available && config.schema_ready
|
||||
? t(
|
||||
'UGuard 仅作用于同时命中用户和实际调用分组的请求。未命中请求不会调用防护服务。',
|
||||
)
|
||||
: t('运行环境或数据库迁移尚未允许启用内容防护。')
|
||||
}
|
||||
/>
|
||||
<Card style={{ width: '100%' }}>
|
||||
<Space style={{ justifyContent: 'space-between', width: '100%' }}>
|
||||
<Space>
|
||||
|
||||
@@ -41,7 +41,6 @@ import {
|
||||
PowerOff,
|
||||
RefreshCw,
|
||||
Users,
|
||||
Headphones,
|
||||
Upload as UploadIcon,
|
||||
} from 'lucide-react';
|
||||
import { API, showError, showSuccess } from '../../helpers';
|
||||
@@ -369,7 +368,6 @@ const CustomerServiceSetting = () => {
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<Banner
|
||||
type='info'
|
||||
icon={<Headphones size={16} />}
|
||||
description={t(
|
||||
'配置企业微信客服,支持多客服轮询、加权分配、最少接待等策略。客服链接可在企业微信管理后台的「微信客服」中获取。',
|
||||
)}
|
||||
|
||||
@@ -38,8 +38,6 @@ import {
|
||||
import { API, isRoot, showError, showSuccess } from '../../helpers';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const PAGE_SIZE = 20;
|
||||
|
||||
const MODE_OPTIONS = [
|
||||
{ value: 'detect_only', label: '仅检测告警' },
|
||||
{ value: 'standard', label: '标准脱敏(可逆占位符)' },
|
||||
@@ -128,12 +126,15 @@ export default function DataSecuritySetting() {
|
||||
// 企业私有规则监督视图(企业自助维护;平台只读 + 紧急删除止血)
|
||||
const [orgRules, setOrgRules] = useState([]);
|
||||
const [audits, setAudits] = useState([]);
|
||||
const [auditPageSize, setAuditPageSize] = useState(20);
|
||||
const [auditPage, setAuditPage] = useState(1);
|
||||
const [auditTotal, setAuditTotal] = useState(0);
|
||||
const [hitLogs, setHitLogs] = useState([]);
|
||||
const [hitLogPageSize, setHitLogPageSize] = useState(20);
|
||||
const [hitLogPage, setHitLogPage] = useState(1);
|
||||
const [hitLogTotal, setHitLogTotal] = useState(0);
|
||||
const [changeRequests, setChangeRequests] = useState([]);
|
||||
const [changeReqPageSize, setChangeReqPageSize] = useState(20);
|
||||
const [changeReqPage, setChangeReqPage] = useState(1);
|
||||
const [changeReqTotal, setChangeReqTotal] = useState(0);
|
||||
const [metrics, setMetrics] = useState(null);
|
||||
@@ -183,40 +184,64 @@ export default function DataSecuritySetting() {
|
||||
showError(res.data?.message || t('加载规则失败'));
|
||||
}
|
||||
};
|
||||
const loadAudits = async (page = 1) => {
|
||||
const res = await API.get(
|
||||
`/api/desensitize/config-audit?page=${page}&page_size=${PAGE_SIZE}`,
|
||||
);
|
||||
if (res.data?.success) {
|
||||
setAudits(res.data.data?.items || []);
|
||||
setAuditTotal(res.data.data?.total || 0);
|
||||
setAuditPage(page);
|
||||
} else {
|
||||
showError(res.data?.message || t('加载配置审计失败'));
|
||||
const [auditLoading, setAuditLoading] = useState(false);
|
||||
const [hitLogLoading, setHitLogLoading] = useState(false);
|
||||
const [changeReqLoading, setChangeReqLoading] = useState(false);
|
||||
const loadAudits = async (page = 1, size = auditPageSize) => {
|
||||
setAuditLoading(true);
|
||||
try {
|
||||
const res = await API.get(
|
||||
`/api/desensitize/config-audit?page=${page}&page_size=${size}`,
|
||||
);
|
||||
if (res.data?.success) {
|
||||
setAudits(res.data.data?.items || []);
|
||||
setAuditTotal(res.data.data?.total || 0);
|
||||
setAuditPage(page);
|
||||
} else {
|
||||
showError(res.data?.message || t('加载配置审计失败'));
|
||||
}
|
||||
} catch (err) {
|
||||
showError(err.message || t('加载配置审计失败'));
|
||||
} finally {
|
||||
setAuditLoading(false);
|
||||
}
|
||||
};
|
||||
const loadHitLogs = async (page = 1) => {
|
||||
const res = await API.get(
|
||||
`/api/desensitize/logs?page=${page}&page_size=${PAGE_SIZE}`,
|
||||
);
|
||||
if (res.data?.success) {
|
||||
setHitLogs(res.data.data?.items || []);
|
||||
setHitLogTotal(res.data.data?.total || 0);
|
||||
setHitLogPage(page);
|
||||
} else {
|
||||
showError(res.data?.message || t('加载命中审计失败'));
|
||||
const loadHitLogs = async (page = 1, size = hitLogPageSize) => {
|
||||
setHitLogLoading(true);
|
||||
try {
|
||||
const res = await API.get(
|
||||
`/api/desensitize/logs?page=${page}&page_size=${size}`,
|
||||
);
|
||||
if (res.data?.success) {
|
||||
setHitLogs(res.data.data?.items || []);
|
||||
setHitLogTotal(res.data.data?.total || 0);
|
||||
setHitLogPage(page);
|
||||
} else {
|
||||
showError(res.data?.message || t('加载命中审计失败'));
|
||||
}
|
||||
} catch (err) {
|
||||
showError(err.message || t('加载命中审计失败'));
|
||||
} finally {
|
||||
setHitLogLoading(false);
|
||||
}
|
||||
};
|
||||
const loadChangeRequests = async (page = 1) => {
|
||||
const res = await API.get(
|
||||
`/api/desensitize/change-requests?page=${page}&page_size=${PAGE_SIZE}`,
|
||||
);
|
||||
if (res.data?.success) {
|
||||
setChangeRequests(res.data.data?.items || []);
|
||||
setChangeReqTotal(res.data.data?.total || 0);
|
||||
setChangeReqPage(page);
|
||||
} else {
|
||||
showError(res.data?.message || t('加载变更审批列表失败'));
|
||||
const loadChangeRequests = async (page = 1, size = changeReqPageSize) => {
|
||||
setChangeReqLoading(true);
|
||||
try {
|
||||
const res = await API.get(
|
||||
`/api/desensitize/change-requests?page=${page}&page_size=${size}`,
|
||||
);
|
||||
if (res.data?.success) {
|
||||
setChangeRequests(res.data.data?.items || []);
|
||||
setChangeReqTotal(res.data.data?.total || 0);
|
||||
setChangeReqPage(page);
|
||||
} else {
|
||||
showError(res.data?.message || t('加载变更审批列表失败'));
|
||||
}
|
||||
} catch (err) {
|
||||
showError(err.message || t('加载变更审批列表失败'));
|
||||
} finally {
|
||||
setChangeReqLoading(false);
|
||||
}
|
||||
};
|
||||
// 监控指标失败必须显式呈现 '-' 而非 0:安全巡检语境下"待审批 0 / 敏感命中 0"
|
||||
@@ -647,7 +672,7 @@ export default function DataSecuritySetting() {
|
||||
return (
|
||||
<Spin spinning={loading}>
|
||||
<Banner
|
||||
type='warning'
|
||||
type='info'
|
||||
closeIcon={null}
|
||||
description={t(
|
||||
'本功能基于规则匹配,无法识别所有类型的敏感信息(如图像内容、详细地址、外文姓名、未知格式的密钥等)。请勿单独依赖本功能作为合规保障。',
|
||||
@@ -941,12 +966,17 @@ export default function DataSecuritySetting() {
|
||||
<Table
|
||||
columns={changeReqColumns}
|
||||
dataSource={changeRequests}
|
||||
loading={changeReqLoading}
|
||||
rowKey='id'
|
||||
pagination={{
|
||||
currentPage: changeReqPage,
|
||||
pageSize: PAGE_SIZE,
|
||||
pageSize: changeReqPageSize,
|
||||
total: changeReqTotal,
|
||||
onPageChange: (p) => loadChangeRequests(p),
|
||||
onPageSizeChange: (size) => {
|
||||
setChangeReqPageSize(size);
|
||||
loadChangeRequests(1, size);
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
@@ -1194,12 +1224,17 @@ export default function DataSecuritySetting() {
|
||||
<Table
|
||||
columns={hitLogColumns}
|
||||
dataSource={hitLogs}
|
||||
loading={hitLogLoading}
|
||||
rowKey='id'
|
||||
pagination={{
|
||||
currentPage: hitLogPage,
|
||||
pageSize: PAGE_SIZE,
|
||||
pageSize: hitLogPageSize,
|
||||
total: hitLogTotal,
|
||||
onPageChange: (p) => loadHitLogs(p),
|
||||
onPageSizeChange: (size) => {
|
||||
setHitLogPageSize(size);
|
||||
loadHitLogs(1, size);
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
@@ -1210,12 +1245,17 @@ export default function DataSecuritySetting() {
|
||||
<Table
|
||||
columns={auditColumns}
|
||||
dataSource={audits}
|
||||
loading={auditLoading}
|
||||
rowKey='id'
|
||||
pagination={{
|
||||
currentPage: auditPage,
|
||||
pageSize: PAGE_SIZE,
|
||||
pageSize: auditPageSize,
|
||||
total: auditTotal,
|
||||
onPageChange: (p) => loadAudits(p),
|
||||
onPageSizeChange: (size) => {
|
||||
setAuditPageSize(size);
|
||||
loadAudits(1, size);
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
@@ -23,6 +23,7 @@ import { API, showError, showSuccess, timestamp2string } from '../../helpers';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
import { Text } from '@/components/ui';
|
||||
import './other-setting.css';
|
||||
|
||||
const LEGAL_USER_AGREEMENT_KEY = 'legal.user_agreement';
|
||||
const LEGAL_PRIVACY_POLICY_KEY = 'legal.privacy_policy';
|
||||
@@ -370,22 +371,14 @@ const OtherSetting = () => {
|
||||
|
||||
return (
|
||||
<Row>
|
||||
<Col
|
||||
span={24}
|
||||
style={{
|
||||
marginTop: '10px',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '10px',
|
||||
}}
|
||||
>
|
||||
<Col span={24} className='settings-other-sections'>
|
||||
{/* 版本信息 */}
|
||||
<Form>
|
||||
<Card>
|
||||
<Form.Section text={t('系统信息')}>
|
||||
<Form.Section text={t('系统信息')} className='settings-other-info'>
|
||||
<Row>
|
||||
<Col span={16}>
|
||||
<Space>
|
||||
<Col span={24}>
|
||||
<Space wrap>
|
||||
<Text>
|
||||
{t('当前版本')}:
|
||||
{statusState?.status?.version || t('未知')}
|
||||
@@ -401,7 +394,7 @@ const OtherSetting = () => {
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col span={16}>
|
||||
<Col span={24}>
|
||||
<Text>
|
||||
{t('启动时间')}:{getStartTimeString()}
|
||||
</Text>
|
||||
@@ -416,7 +409,10 @@ const OtherSetting = () => {
|
||||
getFormApi={(formAPI) => (formAPISettingGeneral.current = formAPI)}
|
||||
>
|
||||
<Card>
|
||||
<Form.Section text={t('通用设置')}>
|
||||
<Form.Section
|
||||
text={t('通用设置')}
|
||||
className='settings-other-fields'
|
||||
>
|
||||
<Form.TextArea
|
||||
label={t('公告')}
|
||||
placeholder={t(
|
||||
@@ -477,7 +473,10 @@ const OtherSetting = () => {
|
||||
getFormApi={(formAPI) => (formAPIPersonalization.current = formAPI)}
|
||||
>
|
||||
<Card>
|
||||
<Form.Section text={t('个性化设置')}>
|
||||
<Form.Section
|
||||
text={t('个性化设置')}
|
||||
className='settings-other-fields'
|
||||
>
|
||||
<Form.Input
|
||||
label={t('系统名称')}
|
||||
placeholder={t('在此输入系统名称')}
|
||||
|
||||
@@ -17,9 +17,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { writeClipboardText } from '../../helpers/clipboard';
|
||||
import React, { useContext, useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import UserCenterPageHeader from '../common/UserCenterPageHeader';
|
||||
import { useConsolePage } from '../console/ConsoleContext';
|
||||
import {
|
||||
API,
|
||||
showError,
|
||||
@@ -68,6 +70,7 @@ const NAV_ITEMS = [
|
||||
];
|
||||
|
||||
const PersonalSetting = () => {
|
||||
const consolePage = useConsolePage();
|
||||
const [userState, userDispatch] = useContext(UserContext);
|
||||
let navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
@@ -508,22 +511,13 @@ const PersonalSetting = () => {
|
||||
// 复制用户ID
|
||||
const copyUserId = () => {
|
||||
const userId = String(userState?.user?.id || '');
|
||||
navigator.clipboard
|
||||
.writeText(userId)
|
||||
writeClipboardText(userId)
|
||||
.then(() => {
|
||||
setUserIdCopied(true);
|
||||
setTimeout(() => setUserIdCopied(false), 2000);
|
||||
})
|
||||
.catch(() => {
|
||||
// 降级方案
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = userId;
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textarea);
|
||||
setUserIdCopied(true);
|
||||
setTimeout(() => setUserIdCopied(false), 2000);
|
||||
showError(t('复制失败,请手动复制'));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -595,12 +589,18 @@ const PersonalSetting = () => {
|
||||
const roleInfo = getRoleTag();
|
||||
|
||||
return (
|
||||
<div className='ui-personal-settings min-h-screen pt-16 sm:pt-20'>
|
||||
<div className='ui-personal-inner uc-page'>
|
||||
<UserCenterPageHeader
|
||||
title={t('个人设置')}
|
||||
subtitle={t('管理你的平台形象、账户安全与通知偏好')}
|
||||
/>
|
||||
<div
|
||||
className={`ui-personal-settings ${consolePage ? 'console-personal' : 'min-h-screen pt-16 sm:pt-20'}`}
|
||||
>
|
||||
<div
|
||||
className={`ui-personal-inner ${consolePage ? 'console-content' : 'uc-page'}`}
|
||||
>
|
||||
{!consolePage && (
|
||||
<UserCenterPageHeader
|
||||
title={t('个人设置')}
|
||||
subtitle={t('管理你的平台形象、账户安全与通知偏好')}
|
||||
/>
|
||||
)}
|
||||
<Card className='ui-personal-profile'>
|
||||
<div className='ui-profile-identity'>
|
||||
<span className='ui-profile-avatar'>
|
||||
|
||||
@@ -780,7 +780,6 @@ const SystemSetting = () => {
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '10px',
|
||||
marginTop: '10px',
|
||||
}}
|
||||
>
|
||||
<Card>
|
||||
@@ -812,7 +811,7 @@ const SystemSetting = () => {
|
||||
description={t(
|
||||
'此代理仅用于图片请求转发,Webhook通知发送等,AI API请求仍然由服务器直接发出,可在渠道设置中单独配置代理',
|
||||
)}
|
||||
style={{ marginBottom: 20, marginTop: 16 }}
|
||||
style={{ marginBlock: '16px' }}
|
||||
/>
|
||||
<Text>{t('或其兼容new-api-worker格式的其他版本')}</Text>
|
||||
<Row
|
||||
@@ -1231,7 +1230,7 @@ const SystemSetting = () => {
|
||||
description={t(
|
||||
'Passkey 是基于 WebAuthn 标准的无密码身份验证方法,支持指纹、面容、硬件密钥等认证方式',
|
||||
)}
|
||||
style={{ marginBottom: 20, marginTop: 16 }}
|
||||
style={{ marginBlock: '16px' }}
|
||||
/>
|
||||
<Row
|
||||
gutter={{ xs: 8, sm: 16, md: 24, lg: 24, xl: 24, xxl: 24 }}
|
||||
@@ -1479,7 +1478,7 @@ const SystemSetting = () => {
|
||||
<Banner
|
||||
type='info'
|
||||
description={`${t('主页链接填')} ${inputs.ServerAddress ? inputs.ServerAddress : t('网站地址')},${t('重定向 URL 填')} ${inputs.ServerAddress ? inputs.ServerAddress : t('网站地址')}/oauth/oidc`}
|
||||
style={{ marginBottom: 20, marginTop: 16 }}
|
||||
style={{ marginBlock: '16px' }}
|
||||
/>
|
||||
<Text>
|
||||
{t(
|
||||
@@ -1553,7 +1552,7 @@ const SystemSetting = () => {
|
||||
<Banner
|
||||
type='info'
|
||||
description={`${t('Homepage URL 填')} ${inputs.ServerAddress ? inputs.ServerAddress : t('网站地址')},${t('Authorization callback URL 填')} ${inputs.ServerAddress ? inputs.ServerAddress : t('网站地址')}/oauth/github`}
|
||||
style={{ marginBottom: 20, marginTop: 16 }}
|
||||
style={{ marginBlock: '16px' }}
|
||||
/>
|
||||
<Row
|
||||
gutter={{ xs: 8, sm: 16, md: 24, lg: 24, xl: 24, xxl: 24 }}
|
||||
@@ -1584,7 +1583,7 @@ const SystemSetting = () => {
|
||||
<Banner
|
||||
type='info'
|
||||
description={`${t('Homepage URL 填')} ${inputs.ServerAddress ? inputs.ServerAddress : t('网站地址')},${t('Authorization callback URL 填')} ${inputs.ServerAddress ? inputs.ServerAddress : t('网站地址')}/oauth/discord`}
|
||||
style={{ marginBottom: 20, marginTop: 16 }}
|
||||
style={{ marginBlock: '16px' }}
|
||||
/>
|
||||
<Row
|
||||
gutter={{ xs: 8, sm: 16, md: 24, lg: 24, xl: 24, xxl: 24 }}
|
||||
@@ -1630,7 +1629,7 @@ const SystemSetting = () => {
|
||||
<Banner
|
||||
type='info'
|
||||
description={`${t('回调 URL 填')} ${inputs.ServerAddress ? inputs.ServerAddress : t('网站地址')}/oauth/linuxdo`}
|
||||
style={{ marginBottom: 20, marginTop: 16 }}
|
||||
style={{ marginBlock: '16px' }}
|
||||
/>
|
||||
<Row
|
||||
gutter={{ xs: 8, sm: 16, md: 24, lg: 24, xl: 24, xxl: 24 }}
|
||||
@@ -1713,7 +1712,7 @@ const SystemSetting = () => {
|
||||
window.location.origin +
|
||||
'/oauth/wechat-open'
|
||||
}
|
||||
style={{ marginBottom: 20, marginTop: 16 }}
|
||||
style={{ marginBlock: '16px' }}
|
||||
/>
|
||||
<Row
|
||||
gutter={{ xs: 8, sm: 16, md: 24, lg: 24, xl: 24, xxl: 24 }}
|
||||
@@ -1760,7 +1759,7 @@ const SystemSetting = () => {
|
||||
window.location.origin +
|
||||
'/oauth/wechat-mp'
|
||||
}
|
||||
style={{ marginBottom: 20, marginTop: 16 }}
|
||||
style={{ marginBlock: '16px' }}
|
||||
/>
|
||||
<Row
|
||||
gutter={{ xs: 8, sm: 16, md: 24, lg: 24, xl: 24, xxl: 24 }}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
.settings-page .settings-other-sections {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--console-space-2, 16px);
|
||||
}
|
||||
|
||||
/* Match the default Tabs navigation gap without stacking form margins. */
|
||||
.settings-page .settings-other-sections > .ant-form + .ant-form {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.settings-page .settings-other-info > .ant-row + .ant-row {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.settings-page .settings-other-info .ant-typography {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.settings-page .settings-other-fields {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.settings-page .settings-other-fields > .ant-btn {
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.settings-page .settings-other-fields > .ant-form-item {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
/* These individually saved fields need spacing, rather than a blank error row. */
|
||||
.settings-page .settings-other-fields .ant-form-item-control::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.settings-page .settings-other-fields .ant-form-item-explain {
|
||||
min-height: 0;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.settings-page .settings-other-fields > .ant-btn + .ant-form-item {
|
||||
margin-top: var(--settings-field-gap);
|
||||
}
|
||||
@@ -79,7 +79,7 @@ const AccountManagement = ({
|
||||
|
||||
const popContent = (
|
||||
<div className='text-xs p-2'>
|
||||
<Typography.Paragraph copyable={{ content: accountId }}>
|
||||
<Typography.Paragraph copyable={{ text: accountId }}>
|
||||
{accountId}
|
||||
</Typography.Paragraph>
|
||||
{label ? (
|
||||
|
||||
@@ -16,6 +16,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { writeClipboardText } from '../../../../helpers/clipboard';
|
||||
import { API, showError, showSuccess, showWarning } from '../../../../helpers';
|
||||
import {
|
||||
Banner,
|
||||
@@ -190,8 +192,7 @@ const TwoFASetting = ({ t }) => {
|
||||
|
||||
// 通用复制函数
|
||||
const copyTextToClipboard = (text, successMessage = t('已复制到剪贴板')) => {
|
||||
navigator.clipboard
|
||||
.writeText(text)
|
||||
writeClipboardText(text)
|
||||
.then(() => {
|
||||
showSuccess(successMessage);
|
||||
})
|
||||
|
||||
@@ -58,7 +58,7 @@ const AccountBindingSection = ({
|
||||
|
||||
const popContent = (
|
||||
<div className='text-xs p-2'>
|
||||
<Typography.Paragraph copyable={{ content: accountId }}>
|
||||
<Typography.Paragraph copyable={{ text: accountId }}>
|
||||
{accountId}
|
||||
</Typography.Paragraph>
|
||||
{label && <div className='ui-binding-popover-label'>{label}</div>}
|
||||
|
||||
@@ -71,10 +71,10 @@ const NotificationSection = ({
|
||||
const handleCopyExample = async () => {
|
||||
try {
|
||||
const success = await copy(JSON.stringify(WEBHOOK_EXAMPLE, null, 2));
|
||||
Toast.success(t('已复制到剪贴板'));
|
||||
if (!success) {
|
||||
throw new Error('Copy operation failed');
|
||||
}
|
||||
Toast.success(t('已复制到剪贴板'));
|
||||
} catch (err) {
|
||||
Toast.error(t('复制失败'));
|
||||
console.error('Copy failed:', err);
|
||||
|
||||
@@ -19,6 +19,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import React from 'react';
|
||||
import { Button, Tag } from '@/components/ui';
|
||||
import { RefreshCw } from 'lucide-react';
|
||||
import { isAdmin } from '../../../helpers';
|
||||
|
||||
const AdminTokensActions = ({
|
||||
@@ -30,7 +31,7 @@ const AdminTokensActions = ({
|
||||
const hasSelection = selectedRowKeys && selectedRowKeys.length > 0;
|
||||
|
||||
return (
|
||||
<div className='flex flex-wrap items-center gap-2 w-full md:w-auto order-2 md:order-1'>
|
||||
<div className='admin-tokens-tools'>
|
||||
{hasSelection && (
|
||||
<Tag color='violet' shape='circle' size='small'>
|
||||
{t('已选 {{count}} 项', { count: selectedRowKeys.length })}
|
||||
@@ -57,7 +58,7 @@ const AdminTokensActions = ({
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
<Button size='small' type='tertiary' onClick={onRefresh}>
|
||||
<Button icon={<RefreshCw size={16} />} onClick={onRefresh}>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -18,15 +18,8 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
Button,
|
||||
Space,
|
||||
Tag,
|
||||
Typography,
|
||||
Popover,
|
||||
Dropdown,
|
||||
} from '@/components/ui';
|
||||
import { IconMore } from '@/components/ui/icons';
|
||||
import { Button, Switch, Tag as AntTag } from 'antd';
|
||||
import { Tag, Typography, Popover } from '@/components/ui';
|
||||
import {
|
||||
renderGroup,
|
||||
renderQuota,
|
||||
@@ -37,18 +30,33 @@ import {
|
||||
const { Text } = Typography;
|
||||
|
||||
const statusMeta = {
|
||||
1: { color: 'green', label: '已启用' },
|
||||
2: { color: 'grey', label: '已禁用' },
|
||||
3: { color: 'red', label: '已过期' },
|
||||
4: { color: 'orange', label: '已耗尽' },
|
||||
3: { color: 'error', label: '已过期' },
|
||||
4: { color: 'warning', label: '已耗尽' },
|
||||
};
|
||||
|
||||
const renderStatus = (status, t) => {
|
||||
const meta = statusMeta[status] || { color: 'red', label: t('未知状态') };
|
||||
const renderStatus = (status, record, t, showEnableDisableModal) => {
|
||||
const meta =
|
||||
statusMeta[status] ||
|
||||
(![1, 2].includes(status) ? { color: 'error', label: '未知状态' } : null);
|
||||
return (
|
||||
<Tag color={meta.color} shape='circle' size='small'>
|
||||
{t(meta.label)}
|
||||
</Tag>
|
||||
<div className='admin-tokens-status'>
|
||||
<Switch
|
||||
size='small'
|
||||
checked={status === 1}
|
||||
checkedChildren={t('启用')}
|
||||
unCheckedChildren={t('禁用')}
|
||||
aria-label={status === 1 ? t('禁用') : t('启用')}
|
||||
disabled={!isAdmin() || Boolean(record.DeletedAt)}
|
||||
onChange={() =>
|
||||
showEnableDisableModal(record, status === 1 ? 'disable' : 'enable')
|
||||
}
|
||||
/>
|
||||
{meta && (
|
||||
<AntTag color={meta.color} bordered={false}>
|
||||
{t(meta.label)}
|
||||
</AntTag>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -72,21 +80,17 @@ const renderUserCell = (text, record, t) => {
|
||||
);
|
||||
};
|
||||
|
||||
const renderKey = (text, record) => {
|
||||
const renderKey = (text) => {
|
||||
// 后端已脱敏,前端再加 sk- 前缀
|
||||
return (
|
||||
<code className='text-xs bg-[var(--ui-color-fill-0)] px-2 py-0.5 rounded font-mono'>
|
||||
sk-{text}
|
||||
</code>
|
||||
);
|
||||
return <code className='admin-tokens-key'>sk-{text}</code>;
|
||||
};
|
||||
|
||||
const renderQuotaCell = (text, record, t) => {
|
||||
if (record.unlimited_quota) {
|
||||
return (
|
||||
<Tag color='violet' shape='circle' size='small'>
|
||||
<AntTag color='success' bordered={false}>
|
||||
{t('无限制')}
|
||||
</Tag>
|
||||
</AntTag>
|
||||
);
|
||||
}
|
||||
const used = record.used_quota || 0;
|
||||
@@ -103,9 +107,7 @@ const renderQuotaCell = (text, record, t) => {
|
||||
);
|
||||
return (
|
||||
<Popover content={popoverContent} position='top'>
|
||||
<Tag color='white' shape='circle' size='small'>
|
||||
{renderQuota(remain)}
|
||||
</Tag>
|
||||
<span>{renderQuota(remain)}</span>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
@@ -113,13 +115,8 @@ const renderQuotaCell = (text, record, t) => {
|
||||
const renderTime = (ts, t) => {
|
||||
if (!ts || ts === 0)
|
||||
return <span className='text-[var(--ui-color-text-2)]'>—</span>;
|
||||
if (ts === -1)
|
||||
return (
|
||||
<Tag color='blue' shape='circle' size='small'>
|
||||
{t('永不过期')}
|
||||
</Tag>
|
||||
);
|
||||
return <span className='text-xs'>{timestamp2string(ts)}</span>;
|
||||
if (ts === -1) return <span>{t('永不过期')}</span>;
|
||||
return <span>{timestamp2string(ts)}</span>;
|
||||
};
|
||||
|
||||
const renderScope = (orgId, t) => {
|
||||
@@ -140,51 +137,28 @@ const renderScope = (orgId, t) => {
|
||||
const renderOperations = (
|
||||
text,
|
||||
record,
|
||||
{ showEditTokenModal, showEnableDisableModal, showDeleteTokenModal, t },
|
||||
{ showEditTokenModal, showDeleteTokenModal, t },
|
||||
) => {
|
||||
if (record.DeletedAt) return <></>;
|
||||
const isEnabled = record.status === 1;
|
||||
if (!isAdmin()) return null;
|
||||
return (
|
||||
<Space>
|
||||
<div className='admin-tokens-row-actions'>
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
type='link'
|
||||
onClick={() => showEditTokenModal(record)}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
{isEnabled ? (
|
||||
<Button
|
||||
size='small'
|
||||
type='danger'
|
||||
onClick={() => showEnableDisableModal(record, 'disable')}
|
||||
>
|
||||
{t('禁用')}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
size='small'
|
||||
onClick={() => showEnableDisableModal(record, 'enable')}
|
||||
>
|
||||
{t('启用')}
|
||||
</Button>
|
||||
)}
|
||||
<Dropdown
|
||||
trigger='click'
|
||||
position='bottomRight'
|
||||
menu={[
|
||||
{
|
||||
node: 'item',
|
||||
name: t('删除'),
|
||||
type: 'danger',
|
||||
onClick: () => showDeleteTokenModal(record),
|
||||
},
|
||||
]}
|
||||
<Button
|
||||
size='small'
|
||||
type='link'
|
||||
danger
|
||||
onClick={() => showDeleteTokenModal(record)}
|
||||
>
|
||||
<Button size='small' type='tertiary' icon={<IconMore />} />
|
||||
</Dropdown>
|
||||
</Space>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -207,10 +181,13 @@ export const getAdminTokensColumns = ({
|
||||
render: (text, record) => renderUserCell(text, record, t),
|
||||
},
|
||||
{
|
||||
title: t('密钥名称'),
|
||||
title: t('名称'),
|
||||
dataIndex: 'name',
|
||||
render: (text) => (
|
||||
<span className='truncate inline-block max-w-[160px]' title={text}>
|
||||
<span
|
||||
className='admin-tokens-name truncate inline-block max-w-[160px]'
|
||||
title={text}
|
||||
>
|
||||
{text || <Text type='tertiary'>—</Text>}
|
||||
</span>
|
||||
),
|
||||
@@ -223,8 +200,9 @@ export const getAdminTokensColumns = ({
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: 90,
|
||||
render: (text) => renderStatus(text, t),
|
||||
width: 150,
|
||||
render: (text, record) =>
|
||||
renderStatus(text, record, t, showEnableDisableModal),
|
||||
},
|
||||
{
|
||||
title: t('归属'),
|
||||
@@ -248,11 +226,7 @@ export const getAdminTokensColumns = ({
|
||||
title: t('已用额度'),
|
||||
dataIndex: 'used_quota',
|
||||
width: 110,
|
||||
render: (text) => (
|
||||
<Text type='tertiary' size='small'>
|
||||
{renderQuota(text || 0)}
|
||||
</Text>
|
||||
),
|
||||
render: (text) => <span>{renderQuota(text || 0)}</span>,
|
||||
},
|
||||
{
|
||||
title: t('创建时间'),
|
||||
@@ -273,14 +247,13 @@ export const getAdminTokensColumns = ({
|
||||
render: (text) => renderTime(text, t),
|
||||
},
|
||||
{
|
||||
title: '',
|
||||
title: t('操作'),
|
||||
dataIndex: 'operate',
|
||||
fixed: 'right',
|
||||
width: 200,
|
||||
width: 130,
|
||||
render: (text, record) =>
|
||||
renderOperations(text, record, {
|
||||
showEditTokenModal,
|
||||
showEnableDisableModal,
|
||||
showDeleteTokenModal,
|
||||
t,
|
||||
}),
|
||||
|
||||
@@ -18,29 +18,10 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Typography, Tag } from '@/components/ui';
|
||||
import { IconKey } from '@/components/ui/icons';
|
||||
import CompactModeToggle from '../../common/ui/CompactModeToggle';
|
||||
import { TableTitle } from '../../common/table/TableToolbar';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const AdminTokensDescription = ({ compactMode, setCompactMode, t }) => {
|
||||
return (
|
||||
<div className='flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full'>
|
||||
<div className='flex items-center gap-2 text-brand'>
|
||||
<IconKey />
|
||||
<Text>{t('密钥管理')}</Text>
|
||||
<Tag color='orange' shape='circle' size='small'>
|
||||
{t('管理员')}
|
||||
</Tag>
|
||||
</div>
|
||||
<CompactModeToggle
|
||||
compactMode={compactMode}
|
||||
setCompactMode={setCompactMode}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
const AdminTokensDescription = ({ t }) => (
|
||||
<TableTitle>{t('密钥列表')}</TableTitle>
|
||||
);
|
||||
|
||||
export default AdminTokensDescription;
|
||||
|
||||
@@ -20,12 +20,13 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React, { useRef } from 'react';
|
||||
import { Form, Button } from '@/components/ui';
|
||||
import { IconSearch } from '@/components/ui/icons';
|
||||
import FilterSearchButton from '../../common/table/FilterSearchButton';
|
||||
import { useFilterSearch } from '../../../hooks/common/useFilterSearch';
|
||||
|
||||
const AdminTokensFilters = ({
|
||||
formInitValues,
|
||||
setFormApi,
|
||||
searchTokens,
|
||||
debouncedSearch,
|
||||
loadTokens,
|
||||
pageSize,
|
||||
groupOptions,
|
||||
@@ -34,61 +35,71 @@ const AdminTokensFilters = ({
|
||||
t,
|
||||
}) => {
|
||||
const formApiRef = useRef(null);
|
||||
const { scheduleSearch, submitSearch, cancelPendingSearch } = useFilterSearch(
|
||||
() => searchTokens(pageSize),
|
||||
);
|
||||
|
||||
const handleReset = () => {
|
||||
if (!formApiRef.current) return;
|
||||
formApiRef.current.reset();
|
||||
cancelPendingSearch();
|
||||
// 重置后立即用初始值刷新(不走 debounce)
|
||||
loadTokens(1, pageSize, formInitValues);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
initValues={formInitValues}
|
||||
initValues={{
|
||||
...formInitValues,
|
||||
group: formInitValues.group === '' ? undefined : formInitValues.group,
|
||||
unlimited:
|
||||
formInitValues.unlimited === ''
|
||||
? undefined
|
||||
: formInitValues.unlimited,
|
||||
}}
|
||||
getFormApi={(api) => {
|
||||
setFormApi(api);
|
||||
formApiRef.current = api;
|
||||
}}
|
||||
onSubmit={() => searchTokens(pageSize)}
|
||||
onSubmit={submitSearch}
|
||||
onValueChange={scheduleSearch}
|
||||
allowEmpty
|
||||
autoComplete='off'
|
||||
layout='horizontal'
|
||||
layout='vertical'
|
||||
trigger='change'
|
||||
className='w-full md:w-auto order-1 md:order-2'
|
||||
className='admin-tokens-filter-form'
|
||||
>
|
||||
<div className='flex flex-col md:flex-row items-center gap-2 w-full md:w-auto flex-wrap'>
|
||||
<div className='w-full md:w-56'>
|
||||
<div className='admin-tokens-filter-grid'>
|
||||
<div className='admin-tokens-filter-field'>
|
||||
<Form.Input
|
||||
field='keyword'
|
||||
label={t('密钥名称 / Key 片段')}
|
||||
prefix={<IconSearch />}
|
||||
placeholder={t('密钥名称 / Key 片段')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
</div>
|
||||
<div className='w-full md:w-44'>
|
||||
<div className='admin-tokens-filter-field'>
|
||||
<Form.Input
|
||||
field='user_keyword'
|
||||
label={t('用户名/昵称')}
|
||||
placeholder={t('用户名/昵称')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
</div>
|
||||
<div className='w-full md:w-28'>
|
||||
<div className='admin-tokens-filter-field'>
|
||||
<Form.Input
|
||||
field='user_id'
|
||||
label={t('用户ID')}
|
||||
placeholder={t('用户ID')}
|
||||
type='number'
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
</div>
|
||||
<div className='w-full md:w-44'>
|
||||
<div className='admin-tokens-filter-field'>
|
||||
<Form.Select
|
||||
field='statuses'
|
||||
label={t('状态')}
|
||||
placeholder={t('状态(多选)')}
|
||||
multiple
|
||||
optionList={[
|
||||
@@ -98,42 +109,36 @@ const AdminTokensFilters = ({
|
||||
{ label: t('已耗尽'), value: 4 },
|
||||
]}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
className='w-full'
|
||||
onChange={debouncedSearch}
|
||||
/>
|
||||
</div>
|
||||
<div className='w-full md:w-36'>
|
||||
<div className='admin-tokens-filter-field'>
|
||||
<Form.Select
|
||||
field='group'
|
||||
label={t('分组')}
|
||||
placeholder={t('分组')}
|
||||
optionList={groupOptions}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
className='w-full'
|
||||
onChange={debouncedSearch}
|
||||
/>
|
||||
</div>
|
||||
<div className='w-full md:w-32'>
|
||||
<div className='admin-tokens-filter-field'>
|
||||
<Form.Select
|
||||
field='unlimited'
|
||||
placeholder={t('额度类型')}
|
||||
label={t('剩余额度')}
|
||||
placeholder={t('剩余额度')}
|
||||
optionList={[
|
||||
{ label: t('无限额度'), value: true },
|
||||
{ label: t('有限额度'), value: false },
|
||||
]}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
className='w-full'
|
||||
onChange={debouncedSearch}
|
||||
/>
|
||||
</div>
|
||||
<div className='w-full md:w-32'>
|
||||
<div className='admin-tokens-filter-field'>
|
||||
<Form.Select
|
||||
field='org_scope'
|
||||
label={t('归属')}
|
||||
placeholder={t('归属')}
|
||||
optionList={[
|
||||
{ label: t('全部'), value: 'all' },
|
||||
@@ -141,25 +146,13 @@ const AdminTokensFilters = ({
|
||||
{ label: t('企业'), value: 'org' },
|
||||
]}
|
||||
showClear={false}
|
||||
pure
|
||||
size='small'
|
||||
className='w-full'
|
||||
onChange={debouncedSearch}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex gap-2 w-full md:w-auto'>
|
||||
<Button
|
||||
type='tertiary'
|
||||
htmlType='submit'
|
||||
loading={loading || searching}
|
||||
size='small'
|
||||
>
|
||||
{t('查询')}
|
||||
</Button>
|
||||
<Button type='tertiary' onClick={handleReset} size='small'>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className='admin-tokens-filter-actions'>
|
||||
<Button onClick={handleReset}>{t('重置')}</Button>
|
||||
<FilterSearchButton loading={loading || searching} />
|
||||
</div>
|
||||
</Form>
|
||||
);
|
||||
|
||||
@@ -17,13 +17,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import TableEmpty from '../../common/table/TableEmpty';
|
||||
import React, { useMemo } from 'react';
|
||||
import { Empty } from '@/components/ui';
|
||||
import CardTable from '../../common/ui/CardTable';
|
||||
import {
|
||||
IllustrationNoResult,
|
||||
IllustrationNoResultDark,
|
||||
} from '../../common/illustrations';
|
||||
|
||||
import { getAdminTokensColumns } from './AdminTokensColumnDefs';
|
||||
|
||||
const AdminTokensTable = ({
|
||||
@@ -32,7 +29,6 @@ const AdminTokensTable = ({
|
||||
activePage,
|
||||
pageSize,
|
||||
tokenCount,
|
||||
compactMode,
|
||||
selectedRowKeys,
|
||||
setSelectedRowKeys,
|
||||
handlePageChange,
|
||||
@@ -72,20 +68,6 @@ const AdminTokensTable = ({
|
||||
[t],
|
||||
);
|
||||
|
||||
const tableColumns = useMemo(
|
||||
() =>
|
||||
compactMode
|
||||
? columns.map((col) => {
|
||||
if (col.dataIndex === 'operate') {
|
||||
const { fixed, ...rest } = col;
|
||||
return rest;
|
||||
}
|
||||
return col;
|
||||
})
|
||||
: columns,
|
||||
[compactMode, columns],
|
||||
);
|
||||
|
||||
const rowSelection = {
|
||||
selectedRowKeys,
|
||||
onChange: (keys) => setSelectedRowKeys(keys),
|
||||
@@ -93,10 +75,10 @@ const AdminTokensTable = ({
|
||||
|
||||
return (
|
||||
<CardTable
|
||||
columns={tableColumns}
|
||||
columns={columns}
|
||||
dataSource={tokens}
|
||||
rowKey='id'
|
||||
scroll={compactMode ? undefined : { x: 'max-content' }}
|
||||
scroll={{ x: 'max-content' }}
|
||||
pagination={{
|
||||
currentPage: activePage,
|
||||
pageSize: pageSize,
|
||||
@@ -110,17 +92,8 @@ const AdminTokensTable = ({
|
||||
loading={loading}
|
||||
onRow={handleRow}
|
||||
rowSelection={rowSelection}
|
||||
empty={
|
||||
<Empty
|
||||
image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
|
||||
darkModeImage={
|
||||
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
|
||||
}
|
||||
description={t('搜索无结果')}
|
||||
style={{ padding: 30 }}
|
||||
/>
|
||||
}
|
||||
className='overflow-hidden'
|
||||
empty={<TableEmpty />}
|
||||
className='admin-tokens-table overflow-hidden'
|
||||
size='middle'
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
.console-page .console-search-card .admin-tokens-filter-form {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.admin-tokens-filter-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 1rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.console-page .admin-tokens-filter-grid .ant-form-item-label > label {
|
||||
color: var(--console-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.admin-tokens-filter-actions,
|
||||
.admin-tokens-tools {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.admin-tokens-filter-actions {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.admin-tokens-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 1.25rem;
|
||||
width: 100%;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.admin-tokens-tools {
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
.console-page .console-table.admin-tokens-table .ant-table-thead > tr > th {
|
||||
height: 46px;
|
||||
padding-block: 0;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.admin-tokens-name {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.admin-tokens-key {
|
||||
font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
|
||||
font-size: 12px;
|
||||
line-height: 21px;
|
||||
}
|
||||
|
||||
.admin-tokens-status,
|
||||
.admin-tokens-row-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.admin-tokens-status {
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.admin-tokens-status .ant-tag {
|
||||
margin-inline-end: 0;
|
||||
}
|
||||
|
||||
.admin-tokens-row-actions .ant-btn {
|
||||
height: auto;
|
||||
padding: 0 4px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.admin-tokens-filter-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.admin-tokens-filter-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import './admin-tokens.css';
|
||||
import CardPro from '../../common/ui/CardPro';
|
||||
import AdminTokensTable from './AdminTokensTable';
|
||||
import AdminTokensActions from './AdminTokensActions';
|
||||
@@ -79,9 +80,6 @@ const AdminTokensPage = () => {
|
||||
handlePageSizeChange,
|
||||
handleRow,
|
||||
|
||||
compactMode,
|
||||
setCompactMode,
|
||||
|
||||
t,
|
||||
} = data;
|
||||
|
||||
@@ -150,37 +148,34 @@ const AdminTokensPage = () => {
|
||||
/>
|
||||
|
||||
<CardPro
|
||||
type='type1'
|
||||
descriptionArea={
|
||||
<AdminTokensDescription
|
||||
compactMode={compactMode}
|
||||
setCompactMode={setCompactMode}
|
||||
searchArea={
|
||||
<AdminTokensFilters
|
||||
formInitValues={formInitValues}
|
||||
setFormApi={setFormApi}
|
||||
searchTokens={searchTokens}
|
||||
debouncedSearch={debouncedSearch}
|
||||
loadTokens={loadTokens}
|
||||
pageSize={pageSize}
|
||||
groupOptions={groupOptions}
|
||||
loading={loading}
|
||||
searching={searching}
|
||||
t={t}
|
||||
/>
|
||||
}
|
||||
type='type1'
|
||||
actionsArea={
|
||||
<div className='flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full'>
|
||||
<div className='admin-tokens-toolbar'>
|
||||
<AdminTokensDescription t={t} />
|
||||
<AdminTokensActions
|
||||
selectedRowKeys={selectedRowKeys}
|
||||
onBatchAction={handleBatchClick}
|
||||
onRefresh={refresh}
|
||||
t={t}
|
||||
/>
|
||||
<AdminTokensFilters
|
||||
formInitValues={formInitValues}
|
||||
setFormApi={setFormApi}
|
||||
searchTokens={searchTokens}
|
||||
debouncedSearch={debouncedSearch}
|
||||
loadTokens={loadTokens}
|
||||
pageSize={pageSize}
|
||||
groupOptions={groupOptions}
|
||||
loading={loading}
|
||||
searching={searching}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
paginationArea={createCardProPagination({
|
||||
showRange: false,
|
||||
currentPage: activePage,
|
||||
pageSize: pageSize,
|
||||
total: tokenCount,
|
||||
@@ -197,7 +192,6 @@ const AdminTokensPage = () => {
|
||||
activePage={activePage}
|
||||
pageSize={pageSize}
|
||||
tokenCount={tokenCount}
|
||||
compactMode={compactMode}
|
||||
selectedRowKeys={selectedRowKeys}
|
||||
setSelectedRowKeys={setSelectedRowKeys}
|
||||
handlePageChange={handlePageChange}
|
||||
|
||||
@@ -24,7 +24,7 @@ const { Text } = Typography;
|
||||
|
||||
const AdminDeleteTokenModal = ({ visible, onCancel, onConfirm, token, t }) => {
|
||||
if (!token) return null;
|
||||
const isOrgToken = token.organization_id && token.organization_id > 0;
|
||||
const isOrgToken = token.organization_id > 0;
|
||||
|
||||
return (
|
||||
<Modal
|
||||
|
||||
@@ -20,10 +20,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { Modal, Form, Typography, Banner, Spin, Tag } from '@/components/ui';
|
||||
import { API, showError, renderQuotaWithPrompt } from '../../../../helpers';
|
||||
import {
|
||||
quotaToMoney,
|
||||
moneyToQuota,
|
||||
} from '../../../common/ui/QuotaInput';
|
||||
import { quotaToMoney, moneyToQuota } from '../../../common/ui/QuotaInput';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
@@ -131,7 +128,7 @@ const AdminEditTokenModal = ({
|
||||
|
||||
if (!token) return null;
|
||||
|
||||
const isOrgToken = token.organization_id && token.organization_id > 0;
|
||||
const isOrgToken = token.organization_id > 0;
|
||||
const curStatusMeta = statusMeta[token.status] || statusMeta[2];
|
||||
|
||||
return (
|
||||
|
||||
@@ -18,14 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
Button,
|
||||
Dropdown,
|
||||
Modal,
|
||||
Switch,
|
||||
Typography,
|
||||
Select,
|
||||
} from '@/components/ui';
|
||||
import { Button, Dropdown, Modal, Switch, Typography } from '@/components/ui';
|
||||
import CompactModeToggle from '../../common/ui/CompactModeToggle';
|
||||
import { isRoot } from '../../../helpers';
|
||||
|
||||
@@ -40,7 +33,7 @@ const renderBatchDeleteContent = (t) => (
|
||||
);
|
||||
|
||||
const ChannelsActions = ({
|
||||
enableBatchDelete,
|
||||
selectedChannels,
|
||||
batchDeleteChannels,
|
||||
setShowBatchSetTag,
|
||||
testAllChannels,
|
||||
@@ -50,17 +43,9 @@ const ChannelsActions = ({
|
||||
compactMode,
|
||||
setCompactMode,
|
||||
idSort,
|
||||
setIdSort,
|
||||
setEnableBatchDelete,
|
||||
enableTagMode,
|
||||
setEnableTagMode,
|
||||
statusFilter,
|
||||
setStatusFilter,
|
||||
getFormValues,
|
||||
loadChannels,
|
||||
searchChannels,
|
||||
activeTypeKey,
|
||||
activePage,
|
||||
pageSize,
|
||||
setActivePage,
|
||||
t,
|
||||
@@ -74,7 +59,7 @@ const ChannelsActions = ({
|
||||
{isRoot() && (
|
||||
<Button
|
||||
size='small'
|
||||
disabled={!enableBatchDelete}
|
||||
disabled={!selectedChannels.length}
|
||||
type='danger'
|
||||
className='w-full md:w-auto'
|
||||
onClick={() => {
|
||||
@@ -92,7 +77,7 @@ const ChannelsActions = ({
|
||||
{isRoot() && (
|
||||
<Button
|
||||
size='small'
|
||||
disabled={!enableBatchDelete}
|
||||
disabled={!selectedChannels.length}
|
||||
type='tertiary'
|
||||
onClick={() => setShowBatchSetTag(true)}
|
||||
className='w-full md:w-auto'
|
||||
@@ -209,54 +194,6 @@ const ChannelsActions = ({
|
||||
|
||||
{/* 右侧:设置开关区域 */}
|
||||
<div className='flex flex-col md:flex-row items-start md:items-center gap-2 w-full md:w-auto order-1 md:order-2'>
|
||||
<div className='flex items-center justify-between w-full md:w-auto'>
|
||||
<Typography.Text strong className='mr-2'>
|
||||
{t('使用ID排序')}
|
||||
</Typography.Text>
|
||||
<Switch
|
||||
size='small'
|
||||
checked={idSort}
|
||||
onChange={(v) => {
|
||||
localStorage.setItem('id-sort', v + '');
|
||||
setIdSort(v);
|
||||
const { searchKeyword, searchGroup, searchModel } =
|
||||
getFormValues();
|
||||
if (
|
||||
searchKeyword === '' &&
|
||||
searchGroup === '' &&
|
||||
searchModel === ''
|
||||
) {
|
||||
loadChannels(activePage, pageSize, v, enableTagMode);
|
||||
} else {
|
||||
searchChannels(
|
||||
enableTagMode,
|
||||
activeTypeKey,
|
||||
statusFilter,
|
||||
activePage,
|
||||
pageSize,
|
||||
v,
|
||||
);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{isRoot() && (
|
||||
<div className='flex items-center justify-between w-full md:w-auto'>
|
||||
<Typography.Text strong className='mr-2'>
|
||||
{t('开启批量操作')}
|
||||
</Typography.Text>
|
||||
<Switch
|
||||
size='small'
|
||||
checked={enableBatchDelete}
|
||||
onChange={(v) => {
|
||||
localStorage.setItem('enable-batch-delete', v + '');
|
||||
setEnableBatchDelete(v);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className='flex items-center justify-between w-full md:w-auto'>
|
||||
<Typography.Text strong className='mr-2'>
|
||||
{t('标签聚合模式')}
|
||||
@@ -272,33 +209,6 @@ const ChannelsActions = ({
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='flex items-center justify-between w-full md:w-auto'>
|
||||
<Typography.Text strong className='mr-2'>
|
||||
{t('状态筛选')}
|
||||
</Typography.Text>
|
||||
<Select
|
||||
size='small'
|
||||
value={statusFilter}
|
||||
onChange={(v) => {
|
||||
localStorage.setItem('channel-status-filter', v);
|
||||
setStatusFilter(v);
|
||||
setActivePage(1);
|
||||
loadChannels(
|
||||
1,
|
||||
pageSize,
|
||||
idSort,
|
||||
enableTagMode,
|
||||
activeTypeKey,
|
||||
v,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<Select.Option value='all'>{t('全部')}</Select.Option>
|
||||
<Select.Option value='enabled'>{t('已启用')}</Select.Option>
|
||||
<Select.Option value='disabled'>{t('已禁用')}</Select.Option>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -17,15 +17,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { writeClipboardText } from '../../../helpers/clipboard';
|
||||
import React, { useState } from 'react';
|
||||
import { Switch } from 'antd';
|
||||
import {
|
||||
Button,
|
||||
Dropdown,
|
||||
InputNumber,
|
||||
Modal,
|
||||
Progress,
|
||||
Space,
|
||||
SplitButtonGroup,
|
||||
Tag,
|
||||
Tooltip,
|
||||
} from '@/components/ui';
|
||||
@@ -42,9 +42,39 @@ import {
|
||||
hoverOrClickTrigger,
|
||||
} from '../../../helpers';
|
||||
import { CHANNEL_OPTIONS } from '../../../constants';
|
||||
import { IconTreeTriangleDown, IconMore } from '@/components/ui/icons';
|
||||
import { IconTreeTriangleDown } from '@/components/ui/icons';
|
||||
import { ShuffleBrandIcon } from '../../common/icons/BrandIcons';
|
||||
|
||||
function ChannelStatusSwitch({ record, manageChannel, t }) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
return (
|
||||
<Switch
|
||||
size='small'
|
||||
checked={record.status === 1}
|
||||
checkedChildren={t('启用')}
|
||||
unCheckedChildren={t('禁用')}
|
||||
disabled={!isRoot()}
|
||||
loading={loading}
|
||||
aria-label={t('状态')}
|
||||
onClick={(_, event) => event.stopPropagation()}
|
||||
onChange={async (checked) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
await manageChannel(
|
||||
record.id,
|
||||
checked ? 'enable' : 'disable',
|
||||
record,
|
||||
);
|
||||
} catch (error) {
|
||||
showError(error.message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// 删除单个渠道的确认文案:若该渠道被其他渠道列为兜底,追加影响说明。
|
||||
// 查询失败不阻塞删除,仅回退为原确认文案
|
||||
const buildDeleteConfirmContent = async (channelId, t) => {
|
||||
@@ -360,8 +390,7 @@ export const getChannelsColumns = ({
|
||||
theme='outline'
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
navigator.clipboard
|
||||
.writeText(record.remark)
|
||||
writeClipboardText(record.remark)
|
||||
.then(() => {
|
||||
showSuccess(t('复制成功'));
|
||||
})
|
||||
@@ -425,13 +454,46 @@ export const getChannelsColumns = ({
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
render: (text, record, index) => {
|
||||
const statusControl =
|
||||
record.children !== undefined ? (
|
||||
renderStatus(text, record.channel_info, t)
|
||||
) : (
|
||||
<Space>
|
||||
<ChannelStatusSwitch
|
||||
record={record}
|
||||
manageChannel={manageChannel}
|
||||
t={t}
|
||||
/>
|
||||
{record.channel_info?.is_multi_key && (
|
||||
<span>
|
||||
{(record.channel_info.multi_key_size || 0) -
|
||||
Object.keys(record.channel_info.multi_key_status_list || {})
|
||||
.length}
|
||||
/{record.channel_info.multi_key_size || 0}
|
||||
</span>
|
||||
)}
|
||||
</Space>
|
||||
);
|
||||
if (text === 3) {
|
||||
if (record.other_info === '') {
|
||||
record.other_info = '{}';
|
||||
let otherInfo;
|
||||
try {
|
||||
otherInfo =
|
||||
typeof record.other_info === 'string'
|
||||
? JSON.parse(record.other_info)
|
||||
: record.other_info;
|
||||
} catch {
|
||||
return statusControl;
|
||||
}
|
||||
let otherInfo = JSON.parse(record.other_info);
|
||||
let reason = otherInfo['status_reason'];
|
||||
let time = otherInfo['status_time'];
|
||||
if (
|
||||
!otherInfo ||
|
||||
typeof otherInfo !== 'object' ||
|
||||
Array.isArray(otherInfo) ||
|
||||
(!otherInfo.status_reason && !otherInfo.status_time)
|
||||
) {
|
||||
return statusControl;
|
||||
}
|
||||
const reason = otherInfo.status_reason || '';
|
||||
const time = otherInfo.status_time;
|
||||
return (
|
||||
<div>
|
||||
<Tooltip
|
||||
@@ -439,12 +501,12 @@ export const getChannelsColumns = ({
|
||||
t('原因:') + reason + t(',时间:') + timestamp2string(time)
|
||||
}
|
||||
>
|
||||
{renderStatus(text, record.channel_info, t)}
|
||||
{statusControl}
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return renderStatus(text, record.channel_info, t);
|
||||
return statusControl;
|
||||
}
|
||||
},
|
||||
},
|
||||
@@ -660,7 +722,7 @@ export const getChannelsColumns = ({
|
||||
},
|
||||
{
|
||||
key: COLUMN_KEYS.OPERATE,
|
||||
title: '',
|
||||
title: t('操作'),
|
||||
dataIndex: 'operate',
|
||||
fixed: 'right',
|
||||
render: (text, record, index) => {
|
||||
@@ -704,105 +766,63 @@ export const getChannelsColumns = ({
|
||||
];
|
||||
|
||||
return (
|
||||
<Space wrap>
|
||||
<Space wrap className='console-module-row-actions'>
|
||||
{isRoot() && (
|
||||
<SplitButtonGroup
|
||||
className='overflow-hidden'
|
||||
aria-label={t('测试单个渠道操作项目组')}
|
||||
>
|
||||
<>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
type='tertiary'
|
||||
onClick={() => testChannel(record, '')}
|
||||
>
|
||||
{t('测试')}
|
||||
</Button>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
type='tertiary'
|
||||
icon={<IconTreeTriangleDown />}
|
||||
onClick={() => {
|
||||
setCurrentTestChannel(record);
|
||||
setShowModelTestModal(true);
|
||||
}}
|
||||
/>
|
||||
</SplitButtonGroup>
|
||||
)}
|
||||
|
||||
{isRoot() && (
|
||||
<>
|
||||
{record.status === 1 ? (
|
||||
>
|
||||
{t('批量测试')}
|
||||
</Button>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setEditingChannel(record);
|
||||
setShowEdit(true);
|
||||
}}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
<Button
|
||||
type='link'
|
||||
danger
|
||||
size='small'
|
||||
onClick={moreMenuItems[0].onClick}
|
||||
>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={moreMenuItems[1].onClick}
|
||||
>
|
||||
{t('复制')}
|
||||
</Button>
|
||||
{record.channel_info?.is_multi_key && (
|
||||
<Button
|
||||
type='danger'
|
||||
size='small'
|
||||
onClick={() =>
|
||||
manageChannel(record.id, 'disable', record)
|
||||
}
|
||||
>
|
||||
{t('禁用')}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
size='small'
|
||||
onClick={() => manageChannel(record.id, 'enable', record)}
|
||||
>
|
||||
{t('启用')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{record.channel_info?.is_multi_key ? (
|
||||
<SplitButtonGroup aria-label={t('多密钥渠道操作项目组')}>
|
||||
<Button
|
||||
type='tertiary'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setEditingChannel(record);
|
||||
setShowEdit(true);
|
||||
}}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
<Dropdown
|
||||
trigger='click'
|
||||
position='bottomRight'
|
||||
menu={[
|
||||
{
|
||||
node: 'item',
|
||||
name: t('多密钥管理'),
|
||||
onClick: () => {
|
||||
setCurrentMultiKeyChannel(record);
|
||||
setShowMultiKeyManageModal(true);
|
||||
},
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Button
|
||||
type='tertiary'
|
||||
size='small'
|
||||
icon={<IconTreeTriangleDown />}
|
||||
/>
|
||||
</Dropdown>
|
||||
</SplitButtonGroup>
|
||||
) : (
|
||||
<Button
|
||||
type='tertiary'
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setEditingChannel(record);
|
||||
setShowEdit(true);
|
||||
setCurrentMultiKeyChannel(record);
|
||||
setShowMultiKeyManageModal(true);
|
||||
}}
|
||||
>
|
||||
{t('编辑')}
|
||||
{t('多密钥管理')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Dropdown
|
||||
trigger='click'
|
||||
position='bottomRight'
|
||||
menu={moreMenuItems}
|
||||
>
|
||||
<Button icon={<IconMore />} type='tertiary' size='small' />
|
||||
</Dropdown>
|
||||
</>
|
||||
)}
|
||||
</Space>
|
||||
@@ -814,21 +834,21 @@ export const getChannelsColumns = ({
|
||||
{isRoot() && (
|
||||
<>
|
||||
<Button
|
||||
type='tertiary'
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => manageTag(record.key, 'enable')}
|
||||
>
|
||||
{t('启用全部')}
|
||||
</Button>
|
||||
<Button
|
||||
type='tertiary'
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => manageTag(record.key, 'disable')}
|
||||
>
|
||||
{t('禁用全部')}
|
||||
</Button>
|
||||
<Button
|
||||
type='tertiary'
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setShowEditTag(true);
|
||||
|
||||
@@ -18,15 +18,12 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Button, Form } from '@/components/ui';
|
||||
import { Form } from '@/components/ui';
|
||||
import { IconSearch } from '@/components/ui/icons';
|
||||
import { isRoot } from '../../../helpers';
|
||||
import { ConsoleFilterActions } from '../../console/ConsoleModuleFilters';
|
||||
import { useFilterSearch } from '../../../hooks/common/useFilterSearch';
|
||||
|
||||
const ChannelsFilters = ({
|
||||
setEditingChannel,
|
||||
setShowEdit,
|
||||
refresh,
|
||||
setShowColumnSelector,
|
||||
formInitValues,
|
||||
setFormApi,
|
||||
searchChannels,
|
||||
@@ -37,148 +34,122 @@ const ChannelsFilters = ({
|
||||
searching,
|
||||
autoBanExclusionFilter,
|
||||
setAutoBanExclusionFilter,
|
||||
statusFilter,
|
||||
setStatusFilter,
|
||||
t,
|
||||
}) => {
|
||||
const { scheduleSearch, submitSearch, cancelPendingSearch } = useFilterSearch(
|
||||
() => searchChannels(enableTagMode),
|
||||
);
|
||||
return (
|
||||
<div className='flex flex-col md:flex-row justify-between items-center gap-2 w-full'>
|
||||
<div className='flex gap-2 w-full md:w-auto order-2 md:order-1'>
|
||||
{isRoot() && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
type='primary'
|
||||
className='w-full md:w-auto'
|
||||
onClick={() => {
|
||||
setEditingChannel({
|
||||
id: undefined,
|
||||
});
|
||||
setShowEdit(true);
|
||||
}}
|
||||
>
|
||||
{t('添加渠道')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
className='w-full md:w-auto'
|
||||
onClick={refresh}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
onClick={() => setShowColumnSelector(true)}
|
||||
className='w-full md:w-auto'
|
||||
>
|
||||
{t('列设置')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className='w-full'>
|
||||
<div className='flex flex-col md:flex-row items-center gap-2 w-full md:w-auto order-1 md:order-2'>
|
||||
<Form
|
||||
initValues={formInitValues}
|
||||
initValues={{
|
||||
...formInitValues,
|
||||
searchGroup: formInitValues.searchGroup || undefined,
|
||||
}}
|
||||
getFormApi={(api) => setFormApi(api)}
|
||||
onSubmit={() => searchChannels(enableTagMode)}
|
||||
onSubmit={submitSearch}
|
||||
onValueChange={scheduleSearch}
|
||||
allowEmpty={true}
|
||||
autoComplete='off'
|
||||
layout='horizontal'
|
||||
layout='vertical'
|
||||
trigger='change'
|
||||
stopValidateWithError={false}
|
||||
className='flex flex-col md:flex-row items-center gap-2 w-full'
|
||||
className='console-module-filter-form'
|
||||
>
|
||||
<div className='relative w-full md:w-64'>
|
||||
<Form.Input
|
||||
size='small'
|
||||
field='searchKeyword'
|
||||
prefix={<IconSearch />}
|
||||
placeholder={t('渠道ID,名称,密钥,API地址')}
|
||||
showClear
|
||||
pure
|
||||
/>
|
||||
<div className='console-module-filter-grid'>
|
||||
<div className='console-module-field'>
|
||||
<Form.Input
|
||||
label={t('渠道ID,名称,密钥,API地址')}
|
||||
size='small'
|
||||
field='searchKeyword'
|
||||
prefix={<IconSearch />}
|
||||
placeholder={t('渠道ID,名称,密钥,API地址')}
|
||||
showClear
|
||||
/>
|
||||
</div>
|
||||
<div className='console-module-field'>
|
||||
<Form.Input
|
||||
label={t('模型名称')}
|
||||
size='small'
|
||||
field='searchModel'
|
||||
prefix={<IconSearch />}
|
||||
placeholder={t('模型关键字')}
|
||||
showClear
|
||||
/>
|
||||
</div>
|
||||
<div className='console-module-field'>
|
||||
<Form.Select
|
||||
label={t('分组')}
|
||||
size='small'
|
||||
field='searchGroup'
|
||||
placeholder={t('选择分组')}
|
||||
optionList={[...groupOptions]}
|
||||
className='w-full'
|
||||
showClear
|
||||
/>
|
||||
</div>
|
||||
<div className='console-module-field'>
|
||||
<Form.Select
|
||||
label={t('自动封禁')}
|
||||
size='small'
|
||||
placeholder={t('自动封禁')}
|
||||
value={autoBanExclusionFilter}
|
||||
optionList={[
|
||||
{ label: t('全部'), value: 'all' },
|
||||
{ label: t('参与'), value: 'included' },
|
||||
{ label: t('已排除'), value: 'excluded' },
|
||||
]}
|
||||
className='w-full'
|
||||
showClear
|
||||
onChange={(value) => {
|
||||
const newValue = value || 'all';
|
||||
localStorage.setItem(
|
||||
'channel-autoban-exclusion-filter',
|
||||
newValue,
|
||||
);
|
||||
setAutoBanExclusionFilter(newValue);
|
||||
scheduleSearch();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className='console-module-field'>
|
||||
<Form.Select
|
||||
label={t('状态')}
|
||||
placeholder={t('全部状态')}
|
||||
value={statusFilter}
|
||||
onChange={(value) => {
|
||||
localStorage.setItem('channel-status-filter', value);
|
||||
setStatusFilter(value);
|
||||
scheduleSearch();
|
||||
}}
|
||||
optionList={[
|
||||
{ label: t('全部'), value: 'all' },
|
||||
{ label: t('已启用'), value: 'enabled' },
|
||||
{ label: t('已禁用'), value: 'disabled' },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className='w-full md:w-48'>
|
||||
<Form.Input
|
||||
size='small'
|
||||
field='searchModel'
|
||||
prefix={<IconSearch />}
|
||||
placeholder={t('模型关键字')}
|
||||
showClear
|
||||
pure
|
||||
/>
|
||||
</div>
|
||||
<div className='w-full md:w-32'>
|
||||
<Form.Select
|
||||
size='small'
|
||||
field='searchGroup'
|
||||
placeholder={t('选择分组')}
|
||||
optionList={[
|
||||
{ label: t('选择分组'), value: null },
|
||||
...groupOptions,
|
||||
]}
|
||||
className='w-full'
|
||||
showClear
|
||||
pure
|
||||
onChange={() => {
|
||||
// 延迟执行搜索,让表单值先更新
|
||||
setTimeout(() => {
|
||||
searchChannels(enableTagMode);
|
||||
}, 0);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className='w-full md:w-32'>
|
||||
<Form.Select
|
||||
size='small'
|
||||
field='autoBanExclusionFilter'
|
||||
placeholder={t('自动封禁')}
|
||||
value={autoBanExclusionFilter}
|
||||
optionList={[
|
||||
{ label: t('全部'), value: 'all' },
|
||||
{ label: t('参与'), value: 'included' },
|
||||
{ label: t('已排除'), value: 'excluded' },
|
||||
]}
|
||||
className='w-full'
|
||||
showClear
|
||||
pure
|
||||
onChange={(value) => {
|
||||
const newValue = value || 'all';
|
||||
localStorage.setItem(
|
||||
'channel-autoban-exclusion-filter',
|
||||
newValue,
|
||||
);
|
||||
setAutoBanExclusionFilter(newValue);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
htmlType='submit'
|
||||
<ConsoleFilterActions
|
||||
loading={loading || searching}
|
||||
className='w-full md:w-auto'
|
||||
>
|
||||
{t('查询')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
onClick={() => {
|
||||
onReset={() => {
|
||||
if (formApi) {
|
||||
formApi.reset();
|
||||
cancelPendingSearch();
|
||||
setStatusFilter('all');
|
||||
setAutoBanExclusionFilter('all');
|
||||
localStorage.setItem('channel-status-filter', 'all');
|
||||
localStorage.setItem('channel-autoban-exclusion-filter', 'all');
|
||||
// 重置后立即查询,使用setTimeout确保表单重置完成
|
||||
setTimeout(() => {
|
||||
refresh();
|
||||
searchChannels(enableTagMode, undefined, 'all');
|
||||
}, 100);
|
||||
}
|
||||
}}
|
||||
className='w-full md:w-auto'
|
||||
>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
/>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -17,13 +17,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import { Empty } from '@/components/ui';
|
||||
import TableEmpty from '../../common/table/TableEmpty';
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import CardTable from '../../common/ui/CardTable';
|
||||
import {
|
||||
IllustrationNoResult,
|
||||
IllustrationNoResultDark,
|
||||
} from '../../common/illustrations';
|
||||
|
||||
import { isRoot } from '../../../helpers';
|
||||
import { getChannelsColumns } from './ChannelsColumnDefs';
|
||||
|
||||
const ChannelsTable = (channelsData) => {
|
||||
@@ -34,7 +32,7 @@ const ChannelsTable = (channelsData) => {
|
||||
activePage,
|
||||
pageSize,
|
||||
channelCount,
|
||||
enableBatchDelete,
|
||||
selectedChannels,
|
||||
compactMode,
|
||||
visibleColumns,
|
||||
setSelectedChannels,
|
||||
@@ -66,8 +64,25 @@ const ChannelsTable = (channelsData) => {
|
||||
autoBanExclusionFilter,
|
||||
// Daily quota info
|
||||
dailyQuotaInfo,
|
||||
idSort,
|
||||
setIdSort,
|
||||
enableTagMode,
|
||||
loadChannels,
|
||||
} = channelsData;
|
||||
|
||||
const [idSortOrder, setIdSortOrder] = useState('descend');
|
||||
|
||||
const handleTableChange = ({ sorter, extra, action }) => {
|
||||
if ((action ?? extra?.action) !== 'sort') return;
|
||||
const order = sorter?.columnKey === COLUMN_KEYS.ID ? sorter.order : null;
|
||||
setIdSortOrder(order || 'descend');
|
||||
const nextIdSort = Boolean(order);
|
||||
if (nextIdSort === idSort) return;
|
||||
localStorage.setItem('id-sort', String(nextIdSort));
|
||||
setIdSort(nextIdSort);
|
||||
loadChannels(activePage, pageSize, nextIdSort, enableTagMode);
|
||||
};
|
||||
|
||||
// Filter channels based on auto-ban exclusion filter
|
||||
const filteredChannels = useMemo(() => {
|
||||
if (!autoBanExclusionFilter || autoBanExclusionFilter === 'all') {
|
||||
@@ -174,14 +189,28 @@ const ChannelsTable = (channelsData) => {
|
||||
}, [visibleColumns, allColumns]);
|
||||
|
||||
const tableColumns = useMemo(() => {
|
||||
const sortableColumns = visibleColumnsList.map((column) =>
|
||||
column.key === COLUMN_KEYS.ID
|
||||
? {
|
||||
...column,
|
||||
sorter: (a, b) => {
|
||||
if (a.children !== undefined || b.children !== undefined)
|
||||
return 0;
|
||||
return Number(a.id) - Number(b.id);
|
||||
},
|
||||
sortOrder: idSort ? idSortOrder : null,
|
||||
}
|
||||
: column,
|
||||
);
|
||||
return compactMode
|
||||
? visibleColumnsList.map(({ fixed, ...rest }) => rest)
|
||||
: visibleColumnsList;
|
||||
}, [compactMode, visibleColumnsList]);
|
||||
? sortableColumns.map(({ fixed, ...rest }) => rest)
|
||||
: sortableColumns;
|
||||
}, [compactMode, visibleColumnsList, COLUMN_KEYS.ID, idSort, idSortOrder]);
|
||||
|
||||
return (
|
||||
<CardTable
|
||||
columns={tableColumns}
|
||||
onChange={handleTableChange}
|
||||
dataSource={filteredChannels}
|
||||
scroll={compactMode ? undefined : { x: 'max-content' }}
|
||||
pagination={{
|
||||
@@ -197,24 +226,21 @@ const ChannelsTable = (channelsData) => {
|
||||
expandAllRows={false}
|
||||
onRow={handleRow}
|
||||
rowSelection={
|
||||
enableBatchDelete
|
||||
isRoot()
|
||||
? {
|
||||
selectedRowKeys: selectedChannels.map(
|
||||
(channel) => channel.key ?? String(channel.id),
|
||||
),
|
||||
getCheckboxProps: (record) => ({
|
||||
disabled: record.children !== undefined,
|
||||
}),
|
||||
onChange: (selectedRowKeys, selectedRows) => {
|
||||
setSelectedChannels(selectedRows);
|
||||
},
|
||||
}
|
||||
: null
|
||||
}
|
||||
empty={
|
||||
<Empty
|
||||
image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
|
||||
darkModeImage={
|
||||
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
|
||||
}
|
||||
description={t('搜索无结果')}
|
||||
style={{ padding: 30 }}
|
||||
/>
|
||||
}
|
||||
empty={<TableEmpty />}
|
||||
className='rounded-xl overflow-hidden'
|
||||
size='middle'
|
||||
loading={loading || searching}
|
||||
|
||||
@@ -19,8 +19,11 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import React from 'react';
|
||||
import { Tabs, TabPane, Tag } from '@/components/ui';
|
||||
import { Button } from 'antd';
|
||||
import { Plus } from 'lucide-react';
|
||||
import { CHANNEL_OPTIONS } from '../../../constants';
|
||||
import { getChannelIcon } from '../../../helpers';
|
||||
import { getChannelIcon, isRoot } from '../../../helpers';
|
||||
import './channels-tabs.css';
|
||||
|
||||
const ChannelsTabs = ({
|
||||
enableTagMode,
|
||||
@@ -33,9 +36,30 @@ const ChannelsTabs = ({
|
||||
pageSize,
|
||||
idSort,
|
||||
setActivePage,
|
||||
setEditingChannel,
|
||||
setShowEdit,
|
||||
t,
|
||||
}) => {
|
||||
if (enableTagMode) return null;
|
||||
const createButton = isRoot() ? (
|
||||
<Button
|
||||
className='console-create-action'
|
||||
type='primary'
|
||||
size='middle'
|
||||
icon={<Plus size={16} />}
|
||||
onClick={() => {
|
||||
setEditingChannel({ id: undefined });
|
||||
setShowEdit(true);
|
||||
}}
|
||||
>
|
||||
{t('创建渠道')}
|
||||
</Button>
|
||||
) : null;
|
||||
|
||||
if (enableTagMode) {
|
||||
return createButton ? (
|
||||
<div className='flex justify-end'>{createButton}</div>
|
||||
) : null;
|
||||
}
|
||||
|
||||
const handleTabChange = (key) => {
|
||||
setActiveTypeKey(key);
|
||||
@@ -46,10 +70,10 @@ const ChannelsTabs = ({
|
||||
return (
|
||||
<Tabs
|
||||
activeKey={activeTypeKey}
|
||||
type='card'
|
||||
collapsible
|
||||
type='line'
|
||||
onChange={handleTabChange}
|
||||
className='mb-2'
|
||||
className='channels-tabs mb-2'
|
||||
tabBarExtraContent={createButton}
|
||||
>
|
||||
<TabPane
|
||||
itemKey='all'
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
.channels-tabs > .ant-tabs-nav > .ant-tabs-extra-content {
|
||||
align-self: flex-end;
|
||||
/* Match the space below the tab labels above the navigation divider. */
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
@@ -19,6 +19,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import React from 'react';
|
||||
import CardPro from '../../common/ui/CardPro';
|
||||
import { ColumnSettingsButton } from '../../common/table/ColumnSettings';
|
||||
import ChannelsTable from './ChannelsTable';
|
||||
import ChannelsActions from './ChannelsActions';
|
||||
import ChannelsFilters from './ChannelsFilters';
|
||||
@@ -64,11 +65,20 @@ const ChannelsPage = () => {
|
||||
|
||||
{/* Main Content */}
|
||||
<CardPro
|
||||
tableTitle={channelsData.t('渠道列表')}
|
||||
tableActionsOffset
|
||||
type='type3'
|
||||
tabsArea={<ChannelsTabs {...channelsData} />}
|
||||
actionsArea={<ChannelsActions {...channelsData} />}
|
||||
searchArea={<ChannelsFilters {...channelsData} />}
|
||||
tableActions={
|
||||
<ColumnSettingsButton
|
||||
open={channelsData.showColumnSelector}
|
||||
onClick={() => channelsData.setShowColumnSelector(true)}
|
||||
/>
|
||||
}
|
||||
paginationArea={createCardProPagination({
|
||||
showRange: false,
|
||||
currentPage: channelsData.activePage,
|
||||
pageSize: channelsData.pageSize,
|
||||
total: channelsData.channelCount,
|
||||
|
||||
@@ -18,16 +18,15 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Modal, Button, Checkbox } from '@/components/ui';
|
||||
import { ColumnVisibilitySettings } from '../../../common/table/ColumnSettings';
|
||||
import { getChannelsColumns } from '../ChannelsColumnDefs';
|
||||
|
||||
const ColumnSelectorModal = ({
|
||||
showColumnSelector,
|
||||
setShowColumnSelector,
|
||||
visibleColumns,
|
||||
handleColumnVisibilityChange,
|
||||
handleSelectAll,
|
||||
initDefaultColumns,
|
||||
setVisibleColumns,
|
||||
getDefaultColumnVisibility,
|
||||
COLUMN_KEYS,
|
||||
t,
|
||||
// Props needed for getChannelsColumns
|
||||
@@ -69,59 +68,14 @@ const ColumnSelectorModal = ({
|
||||
});
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('列设置')}
|
||||
visible={showColumnSelector}
|
||||
onCancel={() => setShowColumnSelector(false)}
|
||||
footer={
|
||||
<div className='flex justify-end'>
|
||||
<Button onClick={() => initDefaultColumns()}>{t('重置')}</Button>
|
||||
<Button onClick={() => setShowColumnSelector(false)}>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
<Button onClick={() => setShowColumnSelector(false)}>
|
||||
{t('确定')}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div style={{ marginBottom: 20 }}>
|
||||
<Checkbox
|
||||
checked={Object.values(visibleColumns).every((v) => v === true)}
|
||||
indeterminate={
|
||||
Object.values(visibleColumns).some((v) => v === true) &&
|
||||
!Object.values(visibleColumns).every((v) => v === true)
|
||||
}
|
||||
onChange={(e) => handleSelectAll(e.target.checked)}
|
||||
>
|
||||
{t('全选')}
|
||||
</Checkbox>
|
||||
</div>
|
||||
<div
|
||||
className='flex flex-wrap max-h-96 overflow-y-auto rounded-lg p-4'
|
||||
style={{ border: '1px solid var(--ui-color-border)' }}
|
||||
>
|
||||
{allColumns.map((column) => {
|
||||
// Skip columns without title
|
||||
if (!column.title) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={column.key} className='w-1/2 mb-4 pr-2'>
|
||||
<Checkbox
|
||||
checked={!!visibleColumns[column.key]}
|
||||
onChange={(e) =>
|
||||
handleColumnVisibilityChange(column.key, e.target.checked)
|
||||
}
|
||||
>
|
||||
{column.title}
|
||||
</Checkbox>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Modal>
|
||||
<ColumnVisibilitySettings
|
||||
showColumnSelector={showColumnSelector}
|
||||
setShowColumnSelector={setShowColumnSelector}
|
||||
columns={allColumns.filter((column) => !!column.title)}
|
||||
visibleColumns={visibleColumns}
|
||||
setVisibleColumns={setVisibleColumns}
|
||||
getDefaultColumnVisibility={getDefaultColumnVisibility}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import '../../../console/module-alignment.css';
|
||||
import React, { useEffect, useState, useRef, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
@@ -60,18 +61,14 @@ import ChannelKeyDisplay from '../../../common/ui/ChannelKeyDisplay';
|
||||
import { useSecureVerification } from '../../../../hooks/common/useSecureVerification';
|
||||
import { createApiCalls } from '../../../../services/secureVerification';
|
||||
import {
|
||||
IconSave,
|
||||
IconClose,
|
||||
IconServer,
|
||||
IconSetting,
|
||||
IconCode,
|
||||
IconGlobe,
|
||||
IconBolt,
|
||||
IconChevronUp,
|
||||
IconChevronDown,
|
||||
} from '@/components/ui/icons';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const { Text } = Typography;
|
||||
|
||||
const MODEL_MAPPING_EXAMPLE = {
|
||||
'gpt-3.5-turbo': 'gpt-3.5-turbo-0125',
|
||||
@@ -351,23 +348,6 @@ const EditChannelModal = (props) => {
|
||||
t,
|
||||
]);
|
||||
|
||||
// 表单块导航相关状态
|
||||
const formSectionRefs = useRef({
|
||||
basicInfo: null,
|
||||
apiConfig: null,
|
||||
modelConfig: null,
|
||||
advancedSettings: null,
|
||||
channelExtraSettings: null,
|
||||
});
|
||||
const [currentSectionIndex, setCurrentSectionIndex] = useState(0);
|
||||
const formSections = [
|
||||
'basicInfo',
|
||||
'apiConfig',
|
||||
'modelConfig',
|
||||
'advancedSettings',
|
||||
'channelExtraSettings',
|
||||
];
|
||||
const formContainerRef = useRef(null);
|
||||
const doubaoApiClickCountRef = useRef(0);
|
||||
const initialModelsRef = useRef([]);
|
||||
const initialModelMappingRef = useRef('');
|
||||
@@ -411,43 +391,6 @@ const EditChannelModal = (props) => {
|
||||
});
|
||||
};
|
||||
|
||||
// 表单导航功能
|
||||
const scrollToSection = (sectionKey) => {
|
||||
const sectionElement = formSectionRefs.current[sectionKey];
|
||||
if (sectionElement) {
|
||||
sectionElement.scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'start',
|
||||
inline: 'nearest',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const navigateToSection = (direction) => {
|
||||
const availableSections = formSections.filter((section) => {
|
||||
if (section === 'apiConfig') {
|
||||
return showApiConfigCard;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
let newIndex;
|
||||
if (direction === 'up') {
|
||||
newIndex =
|
||||
currentSectionIndex > 0
|
||||
? currentSectionIndex - 1
|
||||
: availableSections.length - 1;
|
||||
} else {
|
||||
newIndex =
|
||||
currentSectionIndex < availableSections.length - 1
|
||||
? currentSectionIndex + 1
|
||||
: 0;
|
||||
}
|
||||
|
||||
setCurrentSectionIndex(newIndex);
|
||||
scrollToSection(availableSections[newIndex]);
|
||||
};
|
||||
|
||||
const handleApiConfigSecretClick = () => {
|
||||
if (inputs.type !== 45) return;
|
||||
const next = doubaoApiClickCountRef.current + 1;
|
||||
@@ -1055,8 +998,6 @@ const EditChannelModal = (props) => {
|
||||
fetchModelGroups();
|
||||
// 重置手动输入模式状态
|
||||
setUseManualInput(false);
|
||||
// 重置导航状态
|
||||
setCurrentSectionIndex(0);
|
||||
} else {
|
||||
// 统一的模态框关闭重置逻辑
|
||||
resetModalState();
|
||||
@@ -1655,7 +1596,7 @@ const EditChannelModal = (props) => {
|
||||
|
||||
const batchAllowed = !isEdit || isMultiKeyChannel;
|
||||
const batchExtra = batchAllowed ? (
|
||||
<Space>
|
||||
<Space wrap className='console-channel-key-actions'>
|
||||
{!isEdit && (
|
||||
<Checkbox
|
||||
disabled={isEdit}
|
||||
@@ -1827,76 +1768,25 @@ const EditChannelModal = (props) => {
|
||||
return (
|
||||
<>
|
||||
<SideSheet
|
||||
placement={isEdit ? 'right' : 'left'}
|
||||
title={
|
||||
<Space>
|
||||
<Tag color='blue' shape='circle'>
|
||||
{isEdit ? t('编辑') : t('新建')}
|
||||
</Tag>
|
||||
<Title heading={4} className='m-0'>
|
||||
{isEdit ? t('更新渠道信息') : t('创建新的渠道')}
|
||||
</Title>
|
||||
</Space>
|
||||
}
|
||||
rootClassName='console-channel-drawer'
|
||||
classNames={{ header: 'console-channel-editor-header' }}
|
||||
placement='right'
|
||||
title={isEdit ? t('更新渠道信息') : t('创建新的渠道')}
|
||||
bodyStyle={{ padding: '0' }}
|
||||
visible={props.visible}
|
||||
width={isMobile ? '100%' : 600}
|
||||
footer={
|
||||
<div className='flex justify-between items-center'>
|
||||
<div className='flex gap-2'>
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
icon={<IconChevronUp />}
|
||||
onClick={() => navigateToSection('up')}
|
||||
style={{
|
||||
borderRadius: '50%',
|
||||
width: '32px',
|
||||
height: '32px',
|
||||
padding: 0,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
}}
|
||||
title={t('上一个表单块')}
|
||||
/>
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
icon={<IconChevronDown />}
|
||||
onClick={() => navigateToSection('down')}
|
||||
style={{
|
||||
borderRadius: '50%',
|
||||
width: '32px',
|
||||
height: '32px',
|
||||
padding: 0,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
}}
|
||||
title={t('下一个表单块')}
|
||||
/>
|
||||
</div>
|
||||
<Space>
|
||||
<Button
|
||||
theme='solid'
|
||||
onClick={() => formApiRef.current?.submitForm()}
|
||||
icon={<IconSave />}
|
||||
>
|
||||
{t('提交')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='light'
|
||||
type='primary'
|
||||
onClick={handleCancel}
|
||||
icon={<IconClose />}
|
||||
>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
</Space>
|
||||
<div className='console-channel-footer'>
|
||||
<Button onClick={handleCancel}>{t('取消')}</Button>
|
||||
<Button
|
||||
theme='solid'
|
||||
type='primary'
|
||||
onClick={() => formApiRef.current?.submitForm()}
|
||||
>
|
||||
{t('提交')}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
closeIcon={null}
|
||||
onCancel={() => handleCancel()}
|
||||
>
|
||||
<Form
|
||||
@@ -1907,16 +1797,12 @@ const EditChannelModal = (props) => {
|
||||
>
|
||||
{() => (
|
||||
<Spin spinning={loading}>
|
||||
<div className='p-2' ref={formContainerRef}>
|
||||
<div ref={(el) => (formSectionRefs.current.basicInfo = el)}>
|
||||
<div className='console-channel-sections p-2'>
|
||||
<div>
|
||||
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
||||
{/* Header: Basic Info */}
|
||||
<div className='flex items-center mb-2'>
|
||||
<Avatar
|
||||
size='small'
|
||||
color='blue'
|
||||
className='mr-2 shadow-md'
|
||||
>
|
||||
<div className='console-channel-section'>
|
||||
<Avatar size='small' color='blue'>
|
||||
<IconServer size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
@@ -2438,9 +2324,8 @@ const EditChannelModal = (props) => {
|
||||
<Form.Input
|
||||
field='openai_organization'
|
||||
label={t('组织')}
|
||||
placeholder={t('请输入组织org-xxx')}
|
||||
placeholder={t('组织 org-xxx(留空使用默认组织)')}
|
||||
showClear
|
||||
helpText={t('组织,不填则为默认组织')}
|
||||
onChange={(value) =>
|
||||
handleInputChange('openai_organization', value)
|
||||
}
|
||||
@@ -2451,18 +2336,14 @@ const EditChannelModal = (props) => {
|
||||
|
||||
{/* API Configuration Card */}
|
||||
{showApiConfigCard && (
|
||||
<div ref={(el) => (formSectionRefs.current.apiConfig = el)}>
|
||||
<div>
|
||||
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
||||
{/* Header: API Config */}
|
||||
<div
|
||||
className='flex items-center mb-2'
|
||||
className='console-channel-section'
|
||||
onClick={handleApiConfigSecretClick}
|
||||
>
|
||||
<Avatar
|
||||
size='small'
|
||||
color='green'
|
||||
className='mr-2 shadow-md'
|
||||
>
|
||||
<Avatar size='small' color='green'>
|
||||
<IconGlobe size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
@@ -2679,15 +2560,11 @@ const EditChannelModal = (props) => {
|
||||
)}
|
||||
|
||||
{/* Model Configuration Card */}
|
||||
<div ref={(el) => (formSectionRefs.current.modelConfig = el)}>
|
||||
<div>
|
||||
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
||||
{/* Header: Model Config */}
|
||||
<div className='flex items-center mb-2'>
|
||||
<Avatar
|
||||
size='small'
|
||||
color='purple'
|
||||
className='mr-2 shadow-md'
|
||||
>
|
||||
<div className='console-channel-section'>
|
||||
<Avatar size='small' color='purple'>
|
||||
<IconCode size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
@@ -2740,7 +2617,7 @@ const EditChannelModal = (props) => {
|
||||
};
|
||||
}}
|
||||
extraText={
|
||||
<Space wrap>
|
||||
<Space wrap className='console-channel-model-actions'>
|
||||
<Button
|
||||
size='small'
|
||||
type='primary'
|
||||
@@ -2778,13 +2655,15 @@ const EditChannelModal = (props) => {
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
onClick={() => {
|
||||
onClick={async () => {
|
||||
if (inputs.models.length === 0) {
|
||||
showInfo(t('没有模型可以复制'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
copy(inputs.models.join(','));
|
||||
if (!(await copy(inputs.models.join(',')))) {
|
||||
throw new Error('Clipboard copy failed');
|
||||
}
|
||||
showSuccess(t('模型列表已复制到剪贴板'));
|
||||
} catch (error) {
|
||||
showError(t('复制失败'));
|
||||
@@ -2888,17 +2767,11 @@ const EditChannelModal = (props) => {
|
||||
</div>
|
||||
|
||||
{/* Advanced Settings Card */}
|
||||
<div
|
||||
ref={(el) => (formSectionRefs.current.advancedSettings = el)}
|
||||
>
|
||||
<div>
|
||||
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
||||
{/* Header: Advanced Settings */}
|
||||
<div className='flex items-center mb-2'>
|
||||
<Avatar
|
||||
size='small'
|
||||
color='orange'
|
||||
className='mr-2 shadow-md'
|
||||
>
|
||||
<div className='console-channel-section'>
|
||||
<Avatar size='small' color='orange'>
|
||||
<IconSetting size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
@@ -3432,19 +3305,11 @@ const EditChannelModal = (props) => {
|
||||
</div>
|
||||
|
||||
{/* Channel Extra Settings Card */}
|
||||
<div
|
||||
ref={(el) =>
|
||||
(formSectionRefs.current.channelExtraSettings = el)
|
||||
}
|
||||
>
|
||||
<div>
|
||||
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
||||
{/* Header: Channel Extra Settings */}
|
||||
<div className='flex items-center mb-2'>
|
||||
<Avatar
|
||||
size='small'
|
||||
color='violet'
|
||||
className='mr-2 shadow-md'
|
||||
>
|
||||
<div className='console-channel-section'>
|
||||
<Avatar size='small' color='violet'>
|
||||
<IconBolt size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
|
||||
@@ -17,19 +17,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
Modal,
|
||||
Button,
|
||||
Input,
|
||||
Table,
|
||||
Tag,
|
||||
Typography,
|
||||
Select,
|
||||
} from '@/components/ui';
|
||||
import { IconSearch } from '@/components/ui/icons';
|
||||
import React, { useState } from 'react';
|
||||
import { Modal, Button, Input, Table, Tag, Typography, Select } from 'antd';
|
||||
import { Search } from 'lucide-react';
|
||||
import { copy, showError, showInfo, showSuccess } from '../../../../helpers';
|
||||
import { MODEL_TABLE_PAGE_SIZE } from '../../../../constants';
|
||||
import './model-test-modal.css';
|
||||
|
||||
const ModelTestModal = ({
|
||||
showModelTestModal,
|
||||
@@ -48,19 +41,19 @@ const ModelTestModal = ({
|
||||
setModelTablePage,
|
||||
selectedEndpointType,
|
||||
setSelectedEndpointType,
|
||||
allSelectingRef,
|
||||
isMobile,
|
||||
t,
|
||||
}) => {
|
||||
const [paginationSize, setPaginationSize] = useState(MODEL_TABLE_PAGE_SIZE);
|
||||
const hasChannel = Boolean(currentTestChannel);
|
||||
const models =
|
||||
typeof currentTestChannel?.models === 'string'
|
||||
? currentTestChannel.models.split(',').filter(Boolean)
|
||||
: [];
|
||||
|
||||
const filteredModels = hasChannel
|
||||
? currentTestChannel.models
|
||||
.split(',')
|
||||
.filter((model) =>
|
||||
model.toLowerCase().includes(modelSearchKeyword.toLowerCase()),
|
||||
)
|
||||
: [];
|
||||
const filteredModels = models.filter((model) =>
|
||||
model.toLowerCase().includes(modelSearchKeyword.toLowerCase()),
|
||||
);
|
||||
|
||||
const endpointTypeOptions = [
|
||||
{ value: '', label: t('自动检测') },
|
||||
@@ -100,8 +93,7 @@ const ModelTestModal = ({
|
||||
|
||||
const handleSelectSuccess = () => {
|
||||
if (!currentTestChannel) return;
|
||||
const successKeys = currentTestChannel.models
|
||||
.split(',')
|
||||
const successKeys = models
|
||||
.filter((m) => m.toLowerCase().includes(modelSearchKeyword.toLowerCase()))
|
||||
.filter((m) => {
|
||||
const result = modelTestResults[`${currentTestChannel.id}-${m}`];
|
||||
@@ -126,34 +118,27 @@ const ModelTestModal = ({
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: 112,
|
||||
render: (text, record) => {
|
||||
const testResult =
|
||||
modelTestResults[`${currentTestChannel.id}-${record.model}`];
|
||||
const isTesting = testingModels.has(record.model);
|
||||
|
||||
if (isTesting) {
|
||||
return (
|
||||
<Tag color='blue' shape='circle'>
|
||||
{t('测试中')}
|
||||
</Tag>
|
||||
);
|
||||
return <Tag color='processing'>{t('测试中')}</Tag>;
|
||||
}
|
||||
|
||||
if (!testResult) {
|
||||
return (
|
||||
<Tag color='grey' shape='circle'>
|
||||
{t('未开始')}
|
||||
</Tag>
|
||||
);
|
||||
return <Tag>{t('未开始')}</Tag>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='flex items-center gap-2'>
|
||||
<Tag color={testResult.success ? 'green' : 'red'} shape='circle'>
|
||||
<div className='model-test-status'>
|
||||
<Tag color={testResult.success ? 'success' : 'error'}>
|
||||
{testResult.success ? t('成功') : t('失败')}
|
||||
</Tag>
|
||||
{testResult.success && (
|
||||
<Typography.Text type='tertiary'>
|
||||
<Typography.Text type='secondary'>
|
||||
{t('请求时长: ${time}s').replace(
|
||||
'${time}',
|
||||
testResult.time.toFixed(2),
|
||||
@@ -165,13 +150,15 @@ const ModelTestModal = ({
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '',
|
||||
title: t('操作'),
|
||||
dataIndex: 'operate',
|
||||
width: 72,
|
||||
align: 'left',
|
||||
render: (text, record) => {
|
||||
const isTesting = testingModels.has(record.model);
|
||||
return (
|
||||
<Button
|
||||
type='tertiary'
|
||||
type='link'
|
||||
onClick={() =>
|
||||
testChannel(
|
||||
currentTestChannel,
|
||||
@@ -191,9 +178,7 @@ const ModelTestModal = ({
|
||||
|
||||
const dataSource = (() => {
|
||||
if (!hasChannel) return [];
|
||||
const start = (modelTablePage - 1) * MODEL_TABLE_PAGE_SIZE;
|
||||
const end = start + MODEL_TABLE_PAGE_SIZE;
|
||||
return filteredModels.slice(start, end).map((model) => ({
|
||||
return filteredModels.map((model) => ({
|
||||
model,
|
||||
key: model,
|
||||
}));
|
||||
@@ -202,114 +187,110 @@ const ModelTestModal = ({
|
||||
return (
|
||||
<Modal
|
||||
title={
|
||||
hasChannel ? (
|
||||
<div className='flex flex-col gap-2 w-full'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<Typography.Text
|
||||
strong
|
||||
className='!text-[var(--ui-color-text-0)] !text-base'
|
||||
>
|
||||
{currentTestChannel.name} {t('渠道的模型测试')}
|
||||
</Typography.Text>
|
||||
<Typography.Text type='tertiary' size='small'>
|
||||
{t('共')} {currentTestChannel.models.split(',').length}{' '}
|
||||
{t('个模型')}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
</div>
|
||||
) : null
|
||||
hasChannel ? `${currentTestChannel.name} ${t('渠道的模型测试')}` : null
|
||||
}
|
||||
visible={showModelTestModal}
|
||||
open={showModelTestModal}
|
||||
onCancel={handleCloseModal}
|
||||
footer={
|
||||
hasChannel ? (
|
||||
<div className='flex justify-end'>
|
||||
<div className='model-test-footer'>
|
||||
{isBatchTesting ? (
|
||||
<Button type='danger' onClick={handleCloseModal}>
|
||||
<Button danger onClick={handleCloseModal}>
|
||||
{t('停止测试')}
|
||||
</Button>
|
||||
) : (
|
||||
<Button type='tertiary' onClick={handleCloseModal}>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
<Button onClick={handleCloseModal}>{t('取消')}</Button>
|
||||
)}
|
||||
<Button
|
||||
type='primary'
|
||||
onClick={batchTestModels}
|
||||
loading={isBatchTesting}
|
||||
disabled={isBatchTesting}
|
||||
disabled={isBatchTesting || selectedModelKeys.length === 0}
|
||||
>
|
||||
{isBatchTesting
|
||||
? t('测试中...')
|
||||
: t('批量测试${count}个模型').replace(
|
||||
'${count}',
|
||||
filteredModels.length,
|
||||
)}
|
||||
{isBatchTesting ? t('测试中...') : t('批量测试')}
|
||||
</Button>
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
maskClosable={!isBatchTesting}
|
||||
className='!rounded-lg'
|
||||
size={isMobile ? 'full-width' : 'large'}
|
||||
rootClassName='console-overlay model-test-modal'
|
||||
width={isMobile ? 'calc(100vw - 32px)' : 514.8}
|
||||
centered
|
||||
styles={{ body: { maxHeight: 'none', overflow: 'visible' } }}
|
||||
>
|
||||
{hasChannel && (
|
||||
<div className='model-test-scroll'>
|
||||
<div className='model-test-content'>
|
||||
{/* 端点类型选择器 */}
|
||||
<div className='flex items-center gap-2 w-full mb-2'>
|
||||
<Typography.Text strong>{t('端点类型')}:</Typography.Text>
|
||||
<div className='model-test-endpoint'>
|
||||
<Typography.Text strong id='model-test-endpoint-label'>
|
||||
{t('端点类型')}:
|
||||
</Typography.Text>
|
||||
<Select
|
||||
value={selectedEndpointType}
|
||||
onChange={setSelectedEndpointType}
|
||||
optionList={endpointTypeOptions}
|
||||
className='!w-full'
|
||||
options={endpointTypeOptions}
|
||||
aria-labelledby='model-test-endpoint-label'
|
||||
placeholder={t('选择端点类型')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 搜索与操作按钮 */}
|
||||
<div className='flex items-center justify-end gap-2 w-full mb-2'>
|
||||
<div className='model-test-toolbar'>
|
||||
<Input
|
||||
placeholder={t('搜索模型...')}
|
||||
value={modelSearchKeyword}
|
||||
onChange={(v) => {
|
||||
setModelSearchKeyword(v);
|
||||
onChange={(event) => {
|
||||
setModelSearchKeyword(event.target.value);
|
||||
setModelTablePage(1);
|
||||
}}
|
||||
className='!w-full'
|
||||
prefix={<IconSearch />}
|
||||
showClear
|
||||
prefix={<Search size={16} />}
|
||||
allowClear
|
||||
/>
|
||||
|
||||
<Button onClick={handleCopySelected}>{t('复制已选')}</Button>
|
||||
|
||||
<Button type='tertiary' onClick={handleSelectSuccess}>
|
||||
{t('选择成功')}
|
||||
</Button>
|
||||
<Button onClick={handleSelectSuccess}>{t('选择成功')}</Button>
|
||||
</div>
|
||||
|
||||
<div className='model-test-list-header'>
|
||||
<Typography.Text strong>{t('模型列表')}</Typography.Text>
|
||||
<Typography.Text type='secondary'>
|
||||
{t('共 {{count}} 个模型', { count: models.length })}
|
||||
</Typography.Text>
|
||||
<Typography.Text type='secondary' aria-live='polite'>
|
||||
{t('已选择 {{count}} 个模型', {
|
||||
count: selectedModelKeys.length,
|
||||
})}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
|
||||
<Table
|
||||
size='middle'
|
||||
tableLayout='fixed'
|
||||
className='model-test-table'
|
||||
columns={columns}
|
||||
scroll={{
|
||||
x: 400,
|
||||
y: `clamp(80px, calc(100dvh - ${isMobile ? 500 : 440}px), 400px)`,
|
||||
}}
|
||||
dataSource={dataSource}
|
||||
rowSelection={{
|
||||
selectedRowKeys: selectedModelKeys,
|
||||
onChange: (keys) => {
|
||||
if (allSelectingRef.current) {
|
||||
allSelectingRef.current = false;
|
||||
return;
|
||||
}
|
||||
setSelectedModelKeys(keys);
|
||||
},
|
||||
onSelectAll: (checked) => {
|
||||
allSelectingRef.current = true;
|
||||
setSelectedModelKeys(checked ? filteredModels : []);
|
||||
},
|
||||
preserveSelectedRowKeys: true,
|
||||
columnWidth: 40,
|
||||
onChange: (keys) => setSelectedModelKeys(keys),
|
||||
}}
|
||||
pagination={{
|
||||
currentPage: modelTablePage,
|
||||
pageSize: MODEL_TABLE_PAGE_SIZE,
|
||||
current: modelTablePage,
|
||||
pageSize: paginationSize,
|
||||
total: filteredModels.length,
|
||||
showSizeChanger: false,
|
||||
onPageChange: (page) => setModelTablePage(page),
|
||||
showTotal: (total) => t('共 {{total}} 条', { total }),
|
||||
size: 'small',
|
||||
onChange: (page, size) => {
|
||||
setModelTablePage(size !== paginationSize ? 1 : page);
|
||||
setPaginationSize(size);
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
.model-test-list-header {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.model-test-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.model-test-endpoint,
|
||||
.model-test-toolbar,
|
||||
.model-test-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.model-test-endpoint > .ant-typography {
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.model-test-endpoint > .ant-select,
|
||||
.model-test-toolbar > .ant-input-affix-wrapper {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.model-test-toolbar > .ant-btn {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.model-test-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.model-test-table .ant-table-cell {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.model-test-table .ant-table-selection-column {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.model-test-table .ant-btn-link {
|
||||
padding-inline: 0;
|
||||
}
|
||||
|
||||
.model-test-table .ant-table-pagination {
|
||||
margin: 16px 0 0;
|
||||
row-gap: 8px;
|
||||
}
|
||||
|
||||
.model-test-footer {
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.model-test-toolbar {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.model-test-toolbar > .ant-input-affix-wrapper {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
}
|
||||
@@ -21,18 +21,10 @@ import React from 'react';
|
||||
import { Skeleton, Typography } from '@/components/ui';
|
||||
import { useMinimumLoadingTime } from '../../../hooks/common/useMinimumLoadingTime';
|
||||
import { IconEyeOpened } from '@/components/ui/icons';
|
||||
import CompactModeToggle from '../../common/ui/CompactModeToggle';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const MjLogsActions = ({
|
||||
loading,
|
||||
showBanner,
|
||||
isAdminUser,
|
||||
compactMode,
|
||||
setCompactMode,
|
||||
t,
|
||||
}) => {
|
||||
const MjLogsActions = ({ loading, showBanner, isAdminUser, t }) => {
|
||||
const showSkeleton = useMinimumLoadingTime(loading);
|
||||
|
||||
const placeholder = (
|
||||
@@ -56,12 +48,6 @@ const MjLogsActions = ({
|
||||
</Text>
|
||||
</div>
|
||||
</Skeleton>
|
||||
|
||||
<CompactModeToggle
|
||||
compactMode={compactMode}
|
||||
setCompactMode={setCompactMode}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -19,7 +19,9 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import React from 'react';
|
||||
import { Button, Form } from '@/components/ui';
|
||||
import { IconSearch } from '@/components/ui/icons';
|
||||
import FilterSearchButton from '../../common/table/FilterSearchButton';
|
||||
import { useFilterSearch } from '../../../hooks/common/useFilterSearch';
|
||||
import '../../common/table/log-filters.css';
|
||||
|
||||
import { DATE_RANGE_PRESETS } from '../../../constants/console.constants';
|
||||
|
||||
@@ -27,35 +29,37 @@ const MjLogsFilters = ({
|
||||
formInitValues,
|
||||
setFormApi,
|
||||
refresh,
|
||||
setShowColumnSelector,
|
||||
formApi,
|
||||
loading,
|
||||
isAdminUser,
|
||||
t,
|
||||
}) => {
|
||||
const { scheduleSearch, submitSearch, cancelPendingSearch } =
|
||||
useFilterSearch(refresh);
|
||||
return (
|
||||
<Form
|
||||
initValues={formInitValues}
|
||||
getFormApi={(api) => setFormApi(api)}
|
||||
onSubmit={refresh}
|
||||
onSubmit={submitSearch}
|
||||
onValueChange={scheduleSearch}
|
||||
allowEmpty={true}
|
||||
autoComplete='off'
|
||||
layout='vertical'
|
||||
trigger='change'
|
||||
stopValidateWithError={false}
|
||||
className='log-filter-form'
|
||||
>
|
||||
<div className='flex flex-col gap-2'>
|
||||
<div className='grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2'>
|
||||
<div className='log-filter-content'>
|
||||
<div className='log-filter-grid'>
|
||||
{/* 时间选择器 */}
|
||||
<div className='col-span-1 lg:col-span-2'>
|
||||
<div className='log-filter-wide'>
|
||||
<Form.DatePicker
|
||||
field='dateRange'
|
||||
label={t('时间范围')}
|
||||
className='w-full'
|
||||
type='dateTimeRange'
|
||||
placeholder={[t('开始时间'), t('结束时间')]}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
presets={DATE_RANGE_PRESETS.map((preset) => ({
|
||||
text: t(preset.text),
|
||||
start: preset.start(),
|
||||
@@ -67,60 +71,38 @@ const MjLogsFilters = ({
|
||||
{/* 任务 ID */}
|
||||
<Form.Input
|
||||
field='mj_id'
|
||||
prefix={<IconSearch />}
|
||||
label={t('任务 ID')}
|
||||
placeholder={t('任务 ID')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
|
||||
{/* 渠道 ID - 仅管理员可见 */}
|
||||
{isAdminUser && (
|
||||
<Form.Input
|
||||
field='channel_id'
|
||||
prefix={<IconSearch />}
|
||||
label={t('渠道 ID')}
|
||||
placeholder={t('渠道 ID')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 操作按钮区域 */}
|
||||
<div className='flex justify-between items-center'>
|
||||
<div></div>
|
||||
<div className='flex gap-2'>
|
||||
<Button
|
||||
type='tertiary'
|
||||
htmlType='submit'
|
||||
loading={loading}
|
||||
size='small'
|
||||
>
|
||||
{t('查询')}
|
||||
</Button>
|
||||
<Button
|
||||
type='tertiary'
|
||||
onClick={() => {
|
||||
if (formApi) {
|
||||
formApi.reset();
|
||||
setTimeout(() => {
|
||||
refresh();
|
||||
}, 100);
|
||||
}
|
||||
}}
|
||||
size='small'
|
||||
>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
<Button
|
||||
type='tertiary'
|
||||
onClick={() => setShowColumnSelector(true)}
|
||||
size='small'
|
||||
>
|
||||
{t('列设置')}
|
||||
</Button>
|
||||
</div>
|
||||
<div className='log-filter-actions'>
|
||||
<Button
|
||||
onClick={() => {
|
||||
if (formApi) {
|
||||
formApi.reset();
|
||||
cancelPendingSearch();
|
||||
setTimeout(() => {
|
||||
refresh();
|
||||
}, 100);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
<FilterSearchButton loading={loading} />
|
||||
</div>
|
||||
</div>
|
||||
</Form>
|
||||
|
||||
@@ -17,13 +17,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import TableEmpty from '../../common/table/TableEmpty';
|
||||
import React, { useMemo } from 'react';
|
||||
import { Empty } from '@/components/ui';
|
||||
import CardTable from '../../common/ui/CardTable';
|
||||
import {
|
||||
IllustrationNoResult,
|
||||
IllustrationNoResultDark,
|
||||
} from '../../common/illustrations';
|
||||
|
||||
import { getMjLogsColumns } from './MjLogsColumnDefs';
|
||||
|
||||
const MjLogsTable = (mjLogsData) => {
|
||||
@@ -33,7 +30,6 @@ const MjLogsTable = (mjLogsData) => {
|
||||
activePage,
|
||||
pageSize,
|
||||
logCount,
|
||||
compactMode,
|
||||
visibleColumns,
|
||||
handlePageChange,
|
||||
handlePageSizeChange,
|
||||
@@ -66,31 +62,16 @@ const MjLogsTable = (mjLogsData) => {
|
||||
return getVisibleColumns();
|
||||
}, [visibleColumns, allColumns]);
|
||||
|
||||
const tableColumns = useMemo(() => {
|
||||
return compactMode
|
||||
? visibleColumnsList.map(({ fixed, ...rest }) => rest)
|
||||
: visibleColumnsList;
|
||||
}, [compactMode, visibleColumnsList]);
|
||||
|
||||
return (
|
||||
<CardTable
|
||||
columns={tableColumns}
|
||||
columns={visibleColumnsList}
|
||||
dataSource={logs}
|
||||
rowKey='key'
|
||||
loading={loading}
|
||||
scroll={compactMode ? undefined : { x: 'max-content' }}
|
||||
scroll={{ x: 'max-content' }}
|
||||
className='rounded-xl overflow-hidden'
|
||||
size='middle'
|
||||
empty={
|
||||
<Empty
|
||||
image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
|
||||
darkModeImage={
|
||||
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
|
||||
}
|
||||
description={t('搜索无结果')}
|
||||
style={{ padding: 30 }}
|
||||
/>
|
||||
}
|
||||
empty={<TableEmpty />}
|
||||
pagination={{
|
||||
currentPage: activePage,
|
||||
pageSize: pageSize,
|
||||
|
||||
@@ -20,6 +20,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React from 'react';
|
||||
import { Layout } from '@/components/ui';
|
||||
import CardPro from '../../common/ui/CardPro';
|
||||
import { ColumnSettingsButton } from '../../common/table/ColumnSettings';
|
||||
import MjLogsTable from './MjLogsTable';
|
||||
import MjLogsActions from './MjLogsActions';
|
||||
import MjLogsFilters from './MjLogsFilters';
|
||||
@@ -41,9 +42,16 @@ const MjLogsPage = () => {
|
||||
|
||||
<Layout>
|
||||
<CardPro
|
||||
tableTitle={mjLogsData.t('调用明细')}
|
||||
type='type2'
|
||||
statsArea={<MjLogsActions {...mjLogsData} />}
|
||||
searchArea={<MjLogsFilters {...mjLogsData} />}
|
||||
tableActions={
|
||||
<ColumnSettingsButton
|
||||
open={mjLogsData.showColumnSelector}
|
||||
onClick={() => mjLogsData.setShowColumnSelector(true)}
|
||||
/>
|
||||
}
|
||||
paginationArea={createCardProPagination({
|
||||
currentPage: mjLogsData.activePage,
|
||||
pageSize: mjLogsData.pageSize,
|
||||
|
||||
@@ -18,16 +18,15 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Modal, Button, Checkbox } from '@/components/ui';
|
||||
import { ColumnVisibilitySettings } from '../../../common/table/ColumnSettings';
|
||||
import { getMjLogsColumns } from '../MjLogsColumnDefs';
|
||||
|
||||
const ColumnSelectorModal = ({
|
||||
showColumnSelector,
|
||||
setShowColumnSelector,
|
||||
visibleColumns,
|
||||
handleColumnVisibilityChange,
|
||||
handleSelectAll,
|
||||
initDefaultColumns,
|
||||
setVisibleColumns,
|
||||
getDefaultColumnVisibility,
|
||||
COLUMN_KEYS,
|
||||
isAdminUser,
|
||||
copyText,
|
||||
@@ -46,63 +45,22 @@ const ColumnSelectorModal = ({
|
||||
});
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('列设置')}
|
||||
visible={showColumnSelector}
|
||||
onCancel={() => setShowColumnSelector(false)}
|
||||
footer={
|
||||
<div className='flex justify-end'>
|
||||
<Button onClick={() => initDefaultColumns()}>{t('重置')}</Button>
|
||||
<Button onClick={() => setShowColumnSelector(false)}>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
<Button onClick={() => setShowColumnSelector(false)}>
|
||||
{t('确定')}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div style={{ marginBottom: 20 }}>
|
||||
<Checkbox
|
||||
checked={Object.values(visibleColumns).every((v) => v === true)}
|
||||
indeterminate={
|
||||
Object.values(visibleColumns).some((v) => v === true) &&
|
||||
!Object.values(visibleColumns).every((v) => v === true)
|
||||
}
|
||||
onChange={(e) => handleSelectAll(e.target.checked)}
|
||||
>
|
||||
{t('全选')}
|
||||
</Checkbox>
|
||||
</div>
|
||||
<div
|
||||
className='flex flex-wrap max-h-96 overflow-y-auto rounded-lg p-4'
|
||||
style={{ border: '1px solid var(--ui-color-border)' }}
|
||||
>
|
||||
{allColumns.map((column) => {
|
||||
// Skip admin-only columns for non-admin users
|
||||
if (
|
||||
<ColumnVisibilitySettings
|
||||
showColumnSelector={showColumnSelector}
|
||||
setShowColumnSelector={setShowColumnSelector}
|
||||
columns={allColumns.filter(
|
||||
(column) =>
|
||||
!(
|
||||
!isAdminUser &&
|
||||
(column.key === COLUMN_KEYS.CHANNEL ||
|
||||
column.key === COLUMN_KEYS.SUBMIT_RESULT)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={column.key} className='w-1/2 mb-4 pr-2'>
|
||||
<Checkbox
|
||||
checked={!!visibleColumns[column.key]}
|
||||
onChange={(e) =>
|
||||
handleColumnVisibilityChange(column.key, e.target.checked)
|
||||
}
|
||||
>
|
||||
{column.title}
|
||||
</Checkbox>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Modal>
|
||||
[COLUMN_KEYS.CHANNEL, COLUMN_KEYS.SUBMIT_RESULT].includes(
|
||||
column.key,
|
||||
)
|
||||
),
|
||||
)}
|
||||
visibleColumns={visibleColumns}
|
||||
setVisibleColumns={setVisibleColumns}
|
||||
getDefaultColumnVisibility={getDefaultColumnVisibility}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -18,17 +18,13 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
Button,
|
||||
Space,
|
||||
Tag,
|
||||
Typography,
|
||||
Modal,
|
||||
Tooltip,
|
||||
} from '@/components/ui';
|
||||
import { Button as AntButton, Tooltip as AntTooltip } from 'antd';
|
||||
import { Copy } from 'lucide-react';
|
||||
import { Button, Space, Tag, Modal, Tooltip } from '@/components/ui';
|
||||
import {
|
||||
timestamp2string,
|
||||
getLobeHubIcon,
|
||||
renderGroup,
|
||||
stringToColor,
|
||||
isRoot,
|
||||
} from '../../../helpers';
|
||||
@@ -37,8 +33,6 @@ import {
|
||||
renderDescription,
|
||||
} from '../../common/ui/RenderUtils';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
// Render timestamp
|
||||
function renderTimestamp(timestamp) {
|
||||
return <>{timestamp2string(timestamp)}</>;
|
||||
@@ -48,11 +42,7 @@ function renderTimestamp(timestamp) {
|
||||
const renderModelIconCol = (record, vendorMap) => {
|
||||
const iconKey = record?.icon || vendorMap[record?.vendor_id]?.icon;
|
||||
if (!iconKey) return '-';
|
||||
return (
|
||||
<div className='flex items-center justify-center'>
|
||||
{getLobeHubIcon(iconKey, 20)}
|
||||
</div>
|
||||
);
|
||||
return <div className='models-model-icon'>{getLobeHubIcon(iconKey, 20)}</div>;
|
||||
};
|
||||
|
||||
// Render vendor column with icon
|
||||
@@ -125,9 +115,7 @@ const renderGroups = (groups) => {
|
||||
return renderLimitedItems({
|
||||
items: groups,
|
||||
renderItem: (g, idx) => (
|
||||
<Tag key={idx} size='small' shape='circle' color={stringToColor(g)}>
|
||||
{g}
|
||||
</Tag>
|
||||
<React.Fragment key={idx}>{renderGroup(g)}</React.Fragment>
|
||||
),
|
||||
});
|
||||
};
|
||||
@@ -247,14 +235,19 @@ const renderOperations = (
|
||||
manageModel,
|
||||
refresh,
|
||||
t,
|
||||
setDetailModel,
|
||||
) => {
|
||||
return (
|
||||
<Space wrap>
|
||||
<Space wrap className='console-module-row-actions'>
|
||||
<Button type='link' size='small' onClick={() => setDetailModel(record)}>
|
||||
{t('详情')}
|
||||
</Button>
|
||||
{isRoot() && (
|
||||
<>
|
||||
{record.status === 1 ? (
|
||||
<Button
|
||||
type='danger'
|
||||
type='link'
|
||||
danger
|
||||
size='small'
|
||||
onClick={() => manageModel(record.id, 'disable', record)}
|
||||
>
|
||||
@@ -262,6 +255,7 @@ const renderOperations = (
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => manageModel(record.id, 'enable', record)}
|
||||
>
|
||||
@@ -270,7 +264,7 @@ const renderOperations = (
|
||||
)}
|
||||
|
||||
<Button
|
||||
type='tertiary'
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setEditingModel(record);
|
||||
@@ -281,7 +275,8 @@ const renderOperations = (
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type='danger'
|
||||
type='link'
|
||||
danger
|
||||
size='small'
|
||||
onClick={() => {
|
||||
Modal.confirm({
|
||||
@@ -347,8 +342,10 @@ export const getModelsColumns = ({
|
||||
setEditingModel,
|
||||
setShowEdit,
|
||||
refresh,
|
||||
copyText,
|
||||
vendorMap,
|
||||
categoryNames = {},
|
||||
setDetailModel,
|
||||
}) => {
|
||||
return [
|
||||
{
|
||||
@@ -362,9 +359,19 @@ export const getModelsColumns = ({
|
||||
title: t('模型名称'),
|
||||
dataIndex: 'model_name',
|
||||
render: (text) => (
|
||||
<Text copyable onClick={(e) => e.stopPropagation()}>
|
||||
{text}
|
||||
</Text>
|
||||
<span className='models-name-cell' onClick={(e) => e.stopPropagation()}>
|
||||
<span>{text}</span>
|
||||
<AntTooltip title={t('复制模型名称')}>
|
||||
<AntButton
|
||||
type='text'
|
||||
size='small'
|
||||
className='models-name-copy'
|
||||
aria-label={t('复制模型名称')}
|
||||
icon={<Copy size={14} />}
|
||||
onClick={() => copyText(text)}
|
||||
/>
|
||||
</AntTooltip>
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -436,7 +443,7 @@ export const getModelsColumns = ({
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '',
|
||||
title: t('操作'),
|
||||
dataIndex: 'operate',
|
||||
fixed: 'right',
|
||||
render: (text, record, index) =>
|
||||
@@ -448,6 +455,7 @@ export const getModelsColumns = ({
|
||||
manageModel,
|
||||
refresh,
|
||||
t,
|
||||
setDetailModel,
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -18,7 +18,9 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useRef } from 'react';
|
||||
import { Form, Button } from '@/components/ui';
|
||||
import { Form } from '@/components/ui';
|
||||
import { ConsoleFilterActions } from '../../console/ConsoleModuleFilters';
|
||||
import { useFilterSearch } from '../../../hooks/common/useFilterSearch';
|
||||
import { IconSearch } from '@/components/ui/icons';
|
||||
import { MODEL_CATEGORY_NAMES } from '../../../constants';
|
||||
|
||||
@@ -30,12 +32,17 @@ const ModelsFilters = ({
|
||||
searching,
|
||||
t,
|
||||
}) => {
|
||||
const { scheduleSearch, submitSearch, cancelPendingSearch } = useFilterSearch(
|
||||
() => searchModels(),
|
||||
);
|
||||
|
||||
// Handle form reset and immediate search
|
||||
const formApiRef = useRef(null);
|
||||
|
||||
const handleReset = () => {
|
||||
if (!formApiRef.current) return;
|
||||
formApiRef.current.reset();
|
||||
cancelPendingSearch();
|
||||
setTimeout(() => {
|
||||
searchModels();
|
||||
}, 100);
|
||||
@@ -43,48 +50,52 @@ const ModelsFilters = ({
|
||||
|
||||
return (
|
||||
<Form
|
||||
initValues={formInitValues}
|
||||
initValues={{
|
||||
...formInitValues,
|
||||
searchCategory: formInitValues.searchCategory || undefined,
|
||||
}}
|
||||
getFormApi={(api) => {
|
||||
setFormApi(api);
|
||||
formApiRef.current = api;
|
||||
}}
|
||||
onSubmit={searchModels}
|
||||
onSubmit={submitSearch}
|
||||
allowEmpty={true}
|
||||
autoComplete='off'
|
||||
layout='horizontal'
|
||||
layout='vertical'
|
||||
trigger='change'
|
||||
stopValidateWithError={false}
|
||||
className='w-full md:w-auto order-1 md:order-2'
|
||||
className='console-module-filter-form'
|
||||
onValueChange={scheduleSearch}
|
||||
>
|
||||
<div className='flex flex-col md:flex-row items-center gap-2 w-full md:w-auto'>
|
||||
<div className='relative w-full md:w-56'>
|
||||
<div className='console-module-filter-grid'>
|
||||
<div className='console-module-field'>
|
||||
<Form.Input
|
||||
label={t('模型名称')}
|
||||
field='searchKeyword'
|
||||
prefix={<IconSearch />}
|
||||
placeholder={t('搜索模型名称')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='relative w-full md:w-56'>
|
||||
<div className='console-module-field'>
|
||||
<Form.Input
|
||||
label={t('供应商')}
|
||||
field='searchVendor'
|
||||
prefix={<IconSearch />}
|
||||
placeholder={t('搜索供应商')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='relative w-full md:w-56'>
|
||||
<div className='console-module-field'>
|
||||
<Form.Select
|
||||
label={t('分类')}
|
||||
field='searchCategory'
|
||||
placeholder={t('选择分类')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
@@ -96,28 +107,11 @@ const ModelsFilters = ({
|
||||
))}
|
||||
</Form.Select>
|
||||
</div>
|
||||
|
||||
<div className='flex gap-2 w-full md:w-auto'>
|
||||
<Button
|
||||
type='tertiary'
|
||||
htmlType='submit'
|
||||
loading={loading || searching}
|
||||
className='flex-1 md:flex-initial md:w-auto'
|
||||
size='small'
|
||||
>
|
||||
{t('查询')}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type='tertiary'
|
||||
onClick={handleReset}
|
||||
className='flex-1 md:flex-initial md:w-auto'
|
||||
size='small'
|
||||
>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<ConsoleFilterActions
|
||||
onReset={handleReset}
|
||||
loading={loading || searching}
|
||||
/>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -17,17 +17,18 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import { Empty } from '@/components/ui';
|
||||
import TableEmpty from '../../common/table/TableEmpty';
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { Descriptions } from 'antd';
|
||||
import { Modal } from '@/components/ui';
|
||||
import CardTable from '../../common/ui/CardTable';
|
||||
import {
|
||||
IllustrationNoResult,
|
||||
IllustrationNoResultDark,
|
||||
} from '../../common/illustrations';
|
||||
|
||||
import { getModelsColumns } from './ModelsColumnDefs';
|
||||
import { useModelCategories } from '../../../hooks/models/useModelCategories';
|
||||
import './models-vendor-tabs.css';
|
||||
|
||||
const ModelsTable = (modelsData) => {
|
||||
const [detailModel, setDetailModel] = useState(null);
|
||||
const {
|
||||
models,
|
||||
loading,
|
||||
@@ -44,6 +45,7 @@ const ModelsTable = (modelsData) => {
|
||||
setShowEdit,
|
||||
refresh,
|
||||
vendorMap,
|
||||
copyText,
|
||||
t,
|
||||
} = modelsData;
|
||||
|
||||
@@ -60,6 +62,8 @@ const ModelsTable = (modelsData) => {
|
||||
refresh,
|
||||
vendorMap,
|
||||
categoryNames,
|
||||
setDetailModel,
|
||||
copyText,
|
||||
});
|
||||
}, [
|
||||
t,
|
||||
@@ -69,6 +73,7 @@ const ModelsTable = (modelsData) => {
|
||||
refresh,
|
||||
vendorMap,
|
||||
categoryNames,
|
||||
copyText,
|
||||
]);
|
||||
|
||||
// Handle compact mode by removing fixed positioning
|
||||
@@ -85,36 +90,59 @@ const ModelsTable = (modelsData) => {
|
||||
}, [compactMode, columns]);
|
||||
|
||||
return (
|
||||
<CardTable
|
||||
columns={tableColumns}
|
||||
dataSource={models}
|
||||
scroll={compactMode ? undefined : { x: 'max-content' }}
|
||||
pagination={{
|
||||
currentPage: activePage,
|
||||
pageSize: pageSize,
|
||||
total: modelCount,
|
||||
showSizeChanger: true,
|
||||
pageSizeOptions: [10, 20, 50, 100],
|
||||
onPageSizeChange: handlePageSizeChange,
|
||||
onPageChange: handlePageChange,
|
||||
}}
|
||||
hidePagination={true}
|
||||
loading={loading}
|
||||
rowSelection={rowSelection}
|
||||
onRow={handleRow}
|
||||
empty={
|
||||
<Empty
|
||||
image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
|
||||
darkModeImage={
|
||||
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
|
||||
<>
|
||||
<Modal
|
||||
title={t('详情')}
|
||||
visible={Boolean(detailModel)}
|
||||
onCancel={() => setDetailModel(null)}
|
||||
maskClosable
|
||||
footer={null}
|
||||
width={720}
|
||||
>
|
||||
<Descriptions
|
||||
className='models-detail-descriptions'
|
||||
bordered
|
||||
column={1}
|
||||
items={
|
||||
detailModel
|
||||
? columns
|
||||
.filter((column) => column.dataIndex !== 'operate')
|
||||
.map((column, key) => ({
|
||||
key,
|
||||
label: column.title,
|
||||
children: column.render
|
||||
? column.render(
|
||||
detailModel[column.dataIndex],
|
||||
detailModel,
|
||||
)
|
||||
: (detailModel[column.dataIndex] ?? '-'),
|
||||
}))
|
||||
: []
|
||||
}
|
||||
description={t('搜索无结果')}
|
||||
style={{ padding: 30 }}
|
||||
/>
|
||||
}
|
||||
className='rounded-xl overflow-hidden'
|
||||
size='middle'
|
||||
/>
|
||||
</Modal>
|
||||
<CardTable
|
||||
columns={tableColumns}
|
||||
dataSource={models}
|
||||
scroll={compactMode ? undefined : { x: 'max-content' }}
|
||||
pagination={{
|
||||
currentPage: activePage,
|
||||
pageSize: pageSize,
|
||||
total: modelCount,
|
||||
showSizeChanger: true,
|
||||
pageSizeOptions: [10, 20, 50, 100],
|
||||
onPageSizeChange: handlePageSizeChange,
|
||||
onPageChange: handlePageChange,
|
||||
}}
|
||||
hidePagination={true}
|
||||
loading={loading}
|
||||
rowSelection={rowSelection}
|
||||
onRow={handleRow}
|
||||
empty={<TableEmpty />}
|
||||
className='rounded-xl overflow-hidden'
|
||||
size='middle'
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -18,8 +18,10 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Tabs, TabPane, Tag, Button, Dropdown, Modal } from '@/components/ui';
|
||||
import { IconEdit, IconDelete } from '@/components/ui/icons';
|
||||
import { Modal } from '@/components/ui';
|
||||
import { Button } from 'antd';
|
||||
import { Plus } from 'lucide-react';
|
||||
import { IconEdit, IconClose } from '@/components/ui/icons';
|
||||
import {
|
||||
getLobeHubIcon,
|
||||
showError,
|
||||
@@ -27,6 +29,7 @@ import {
|
||||
isRoot,
|
||||
} from '../../../helpers';
|
||||
import { API } from '../../../helpers';
|
||||
import './models-vendor-tabs.css';
|
||||
|
||||
const ModelsTabs = ({
|
||||
activeVendorKey,
|
||||
@@ -52,13 +55,13 @@ const ModelsTabs = ({
|
||||
};
|
||||
|
||||
const handleEditVendor = (vendor, e) => {
|
||||
e.stopPropagation(); // 阻止事件冒泡,避免触发tab切换
|
||||
e.stopPropagation();
|
||||
setEditingVendor(vendor);
|
||||
setShowEditVendor(true);
|
||||
};
|
||||
|
||||
const handleDeleteVendor = async (vendor, e) => {
|
||||
e.stopPropagation(); // 阻止事件冒泡,避免触发tab切换
|
||||
e.stopPropagation();
|
||||
try {
|
||||
const res = await API.delete(`/api/vendors/${vendor.id}`);
|
||||
if (res.data.success) {
|
||||
@@ -80,109 +83,95 @@ const ModelsTabs = ({
|
||||
};
|
||||
|
||||
return (
|
||||
<Tabs
|
||||
activeKey={activeVendorKey}
|
||||
type='card'
|
||||
collapsible
|
||||
onChange={handleTabChange}
|
||||
className='mb-2'
|
||||
tabBarExtraContent={
|
||||
canManageVendors && (
|
||||
<div className='models-vendor-toolbar'>
|
||||
<div className='models-vendor-list' role='group' aria-label={t('供应商')}>
|
||||
<div
|
||||
className={`models-vendor-group${activeVendorKey === 'all' ? ' is-selected' : ''}`}
|
||||
>
|
||||
<Button
|
||||
type='primary'
|
||||
size='small'
|
||||
onClick={() => setShowAddVendor(true)}
|
||||
type='text'
|
||||
className='models-vendor-filter'
|
||||
aria-pressed={activeVendorKey === 'all'}
|
||||
onClick={() => handleTabChange('all')}
|
||||
>
|
||||
{t('新增供应商')}
|
||||
<span>{t('全部')}</span>
|
||||
<span className='models-vendor-count'>{vendorCounts.all || 0}</span>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
>
|
||||
<TabPane
|
||||
itemKey='all'
|
||||
tab={
|
||||
<span className='flex items-center gap-2'>
|
||||
{t('全部')}
|
||||
<Tag
|
||||
color={activeVendorKey === 'all' ? 'red' : 'grey'}
|
||||
shape='circle'
|
||||
</div>
|
||||
{vendors.map((vendor) => {
|
||||
const key = String(vendor.id);
|
||||
return (
|
||||
<div
|
||||
key={key}
|
||||
className={`models-vendor-group${activeVendorKey === key ? ' is-selected' : ''}`}
|
||||
>
|
||||
{vendorCounts['all'] || 0}
|
||||
</Tag>
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
|
||||
{vendors.map((vendor) => {
|
||||
const key = String(vendor.id);
|
||||
const count = vendorCounts[vendor.id] || 0;
|
||||
return (
|
||||
<TabPane
|
||||
key={key}
|
||||
itemKey={key}
|
||||
tab={
|
||||
<span className='flex items-center gap-2'>
|
||||
{getLobeHubIcon(vendor.icon || 'Layers', 14)}
|
||||
{vendor.name}
|
||||
<Tag
|
||||
color={activeVendorKey === key ? 'red' : 'grey'}
|
||||
shape='circle'
|
||||
>
|
||||
{count}
|
||||
</Tag>
|
||||
{canManageVendors && (
|
||||
<Dropdown
|
||||
trigger='click'
|
||||
position='bottomRight'
|
||||
render={
|
||||
<Dropdown.Menu>
|
||||
<Dropdown.Item
|
||||
icon={<IconEdit />}
|
||||
onClick={(e) => handleEditVendor(vendor, e)}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Dropdown.Item>
|
||||
<Dropdown.Item
|
||||
type='danger'
|
||||
icon={<IconDelete />}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
Modal.confirm({
|
||||
title: t('确认删除'),
|
||||
content: t(
|
||||
'确定要删除供应商 "{{name}}" 吗?此操作不可撤销。',
|
||||
{ name: vendor.name },
|
||||
),
|
||||
onOk: () => handleDeleteVendor(vendor, e),
|
||||
okText: t('删除'),
|
||||
cancelText: t('取消'),
|
||||
type: 'warning',
|
||||
okType: 'danger',
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t('删除')}
|
||||
</Dropdown.Item>
|
||||
</Dropdown.Menu>
|
||||
}
|
||||
onClickOutSide={(e) => e.stopPropagation()}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
theme='outline'
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{t('操作')}
|
||||
</Button>
|
||||
</Dropdown>
|
||||
)}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</Tabs>
|
||||
<Button
|
||||
type='text'
|
||||
className='models-vendor-filter'
|
||||
aria-pressed={activeVendorKey === key}
|
||||
onClick={() => handleTabChange(key)}
|
||||
>
|
||||
<span className='models-vendor-icon'>
|
||||
{getLobeHubIcon(vendor.icon || 'Layers', 14)}
|
||||
</span>
|
||||
<span className='models-vendor-name' title={vendor.name}>
|
||||
{vendor.name}
|
||||
</span>
|
||||
<span className='models-vendor-count'>
|
||||
{vendorCounts[vendor.id] || 0}
|
||||
</span>
|
||||
</Button>
|
||||
{canManageVendors && (
|
||||
<div className='models-vendor-actions'>
|
||||
<Button
|
||||
type='text'
|
||||
size='small'
|
||||
icon={<IconEdit />}
|
||||
aria-label={`${t('编辑')}${vendor.name}`}
|
||||
title={t('编辑')}
|
||||
onClick={(e) => handleEditVendor(vendor, e)}
|
||||
/>
|
||||
<Button
|
||||
type='text'
|
||||
danger
|
||||
size='small'
|
||||
icon={<IconClose />}
|
||||
aria-label={`${t('删除')}${vendor.name}`}
|
||||
title={t('删除')}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
Modal.confirm({
|
||||
title: t('确认删除'),
|
||||
content: t(
|
||||
'确定要删除供应商 "{{name}}" 吗?此操作不可撤销。',
|
||||
{ name: vendor.name },
|
||||
),
|
||||
onOk: () => handleDeleteVendor(vendor, e),
|
||||
okText: t('删除'),
|
||||
cancelText: t('取消'),
|
||||
type: 'warning',
|
||||
okType: 'danger',
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{canManageVendors && (
|
||||
<Button
|
||||
className='console-create-action'
|
||||
type='primary'
|
||||
size='middle'
|
||||
icon={<Plus size={16} />}
|
||||
onClick={() => setShowAddVendor(true)}
|
||||
>
|
||||
{t('新增供应商')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -98,6 +98,18 @@ const ModelsPage = () => {
|
||||
<ModelsCategoryStats t={t} />
|
||||
|
||||
<CardPro
|
||||
tableTitle={t('模型列表')}
|
||||
tableActionsOffset
|
||||
searchArea={
|
||||
<ModelsFilters
|
||||
formInitValues={formInitValues}
|
||||
setFormApi={setFormApi}
|
||||
searchModels={searchModels}
|
||||
loading={loading}
|
||||
searching={searching}
|
||||
t={t}
|
||||
/>
|
||||
}
|
||||
type='type3'
|
||||
tabsArea={<ModelsTabs {...modelsData} />}
|
||||
actionsArea={
|
||||
@@ -118,17 +130,6 @@ const ModelsPage = () => {
|
||||
setCompactMode={setCompactMode}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<div className='w-full md:w-full lg:w-auto order-1 md:order-2'>
|
||||
<ModelsFilters
|
||||
formInitValues={formInitValues}
|
||||
setFormApi={setFormApi}
|
||||
searchModels={searchModels}
|
||||
loading={loading}
|
||||
searching={searching}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
paginationArea={createCardProPagination({
|
||||
|
||||
@@ -17,7 +17,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
||||
import '../../../console/module-alignment.css';
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import JSONEditor from '../../../common/ui/JSONEditor';
|
||||
import {
|
||||
SideSheet,
|
||||
@@ -27,18 +28,17 @@ import {
|
||||
Spin,
|
||||
Typography,
|
||||
Card,
|
||||
Tag,
|
||||
Avatar,
|
||||
Col,
|
||||
Row,
|
||||
} from '@/components/ui';
|
||||
import { Save, X, FileText } from 'lucide-react';
|
||||
import { FileText } from 'lucide-react';
|
||||
import { IconLink } from '@/components/ui/icons';
|
||||
import { API, showError, showSuccess } from '../../../../helpers';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const { Text } = Typography;
|
||||
|
||||
// Example endpoint template for quick fill
|
||||
const ENDPOINT_TEMPLATE = {
|
||||
@@ -63,7 +63,6 @@ const EditModelModal = (props) => {
|
||||
const isMobile = useIsMobile();
|
||||
const formApiRef = useRef(null);
|
||||
const isEdit = props.editingModel && props.editingModel.id !== undefined;
|
||||
const placement = useMemo(() => (isEdit ? 'right' : 'left'), [isEdit]);
|
||||
|
||||
// 供应商列表
|
||||
const [vendors, setVendors] = useState([]);
|
||||
@@ -308,51 +307,26 @@ const EditModelModal = (props) => {
|
||||
|
||||
return (
|
||||
<SideSheet
|
||||
placement={placement}
|
||||
title={
|
||||
<Space>
|
||||
{isEdit ? (
|
||||
<Tag color='blue' shape='circle'>
|
||||
{t('更新')}
|
||||
</Tag>
|
||||
) : (
|
||||
<Tag color='green' shape='circle'>
|
||||
{t('新建')}
|
||||
</Tag>
|
||||
)}
|
||||
<Title heading={4} className='m-0'>
|
||||
{isEdit ? t('更新模型信息') : t('创建新的模型')}
|
||||
</Title>
|
||||
</Space>
|
||||
}
|
||||
rootClassName='console-model-drawer'
|
||||
classNames={{ header: 'console-model-editor-header' }}
|
||||
placement='right'
|
||||
title={isEdit ? t('更新模型信息') : t('创建新的模型')}
|
||||
bodyStyle={{ padding: '0' }}
|
||||
visible={props.visiable}
|
||||
width={isMobile ? '100%' : 600}
|
||||
footer={
|
||||
<div className='flex justify-end'>
|
||||
<Space>
|
||||
<Button
|
||||
theme='solid'
|
||||
className='!rounded-lg'
|
||||
onClick={() => formApiRef.current?.submitForm()}
|
||||
icon={<Save size={16} />}
|
||||
loading={loading}
|
||||
>
|
||||
{t('提交')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='light'
|
||||
className='!rounded-lg'
|
||||
type='primary'
|
||||
onClick={handleCancel}
|
||||
icon={<X size={16} />}
|
||||
>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
</Space>
|
||||
<div className='console-model-footer'>
|
||||
<Button onClick={handleCancel}>{t('取消')}</Button>
|
||||
<Button
|
||||
theme='solid'
|
||||
type='primary'
|
||||
onClick={() => formApiRef.current?.submitForm()}
|
||||
loading={loading}
|
||||
>
|
||||
{t('确定')}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
closeIcon={null}
|
||||
onCancel={() => handleCancel()}
|
||||
>
|
||||
<Spin spinning={loading}>
|
||||
@@ -366,8 +340,8 @@ const EditModelModal = (props) => {
|
||||
<div className='p-2'>
|
||||
{/* 基本信息 */}
|
||||
<Card className='!rounded-2xl shadow-sm border-0'>
|
||||
<div className='flex items-center mb-2'>
|
||||
<Avatar size='small' color='green' className='mr-2 shadow-md'>
|
||||
<div className='console-model-section'>
|
||||
<Avatar size='small' color='green'>
|
||||
<FileText size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
@@ -470,7 +444,7 @@ const EditModelModal = (props) => {
|
||||
style={{ width: '100%' }}
|
||||
{...(tagGroups.length > 0 && {
|
||||
extraText: (
|
||||
<Space wrap>
|
||||
<Space wrap className='console-model-tag-presets'>
|
||||
{tagGroups.map((group) => (
|
||||
<Button
|
||||
key={group.id}
|
||||
@@ -602,7 +576,7 @@ const EditModelModal = (props) => {
|
||||
)}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<Col span={24} className='console-model-endpoints'>
|
||||
<JSONEditor
|
||||
field='endpoints'
|
||||
label={t('端点映射')}
|
||||
@@ -615,6 +589,7 @@ const EditModelModal = (props) => {
|
||||
}
|
||||
formApi={formApiRef.current}
|
||||
editorType='object'
|
||||
objectValueAutoSize={{ minRows: 3, maxRows: 8 }}
|
||||
template={ENDPOINT_TEMPLATE}
|
||||
templateLabel={t('填入模板')}
|
||||
extraText={t('留空则使用默认端点;支持 {path, method}')}
|
||||
|
||||
@@ -17,28 +17,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import '../../../console/module-alignment.css';
|
||||
import React, { useState, useRef, useEffect } from 'react';
|
||||
import JSONEditor from '../../../common/ui/JSONEditor';
|
||||
import {
|
||||
SideSheet,
|
||||
Button,
|
||||
Form,
|
||||
Typography,
|
||||
Space,
|
||||
Tag,
|
||||
Row,
|
||||
Col,
|
||||
Card,
|
||||
Avatar,
|
||||
Spin,
|
||||
} from '@/components/ui';
|
||||
import { IconLayers, IconSave, IconClose } from '@/components/ui/icons';
|
||||
import { Modal, Form, Row, Col, Spin } from '@/components/ui';
|
||||
import { API, showError, showSuccess } from '../../../../helpers';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
|
||||
// Example endpoint template for quick fill
|
||||
const ENDPOINT_TEMPLATE = {
|
||||
openai: { path: '/v1/chat/completions', method: 'POST' },
|
||||
@@ -112,53 +98,13 @@ const EditPrefillGroupModal = ({
|
||||
};
|
||||
|
||||
return (
|
||||
<SideSheet
|
||||
placement='left'
|
||||
title={
|
||||
<Space>
|
||||
{isEdit ? (
|
||||
<Tag color='blue' shape='circle'>
|
||||
{t('更新')}
|
||||
</Tag>
|
||||
) : (
|
||||
<Tag color='green' shape='circle'>
|
||||
{t('新建')}
|
||||
</Tag>
|
||||
)}
|
||||
<Title heading={4} className='m-0'>
|
||||
{isEdit ? t('更新预填组') : t('创建新的预填组')}
|
||||
</Title>
|
||||
</Space>
|
||||
}
|
||||
<Modal
|
||||
title={isEdit ? t('更新预填组') : t('创建新的预填组')}
|
||||
visible={visible}
|
||||
onCancel={onClose}
|
||||
width={isMobile ? '100%' : 600}
|
||||
bodyStyle={{ padding: '0' }}
|
||||
footer={
|
||||
<div className='flex justify-end'>
|
||||
<Space>
|
||||
<Button
|
||||
theme='solid'
|
||||
className='!rounded-lg'
|
||||
onClick={() => formRef.current?.submitForm()}
|
||||
icon={<IconSave />}
|
||||
loading={loading}
|
||||
>
|
||||
{t('提交')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='light'
|
||||
className='!rounded-lg'
|
||||
type='primary'
|
||||
onClick={onClose}
|
||||
icon={<IconClose />}
|
||||
>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
}
|
||||
closeIcon={null}
|
||||
onOk={() => formRef.current?.submitForm()}
|
||||
confirmLoading={loading}
|
||||
size={isMobile ? 'full-width' : 'small'}
|
||||
>
|
||||
<Spin spinning={loading}>
|
||||
<Form
|
||||
@@ -185,89 +131,71 @@ const EditPrefillGroupModal = ({
|
||||
}}
|
||||
onSubmit={handleSubmit}
|
||||
>
|
||||
<div className='p-2'>
|
||||
{/* 基本信息 */}
|
||||
<Card className='!rounded-2xl shadow-sm border-0'>
|
||||
<div className='flex items-center mb-2'>
|
||||
<Avatar size='small' color='green' className='mr-2 shadow-md'>
|
||||
<IconLayers size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
<Text className='text-lg font-medium'>{t('基本信息')}</Text>
|
||||
<div className='text-xs text-gray-600'>
|
||||
{t('设置预填组的基本信息')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Row gutter={12}>
|
||||
<Col span={24}>
|
||||
<Form.Input
|
||||
field='name'
|
||||
label={t('组名')}
|
||||
placeholder={t('请输入组名')}
|
||||
rules={[{ required: true, message: t('请输入组名') }]}
|
||||
showClear
|
||||
/>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<Form.Select
|
||||
field='type'
|
||||
label={t('类型')}
|
||||
placeholder={t('选择组类型')}
|
||||
optionList={typeOptions}
|
||||
rules={[{ required: true, message: t('请选择组类型') }]}
|
||||
style={{ width: '100%' }}
|
||||
onChange={(val) => setSelectedType(val)}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<Form.TextArea
|
||||
field='description'
|
||||
label={t('描述')}
|
||||
placeholder={t('请输入组描述')}
|
||||
rows={3}
|
||||
showClear
|
||||
/>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
{selectedType === 'endpoint' ? (
|
||||
<JSONEditor
|
||||
field='items'
|
||||
label={t('端点映射')}
|
||||
value={
|
||||
formRef.current?.getValue('items') ??
|
||||
(typeof editingGroup?.items === 'string'
|
||||
? editingGroup.items
|
||||
: JSON.stringify(editingGroup.items || {}, null, 2))
|
||||
}
|
||||
onChange={(val) =>
|
||||
formRef.current?.setValue('items', val)
|
||||
}
|
||||
editorType='object'
|
||||
placeholder={
|
||||
'{\n "openai": {"path": "/v1/chat/completions", "method": "POST"}\n}'
|
||||
}
|
||||
template={ENDPOINT_TEMPLATE}
|
||||
templateLabel={t('填入模板')}
|
||||
extraText={t('键为端点类型,值为路径和方法对象')}
|
||||
/>
|
||||
) : (
|
||||
<Form.TagInput
|
||||
field='items'
|
||||
label={t('项目')}
|
||||
placeholder={t('输入项目名称,按回车添加')}
|
||||
addOnBlur
|
||||
showClear
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
)}
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</div>
|
||||
<Row gutter={12}>
|
||||
<Col span={24}>
|
||||
<Form.Input
|
||||
field='name'
|
||||
label={t('组名')}
|
||||
placeholder={t('请输入组名')}
|
||||
rules={[{ required: true, message: t('请输入组名') }]}
|
||||
showClear
|
||||
/>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<Form.Select
|
||||
field='type'
|
||||
label={t('类型')}
|
||||
placeholder={t('选择组类型')}
|
||||
optionList={typeOptions}
|
||||
rules={[{ required: true, message: t('请选择组类型') }]}
|
||||
style={{ width: '100%' }}
|
||||
onChange={(val) => setSelectedType(val)}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<Form.TextArea
|
||||
field='description'
|
||||
label={t('描述')}
|
||||
placeholder={t('请输入组描述')}
|
||||
rows={3}
|
||||
showClear
|
||||
/>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
{selectedType === 'endpoint' ? (
|
||||
<JSONEditor
|
||||
field='items'
|
||||
label={t('端点映射')}
|
||||
value={
|
||||
formRef.current?.getValue('items') ??
|
||||
(typeof editingGroup?.items === 'string'
|
||||
? editingGroup.items
|
||||
: JSON.stringify(editingGroup.items || {}, null, 2))
|
||||
}
|
||||
onChange={(val) => formRef.current?.setValue('items', val)}
|
||||
editorType='object'
|
||||
placeholder={
|
||||
'{\n "openai": {"path": "/v1/chat/completions", "method": "POST"}\n}'
|
||||
}
|
||||
template={ENDPOINT_TEMPLATE}
|
||||
templateLabel={t('填入模板')}
|
||||
extraText={t('键为端点类型,值为路径和方法对象')}
|
||||
/>
|
||||
) : (
|
||||
<Form.TagInput
|
||||
field='items'
|
||||
label={t('项目')}
|
||||
placeholder={t('输入项目名称,按回车添加')}
|
||||
addOnBlur
|
||||
showClear
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
)}
|
||||
</Col>
|
||||
</Row>
|
||||
</Form>
|
||||
</Spin>
|
||||
</SideSheet>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import { MODEL_TABLE_PAGE_SIZE } from '../../../../constants';
|
||||
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
|
||||
|
||||
const MissingModelsModal = ({ visible, onClose, onConfigureModel, t }) => {
|
||||
const [paginationSize, setPaginationSize] = useState(MODEL_TABLE_PAGE_SIZE);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [missingModels, setMissingModels] = useState([]);
|
||||
const [searchKeyword, setSearchKeyword] = useState('');
|
||||
@@ -74,8 +75,8 @@ const MissingModelsModal = ({ visible, onClose, onConfigureModel, t }) => {
|
||||
);
|
||||
|
||||
const dataSource = (() => {
|
||||
const start = (currentPage - 1) * MODEL_TABLE_PAGE_SIZE;
|
||||
const end = start + MODEL_TABLE_PAGE_SIZE;
|
||||
const start = (currentPage - 1) * paginationSize;
|
||||
const end = start + paginationSize;
|
||||
return filteredModels.slice(start, end).map((model) => ({
|
||||
model,
|
||||
key: model,
|
||||
@@ -169,10 +170,14 @@ const MissingModelsModal = ({ visible, onClose, onConfigureModel, t }) => {
|
||||
dataSource={dataSource}
|
||||
pagination={{
|
||||
currentPage: currentPage,
|
||||
pageSize: MODEL_TABLE_PAGE_SIZE,
|
||||
pageSize: paginationSize,
|
||||
total: filteredModels.length,
|
||||
showSizeChanger: false,
|
||||
onPageChange: (page) => setCurrentPage(page),
|
||||
onPageSizeChange: (size) => {
|
||||
setCurrentPage(1);
|
||||
setPaginationSize(size);
|
||||
},
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
|
||||
@@ -17,7 +17,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import '../../../console/module-alignment.css';
|
||||
import React, { useState, useEffect, useCallback } from 'react';
|
||||
import {
|
||||
SideSheet,
|
||||
Button,
|
||||
@@ -50,7 +51,7 @@ import {
|
||||
renderDescription,
|
||||
} from '../../../common/ui/RenderUtils';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const { Text } = Typography;
|
||||
|
||||
const PrefillGroupManagement = ({ visible, onClose }) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -67,7 +68,7 @@ const PrefillGroupManagement = ({ visible, onClose }) => {
|
||||
];
|
||||
|
||||
// 加载组列表
|
||||
const loadGroups = async () => {
|
||||
const loadGroups = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await API.get('/api/prefill_group');
|
||||
@@ -80,7 +81,7 @@ const PrefillGroupManagement = ({ visible, onClose }) => {
|
||||
showError(t('获取组列表失败'));
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
}, [t]);
|
||||
|
||||
// 删除组
|
||||
const deleteGroup = async (id) => {
|
||||
@@ -193,20 +194,20 @@ const PrefillGroupManagement = ({ visible, onClose }) => {
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '',
|
||||
title: t('操作'),
|
||||
key: 'action',
|
||||
fixed: 'right',
|
||||
width: 140,
|
||||
render: (_, record) => (
|
||||
<Space>
|
||||
<Button size='small' onClick={() => handleEdit(record)}>
|
||||
<Space className='console-module-row-actions'>
|
||||
<Button type='link' size='small' onClick={() => handleEdit(record)}>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title={t('确定删除此组?')}
|
||||
onConfirm={() => deleteGroup(record.id)}
|
||||
>
|
||||
<Button size='small' type='danger'>
|
||||
<Button size='small' type='link' danger>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
@@ -219,33 +220,25 @@ const PrefillGroupManagement = ({ visible, onClose }) => {
|
||||
if (visible) {
|
||||
loadGroups();
|
||||
}
|
||||
}, [visible]);
|
||||
}, [visible, loadGroups]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<SideSheet
|
||||
placement='left'
|
||||
title={
|
||||
<Space>
|
||||
<Tag color='blue' shape='circle'>
|
||||
{t('管理')}
|
||||
</Tag>
|
||||
<Title heading={4} className='m-0'>
|
||||
{t('预填组管理')}
|
||||
</Title>
|
||||
</Space>
|
||||
}
|
||||
rootClassName='console-model-drawer'
|
||||
placement='right'
|
||||
title={t('预填组管理')}
|
||||
classNames={{ header: 'prefill-management-header' }}
|
||||
visible={visible}
|
||||
onCancel={onClose}
|
||||
width={isMobile ? '100%' : 800}
|
||||
bodyStyle={{ padding: '0' }}
|
||||
closeIcon={null}
|
||||
>
|
||||
<Spin spinning={loading}>
|
||||
<div className='p-2'>
|
||||
<Card className='!rounded-2xl shadow-sm border-0'>
|
||||
<div className='flex items-center mb-2'>
|
||||
<Avatar size='small' color='blue' className='mr-2 shadow-md'>
|
||||
<div className='console-model-section'>
|
||||
<Avatar size='small' color='blue'>
|
||||
<IconLayers size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
@@ -257,6 +250,7 @@ const PrefillGroupManagement = ({ visible, onClose }) => {
|
||||
</div>
|
||||
<div className='flex justify-end mb-4'>
|
||||
<Button
|
||||
className='console-create-action'
|
||||
type='primary'
|
||||
theme='solid'
|
||||
size='small'
|
||||
|
||||
@@ -41,7 +41,7 @@ const SyncWizardModal = ({ visible, onClose, onConfirm, loading, t }) => {
|
||||
visible={visible}
|
||||
onCancel={onClose}
|
||||
footer={
|
||||
<div className='flex justify-end'>
|
||||
<div className='console-model-footer'>
|
||||
{step === 1 && (
|
||||
<Button onClick={() => setStep(0)}>{t('上一步')}</Button>
|
||||
)}
|
||||
@@ -49,6 +49,7 @@ const SyncWizardModal = ({ visible, onClose, onConfirm, loading, t }) => {
|
||||
{step === 0 && (
|
||||
<Button
|
||||
type='primary'
|
||||
theme='solid'
|
||||
onClick={() => setStep(1)}
|
||||
disabled={option !== 'official'}
|
||||
>
|
||||
@@ -69,7 +70,7 @@ const SyncWizardModal = ({ visible, onClose, onConfirm, loading, t }) => {
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
width={isMobile ? '100%' : 'small'}
|
||||
width={isMobile ? '100%' : '65%'}
|
||||
>
|
||||
<div className='mb-3'>
|
||||
<Steps type='basic' current={step} size='small'>
|
||||
|
||||
@@ -54,6 +54,7 @@ const UpstreamConflictModal = ({
|
||||
t,
|
||||
loading = false,
|
||||
}) => {
|
||||
const [paginationSize, setPaginationSize] = useState(MODEL_TABLE_PAGE_SIZE);
|
||||
const [selections, setSelections] = useState({});
|
||||
const isMobile = useIsMobile();
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
@@ -247,10 +248,10 @@ const UpstreamConflictModal = ({
|
||||
]);
|
||||
|
||||
const pagedDataSource = useMemo(() => {
|
||||
const start = (currentPage - 1) * MODEL_TABLE_PAGE_SIZE;
|
||||
const end = start + MODEL_TABLE_PAGE_SIZE;
|
||||
const start = (currentPage - 1) * paginationSize;
|
||||
const end = start + paginationSize;
|
||||
return filteredDataSource.slice(start, end);
|
||||
}, [filteredDataSource, currentPage]);
|
||||
}, [filteredDataSource, currentPage, paginationSize]);
|
||||
|
||||
const handleOk = async () => {
|
||||
const payload = Object.entries(selections)
|
||||
@@ -302,10 +303,14 @@ const UpstreamConflictModal = ({
|
||||
dataSource={pagedDataSource}
|
||||
pagination={{
|
||||
currentPage: currentPage,
|
||||
pageSize: MODEL_TABLE_PAGE_SIZE,
|
||||
pageSize: paginationSize,
|
||||
total: filteredDataSource.length,
|
||||
showSizeChanger: false,
|
||||
onPageChange: (page) => setCurrentPage(page),
|
||||
onPageSizeChange: (size) => {
|
||||
setCurrentPage(1);
|
||||
setPaginationSize(size);
|
||||
},
|
||||
}}
|
||||
scroll={{ x: 'max-content' }}
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
.models-vendor-toolbar {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 16px;
|
||||
}
|
||||
|
||||
.models-vendor-list {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.models-vendor-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
max-width: 100%;
|
||||
min-height: 34px;
|
||||
padding-inline: 2px;
|
||||
border: 1px solid var(--ui-color-border);
|
||||
border-radius: var(--ui-border-radius-small);
|
||||
background: var(--ui-color-fill-0);
|
||||
}
|
||||
|
||||
.models-vendor-group.is-selected {
|
||||
border-color: var(--ui-color-primary-light-active);
|
||||
background: var(--ui-color-primary-light-default);
|
||||
}
|
||||
|
||||
.models-vendor-group .models-vendor-filter {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
gap: 8px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.models-vendor-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.models-vendor-name {
|
||||
overflow: hidden;
|
||||
max-width: 200px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.models-model-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.models-detail-descriptions .models-model-icon {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.models-name-cell {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.models-name-copy.ant-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 24px;
|
||||
min-width: 24px;
|
||||
height: 24px;
|
||||
padding: 0;
|
||||
font-size: inherit;
|
||||
color: var(--ui-color-primary);
|
||||
}
|
||||
|
||||
.models-name-cell .models-name-copy.ant-btn .lucide {
|
||||
width: 0.8em;
|
||||
height: 0.8em;
|
||||
}
|
||||
|
||||
.models-vendor-count {
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
opacity: 0.65;
|
||||
}
|
||||
|
||||
/* Sticky headers need an opaque surface below the translucent header tint. */
|
||||
.console-page[data-console-page='models']
|
||||
.console-table
|
||||
.ant-table-thead
|
||||
> tr
|
||||
> th.ant-table-cell-fix-right {
|
||||
background-color: var(--console-surface);
|
||||
background-image: linear-gradient(var(--console-fill), var(--console-fill));
|
||||
}
|
||||
|
||||
.models-vendor-actions {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.models-vendor-group:hover .models-vendor-actions,
|
||||
.models-vendor-group:focus-within .models-vendor-actions {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
@media (hover: none) {
|
||||
.models-vendor-actions {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,20 @@ import React from 'react';
|
||||
import { Typography } from '@/components/ui';
|
||||
import { Ticket } from 'lucide-react';
|
||||
import CompactModeToggle from '../../common/ui/CompactModeToggle';
|
||||
import { useConsolePage } from '../../console/ConsoleContext';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const RedemptionsDescription = ({ compactMode, setCompactMode, t }) => {
|
||||
const consolePage = useConsolePage();
|
||||
if (consolePage)
|
||||
return (
|
||||
<CompactModeToggle
|
||||
compactMode={compactMode}
|
||||
setCompactMode={setCompactMode}
|
||||
t={t}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<div className='flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full'>
|
||||
<div className='flex items-center text-orange-500'>
|
||||
|
||||
@@ -18,7 +18,8 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useRef } from 'react';
|
||||
import { Form, Button } from '@/components/ui';
|
||||
import { Form } from '@/components/ui';
|
||||
import { ConsoleSearchActions } from '../../console/ConsolePrimitives';
|
||||
import { IconSearch } from '@/components/ui/icons';
|
||||
|
||||
const RedemptionsFilters = ({
|
||||
@@ -53,10 +54,10 @@ const RedemptionsFilters = ({
|
||||
layout='horizontal'
|
||||
trigger='change'
|
||||
stopValidateWithError={false}
|
||||
className='w-full md:w-auto order-1 md:order-2'
|
||||
className='w-full'
|
||||
>
|
||||
<div className='flex flex-col md:flex-row items-center gap-2 w-full md:w-auto'>
|
||||
<div className='relative w-full md:w-64'>
|
||||
<div className='console-search-fields'>
|
||||
<div className='console-search-field'>
|
||||
<Form.Input
|
||||
field='searchKeyword'
|
||||
prefix={<IconSearch />}
|
||||
@@ -66,25 +67,11 @@ const RedemptionsFilters = ({
|
||||
size='small'
|
||||
/>
|
||||
</div>
|
||||
<div className='flex gap-2 w-full md:w-auto'>
|
||||
<Button
|
||||
type='tertiary'
|
||||
htmlType='submit'
|
||||
loading={loading || searching}
|
||||
className='flex-1 md:flex-initial md:w-auto'
|
||||
size='small'
|
||||
>
|
||||
{t('查询')}
|
||||
</Button>
|
||||
<Button
|
||||
type='tertiary'
|
||||
onClick={handleReset}
|
||||
className='flex-1 md:flex-initial md:w-auto'
|
||||
size='small'
|
||||
>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
</div>
|
||||
<ConsoleSearchActions
|
||||
onReset={handleReset}
|
||||
loading={loading || searching}
|
||||
searchLabel='查询'
|
||||
/>
|
||||
</div>
|
||||
</Form>
|
||||
);
|
||||
|
||||
@@ -71,6 +71,16 @@ const RedemptionsPage = () => {
|
||||
/>
|
||||
|
||||
<CardPro
|
||||
searchArea={
|
||||
<RedemptionsFilters
|
||||
formInitValues={formInitValues}
|
||||
setFormApi={setFormApi}
|
||||
searchRedemptions={searchRedemptions}
|
||||
loading={loading}
|
||||
searching={searching}
|
||||
t={t}
|
||||
/>
|
||||
}
|
||||
type='type1'
|
||||
descriptionArea={
|
||||
<RedemptionsDescription
|
||||
@@ -89,17 +99,6 @@ const RedemptionsPage = () => {
|
||||
batchDeleteRedemptions={batchDeleteRedemptions}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<div className='w-full md:w-full lg:w-auto order-1 md:order-2'>
|
||||
<RedemptionsFilters
|
||||
formInitValues={formInitValues}
|
||||
setFormApi={setFormApi}
|
||||
searchRedemptions={searchRedemptions}
|
||||
loading={loading}
|
||||
searching={searching}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
paginationArea={createCardProPagination({
|
||||
|
||||
@@ -28,6 +28,8 @@ import {
|
||||
Loader2,
|
||||
} from 'lucide-react';
|
||||
import { exportToCsv, formatTimestampForCsv } from '../../../helpers/exportCsv';
|
||||
import { Space, Statistic } from 'antd';
|
||||
import { useConsolePage } from '../../console/ConsoleContext';
|
||||
|
||||
// CSV 导出:仅当前页已加载的数据,避免一次性拉取全量产生巨大请求
|
||||
export const exportTaskLogsPageCsv = (logs, isAdminUser, t) => {
|
||||
@@ -98,6 +100,7 @@ const TaskLogsActions = ({
|
||||
isAdminUser,
|
||||
usageRecordMode = false,
|
||||
}) => {
|
||||
const consolePage = useConsolePage();
|
||||
const exportButtonClass =
|
||||
'hover:!bg-gray-100 dark:hover:!bg-neutral-800 !transition-all !duration-300';
|
||||
|
||||
@@ -106,6 +109,28 @@ const TaskLogsActions = ({
|
||||
|
||||
const handleExportCsv = () => exportTaskLogsPageCsv(logs, isAdminUser, t);
|
||||
|
||||
if (consolePage) {
|
||||
return (
|
||||
<div className='console-task-stats'>
|
||||
<Space wrap size={24}>
|
||||
<Statistic title={t('本页成功')} value={stats.successCount} />
|
||||
<Statistic title={t('本页失败')} value={stats.failureCount} />
|
||||
<Statistic title={t('本页进行中')} value={stats.pendingCount} />
|
||||
</Space>
|
||||
<Space wrap>
|
||||
{stats.pendingCount > 0 && <span>{t('实时更新中')}</span>}
|
||||
<Button
|
||||
icon={<Download size={16} />}
|
||||
onClick={handleExportCsv}
|
||||
disabled={!logs.length}
|
||||
>
|
||||
{t('导出本页')}
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const StatBadge = ({ icon: Icon, label, value, gradient, iconBg }) => (
|
||||
<div className='relative group'>
|
||||
<div
|
||||
|
||||
@@ -25,13 +25,15 @@ import {
|
||||
Radio,
|
||||
RotateCcw,
|
||||
Search,
|
||||
Settings2,
|
||||
Filter,
|
||||
Activity,
|
||||
Layers,
|
||||
} from 'lucide-react';
|
||||
|
||||
import { DATE_RANGE_PRESETS } from '../../../constants/console.constants';
|
||||
import { useConsolePage } from '../../console/ConsoleContext';
|
||||
import FilterSearchButton from '../../common/table/FilterSearchButton';
|
||||
import { useFilterSearch } from '../../../hooks/common/useFilterSearch';
|
||||
import {
|
||||
TASK_ACTION_FIRST_TAIL_GENERATE,
|
||||
TASK_ACTION_GENERATE,
|
||||
@@ -45,7 +47,6 @@ const TaskLogsFilters = ({
|
||||
formInitValues,
|
||||
setFormApi,
|
||||
refresh,
|
||||
setShowColumnSelector,
|
||||
formApi,
|
||||
loading,
|
||||
isAdminUser,
|
||||
@@ -54,9 +55,11 @@ const TaskLogsFilters = ({
|
||||
hideDateRange = false,
|
||||
t,
|
||||
}) => {
|
||||
const consolePage = useConsolePage();
|
||||
const { scheduleSearch, submitSearch, cancelPendingSearch } =
|
||||
useFilterSearch(refresh);
|
||||
const SearchIcon = Search;
|
||||
const ResetIcon = RotateCcw;
|
||||
const ColumnsIcon = Settings2;
|
||||
const primaryButtonClass =
|
||||
'!bg-gradient-to-r !from-cyan-500 !to-blue-600 !border-0 hover:!from-cyan-600 hover:!to-blue-700 !shadow-md hover:!shadow-lg !transition-all !duration-300';
|
||||
const softButtonClass =
|
||||
@@ -77,6 +80,7 @@ const TaskLogsFilters = ({
|
||||
? getFreshInitValues()
|
||||
: formInitValues;
|
||||
formApi.setValues(fresh, { isOverride: true });
|
||||
cancelPendingSearch();
|
||||
setTimeout(() => {
|
||||
refresh();
|
||||
}, 100);
|
||||
@@ -165,12 +169,13 @@ const TaskLogsFilters = ({
|
||||
);
|
||||
|
||||
// 个人端使用记录:原型为带字段标签的五列筛选卡,重置/搜索位于右下;列设置移至表格卡片标题栏
|
||||
if (usageRecordMode) {
|
||||
if (usageRecordMode || consolePage) {
|
||||
return (
|
||||
<Form
|
||||
initValues={formInitValues}
|
||||
getFormApi={(api) => setFormApi(api)}
|
||||
onSubmit={refresh}
|
||||
onSubmit={consolePage ? submitSearch : refresh}
|
||||
onValueChange={consolePage ? scheduleSearch : undefined}
|
||||
allowEmpty={true}
|
||||
autoComplete='off'
|
||||
layout='vertical'
|
||||
@@ -232,14 +237,18 @@ const TaskLogsFilters = ({
|
||||
</div>
|
||||
<div className='usage-record-filter-actions'>
|
||||
<Button onClick={resetFilters}>{t('重置')}</Button>
|
||||
<Button
|
||||
type='primary'
|
||||
htmlType='submit'
|
||||
loading={loading}
|
||||
icon={<Search size={14} />}
|
||||
>
|
||||
{t('搜索')}
|
||||
</Button>
|
||||
{consolePage ? (
|
||||
<FilterSearchButton loading={loading} />
|
||||
) : (
|
||||
<Button
|
||||
type='primary'
|
||||
htmlType='submit'
|
||||
loading={loading}
|
||||
icon={<Search size={14} />}
|
||||
>
|
||||
{t('搜索')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</Form>
|
||||
);
|
||||
@@ -412,17 +421,6 @@ const TaskLogsFilters = ({
|
||||
>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
|
||||
{/* 列设置按钮 */}
|
||||
<Button
|
||||
type='tertiary'
|
||||
onClick={() => setShowColumnSelector(true)}
|
||||
size='small'
|
||||
icon={<ColumnsIcon className='w-3.5 h-3.5' />}
|
||||
className={softButtonClass}
|
||||
>
|
||||
{t('列设置')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user