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:
+35
-21
@@ -134,7 +134,7 @@ export function showError(error) {
|
||||
if (error.name === 'AxiosError') {
|
||||
// 检查 response 是否存在(网络错误时 response 为 undefined)
|
||||
if (!error.response) {
|
||||
Toast.error('错误:网络请求失败,请检查网络连接');
|
||||
Toast.error(i18next.t('错误:网络请求失败,请检查网络连接'));
|
||||
return;
|
||||
}
|
||||
switch (error.response.status) {
|
||||
@@ -153,26 +153,30 @@ export function showError(error) {
|
||||
window.location.href = `/org/login?expired=true${redirect}`;
|
||||
break;
|
||||
case 429:
|
||||
Toast.error('错误:请求次数过多,请稍后再试!');
|
||||
Toast.error(i18next.t('错误:请求次数过多,请稍后再试!'));
|
||||
break;
|
||||
case 500:
|
||||
Toast.error('错误:服务器内部错误,请联系管理员!');
|
||||
Toast.error(i18next.t('错误:服务器内部错误,请联系管理员!'));
|
||||
break;
|
||||
case 405:
|
||||
Toast.info('本站仅作演示之用,无服务端!');
|
||||
Toast.info(i18next.t('本站仅作演示之用,无服务端!'));
|
||||
break;
|
||||
default: {
|
||||
// 后端业务错误(4xx/5xx)带有面向用户的 message 字段;
|
||||
// 优先展示它,而不是 axios 的 "Request failed with status code XXX"。
|
||||
const backendMessage = error.response?.data?.message;
|
||||
Toast.error('错误:' + (backendMessage || error.message));
|
||||
Toast.error(
|
||||
i18next.t('错误:{{message}}', {
|
||||
message: backendMessage || error.message,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
Toast.error('错误:' + error.message);
|
||||
Toast.error(i18next.t('错误:{{message}}', { message: error.message }));
|
||||
} else {
|
||||
Toast.error('错误:' + error);
|
||||
Toast.error(i18next.t('错误:{{message}}', { message: error }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -676,19 +680,19 @@ export const getRelativeTime = (publishDate) => {
|
||||
|
||||
// 根据时间差返回相应的描述
|
||||
if (diffSeconds < 60) {
|
||||
return '刚刚';
|
||||
return i18next.t('刚刚');
|
||||
} else if (diffMinutes < 60) {
|
||||
return `${diffMinutes} 分钟前`;
|
||||
return i18next.t('{{n}} 分钟前', { n: diffMinutes });
|
||||
} else if (diffHours < 24) {
|
||||
return `${diffHours} 小时前`;
|
||||
return i18next.t('{{n}} 小时前', { n: diffHours });
|
||||
} else if (diffDays < 7) {
|
||||
return `${diffDays} 天前`;
|
||||
return i18next.t('{{n}} 天前', { n: diffDays });
|
||||
} else if (diffWeeks < 4) {
|
||||
return `${diffWeeks} 周前`;
|
||||
return i18next.t('{{n}} 周前', { n: diffWeeks });
|
||||
} else if (diffMonths < 12) {
|
||||
return `${diffMonths} 个月前`;
|
||||
return i18next.t('{{n}} 个月前', { n: diffMonths });
|
||||
} else if (diffYears < 2) {
|
||||
return '1 年前';
|
||||
return i18next.t('{{n}} 年前', { n: 1 });
|
||||
} else {
|
||||
// 超过2年显示具体日期
|
||||
return formatDateString(pubDate);
|
||||
@@ -835,14 +839,20 @@ export const calculateModelPrice = ({
|
||||
const hasCacheCreation5m = hasNumericPriceValue(
|
||||
record.cache_creation_5m_ratio,
|
||||
);
|
||||
// 只有 1h 档(Claude:全部写入按 1h 计费)时不再重复展示通用缓存创建价
|
||||
const onlyCacheCreation1h =
|
||||
!hasCacheCreation5m &&
|
||||
hasNumericPriceValue(record.cache_creation_1h_ratio);
|
||||
const cacheCreationRatio = hasCacheCreation5m
|
||||
? record.cache_creation_5m_ratio
|
||||
: record.cache_creation_ratio;
|
||||
addExtraPrice(
|
||||
hasCacheCreation5m ? 'cache_creation_5m' : 'cache_creation',
|
||||
hasCacheCreation5m ? '缓存创建(5m)' : '缓存创建',
|
||||
cacheCreationRatio,
|
||||
);
|
||||
if (!onlyCacheCreation1h) {
|
||||
addExtraPrice(
|
||||
hasCacheCreation5m ? 'cache_creation_5m' : 'cache_creation',
|
||||
hasCacheCreation5m ? '缓存创建(5m)' : '缓存创建',
|
||||
cacheCreationRatio,
|
||||
);
|
||||
}
|
||||
addExtraPrice(
|
||||
'cache_creation_1h',
|
||||
'缓存创建(1h)',
|
||||
@@ -1068,7 +1078,7 @@ export const createCardProPagination = ({
|
||||
showSizeChanger = true,
|
||||
showRange = true,
|
||||
preventPageChangeOnPageSizeChange = false,
|
||||
t = (key) => key,
|
||||
t = i18next.t.bind(i18next),
|
||||
}) => {
|
||||
if (!total || total <= 0) return null;
|
||||
|
||||
@@ -1078,7 +1088,11 @@ export const createCardProPagination = ({
|
||||
|
||||
const start = (currentPage - 1) * pageSize + 1;
|
||||
const end = Math.min(currentPage * pageSize, total);
|
||||
const totalText = `${t('显示第')} ${start} ${t('条 - 第')} ${end} ${t('条,共')} ${total} ${t('条')}`;
|
||||
const totalText = t('显示第 {{start}} 条 - 第 {{end}} 条,共 {{total}} 条', {
|
||||
start,
|
||||
end,
|
||||
total,
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user