sync: 同步总仓库 luoguang/monkey-ai weiyuan@bfdfb339 的 web/ 改动
同步基准:总仓库 a2ca13cb(= 本仓库初始导入 d8f3aee2) 范围:a2ca13cb..bfdfb339 中触及 web/ 的提交(不含 web/.claude/settings.local.json) - 8490ac02 feat(aliyun): integrate Wan 3 and Qwen Image models - 2aff08ec perf(analytics): 运营看板概览改读汇总表,首屏从 19s 降到 0.4s - dc69335e feat(experience): 体验中心图像/视频创作升级(能力 schema、估价、新创作台) - b059c657 fix(org): 下线 /org/create 自助加入企业页与 POST /api/org/join - 4fcf47e6 fix(i18n): 修复中/英/韩/繁体多语言错乱,补齐日/越/泰译文 - e4c301d5 fix: merge enterprise task record date filters - c9369b95 feat: expose enterprise image and video task records - a410fee5 feat(claude): 无断点请求自动注入 cache_control 断点(方案 2) - 521b3376 feat(claude): 缓存命中率优化——上游粘性路由 + 缓存时长强制改写 - 73b615dd feat(pricing): 企业成员不论登录身份均按所属企业等级计价与扣费 - f73f55c3 feat(client): 新增 WeyAi 版本说明管理与公开读取接口 - 8cdf1994 fix(topup): reset amount when switching from PayPal - 93a4ac34 feat(baidu): configure Seedance liveness header by channel - cb1818c5 fix(weyai): 按评审修正内容清理竞态、默认适用端与中文退回(M21) - 04214d83 feat(weyai): WeyAi 内容管理与客户端内容接口(M21 第二部分) - e3c4a57c feat(weyai): 设置页新增 WeyAi 页签与内容专用 COS 桶(M21 第一部分) - b5ee8e70 fix(auth): 会话角色/状态以 DB 为准,修复提升管理员后管理接口报权限不足 - e4618fc2 fix: 修复企业看板日志聚合死循环导致 CPU 打满,并降低看板查询开销 - 584aad52 style(web): 个人中心侧边栏按 prettier 换行 - b8d87064 fix: 小程序教程隐藏充值后保留原步骤编号,企业充值判断直接用 isMiniProgramWebView - eee7f5b2 fix: 小程序里企业首页不落到充值页,隐藏钱包入口与教程充值步骤 - 8b254d49 fix: 小程序里隐藏企业充值入口与页面 - a67661b4 fix(web): 小程序里个人中心默认页跳过充值和发票,避免来回跳转 - cff6c543 feat(web): WeyAi 小程序里打开个人中心时不出现充值和开票 - c6c99eb6 feat(billing): Claude 全部缓存写入统一按 1h 倍率计费 - 0699d1bf fix(web): 小程序 web-view 里注册页同样只显示站内方式 - 04853331 feat(web): WeyAi 小程序 web-view 里登录页只显示站内登录方式
This commit is contained in:
@@ -208,14 +208,14 @@ function formatRelativeTime(timestamp, t) {
|
||||
const days = Math.floor(hours / 24);
|
||||
|
||||
if (seconds < 60) return t('刚刚');
|
||||
if (minutes < 60) return minutes + t('分钟前');
|
||||
if (hours < 24) return hours + t('小时前');
|
||||
if (days < 30) return days + t('天前');
|
||||
if (minutes < 60) return t('{{n}} 分钟前', { n: minutes });
|
||||
if (hours < 24) return t('{{n}} 小时前', { n: hours });
|
||||
if (days < 30) return t('{{n}} 天前', { n: days });
|
||||
return new Date(timestamp * 1000).toLocaleDateString();
|
||||
}
|
||||
|
||||
const OrgAudit = ({ orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const quotaPerUnit = getQuotaPerUnit();
|
||||
const { logs, total, loading, fetch } = useOrgAuditLogs(orgId);
|
||||
const [page, setPage] = useState(1);
|
||||
@@ -391,7 +391,7 @@ const OrgAudit = ({ orgId }) => {
|
||||
width: 140,
|
||||
render: (v) =>
|
||||
v ? (
|
||||
<Tooltip content={new Date(v * 1000).toLocaleString('zh-CN')}>
|
||||
<Tooltip content={new Date(v * 1000).toLocaleString(i18n.language)}>
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400 cursor-default'>
|
||||
{formatRelativeTime(v, t)}
|
||||
</span>
|
||||
|
||||
@@ -1,299 +0,0 @@
|
||||
/*
|
||||
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, useCallback, useEffect, useContext } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
Building2,
|
||||
KeyRound,
|
||||
ArrowRight,
|
||||
HelpCircle,
|
||||
Home,
|
||||
AlertTriangle,
|
||||
RefreshCw,
|
||||
} from 'lucide-react';
|
||||
import { Input, Button, Toast } from '@douyinfe/semi-ui';
|
||||
import { API } from '../../helpers/api';
|
||||
import { showError } from '../../helpers';
|
||||
import { UserContext } from '../../context/User';
|
||||
import Loading from '../../components/common/ui/Loading';
|
||||
import PageBackground from '../../components/common/PageBackground';
|
||||
|
||||
// 企业创建已收归系统管理员手动创建(/api/admin/organizations/)。
|
||||
// 此页面是「无企业归属」用户的落地引导页,按意图区分三态:
|
||||
// join —— 用户不属于任何企业,展示企业代码加入入口
|
||||
// inactive —— 用户有企业但均非活跃(冻结/欠费/待激活),引导联系管理员,避免误导其"加入"
|
||||
// error —— 企业列表加载失败,提供重试
|
||||
const ORG_STATUS_TEXT = {
|
||||
2: '已被冻结',
|
||||
3: '已欠费',
|
||||
4: '待激活',
|
||||
};
|
||||
|
||||
const OrgCreate = () => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [userState] = useContext(UserContext);
|
||||
const isOrgOnly = userState?.user?.org_only_mode === true;
|
||||
const [joinLoading, setJoinLoading] = useState(false);
|
||||
const [orgCode, setOrgCode] = useState('');
|
||||
// 'checking' | 'join' | 'inactive' | 'error'
|
||||
const [mode, setMode] = useState('checking');
|
||||
const [inactiveOrgs, setInactiveOrgs] = useState([]);
|
||||
|
||||
// 检查用户企业归属并决定落地状态。
|
||||
// 有 active(status=1) 企业 → 写入 current_org_id 并跳转控制台(仅认 active,防冻结企业死循环)。
|
||||
const runCheck = useCallback(async () => {
|
||||
setMode('checking');
|
||||
try {
|
||||
const res = await API.get('/api/org/list');
|
||||
if (res.data.success) {
|
||||
const orgs = res.data.data || [];
|
||||
const activeOrgs = orgs.filter((o) => o.status === 1);
|
||||
if (activeOrgs.length > 0) {
|
||||
const savedOrgId = parseInt(
|
||||
localStorage.getItem('current_org_id') || '0',
|
||||
10,
|
||||
);
|
||||
const savedOrg =
|
||||
savedOrgId > 0 ? activeOrgs.find((o) => o.id === savedOrgId) : null;
|
||||
const targetOrg = savedOrg || activeOrgs[0];
|
||||
localStorage.setItem('current_org_id', String(targetOrg.id));
|
||||
navigate('/org/dashboard', { replace: true });
|
||||
return;
|
||||
}
|
||||
if (orgs.length > 0) {
|
||||
setInactiveOrgs(orgs);
|
||||
setMode('inactive');
|
||||
return;
|
||||
}
|
||||
setMode('join');
|
||||
return;
|
||||
}
|
||||
setMode('error');
|
||||
} catch {
|
||||
setMode('error');
|
||||
}
|
||||
}, [navigate]);
|
||||
|
||||
useEffect(() => {
|
||||
runCheck();
|
||||
}, [runCheck]);
|
||||
|
||||
const handleJoin = useCallback(async () => {
|
||||
if (!orgCode.trim()) {
|
||||
Toast.warning(t('请输入企业代码'));
|
||||
return;
|
||||
}
|
||||
setJoinLoading(true);
|
||||
try {
|
||||
const res = await API.post('/api/org/join', { code: orgCode.trim() });
|
||||
if (res.data.success) {
|
||||
Toast.success(t('成功加入企业'));
|
||||
const data = res.data.data;
|
||||
if (data && data.organization && data.organization.id) {
|
||||
localStorage.setItem('current_org_id', String(data.organization.id));
|
||||
}
|
||||
navigate('/org/dashboard');
|
||||
} else {
|
||||
showError(res.data.message);
|
||||
}
|
||||
} catch (err) {
|
||||
showError(err.message);
|
||||
} finally {
|
||||
setJoinLoading(false);
|
||||
}
|
||||
}, [orgCode, t, navigate]);
|
||||
|
||||
if (mode === 'checking') {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
// 非 org_only 用户提供「返回首页」出口,避免被困在本页;org_only 员工受守卫限制在 /org,不提供。
|
||||
const backHome = !isOrgOnly && (
|
||||
<div className='mt-6 text-center'>
|
||||
<button
|
||||
onClick={() => navigate('/')}
|
||||
className='inline-flex items-center gap-1.5 text-sm text-gray-400 dark:text-gray-500 hover:text-brand-deep transition-colors'
|
||||
>
|
||||
<Home size={14} />
|
||||
{t('返回首页')}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='org-center relative min-h-screen flex items-center justify-center bg-[var(--surface-bg-base)] py-16 px-4 transition-colors duration-300'>
|
||||
{/* 统一页面背景层 —— 唯一背景来源,走 bg-glow-* 主题变量 */}
|
||||
<PageBackground />
|
||||
|
||||
<div className='w-full max-w-md relative z-10'>
|
||||
{mode === 'join' && (
|
||||
<>
|
||||
<div className='text-center mb-7'>
|
||||
<div className='inline-flex p-4 rounded-2xl bg-gradient-to-br from-brand-from via-brand-via to-brand-to mb-5 shadow-lg shadow-brand/25 dark:shadow-brand/15'>
|
||||
<Building2 size={34} className='text-white' />
|
||||
</div>
|
||||
<h1 className='text-3xl font-bold text-gray-900 dark:text-white'>
|
||||
{t('加入企业')}
|
||||
</h1>
|
||||
<p className='text-gray-500 dark:text-gray-400 mt-2.5 leading-relaxed'>
|
||||
{t('输入企业管理员提供的企业代码,即可加入你的团队')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className='rounded-xl border border-[var(--border-subtle)] bg-[var(--surface-card)] shadow-[var(--elevation-sm)] p-6 sm:p-7 transition-colors duration-300'>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
|
||||
{t('企业代码')}
|
||||
</label>
|
||||
<Input
|
||||
value={orgCode}
|
||||
onChange={(v) => setOrgCode(v)}
|
||||
placeholder={t('请输入 8 位企业代码')}
|
||||
size='large'
|
||||
prefix={<KeyRound size={18} className='text-gray-400 ml-1' />}
|
||||
onEnterPress={handleJoin}
|
||||
className='tracking-wide'
|
||||
/>
|
||||
<Button
|
||||
type='primary'
|
||||
size='large'
|
||||
block
|
||||
loading={joinLoading}
|
||||
onClick={handleJoin}
|
||||
icon={<ArrowRight size={18} />}
|
||||
iconPosition='right'
|
||||
className='mt-4'
|
||||
>
|
||||
{t('加入企业')}
|
||||
</Button>
|
||||
|
||||
<div className='mt-5 pt-5 border-t border-gray-100 dark:border-neutral-800 flex items-start gap-2.5'>
|
||||
<HelpCircle
|
||||
size={16}
|
||||
className='text-gray-400 dark:text-gray-500 mt-0.5 flex-shrink-0'
|
||||
/>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400 leading-relaxed'>
|
||||
{t(
|
||||
'没有企业代码?请联系你的企业管理员获取,或由管理员直接为你创建企业账号。',
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{backHome}
|
||||
</>
|
||||
)}
|
||||
|
||||
{mode === 'inactive' && (
|
||||
<>
|
||||
<div className='text-center mb-7'>
|
||||
<div className='inline-flex p-4 rounded-2xl bg-gradient-to-br from-amber-400 to-amber-500 mb-5 shadow-lg shadow-amber-500/25 dark:shadow-amber-500/15'>
|
||||
<AlertTriangle size={34} className='text-white' />
|
||||
</div>
|
||||
<h1 className='text-3xl font-bold text-gray-900 dark:text-white'>
|
||||
{t('企业暂不可用')}
|
||||
</h1>
|
||||
<p className='text-gray-500 dark:text-gray-400 mt-2.5 leading-relaxed'>
|
||||
{t('你所属的企业当前无法访问,请联系管理员处理')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className='rounded-xl border border-[var(--border-subtle)] bg-[var(--surface-card)] shadow-[var(--elevation-sm)] p-6 sm:p-7 transition-colors duration-300'>
|
||||
<div className='space-y-2.5'>
|
||||
{inactiveOrgs.map((org) => (
|
||||
<div
|
||||
key={org.id}
|
||||
className='flex items-center justify-between gap-3 p-3 rounded-xl bg-gray-50 dark:bg-neutral-800/60 border border-gray-100 dark:border-neutral-800'
|
||||
>
|
||||
<div className='flex items-center gap-2.5 min-w-0'>
|
||||
<Building2
|
||||
size={16}
|
||||
className='text-gray-400 flex-shrink-0'
|
||||
/>
|
||||
<span className='text-sm font-medium text-gray-900 dark:text-white truncate'>
|
||||
{org.name || t('企业') + ' #' + org.id}
|
||||
</span>
|
||||
</div>
|
||||
<span className='text-xs font-medium text-amber-600 dark:text-amber-400 flex-shrink-0'>
|
||||
{t(ORG_STATUS_TEXT[org.status] || '不可用')}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className='mt-5 pt-5 border-t border-gray-100 dark:border-neutral-800 flex items-start gap-2.5'>
|
||||
<HelpCircle
|
||||
size={16}
|
||||
className='text-gray-400 dark:text-gray-500 mt-0.5 flex-shrink-0'
|
||||
/>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400 leading-relaxed'>
|
||||
{t(
|
||||
'企业激活、解冻或续费由平台管理员处理,请联系企业管理员或平台客服。',
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
size='large'
|
||||
block
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={runCheck}
|
||||
className='mt-4'
|
||||
>
|
||||
{t('刷新状态')}
|
||||
</Button>
|
||||
</div>
|
||||
{backHome}
|
||||
</>
|
||||
)}
|
||||
|
||||
{mode === 'error' && (
|
||||
<>
|
||||
<div className='text-center mb-7'>
|
||||
<div className='inline-flex p-4 rounded-2xl bg-gradient-to-br from-red-400 to-red-500 mb-5 shadow-lg shadow-red-500/25 dark:shadow-red-500/15'>
|
||||
<AlertTriangle size={34} className='text-white' />
|
||||
</div>
|
||||
<h1 className='text-3xl font-bold text-gray-900 dark:text-white'>
|
||||
{t('加载失败')}
|
||||
</h1>
|
||||
<p className='text-gray-500 dark:text-gray-400 mt-2.5 leading-relaxed'>
|
||||
{t('无法获取你的企业信息,请检查网络后重试')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className='rounded-xl border border-[var(--border-subtle)] bg-[var(--surface-card)] shadow-[var(--elevation-sm)] p-6 sm:p-7 transition-colors duration-300'>
|
||||
<Button
|
||||
type='primary'
|
||||
size='large'
|
||||
block
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={runCheck}
|
||||
>
|
||||
{t('重试')}
|
||||
</Button>
|
||||
</div>
|
||||
{backHome}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default OrgCreate;
|
||||
@@ -25,6 +25,7 @@ import React, {
|
||||
useRef,
|
||||
} from 'react';
|
||||
import { timestamp2string } from '../../helpers/utils';
|
||||
import { isMiniProgramWebView } from '../../helpers/miniProgram';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
@@ -626,7 +627,7 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
)}
|
||||
actions={
|
||||
<>
|
||||
{isAdmin && (
|
||||
{isAdmin && !isMiniProgramWebView() && (
|
||||
<Button
|
||||
icon={<CreditCard size={14} />}
|
||||
theme='solid'
|
||||
|
||||
@@ -318,7 +318,10 @@ const OrgDepartments = ({ orgId }) => {
|
||||
type='info'
|
||||
closeIcon={null}
|
||||
className='mb-3'
|
||||
description={`${t('所选上级部门已有')} ${parentMemberCount} ${t('名直属成员,新增下级后建议将这些成员迁移到末级部门')}`}
|
||||
description={t(
|
||||
'所选上级部门已有 {{n}} 名直属成员,新增下级后建议将这些成员迁移到末级部门',
|
||||
{ n: parentMemberCount },
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<Form
|
||||
|
||||
@@ -353,7 +353,10 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
<PageGuideTrigger guide={guide} />
|
||||
<Select
|
||||
value={dimension}
|
||||
optionList={dimensions}
|
||||
optionList={dimensions.map((d) => ({
|
||||
...d,
|
||||
label: t(d.label),
|
||||
}))}
|
||||
onChange={setDimension}
|
||||
/>
|
||||
{dimension !== 'organization' && (
|
||||
|
||||
@@ -530,7 +530,7 @@ const OrgExperts = ({ orgId }) => {
|
||||
value={form.default_language}
|
||||
onChange={(v) => update('default_language', v)}
|
||||
optionList={[
|
||||
{ value: 'zh', label: '中文' },
|
||||
{ value: 'zh', label: t('中文') },
|
||||
{ value: 'en', label: 'English' },
|
||||
]}
|
||||
/>
|
||||
|
||||
@@ -1916,7 +1916,7 @@ const OrgKnowledge = ({ orgId, canAuditContent = false }) => {
|
||||
{searchSummary && !searching && (
|
||||
<div className='knowledge-hit-summary'>
|
||||
<span>
|
||||
{t('命中')} {searchHits.length} {t('条片段')}
|
||||
{t('命中 {{n}} 条片段', { n: searchHits.length, count: searchHits.length })}
|
||||
</span>
|
||||
<Tag
|
||||
color={searchSummary.full ? 'amber' : 'grey'}
|
||||
|
||||
@@ -48,6 +48,7 @@ import {
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import StatCard from './components/OrgStatCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
import TaskLogsTable from '../../components/table/task-logs';
|
||||
import {
|
||||
API,
|
||||
showError,
|
||||
@@ -241,6 +242,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
const [page, setPage] = useState(1);
|
||||
const pageSize = 20;
|
||||
const [activeTab, setActiveTab] = useState('logs');
|
||||
const [taskFilterRevision, setTaskFilterRevision] = useState(0);
|
||||
const isAdmin =
|
||||
orgRole === 'owner' || orgRole === 'admin' || orgRole === 'super_admin';
|
||||
const canViewTeamUsage = isAdmin || isDeptManager;
|
||||
@@ -352,6 +354,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
);
|
||||
}
|
||||
setPage(1);
|
||||
setTaskFilterRevision((revision) => revision + 1);
|
||||
};
|
||||
|
||||
// 重置:回到默认状态(滚动最近 7 天、不限成员/模型)
|
||||
@@ -372,6 +375,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
});
|
||||
}
|
||||
setPage(1);
|
||||
setTaskFilterRevision((revision) => revision + 1);
|
||||
};
|
||||
|
||||
// 导出弹窗状态(导出方式 + 字段勾选从 localStorage 恢复)
|
||||
@@ -931,6 +935,16 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
/>
|
||||
</TabPane>
|
||||
|
||||
<TabPane tab={t('绘图与视频')} itemKey='tasks'>
|
||||
<TaskLogsTable
|
||||
usageRecordMode
|
||||
organizationMode
|
||||
sharedStartTimestamp={appliedFilters.startTimestamp}
|
||||
sharedEndTimestamp={appliedFilters.endTimestamp}
|
||||
sharedFilterRevision={taskFilterRevision}
|
||||
/>
|
||||
</TabPane>
|
||||
|
||||
{canViewTeamUsage && (
|
||||
<TabPane tab={t('成员排行')} itemKey='ranking'>
|
||||
<Table
|
||||
|
||||
@@ -69,7 +69,7 @@ const formatImportError = (t, row) => {
|
||||
case 'login_name_reserved':
|
||||
return t('该登录名为系统保留名称,请换一个登录名');
|
||||
case 'email_exists':
|
||||
return t('该邮箱已是平台用户,请使用企业代码加入企业');
|
||||
return t('该邮箱已被平台用户使用,请更换邮箱或留空');
|
||||
case 'member_limit_reached':
|
||||
return t('企业成员数量已达到上限 {{max}}', params);
|
||||
case 'password_generation_failed':
|
||||
@@ -328,9 +328,7 @@ const OrgMemberAccounts = ({
|
||||
<div className='flex items-center gap-2'>
|
||||
<span>{r.display_name || r.username || `#${r.user_id}`}</span>
|
||||
{r.created_by_org_id !== r.organization_id && (
|
||||
<Tooltip
|
||||
content={t('通过企业代码加入的个人平台账号,非本企业托管')}
|
||||
>
|
||||
<Tooltip content={t('个人平台账号(非本企业托管)')}>
|
||||
<Tag size='small' color='blue'>
|
||||
{t('个人账号')}
|
||||
</Tag>
|
||||
@@ -555,7 +553,7 @@ const OrgMemberAccounts = ({
|
||||
<Form.Input
|
||||
field='email'
|
||||
label={t('邮箱(可选)')}
|
||||
placeholder={t('已是平台用户的邮箱请改用企业代码加入')}
|
||||
placeholder={t('已被平台用户使用的邮箱不可填写,可留空')}
|
||||
rules={[
|
||||
{
|
||||
pattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
||||
@@ -697,7 +695,14 @@ const OrgMemberAccounts = ({
|
||||
type={importResult.failed > 0 ? 'warning' : 'success'}
|
||||
closeIcon={null}
|
||||
className='mb-3'
|
||||
description={`${t('成功')} ${importResult.success} · ${t('失败')} ${importResult.failed} / ${t('共')} ${importResult.total}`}
|
||||
description={t(
|
||||
'成功 {{success}} · 失败 {{failed}} / 共 {{total}}',
|
||||
{
|
||||
success: importResult.success,
|
||||
failed: importResult.failed,
|
||||
total: importResult.total,
|
||||
},
|
||||
)}
|
||||
/>
|
||||
<Table
|
||||
size='small'
|
||||
|
||||
@@ -58,7 +58,7 @@ const OrgMembers = ({
|
||||
showAccounts = true,
|
||||
featureFlags = null,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const {
|
||||
members,
|
||||
total,
|
||||
@@ -333,9 +333,9 @@ const OrgMembers = ({
|
||||
|
||||
if (diffDays === 0) return t('今天');
|
||||
if (diffDays === 1) return t('昨天');
|
||||
if (diffDays < 30) return `${diffDays} ${t('天前')}`;
|
||||
if (diffDays < 30) return t('{{n}} 天前', { n: diffDays });
|
||||
|
||||
return date.toLocaleDateString('zh-CN', {
|
||||
return date.toLocaleDateString(i18n.language, {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
@@ -523,7 +523,9 @@ const OrgMembers = ({
|
||||
}
|
||||
>
|
||||
{enabled
|
||||
? `${record.model_limits.split(',').filter(Boolean).length} ${t('个模型')}`
|
||||
? t('{{count}} 个模型', {
|
||||
count: record.model_limits.split(',').filter(Boolean).length,
|
||||
})
|
||||
: t('不限')}
|
||||
</span>
|
||||
),
|
||||
@@ -567,7 +569,9 @@ const OrgMembers = ({
|
||||
dataIndex: 'joined_at',
|
||||
width: 100,
|
||||
render: (v) => (
|
||||
<Tooltip content={v ? new Date(v * 1000).toLocaleString('zh-CN') : '-'}>
|
||||
<Tooltip
|
||||
content={v ? new Date(v * 1000).toLocaleString(i18n.language) : '-'}
|
||||
>
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400 cursor-default'>
|
||||
{formatJoinTime(v)}
|
||||
</span>
|
||||
@@ -763,7 +767,7 @@ const OrgMembers = ({
|
||||
<p className='text-sm'>
|
||||
💡{' '}
|
||||
{t(
|
||||
'当前企业仅有您一位成员。成员可使用企业代码自助加入,或由系统管理员创建成员账号后即可在此管理成员角色、额度上限和访问权限。',
|
||||
'当前企业仅有您一位成员。为员工创建成员账号后,即可在此管理成员角色、额度上限和访问权限。',
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -18,6 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import i18next from 'i18next';
|
||||
import {
|
||||
Copy,
|
||||
Database,
|
||||
@@ -51,14 +52,13 @@ const emptyFilters = {
|
||||
endTimestamp: 0,
|
||||
};
|
||||
|
||||
const tokenNumberFormatter = new Intl.NumberFormat('zh-CN');
|
||||
const formatTokenCount = (value) =>
|
||||
tokenNumberFormatter.format(Number(value) || 0);
|
||||
new Intl.NumberFormat(i18next.language).format(Number(value) || 0);
|
||||
|
||||
// 下钻明细:一条提示词记录 → 该次用户输入的全部接口调用行(首调 + agent 中间调用)。
|
||||
// 数据来自平台消费日志(logs.prompt_group_key 索引等值查询),展开行时按需拉取。
|
||||
const PromptCallDetails = ({ orgId, groupKey }) => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const quotaPerUnit = getQuotaPerUnit();
|
||||
const [calls, setCalls] = useState(null); // null = 加载中
|
||||
const [error, setError] = useState('');
|
||||
@@ -141,7 +141,9 @@ const PromptCallDetails = ({ orgId, groupKey }) => {
|
||||
className='border-t border-gray-100 dark:border-white/[0.06]'
|
||||
>
|
||||
<td className='py-1 pr-3'>
|
||||
{new Date(log.created_at * 1000).toLocaleString('zh-CN')}
|
||||
{new Date(log.created_at * 1000).toLocaleString(
|
||||
i18n.language,
|
||||
)}
|
||||
</td>
|
||||
<td className='py-1 pr-3'>{log.model_name}</td>
|
||||
<td className='py-1 pr-3'>
|
||||
@@ -166,7 +168,7 @@ const PromptCallDetails = ({ orgId, groupKey }) => {
|
||||
// 提示词记录审计表(方案 §35 一期):数据来自企业自行配置的数据库,
|
||||
// 一行 = 一次「用户输入 → 最终 AI 返回」,agent 中间过程调用只累计次数与花费。
|
||||
const OrgPromptRecords = ({ orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const quotaPerUnit = getQuotaPerUnit();
|
||||
const { records, total, loading, error, fetch } = useOrgPromptRecords(orgId);
|
||||
const [page, setPage] = useState(1);
|
||||
@@ -399,11 +401,13 @@ const OrgPromptRecords = ({ orgId }) => {
|
||||
width: 230,
|
||||
render: (v, record) => (
|
||||
<Tooltip
|
||||
content={
|
||||
t('输入 / 输出 tokens(全过程累计)') +
|
||||
`,${t('缓存命中')} ${record.cache_hit_tokens || 0}` +
|
||||
`,${t('缓存创建')} ${record.cache_creation_tokens || 0}`
|
||||
}
|
||||
content={t(
|
||||
'输入 / 输出 tokens(全过程累计),缓存命中 {{hit}},缓存创建 {{created}}',
|
||||
{
|
||||
hit: record.cache_hit_tokens || 0,
|
||||
created: record.cache_creation_tokens || 0,
|
||||
},
|
||||
)}
|
||||
position='top'
|
||||
>
|
||||
<div className='grid cursor-default grid-cols-2 gap-x-4 gap-y-1 whitespace-nowrap text-xs'>
|
||||
@@ -441,18 +445,15 @@ const OrgPromptRecords = ({ orgId }) => {
|
||||
width: 175,
|
||||
render: (v, record) => (
|
||||
<Tooltip
|
||||
content={
|
||||
t('首次') +
|
||||
': ' +
|
||||
new Date(record.first_at * 1000).toLocaleString('zh-CN') +
|
||||
',' +
|
||||
t('最后') +
|
||||
': ' +
|
||||
new Date(v * 1000).toLocaleString('zh-CN')
|
||||
}
|
||||
content={t('首次: {{first}},最后: {{last}}', {
|
||||
first: new Date(record.first_at * 1000).toLocaleString(
|
||||
i18n.language,
|
||||
),
|
||||
last: new Date(v * 1000).toLocaleString(i18n.language),
|
||||
})}
|
||||
>
|
||||
<span className='cursor-default whitespace-nowrap text-xs tabular-nums text-gray-500 dark:text-gray-400'>
|
||||
{v ? new Date(v * 1000).toLocaleString('zh-CN') : '-'}
|
||||
{v ? new Date(v * 1000).toLocaleString(i18n.language) : '-'}
|
||||
</span>
|
||||
</Tooltip>
|
||||
),
|
||||
|
||||
@@ -728,7 +728,9 @@ const OrgRecharge = ({ orgId }) => {
|
||||
}`}
|
||||
>
|
||||
{customEffectiveAmount > 0 && !customValid
|
||||
? `${t('当前 ¥')}${customEffectiveAmount.toLocaleString()}${t(',未达到最低 ¥1,000')}`
|
||||
? t('当前 ¥{{amount}},未达到最低 ¥1,000', {
|
||||
amount: customEffectiveAmount.toLocaleString(),
|
||||
})
|
||||
: t('最少 1000 元,必须为 1000 元的整倍数')}
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
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, useCallback, useEffect, useContext } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
Building2,
|
||||
AlertTriangle,
|
||||
RefreshCw,
|
||||
HelpCircle,
|
||||
Home,
|
||||
} from 'lucide-react';
|
||||
import { Button } from '@douyinfe/semi-ui';
|
||||
import { API } from '../../helpers/api';
|
||||
import { UserContext } from '../../context/User';
|
||||
import Loading from '../../components/common/ui/Loading';
|
||||
import PageBackground from '../../components/common/PageBackground';
|
||||
|
||||
// 企业中心入口解析:本地没有可用的 current_org_id 时,由企业中心就地渲染本组件(不再跳转独立页面)。
|
||||
// 企业与成员均由管理员创建,不提供用户自助加入。按归属状态区分:
|
||||
// none —— 用户不属于任何企业,引导联系企业管理员开通账号
|
||||
// inactive —— 用户有企业但均非活跃(冻结/欠费/待激活),引导联系管理员
|
||||
// error —— 企业列表加载失败,提供重试
|
||||
const ORG_STATUS_TEXT = {
|
||||
2: '已被冻结',
|
||||
3: '已欠费',
|
||||
4: '待激活',
|
||||
};
|
||||
|
||||
const OrgResolver = ({
|
||||
onResolved,
|
||||
excludeOrgIds = [],
|
||||
hasMarquee = false,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [userState] = useContext(UserContext);
|
||||
const isOrgOnly = userState?.user?.org_only_mode === true;
|
||||
// 'checking' | 'none' | 'inactive' | 'error'
|
||||
const [mode, setMode] = useState('checking');
|
||||
const [inactiveOrgs, setInactiveOrgs] = useState([]);
|
||||
|
||||
// 有 active(status=1) 企业 → 写入 current_org_id 并交回企业中心(仅认 active,防冻结企业死循环)。
|
||||
// excludeOrgIds 为本次加载失败过的企业:自动解析时一律跳过,避免"选中→失败→再选中"的循环;
|
||||
// 可用企业若全部失败过,按加载失败处理(可能只是网络抖动),由用户手动重试时才再次尝试。
|
||||
const runCheck = useCallback(
|
||||
async (retryExcluded = false) => {
|
||||
setMode('checking');
|
||||
try {
|
||||
const res = await API.get('/api/org/list');
|
||||
if (res.data.success) {
|
||||
const orgs = res.data.data || [];
|
||||
const activeOrgs = orgs.filter((o) => o.status === 1);
|
||||
const candidates = retryExcluded
|
||||
? activeOrgs
|
||||
: activeOrgs.filter((o) => !excludeOrgIds.includes(o.id));
|
||||
if (candidates.length > 0) {
|
||||
const savedOrgId = parseInt(
|
||||
localStorage.getItem('current_org_id') || '0',
|
||||
10,
|
||||
);
|
||||
const savedOrg =
|
||||
savedOrgId > 0
|
||||
? candidates.find((o) => o.id === savedOrgId)
|
||||
: null;
|
||||
const targetOrg = savedOrg || candidates[0];
|
||||
localStorage.setItem('current_org_id', String(targetOrg.id));
|
||||
onResolved(targetOrg.id);
|
||||
return;
|
||||
}
|
||||
if (activeOrgs.length > 0) {
|
||||
setMode('error');
|
||||
return;
|
||||
}
|
||||
if (orgs.length > 0) {
|
||||
setInactiveOrgs(orgs);
|
||||
setMode('inactive');
|
||||
return;
|
||||
}
|
||||
setMode('none');
|
||||
return;
|
||||
}
|
||||
setMode('error');
|
||||
} catch {
|
||||
setMode('error');
|
||||
}
|
||||
},
|
||||
[onResolved, excludeOrgIds],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
runCheck();
|
||||
}, [runCheck]);
|
||||
|
||||
if (mode === 'checking') {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
// 非 org_only 用户提供「返回首页」出口,避免被困在本页;org_only 员工受守卫限制在 /org,不提供。
|
||||
const backHome = !isOrgOnly && (
|
||||
<div className='mt-6 text-center'>
|
||||
<button
|
||||
onClick={() => navigate('/')}
|
||||
className='inline-flex items-center gap-1.5 text-sm text-gray-400 dark:text-gray-500 hover:text-brand-deep transition-colors'
|
||||
>
|
||||
<Home size={14} />
|
||||
{t('返回首页')}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
// /org 下 PageLayout 关闭外层滚动、也不插跑马灯占位:顶部让位与滚动都由本页自理(同企业中心主布局)。
|
||||
<div
|
||||
className={`org-center relative h-screen overflow-y-auto bg-[var(--surface-bg-base)] transition-colors duration-300 ${hasMarquee ? 'pt-[96px] sm:pt-[104px]' : 'pt-14 sm:pt-16'}`}
|
||||
>
|
||||
{/* 统一页面背景层 —— 唯一背景来源,走 bg-glow-* 主题变量 */}
|
||||
<PageBackground />
|
||||
|
||||
<div className='relative z-10 min-h-full flex items-center justify-center py-10 px-4'>
|
||||
<div className='w-full max-w-md'>
|
||||
{mode === 'none' && (
|
||||
<>
|
||||
<div className='text-center mb-7'>
|
||||
<div className='inline-flex p-4 rounded-2xl bg-gradient-to-br from-brand-from via-brand-via to-brand-to mb-5 shadow-lg shadow-brand/25 dark:shadow-brand/15'>
|
||||
<Building2 size={34} className='text-white' />
|
||||
</div>
|
||||
<h1 className='text-3xl font-bold text-gray-900 dark:text-white'>
|
||||
{t('暂未加入企业')}
|
||||
</h1>
|
||||
<p className='text-gray-500 dark:text-gray-400 mt-2.5 leading-relaxed'>
|
||||
{t(
|
||||
'企业成员账号由企业管理员统一创建,请联系你的企业管理员开通',
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className='rounded-xl border border-[var(--border-subtle)] bg-[var(--surface-card)] shadow-[var(--elevation-sm)] p-6 sm:p-7 transition-colors duration-300'>
|
||||
<div className='flex items-start gap-2.5'>
|
||||
<HelpCircle
|
||||
size={16}
|
||||
className='text-gray-400 dark:text-gray-500 mt-0.5 flex-shrink-0'
|
||||
/>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400 leading-relaxed'>
|
||||
{t(
|
||||
'管理员创建账号后,请使用企业账号通过「企业登录」进入企业中心。',
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
size='large'
|
||||
block
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => runCheck()}
|
||||
className='mt-4'
|
||||
>
|
||||
{t('刷新状态')}
|
||||
</Button>
|
||||
</div>
|
||||
{backHome}
|
||||
</>
|
||||
)}
|
||||
|
||||
{mode === 'inactive' && (
|
||||
<>
|
||||
<div className='text-center mb-7'>
|
||||
<div className='inline-flex p-4 rounded-2xl bg-gradient-to-br from-amber-400 to-amber-500 mb-5 shadow-lg shadow-amber-500/25 dark:shadow-amber-500/15'>
|
||||
<AlertTriangle size={34} className='text-white' />
|
||||
</div>
|
||||
<h1 className='text-3xl font-bold text-gray-900 dark:text-white'>
|
||||
{t('企业暂不可用')}
|
||||
</h1>
|
||||
<p className='text-gray-500 dark:text-gray-400 mt-2.5 leading-relaxed'>
|
||||
{t('你所属的企业当前无法访问,请联系管理员处理')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className='rounded-xl border border-[var(--border-subtle)] bg-[var(--surface-card)] shadow-[var(--elevation-sm)] p-6 sm:p-7 transition-colors duration-300'>
|
||||
<div className='space-y-2.5'>
|
||||
{inactiveOrgs.map((org) => (
|
||||
<div
|
||||
key={org.id}
|
||||
className='flex items-center justify-between gap-3 p-3 rounded-xl bg-gray-50 dark:bg-neutral-800/60 border border-gray-100 dark:border-neutral-800'
|
||||
>
|
||||
<div className='flex items-center gap-2.5 min-w-0'>
|
||||
<Building2
|
||||
size={16}
|
||||
className='text-gray-400 flex-shrink-0'
|
||||
/>
|
||||
<span className='text-sm font-medium text-gray-900 dark:text-white truncate'>
|
||||
{org.name || t('企业') + ' #' + org.id}
|
||||
</span>
|
||||
</div>
|
||||
<span className='text-xs font-medium text-amber-600 dark:text-amber-400 flex-shrink-0'>
|
||||
{t(ORG_STATUS_TEXT[org.status] || '不可用')}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className='mt-5 pt-5 border-t border-gray-100 dark:border-neutral-800 flex items-start gap-2.5'>
|
||||
<HelpCircle
|
||||
size={16}
|
||||
className='text-gray-400 dark:text-gray-500 mt-0.5 flex-shrink-0'
|
||||
/>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400 leading-relaxed'>
|
||||
{t(
|
||||
'企业激活、解冻或续费由平台管理员处理,请联系企业管理员或平台客服。',
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
size='large'
|
||||
block
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => runCheck()}
|
||||
className='mt-4'
|
||||
>
|
||||
{t('刷新状态')}
|
||||
</Button>
|
||||
</div>
|
||||
{backHome}
|
||||
</>
|
||||
)}
|
||||
|
||||
{mode === 'error' && (
|
||||
<>
|
||||
<div className='text-center mb-7'>
|
||||
<div className='inline-flex p-4 rounded-2xl bg-gradient-to-br from-red-400 to-red-500 mb-5 shadow-lg shadow-red-500/25 dark:shadow-red-500/15'>
|
||||
<AlertTriangle size={34} className='text-white' />
|
||||
</div>
|
||||
<h1 className='text-3xl font-bold text-gray-900 dark:text-white'>
|
||||
{t('加载失败')}
|
||||
</h1>
|
||||
<p className='text-gray-500 dark:text-gray-400 mt-2.5 leading-relaxed'>
|
||||
{t('无法获取你的企业信息,请检查网络后重试')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className='rounded-xl border border-[var(--border-subtle)] bg-[var(--surface-card)] shadow-[var(--elevation-sm)] p-6 sm:p-7 transition-colors duration-300'>
|
||||
<Button
|
||||
type='primary'
|
||||
size='large'
|
||||
block
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => runCheck(true)}
|
||||
>
|
||||
{t('重试')}
|
||||
</Button>
|
||||
</div>
|
||||
{backHome}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default OrgResolver;
|
||||
@@ -32,7 +32,6 @@ import {
|
||||
Check,
|
||||
RefreshCw,
|
||||
Shield,
|
||||
Coins,
|
||||
BellRing,
|
||||
Database,
|
||||
} from 'lucide-react';
|
||||
@@ -56,7 +55,6 @@ import {
|
||||
getQuotaPerUnit,
|
||||
collectPagedItems,
|
||||
} from '../../helpers';
|
||||
import QuotaInput from '../../components/common/ui/QuotaInput';
|
||||
import Loading from '../../components/common/ui/Loading';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
@@ -658,50 +656,6 @@ const OrgSettings = ({ orgId, orgRole }) => {
|
||||
</TabPane>
|
||||
)}
|
||||
|
||||
{(isOwner || isSuperAdmin) && (
|
||||
<TabPane tab={t('额度与成员')} itemKey='quota'>
|
||||
<OrgPanel
|
||||
icon={Coins}
|
||||
title={t('额度策略')}
|
||||
padding='p-5'
|
||||
className='mt-4 mb-2'
|
||||
>
|
||||
<p className='text-sm text-gray-500 dark:text-gray-400 mb-3'>
|
||||
{t(
|
||||
'新成员通过企业代码自助加入时的默认个人额度上限。设置为大于 0 的值可避免企业代码泄露后被盗刷企业额度池;设置为 0 表示不限制(新成员可直接使用企业统一额度池,存在风险)。',
|
||||
)}
|
||||
</p>
|
||||
<div className='max-w-md'>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5'>
|
||||
{t('新成员默认额度上限')}
|
||||
</label>
|
||||
<QuotaInput
|
||||
value={orgInfo.default_member_quota}
|
||||
onChange={(v) =>
|
||||
setOrgInfo({ ...orgInfo, default_member_quota: v })
|
||||
}
|
||||
minQuota={0}
|
||||
style={{ width: '100%' }}
|
||||
placeholder={t('请输入金额,0 表示不限制')}
|
||||
disabled={isSuperAdmin}
|
||||
/>
|
||||
{!(Number(orgInfo.default_member_quota) > 0) && (
|
||||
<p className='text-xs text-amber-500 mt-1'>
|
||||
{t('当前为 0:新成员将不受限制地使用企业额度池')}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{!isSuperAdmin && (
|
||||
<div className='mt-4 flex justify-end'>
|
||||
<Button type='primary' loading={loading} onClick={handleSave}>
|
||||
{t('保存设置')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</OrgPanel>
|
||||
</TabPane>
|
||||
)}
|
||||
|
||||
{(isOwner || isSuperAdmin) && (
|
||||
<TabPane tab={t('通知预警')} itemKey='alerts'>
|
||||
<OrgPanel
|
||||
@@ -731,8 +685,9 @@ const OrgSettings = ({ orgId, orgRole }) => {
|
||||
/>
|
||||
{Number(alertYuan) >= 0.005 ? (
|
||||
<p className='text-xs text-brand-deep mt-1'>
|
||||
{t('当企业剩余额度低于')} {getCurrencySymbol()}
|
||||
{Number(alertYuan).toFixed(2)} {t('时触发预警')}
|
||||
{t('当企业剩余额度低于 {{amount}} 时触发预警', {
|
||||
amount: `${getCurrencySymbol()}${Number(alertYuan).toFixed(2)}`,
|
||||
})}
|
||||
</p>
|
||||
) : (
|
||||
<p className='text-xs text-amber-500 mt-1'>
|
||||
|
||||
@@ -54,6 +54,10 @@ import { useSidebarCollapsed } from '../../hooks/common/useSidebarCollapsed';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
import { normalizeSidebarModulesAdmin } from '../../constants/sidebarModules';
|
||||
import { canAccessOrgSettings } from './orgFeatureFlags';
|
||||
import {
|
||||
isMiniProgramPaymentPath,
|
||||
isMiniProgramWebView,
|
||||
} from '../../helpers/miniProgram';
|
||||
import {
|
||||
CLOUD_BRAIN_UI_ENABLED,
|
||||
isCloudBrainOrgPath,
|
||||
@@ -360,6 +364,9 @@ const OrgSidebar = ({
|
||||
return false;
|
||||
}
|
||||
if (item.adminOnly && !isAdmin) return false;
|
||||
// WeyAi 小程序里不出现付费入口(helpers/miniProgram.js)。
|
||||
if (isMiniProgramWebView() && isMiniProgramPaymentPath(item.itemKey))
|
||||
return false;
|
||||
// 平台超管(无成员身份)访问成员型入口必被 member_actor_required 拒绝。
|
||||
if (!isMemberActor && item.itemKey === '/org/my-capabilities')
|
||||
return false;
|
||||
|
||||
@@ -82,7 +82,7 @@ const getCurrentUserId = () => {
|
||||
};
|
||||
|
||||
const OrgTokens = ({ orgId, orgRole }) => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const {
|
||||
tokens,
|
||||
total,
|
||||
@@ -190,8 +190,8 @@ const OrgTokens = ({ orgId, orgRole }) => {
|
||||
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
|
||||
if (diffDays === 0) return t('今天');
|
||||
if (diffDays === 1) return t('昨天');
|
||||
if (diffDays < 30) return `${diffDays} ${t('天前')}`;
|
||||
return date.toLocaleDateString('zh-CN', {
|
||||
if (diffDays < 30) return t('{{n}} 天前', { n: diffDays });
|
||||
return date.toLocaleDateString(i18n.language, {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
@@ -275,7 +275,9 @@ const OrgTokens = ({ orgId, orgRole }) => {
|
||||
<Layers size={14} />
|
||||
<span>
|
||||
{record.model_limits_enabled && record.model_limits
|
||||
? `${record.model_limits.split(',').filter(Boolean).length} ${t('个模型')}`
|
||||
? t('{{count}} 个模型', {
|
||||
count: record.model_limits.split(',').filter(Boolean).length,
|
||||
})
|
||||
: t('全部模型')}
|
||||
</span>
|
||||
</button>
|
||||
@@ -339,7 +341,9 @@ const OrgTokens = ({ orgId, orgRole }) => {
|
||||
width: 100,
|
||||
align: 'center',
|
||||
render: (v) => (
|
||||
<Tooltip content={v ? new Date(v * 1000).toLocaleString('zh-CN') : '-'}>
|
||||
<Tooltip
|
||||
content={v ? new Date(v * 1000).toLocaleString(i18n.language) : '-'}
|
||||
>
|
||||
<span className='text-gray-500 dark:text-gray-400 text-xs cursor-default'>
|
||||
{formatTime(v)}
|
||||
</span>
|
||||
|
||||
@@ -165,8 +165,10 @@ const OrgWorkbench = ({ orgId, orgRole, featureFlags }) => {
|
||||
if (!orgId) return;
|
||||
if (!silent) setLoading(true);
|
||||
try {
|
||||
// include_usage=1:只有工作台展示个人用量,后端仅在此时查询日志聚合
|
||||
const res = await API.get('/api/org/me/summary', {
|
||||
headers: getOrgHeaders(orgId),
|
||||
params: { include_usage: 1 },
|
||||
});
|
||||
if (res.data.success) {
|
||||
setSummary(res.data.data);
|
||||
|
||||
@@ -182,7 +182,7 @@ const DeptNode = memo(({ data, selected }) => {
|
||||
<Tooltip
|
||||
content={
|
||||
collapsed
|
||||
? `${t('展开')}(${t('已收起')} ${hiddenCount} ${t('个下级')})`
|
||||
? t('展开(已收起 {{n}} 个下级)', { n: hiddenCount })
|
||||
: t('收起下级部门')
|
||||
}
|
||||
>
|
||||
|
||||
@@ -176,7 +176,7 @@ const OrgAvatarSection = ({
|
||||
>
|
||||
<img
|
||||
src={getCartoonAvatarDataUrl(preset.id, 96)}
|
||||
alt={preset.label}
|
||||
alt={t(preset.label)}
|
||||
className='w-14 h-14 rounded-xl object-cover transition-transform group-hover:scale-105'
|
||||
/>
|
||||
<div className='mt-2 text-xs font-medium text-[var(--text-primary)] truncate max-w-full'>
|
||||
|
||||
@@ -178,7 +178,7 @@ const OrgScopedLimitButtons = ({ orgId, record, apiBase, scopeLabel, onSaved })
|
||||
|
||||
{/* 模型限制 Modal */}
|
||||
<OrgModal
|
||||
title={`${t(scopeLabel)}${t('模型限制')}${scopeName ? ` - ${scopeName}` : ''}`}
|
||||
title={`${t('{{scope}}模型限制', { scope: t(scopeLabel) })}${scopeName ? ` - ${scopeName}` : ''}`}
|
||||
visible={modelModalVisible}
|
||||
onOk={handleModelSave}
|
||||
onCancel={() => setModelModalVisible(false)}
|
||||
@@ -220,7 +220,7 @@ const OrgScopedLimitButtons = ({ orgId, record, apiBase, scopeLabel, onSaved })
|
||||
|
||||
{/* 可调用分组 Modal */}
|
||||
<OrgModal
|
||||
title={`${t(scopeLabel)}${t('可调用分组')}${scopeName ? ` - ${scopeName}` : ''}`}
|
||||
title={`${t('{{scope}}可调用分组', { scope: t(scopeLabel) })}${scopeName ? ` - ${scopeName}` : ''}`}
|
||||
visible={groupsModalVisible}
|
||||
onOk={handleGroupsSave}
|
||||
onCancel={() => setGroupsModalVisible(false)}
|
||||
|
||||
@@ -17,6 +17,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import i18next from 'i18next';
|
||||
|
||||
// 部门树构建工具:/api/org/dept 返回按 sort asc, id asc 排序的扁平列表,
|
||||
// 这里按 parent_id 组装成 Semi Tree/TreeSelect 的 treeData。
|
||||
|
||||
@@ -34,7 +36,7 @@ export function buildDeptTreeData(depts, options = {}) {
|
||||
const {
|
||||
disableNonLeaf = true,
|
||||
excludeSubtreeOf = null,
|
||||
disabledLabel = '已停用',
|
||||
disabledLabel = i18next.t('已停用'),
|
||||
} = options;
|
||||
const excluded = (d) =>
|
||||
excludeSubtreeOf &&
|
||||
|
||||
@@ -33,8 +33,10 @@ import { StatusContext } from '../../context/Status';
|
||||
import { UserContext } from '../../context/User';
|
||||
import { API } from '../../helpers/api';
|
||||
import { showError } from '../../helpers';
|
||||
import { isMiniProgramWebView } from '../../helpers/miniProgram';
|
||||
import Loading from '../../components/common/ui/Loading';
|
||||
import PageBackground from '../../components/common/PageBackground';
|
||||
import OrgResolver from './OrgResolver';
|
||||
import OrgSidebar from './OrgSidebar';
|
||||
import OrgWorkbench from './OrgWorkbench';
|
||||
import OrgDashboard from './OrgDashboard';
|
||||
@@ -230,7 +232,9 @@ const Organization = () => {
|
||||
if (isOrgModuleVisible('tokens')) routes.push('tokens');
|
||||
if (isOrgModuleVisible('logs')) routes.push('logs');
|
||||
if (isAdmin && isOrgModuleVisible('audit')) routes.push('audit');
|
||||
if (isAdmin && isOrgModuleVisible('recharge')) routes.push('recharge');
|
||||
// WeyAi 小程序里充值页会被送回 /user-center → /org,不能作落点,否则来回跳转。
|
||||
if (isAdmin && isOrgModuleVisible('recharge') && !isMiniProgramWebView())
|
||||
routes.push('recharge');
|
||||
if (canManageSettings && isOrgModuleVisible('settings'))
|
||||
routes.push('settings');
|
||||
return routes;
|
||||
@@ -264,6 +268,17 @@ const Organization = () => {
|
||||
|
||||
// 从 localStorage 获取当前企业ID
|
||||
const orgId = parseInt(localStorage.getItem('current_org_id') || '0', 10);
|
||||
// localStorage 不会触发重渲染:解析器写入/清除 current_org_id 后靠它刷新。
|
||||
// failedOrgIds 累计本次挂载内加载失败过的企业,交给解析器跳过:只记最近一个会在
|
||||
// 两个都失败的企业之间 A→B→A 来回自动切换(每轮都发请求并弹错误提示)。
|
||||
const [failedOrgIds, setFailedOrgIds] = useState([]);
|
||||
const [, setOrgResolveTick] = useState(0);
|
||||
const handleOrgResolved = useCallback(() => {
|
||||
// 同次挂载内 loading 已是 false、角色仍为空:不先置回 loading,
|
||||
// 切到新 orgId 的首帧就会按"非管理员"渲染路由守卫,把管理员从 /org/dashboard 弹走。
|
||||
setLoading(true);
|
||||
setOrgResolveTick((n) => n + 1);
|
||||
}, []);
|
||||
|
||||
const fetchOrgInfo = useCallback(async () => {
|
||||
if (!orgId) {
|
||||
@@ -300,11 +315,11 @@ const Organization = () => {
|
||||
} else {
|
||||
showError(res.data.message);
|
||||
localStorage.removeItem('current_org_id');
|
||||
navigateRef.current('/org/create', { replace: true });
|
||||
setFailedOrgIds((ids) => (ids.includes(orgId) ? ids : [...ids, orgId]));
|
||||
}
|
||||
} catch {
|
||||
localStorage.removeItem('current_org_id');
|
||||
navigateRef.current('/org/create', { replace: true });
|
||||
setFailedOrgIds((ids) => (ids.includes(orgId) ? ids : [...ids, orgId]));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -387,7 +402,13 @@ const Organization = () => {
|
||||
}
|
||||
|
||||
if (!orgId) {
|
||||
return <Navigate to='/org/create' replace />;
|
||||
return (
|
||||
<OrgResolver
|
||||
onResolved={handleOrgResolved}
|
||||
excludeOrgIds={failedOrgIds}
|
||||
hasMarquee={hasMarquee}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
|
||||
Reference in New Issue
Block a user