feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面

This commit is contained in:
zhanjunhao
2026-11-09 21:45:37 +08:00
parent 54b3e0cc21
commit 5c0849e82b
242 changed files with 9242 additions and 5043 deletions
+298 -293
View File
@@ -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>
);
};