merge: 合入总仓库 weiyuan(bfdfb339) web/ 新功能,保留 ui-optimization 的 UI 重构

来源:luoguang/monkey-ai weiyuan@bfdfb339 的 web/(经 sync/main-weiyuan-web-bfdfb339 同步)
同步基准:总仓库 a2ca13cb = 本仓库初始导入 d8f3aee2

冲突处理原则:保留 ui-optimization 的 UI(样式/结构/组件),嫁接 weiyuan 的功能逻辑。
- i18n:按键三方合并;ours 的「令牌→密钥」改名键上移植 theirs 的术语修订
- task-logs / OrgLogs:ours 已手工移植同一功能(6ad95e2),保留 ours
- 删除:OrgCreate(theirs 下线 /org/create)、旧 image 组件与 VideoRegenerateModal(theirs 体验中心重写)、
  OrgAvatarSection / PricingBentoPage / CommissionConsole(ours 重构中已移除)
- 测试:users-pagination 的 i18next mock 补 t();theirs 新增文件补 license header
This commit is contained in:
qiubaishen
2026-11-10 12:01:21 +08:00
266 changed files with 38432 additions and 7570 deletions
@@ -149,7 +149,7 @@ const ChannelConsumption = ({ data, title, icon, t, embedded = false }) => {
pageSize,
showSizeChanger: true,
pageSizeOpts: [10, 20, 30],
showTotal: (total) => `${t('共')} ${total} ${t('条')}`,
showTotal: (total) => t('共 {{total}} 条', { total, count: total }),
onPageChange: (page) => setCurrentPage(page),
onPageSizeChange: (size) => {
setPageSize(size);
+1 -1
View File
@@ -200,7 +200,7 @@ const DailyStatsTable = ({ data, title, icon, t, embedded = false }) => {
pagination={{
pageSize: 10,
showSizeChanger: true,
showTotal: (total) => `${t('共')} ${total} ${t('条')}`,
showTotal: (total) => t('共 {{total}} 条', { total, count: total }),
}}
scroll={{ x: 1100 }}
size='small'
+39 -26
View File
@@ -29,9 +29,9 @@ import {
TrendingUp,
TrendingDown,
} from 'lucide-react';
import { renderQuota } from '../../helpers';
import { renderQuota, timestamp2string } from '../../helpers';
const OverviewCards = ({ overview, t }) => {
const OverviewCards = ({ overview, loading = false, t }) => {
if (!overview) {
return (
<div className='grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4'>
@@ -124,31 +124,44 @@ const OverviewCards = ({ overview, t }) => {
};
return (
<div className='grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4'>
{cards.map((card, index) => (
<Card
key={index}
className={`${card.bgColor} border-none shadow-sm hover:shadow-md transition-shadow`}
bodyStyle={{ padding: '16px' }}
>
<div className='flex items-start justify-between'>
<div className='flex-1'>
<p className='text-xs text-gray-500 dark:text-gray-400 mb-1'>
{card.title}
</p>
<p className='text-xl font-bold text-gray-800 dark:text-gray-100'>
{card.value}
</p>
{renderChange(card.change)}
<div>
<div
className={`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 transition-opacity ${
loading ? 'opacity-50' : ''
}`}
>
{cards.map((card, index) => (
<Card
key={index}
className={`${card.bgColor} border-none shadow-sm hover:shadow-md transition-shadow`}
bodyStyle={{ padding: '16px' }}
>
<div className='flex items-start justify-between'>
<div className='flex-1'>
<p className='text-xs text-gray-500 dark:text-gray-400 mb-1'>
{card.title}
</p>
<p className='text-xl font-bold text-gray-800 dark:text-gray-100'>
{card.value}
</p>
{renderChange(card.change)}
</div>
<div
className={`${card.iconBg} p-2 rounded-lg text-white shadow-sm`}
>
{card.icon}
</div>
</div>
<div
className={`${card.iconBg} p-2 rounded-lg text-white shadow-sm`}
>
{card.icon}
</div>
</div>
</Card>
))}
</Card>
))}
</div>
{/* 活跃/消耗取自汇总层时会落后一个同步周期(约 30~60 秒),把截止时间标出来,
避免「数字和日志对不上」被当成算错;data_as_of 为 0 表示本次是实时直查。 */}
{overview.data_as_of > 0 && (
<p className='mt-2 text-xs text-gray-400 dark:text-gray-500 text-right'>
{t('活跃与消耗数据截至')} {timestamp2string(overview.data_as_of)}
</p>
)}
</div>
);
};
@@ -45,7 +45,8 @@ const TopupChannelChart = ({ data, title, icon, t }) => {
if (!data || data.length === 0) return null;
const chartData = data.map((item) => ({
name: item.payment_method || t('未知'),
name: item.payment_method ? t(item.payment_method) : t('未知'),
rawName: item.payment_method,
value: item.amount || 0,
count: item.count || 0,
}));
@@ -53,7 +54,7 @@ const TopupChannelChart = ({ data, title, icon, t }) => {
// 根据支付渠道名称生成颜色数组
const colorList = chartData.map((item, index) => {
return (
CHANNEL_COLORS[item.name] ||
CHANNEL_COLORS[item.rawName] ||
DEFAULT_COLORS[index % DEFAULT_COLORS.length]
);
});
@@ -80,7 +81,7 @@ const TopupChannelChart = ({ data, title, icon, t }) => {
},
{
key: () => t('笔数'),
value: (datum) => `${datum?.count || 0} ${t('笔')}`,
value: (datum) => t('{{n}} 笔', { n: datum?.count || 0, count: datum?.count || 0 }),
},
],
},
@@ -131,7 +132,7 @@ const TopupChannelChart = ({ data, title, icon, t }) => {
className='flex items-center justify-between text-sm py-1 border-b border-gray-100 dark:border-gray-700 last:border-0'
>
<span className='text-gray-600 dark:text-gray-400'>
{item.payment_method}
{item.payment_method ? t(item.payment_method) : t('未知')}
</span>
<div className='text-right'>
<span className='font-medium'>
+2 -2
View File
@@ -65,7 +65,7 @@ const TrendCharts = ({ title, icon, data, type, t }) => {
{
key: (datum) => datum?.type,
value: (datum) =>
`${(datum?.value || 0).toLocaleString()} ${t('人')}`,
t('{{n}} 人', { n: (datum?.value || 0).toLocaleString(), count: datum?.value || 0 }),
},
],
},
@@ -75,7 +75,7 @@ const TrendCharts = ({ title, icon, data, type, t }) => {
{
key: (datum) => datum?.type,
value: (datum) =>
`${(datum?.value || 0).toLocaleString()} ${t('人')}`,
t('{{n}} 人', { n: (datum?.value || 0).toLocaleString(), count: datum?.value || 0 }),
},
],
},
+27 -12
View File
@@ -99,7 +99,7 @@ const UserSurveyStats = ({ title, icon, t }) => {
return null;
const chartData = surveyStats.job_type_stats.map((item) => ({
name: JOB_TYPE_CONFIG[item.job_type]?.label || t('未知'),
name: t(JOB_TYPE_CONFIG[item.job_type]?.label || '未知'),
value: item.count,
percentage: item.percentage,
}));
@@ -122,7 +122,11 @@ const UserSurveyStats = ({ title, icon, t }) => {
content: [
{
key: (datum) => datum?.name,
value: (datum) => `${datum?.value || 0} ${t('人')}`,
value: (datum) =>
t('{{n}} 人', {
n: datum?.value || 0,
count: datum?.value || 0,
}),
},
{
key: () => t('占比'),
@@ -151,7 +155,7 @@ const UserSurveyStats = ({ title, icon, t }) => {
return null;
const chartData = surveyStats.ai_tool_stats.map((item) => ({
name: AI_TOOL_CONFIG[item.ai_tool_usage]?.label || t('未知'),
name: t(AI_TOOL_CONFIG[item.ai_tool_usage]?.label || '未知'),
value: item.count,
percentage: item.percentage,
}));
@@ -174,7 +178,11 @@ const UserSurveyStats = ({ title, icon, t }) => {
content: [
{
key: (datum) => datum?.name,
value: (datum) => `${datum?.value || 0} ${t('人')}`,
value: (datum) =>
t('{{n}} 人', {
n: datum?.value || 0,
count: datum?.value || 0,
}),
},
{
key: () => t('占比'),
@@ -236,7 +244,11 @@ const UserSurveyStats = ({ title, icon, t }) => {
},
{
key: () => t('新增'),
value: (datum) => `${datum?.count || 0} ${t('人')}`,
value: (datum) =>
t('{{n}} 人', {
n: datum?.count || 0,
count: datum?.count || 0,
}),
},
],
},
@@ -279,7 +291,7 @@ const UserSurveyStats = ({ title, icon, t }) => {
<>
{totalUsers > 0 && (
<Tag color='purple' size='small'>
{totalUsers} {t('人已填写')}
{t('{{n}} 人已填写', { n: totalUsers, count: totalUsers })}
</Tag>
)}
</>
@@ -394,7 +406,7 @@ const UserSurveyStats = ({ title, icon, t }) => {
{config?.icon}
</span>
<span className='text-sm text-gray-600 dark:text-gray-400'>
{config?.label}
{t(config?.label || '')}
</span>
</div>
<div className='flex items-center gap-2'>
@@ -461,7 +473,7 @@ const UserSurveyStats = ({ title, icon, t }) => {
{config?.icon}
</span>
<span className='text-sm text-gray-600 dark:text-gray-400'>
{config?.label}
{t(config?.label || '')}
</span>
</div>
<div className='flex items-center gap-2'>
@@ -549,7 +561,10 @@ const UserSurveyStats = ({ title, icon, t }) => {
{JOB_TYPE_CONFIG[item.job_type]?.icon}
</span>
<span className='text-gray-700 dark:text-gray-300'>
{JOB_TYPE_CONFIG[item.job_type]?.label}
{t(
JOB_TYPE_CONFIG[item.job_type]
?.label || '',
)}
</span>
</div>
</td>
@@ -561,10 +576,10 @@ const UserSurveyStats = ({ title, icon, t }) => {
}
size='small'
>
{
{t(
AI_TOOL_CONFIG[item.ai_tool_usage]
?.label
}
?.label || '',
)}
</Tag>
</td>
<td className='py-2 px-3 text-right font-medium'>
@@ -158,7 +158,7 @@ const columnsFor = (tab, cny, t, atRisk) => {
: 'var(--ui-color-warning)',
}}
>
{v < 1 ? t('不足 1 天') : `${v.toFixed(1)} ${t('天')}`}
{v < 1 ? t('不足 1 天') : t('{{days}} 天', { days: v.toFixed(1) })}
</span>
);
},
@@ -195,7 +195,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => {
},
{
title: t('活跃企业'),
value: `${(k.active_orgs || 0).toLocaleString()} ${t('家')}`,
value: t('{{n}} 家', { n: (k.active_orgs || 0).toLocaleString(), count: k.active_orgs || 0 }),
sub: `${t('活跃率')} ${pct(k.active_orgs, servingOrgs).toFixed(1)}% · ${t('新增')} ${k.new_orgs || 0}`,
compare: (
<ChangeText cur={k.active_orgs} prev={k.prev_active_orgs} t={t} />
@@ -212,7 +212,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => {
},
{
title: t('企业活跃成员'),
value: `${(k.active_members || 0).toLocaleString()} ${t('人')}`,
value: t('{{n}} 人', { n: (k.active_members || 0).toLocaleString(), count: k.active_members || 0 }),
sub: `${t('渗透率')} ${Math.min(100, pct(k.active_members, k.total_members)).toFixed(1)}% · ${t('成员')} ${(k.total_members || 0).toLocaleString()}`,
tip: t('本期通过企业密钥产生调用的去重成员数(按自然日统计)'),
onClick: () => onJump('growth'),
@@ -238,7 +238,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => {
{
title: t('未来 30 天充值缺口'),
value: formatCny(k.topup_gap_30d, cny),
sub: `${lists.renewal.length} ${t('家需续费跟进')}`,
sub: t('{{n}} 家需续费跟进', { n: lists.renewal.length, count: lists.renewal.length }),
tip: t('按各企业近 7 日日均消耗覆盖 30 天所需金额,减去当前余额后累加'),
accent:
k.topup_gap_30d > 0
@@ -308,7 +308,7 @@ export const OrgDetailTable = ({ report, filter, setFilter, cny, t }) => {
<Text type='tertiary'>—</Text>
) : (
<span className='tabular-nums'>
{v < 1 ? t('不足 1 天') : `${v.toFixed(0)} ${t('天')}`}
{v < 1 ? t('不足 1 天') : t('{{days}} 天', { days: v.toFixed(0) })}
</span>
),
sorter: (a, b) =>