feat: 参考原型图 ui优化提交 企业端-企业中心 相关的页面
This commit is contained in:
+1
-15
@@ -20,7 +20,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React, { lazy, Suspense, useContext, useMemo } from 'react';
|
||||
import { Route, Routes, Navigate, useLocation } from 'react-router-dom';
|
||||
import Loading from './components/common/ui/Loading';
|
||||
import { AuthRedirect, PrivateRoute, AdminRoute, RootRoute } from './helpers';
|
||||
import { AuthRedirect, PrivateRoute, AdminRoute } from './helpers';
|
||||
import NotFound from './pages/NotFound';
|
||||
import Forbidden from './pages/Forbidden';
|
||||
import { StatusContext } from './context/Status';
|
||||
@@ -55,7 +55,6 @@ const LoginForm = lazy(() => import('./components/auth/LoginForm'));
|
||||
const OrgLogin = lazy(() => import('./pages/OrgLogin'));
|
||||
const PartnerPortal = lazy(() => import('./pages/PartnerPortal'));
|
||||
const PartnerConsole = lazy(() => import('./pages/PartnerPortal/Console'));
|
||||
const CommissionConsole = lazy(() => import('./pages/CommissionConsole'));
|
||||
const MyCommission = lazy(() => import('./pages/MyCommission'));
|
||||
const OrgRegister = lazy(() => import('./pages/OrgRegister'));
|
||||
const RegisterForm = lazy(() => import('./components/auth/RegisterForm'));
|
||||
@@ -335,19 +334,6 @@ function App() {
|
||||
</PrivateRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/commission'
|
||||
element={
|
||||
/* 分佣管理为 Root 专属:侧边栏一直用 isRoot() 隐藏该入口,后端结算/销售/成本/
|
||||
伙伴管理各路由组也已全部 Root 收口。这里把路由守卫对齐,避免 role=10 直接
|
||||
输 URL 进到一个读得到、写按钮全 403 的半残页面。 */
|
||||
<RootRoute>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<CommissionConsole />
|
||||
</Suspense>
|
||||
</RootRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/experience-center-audit'
|
||||
element={
|
||||
|
||||
@@ -218,7 +218,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => {
|
||||
title: t('企业活跃成员'),
|
||||
value: `${(k.active_members || 0).toLocaleString()} ${t('人')}`,
|
||||
sub: `${t('渗透率')} ${Math.min(100, pct(k.active_members, k.total_members)).toFixed(1)}% · ${t('成员')} ${(k.total_members || 0).toLocaleString()}`,
|
||||
tip: t('本期通过企业令牌产生调用的去重成员数(按自然日统计)'),
|
||||
tip: t('本期通过企业密钥产生调用的去重成员数(按自然日统计)'),
|
||||
onClick: () => onJump('growth'),
|
||||
},
|
||||
{
|
||||
|
||||
@@ -155,7 +155,7 @@ export const REASONS = {
|
||||
never_used: {
|
||||
label: '开通未使用',
|
||||
color: 'violet',
|
||||
action: '引导创建令牌、完成首次调用',
|
||||
action: '引导创建密钥、完成首次调用',
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ const CardTable = ({
|
||||
|
||||
// ===== 移动端多选支持 =====
|
||||
// 移动端卡片分支此前完全没有消费 rowSelection,导致调用方的 selectedKeys 永远是空数组,
|
||||
// 令牌/兑换码/渠道/模型/管理员令牌五个页面的批量操作在手机上全是死按钮
|
||||
// 密钥/兑换码/渠道/模型/管理员密钥五个页面的批量操作在手机上全是死按钮
|
||||
// (点了只提示「请至少选择一个」,渠道页甚至会对空集合弹出删除确认)。
|
||||
// 这里补上:兼容 Semi 的受控(传 selectedRowKeys)与非受控(只传 onChange)两种用法。
|
||||
const rowSelection =
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
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 { DatePicker, Form, Input, Modal, Select } from 'antd';
|
||||
import dayjs from 'dayjs';
|
||||
import './user-dashboard-filter.css';
|
||||
|
||||
const DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss';
|
||||
|
||||
const UserDashboardFilterModal = ({
|
||||
searchModalVisible,
|
||||
handleSearchConfirm,
|
||||
handleCloseModal,
|
||||
isAdminUser,
|
||||
inputs,
|
||||
dataExportDefaultTime,
|
||||
timeOptions,
|
||||
handleInputChange,
|
||||
t,
|
||||
}) => (
|
||||
<Modal
|
||||
open={searchModalVisible}
|
||||
title={t('筛选数据')}
|
||||
width={520}
|
||||
className='uc-dashboard-filter-modal'
|
||||
onCancel={handleCloseModal}
|
||||
onOk={handleSearchConfirm}
|
||||
okText={t('查询')}
|
||||
cancelText={t('取消')}
|
||||
maskClosable
|
||||
>
|
||||
<Form layout='vertical' requiredMark={false}>
|
||||
<Form.Item label={t('时间范围')} htmlFor='dashboard-filter-range'>
|
||||
<DatePicker.RangePicker
|
||||
id='dashboard-filter-range'
|
||||
aria-label={t('时间范围')}
|
||||
showTime
|
||||
format={DATE_FORMAT}
|
||||
allowClear={false}
|
||||
value={[dayjs(inputs.start_timestamp), dayjs(inputs.end_timestamp)]}
|
||||
onChange={(_, dateStrings) => {
|
||||
// Keep the existing query hook's local date-string contract.
|
||||
handleInputChange(dateStrings[0], 'start_timestamp');
|
||||
handleInputChange(dateStrings[1], 'end_timestamp');
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('时间粒度')} htmlFor='dashboard-filter-granularity'>
|
||||
<Select
|
||||
id='dashboard-filter-granularity'
|
||||
value={dataExportDefaultTime}
|
||||
options={timeOptions}
|
||||
onChange={(value) =>
|
||||
handleInputChange(value, 'data_export_default_time')
|
||||
}
|
||||
/>
|
||||
</Form.Item>
|
||||
{isAdminUser && (
|
||||
<Form.Item label={t('用户名称')} htmlFor='dashboard-filter-username'>
|
||||
<Input
|
||||
id='dashboard-filter-username'
|
||||
value={inputs.username}
|
||||
placeholder={t('可选值')}
|
||||
onChange={(event) =>
|
||||
handleInputChange(event.target.value, 'username')
|
||||
}
|
||||
/>
|
||||
</Form.Item>
|
||||
)}
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
|
||||
export default UserDashboardFilterModal;
|
||||
@@ -0,0 +1,15 @@
|
||||
.uc-dashboard-filter-modal .ant-modal-body {
|
||||
padding-top: 24px;
|
||||
}
|
||||
|
||||
.uc-dashboard-filter-modal .ant-picker-range {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.uc-dashboard-filter-modal .ant-form-item {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.uc-dashboard-filter-modal .ant-modal-footer {
|
||||
margin-top: 0;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ 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 { ChevronLeft } from 'lucide-react';
|
||||
import { ChevronDown, ChevronLeft } from 'lucide-react';
|
||||
import { useSidebarCollapsed } from '../../hooks/common/useSidebarCollapsed';
|
||||
import { useSidebar } from '../../hooks/common/useSidebar';
|
||||
import { useMinimumLoadingTime } from '../../hooks/common/useMinimumLoadingTime';
|
||||
@@ -35,7 +35,7 @@ import {
|
||||
import SkeletonWrapper from './components/SkeletonWrapper';
|
||||
import { CLOUD_BRAIN_UI_ENABLED } from '../../config/cloudBrainUi';
|
||||
|
||||
import { Nav, Divider, Button } from '@/components/ui';
|
||||
import { Nav, Button } from '@/components/ui';
|
||||
|
||||
const routerMap = {
|
||||
home: '/',
|
||||
@@ -58,7 +58,6 @@ const routerMap = {
|
||||
personal: '/console/personal',
|
||||
monitor: '/console/monitor',
|
||||
analytics: '/console/analytics',
|
||||
commission: '/console/commission',
|
||||
'my-commission': '/console/my-commission',
|
||||
partner: '/console/partner',
|
||||
organizations: '/console/organizations',
|
||||
@@ -97,6 +96,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
const [selectedKeys, setSelectedKeys] = useState(['home']);
|
||||
const [chatItems, setChatItems] = useState([]);
|
||||
const [openedKeys, setOpenedKeys] = useState([]);
|
||||
const [foldedGroups, setFoldedGroups] = useState([]);
|
||||
const location = useLocation();
|
||||
const [routerMapState, setRouterMapState] = useState(routerMap);
|
||||
|
||||
@@ -112,7 +112,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
: 'tableHiddle',
|
||||
},
|
||||
{
|
||||
text: t('令牌管理'),
|
||||
text: t('密钥管理'),
|
||||
itemKey: 'token',
|
||||
to: '/token',
|
||||
},
|
||||
@@ -210,12 +210,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
to: '/console/analytics',
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
text: t('分佣管理'),
|
||||
itemKey: 'commission',
|
||||
to: '/console/commission',
|
||||
className: isRoot() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
text: t('渠道管理'),
|
||||
itemKey: 'channel',
|
||||
@@ -247,7 +241,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
text: t('秘钥管理'),
|
||||
text: t('密钥管理'),
|
||||
itemKey: 'admin-token',
|
||||
to: '/console/token',
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
@@ -320,10 +314,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
// 分佣管理:新增模块不在 sidebar 配置注册表内,绕过 isModuleVisible(Root 硬门控)
|
||||
if (item.itemKey === 'commission') {
|
||||
return isRoot();
|
||||
}
|
||||
// 系统设置入口:被下放了至少一个 tab 的普通管理员强制可见
|
||||
// (需绕过 isModuleVisible,因为 GetSelf 默认对普通管理员置 admin.setting=false)。
|
||||
// root 及其它情况仍走原有 isModuleVisible 逻辑,保留 root 自行隐藏该入口的能力。
|
||||
@@ -459,6 +449,35 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
// 选中高亮颜色(统一)
|
||||
const SELECTED_COLOR = 'var(--ui-color-primary)';
|
||||
|
||||
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) => {
|
||||
// 跳过隐藏的项目
|
||||
@@ -546,7 +565,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
width: forceExpanded
|
||||
? 'var(--sidebar-width)'
|
||||
: 'var(--sidebar-current-width)',
|
||||
background: 'var(--ui-color-bg-0)',
|
||||
background: 'var(--surface-sidebar)',
|
||||
}}
|
||||
>
|
||||
<SkeletonWrapper
|
||||
@@ -596,53 +615,36 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
}}
|
||||
>
|
||||
{/* 聊天区域 */}
|
||||
{hasSectionVisibleModules('chat') && (
|
||||
<div className='sidebar-section'>
|
||||
{!collapsed && (
|
||||
<div className='sidebar-group-label'>{t('聊天')}</div>
|
||||
)}
|
||||
{chatMenuItems.map((item) => renderSubItem(item))}
|
||||
</div>
|
||||
)}
|
||||
{hasSectionVisibleModules('chat') &&
|
||||
renderGroup(
|
||||
'chat-group',
|
||||
t('聊天'),
|
||||
chatMenuItems.map(renderSubItem),
|
||||
)}
|
||||
|
||||
{/* 控制台区域 */}
|
||||
{hasSectionVisibleModules('console') && (
|
||||
<>
|
||||
<Divider className='sidebar-divider' />
|
||||
<div>
|
||||
{!collapsed && (
|
||||
<div className='sidebar-group-label'>{t('控制台')}</div>
|
||||
)}
|
||||
{workspaceItems.map((item) => renderNavItem(item))}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{hasSectionVisibleModules('console') &&
|
||||
renderGroup(
|
||||
'console-group',
|
||||
t('控制台'),
|
||||
workspaceItems.map(renderNavItem),
|
||||
)}
|
||||
|
||||
{/* 个人中心区域 */}
|
||||
{hasSectionVisibleModules('personal') && (
|
||||
<>
|
||||
<Divider className='sidebar-divider' />
|
||||
<div>
|
||||
{!collapsed && (
|
||||
<div className='sidebar-group-label'>{t('个人中心')}</div>
|
||||
)}
|
||||
{financeItems.map((item) => renderNavItem(item))}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{hasSectionVisibleModules('personal') &&
|
||||
renderGroup(
|
||||
'personal-group',
|
||||
t('个人中心'),
|
||||
financeItems.map(renderNavItem),
|
||||
)}
|
||||
|
||||
{/* 管理员区域:按角色、权限下放及菜单配置过滤。 */}
|
||||
{isAdmin() && (
|
||||
<>
|
||||
<Divider className='sidebar-divider' />
|
||||
<div>
|
||||
{!collapsed && (
|
||||
<div className='sidebar-group-label'>{t('管理员')}</div>
|
||||
)}
|
||||
{adminItems.map((item) => renderNavItem(item))}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{isAdmin() &&
|
||||
renderGroup(
|
||||
'admin-group',
|
||||
t('管理员'),
|
||||
adminItems.map(renderNavItem),
|
||||
)}
|
||||
</Nav>
|
||||
</SkeletonWrapper>
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ const UserArea = ({
|
||||
isActionVisible('userSettings') &&
|
||||
isTopNavModuleVisible('userCenter') &&
|
||||
isSidebarModuleVisible('userCenter', 'settings');
|
||||
// 「秘钥管理快捷入口」由 rightActions.keyManagement 单独控制(运营设置→顶栏管理)。
|
||||
// 「密钥管理快捷入口」由 rightActions.keyManagement 单独控制(运营设置→顶栏管理)。
|
||||
// 个人用户的 /user-center/key-management 路由不依赖顶栏模块是否显示,故顶栏导航隐藏该模块时
|
||||
// 头像菜单仍保留入口;企业员工只有在其顶栏模块放开时路由才被放行,继续联动判断。
|
||||
const showKeyManagement =
|
||||
|
||||
@@ -195,7 +195,7 @@ const SSEViewer = ({ sseData }) => {
|
||||
)}
|
||||
{item.parsed.usage && (
|
||||
<Badge
|
||||
count={`${t('令牌')}: ${item.parsed.usage.prompt_tokens || 0}/${item.parsed.usage.completion_tokens || 0}`}
|
||||
count={`${t('密钥')}: ${item.parsed.usage.prompt_tokens || 0}/${item.parsed.usage.completion_tokens || 0}`}
|
||||
type='tertiary'
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -175,7 +175,7 @@ const QualityBreakdown = ({ quality, t }) => {
|
||||
if (dim === 'error')
|
||||
return row.key !== 'service_error' && (row.key || row.key2);
|
||||
if (row.key === '' || row.key === '__unknown__') return false;
|
||||
// 渠道 / 企业 / 用户 / 令牌的 0 表示"无",筛选参数里 0 等于不过滤
|
||||
// 渠道 / 企业 / 用户 / 密钥的 0 表示"无",筛选参数里 0 等于不过滤
|
||||
if (['channel', 'org', 'user', 'token'].includes(dim) && row.key === '0')
|
||||
return false;
|
||||
return true;
|
||||
|
||||
@@ -343,7 +343,7 @@ const QualityDetail = ({ quality, t }) => {
|
||||
)}
|
||||
{row.token_name && (
|
||||
<span>
|
||||
{t('令牌')}: {row.token_name}
|
||||
{t('密钥')}: {row.token_name}
|
||||
</span>
|
||||
)}
|
||||
{!isOrg && row.group && (
|
||||
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
const splitList = (v) => (v ? String(v).split(',').filter(Boolean) : []);
|
||||
|
||||
/**
|
||||
* 远程搜索下拉(企业 / 用户 / 令牌)。选中项的名称缓存在本地,
|
||||
* 远程搜索下拉(企业 / 用户 / 密钥)。选中项的名称缓存在本地,
|
||||
* 即使结果列表被新的搜索替换,已选值仍能显示名称而非裸 ID。
|
||||
*/
|
||||
const RemoteSelect = ({
|
||||
@@ -88,7 +88,7 @@ const RemoteSelect = ({
|
||||
[quality.get, type, extraKey],
|
||||
);
|
||||
|
||||
// 联动条件(如令牌随用户)变化后清空候选,下次展开时按新条件重新搜索
|
||||
// 联动条件(如密钥随用户)变化后清空候选,下次展开时按新条件重新搜索
|
||||
useEffect(() => {
|
||||
seq.current += 1;
|
||||
setList([]);
|
||||
@@ -193,7 +193,7 @@ const QualityFilterBar = ({ quality, t, onOpenDetail }) => {
|
||||
if (filters.token_id)
|
||||
push(
|
||||
'token_id',
|
||||
`${t('令牌')}: ${nameOf(options.tokens, filters.token_id) || '#' + filters.token_id}`,
|
||||
`${t('密钥')}: ${nameOf(options.tokens, filters.token_id) || '#' + filters.token_id}`,
|
||||
);
|
||||
if (filters.path) push('path', `${t('接口')}: ${filters.path}`);
|
||||
if (filters.error_code)
|
||||
@@ -415,7 +415,7 @@ const QualityFilterBar = ({ quality, t, onOpenDetail }) => {
|
||||
extra={
|
||||
filters.user_id ? { user_id: filters.user_id } : undefined
|
||||
}
|
||||
placeholder={t('全部令牌(输入名称搜索)')}
|
||||
placeholder={t('全部密钥(输入名称搜索)')}
|
||||
onChange={(v) => setFilters({ token_id: v })}
|
||||
/>
|
||||
)}
|
||||
@@ -425,7 +425,7 @@ const QualityFilterBar = ({ quality, t, onOpenDetail }) => {
|
||||
quality={quality}
|
||||
type='token'
|
||||
value={filters.token_id}
|
||||
placeholder={t('全部令牌(输入名称搜索)')}
|
||||
placeholder={t('全部密钥(输入名称搜索)')}
|
||||
onChange={(v) => setFilters({ token_id: v })}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -102,7 +102,7 @@ export const QualityMetaNotice = ({ meta, scope, t }) => {
|
||||
if (meta.detail_available === false) {
|
||||
notes.push({
|
||||
tone: 'warn',
|
||||
text: t('日志表尚未完成质量字段升级,明细与按用户 / 令牌分析暂不可用'),
|
||||
text: t('日志表尚未完成质量字段升级,明细与按用户 / 密钥分析暂不可用'),
|
||||
});
|
||||
}
|
||||
if (notes.length === 0) return null;
|
||||
|
||||
@@ -61,7 +61,7 @@ export const PLATFORM_DIMS = [
|
||||
{ value: 'error', label: '错误码', filterKey: 'error_code' },
|
||||
{ value: 'path', label: '接口', filterKey: 'path' },
|
||||
{ value: 'user', label: '用户', filterKey: 'user_id' },
|
||||
{ value: 'token', label: '令牌', filterKey: 'token_id' },
|
||||
{ value: 'token', label: '密钥', filterKey: 'token_id' },
|
||||
];
|
||||
|
||||
export const ORG_DIMS = [
|
||||
@@ -69,7 +69,7 @@ export const ORG_DIMS = [
|
||||
{ value: 'dept', label: '部门', filterKey: 'dept_id' },
|
||||
{ value: 'project', label: '项目', filterKey: 'project_id' },
|
||||
{ value: 'user', label: '成员', filterKey: 'user_id' },
|
||||
{ value: 'token', label: '令牌', filterKey: 'token_id' },
|
||||
{ value: 'token', label: '密钥', filterKey: 'token_id' },
|
||||
{ value: 'error', label: '错误码', filterKey: 'error_code' },
|
||||
];
|
||||
|
||||
@@ -100,7 +100,7 @@ export const ALERT_DIM_TYPES = [
|
||||
export const QUALITY_ERROR_TEXT = {
|
||||
window_invalid: '时间范围无效,请重新选择',
|
||||
window_too_wide:
|
||||
'按用户 / 令牌或交叉条件筛选时,时间范围最长 7 天,请缩小范围',
|
||||
'按用户 / 密钥或交叉条件筛选时,时间范围最长 7 天,请缩小范围',
|
||||
detail_window_too_wide: '明细查询时间范围最长 31 天,请缩小范围',
|
||||
invalid_dimension: '不支持的分析维度',
|
||||
unsupported_dimension: '当前筛选条件下不支持该维度',
|
||||
@@ -113,7 +113,7 @@ export const QUALITY_ERROR_TEXT = {
|
||||
invalid_path: '接口参数过长',
|
||||
invalid_error_code: '错误码参数过长',
|
||||
org_required: '缺少企业上下文,请重新进入企业中心',
|
||||
token_not_in_org: '该令牌不属于本企业',
|
||||
token_not_in_org: '该密钥不属于本企业',
|
||||
invalid_keyword: '搜索关键词过长',
|
||||
invalid_type: '搜索类型无效',
|
||||
request_trace_params_required: '缺少请求 ID,无法查看链路',
|
||||
@@ -135,8 +135,8 @@ export const QUALITY_ERROR_TEXT = {
|
||||
};
|
||||
|
||||
export const DEGRADE_TEXT = {
|
||||
user_or_token_filter: '按用户 / 令牌筛选,已改为直接统计调用日志',
|
||||
user_or_token_dimension: '按用户 / 令牌维度分析,已改为直接统计调用日志',
|
||||
user_or_token_filter: '按用户 / 密钥筛选,已改为直接统计调用日志',
|
||||
user_or_token_dimension: '按用户 / 密钥维度分析,已改为直接统计调用日志',
|
||||
cross_dimension: '当前筛选组合超出预聚合范围,已改为直接统计调用日志',
|
||||
path_ignored: '直查日志时不支持按接口筛选,接口条件未生效',
|
||||
heatmap_requires_single_dimension:
|
||||
|
||||
@@ -71,7 +71,7 @@ const ChatsSetting = () => {
|
||||
<>
|
||||
<Spin spinning={loading} size='large'>
|
||||
{/* 聊天设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsChats options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
</Spin>
|
||||
|
||||
@@ -423,6 +423,7 @@ const CustomerServiceSetting = () => {
|
||||
|
||||
{/* 新建/编辑弹窗 */}
|
||||
<Modal
|
||||
rootClassName='settings-form-dialog'
|
||||
title={editingAgent ? t('编辑客服') : t('添加客服')}
|
||||
visible={modalVisible}
|
||||
onOk={handleSubmit}
|
||||
|
||||
@@ -146,27 +146,27 @@ const DashboardSetting = () => {
|
||||
</Modal>
|
||||
|
||||
{/* 数据看板设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsDataDashboard options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
|
||||
{/* 系统公告管理 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsAnnouncements options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
|
||||
{/* API信息管理 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsAPIInfo options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
|
||||
{/* 常见问答管理 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsFAQ options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
|
||||
{/* Uptime Kuma 监控设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsUptimeKuma options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
</Spin>
|
||||
|
||||
@@ -73,7 +73,7 @@ const DrawingSetting = () => {
|
||||
<>
|
||||
<Spin spinning={loading} size='large'>
|
||||
{/* 绘图设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsDrawing options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
</Spin>
|
||||
|
||||
@@ -113,7 +113,7 @@ const GroupModelDiscountEditor = ({
|
||||
maxTagCount={3}
|
||||
showClear
|
||||
size='small'
|
||||
style={{ minWidth: 320 }}
|
||||
style={{ width: 320, maxWidth: '100%' }}
|
||||
placeholder={t('搜索并选择模型(可多选)')}
|
||||
optionList={selectableModels.map((m) => ({ label: m, value: m }))}
|
||||
value={pendingModels}
|
||||
@@ -954,7 +954,7 @@ const LevelPolicySetting = () => {
|
||||
content={
|
||||
<div style={{ maxWidth: 360 }}>
|
||||
{t(
|
||||
'该等级用户在市场页与令牌创建中看不到这些分组,也无法显式选用',
|
||||
'该等级用户在市场页与密钥创建中看不到这些分组,也无法显式选用',
|
||||
)}
|
||||
{rest > 0 && (
|
||||
<div style={{ marginTop: 4 }}>
|
||||
@@ -1374,7 +1374,7 @@ const LevelPolicySetting = () => {
|
||||
searchPosition='dropdown'
|
||||
maxTagCount={3}
|
||||
showClear
|
||||
style={{ minWidth: 340, flex: 1 }}
|
||||
style={{ minWidth: 0, flex: '1 1 340px' }}
|
||||
placeholder={t('搜索并选择模型(可多选)')}
|
||||
value={overrideModels}
|
||||
onChange={setOverrideModels}
|
||||
@@ -1491,7 +1491,7 @@ const LevelPolicySetting = () => {
|
||||
'折扣系数 <=1 表示打折,在分组倍率基础上相乘,对该个人等级用户计费生效;留空表示该分组不打折。',
|
||||
)}{' '}
|
||||
{t(
|
||||
'「隐藏」开启后:该等级用户在市场页、令牌创建下拉中看不到该分组,显式选用的令牌在调用时会被拒绝(403);auto 路由也会绕开。例外:分组等于用户自身分组(企业为作用域默认分组)的令牌不受影响,避免误配切断存量流量(用户分组事后迁移则豁免随之失效)。',
|
||||
'「隐藏」开启后:该等级用户在市场页、密钥创建下拉中看不到该分组,显式选用的密钥在调用时会被拒绝(403);auto 路由也会绕开。例外:分组等于用户自身分组(企业为作用域默认分组)的密钥不受影响,避免误配切断存量流量(用户分组事后迁移则豁免随之失效)。',
|
||||
)}{' '}
|
||||
{t(
|
||||
'点击「模型折扣」列可展开分组行,为指定模型单独设置折扣系数——命中的模型直接按覆盖系数计费(替换分组折扣,不叠乘)。',
|
||||
|
||||
@@ -106,27 +106,27 @@ const ModelSetting = () => {
|
||||
<>
|
||||
<Spin spinning={loading} size='large'>
|
||||
{/* 模型分类管理 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingModelCategory />
|
||||
</Card>
|
||||
{/* OpenAI */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingGlobalModel options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* Gemini */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingGeminiModel options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* Claude */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingClaudeModel options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* Image pricing */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingImagePricing options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* Video */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingVideoModel options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
</Spin>
|
||||
|
||||
@@ -61,14 +61,13 @@ const NotifyChannelForm = ({
|
||||
const patch = (fields) => onChange?.({ ...v, ...fields });
|
||||
|
||||
const Label = ({ children }) => (
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5'>
|
||||
{children}
|
||||
</label>
|
||||
<label className='oc-notify-label'>{children}</label>
|
||||
);
|
||||
|
||||
// 原型:渠道下拉(≤360px)+ 浅底详情框承载各渠道字段(竖排标签)
|
||||
return (
|
||||
<div className='space-y-4'>
|
||||
<div className='max-w-xs'>
|
||||
<div className='oc-notify-form'>
|
||||
<div className='oc-notify-field oc-notify-channel'>
|
||||
<Label>{t('通知渠道')}</Label>
|
||||
<Select
|
||||
value={type}
|
||||
@@ -84,85 +83,87 @@ const NotifyChannelForm = ({
|
||||
/>
|
||||
</div>
|
||||
|
||||
{type === 'email' && (
|
||||
<div className='max-w-md'>
|
||||
<Label>{t('通知邮箱')}</Label>
|
||||
<Input
|
||||
value={v.notification_email || ''}
|
||||
onChange={(val) => patch({ notification_email: val })}
|
||||
placeholder={emailPlaceholder || t('留空则使用企业联系邮箱')}
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className='oc-notify-details'>
|
||||
{type === 'email' && (
|
||||
<div className='oc-notify-field'>
|
||||
<Label>{t('通知邮箱')}</Label>
|
||||
<Input
|
||||
value={v.notification_email || ''}
|
||||
onChange={(val) => patch({ notification_email: val })}
|
||||
placeholder={emailPlaceholder || t('留空则使用企业联系邮箱')}
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{type === 'webhook' && (
|
||||
<div className='max-w-md space-y-3'>
|
||||
<div>
|
||||
<Label>{t('Webhook 地址')}</Label>
|
||||
<Input
|
||||
value={v.webhook_url || ''}
|
||||
onChange={(val) => patch({ webhook_url: val })}
|
||||
placeholder='https://example.com/webhook'
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Label>{t('接口凭证')}</Label>
|
||||
<Input
|
||||
value={v.webhook_secret || ''}
|
||||
onChange={(val) => patch({ webhook_secret: val })}
|
||||
placeholder={t('可选,将以 Bearer 方式加入请求头')}
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{type === 'webhook' && (
|
||||
<>
|
||||
<div className='oc-notify-field'>
|
||||
<Label>{t('Webhook 地址')}</Label>
|
||||
<Input
|
||||
value={v.webhook_url || ''}
|
||||
onChange={(val) => patch({ webhook_url: val })}
|
||||
placeholder='https://example.com/webhook'
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
<div className='oc-notify-field'>
|
||||
<Label>{t('接口凭证')}</Label>
|
||||
<Input
|
||||
value={v.webhook_secret || ''}
|
||||
onChange={(val) => patch({ webhook_secret: val })}
|
||||
placeholder={t('可选,将以 Bearer 方式加入请求头')}
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{type === 'bark' && (
|
||||
<div className='max-w-md'>
|
||||
<Label>{t('Bark 推送地址')}</Label>
|
||||
<Input
|
||||
value={v.bark_url || ''}
|
||||
onChange={(val) => patch({ bark_url: val })}
|
||||
placeholder='https://api.day.app/xxx'
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{type === 'bark' && (
|
||||
<div className='oc-notify-field'>
|
||||
<Label>{t('Bark 推送地址')}</Label>
|
||||
<Input
|
||||
value={v.bark_url || ''}
|
||||
onChange={(val) => patch({ bark_url: val })}
|
||||
placeholder='https://api.day.app/xxx'
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{type === 'gotify' && (
|
||||
<div className='max-w-md space-y-3'>
|
||||
<div>
|
||||
<Label>{t('Gotify 服务器地址')}</Label>
|
||||
<Input
|
||||
value={v.gotify_url || ''}
|
||||
onChange={(val) => patch({ gotify_url: val })}
|
||||
placeholder='https://gotify.example.com'
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Label>{t('Gotify 应用令牌')}</Label>
|
||||
<Input
|
||||
value={v.gotify_token || ''}
|
||||
onChange={(val) => patch({ gotify_token: val })}
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Label>{t('消息优先级')}</Label>
|
||||
<InputNumber
|
||||
value={v.gotify_priority ?? 0}
|
||||
onChange={(val) => patch({ gotify_priority: val })}
|
||||
min={0}
|
||||
max={10}
|
||||
disabled={disabled}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{type === 'gotify' && (
|
||||
<>
|
||||
<div className='oc-notify-field'>
|
||||
<Label>{t('Gotify 服务器地址')}</Label>
|
||||
<Input
|
||||
value={v.gotify_url || ''}
|
||||
onChange={(val) => patch({ gotify_url: val })}
|
||||
placeholder='https://gotify.example.com'
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
<div className='oc-notify-field'>
|
||||
<Label>{t('Gotify 应用密钥')}</Label>
|
||||
<Input
|
||||
value={v.gotify_token || ''}
|
||||
onChange={(val) => patch({ gotify_token: val })}
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
<div className='oc-notify-field'>
|
||||
<Label>{t('消息优先级')}</Label>
|
||||
<InputNumber
|
||||
value={v.gotify_priority ?? 0}
|
||||
onChange={(val) => patch({ gotify_priority: val })}
|
||||
min={0}
|
||||
max={10}
|
||||
disabled={disabled}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -230,59 +230,59 @@ const OperationSetting = () => {
|
||||
{errorBanner}
|
||||
<ProgressiveSettingsSections loading={loading}>
|
||||
{/* 通用设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsGeneral options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 语言与地区 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsLanguage options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 主题色配置 */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<div className='settings-section'>
|
||||
<SettingsTheme options={inputs} refresh={onRefresh} />
|
||||
</div>
|
||||
{/* 顶栏模块管理 */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<div className='settings-section'>
|
||||
<SettingsHeaderNavModules options={inputs} refresh={onRefresh} />
|
||||
</div>
|
||||
{/* 企业员工顶栏管理 */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<div className='settings-section'>
|
||||
<SettingsOrgUserNavModules options={inputs} refresh={onRefresh} />
|
||||
</div>
|
||||
{/* 左侧边栏模块管理(管理员) */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<div className='settings-section'>
|
||||
<SettingsSidebarModulesAdmin options={inputs} refresh={onRefresh} />
|
||||
</div>
|
||||
{/* 屏蔽词过滤设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsSensitiveWords options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 日志设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsLog options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 监控设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsMonitoring options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 兜底渠道设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsFallback options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 技能注入(网关直连)设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsSkillInject options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 服务大盘监控设置 */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<div className='settings-section'>
|
||||
<SettingsDashboardMonitor />
|
||||
</div>
|
||||
{/* 额度设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsCreditLimit options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 跑马灯设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsMarquee options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 体验中心设置 */}
|
||||
|
||||
@@ -270,28 +270,28 @@ const PaymentSetting = () => {
|
||||
return (
|
||||
<>
|
||||
<Spin spinning={loading} size='large'>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsGeneralPayment options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsPaymentGateway options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsPaymentGatewayStripe options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsPaymentGatewayPayPal options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsPaymentGatewayCreem options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsPaymentWechat options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsPaymentAlipay options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsNuonuoInvoice options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
</Spin>
|
||||
|
||||
@@ -78,7 +78,7 @@ const RateLimitSetting = () => {
|
||||
<>
|
||||
<Spin spinning={loading} size='large'>
|
||||
{/* AI请求速率限制 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<RequestRateLimit options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
</Spin>
|
||||
|
||||
@@ -98,7 +98,7 @@ const RatioSetting = () => {
|
||||
return (
|
||||
<Spin spinning={loading} size='large'>
|
||||
{/* 模型倍率设置以及可视化编辑器 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<Tabs type='card'>
|
||||
<Tabs.TabPane tab={t('模型倍率设置')} itemKey='model'>
|
||||
<ModelRatioSettings options={inputs} refresh={onRefresh} />
|
||||
|
||||
@@ -1875,7 +1875,7 @@ const SystemSetting = () => {
|
||||
)}
|
||||
{/* WeyAi 账号接入配置:仅超级管理员可见(后端同样按 root-only 校验) */}
|
||||
{isLoaded && isRoot() && (
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<div className='settings-section'>
|
||||
<SettingsWeyAi />
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -473,7 +473,7 @@ const AccountManagement = ({
|
||||
<div className='py-4'>
|
||||
<div className='space-y-6'>
|
||||
<Space vertical className='w-full'>
|
||||
{/* 系统访问令牌 */}
|
||||
{/* 系统访问密钥 */}
|
||||
<Card className='!rounded-xl w-full'>
|
||||
<div className='flex flex-col sm:flex-row items-start sm:justify-between gap-4'>
|
||||
<div className='flex items-start w-full sm:w-auto'>
|
||||
@@ -482,10 +482,10 @@ const AccountManagement = ({
|
||||
</div>
|
||||
<div className='flex-1'>
|
||||
<Typography.Title heading={6} className='mb-1'>
|
||||
{t('系统访问令牌')}
|
||||
{t('系统访问密钥')}
|
||||
</Typography.Title>
|
||||
<Typography.Text type='tertiary' className='text-sm'>
|
||||
{t('用于API调用的身份验证令牌,请妥善保管')}
|
||||
{t('用于API调用的身份验证密钥,请妥善保管')}
|
||||
</Typography.Text>
|
||||
{systemToken && (
|
||||
<div className='mt-3'>
|
||||
@@ -508,7 +508,7 @@ const AccountManagement = ({
|
||||
className='!bg-slate-600 hover:!bg-slate-700 w-full sm:w-auto'
|
||||
icon={<IconKey />}
|
||||
>
|
||||
{systemToken ? t('重新生成') : t('生成令牌')}
|
||||
{systemToken ? t('重新生成') : t('生成密钥')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -240,7 +240,7 @@ const NotificationSettings = ({
|
||||
description: t('数据管理和日志查看'),
|
||||
modules: [
|
||||
{ key: 'detail', title: t('数据看板'), description: t('系统数据统计') },
|
||||
{ key: 'token', title: t('令牌管理'), description: t('API令牌管理') },
|
||||
{ key: 'token', title: t('密钥管理'), description: t('API密钥管理') },
|
||||
{ key: 'log', title: t('使用日志'), description: t('API使用记录') },
|
||||
{
|
||||
key: 'midjourney',
|
||||
@@ -628,19 +628,19 @@ const NotificationSettings = ({
|
||||
|
||||
<Form.Input
|
||||
field='gotifyToken'
|
||||
label={t('Gotify应用令牌')}
|
||||
placeholder={t('请输入Gotify应用令牌')}
|
||||
label={t('Gotify应用密钥')}
|
||||
placeholder={t('请输入Gotify应用密钥')}
|
||||
onChange={(val) => handleFormChange('gotifyToken', val)}
|
||||
prefix={<IconKey />}
|
||||
extraText={t(
|
||||
'在Gotify服务器创建应用后获得的令牌,用于发送通知',
|
||||
'在Gotify服务器创建应用后获得的密钥,用于发送通知',
|
||||
)}
|
||||
showClear
|
||||
rules={[
|
||||
{
|
||||
required:
|
||||
notificationSettings.warningType === 'gotify',
|
||||
message: t('请输入Gotify应用令牌'),
|
||||
message: t('请输入Gotify应用密钥'),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
@@ -675,7 +675,7 @@ const NotificationSettings = ({
|
||||
<div>
|
||||
2.{' '}
|
||||
{t(
|
||||
'复制应用的令牌(Token)并填写到上方的应用令牌字段',
|
||||
'复制应用的密钥(Token)并填写到上方的应用密钥字段',
|
||||
)}
|
||||
</div>
|
||||
<div>3. {t('填写Gotify服务器的完整URL地址')}</div>
|
||||
|
||||
@@ -18,7 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Input as AntInput, Segmented } from 'antd';
|
||||
import { Segmented } from 'antd';
|
||||
import { Button, Input } from '@/components/ui';
|
||||
import { Check } from 'lucide-react';
|
||||
import {
|
||||
@@ -58,9 +58,6 @@ const AvatarSection = ({
|
||||
avatarSettings.avatarType === USER_AVATAR_TYPES.CUSTOM &&
|
||||
!avatarSettings.customAvatarUrl?.trim();
|
||||
|
||||
// 与 getInitialAvatarDataUrl 相同的首字取法,仅用于展示,不进入保存载荷
|
||||
const initialText = username ? username[0].toUpperCase() : '';
|
||||
|
||||
return (
|
||||
<section className='ui-avatar-section'>
|
||||
<SectionHeader
|
||||
@@ -135,13 +132,6 @@ const AvatarSection = ({
|
||||
)}
|
||||
{avatarSettings.avatarType === USER_AVATAR_TYPES.INITIAL && (
|
||||
<div className='ui-avatar-field'>
|
||||
<div className='ui-avatar-field-label'>{t('显示文字')}</div>
|
||||
<AntInput
|
||||
readOnly
|
||||
value={initialText}
|
||||
className='ui-avatar-text-input'
|
||||
aria-label={t('显示文字')}
|
||||
/>
|
||||
<p className='ui-avatar-help'>
|
||||
{t('根据用户名自动生成简洁文字头像')}
|
||||
</p>
|
||||
|
||||
@@ -178,7 +178,7 @@ const SidebarSection = ({ t }) => {
|
||||
gradient: 'from-emerald-500 to-teal-500',
|
||||
modules: [
|
||||
{ key: 'detail', title: t('数据看板'), description: t('系统数据统计') },
|
||||
{ key: 'token', title: t('令牌管理'), description: t('API令牌管理') },
|
||||
{ key: 'token', title: t('密钥管理'), description: t('API密钥管理') },
|
||||
{ key: 'log', title: t('使用日志'), description: t('API使用记录') },
|
||||
{
|
||||
key: 'midjourney',
|
||||
|
||||
@@ -207,7 +207,7 @@ 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}>
|
||||
@@ -216,7 +216,7 @@ export const getAdminTokensColumns = ({
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('秘钥'),
|
||||
title: t('密钥'),
|
||||
dataIndex: 'key',
|
||||
render: renderKey,
|
||||
},
|
||||
|
||||
@@ -29,7 +29,7 @@ const AdminTokensDescription = ({ compactMode, setCompactMode, t }) => {
|
||||
<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>
|
||||
<Text>{t('密钥管理')}</Text>
|
||||
<Tag color='orange' shape='circle' size='small'>
|
||||
{t('管理员')}
|
||||
</Tag>
|
||||
|
||||
@@ -61,7 +61,7 @@ const AdminTokensFilters = ({
|
||||
<Form.Input
|
||||
field='keyword'
|
||||
prefix={<IconSearch />}
|
||||
placeholder={t('秘钥名称 / Key 片段')}
|
||||
placeholder={t('密钥名称 / Key 片段')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
|
||||
@@ -21,16 +21,16 @@ import React from 'react';
|
||||
import { Modal, Banner } from '@/components/ui';
|
||||
|
||||
const actionMeta = {
|
||||
enable: { title: '批量启用', danger: false, hint: '将选中秘钥批量启用' },
|
||||
enable: { title: '批量启用', danger: false, hint: '将选中密钥批量启用' },
|
||||
disable: {
|
||||
title: '批量禁用',
|
||||
danger: true,
|
||||
hint: '将选中秘钥批量禁用,用户将无法使用',
|
||||
hint: '将选中密钥批量禁用,用户将无法使用',
|
||||
},
|
||||
delete: {
|
||||
title: '批量删除',
|
||||
danger: true,
|
||||
hint: '将选中秘钥批量删除,操作不可恢复',
|
||||
hint: '将选中密钥批量删除,操作不可恢复',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ const AdminBatchActionModal = ({
|
||||
okText={t('确认执行')}
|
||||
>
|
||||
<div className='space-y-2'>
|
||||
<div>{t('共选中 {{count}} 个秘钥', { count })}</div>
|
||||
<div>{t('共选中 {{count}} 个密钥', { count })}</div>
|
||||
<Banner
|
||||
type={meta.danger ? 'danger' : 'info'}
|
||||
description={t(meta.hint)}
|
||||
|
||||
@@ -28,7 +28,7 @@ const AdminDeleteTokenModal = ({ visible, onCancel, onConfirm, token, t }) => {
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('确定要删除此秘钥吗?')}
|
||||
title={t('确定要删除此密钥吗?')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={onConfirm}
|
||||
@@ -41,14 +41,14 @@ const AdminDeleteTokenModal = ({ visible, onCancel, onConfirm, token, t }) => {
|
||||
<Banner
|
||||
type='warning'
|
||||
description={t(
|
||||
'该秘钥属于企业 Token,删除将影响企业内多用户的使用',
|
||||
'该密钥属于企业 Token,删除将影响企业内多用户的使用',
|
||||
)}
|
||||
closeIcon={null}
|
||||
/>
|
||||
)}
|
||||
<div>{t('删除后将无法恢复,且会立即终止使用此秘钥的所有调用')}</div>
|
||||
<div>{t('删除后将无法恢复,且会立即终止使用此密钥的所有调用')}</div>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('秘钥名称')}:{token.name || '—'}
|
||||
{t('密钥名称')}:{token.name || '—'}
|
||||
</Text>
|
||||
<br />
|
||||
<Text type='tertiary' size='small'>
|
||||
|
||||
@@ -35,7 +35,7 @@ const statusMeta = {
|
||||
};
|
||||
|
||||
/**
|
||||
* 管理员编辑秘钥弹窗
|
||||
* 管理员编辑密钥弹窗
|
||||
* 允许修改:name / group / unlimited_quota / remain_quota / expired_time
|
||||
* 不修改:
|
||||
* - status —— 启用/禁用走专用按钮,避免在编辑路径上绕过状态校验
|
||||
@@ -136,7 +136,7 @@ const AdminEditTokenModal = ({
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('编辑秘钥')}
|
||||
title={t('编辑密钥')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={handleSubmit}
|
||||
@@ -155,7 +155,7 @@ const AdminEditTokenModal = ({
|
||||
<Text strong>
|
||||
{token.display_name || token.username || '—'}
|
||||
</Text>{' '}
|
||||
(ID: {token.user_id}) {t('的秘钥')}
|
||||
(ID: {token.user_id}) {t('的密钥')}
|
||||
<Tag
|
||||
color={curStatusMeta.color}
|
||||
shape='circle'
|
||||
@@ -172,7 +172,7 @@ const AdminEditTokenModal = ({
|
||||
<Banner
|
||||
type='warning'
|
||||
description={t(
|
||||
'该秘钥属于企业 Token,修改额度或过期时间将影响企业内多用户的使用',
|
||||
'该密钥属于企业 Token,修改额度或过期时间将影响企业内多用户的使用',
|
||||
)}
|
||||
closeIcon={null}
|
||||
className='!mt-2'
|
||||
@@ -190,10 +190,10 @@ const AdminEditTokenModal = ({
|
||||
>
|
||||
<Form.Input
|
||||
field='name'
|
||||
label={t('秘钥名称')}
|
||||
placeholder={t('给秘钥起个名字')}
|
||||
label={t('密钥名称')}
|
||||
placeholder={t('给密钥起个名字')}
|
||||
maxLength={30}
|
||||
rules={[{ required: true, message: t('请输入秘钥名称') }]}
|
||||
rules={[{ required: true, message: t('请输入密钥名称') }]}
|
||||
/>
|
||||
|
||||
<Form.Select
|
||||
|
||||
@@ -35,7 +35,7 @@ const AdminEnableDisableTokenModal = ({
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={isDisable ? t('确定要禁用此秘钥吗?') : t('确定要启用此秘钥吗?')}
|
||||
title={isDisable ? t('确定要禁用此密钥吗?') : t('确定要启用此密钥吗?')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={onConfirm}
|
||||
@@ -44,11 +44,11 @@ const AdminEnableDisableTokenModal = ({
|
||||
<div className='space-y-1'>
|
||||
<div>
|
||||
{isDisable
|
||||
? t('禁用后用户将无法使用此秘钥调用 API')
|
||||
: t('启用后用户即可重新使用此秘钥')}
|
||||
? t('禁用后用户将无法使用此密钥调用 API')
|
||||
: t('启用后用户即可重新使用此密钥')}
|
||||
</div>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('秘钥名称')}:{token.name || '—'}
|
||||
{t('密钥名称')}:{token.name || '—'}
|
||||
</Text>
|
||||
<br />
|
||||
<Text type='tertiary' size='small'>
|
||||
|
||||
@@ -79,7 +79,7 @@ const PricingGroups = ({
|
||||
|
||||
return (
|
||||
<MarketFilterGroup
|
||||
title={title === undefined ? t('可用令牌分组') : title}
|
||||
title={title === undefined ? t('可用密钥分组') : title}
|
||||
items={items}
|
||||
activeValue={filterGroup}
|
||||
onChange={setFilterGroup}
|
||||
|
||||
@@ -56,6 +56,7 @@ const ModelDetailSideSheet = ({
|
||||
title={t('模型详情')}
|
||||
open={visible}
|
||||
onClose={onClose}
|
||||
maskClosable
|
||||
width={isMobile ? '100%' : 820}
|
||||
rootClassName='mm-detail-drawer mm-theme'
|
||||
rootStyle={themeStyle}
|
||||
|
||||
@@ -39,7 +39,7 @@ const TokensActions = ({
|
||||
// Handle copy selected tokens with options
|
||||
const handleCopySelectedTokens = () => {
|
||||
if (selectedKeys.length === 0) {
|
||||
showError(t('请至少选择一个令牌!'));
|
||||
showError(t('请至少选择一个密钥!'));
|
||||
return;
|
||||
}
|
||||
setShowCopyModal(true);
|
||||
@@ -48,7 +48,7 @@ const TokensActions = ({
|
||||
// Handle delete selected tokens with confirmation
|
||||
const handleDeleteSelectedTokens = () => {
|
||||
if (selectedKeys.length === 0) {
|
||||
showError(t('请至少选择一个令牌!'));
|
||||
showError(t('请至少选择一个密钥!'));
|
||||
return;
|
||||
}
|
||||
setShowDeleteModal(true);
|
||||
@@ -74,7 +74,7 @@ const TokensActions = ({
|
||||
}}
|
||||
size='small'
|
||||
>
|
||||
{t('添加令牌')}
|
||||
{t('添加密钥')}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
@@ -83,7 +83,7 @@ const TokensActions = ({
|
||||
onClick={handleCopySelectedTokens}
|
||||
size='small'
|
||||
>
|
||||
{t('复制所选令牌')}
|
||||
{t('复制所选密钥')}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
@@ -92,7 +92,7 @@ const TokensActions = ({
|
||||
onClick={handleDeleteSelectedTokens}
|
||||
size='small'
|
||||
>
|
||||
{t('删除所选令牌')}
|
||||
{t('删除所选密钥')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ const renderOperations = (
|
||||
size='small'
|
||||
onClick={() => {
|
||||
Modal.confirm({
|
||||
title: t('确定是否要删除此令牌?'),
|
||||
title: t('确定是否要删除此密钥?'),
|
||||
content: t('此修改将不可逆'),
|
||||
onOk: () => {
|
||||
(async () => {
|
||||
|
||||
@@ -29,7 +29,7 @@ const TokensDescription = ({ compactMode, setCompactMode, t }) => {
|
||||
<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-blue-500'>
|
||||
<Key size={16} className='mr-2' />
|
||||
<Text>{t('令牌管理')}</Text>
|
||||
<Text>{t('密钥管理')}</Text>
|
||||
</div>
|
||||
|
||||
<CompactModeToggle
|
||||
|
||||
@@ -55,7 +55,7 @@ function TokensPage({ labelReplace } = {}) {
|
||||
? (key, options) => {
|
||||
const result = originalT(key, options);
|
||||
return typeof result === 'string'
|
||||
? result.replace(/令牌/g, labelReplace)
|
||||
? result.replace(/密钥/g, labelReplace)
|
||||
: result;
|
||||
}
|
||||
: originalT;
|
||||
@@ -145,7 +145,7 @@ function TokensPage({ labelReplace } = {}) {
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
{key
|
||||
? t('请选择模型。')
|
||||
: t('选择模型后可一键填充当前选中令牌(或本页第一个令牌)。')}
|
||||
: t('选择模型后可一键填充当前选中密钥(或本页第一个密钥)。')}
|
||||
</div>
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
<Select
|
||||
@@ -235,7 +235,7 @@ function TokensPage({ labelReplace } = {}) {
|
||||
? tokens[0]
|
||||
: null;
|
||||
if (!token) {
|
||||
Toast.warning(t('没有可用令牌用于填充'));
|
||||
Toast.warning(t('没有可用密钥用于填充'));
|
||||
return;
|
||||
}
|
||||
apiKeyToUse = 'sk-' + token.key;
|
||||
|
||||
@@ -43,7 +43,7 @@ const CopyTokensModal = ({ visible, onCancel, selectedKeys, copyText, t }) => {
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('复制令牌')}
|
||||
title={t('复制密钥')}
|
||||
icon={null}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
|
||||
@@ -29,14 +29,14 @@ const DeleteTokensModal = ({
|
||||
}) => {
|
||||
return (
|
||||
<Modal
|
||||
title={t('批量删除令牌')}
|
||||
title={t('批量删除密钥')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={onConfirm}
|
||||
type='warning'
|
||||
>
|
||||
<div>
|
||||
{t('确定要删除所选的 {{count}} 个令牌吗?', {
|
||||
{t('确定要删除所选的 {{count}} 个密钥吗?', {
|
||||
count: selectedKeys.length,
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -95,9 +95,9 @@ const EditTokenDrawer = ({
|
||||
<Drawer
|
||||
open={open}
|
||||
onClose={onCancel}
|
||||
title={isEdit ? t('编辑令牌') : t('创建令牌')}
|
||||
title={isEdit ? t('编辑密钥') : t('创建密钥')}
|
||||
width={isMobile ? '100%' : 560}
|
||||
maskClosable={false}
|
||||
maskClosable
|
||||
forceRender
|
||||
rootClassName='km-edit-drawer'
|
||||
footer={
|
||||
@@ -108,7 +108,7 @@ const EditTokenDrawer = ({
|
||||
loading={loading}
|
||||
onClick={() => formApiRef.current?.submitForm()}
|
||||
>
|
||||
{isEdit ? t('保存') : t('创建令牌')}
|
||||
{isEdit ? t('保存') : t('创建密钥')}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
@@ -126,13 +126,13 @@ const EditTokenDrawer = ({
|
||||
<Form.Input
|
||||
field='name'
|
||||
label={t('名称')}
|
||||
placeholder={t('请输入令牌名称')}
|
||||
placeholder={t('请输入密钥名称')}
|
||||
rules={[{ required: true, message: t('请输入名称') }]}
|
||||
/>
|
||||
{groups.length > 0 ? (
|
||||
<Form.Select
|
||||
field='group'
|
||||
label={t('令牌分组')}
|
||||
label={t('密钥分组')}
|
||||
placeholder={t('选择分组,默认为用户分组')}
|
||||
optionList={groups}
|
||||
renderOptionItem={renderGroupOption}
|
||||
@@ -142,7 +142,7 @@ const EditTokenDrawer = ({
|
||||
) : (
|
||||
<Form.Select
|
||||
field='group'
|
||||
label={t('令牌分组')}
|
||||
label={t('密钥分组')}
|
||||
placeholder={t('管理员未设置用户可选分组')}
|
||||
disabled
|
||||
style={{ width: '100%' }}
|
||||
|
||||
@@ -60,7 +60,7 @@ const EditTokenModal = (props) => {
|
||||
? (key, options) => {
|
||||
const result = originalT(key, options);
|
||||
return typeof result === 'string'
|
||||
? result.replace(/令牌/g, props.labelReplace)
|
||||
? result.replace(/密钥/g, props.labelReplace)
|
||||
: result;
|
||||
}
|
||||
: originalT;
|
||||
@@ -365,7 +365,7 @@ const EditTokenModal = (props) => {
|
||||
});
|
||||
const { success, message } = res.data;
|
||||
if (success) {
|
||||
showSuccess(t('令牌更新成功!'));
|
||||
showSuccess(t('密钥更新成功!'));
|
||||
props.refresh();
|
||||
props.handleClose();
|
||||
} else {
|
||||
@@ -393,7 +393,7 @@ const EditTokenModal = (props) => {
|
||||
}
|
||||
}
|
||||
if (successCount > 0) {
|
||||
showSuccess(t('令牌创建成功,请在列表页面点击复制获取令牌!'));
|
||||
showSuccess(t('密钥创建成功,请在列表页面点击复制获取密钥!'));
|
||||
props.refresh();
|
||||
props.handleClose();
|
||||
}
|
||||
@@ -464,10 +464,10 @@ const EditTokenModal = (props) => {
|
||||
</div>
|
||||
<div>
|
||||
<h2 className='text-base font-semibold text-gray-800 dark:text-gray-100'>
|
||||
{isEdit ? t('编辑令牌') : t('创建令牌')}
|
||||
{isEdit ? t('编辑密钥') : t('创建密钥')}
|
||||
</h2>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400'>
|
||||
{isEdit ? t('修改令牌配置') : t('快速创建访问令牌')}
|
||||
{isEdit ? t('修改密钥配置') : t('快速创建访问密钥')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -506,16 +506,16 @@ const EditTokenModal = (props) => {
|
||||
<Form.Input
|
||||
field='name'
|
||||
noLabel
|
||||
placeholder={t('请输入令牌名称')}
|
||||
placeholder={t('请输入密钥名称')}
|
||||
rules={[{ required: true, message: t('请输入名称') }]}
|
||||
showClear
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 秘钥分组 */}
|
||||
{/* 密钥分组 */}
|
||||
<div>
|
||||
<FieldLabel icon={Layers} iconColor='text-brand'>
|
||||
{t('令牌分组')}
|
||||
{t('密钥分组')}
|
||||
</FieldLabel>
|
||||
{groups.length > 0 ? (
|
||||
<Form.Select
|
||||
@@ -664,7 +664,7 @@ const EditTokenModal = (props) => {
|
||||
<Form.Switch
|
||||
field='unlimited_quota'
|
||||
label={t('无限额度')}
|
||||
extraText={t('开启后令牌不限制使用额度')}
|
||||
extraText={t('开启后密钥不限制使用额度')}
|
||||
/>
|
||||
|
||||
{!values.unlimited_quota && (
|
||||
@@ -755,7 +755,7 @@ const EditTokenModal = (props) => {
|
||||
icon={<Check size={16} />}
|
||||
loading={loading}
|
||||
>
|
||||
{isEdit ? t('保存修改') : t('创建令牌')}
|
||||
{isEdit ? t('保存修改') : t('创建密钥')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='light'
|
||||
|
||||
@@ -504,7 +504,7 @@ export const getLogsColumns = ({
|
||||
},
|
||||
{
|
||||
key: COLUMN_KEYS.TOKEN,
|
||||
title: t('令牌'),
|
||||
title: t('密钥'),
|
||||
dataIndex: 'token_name',
|
||||
render: (text, record, index) => {
|
||||
return record.type === 0 || record.type === 2 || record.type === 5 ? (
|
||||
|
||||
@@ -259,7 +259,7 @@ const LogsFilters = ({
|
||||
field='token_name'
|
||||
className={controlClass}
|
||||
prefix={<InputPrefix icon={Key} />}
|
||||
placeholder={t('令牌名称')}
|
||||
placeholder={t('密钥名称')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
|
||||
@@ -96,7 +96,7 @@ const FIELD_DEFS = [
|
||||
},
|
||||
{
|
||||
id: 'tokenName',
|
||||
label: '令牌名称',
|
||||
label: '密钥名称',
|
||||
width: 16,
|
||||
value: (r) => r.token_name || '',
|
||||
},
|
||||
|
||||
@@ -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 './payment-confirm.css';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Tag as AntTag } from 'antd';
|
||||
import { Modal, Typography, Skeleton } from '@/components/ui';
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/* 充值确认弹窗(原型未定义):Ant Design 默认弹窗 + 统一规范的语义行列表 */
|
||||
.payment-confirm-rows {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
margin: 16px 0;
|
||||
padding: 16px 0;
|
||||
border-block: 1px solid var(--border-subtle);
|
||||
}
|
||||
.payment-confirm-rows > div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
.payment-confirm-rows dt {
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
.payment-confirm-rows dd {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
color: var(--text-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
.payment-confirm-amount {
|
||||
color: var(--ui-color-primary);
|
||||
font-size: 20px;
|
||||
}
|
||||
.payment-confirm-discount {
|
||||
color: var(--ui-color-success);
|
||||
}
|
||||
.payment-confirm-method .ant-typography {
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.payment-confirm-modal .ant-modal-content {
|
||||
border-radius: 12px;
|
||||
padding: 20px 24px;
|
||||
}
|
||||
.payment-confirm-modal .ant-modal-footer {
|
||||
margin-top: 12px;
|
||||
}
|
||||
.payment-confirm-rows {
|
||||
gap: 12px;
|
||||
margin: 18px 0;
|
||||
padding: 18px 0;
|
||||
}
|
||||
.payment-confirm-rows dt {
|
||||
line-height: 20px;
|
||||
}
|
||||
.payment-confirm-rows dd {
|
||||
font-size: 13px;
|
||||
}
|
||||
.payment-confirm-method {
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
@@ -109,7 +109,17 @@ export const Form = forwardRef(function Form(
|
||||
? 'inline'
|
||||
: 'vertical'
|
||||
}
|
||||
labelCol={labelWidth ? { flex: labelWidth } : undefined}
|
||||
labelCol={
|
||||
props.labelCol ??
|
||||
(labelWidth
|
||||
? {
|
||||
flex: `0 0 ${typeof labelWidth === 'number' ? `${labelWidth}px` : labelWidth}`,
|
||||
}
|
||||
: undefined)
|
||||
}
|
||||
wrapperCol={
|
||||
props.wrapperCol ?? (labelWidth ? { flex: '1 1 0' } : undefined)
|
||||
}
|
||||
labelAlign={labelAlign}
|
||||
onFinish={onSubmit}
|
||||
onFinishFailed={onSubmitFail}
|
||||
|
||||
@@ -20,7 +20,8 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React, { forwardRef } from 'react';
|
||||
import * as Ant from 'antd';
|
||||
import { controlSize, placement } from './controls';
|
||||
import { paginationEvents } from './pagination';
|
||||
import { paginationEvents, paginationShowTotal } from './pagination';
|
||||
import { overlayMaskClosable } from './overlayPolicy';
|
||||
|
||||
export * from './controls';
|
||||
export { Form, withField } from './form';
|
||||
@@ -124,7 +125,7 @@ export const Space = ({ spacing, vertical, size, ...props }) => (
|
||||
<Ant.Space
|
||||
{...props}
|
||||
direction={vertical ? 'vertical' : 'horizontal'}
|
||||
size={spacing ?? size}
|
||||
size={spacing === 'medium' ? 'middle' : (spacing ?? size)}
|
||||
/>
|
||||
);
|
||||
export const Divider = ({ margin, align, layout, style, ...props }) => (
|
||||
@@ -271,6 +272,7 @@ export function Table({
|
||||
current: pagination.currentPage ?? pagination.current,
|
||||
pageSizeOptions:
|
||||
pagination.pageSizeOpts ?? pagination.pageSizeOptions,
|
||||
showTotal: paginationShowTotal(pagination.showTotal),
|
||||
...paginationEvents(pagination),
|
||||
}
|
||||
: false
|
||||
@@ -301,7 +303,7 @@ export function Pagination({
|
||||
})}
|
||||
pageSizeOptions={pageSizeOpts ?? props.pageSizeOptions}
|
||||
size={size === 'small' ? 'small' : 'default'}
|
||||
showTotal={showTotal === true ? (total) => `${total}` : showTotal}
|
||||
showTotal={paginationShowTotal(showTotal)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -516,6 +518,7 @@ function modalProps({
|
||||
}) {
|
||||
return {
|
||||
...props,
|
||||
maskClosable: overlayMaskClosable(props.maskClosable),
|
||||
open: visible,
|
||||
title: header === null ? null : (props.title ?? header),
|
||||
keyboard: closeOnEsc,
|
||||
@@ -556,6 +559,7 @@ export const SideSheet = ({
|
||||
}) => (
|
||||
<Ant.Drawer
|
||||
{...props}
|
||||
maskClosable={overlayMaskClosable(props.maskClosable)}
|
||||
open={visible}
|
||||
onClose={onCancel}
|
||||
keyboard={closeOnEsc}
|
||||
@@ -681,6 +685,7 @@ export const Dropdown = Object.assign(
|
||||
|
||||
const NavItem = ({ children }) => children;
|
||||
const NavSub = ({ children }) => children;
|
||||
const NavGroup = ({ children }) => children;
|
||||
export const Nav = Object.assign(
|
||||
function Nav({
|
||||
children,
|
||||
@@ -701,6 +706,21 @@ export const Nav = Object.assign(
|
||||
return React.Children.toArray(nodes).flatMap((child, index) => {
|
||||
if (!React.isValidElement(child)) return [];
|
||||
const p = child.props;
|
||||
if (child.type === NavGroup) {
|
||||
const children = items(p.children, `${prefix}${p.itemKey}-`);
|
||||
if (children.length === 0) return [];
|
||||
// Collapsed menus keep their icon tooltips without group headings.
|
||||
if (isCollapsed) return children;
|
||||
return [
|
||||
{
|
||||
type: 'group',
|
||||
key: p.itemKey,
|
||||
label: p.text,
|
||||
className: p.className,
|
||||
children: p.folded ? [] : children,
|
||||
},
|
||||
];
|
||||
}
|
||||
if (child.type === NavItem || child.type === NavSub) {
|
||||
const label = renderWrapper
|
||||
? renderWrapper({ itemElement: <span>{p.text}</span>, props: p })
|
||||
@@ -736,5 +756,5 @@ export const Nav = Object.assign(
|
||||
/>
|
||||
);
|
||||
},
|
||||
{ Item: NavItem, Sub: NavSub },
|
||||
{ Item: NavItem, Sub: NavSub, Group: NavGroup },
|
||||
);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
// Shared overlays also serve admin pages; apply the personal-page policy only
|
||||
// when rendering an overlay or opening an imperative confirmation on these routes.
|
||||
export function overlayMaskClosable(
|
||||
configured,
|
||||
pathname = globalThis.window?.location?.pathname ?? '',
|
||||
) {
|
||||
const scoped =
|
||||
pathname === '/market' ||
|
||||
pathname === '/market/' ||
|
||||
pathname === '/skill-market' ||
|
||||
pathname === '/skill-market/' ||
|
||||
pathname === '/user-center' ||
|
||||
pathname.startsWith('/user-center/');
|
||||
return scoped ? true : configured;
|
||||
}
|
||||
@@ -17,6 +17,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
// Legacy pagination accepts a boolean; Ant Design calls a renderer when enabled.
|
||||
export const paginationShowTotal = (showTotal) =>
|
||||
showTotal === true ? (total) => `${total}` : showTotal;
|
||||
|
||||
// Preserve the existing callback sequence while Ant Design owns presentation.
|
||||
export function paginationEvents({
|
||||
currentPage,
|
||||
|
||||
@@ -193,7 +193,7 @@ export const CHANNEL_OPTIONS = [
|
||||
},
|
||||
{
|
||||
// Tezign(特赞)视频网关(seedance 2.0);value 对应后端 ChannelTypeTezignVideo=58
|
||||
// 密钥格式:上游 Bearer 令牌(sk-gw-...)
|
||||
// 密钥格式:上游 Bearer 密钥(sk-gw-...)
|
||||
value: 58,
|
||||
color: 'orange',
|
||||
label: 'Tezign 视频',
|
||||
|
||||
@@ -70,7 +70,7 @@ export async function finishLogin({
|
||||
showSuccess(message);
|
||||
}
|
||||
// org_only(仅企业资源)用户默认落企业空间,与 AuthRedirect 一致:默认落地页
|
||||
// (秘钥管理)挂载即调用被 BlockOrgOnlyMode 拦截的 /api/token,会先弹报错再被
|
||||
// (密钥管理)挂载即调用被 BlockOrgOnlyMode 拦截的 /api/token,会先弹报错再被
|
||||
// orgConfined 踢回 /org;企业中心整体关闭时 orgConfined 不生效,会一直停在报错页
|
||||
const defaultRedirect =
|
||||
verifiedUser.org_only_mode === true ? '/org' : undefined;
|
||||
|
||||
@@ -122,7 +122,7 @@ export const useAdminTokensData = () => {
|
||||
);
|
||||
|
||||
// 注意:不能像 users hook 那样用 `list[i].key = list[i].id`,
|
||||
// 因为 Token 的 key 字段本身有意义(脱敏后的秘钥),覆盖会破坏列表展示
|
||||
// 因为 Token 的 key 字段本身有意义(脱敏后的密钥),覆盖会破坏列表展示
|
||||
// 改为在 Table 上用 rowKey='id'
|
||||
const setListFormat = (list) => {
|
||||
setTokens(list);
|
||||
@@ -219,7 +219,7 @@ export const useAdminTokensData = () => {
|
||||
// 批量管理
|
||||
const batchManageTokens = async (ids, action) => {
|
||||
if (!ids || ids.length === 0) {
|
||||
showError(t('请先选择秘钥'));
|
||||
showError(t('请先选择密钥'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -30,7 +30,7 @@ export function useTokenKeys(id) {
|
||||
const loadAllData = async () => {
|
||||
const fetchedKeys = await fetchTokenKeys();
|
||||
if (fetchedKeys.length === 0) {
|
||||
showError('当前没有可用的启用令牌,请确认是否有令牌处于启用状态!');
|
||||
showError('当前没有可用的启用密钥,请确认是否有密钥处于启用状态!');
|
||||
setTimeout(() => {
|
||||
window.location.href = '/console/token';
|
||||
}, 1500); // 延迟 1.5 秒后跳转
|
||||
|
||||
@@ -107,7 +107,7 @@ export const useNavigation = (
|
||||
|
||||
const allLinks = [
|
||||
{
|
||||
text: t('秘钥管理'),
|
||||
text: t('密钥管理'),
|
||||
itemKey: 'keyManagement',
|
||||
to: '/user-center/key-management',
|
||||
requireAuth: getHeaderModuleRequireAuth(modules, 'keyManagement'),
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
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 { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { API } from '../../helpers';
|
||||
import { parsePayPalQuote } from '../../helpers/paypalPayment';
|
||||
|
||||
// Bind quotes to the exact selection and coalesce preview/confirmation requests.
|
||||
export default function usePayPalQuote(endpoint, body, enabled, orgId) {
|
||||
const key = JSON.stringify([endpoint, body, orgId]);
|
||||
const currentKey = useRef(key);
|
||||
currentKey.current = key;
|
||||
const pending = useRef(null);
|
||||
const [result, setResult] = useState(null);
|
||||
const [loadingKey, setLoadingKey] = useState(null);
|
||||
|
||||
const setQuote = (quote) => setResult({ key, quote });
|
||||
const refresh = useCallback(() => {
|
||||
if (pending.current?.key === key) return pending.current.promise;
|
||||
const [url, payload, organization] = JSON.parse(key);
|
||||
setLoadingKey(key);
|
||||
setResult(null);
|
||||
const promise = API.post(
|
||||
url,
|
||||
payload,
|
||||
organization === undefined || organization === null
|
||||
? undefined
|
||||
: { headers: { 'X-Org-Id': String(organization) } },
|
||||
)
|
||||
.then((response) => {
|
||||
if (!response.data.success) throw new Error(response.data.message);
|
||||
const quote = parsePayPalQuote(response);
|
||||
if (currentKey.current !== key) return null;
|
||||
setResult({ key, quote });
|
||||
return quote;
|
||||
})
|
||||
.finally(() => {
|
||||
if (pending.current?.promise === promise) pending.current = null;
|
||||
setLoadingKey((previous) => (previous === key ? null : previous));
|
||||
});
|
||||
pending.current = { key, promise };
|
||||
return promise;
|
||||
}, [key]);
|
||||
|
||||
useEffect(() => {
|
||||
if (enabled) refresh().catch(() => {});
|
||||
}, [enabled, refresh]);
|
||||
|
||||
return {
|
||||
quote: result?.key === key ? result.quote : null,
|
||||
setQuote,
|
||||
loading: enabled && loadingKey === key,
|
||||
refresh,
|
||||
};
|
||||
}
|
||||
@@ -258,7 +258,7 @@ export const useTokensData = (openFluentNotification) => {
|
||||
// Batch delete tokens
|
||||
const batchDeleteTokens = async () => {
|
||||
if (selectedKeys.length === 0) {
|
||||
showError(t('请先选择要删除的令牌!'));
|
||||
showError(t('请先选择要删除的密钥!'));
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
@@ -267,7 +267,7 @@ export const useTokensData = (openFluentNotification) => {
|
||||
const res = await API.post('/api/token/batch', { ids });
|
||||
if (res?.data?.success) {
|
||||
const count = res.data.data || 0;
|
||||
showSuccess(t('已删除 {{count}} 个令牌!', { count }));
|
||||
showSuccess(t('已删除 {{count}} 个密钥!', { count }));
|
||||
await refresh();
|
||||
setTimeout(() => {
|
||||
if (tokens.length === 0 && activePage > 1) {
|
||||
@@ -287,12 +287,12 @@ export const useTokensData = (openFluentNotification) => {
|
||||
// Batch copy tokens
|
||||
const batchCopyTokens = (copyType) => {
|
||||
if (selectedKeys.length === 0) {
|
||||
showError(t('请至少选择一个令牌!'));
|
||||
showError(t('请至少选择一个密钥!'));
|
||||
return;
|
||||
}
|
||||
|
||||
Modal.info({
|
||||
title: t('复制令牌'),
|
||||
title: t('复制密钥'),
|
||||
icon: null,
|
||||
content: t('请选择你的复制方式'),
|
||||
footer: (
|
||||
|
||||
+212
-182
File diff suppressed because it is too large
Load Diff
+218
-182
File diff suppressed because it is too large
Load Diff
+211
-181
File diff suppressed because it is too large
Load Diff
+210
-180
File diff suppressed because it is too large
Load Diff
+227
-192
File diff suppressed because it is too large
Load Diff
+210
-180
File diff suppressed because it is too large
Load Diff
+210
-180
File diff suppressed because it is too large
Load Diff
+214
-184
File diff suppressed because it is too large
Load Diff
+209
-179
File diff suppressed because it is too large
Load Diff
+84
-20
@@ -16,8 +16,8 @@
|
||||
/* ==================== 全局基础样式 ==================== */
|
||||
:root {
|
||||
/* Sidebar 宽度变量 */
|
||||
--sidebar-width: 180px;
|
||||
--sidebar-width-collapsed: 60px;
|
||||
--sidebar-width: 216px;
|
||||
--sidebar-width-collapsed: 64px;
|
||||
--sidebar-current-width: var(--sidebar-width);
|
||||
|
||||
/* 统一配色变量 - 亮色模式 */
|
||||
@@ -189,6 +189,51 @@ code {
|
||||
overflow-y: auto;
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
padding: 4px 12px 8px;
|
||||
}
|
||||
|
||||
.sidebar-nav .ant-menu-item-group + .ant-menu-item-group {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.sidebar-nav .ant-menu-item-group-list {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sidebar-nav .ant-menu-item,
|
||||
.sidebar-nav .ant-menu-submenu-title {
|
||||
width: 100%;
|
||||
height: 46px;
|
||||
line-height: 46px;
|
||||
margin: 0 0 6px;
|
||||
padding-inline: 12px !important;
|
||||
border-radius: 8px;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.sidebar-nav .ant-menu-item-icon.sidebar-icon-container {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin-right: 0;
|
||||
color: var(--ui-color-text-1);
|
||||
}
|
||||
|
||||
.sidebar-nav .sidebar-icon-container svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.sidebar-nav .ant-menu-item-selected {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.sidebar-nav.ant-menu-inline-collapsed {
|
||||
padding-inline: 8px;
|
||||
}
|
||||
|
||||
.sidebar-nav.ant-menu-inline-collapsed .ant-menu-item,
|
||||
.sidebar-nav.ant-menu-inline-collapsed .ant-menu-submenu-title {
|
||||
padding-inline: 9px !important;
|
||||
}
|
||||
|
||||
.sidebar-nav::-webkit-scrollbar {
|
||||
@@ -237,20 +282,44 @@ code {
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
/* 分割线样式 */
|
||||
.sidebar-divider {
|
||||
margin: 4px 8px;
|
||||
opacity: 0.15;
|
||||
/* 分组标签样式 */
|
||||
.sidebar-nav .ant-menu-item-group-title {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* 分组标签样式 */
|
||||
.sidebar-group-label {
|
||||
padding: 4px 15px 8px;
|
||||
.sidebar-group-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
margin-bottom: 4px;
|
||||
padding: 4px 8px;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: var(--ui-color-text-2);
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
line-height: 16px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
opacity: 0.8;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sidebar-group-toggle:hover {
|
||||
background: var(--ui-color-fill-0);
|
||||
color: var(--ui-color-text-1);
|
||||
}
|
||||
|
||||
.sidebar-group-toggle:focus-visible {
|
||||
outline: 2px solid var(--ui-color-primary);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.sidebar-group-toggle svg {
|
||||
flex-shrink: 0;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
/* 底部折叠按钮 */
|
||||
@@ -286,11 +355,6 @@ code {
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
/* 侧边栏区域容器 */
|
||||
.sidebar-section {
|
||||
padding-top: 12px;
|
||||
}
|
||||
|
||||
/* ==================== 聊天界面样式 ==================== */
|
||||
|
||||
/* 用户消息气泡样式 - 主题渐变 */
|
||||
@@ -454,7 +518,7 @@ code {
|
||||
|
||||
/* 深色模式下的筛选弹窗 */
|
||||
|
||||
/* ==================== 编辑令牌弹窗 ==================== */
|
||||
/* ==================== 编辑密钥弹窗 ==================== */
|
||||
|
||||
/* ==================== 协议预览弹窗(服务协议/隐私政策) ==================== */
|
||||
|
||||
@@ -1190,9 +1254,9 @@ html.dark .model-select-dropdown {
|
||||
|
||||
/* ==================== 注册/登录表单紧凑样式 ==================== */
|
||||
|
||||
/* ==================== 系统访问令牌 Input 深色模式优化 ==================== */
|
||||
/* ==================== 系统访问密钥 Input 深色模式优化 ==================== */
|
||||
|
||||
/* 深色模式下的系统令牌输入框 */
|
||||
/* 深色模式下的系统密钥输入框 */
|
||||
|
||||
/* 前缀图标颜色 */
|
||||
|
||||
@@ -1307,7 +1371,7 @@ body[theme-mode='dark'] .app-card {
|
||||
* 中性可读正文,圆角与全站统一。
|
||||
* ==================================================================== */
|
||||
/* 表头/单元格精修 —— ⚠️ 同样只作用域到 .app-card 内的表格(与上面透明规则一致)。
|
||||
* 故意不全局:后台数据表(渠道/用户/模型/兑换码/秘钥等)大量自带列渲染与表头样式,
|
||||
* 故意不全局:后台数据表(渠道/用户/模型/兑换码/密钥等)大量自带列渲染与表头样式,
|
||||
* 全局 !important 会盖掉它们的设计意图。仅用户端日志表(已用 .app-card 包裹)吃这套。 */
|
||||
/* 表头:极淡冷调底(跟品牌色 4%)+ 克制细线 + 次级文字色 —— 云控制台轻表头 */
|
||||
/* ⚠️ 例外:固定表头列同样需不透明遮罩 —— 同色相但叠在不透明 surface-card 上
|
||||
|
||||
@@ -33,6 +33,7 @@ import './styles/org.css';
|
||||
import './styles/prototype.css';
|
||||
import './styles/user-center.css';
|
||||
import './styles/org-page.css';
|
||||
import './styles/center-layout.css';
|
||||
import { applyThemeFromCache } from './helpers/theme';
|
||||
import { installChunkReloadHandlers } from './helpers/chunkReload';
|
||||
import ChunkErrorBoundary from './components/common/ChunkErrorBoundary';
|
||||
|
||||
@@ -214,7 +214,7 @@ const gatewayReasonHints = [
|
||||
],
|
||||
[
|
||||
/额度|quota|insufficient[_ ]?(balance|credit|quota)|欠费/i,
|
||||
'账户或令牌额度不足,请充值后重试。',
|
||||
'账户或密钥额度不足,请充值后重试。',
|
||||
],
|
||||
[
|
||||
/rate.?limit|too many requests|429|请求过于频繁/i,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,7 @@
|
||||
|
||||
底部功能区:
|
||||
|
||||
- ✅ 秘钥管理(复用令牌管理)
|
||||
- ✅ 密钥管理(复用密钥管理)
|
||||
|
||||
### 3. 功能组件
|
||||
|
||||
@@ -51,7 +51,7 @@ web/src/pages/ExperienceCenter/
|
||||
├── TextModel.jsx # 大模型体验(复用Playground)
|
||||
├── ImageGeneration.jsx # 语音合成(占位)
|
||||
├── VideoGeneration.jsx # 视频生成(占位)
|
||||
└── KeyManagement.jsx # 秘钥管理(复用Token)
|
||||
└── KeyManagement.jsx # 密钥管理(复用Token)
|
||||
```
|
||||
|
||||
## 访问方式
|
||||
|
||||
@@ -181,7 +181,7 @@ const ExperienceCenter = () => {
|
||||
{/* 统一页面背景层 —— 除 text-model 外,ExperienceCenter 是其子页面的唯一背景来源,
|
||||
* 子组件不再各自渲染背景,避免双层叠加。
|
||||
* text-model 特例:TextModel 自带 via-white 亮底保证聊天可读性,由其自身渲染,此处跳过。
|
||||
* 沉浸式生成页(视频/图片)用 rich 大光球,秘钥管理(Token 列表)用 subtle。 */}
|
||||
* 沉浸式生成页(视频/图片)用 rich 大光球,密钥管理(Token 列表)用 subtle。 */}
|
||||
{!isTextModel && (
|
||||
<PageBackground
|
||||
variant={isVideoGeneration || isImageGeneration ? 'rich' : 'subtle'}
|
||||
|
||||
@@ -284,7 +284,7 @@ const Home = () => {
|
||||
},
|
||||
{
|
||||
icon: <Key size={28} className='text-rose-400' />,
|
||||
title: t('令牌管理'),
|
||||
title: t('密钥管理'),
|
||||
desc: t('精细化的 API Key 权限控制与额度限制'),
|
||||
},
|
||||
{
|
||||
|
||||
@@ -81,7 +81,7 @@ const COLUMN_WIDTHS = {
|
||||
// 列设置:只控制本页表格列的显示,不持久化、不改请求。
|
||||
const COLUMN_OPTIONS = [
|
||||
{ value: 'name', label: '名称' },
|
||||
{ value: 'key', label: '令牌' },
|
||||
{ value: 'key', label: '密钥' },
|
||||
{ value: 'group', label: '分组' },
|
||||
{ value: 'status', label: '状态' },
|
||||
{ value: 'expired_time', label: '过期时间' },
|
||||
@@ -117,11 +117,11 @@ const KeyTable = ({
|
||||
key: 'name',
|
||||
dataIndex: 'name',
|
||||
render: (name) => (
|
||||
<span className='km-name'>{name || t('未命名令牌')}</span>
|
||||
<span className='km-name'>{name || t('未命名密钥')}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('令牌'),
|
||||
title: t('密钥'),
|
||||
key: 'key',
|
||||
render: (_, token) => {
|
||||
const shown = !!showKeys[token.id];
|
||||
@@ -130,22 +130,22 @@ const KeyTable = ({
|
||||
<code className='km-key-code'>
|
||||
sk-{shown ? token.key : KEY_MASK}
|
||||
</code>
|
||||
<Tooltip title={shown ? t('隐藏令牌') : t('显示令牌')}>
|
||||
<Tooltip title={shown ? t('隐藏密钥') : t('显示密钥')}>
|
||||
<Button
|
||||
type='text'
|
||||
size='small'
|
||||
aria-label={shown ? t('隐藏令牌') : t('显示令牌')}
|
||||
aria-label={shown ? t('隐藏密钥') : t('显示密钥')}
|
||||
aria-pressed={shown}
|
||||
icon={shown ? <EyeOff size={16} /> : <Eye size={16} />}
|
||||
onClick={() => onToggleShowKey(token.id)}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title={t('复制令牌')}>
|
||||
<Tooltip title={t('复制密钥')}>
|
||||
<Button
|
||||
type='text'
|
||||
size='small'
|
||||
className='km-copy-btn tour-copy-btn'
|
||||
aria-label={t('复制令牌')}
|
||||
aria-label={t('复制密钥')}
|
||||
icon={<Copy size={16} />}
|
||||
onClick={() => onCopy('sk-' + token.key)}
|
||||
/>
|
||||
@@ -346,12 +346,12 @@ const ModelsDrawer = ({ visible, onClose, token, t }) => {
|
||||
const loadModels = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
// 如果秘钥有模型限制,使用限制的模型列表
|
||||
// 如果密钥有模型限制,使用限制的模型列表
|
||||
if (token.model_limits_enabled && token.model_limits) {
|
||||
const limitedModels = token.model_limits.split(',').filter(Boolean);
|
||||
setModels(limitedModels);
|
||||
} else {
|
||||
// 否则获取该秘钥所属分组下的可用模型
|
||||
// 否则获取该密钥所属分组下的可用模型
|
||||
const groupValue = token.group || token.groups;
|
||||
// 如果分组为 auto 或空,获取用户所有分组的模型
|
||||
const apiUrl =
|
||||
@@ -401,16 +401,17 @@ const ModelsDrawer = ({ visible, onClose, token, t }) => {
|
||||
title={t('可用模型列表')}
|
||||
open={visible}
|
||||
onClose={onClose}
|
||||
maskClosable
|
||||
placement='right'
|
||||
width={440}
|
||||
rootClassName='km-models-drawer'
|
||||
>
|
||||
<dl className='km-models-info'>
|
||||
<dt>{t('令牌名称')}</dt>
|
||||
<dd>{token?.name || t('未命名令牌')}</dd>
|
||||
<dt>{t('密钥名称')}</dt>
|
||||
<dd>{token?.name || t('未命名密钥')}</dd>
|
||||
{token?.group ? (
|
||||
<>
|
||||
<dt>{t('令牌分组')}</dt>
|
||||
<dt>{t('密钥分组')}</dt>
|
||||
<dd>{token.group === 'auto' ? t('智能熔断') : token.group}</dd>
|
||||
</>
|
||||
) : null}
|
||||
@@ -501,11 +502,11 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
t: originalT,
|
||||
} = tokensData;
|
||||
|
||||
// 设计图统一称“密钥”:沿用原 令牌 文案键,仅替换显示词。
|
||||
// 设计图统一称“密钥”:沿用原 密钥 文案键,仅替换显示词。
|
||||
const t = (key, options) => {
|
||||
const result = originalT(key, options);
|
||||
return typeof result === 'string'
|
||||
? result.replace(/令牌|秘钥/g, '密钥')
|
||||
? result.replace(/密钥|密钥/g, '密钥')
|
||||
: result;
|
||||
};
|
||||
|
||||
@@ -525,23 +526,23 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
userState?.user?.group,
|
||||
);
|
||||
|
||||
// 判断是否有秘钥
|
||||
// 判断是否有密钥
|
||||
const hasKeys = tokens.length > 0;
|
||||
|
||||
// 新手引导步骤 - 根据是否有秘钥动态调整
|
||||
// 新手引导步骤 - 根据是否有密钥动态调整
|
||||
const tourSteps = hasKeys
|
||||
? [
|
||||
// 有秘钥时:完整引导
|
||||
// 有密钥时:完整引导
|
||||
{
|
||||
target: '.tour-create-btn',
|
||||
content: (
|
||||
<div>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<span className='text-lg'>✨</span>
|
||||
<span className='font-semibold'>{t('创建秘钥')}</span>
|
||||
<span className='font-semibold'>{t('创建密钥')}</span>
|
||||
</div>
|
||||
<div className='text-sm text-gray-600 dark:text-gray-300'>
|
||||
{t('点击这里创建新秘钥,设置名称和使用额度')}
|
||||
{t('点击这里创建新密钥,设置名称和使用额度')}
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -555,13 +556,13 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
<div>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<span className='text-lg'>📋</span>
|
||||
<span className='font-semibold'>{t('秘钥卡片')}</span>
|
||||
<span className='font-semibold'>{t('密钥卡片')}</span>
|
||||
</div>
|
||||
<div className='text-sm text-gray-600 dark:text-gray-300'>
|
||||
{t('每张卡片展示秘钥的状态、名称和剩余额度')}
|
||||
{t('每张卡片展示密钥的状态、名称和剩余额度')}
|
||||
</div>
|
||||
<div className='mt-2 text-xs text-gray-400'>
|
||||
💡 {t('绿色状态点表示秘钥已启用')}
|
||||
💡 {t('绿色状态点表示密钥已启用')}
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -573,10 +574,10 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
<div>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<span className='text-lg'>📋</span>
|
||||
<span className='font-semibold'>{t('复制秘钥')}</span>
|
||||
<span className='font-semibold'>{t('复制密钥')}</span>
|
||||
</div>
|
||||
<div className='text-sm text-gray-600 dark:text-gray-300'>
|
||||
{t('点击复制完整秘钥(sk-xxx 格式)')}
|
||||
{t('点击复制完整密钥(sk-xxx 格式)')}
|
||||
</div>
|
||||
<div className='mt-2 p-2 bg-gray-100 dark:bg-neutral-800 rounded text-xs font-mono'>
|
||||
sk-xxxxxxxxxxxxxxxx
|
||||
@@ -592,10 +593,10 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
<div>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<span className='text-lg'>⚙️</span>
|
||||
<span className='font-semibold'>{t('管理秘钥')}</span>
|
||||
<span className='font-semibold'>{t('管理密钥')}</span>
|
||||
</div>
|
||||
<div className='text-sm text-gray-600 dark:text-gray-300'>
|
||||
{t('编辑秘钥名称、额度、过期时间等设置')}
|
||||
{t('编辑密钥名称、额度、过期时间等设置')}
|
||||
</div>
|
||||
<div className='mt-3 text-xs text-gray-400'>
|
||||
💡 {t('点击右上角问号可随时重新查看引导')}
|
||||
@@ -607,7 +608,7 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
},
|
||||
]
|
||||
: [
|
||||
// 没有秘钥时:简化引导,只显示创建按钮
|
||||
// 没有密钥时:简化引导,只显示创建按钮
|
||||
{
|
||||
target: '.tour-create-btn',
|
||||
content: (
|
||||
@@ -615,14 +616,14 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<span className='text-lg'>🚀</span>
|
||||
<span className='font-semibold'>
|
||||
{t('开始创建您的第一个秘钥')}
|
||||
{t('开始创建您的第一个密钥')}
|
||||
</span>
|
||||
</div>
|
||||
<div className='text-sm text-gray-600 dark:text-gray-300'>
|
||||
{t('点击这里创建秘钥,创建后可用于调用 API 服务')}
|
||||
{t('点击这里创建密钥,创建后可用于调用 API 服务')}
|
||||
</div>
|
||||
<div className='mt-3 p-2 bg-brand/5 dark:bg-brand-deep/20 rounded-lg text-xs text-brand-deep dark:text-brand-from'>
|
||||
💡 {t('创建秘钥后,可再次点击右上角问号查看完整操作指引')}
|
||||
💡 {t('创建密钥后,可再次点击右上角问号查看完整操作指引')}
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -668,7 +669,7 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
const action = token.status === 1 ? 'disable' : 'enable';
|
||||
Modal.confirm({
|
||||
title: t(
|
||||
action === 'disable' ? '确定要禁用此秘钥吗?' : '确定要启用此秘钥吗?',
|
||||
action === 'disable' ? '确定要禁用此密钥吗?' : '确定要启用此密钥吗?',
|
||||
),
|
||||
onOk: () => manageToken(token.id, action, token),
|
||||
});
|
||||
@@ -676,7 +677,7 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
|
||||
const handleDelete = (token) => {
|
||||
Modal.confirm({
|
||||
title: t('确定要删除此秘钥吗?'),
|
||||
title: t('确定要删除此密钥吗?'),
|
||||
content: t('删除后将无法恢复'),
|
||||
okType: 'danger',
|
||||
onOk: async () => {
|
||||
@@ -744,6 +745,7 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
showCloseButton
|
||||
hideBackButton={false}
|
||||
disableCloseOnEsc={false}
|
||||
disableScrollParentFix
|
||||
disableOverlayClose={false}
|
||||
scrollToFirstStep
|
||||
scrollOffset={100}
|
||||
@@ -848,7 +850,7 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
<div className='km-content uc-page relative'>
|
||||
<UserCenterPageHeader
|
||||
title={t('密钥管理')}
|
||||
subtitle={t('管理模型调用的访问令牌')}
|
||||
subtitle={t('管理模型调用的访问密钥')}
|
||||
extra={
|
||||
<>
|
||||
{tutorialButtonVisible ? (
|
||||
@@ -877,13 +879,13 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
<div className='km-panels'>
|
||||
<Card className='km-card km-search-card tour-search-input'>
|
||||
<label className='km-search-label' htmlFor='km-search-input'>
|
||||
{t('令牌查询')}
|
||||
{t('密钥查询')}
|
||||
</label>
|
||||
<div className='km-search-row'>
|
||||
<Input
|
||||
id='km-search-input'
|
||||
className='km-search-input'
|
||||
placeholder={t('搜索令牌名称、Key 或分组')}
|
||||
placeholder={t('搜索密钥名称、Key 或分组')}
|
||||
value={searchValue}
|
||||
onChange={(event) => setSearchValue(event.target.value)}
|
||||
onPressEnter={() => setSearchValue(searchValue)}
|
||||
@@ -902,14 +904,14 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
|
||||
<Card className='km-card km-list-card'>
|
||||
<div className='km-list-head'>
|
||||
<h2>{t('令牌列表')}</h2>
|
||||
<h2>{t('密钥列表')}</h2>
|
||||
<div className='km-list-actions'>
|
||||
<Button
|
||||
type='link'
|
||||
className='km-contact-link'
|
||||
onClick={openCustomerService}
|
||||
>
|
||||
{t('创建令牌后不知道怎么用?联系客服')}
|
||||
{t('创建密钥后不知道怎么用?联系客服')}
|
||||
</Button>
|
||||
<Button
|
||||
type='primary'
|
||||
@@ -917,7 +919,7 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
className='tour-create-btn'
|
||||
onClick={handleCreate}
|
||||
>
|
||||
{t('创建令牌')}
|
||||
{t('创建密钥')}
|
||||
</Button>
|
||||
<Popover
|
||||
trigger='click'
|
||||
@@ -944,8 +946,8 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={
|
||||
searchValue
|
||||
? t('未找到匹配的令牌')
|
||||
: t('暂无令牌,点击上方按钮创建')
|
||||
? t('未找到匹配的密钥')
|
||||
: t('暂无密钥,点击上方按钮创建')
|
||||
}
|
||||
/>
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ html.dark .km-page {
|
||||
.km-panels {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
gap: var(--uc-layout-gap);
|
||||
}
|
||||
|
||||
/* 卡片:查询卡为 Ant Design 默认描边;列表卡描边 #e6e9ef + 极浅投影(设计图可见),圆角 10px,内边距 24px */
|
||||
|
||||
+137
-121
@@ -20,20 +20,13 @@ import React, { useEffect, useState } from 'react';
|
||||
import { getQuotaPerUnit } from '../../helpers';
|
||||
import { timestamp2string } from '../../helpers/utils';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { RefreshCw, ScrollText } from 'lucide-react';
|
||||
import {
|
||||
Table,
|
||||
Select,
|
||||
Button,
|
||||
Tag,
|
||||
Tooltip,
|
||||
Tabs,
|
||||
TabPane,
|
||||
} from '@/components/ui';
|
||||
import { RefreshCw, ScrollText, Search } from 'lucide-react';
|
||||
import { Form as AntForm, Tabs as AntTabs } from 'antd';
|
||||
import { Table, Select, Button, Tag, Tooltip } from '@/components/ui';
|
||||
import { API } from '../../helpers/api';
|
||||
import { useOrgAuditLogs } from '../../hooks/org/useOrgData';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import { OrgFilterCard, OrgListCard } from './components/OrgListCard';
|
||||
import OrgStateBlock from './components/OrgStateBlock';
|
||||
import OrgPromptRecords from './OrgPromptRecords';
|
||||
import {
|
||||
@@ -62,14 +55,14 @@ const memberStatusMap = {
|
||||
};
|
||||
|
||||
const targetTypeLabels = {
|
||||
token: '令牌',
|
||||
token: '密钥',
|
||||
member: '成员',
|
||||
organization: '企业',
|
||||
invitation: '邀请',
|
||||
};
|
||||
|
||||
const targetTypeColors = {
|
||||
token: 'violet',
|
||||
token: 'purple',
|
||||
member: 'blue',
|
||||
organization: 'green',
|
||||
invitation: 'orange',
|
||||
@@ -95,9 +88,9 @@ const actionConfig = {
|
||||
accept_invitation: { label: '接受邀请', color: 'green' },
|
||||
cancel_invitation: { label: '取消邀请', color: 'grey' },
|
||||
|
||||
create_token: { label: '创建令牌', color: 'green' },
|
||||
update_token: { label: '更新令牌', color: 'blue' },
|
||||
delete_token: { label: '删除令牌', color: 'red' },
|
||||
create_token: { label: '创建密钥', color: 'green' },
|
||||
update_token: { label: '更新密钥', color: 'blue' },
|
||||
delete_token: { label: '删除密钥', color: 'red' },
|
||||
|
||||
admin_create_org: { label: '管理员创建企业', color: 'cyan' },
|
||||
admin_update_org: { label: '管理员更新企业', color: 'cyan' },
|
||||
@@ -134,7 +127,7 @@ const detailKeyLabels = {
|
||||
allow_ips: 'IP白名单',
|
||||
group: '分组',
|
||||
max_members: '最大成员数',
|
||||
max_tokens: '最大令牌数',
|
||||
max_tokens: '最大密钥数',
|
||||
default_member_quota: '新成员默认额度上限',
|
||||
cycle_quota: '周期额度',
|
||||
cycle_quota_delta: '周期额度增量',
|
||||
@@ -289,10 +282,10 @@ const OrgAudit = ({ orgId }) => {
|
||||
{ value: 'update_member_status', label: t('更新状态') },
|
||||
{ value: 'update_member_model_limits', label: t('更新模型限制') },
|
||||
{ value: 'update_member_admin_permissions', label: t('更新管理员权限') },
|
||||
// 令牌操作
|
||||
{ value: 'create_token', label: t('创建令牌') },
|
||||
{ value: 'update_token', label: t('更新令牌') },
|
||||
{ value: 'delete_token', label: t('删除令牌') },
|
||||
// 密钥操作
|
||||
{ value: 'create_token', label: t('创建密钥') },
|
||||
{ value: 'update_token', label: t('更新密钥') },
|
||||
{ value: 'delete_token', label: t('删除密钥') },
|
||||
// 管理员操作
|
||||
{ value: 'admin_create_org', label: t('管理员创建企业') },
|
||||
{ value: 'admin_update_org', label: t('管理员更新企业') },
|
||||
@@ -301,24 +294,21 @@ const OrgAudit = ({ orgId }) => {
|
||||
{ value: 'admin_update_status', label: t('管理员更新状态') },
|
||||
];
|
||||
|
||||
// 列宽与渲染对齐原型 EnterpriseAudit(130/170/110/500/150,scroll.x 1140);标签为无边框 filled
|
||||
const columns = [
|
||||
{
|
||||
title: t('操作者'),
|
||||
dataIndex: 'operator_name',
|
||||
width: 120,
|
||||
render: (name, record) => (
|
||||
<span className='text-sm text-gray-700 dark:text-gray-300 truncate'>
|
||||
{name || `User#${record.operator_id}`}
|
||||
</span>
|
||||
),
|
||||
width: 130,
|
||||
render: (name, record) => name || `User#${record.operator_id}`,
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
title: t('操作类型'),
|
||||
dataIndex: 'action',
|
||||
width: 170,
|
||||
render: (action, record) => {
|
||||
const config = actionConfig[action];
|
||||
if (!config) return <Tag size='small'>{action}</Tag>;
|
||||
if (!config) return <Tag bordered={false}>{action}</Tag>;
|
||||
// 建企业时配的初始额度复用 admin_adjust_quota(供预警取"加额时刻"),
|
||||
// 但它不是二次人工调额,按 detail.source 区分展示
|
||||
let label = config.label;
|
||||
@@ -333,7 +323,7 @@ const OrgAudit = ({ orgId }) => {
|
||||
}
|
||||
}
|
||||
return (
|
||||
<Tag size='small' color={config.color} type='light'>
|
||||
<Tag color={config.color} bordered={false}>
|
||||
{t(label)}
|
||||
</Tag>
|
||||
);
|
||||
@@ -342,9 +332,9 @@ const OrgAudit = ({ orgId }) => {
|
||||
{
|
||||
title: t('目标类型'),
|
||||
dataIndex: 'target_type',
|
||||
width: 90,
|
||||
width: 110,
|
||||
render: (type) => (
|
||||
<Tag size='small' color={targetTypeColors[type] || 'grey'} type='ghost'>
|
||||
<Tag color={targetTypeColors[type] || 'grey'} bordered={false}>
|
||||
{t(targetTypeLabels[type] || type)}
|
||||
</Tag>
|
||||
),
|
||||
@@ -352,49 +342,43 @@ const OrgAudit = ({ orgId }) => {
|
||||
{
|
||||
title: t('详情'),
|
||||
dataIndex: 'detail',
|
||||
width: 500,
|
||||
render: (detail, record) => {
|
||||
if (!detail)
|
||||
return <span className='text-gray-400 dark:text-gray-500'>-</span>;
|
||||
if (!detail) return <span className='oc-muted'>-</span>;
|
||||
let text = detail;
|
||||
try {
|
||||
const obj = JSON.parse(detail);
|
||||
const text = formatDetail(record.action, obj, t, quotaPerUnit);
|
||||
if (text.length > 60) {
|
||||
return (
|
||||
<Tooltip
|
||||
content={text}
|
||||
position='topLeft'
|
||||
style={{ maxWidth: 400 }}
|
||||
>
|
||||
<span className='text-xs text-gray-600 dark:text-gray-400 cursor-default truncate block max-w-xs'>
|
||||
{text}
|
||||
</span>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<span className='text-xs text-gray-600 dark:text-gray-400'>
|
||||
{text}
|
||||
</span>
|
||||
text = formatDetail(
|
||||
record.action,
|
||||
JSON.parse(detail),
|
||||
t,
|
||||
quotaPerUnit,
|
||||
);
|
||||
} catch {
|
||||
return (
|
||||
<span className='text-xs text-gray-600 dark:text-gray-400'>
|
||||
{detail}
|
||||
</span>
|
||||
);
|
||||
// detail 非 JSON 时原样展示
|
||||
}
|
||||
return (
|
||||
<Tooltip content={text} position='topLeft' style={{ maxWidth: 400 }}>
|
||||
<span className='oc-audit-detail' tabIndex={0}>
|
||||
{text}
|
||||
</span>
|
||||
</Tooltip>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('时间'),
|
||||
dataIndex: 'created_at',
|
||||
width: 140,
|
||||
width: 150,
|
||||
render: (v) =>
|
||||
v ? (
|
||||
<Tooltip content={new Date(v * 1000).toLocaleString('zh-CN')}>
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400 cursor-default'>
|
||||
<time
|
||||
className='oc-audit-time'
|
||||
dateTime={new Date(v * 1000).toISOString()}
|
||||
tabIndex={0}
|
||||
>
|
||||
{formatRelativeTime(v, t)}
|
||||
</span>
|
||||
</time>
|
||||
</Tooltip>
|
||||
) : (
|
||||
'-'
|
||||
@@ -402,69 +386,101 @@ const OrgAudit = ({ orgId }) => {
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className='uc-page'>
|
||||
<OrgPageHeader
|
||||
title={t('审计日志')}
|
||||
subtitle={t('查看企业操作记录')}
|
||||
actions={
|
||||
activeTab === 'operations' ? (
|
||||
<>
|
||||
<Button
|
||||
icon={<RefreshCw size={14} />}
|
||||
onClick={() => fetch(page, 20, actionFilter)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
<Select
|
||||
value={actionFilter}
|
||||
onChange={(v) => {
|
||||
setActionFilter(v);
|
||||
setPage(1);
|
||||
}}
|
||||
optionList={actionOptions}
|
||||
style={{ width: 200 }}
|
||||
placeholder={t('筛选操作')}
|
||||
filter
|
||||
/>
|
||||
</>
|
||||
) : null
|
||||
}
|
||||
/>
|
||||
const refresh = () => fetch(page, 20, actionFilter);
|
||||
// 选择即筛选(原交互):与原页头 Select 的 onChange 相同
|
||||
const applyAction = (v) => {
|
||||
setActionFilter(v ?? '');
|
||||
setPage(1);
|
||||
};
|
||||
|
||||
<Tabs
|
||||
type='line'
|
||||
const operations = (
|
||||
<>
|
||||
<OrgFilterCard
|
||||
className='oc-audit-filter'
|
||||
actions={
|
||||
<>
|
||||
{/* 重置 = 选择“全部操作”;搜索 = 以当前筛选重新查询(同“刷新”) */}
|
||||
<Button onClick={() => applyAction('')}>{t('重置')}</Button>
|
||||
<Button
|
||||
type='primary'
|
||||
icon={<Search size={16} />}
|
||||
onClick={refresh}
|
||||
>
|
||||
{t('搜索')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('操作类型')}>
|
||||
<Select
|
||||
value={actionFilter}
|
||||
onChange={applyAction}
|
||||
optionList={actionOptions}
|
||||
style={{ width: '100%' }}
|
||||
placeholder={t('全部操作')}
|
||||
filter
|
||||
/>
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
</OrgFilterCard>
|
||||
|
||||
<OrgListCard
|
||||
title={t('操作记录')}
|
||||
tools={
|
||||
<Button
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={refresh}
|
||||
loading={loading}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={logs}
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1140 }}
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
pageSize: 20,
|
||||
showSizeChanger: false,
|
||||
total,
|
||||
onPageChange: setPage,
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
empty={<OrgStateBlock icon={ScrollText} title={t('暂无审计日志')} />}
|
||||
/>
|
||||
</OrgListCard>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='uc-page oc-page'>
|
||||
<OrgPageHeader title={t('审计日志')} subtitle={t('查看企业操作记录')} />
|
||||
|
||||
{/* 原型 platform-list-tabs;“提示词记录”页签沿用原 feature flag + 权限显隐 */}
|
||||
<AntTabs
|
||||
className='oc-list-tabs'
|
||||
activeKey={activeTab}
|
||||
onChange={setActiveTab}
|
||||
className='mt-2'
|
||||
>
|
||||
<TabPane tab={t('操作审计')} itemKey='operations'>
|
||||
<OrgPanel bodyClassName='overflow-x-auto' className='mt-4'>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={logs}
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
pageSize: 20,
|
||||
total,
|
||||
onPageChange: setPage,
|
||||
}}
|
||||
empty={
|
||||
<OrgStateBlock icon={ScrollText} title={t('暂无审计日志')} />
|
||||
}
|
||||
/>
|
||||
</OrgPanel>
|
||||
</TabPane>
|
||||
|
||||
{promptArchiveEnabled && canViewPromptRecords && (
|
||||
<TabPane tab={t('提示词记录')} itemKey='prompt-records'>
|
||||
<OrgPromptRecords key={orgId} orgId={orgId} />
|
||||
</TabPane>
|
||||
)}
|
||||
</Tabs>
|
||||
items={[
|
||||
{ key: 'operations', label: t('操作审计'), children: operations },
|
||||
...(promptArchiveEnabled && canViewPromptRecords
|
||||
? [
|
||||
{
|
||||
key: 'prompt-records',
|
||||
label: t('提示词记录'),
|
||||
// 原 Tabs 预渲染全部页签(lazyRender=false),保持提示词记录随页面挂载、请求时机不变
|
||||
forceRender: true,
|
||||
children: <OrgPromptRecords key={orgId} orgId={orgId} />,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -16,8 +16,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Switch } from 'antd';
|
||||
import {
|
||||
Table,
|
||||
Button,
|
||||
@@ -25,10 +32,9 @@ import {
|
||||
Toast,
|
||||
Tag,
|
||||
Progress,
|
||||
Banner,
|
||||
Popconfirm,
|
||||
} from '@/components/ui';
|
||||
import { RefreshCw, Plus, Pencil, Trash2 } from 'lucide-react';
|
||||
import { RefreshCw, Plus } from 'lucide-react';
|
||||
import { API } from '../../helpers/api';
|
||||
import { showError } from '../../helpers';
|
||||
import {
|
||||
@@ -38,7 +44,7 @@ import {
|
||||
getQuotaInputUnit,
|
||||
} from '../../helpers/render';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
|
||||
const getOrgHeaders = (orgId) => ({ 'X-Org-Id': String(orgId) });
|
||||
@@ -48,7 +54,7 @@ const subjectTypeLabel = (t, st) =>
|
||||
department: t('部门'),
|
||||
project: t('项目'),
|
||||
member: t('成员'),
|
||||
token: t('令牌'),
|
||||
token: t('密钥'),
|
||||
org: t('企业'),
|
||||
})[st] || st;
|
||||
|
||||
@@ -65,11 +71,9 @@ const cycleLabel = (t, c) =>
|
||||
const OrgBudgets = ({ orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
const [list, setList] = useState([]);
|
||||
// null=未知(接口未返回该字段的旧后端),true/false=预算 cap 是否真正在扣费链路生效
|
||||
const [enforcementEnabled, setEnforcementEnabled] = useState(null);
|
||||
// 未生效的细分原因:平台级引擎急停(engine=false) vs 企业未开「预算实时拦截」
|
||||
const [engineEnabled, setEngineEnabled] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [updatingBudgetId, setUpdatingBudgetId] = useState(null);
|
||||
const updatingBudgetRef = useRef(false);
|
||||
const [depts, setDepts] = useState([]);
|
||||
const [projects, setProjects] = useState([]);
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
@@ -96,29 +100,17 @@ const OrgBudgets = ({ orgId }) => {
|
||||
API.get('/api/org/project', { headers: getOrgHeaders(orgId) }),
|
||||
]);
|
||||
if (b.data.success) {
|
||||
// 新后端返回 {items, enforcement_enabled, engine_enabled};兼容旧后端直接返回数组
|
||||
// 新后端返回 {items, enforcement_enabled, engine_enabled};兼容旧后端直接返回数组。
|
||||
// enforcement/engine 两个字段原只驱动表格上方旧提示栏,提示栏按原型移除后不再读取。
|
||||
const payload = b.data.data;
|
||||
if (Array.isArray(payload)) {
|
||||
setList(payload || []);
|
||||
setEnforcementEnabled(null);
|
||||
setEngineEnabled(null);
|
||||
} else {
|
||||
setList(payload?.items || []);
|
||||
setEnforcementEnabled(payload?.enforcement_enabled ?? null);
|
||||
setEngineEnabled(payload?.engine_enabled ?? null);
|
||||
}
|
||||
setList(Array.isArray(payload) ? payload || [] : payload?.items || []);
|
||||
} else {
|
||||
showError(b.data.message);
|
||||
// 拉取失败回到「未知」,避免 Banner 停留在陈旧状态
|
||||
setEnforcementEnabled(null);
|
||||
setEngineEnabled(null);
|
||||
}
|
||||
if (d.data.success) setDepts(d.data.data || []);
|
||||
if (p.data.success) setProjects(p.data.data || []);
|
||||
} catch (err) {
|
||||
showError(err.message);
|
||||
setEnforcementEnabled(null);
|
||||
setEngineEnabled(null);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -128,7 +120,7 @@ const OrgBudgets = ({ orgId }) => {
|
||||
fetchAll();
|
||||
}, [fetchAll]);
|
||||
|
||||
// 主体名称与存在性优先取后端 subject_* 字段(覆盖成员/令牌,且能区分「已删除」与「已停用」);
|
||||
// 主体名称与存在性优先取后端 subject_* 字段(覆盖成员/密钥,且能区分「已删除」与「已停用」);
|
||||
// 旧后端未返回时回落到本地部门/项目列表匹配。
|
||||
const subjectOf = useCallback(
|
||||
(r) => {
|
||||
@@ -156,7 +148,7 @@ const OrgBudgets = ({ orgId }) => {
|
||||
disabled: p?.status === 2,
|
||||
};
|
||||
}
|
||||
// 旧后端下成员/令牌无从解析,按存在处理,避免误标「已删除」
|
||||
// 旧后端下成员/密钥无从解析,按存在处理,避免误标「已删除」
|
||||
return { name: `#${r.subject_id}`, exists: true, disabled: false };
|
||||
},
|
||||
[depts, projects],
|
||||
@@ -252,6 +244,52 @@ const OrgBudgets = ({ orgId }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleStatusChange = async (record, enabled) => {
|
||||
if (
|
||||
updatingBudgetRef.current ||
|
||||
(record.status === 1) === enabled ||
|
||||
!subjectOf(record).exists
|
||||
)
|
||||
return;
|
||||
updatingBudgetRef.current = true;
|
||||
setUpdatingBudgetId(record.id);
|
||||
try {
|
||||
// Reuse the edit upsert contract with raw quotas, without currency conversion.
|
||||
const res = await API.put(
|
||||
'/api/org/budget',
|
||||
{
|
||||
subject_type: record.subject_type,
|
||||
subject_id: record.subject_id,
|
||||
cycle_type: record.cycle_type,
|
||||
cycle_quota: record.cycle_quota,
|
||||
total_quota: record.total_quota,
|
||||
custom_cycle_days: record.custom_cycle_days || 0,
|
||||
over_limit_action: record.over_limit_action,
|
||||
status: enabled ? 1 : 2,
|
||||
},
|
||||
{ headers: getOrgHeaders(orgId), skipErrorHandler: true },
|
||||
);
|
||||
if (res.data.success) {
|
||||
Toast.success({
|
||||
content: t('状态已更新'),
|
||||
key: `org-budget-status-${orgId}-${record.id}`,
|
||||
});
|
||||
setList((items) =>
|
||||
items.map((item) =>
|
||||
item.id === record.id ? { ...item, status: enabled ? 1 : 2 } : item,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
showError(res.data.message);
|
||||
}
|
||||
} catch (err) {
|
||||
showError(err.message);
|
||||
} finally {
|
||||
updatingBudgetRef.current = false;
|
||||
setUpdatingBudgetId(null);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = async (record) => {
|
||||
try {
|
||||
const res = await API.delete(`/api/org/budget/${record.id}`, {
|
||||
@@ -268,30 +306,32 @@ const OrgBudgets = ({ orgId }) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 列宽与渲染对齐原型 EnterpriseBudget(300/110/260/120/120/130,scroll.x 1040);取值与判定沿用原逻辑
|
||||
const columns = [
|
||||
{
|
||||
title: t('主体'),
|
||||
width: 300,
|
||||
render: (_, r) => {
|
||||
const subj = subjectOf(r);
|
||||
return (
|
||||
<span>
|
||||
<Tag color='blue' size='small'>
|
||||
<div className='oc-budget-subject'>
|
||||
<Tag color='gold' bordered={false}>
|
||||
{subjectTypeLabel(t, r.subject_type)}
|
||||
</Tag>{' '}
|
||||
<span className={subj.exists ? '' : 'text-gray-400 line-through'}>
|
||||
</Tag>
|
||||
<span className={subj.exists ? '' : 'oc-muted line-through'}>
|
||||
{subj.name}
|
||||
</span>{' '}
|
||||
</span>
|
||||
{!subj.exists && (
|
||||
<Tag color='red' size='small'>
|
||||
<Tag color='red' bordered={false}>
|
||||
{t('主体已删除')}
|
||||
</Tag>
|
||||
)}
|
||||
{subj.exists && subj.disabled && (
|
||||
<Tag color='grey' size='small'>
|
||||
<Tag color='grey' bordered={false}>
|
||||
{t('已停用')}
|
||||
</Tag>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -299,31 +339,32 @@ const OrgBudgets = ({ orgId }) => {
|
||||
title: t('周期'),
|
||||
dataIndex: 'cycle_type',
|
||||
render: (v) => cycleLabel(t, v),
|
||||
width: 90,
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
title: t('周期用量 / cap'),
|
||||
width: 220,
|
||||
title: t('周期用量 / 上限'),
|
||||
width: 260,
|
||||
render: (_, r) => {
|
||||
if (!r.cycle_quota)
|
||||
return <span className='text-xs text-gray-400'>{t('不限')}</span>;
|
||||
return <span className='oc-budget-unlimited'>{t('不限')}</span>;
|
||||
const pct = Math.min(
|
||||
100,
|
||||
Math.round((r.used_in_cycle / r.cycle_quota) * 100),
|
||||
);
|
||||
return (
|
||||
<div>
|
||||
<div className='oc-budget-usage'>
|
||||
<Progress
|
||||
percent={pct}
|
||||
size='small'
|
||||
showInfo={false}
|
||||
stroke={pct >= 90 ? 'var(--ui-color-danger)' : undefined}
|
||||
/>
|
||||
<span className='text-xs text-gray-500'>
|
||||
<span>
|
||||
{renderQuota(r.used_in_cycle, 2)}
|
||||
{r.reserved_in_cycle > 0
|
||||
? ` (+${renderQuota(r.reserved_in_cycle, 2)} ${t('预留')})`
|
||||
: ''}
|
||||
{' / '}
|
||||
<i>/</i>
|
||||
{renderQuota(r.cycle_quota, 2)}
|
||||
</span>
|
||||
</div>
|
||||
@@ -333,36 +374,37 @@ const OrgBudgets = ({ orgId }) => {
|
||||
{
|
||||
title: t('超限动作'),
|
||||
dataIndex: 'over_limit_action',
|
||||
// 90px 是按中文两字标签定的,泰语最短的地道说法 "เมื่อเกินขีดจำกัด" 也要 ~150px;
|
||||
// 这一列没有更短的译法,只能让列让位(其余列头已在 kt_overrides_th.json 收敛用词)
|
||||
width: 150,
|
||||
// 原型 120px;表头 nowrap,较长译文(如泰语)由表格自动撑开列宽,不截断
|
||||
width: 120,
|
||||
render: () => t('拦截'),
|
||||
},
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: 80,
|
||||
render: (v) => (
|
||||
<Tag color={v === 1 ? 'green' : 'grey'}>
|
||||
{v === 1 ? t('启用') : t('停用')}
|
||||
</Tag>
|
||||
width: 120,
|
||||
render: (v, record) => (
|
||||
<Switch
|
||||
size='small'
|
||||
checked={v === 1}
|
||||
checkedChildren={t('启用')}
|
||||
unCheckedChildren={t('禁用')}
|
||||
aria-label={`${subjectOf(record).name} ${t('状态')}`}
|
||||
loading={updatingBudgetId === record.id}
|
||||
disabled={updatingBudgetId !== null || !subjectOf(record).exists}
|
||||
onChange={(checked) => handleStatusChange(record, checked)}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 160,
|
||||
width: 130,
|
||||
render: (_, r) => {
|
||||
const subj = subjectOf(r);
|
||||
return (
|
||||
<div className='flex gap-1'>
|
||||
<OrgRowActions>
|
||||
{/* 主体已删除的孤儿行改不了(后端 upsert 会因主体不存在报错),只留删除 */}
|
||||
{subj.exists && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
icon={<Pencil size={14} />}
|
||||
onClick={() => openEdit(r)}
|
||||
>
|
||||
<Button type='link' onClick={() => openEdit(r)}>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
)}
|
||||
@@ -373,31 +415,36 @@ const OrgBudgets = ({ orgId }) => {
|
||||
)}
|
||||
onConfirm={() => handleDelete(r)}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
type='danger'
|
||||
icon={<Trash2 size={14} />}
|
||||
>
|
||||
<Button type='link' danger>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
</OrgRowActions>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className='uc-page'>
|
||||
<div className='uc-page oc-page'>
|
||||
<OrgPageHeader
|
||||
title={t('预算中心')}
|
||||
subtitle={t('部门 / 项目 / 成员的额度上限')}
|
||||
actions={
|
||||
subtitle={t('管理部门、项目与成员的额度上限')}
|
||||
/>
|
||||
|
||||
{/* 原型 .eb-policy 说明条:替换原“预算实时拦截未生效”警告与 cap 说明两条 Banner */}
|
||||
<div className='oc-policy' role='note'>
|
||||
{t(
|
||||
'预算只设置「最多能花多少」的上限,不增加企业真实额度池;提额仅提高上限。',
|
||||
)}
|
||||
</div>
|
||||
|
||||
<OrgListCard
|
||||
title={t('预算列表')}
|
||||
tools={
|
||||
<>
|
||||
<Button
|
||||
theme='light'
|
||||
icon={<RefreshCw size={14} />}
|
||||
icon={<RefreshCw size={16} />}
|
||||
loading={loading}
|
||||
onClick={fetchAll}
|
||||
>
|
||||
@@ -405,51 +452,27 @@ const OrgBudgets = ({ orgId }) => {
|
||||
</Button>
|
||||
<Button
|
||||
theme='solid'
|
||||
icon={<Plus size={14} />}
|
||||
icon={<Plus size={16} />}
|
||||
onClick={openCreate}
|
||||
>
|
||||
{t('配置预算')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
{enforcementEnabled === false && (
|
||||
<Banner
|
||||
type='warning'
|
||||
closeIcon={null}
|
||||
description={
|
||||
engineEnabled === false
|
||||
? t(
|
||||
'预算引擎已被平台全局急停:所有企业的预算拦截与用量统计均暂停,恢复需平台管理员开启系统开关,与本企业配置无关。',
|
||||
)
|
||||
: t(
|
||||
'预算实时拦截当前未生效:这里的配置只会被保存,不会拦截超额调用,也不会累计用量统计。请联系平台管理员开启本企业的「预算实时拦截」功能。',
|
||||
)
|
||||
}
|
||||
className='mb-4'
|
||||
/>
|
||||
)}
|
||||
<Banner
|
||||
type='info'
|
||||
closeIcon={null}
|
||||
description={t(
|
||||
'预算只设置「最多能花多少」的上限(cap),不增加企业真实额度池;提额仅提高上限。',
|
||||
)}
|
||||
className='mb-4'
|
||||
/>
|
||||
|
||||
<OrgPanel padding='p-2'>
|
||||
>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
loading={loading}
|
||||
pagination={false}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1040 }}
|
||||
/>
|
||||
</OrgPanel>
|
||||
</OrgListCard>
|
||||
|
||||
<OrgModal
|
||||
className='oc-dialog oc-budget-dialog'
|
||||
width={560}
|
||||
title={editing ? t('编辑预算') : t('配置预算')}
|
||||
visible={modalVisible}
|
||||
onOk={submit}
|
||||
@@ -459,11 +482,11 @@ const OrgBudgets = ({ orgId }) => {
|
||||
>
|
||||
<Form getFormApi={setFormApi}>
|
||||
{editing ? (
|
||||
<div className='mb-3'>
|
||||
<Tag color='blue' size='small'>
|
||||
<div className='oc-budget-edit-subject'>
|
||||
<Tag color='gold' bordered={false}>
|
||||
{subjectTypeLabel(t, editing.subject_type)}
|
||||
</Tag>{' '}
|
||||
{subjectOf(editing).name}
|
||||
</Tag>
|
||||
<strong>{subjectOf(editing).name}</strong>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
|
||||
@@ -28,28 +28,24 @@ import { timestamp2string } from '../../helpers/utils';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
BarChart2,
|
||||
Users,
|
||||
Key,
|
||||
Wallet,
|
||||
TrendingUp,
|
||||
ArrowRight,
|
||||
ShieldCheck,
|
||||
Crown,
|
||||
Shield,
|
||||
PiggyBank,
|
||||
Flame,
|
||||
Coins,
|
||||
RefreshCw,
|
||||
Search,
|
||||
FileText,
|
||||
CreditCard,
|
||||
Activity,
|
||||
} from 'lucide-react';
|
||||
import {
|
||||
Avatar as AntAvatar,
|
||||
Card as AntCard,
|
||||
Tag as AntTag,
|
||||
Typography,
|
||||
} from 'antd';
|
||||
import {
|
||||
Progress,
|
||||
Table,
|
||||
Tag,
|
||||
Button,
|
||||
DatePicker,
|
||||
Input,
|
||||
@@ -60,14 +56,14 @@ import { useOrgDashboard, useOrgQuota } from '../../hooks/org/useOrgData';
|
||||
import { renderQuota } from '../../helpers/render';
|
||||
import { API, showError } from '../../helpers';
|
||||
import Loading from '../../components/common/ui/Loading';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgBreadcrumb from './components/OrgBreadcrumb';
|
||||
import OrgAnalyticsPanel from './components/OrgAnalyticsPanel';
|
||||
import StatCard from './components/OrgStatCard';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import '../../styles/org-center.css';
|
||||
import OrgSideSheet from './components/OrgSideSheet';
|
||||
import OrgStateBlock from './components/OrgStateBlock';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
import { normalizeSidebarModulesAdmin } from '../../constants/sidebarModules';
|
||||
import { getOrgQuotaAvailability } from './orgQuotaAvailability';
|
||||
|
||||
const getOrgHeaders = (orgId) => ({ 'X-Org-Id': String(orgId) });
|
||||
|
||||
@@ -108,7 +104,7 @@ const isFeatureEnabled = (flags, key) => {
|
||||
// 状态配置
|
||||
const getStatusConfig = (status, t) => {
|
||||
const map = {
|
||||
1: { label: t('正常'), tagLabel: t('运行正常'), color: 'green' },
|
||||
1: { label: t('正常'), tagLabel: t('企业运行正常'), color: 'green' },
|
||||
2: { label: t('冻结'), tagLabel: t('已被冻结'), color: 'red' },
|
||||
3: { label: t('欠费'), tagLabel: t('额度不足'), color: 'orange' },
|
||||
};
|
||||
@@ -363,7 +359,20 @@ const MemberUsageSheet = ({ visible, onClose, member, orgId, t }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
// 原型 .ea-budget-primary strong small:货币符号缩小为独立 small,数值格式仍来自 renderQuota
|
||||
const renderBudgetAmount = (quota) => {
|
||||
const text = String(renderQuota(quota, 2) ?? '');
|
||||
const m = text.match(/^([^\d\-−]+)(.*)$/);
|
||||
if (!m) return text;
|
||||
return (
|
||||
<>
|
||||
<small>{m[1].trim()}</small>
|
||||
{m[2]}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const OrgDashboard = ({ orgId, orgRole, orgName, featureFlags }) => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [statusState] = useContext(StatusContext);
|
||||
@@ -398,140 +407,88 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
{
|
||||
title: t('成员'),
|
||||
dataIndex: 'display_name',
|
||||
width: 200,
|
||||
render: (text, record) => (
|
||||
<div className='flex items-center gap-2.5'>
|
||||
<div className='flex-shrink-0 w-8 h-8 rounded-full bg-brand/10 text-brand flex items-center justify-center text-xs font-semibold'>
|
||||
{(text || record.username || '?').charAt(0).toUpperCase()}
|
||||
</div>
|
||||
<div className='min-w-0'>
|
||||
width: 170,
|
||||
render: (text, record) => {
|
||||
const name = text || record.username;
|
||||
return (
|
||||
<div className='oc-ea-member'>
|
||||
<AntAvatar size={28}>
|
||||
{(name || '?').charAt(0).toUpperCase()}
|
||||
</AntAvatar>
|
||||
{isAdmin ? (
|
||||
<div
|
||||
className='font-medium text-brand-deep truncate text-sm cursor-pointer hover:text-brand hover:underline transition-colors'
|
||||
<button
|
||||
type='button'
|
||||
className='oc-ea-member-link'
|
||||
onClick={() => handleViewMemberUsage(record)}
|
||||
>
|
||||
{text || record.username}
|
||||
</div>
|
||||
{name}
|
||||
</button>
|
||||
) : (
|
||||
<div className='font-medium text-gray-900 dark:text-white truncate text-sm'>
|
||||
{text || record.username}
|
||||
</div>
|
||||
<span>{name}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('角色'),
|
||||
dataIndex: 'role',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
width: 132,
|
||||
render: (role) => {
|
||||
const config = {
|
||||
owner: { label: t('所有者'), color: 'red', icon: Crown },
|
||||
admin: { label: t('管理员'), color: 'blue', icon: ShieldCheck },
|
||||
dept_admin: {
|
||||
label: t('部门管理员'),
|
||||
color: 'cyan',
|
||||
icon: ShieldCheck,
|
||||
},
|
||||
super_admin: {
|
||||
label: t('超级管理员'),
|
||||
color: 'violet',
|
||||
icon: ShieldCheck,
|
||||
},
|
||||
member: { label: t('成员'), color: 'grey', icon: Shield },
|
||||
owner: { label: t('所有者'), color: 'volcano' },
|
||||
admin: { label: t('管理员'), color: 'geekblue' },
|
||||
dept_admin: { label: t('部门管理员'), color: 'cyan' },
|
||||
super_admin: { label: t('超级管理员'), color: 'purple' },
|
||||
member: { label: t('成员'), color: 'default' },
|
||||
};
|
||||
const c = config[role] || config.member;
|
||||
return (
|
||||
<div className='flex items-center justify-center gap-1'>
|
||||
<c.icon
|
||||
size={12}
|
||||
className={
|
||||
role === 'owner'
|
||||
? 'text-amber-500'
|
||||
: role === 'admin' ||
|
||||
role === 'dept_admin' ||
|
||||
role === 'super_admin'
|
||||
? 'text-brand-deep'
|
||||
: 'text-gray-400 dark:text-gray-500'
|
||||
}
|
||||
/>
|
||||
<Tag size='small' color={c.color}>
|
||||
{c.label}
|
||||
</Tag>
|
||||
</div>
|
||||
);
|
||||
return <AntTag color={c.color}>{c.label}</AntTag>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('周期内已用'),
|
||||
dataIndex: 'quota_used_in_period',
|
||||
width: 120,
|
||||
width: 130,
|
||||
align: 'right',
|
||||
render: (v, record) =>
|
||||
isPeriodicQuotaPeriod(record.quota_period) ? (
|
||||
<span className='text-gray-700 dark:text-gray-300 font-medium'>
|
||||
{renderQuota(safeQuotaNumber(v), 2)}
|
||||
</span>
|
||||
) : (
|
||||
<span className='text-xs text-gray-400 dark:text-gray-500'>—</span>
|
||||
),
|
||||
isPeriodicQuotaPeriod(record.quota_period)
|
||||
? renderQuota(safeQuotaNumber(v), 2)
|
||||
: '—',
|
||||
},
|
||||
{
|
||||
title: t('总已用额度'),
|
||||
dataIndex: 'used_quota',
|
||||
width: 120,
|
||||
width: 130,
|
||||
align: 'right',
|
||||
render: (v) => (
|
||||
<span className='text-gray-700 dark:text-gray-300 font-medium'>
|
||||
{renderQuota(safeQuotaNumber(v), 2)}
|
||||
</span>
|
||||
),
|
||||
render: (v) => renderQuota(safeQuotaNumber(v), 2),
|
||||
},
|
||||
{
|
||||
title: t('额度上限/周期'),
|
||||
title: t('额度上限 / 周期'),
|
||||
dataIndex: 'quota_limit',
|
||||
width: 150,
|
||||
align: 'right',
|
||||
render: (v, record) => {
|
||||
const quotaLimit = safeQuotaNumber(v);
|
||||
return quotaLimit > 0 ? (
|
||||
<div className='text-right'>
|
||||
<div className='text-gray-700 dark:text-gray-300'>
|
||||
{renderQuota(quotaLimit, 2)}
|
||||
</div>
|
||||
<div
|
||||
className={`text-[11px] ${
|
||||
isPeriodicQuotaPeriod(record.quota_period)
|
||||
? 'text-gray-400 dark:text-gray-500'
|
||||
: 'text-amber-500'
|
||||
}`}
|
||||
>
|
||||
<div className='oc-ea-limit'>
|
||||
{renderQuota(quotaLimit, 2)}
|
||||
<small>
|
||||
{quotaPeriodLimitLabel(t, record.quota_period)}
|
||||
{!isPeriodicQuotaPeriod(record.quota_period) &&
|
||||
` · ${t('不重置')}`}
|
||||
</div>
|
||||
</small>
|
||||
</div>
|
||||
) : (
|
||||
<span className='text-gray-400 dark:text-gray-500'>
|
||||
{t('不限')}
|
||||
</span>
|
||||
t('不限')
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('使用进度'),
|
||||
width: 160,
|
||||
width: 150,
|
||||
render: (_, record) => {
|
||||
const quotaLimit = safeQuotaNumber(record.quota_limit);
|
||||
if (quotaLimit <= 0) {
|
||||
return (
|
||||
<span className='text-xs text-gray-400 dark:text-gray-500'>
|
||||
-
|
||||
</span>
|
||||
);
|
||||
}
|
||||
if (quotaLimit <= 0) return '—';
|
||||
// 周期模式按「周期内已用 / 上限」;终身模式按「总已用 / 上限」。
|
||||
const usedForProgress = isPeriodicQuotaPeriod(record.quota_period)
|
||||
? safeQuotaNumber(record.quota_used_in_period)
|
||||
@@ -541,17 +498,11 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
Math.round((usedForProgress / quotaLimit) * 100),
|
||||
);
|
||||
return (
|
||||
<div className='flex items-center gap-2'>
|
||||
<Progress
|
||||
percent={percent}
|
||||
size='small'
|
||||
style={{ width: 100 }}
|
||||
stroke={usageStrokeColor(percent)}
|
||||
/>
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400 w-8 text-right'>
|
||||
{percent}%
|
||||
</span>
|
||||
</div>
|
||||
<Progress
|
||||
percent={percent}
|
||||
size='small'
|
||||
stroke={usageStrokeColor(percent)}
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -559,6 +510,22 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
[t, isAdmin, handleViewMemberUsage],
|
||||
);
|
||||
|
||||
// “成员用量”按钮:切换到成员用量明细并在页内定位(不发请求)
|
||||
const membersAnchorRef = useRef(null);
|
||||
const [detailTab, setDetailTab] = useState('models');
|
||||
const showMembers = () => {
|
||||
setDetailTab('members');
|
||||
window.setTimeout(() => {
|
||||
const reduce = window.matchMedia?.(
|
||||
'(prefers-reduced-motion: reduce)',
|
||||
)?.matches;
|
||||
membersAnchorRef.current?.scrollIntoView({
|
||||
behavior: reduce ? 'auto' : 'smooth',
|
||||
block: 'start',
|
||||
});
|
||||
}, 60);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetch();
|
||||
fetchQuota();
|
||||
@@ -578,7 +545,7 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
? Math.min(100, Math.round((usedQuota / totalQuota) * 100))
|
||||
: 0;
|
||||
|
||||
// 成员/令牌容量占用率:与其他使用进度共用同一套阈值语义色
|
||||
// 成员/密钥容量占用率:与其他使用进度共用同一套阈值语义色
|
||||
const memberPercent =
|
||||
data?.max_members > 0
|
||||
? Math.min(
|
||||
@@ -595,9 +562,10 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
: 0;
|
||||
|
||||
const statusConfig = getStatusConfig(data?.status, t);
|
||||
const quotaAvailability = getOrgQuotaAvailability(data);
|
||||
|
||||
// 成员明细对账:成员合计(终身已用)与企业池已用(org.UsedQuota)通常不相等,
|
||||
// 差额为「未归属」消费(令牌未绑定成员 / 管理员直接使用 / 成员跟踪前的历史),
|
||||
// 差额为「未归属」消费(密钥未绑定成员 / 管理员直接使用 / 成员跟踪前的历史),
|
||||
// 显式列出避免用户误以为成员明细加总应等于顶部「已用额度」。
|
||||
const memberQuotaRows = quotaData?.member_quotas || [];
|
||||
const memberQuotaPage = Number(quotaData?.member_page || 1);
|
||||
@@ -615,29 +583,88 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
const poolUsedQuota = Number(quotaData?.used_quota ?? data?.used_quota ?? 0);
|
||||
const unattributedQuota = Math.max(0, poolUsedQuota - memberUsedSum);
|
||||
|
||||
const statusTone = data?.status === 1 ? 'ok' : data?.status ? 'warn' : 'none';
|
||||
|
||||
const memberUsageCard = (
|
||||
<AntCard className='oc-ea-detail-card oc-ea-members'>
|
||||
<div className='oc-ea-table-toolbar'>
|
||||
<h2>{t('成员用量明细')}</h2>
|
||||
<Link to='/org/members' className='oc-ea-view-all'>
|
||||
{t('查看全部')}
|
||||
<ArrowRight size={12} />
|
||||
</Link>
|
||||
</div>
|
||||
<Table
|
||||
columns={memberColumns}
|
||||
dataSource={memberQuotaRows}
|
||||
loading={quotaLoading}
|
||||
rowKey='member_id'
|
||||
scroll={{ x: 860 }}
|
||||
pagination={
|
||||
memberQuotaTotal > memberQuotaPageSize
|
||||
? {
|
||||
currentPage: memberQuotaPage,
|
||||
pageSize: memberQuotaPageSize,
|
||||
total: memberQuotaTotal,
|
||||
showSizeChanger: false,
|
||||
onPageChange: (page) => fetchQuota(page, memberQuotaPageSize),
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}
|
||||
: false
|
||||
}
|
||||
empty={<OrgStateBlock icon={Users} title={t('暂无成员数据')} />}
|
||||
/>
|
||||
{memberQuotaRows.length > 0 && (
|
||||
<div className='oc-ea-member-total'>
|
||||
<span>
|
||||
{t('成员合计已用')}
|
||||
<strong>{renderQuota(memberUsedSum, 2)}</strong>
|
||||
</span>
|
||||
<span>
|
||||
{t('企业池已用')}
|
||||
<strong>{renderQuota(poolUsedQuota, 2)}</strong>
|
||||
</span>
|
||||
{unattributedQuota > 0 && (
|
||||
<Tooltip
|
||||
content={t(
|
||||
'企业池已用包含未绑定到具体成员的消费(如管理员直接使用、密钥未分配成员、成员跟踪前的历史数据),因此成员合计通常小于企业池已用。',
|
||||
)}
|
||||
>
|
||||
<span className='oc-ea-unattributed'>
|
||||
{t('未归属差额')}
|
||||
<strong>{renderQuota(unattributedQuota, 2)}</strong>
|
||||
</span>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</AntCard>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='uc-page space-y-6'>
|
||||
{/* Header */}
|
||||
<OrgPageHeader
|
||||
icon={BarChart2}
|
||||
title={t('企业概览')}
|
||||
subtitle={t(
|
||||
'聚合企业额度、组织规模与成员消耗,和个人工作台保持职责分离',
|
||||
)}
|
||||
actions={
|
||||
<>
|
||||
{isAdmin && (
|
||||
<Button
|
||||
icon={<CreditCard size={14} />}
|
||||
theme='solid'
|
||||
type='primary'
|
||||
onClick={() => navigate('/org/recharge')}
|
||||
>
|
||||
{t('立即充值')}
|
||||
</Button>
|
||||
)}
|
||||
<div className='uc-page oc-page oc-dashboard'>
|
||||
<div className='oc-dash-breadcrumb'>
|
||||
<OrgBreadcrumb current={t('数据看板')} />
|
||||
</div>
|
||||
|
||||
{/* 企业概况(原型 .ea-hero) */}
|
||||
<header className='oc-dash-hero'>
|
||||
<div className={`oc-dash-health is-${statusTone}`}>
|
||||
<span>
|
||||
<i aria-hidden='true' />
|
||||
{statusConfig.tagLabel}
|
||||
</span>
|
||||
{orgName && <div className='oc-dash-org-name'>{orgName}</div>}
|
||||
</div>
|
||||
<div className='oc-dash-heading'>
|
||||
<div>
|
||||
<h1>{t('企业数据看板')}</h1>
|
||||
<p>{t('掌握企业额度、组织规模与模型消耗')}</p>
|
||||
</div>
|
||||
<div className='oc-dash-actions'>
|
||||
<Button onClick={showMembers}>{t('成员用量')}</Button>
|
||||
<Button
|
||||
icon={<RefreshCw size={14} />}
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => {
|
||||
fetch();
|
||||
fetchQuota(memberQuotaPage, memberQuotaPageSize);
|
||||
@@ -646,237 +673,132 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
{/* 统计卡片 - 三列 */}
|
||||
<div className='grid grid-cols-1 sm:grid-cols-3 gap-4'>
|
||||
<StatCard
|
||||
icon={Users}
|
||||
title={t('企业成员')}
|
||||
value={data?.member_count ?? 0}
|
||||
tone='brand'
|
||||
loading={loading}
|
||||
subtitle={
|
||||
data?.max_members > 0
|
||||
? `${t('上限')}: ${data.max_members}`
|
||||
: t('不限')
|
||||
}
|
||||
extra={
|
||||
data?.max_members > 0 && (
|
||||
<Progress
|
||||
percent={memberPercent}
|
||||
size='small'
|
||||
stroke={usageStrokeColor(memberPercent)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
/>
|
||||
<StatCard
|
||||
icon={Key}
|
||||
title={t('企业令牌')}
|
||||
value={data?.token_count ?? 0}
|
||||
tone='amber'
|
||||
loading={loading}
|
||||
subtitle={
|
||||
data?.max_tokens > 0
|
||||
? `${t('上限')}: ${data.max_tokens}`
|
||||
: t('不限')
|
||||
}
|
||||
extra={
|
||||
data?.max_tokens > 0 && (
|
||||
<Progress
|
||||
percent={tokenPercent}
|
||||
size='small'
|
||||
stroke={usageStrokeColor(tokenPercent)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
/>
|
||||
<StatCard
|
||||
icon={TrendingUp}
|
||||
title={t('企业状态')}
|
||||
value={statusConfig.label}
|
||||
tone='sky'
|
||||
loading={loading}
|
||||
extra={
|
||||
data && (
|
||||
<Tag
|
||||
size='small'
|
||||
color={statusConfig.color}
|
||||
type='light'
|
||||
className='mt-0.5'
|
||||
{isAdmin && (
|
||||
<Button
|
||||
icon={<Wallet size={16} />}
|
||||
theme='solid'
|
||||
type='primary'
|
||||
onClick={() => navigate('/org/recharge')}
|
||||
>
|
||||
{statusConfig.tagLabel}
|
||||
</Tag>
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 额度使用详情 - 全宽 */}
|
||||
<OrgPanel icon={Wallet} title={t('额度使用详情')} padding='p-5'>
|
||||
<div className='grid grid-cols-1 sm:grid-cols-3 gap-4'>
|
||||
{/* 总额度 */}
|
||||
<div className='flex items-center gap-3 p-4 rounded-xl bg-gray-50/80 dark:bg-neutral-800/50 border border-gray-100 dark:border-neutral-700/50'>
|
||||
<div className='p-2 rounded-lg bg-brand/10'>
|
||||
<Coins size={16} className='text-brand-deep' />
|
||||
</div>
|
||||
<div>
|
||||
<div className='text-xs font-medium text-gray-400 dark:text-gray-500 mb-0.5'>
|
||||
{t('总额度')}
|
||||
</div>
|
||||
<div className='text-lg font-bold text-gray-900 dark:text-white'>
|
||||
{data ? renderQuota(totalQuota, 2) : '-'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* 已用额度 */}
|
||||
<div className='flex items-center gap-3 p-4 rounded-xl bg-orange-50/80 dark:bg-orange-900/10 border border-orange-100 dark:border-orange-800/30'>
|
||||
<div className='p-2 rounded-lg bg-orange-100 dark:bg-orange-900/30'>
|
||||
<Flame
|
||||
size={16}
|
||||
className='text-orange-600 dark:text-orange-400'
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<div className='text-xs font-medium text-gray-400 dark:text-gray-500 mb-0.5'>
|
||||
{t('已用额度')}
|
||||
</div>
|
||||
<div className='text-lg font-bold text-orange-600 dark:text-orange-400'>
|
||||
{data ? renderQuota(usedQuota, 2) : '-'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* 剩余额度 */}
|
||||
<div className='flex items-center gap-3 p-4 rounded-xl bg-emerald-50/80 dark:bg-emerald-900/10 border border-emerald-100 dark:border-emerald-800/30'>
|
||||
<div className='p-2 rounded-lg bg-emerald-100 dark:bg-emerald-900/30'>
|
||||
<PiggyBank
|
||||
size={16}
|
||||
className='text-emerald-600 dark:text-emerald-400'
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<div className='text-xs font-medium text-gray-400 dark:text-gray-500 mb-0.5'>
|
||||
{t('剩余额度')}
|
||||
</div>
|
||||
<div className='text-lg font-bold text-emerald-600 dark:text-emerald-400'>
|
||||
{data ? renderQuota(Number(data.quota || 0), 2) : '-'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 使用率进度条 */}
|
||||
<div className='mt-5 pt-4 border-t border-gray-100 dark:border-neutral-800'>
|
||||
<div className='flex items-center justify-between mb-2'>
|
||||
<span className='text-sm text-gray-500 dark:text-gray-400'>
|
||||
{t('使用率(累计)')}
|
||||
</span>
|
||||
<span
|
||||
className='text-sm font-semibold'
|
||||
style={{ color: usageStrokeColor(usedPercent) }}
|
||||
>
|
||||
{usedPercent}%
|
||||
</span>
|
||||
</div>
|
||||
<div className='w-full h-3 bg-gray-100 dark:bg-neutral-800 rounded-full overflow-hidden'>
|
||||
{/* 渐变由同一语义色的浅调 → 本色构成(单色相),
|
||||
不再引入第二色相(旧 emerald→teal 与用量分析的 teal 系列色撞车) */}
|
||||
<div
|
||||
className='h-full rounded-full transition-all duration-1000 ease-out'
|
||||
style={{
|
||||
width: `${Math.max(usedPercent, 0)}%`,
|
||||
background: `linear-gradient(90deg, color-mix(in srgb, ${usageStrokeColor(usedPercent)} 72%, #fff) 0%, ${usageStrokeColor(usedPercent)} 100%)`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</OrgPanel>
|
||||
|
||||
{/* 成员用量明细 */}
|
||||
<OrgPanel
|
||||
icon={Users}
|
||||
title={t('成员用量明细')}
|
||||
padding='p-5'
|
||||
bodyClassName='overflow-x-auto'
|
||||
actions={
|
||||
<Link
|
||||
to='/org/members'
|
||||
className='flex items-center gap-1 text-xs text-brand-deep hover:text-brand transition-colors'
|
||||
>
|
||||
{t('查看全部')}
|
||||
<ArrowRight size={12} />
|
||||
</Link>
|
||||
}
|
||||
>
|
||||
<Table
|
||||
columns={memberColumns}
|
||||
dataSource={memberQuotaRows}
|
||||
loading={quotaLoading}
|
||||
rowKey='member_id'
|
||||
pagination={
|
||||
memberQuotaTotal > memberQuotaPageSize
|
||||
? {
|
||||
currentPage: memberQuotaPage,
|
||||
pageSize: memberQuotaPageSize,
|
||||
total: memberQuotaTotal,
|
||||
showSizeChanger: false,
|
||||
onPageChange: (page) => fetchQuota(page, memberQuotaPageSize),
|
||||
}
|
||||
: false
|
||||
}
|
||||
size='small'
|
||||
empty={<OrgStateBlock icon={Users} title={t('暂无成员数据')} />}
|
||||
/>
|
||||
{memberQuotaRows.length > 0 && (
|
||||
<div className='mt-3 pt-3 border-t border-gray-100 dark:border-neutral-800 flex flex-wrap items-center gap-x-6 gap-y-1 text-xs'>
|
||||
<span className='text-gray-500 dark:text-gray-400'>
|
||||
{t('成员合计已用')}:
|
||||
<span className='font-medium text-gray-700 dark:text-gray-300'>
|
||||
{renderQuota(memberUsedSum, 2)}
|
||||
</span>
|
||||
</span>
|
||||
<span className='text-gray-500 dark:text-gray-400'>
|
||||
{t('企业池已用')}:
|
||||
<span className='font-medium text-gray-700 dark:text-gray-300'>
|
||||
{renderQuota(poolUsedQuota, 2)}
|
||||
</span>
|
||||
</span>
|
||||
{unattributedQuota > 0 && (
|
||||
<Tooltip
|
||||
content={t(
|
||||
'企业池已用包含未绑定到具体成员的消费(如管理员直接使用、令牌未分配成员、成员跟踪前的历史数据),因此成员合计通常小于企业池已用。',
|
||||
)}
|
||||
>
|
||||
<span className='text-amber-600 dark:text-amber-400 cursor-help'>
|
||||
{t('未归属差额')}:
|
||||
<span className='font-medium'>
|
||||
{renderQuota(unattributedQuota, 2)}
|
||||
</span>
|
||||
</span>
|
||||
</Tooltip>
|
||||
{t('立即充值')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</OrgPanel>
|
||||
|
||||
{showAnalytics && (
|
||||
<div className='space-y-3'>
|
||||
<div className='flex items-center gap-2 px-1'>
|
||||
<Activity size={16} className='text-brand-deep' />
|
||||
<div>
|
||||
<div className='font-semibold text-gray-950 dark:text-white'>
|
||||
{t('多维用量分析')}
|
||||
</div>
|
||||
<div className='oc-dash-overview'>
|
||||
<AntCard className='oc-dash-budget'>
|
||||
<div className='oc-dash-budget-heading'>
|
||||
<h2>{t('企业额度')}</h2>
|
||||
<span>{t('累计额度使用情况')}</span>
|
||||
</div>
|
||||
<div className='oc-dash-budget-primary'>
|
||||
<span>{t('剩余额度')}</span>
|
||||
<strong>
|
||||
{data ? renderBudgetAmount(Number(data.quota || 0)) : '-'}
|
||||
</strong>
|
||||
{quotaAvailability && (
|
||||
<div
|
||||
className={`oc-dash-budget-availability is-${quotaAvailability.type}`}
|
||||
role='status'
|
||||
>
|
||||
<Typography.Text type={quotaAvailability.type}>
|
||||
{t(quotaAvailability.label)}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className='oc-dash-budget-secondary'>
|
||||
<div>
|
||||
<span>{t('总额度')}</span>
|
||||
<strong>{data ? renderQuota(totalQuota, 2) : '-'}</strong>
|
||||
</div>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400'>
|
||||
{t('管理员专属经营数据,避免与个人工作台重复展示')}
|
||||
<div>
|
||||
<span>{t('已用额度')}</span>
|
||||
<strong>{data ? renderQuota(usedQuota, 2) : '-'}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className='oc-dash-budget-progress'>
|
||||
<div>
|
||||
<span>{t('累计使用率')}</span>
|
||||
<strong style={{ color: usageStrokeColor(usedPercent) }}>
|
||||
{usedPercent}%
|
||||
</strong>
|
||||
</div>
|
||||
<Progress
|
||||
percent={usedPercent}
|
||||
size='small'
|
||||
showInfo={false}
|
||||
stroke={usageStrokeColor(usedPercent)}
|
||||
/>
|
||||
</div>
|
||||
</AntCard>
|
||||
|
||||
<div className='oc-dash-org'>
|
||||
<div>
|
||||
<span>
|
||||
<Users size={16} />
|
||||
{t('企业成员')}
|
||||
</span>
|
||||
<strong>
|
||||
{data?.member_count ?? 0}
|
||||
<small>
|
||||
{data?.max_members > 0
|
||||
? `/ ${Number(data.max_members).toLocaleString()}`
|
||||
: `/ ${t('不限')}`}
|
||||
</small>
|
||||
</strong>
|
||||
{data?.max_members > 0 && (
|
||||
<Progress
|
||||
percent={memberPercent}
|
||||
size='small'
|
||||
showInfo={false}
|
||||
stroke={usageStrokeColor(memberPercent)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
<span>
|
||||
<Key size={16} />
|
||||
{t('企业密钥')}
|
||||
</span>
|
||||
<strong>
|
||||
{data?.token_count ?? 0}
|
||||
<small>
|
||||
{data?.max_tokens > 0
|
||||
? `/ ${Number(data.max_tokens).toLocaleString()}`
|
||||
: `/ ${t('不限')}`}
|
||||
</small>
|
||||
</strong>
|
||||
{data?.max_tokens > 0 && (
|
||||
<Progress
|
||||
percent={tokenPercent}
|
||||
size='small'
|
||||
showInfo={false}
|
||||
stroke={usageStrokeColor(tokenPercent)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className='oc-dash-status'>
|
||||
<span>
|
||||
<Activity size={16} />
|
||||
{t('企业状态')}
|
||||
</span>
|
||||
<strong>{statusConfig.label}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<OrgAnalyticsPanel orgId={orgId} />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{showAnalytics ? (
|
||||
<OrgAnalyticsPanel
|
||||
orgId={orgId}
|
||||
memberUsage={memberUsageCard}
|
||||
detailTab={detailTab}
|
||||
onDetailTabChange={setDetailTab}
|
||||
detailsRef={membersAnchorRef}
|
||||
/>
|
||||
) : (
|
||||
<div ref={membersAnchorRef}>{memberUsageCard}</div>
|
||||
)}
|
||||
|
||||
{/* 成员用量明细抽屉 */}
|
||||
|
||||
@@ -242,7 +242,7 @@ const OrgDepartments = ({ orgId }) => {
|
||||
<div className='uc-page'>
|
||||
<OrgPageHeader
|
||||
icon={Network}
|
||||
title={t('部门管理')}
|
||||
title={t('组织架构')}
|
||||
subtitle={t('组织架构与部门预算')}
|
||||
actions={
|
||||
<>
|
||||
|
||||
+222
-263
@@ -21,20 +21,20 @@ import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
RefreshCw,
|
||||
Receipt,
|
||||
Coins,
|
||||
Wallet,
|
||||
Zap,
|
||||
Activity,
|
||||
BarChart3,
|
||||
Download,
|
||||
Trophy,
|
||||
Search,
|
||||
} from 'lucide-react';
|
||||
import { Card as AntCard, Form as AntForm, Tabs as AntTabs } from 'antd';
|
||||
import {
|
||||
Table,
|
||||
Select,
|
||||
Button,
|
||||
DatePicker,
|
||||
Input,
|
||||
Tabs,
|
||||
TabPane,
|
||||
Checkbox,
|
||||
Radio,
|
||||
RadioGroup,
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
useOrgMemberRanking,
|
||||
} from '../../hooks/org/useOrgData';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import StatCard from './components/OrgStatCard';
|
||||
import { OrgFilterCard, OrgListCard } from './components/OrgListCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
import {
|
||||
API,
|
||||
@@ -58,13 +58,6 @@ import {
|
||||
timestamp2string,
|
||||
} from '../../helpers';
|
||||
|
||||
// ========== 排名徽标颜色 ==========
|
||||
const rankColors = {
|
||||
1: 'from-yellow-400 to-yellow-500',
|
||||
2: 'from-gray-300 to-gray-400',
|
||||
3: 'from-orange-400 to-orange-500',
|
||||
};
|
||||
|
||||
// ========== 缓存 Token 解析(来自 other JSON 字段)==========
|
||||
function getCacheTokens(record) {
|
||||
const other = getLogOther(record.other);
|
||||
@@ -609,86 +602,71 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
];
|
||||
}, [appliedFilters, canViewTeamUsage, isAdmin, members, t]);
|
||||
|
||||
// ========== 日志表格列 ==========
|
||||
// ========== 日志表格列(宽度与渲染对齐原型 EnterpriseExpenses)==========
|
||||
const logColumns = useMemo(
|
||||
() => [
|
||||
{
|
||||
title: t('时间'),
|
||||
dataIndex: 'created_at',
|
||||
width: 170,
|
||||
width: 185,
|
||||
render: (v) => (v ? timestamp2string(v) : '-'),
|
||||
},
|
||||
{
|
||||
title: t('用户'),
|
||||
dataIndex: 'username',
|
||||
width: 120,
|
||||
render: (v, record) => (
|
||||
<span className='text-sm text-gray-700 dark:text-gray-300 truncate'>
|
||||
{record.display_name || v || '-'}
|
||||
</span>
|
||||
),
|
||||
width: 105,
|
||||
ellipsis: true,
|
||||
render: (v, record) => record.display_name || v || '-',
|
||||
},
|
||||
{
|
||||
title: t('模型'),
|
||||
dataIndex: 'model_name',
|
||||
width: 180,
|
||||
width: 175,
|
||||
ellipsis: true,
|
||||
render: (v) => (
|
||||
<code className='text-xs px-1.5 py-0.5 bg-gray-100 dark:bg-neutral-800 rounded'>
|
||||
{v || '-'}
|
||||
</code>
|
||||
),
|
||||
render: (v) => <span className='oc-exp-model'>{v || '-'}</span>,
|
||||
},
|
||||
{
|
||||
title: t('Token 名称'),
|
||||
title: t('密钥名称'),
|
||||
dataIndex: 'token_name',
|
||||
width: 120,
|
||||
width: 235,
|
||||
ellipsis: true,
|
||||
render: (v) => (
|
||||
<span className='text-sm text-gray-600 dark:text-gray-400'>
|
||||
{v || '-'}
|
||||
render: (v) => v || '-',
|
||||
},
|
||||
{
|
||||
title: t('提示 / 补全'),
|
||||
width: 165,
|
||||
render: (_, record) => (
|
||||
<span className='oc-number'>
|
||||
<span title='Prompt'>{record.prompt_tokens || 0}</span>{' '}
|
||||
<span className='oc-muted' title='Completion'>
|
||||
/ {record.completion_tokens || 0}
|
||||
</span>
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('提示 / 补全'),
|
||||
width: 130,
|
||||
render: (_, record) => (
|
||||
<div className='text-xs text-gray-600 dark:text-gray-400'>
|
||||
<span title='Prompt'>{record.prompt_tokens || 0}</span>
|
||||
<span className='mx-1 text-gray-300 dark:text-gray-600'>/</span>
|
||||
<span title='Completion'>{record.completion_tokens || 0}</span>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('缓存 / 缓存创建'),
|
||||
width: 130,
|
||||
width: 180,
|
||||
render: (_, record) => (
|
||||
<div className='text-xs text-gray-600 dark:text-gray-400'>
|
||||
<span title={t('缓存 Tokens')}>{getCacheTokens(record)}</span>
|
||||
<span className='mx-1 text-gray-300 dark:text-gray-600'>/</span>
|
||||
<span title={t('缓存创建 Tokens')}>
|
||||
{getCacheCreationTokens(record)}
|
||||
<span className='oc-number'>
|
||||
<span title={t('缓存 Tokens')}>{getCacheTokens(record)}</span>{' '}
|
||||
<span className='oc-muted' title={t('缓存创建 Tokens')}>
|
||||
/ {getCacheCreationTokens(record)}
|
||||
</span>
|
||||
</div>
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('消耗额度'),
|
||||
dataIndex: 'quota',
|
||||
width: 110,
|
||||
width: 150,
|
||||
align: 'right',
|
||||
render: (v) => (
|
||||
<span className='text-orange-600 dark:text-orange-400 font-medium text-sm'>
|
||||
{renderQuota(v, 6)}
|
||||
</span>
|
||||
),
|
||||
render: (v) => <span className='oc-exp-cost'>{renderQuota(v, 6)}</span>,
|
||||
},
|
||||
{
|
||||
title: t('耗时'),
|
||||
dataIndex: 'use_time',
|
||||
width: 80,
|
||||
width: 90,
|
||||
align: 'right',
|
||||
render: (v) => (v ? `${v}s` : '-'),
|
||||
},
|
||||
@@ -696,82 +674,76 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
[t],
|
||||
);
|
||||
|
||||
// ========== 排行榜表格列 ==========
|
||||
// ========== 排行榜表格列(原型 90/200/190/150/160)==========
|
||||
const rankingColumns = useMemo(
|
||||
() => [
|
||||
{
|
||||
title: '#',
|
||||
width: 60,
|
||||
render: (_, __, index) => {
|
||||
const rank = index + 1;
|
||||
const gradient = rankColors[rank];
|
||||
return gradient ? (
|
||||
<div
|
||||
className={`inline-flex items-center justify-center w-7 h-7 rounded-full bg-gradient-to-br ${gradient} text-white text-xs font-bold shadow-sm`}
|
||||
>
|
||||
{rank}
|
||||
</div>
|
||||
) : (
|
||||
<div className='inline-flex items-center justify-center w-7 h-7 rounded-full bg-gray-200 dark:bg-neutral-700 text-gray-600 dark:text-gray-300 text-xs font-medium'>
|
||||
{rank}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
title: t('排名'),
|
||||
width: 90,
|
||||
render: (_, __, index) => (
|
||||
<span className={`oc-exp-rank oc-exp-rank-${index + 1}`}>
|
||||
{index + 1}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('成员'),
|
||||
dataIndex: 'username',
|
||||
width: 160,
|
||||
render: (v, record) => (
|
||||
<div className='flex items-center gap-2'>
|
||||
<div className='w-7 h-7 rounded-full bg-brand/10 text-brand flex items-center justify-center text-xs font-semibold flex-shrink-0'>
|
||||
{(record.display_name || v || '?').charAt(0).toUpperCase()}
|
||||
</div>
|
||||
<span className='text-sm text-gray-700 dark:text-gray-300 truncate'>
|
||||
{record.display_name || v || '-'}
|
||||
</span>
|
||||
</div>
|
||||
),
|
||||
width: 200,
|
||||
render: (v, record) => record.display_name || v || '-',
|
||||
},
|
||||
{
|
||||
title: t('消耗额度'),
|
||||
dataIndex: 'quota',
|
||||
width: 130,
|
||||
width: 190,
|
||||
align: 'right',
|
||||
render: (v) => (
|
||||
<span className='text-orange-600 dark:text-orange-400 font-semibold text-sm'>
|
||||
{renderQuota(v, 6)}
|
||||
</span>
|
||||
),
|
||||
render: (v) => <span className='oc-exp-cost'>{renderQuota(v, 6)}</span>,
|
||||
},
|
||||
{
|
||||
title: t('请求数'),
|
||||
dataIndex: 'requests',
|
||||
width: 100,
|
||||
width: 150,
|
||||
align: 'right',
|
||||
render: (v) => (
|
||||
<span className='text-sm text-gray-600 dark:text-gray-400'>
|
||||
{formatNumber(v)}
|
||||
</span>
|
||||
),
|
||||
render: (v) => <span className='oc-number'>{formatNumber(v)}</span>,
|
||||
},
|
||||
{
|
||||
title: t('Token 数'),
|
||||
dataIndex: 'tokens',
|
||||
width: 120,
|
||||
width: 160,
|
||||
align: 'right',
|
||||
render: (v) => (
|
||||
<span className='text-sm text-gray-600 dark:text-gray-400'>
|
||||
{formatNumber(v)}
|
||||
</span>
|
||||
),
|
||||
render: (v) => <span className='oc-number'>{formatNumber(v)}</span>,
|
||||
},
|
||||
],
|
||||
[t],
|
||||
);
|
||||
|
||||
const statItems = [
|
||||
{
|
||||
key: 'quota',
|
||||
icon: Wallet,
|
||||
label: t('总消耗额度'),
|
||||
value: statLoading ? '...' : renderQuota(stat.quota, 2),
|
||||
},
|
||||
{
|
||||
key: 'rpm',
|
||||
icon: Zap,
|
||||
label: stat.has_time_range ? t('平均 RPM') : t('RPM(需选时间范围)'),
|
||||
value: statLoading ? '...' : stat.has_time_range ? String(stat.rpm) : '—',
|
||||
},
|
||||
{
|
||||
key: 'tpm',
|
||||
icon: BarChart3,
|
||||
label: stat.has_time_range ? t('平均 TPM') : t('TPM(需选时间范围)'),
|
||||
value: statLoading
|
||||
? '...'
|
||||
: stat.has_time_range
|
||||
? formatNumber(stat.tpm)
|
||||
: '—',
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className='uc-page'>
|
||||
<div className='uc-page oc-page'>
|
||||
{/* 标题栏 */}
|
||||
<OrgPageHeader
|
||||
title={canViewTeamUsage ? t('消耗明细') : t('我的消耗明细')}
|
||||
@@ -782,16 +754,107 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
? t('查看所负责部门成员的 API 消耗记录')
|
||||
: t('查看自己的 API 调用明细')
|
||||
}
|
||||
/>
|
||||
|
||||
{/* 统计卡片(原型 .eex-stats) */}
|
||||
<div className='oc-exp-stats'>
|
||||
{statItems.map(({ key, icon: Icon, label, value }, i) => (
|
||||
<AntCard key={key} className={`oc-exp-stat oc-exp-stat-${i}`}>
|
||||
<span className='oc-exp-stat-icon'>
|
||||
<Icon size={20} />
|
||||
</span>
|
||||
<div>
|
||||
<span>{label}</span>
|
||||
<strong>{value}</strong>
|
||||
</div>
|
||||
</AntCard>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* 页签:明细日志 / 成员排行(原型 platform-list-tabs,只切换下方表格) */}
|
||||
<AntTabs
|
||||
className='oc-list-tabs oc-tabs-nav-only'
|
||||
activeKey={activeTab}
|
||||
onChange={setActiveTab}
|
||||
items={[
|
||||
{ key: 'logs', label: t('明细日志') },
|
||||
...(canViewTeamUsage
|
||||
? [{ key: 'ranking', label: t('成员排行') }]
|
||||
: []),
|
||||
]}
|
||||
/>
|
||||
|
||||
{/* 筛选栏(原型 .ee-filter-card / .eex-filter-grid) */}
|
||||
<OrgFilterCard
|
||||
className='oc-exp-filter'
|
||||
actions={
|
||||
<>
|
||||
<Button onClick={handleReset}>{t('重置')}</Button>
|
||||
<Button
|
||||
icon={<Download size={14} />}
|
||||
type='primary'
|
||||
icon={<Search size={16} />}
|
||||
onClick={() => handleSearch(false)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('搜索')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('成员')}>
|
||||
{canViewTeamUsage ? (
|
||||
<Select
|
||||
value={selectedUserId}
|
||||
onChange={setSelectedUserId}
|
||||
optionList={memberOptions}
|
||||
style={{ width: '100%' }}
|
||||
placeholder={isAdmin ? t('全部成员') : t('全部部门成员')}
|
||||
filter
|
||||
/>
|
||||
) : (
|
||||
<div className='oc-exp-self'>{t('仅本人')}</div>
|
||||
)}
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('时间范围')}>
|
||||
<DatePicker
|
||||
type='dateTimeRange'
|
||||
value={dateRange}
|
||||
onChange={(v) => {
|
||||
setDateRange(v);
|
||||
setIsDefaultRange(false);
|
||||
}}
|
||||
placeholder={[t('开始时间'), t('结束时间')]}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('模型名称')}>
|
||||
<Input
|
||||
placeholder={t('请输入模型名称')}
|
||||
value={modelName}
|
||||
onChange={setModelName}
|
||||
onEnterPress={() => handleSearch(false)}
|
||||
/>
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
</OrgFilterCard>
|
||||
|
||||
<OrgListCard
|
||||
title={activeTab === 'ranking' ? t('成员排行') : t('明细日志')}
|
||||
tools={
|
||||
<>
|
||||
<Button
|
||||
icon={<Download size={16} />}
|
||||
onClick={() => setExportModalVisible(true)}
|
||||
>
|
||||
{t('导出')}
|
||||
</Button>
|
||||
<Button
|
||||
icon={<RefreshCw size={14} />}
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => handleSearch(true)}
|
||||
loading={loading}
|
||||
>
|
||||
@@ -799,164 +862,60 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
{/* 统计卡片 */}
|
||||
<div className='grid grid-cols-1 sm:grid-cols-3 gap-3 mb-4'>
|
||||
<StatCard
|
||||
compact
|
||||
tone='brand'
|
||||
icon={Coins}
|
||||
label={t('总消耗额度')}
|
||||
value={statLoading ? '...' : renderQuota(stat.quota, 2)}
|
||||
/>
|
||||
<StatCard
|
||||
compact
|
||||
tone='rose'
|
||||
icon={Zap}
|
||||
label={stat.has_time_range ? t('平均 RPM') : t('RPM(需选时间范围)')}
|
||||
value={
|
||||
statLoading ? '...' : stat.has_time_range ? String(stat.rpm) : '—'
|
||||
}
|
||||
/>
|
||||
<StatCard
|
||||
compact
|
||||
tone='sky'
|
||||
icon={Activity}
|
||||
label={stat.has_time_range ? t('平均 TPM') : t('TPM(需选时间范围)')}
|
||||
value={
|
||||
statLoading
|
||||
? '...'
|
||||
: stat.has_time_range
|
||||
? formatNumber(stat.tpm)
|
||||
: '—'
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 筛选栏 */}
|
||||
<div className='flex flex-wrap items-end gap-3 mb-4 p-4 rounded-xl border border-[var(--border-subtle)] bg-[var(--surface-card)] shadow-[var(--elevation-xs)]'>
|
||||
{canViewTeamUsage ? (
|
||||
<div className='min-w-[160px]'>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400 mb-1'>
|
||||
{t('成员')}
|
||||
</div>
|
||||
<Select
|
||||
value={selectedUserId}
|
||||
onChange={setSelectedUserId}
|
||||
optionList={memberOptions}
|
||||
style={{ width: 180 }}
|
||||
placeholder={isAdmin ? t('全部成员') : t('全部部门成员')}
|
||||
filter
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className='min-w-[160px]'>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400 mb-1'>
|
||||
{t('成员')}
|
||||
</div>
|
||||
<div className='h-8 px-3 inline-flex items-center rounded-md border border-gray-200 dark:border-neutral-700 bg-gray-50/80 dark:bg-neutral-800/70 text-sm text-gray-600 dark:text-gray-300'>
|
||||
{t('仅本人')}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className='min-w-[280px]'>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400 mb-1'>
|
||||
{t('时间范围')}
|
||||
</div>
|
||||
<DatePicker
|
||||
type='dateTimeRange'
|
||||
density='compact'
|
||||
value={dateRange}
|
||||
onChange={(v) => {
|
||||
setDateRange(v);
|
||||
setIsDefaultRange(false);
|
||||
}}
|
||||
placeholder={[t('开始时间'), t('结束时间')]}
|
||||
style={{ width: 320 }}
|
||||
/>
|
||||
</div>
|
||||
<div className='min-w-[140px]'>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400 mb-1'>
|
||||
{t('模型名称')}
|
||||
</div>
|
||||
<Input
|
||||
placeholder={t('输入模型名称')}
|
||||
value={modelName}
|
||||
onChange={setModelName}
|
||||
onEnterPress={() => handleSearch(false)}
|
||||
style={{ width: 180 }}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex gap-2'>
|
||||
<Button
|
||||
theme='solid'
|
||||
onClick={() => handleSearch(false)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('查询')}
|
||||
</Button>
|
||||
<Button onClick={handleReset}>{t('重置')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Tabs: 明细日志 / 成员排行 */}
|
||||
<div className='rounded-xl border border-[var(--border-subtle)] bg-[var(--surface-card)] shadow-[var(--elevation-xs)] p-4'>
|
||||
<Tabs activeKey={activeTab} onChange={setActiveTab}>
|
||||
<TabPane tab={t('明细日志')} itemKey='logs'>
|
||||
<Table
|
||||
columns={logColumns}
|
||||
dataSource={logs}
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
pageSize,
|
||||
total,
|
||||
onPageChange: (p) => doPageFetch(p),
|
||||
}}
|
||||
empty={
|
||||
<div className='py-10 text-center'>
|
||||
<div className='inline-flex p-3 rounded-full bg-gray-100 dark:bg-neutral-800 mb-3'>
|
||||
<Receipt
|
||||
size={24}
|
||||
className='text-gray-400 dark:text-gray-500'
|
||||
/>
|
||||
</div>
|
||||
<p className='text-gray-400 dark:text-gray-500 text-sm'>
|
||||
{t('暂无消耗记录')}
|
||||
</p>
|
||||
>
|
||||
{activeTab === 'ranking' && canViewTeamUsage ? (
|
||||
<Table
|
||||
columns={rankingColumns}
|
||||
dataSource={ranking}
|
||||
loading={rankingLoading}
|
||||
rowKey='user_id'
|
||||
pagination={false}
|
||||
scroll={{ x: 790 }}
|
||||
empty={
|
||||
<div className='py-10 text-center'>
|
||||
<div className='inline-flex p-3 rounded-full bg-gray-100 dark:bg-neutral-800 mb-3'>
|
||||
<Trophy
|
||||
size={24}
|
||||
className='text-gray-400 dark:text-gray-500'
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</TabPane>
|
||||
|
||||
{canViewTeamUsage && (
|
||||
<TabPane tab={t('成员排行')} itemKey='ranking'>
|
||||
<Table
|
||||
columns={rankingColumns}
|
||||
dataSource={ranking}
|
||||
loading={rankingLoading}
|
||||
rowKey='user_id'
|
||||
pagination={false}
|
||||
empty={
|
||||
<div className='py-10 text-center'>
|
||||
<div className='inline-flex p-3 rounded-full bg-gray-100 dark:bg-neutral-800 mb-3'>
|
||||
<Trophy
|
||||
size={24}
|
||||
className='text-gray-400 dark:text-gray-500'
|
||||
/>
|
||||
</div>
|
||||
<p className='text-gray-400 dark:text-gray-500 text-sm'>
|
||||
{t('暂无排行数据')}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</TabPane>
|
||||
)}
|
||||
</Tabs>
|
||||
</div>
|
||||
<p className='text-gray-400 dark:text-gray-500 text-sm'>
|
||||
{t('暂无排行数据')}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<Table
|
||||
columns={logColumns}
|
||||
dataSource={logs}
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1285 }}
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
pageSize,
|
||||
total,
|
||||
showSizeChanger: false,
|
||||
onPageChange: (p) => doPageFetch(p),
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
empty={
|
||||
<div className='py-10 text-center'>
|
||||
<div className='inline-flex p-3 rounded-full bg-gray-100 dark:bg-neutral-800 mb-3'>
|
||||
<Receipt
|
||||
size={24}
|
||||
className='text-gray-400 dark:text-gray-500'
|
||||
/>
|
||||
</div>
|
||||
<p className='text-gray-400 dark:text-gray-500 text-sm'>
|
||||
{t('暂无消耗记录')}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</OrgListCard>
|
||||
|
||||
{/* 导出弹窗:汇总 / 按用户 + 字段选择 */}
|
||||
<OrgModal
|
||||
|
||||
@@ -33,13 +33,13 @@ import {
|
||||
RefreshCw,
|
||||
UserPlus,
|
||||
Upload as UploadIcon,
|
||||
KeyRound,
|
||||
IdCard,
|
||||
} from 'lucide-react';
|
||||
import { API } from '../../helpers/api';
|
||||
import { showError, collectPagedItems } from '../../helpers';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
import DeptTreeSelect from './components/DeptTreeSelect';
|
||||
import {
|
||||
@@ -383,16 +383,15 @@ const OrgMemberAccounts = ({
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 300,
|
||||
width: 260,
|
||||
render: (_, r) => {
|
||||
const managed = r.created_by_org_id === r.organization_id;
|
||||
const canReset = managed || isSuperAdmin;
|
||||
return (
|
||||
<div className='flex items-center gap-2'>
|
||||
<OrgRowActions>
|
||||
{deptEnabled && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
type='link'
|
||||
onClick={() => {
|
||||
setDeptAssignFor(r);
|
||||
setDeptAssignVal(r.department_id || 0);
|
||||
@@ -413,22 +412,11 @@ const OrgMemberAccounts = ({
|
||||
}
|
||||
onConfirm={() => resetPassword(r)}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
icon={<KeyRound size={14} />}
|
||||
>
|
||||
{t('重置密码')}
|
||||
</Button>
|
||||
<Button type='link'>{t('重置密码')}</Button>
|
||||
</Popconfirm>
|
||||
) : (
|
||||
<Tooltip content={t('个人平台账号,请由本人通过找回密码修改')}>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
disabled
|
||||
icon={<KeyRound size={14} />}
|
||||
>
|
||||
<Button type='link' disabled>
|
||||
{t('重置密码')}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
@@ -441,25 +429,32 @@ const OrgMemberAccounts = ({
|
||||
)}
|
||||
onConfirm={() => offboard(r.id)}
|
||||
>
|
||||
<Button size='small' theme='light' type='danger'>
|
||||
<Button type='link' danger>
|
||||
{t('离职回收')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
)}
|
||||
</div>
|
||||
</OrgRowActions>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// 原型员工列表工具区:刷新 / 新建员工(主按钮)/ CSV 导入;回调不变
|
||||
const actions = (
|
||||
<>
|
||||
<Button theme='light' icon={<RefreshCw size={14} />} onClick={fetchAll}>
|
||||
<Button icon={<RefreshCw size={16} />} onClick={fetchAll}>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='light'
|
||||
icon={<UploadIcon size={14} />}
|
||||
theme='solid'
|
||||
icon={<UserPlus size={16} />}
|
||||
onClick={() => setCreateVisible(true)}
|
||||
>
|
||||
{t('创建员工账号')}
|
||||
</Button>
|
||||
<Button
|
||||
icon={<UploadIcon size={16} />}
|
||||
onClick={() => {
|
||||
setImportResult(null);
|
||||
setImportFile(null);
|
||||
@@ -468,38 +463,12 @@ const OrgMemberAccounts = ({
|
||||
>
|
||||
{t('CSV 导入')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='solid'
|
||||
icon={<UserPlus size={14} />}
|
||||
onClick={() => setCreateVisible(true)}
|
||||
>
|
||||
{t('创建员工账号')}
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={embedded ? 'space-y-4' : 'uc-page'}>
|
||||
{embedded ? (
|
||||
<div className='flex items-start justify-between gap-3 flex-wrap rounded-2xl border border-dashed border-brand/25 bg-brand/5 p-4 dark:border-brand/25 dark:bg-brand/10'>
|
||||
<div className='flex items-start gap-3'>
|
||||
<span className='inline-flex h-10 w-10 items-center justify-center rounded-2xl bg-white text-brand-deep shadow-sm dark:bg-white/10 dark:text-brand-from'>
|
||||
<IdCard size={18} />
|
||||
</span>
|
||||
<div>
|
||||
<div className='font-semibold text-gray-950 dark:text-white'>
|
||||
{t('员工账号')}
|
||||
</div>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('集中管理员工登录、批量导入、重置密码与离职回收')}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex items-center gap-2 flex-wrap justify-end'>
|
||||
{actions}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className={embedded ? 'oc-member-accounts' : 'uc-page'}>
|
||||
{!embedded && (
|
||||
<OrgPageHeader
|
||||
icon={IdCard}
|
||||
title={t('员工账号')}
|
||||
@@ -518,15 +487,31 @@ const OrgMemberAccounts = ({
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<OrgPanel padding='p-2'>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={members}
|
||||
loading={loading}
|
||||
pagination={{ pageSize: 15, showSizeChanger: false }}
|
||||
rowKey='id'
|
||||
/>
|
||||
</OrgPanel>
|
||||
{embedded ? (
|
||||
<OrgListCard title={t('员工账号')} tools={actions}>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={members}
|
||||
loading={loading}
|
||||
pagination={{
|
||||
pageSize: 15,
|
||||
showSizeChanger: false,
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
rowKey='id'
|
||||
/>
|
||||
</OrgListCard>
|
||||
) : (
|
||||
<OrgPanel padding='p-2'>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={members}
|
||||
loading={loading}
|
||||
pagination={{ pageSize: 15, showSizeChanger: false }}
|
||||
rowKey='id'
|
||||
/>
|
||||
</OrgPanel>
|
||||
)}
|
||||
|
||||
{/* 创建账号 */}
|
||||
<OrgModal
|
||||
|
||||
@@ -18,17 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Users,
|
||||
Trash2,
|
||||
Settings,
|
||||
Ban,
|
||||
CheckCircle,
|
||||
RefreshCw,
|
||||
Layers,
|
||||
Pencil,
|
||||
ShieldCheck,
|
||||
} from 'lucide-react';
|
||||
import { Users, RefreshCw, Layers, Pencil, ShieldCheck } from 'lucide-react';
|
||||
import {
|
||||
Table,
|
||||
Button,
|
||||
@@ -38,8 +28,6 @@ import {
|
||||
Popconfirm,
|
||||
Toast,
|
||||
Tooltip,
|
||||
Tabs,
|
||||
TabPane,
|
||||
Switch,
|
||||
} from '@/components/ui';
|
||||
import { useOrgMembers } from '../../hooks/org/useOrgMembers';
|
||||
@@ -48,6 +36,8 @@ import { renderQuota } from '../../helpers/render';
|
||||
import QuotaInput from '../../components/common/ui/QuotaInput';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import { Alert as AntAlert, Tabs as AntTabs } from 'antd';
|
||||
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
import OrgMemberAccounts from './OrgMemberAccounts';
|
||||
|
||||
@@ -323,116 +313,100 @@ const OrgMembers = ({
|
||||
[editingRemarkValue, updateMemberRemark, updateMemberInList, t],
|
||||
);
|
||||
|
||||
// 格式化加入时间
|
||||
// 格式化加入时间:原型显示绝对日期 YYYY/MM/DD(同一时间戳,仅格式化方式变化)
|
||||
const formatJoinTime = (timestamp) => {
|
||||
if (!timestamp) return '-';
|
||||
const date = new Date(timestamp * 1000);
|
||||
const now = new Date();
|
||||
const diffMs = now - date;
|
||||
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', {
|
||||
return new Date(timestamp * 1000).toLocaleDateString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
});
|
||||
};
|
||||
|
||||
// 列与渲染对齐原型 EnterpriseEmployees:首列 / 操作列固定,状态用 Switch(onChange 走原 handleStatusChange),
|
||||
// 备注独立成列(沿用原就地编辑交互),操作为 link 按钮
|
||||
const renderRemark = (record) => {
|
||||
const isEditingRemark = editingRemarkId === record.id;
|
||||
if (canWrite && isEditingRemark) {
|
||||
return (
|
||||
<Input
|
||||
size='small'
|
||||
value={editingRemarkValue}
|
||||
onChange={setEditingRemarkValue}
|
||||
placeholder={t('Enter 保存,Esc 取消')}
|
||||
maxLength={100}
|
||||
autoFocus
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
handleRemarkSave(record.id);
|
||||
}
|
||||
if (e.key === 'Escape') {
|
||||
editingRemarkIdRef.current = null;
|
||||
setEditingRemarkId(null);
|
||||
}
|
||||
}}
|
||||
onBlur={() => handleRemarkSave(record.id)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (canWrite) {
|
||||
return (
|
||||
<Tooltip
|
||||
content={record.remark ? t('点击编辑备注') : t('点击添加备注')}
|
||||
>
|
||||
<button
|
||||
type='button'
|
||||
className='oc-member-remark'
|
||||
onClick={() => {
|
||||
const current = record.remark || '';
|
||||
editingRemarkIdRef.current = record.id;
|
||||
originalRemarkRef.current = current;
|
||||
setEditingRemarkId(record.id);
|
||||
setEditingRemarkValue(current);
|
||||
}}
|
||||
>
|
||||
{record.remark ? (
|
||||
<span>{record.remark}</span>
|
||||
) : (
|
||||
<span className='oc-muted'>{t('添加备注')}</span>
|
||||
)}
|
||||
<Pencil size={12} aria-hidden />
|
||||
</button>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
return record.remark || '-';
|
||||
};
|
||||
|
||||
const memberColumns = [
|
||||
{
|
||||
title: t('用户'),
|
||||
dataIndex: 'display_name',
|
||||
width: 240,
|
||||
render: (text, record) => {
|
||||
const isEditingRemark = editingRemarkId === record.id;
|
||||
return (
|
||||
<div className='flex items-center gap-2.5'>
|
||||
<div className='flex-shrink-0 w-8 h-8 rounded-full bg-gradient-to-br from-brand-from to-brand-to flex items-center justify-center text-white text-xs font-bold'>
|
||||
{(text || record.username || '?').charAt(0).toUpperCase()}
|
||||
</div>
|
||||
<div className='min-w-0 flex-1'>
|
||||
<div className='font-medium text-gray-900 dark:text-white truncate'>
|
||||
{text || record.username}
|
||||
</div>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400 truncate'>
|
||||
{record.email}
|
||||
</div>
|
||||
{/* 备注区域 */}
|
||||
{canWrite && isEditingRemark ? (
|
||||
<Input
|
||||
size='small'
|
||||
value={editingRemarkValue}
|
||||
onChange={setEditingRemarkValue}
|
||||
placeholder={t('Enter 保存,Esc 取消')}
|
||||
maxLength={100}
|
||||
autoFocus
|
||||
style={{ marginTop: 4 }}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
handleRemarkSave(record.id);
|
||||
}
|
||||
if (e.key === 'Escape') {
|
||||
editingRemarkIdRef.current = null;
|
||||
setEditingRemarkId(null);
|
||||
}
|
||||
}}
|
||||
onBlur={() => handleRemarkSave(record.id)}
|
||||
/>
|
||||
) : canWrite ? (
|
||||
<Tooltip
|
||||
content={
|
||||
record.remark ? t('点击编辑备注') : t('点击添加备注')
|
||||
}
|
||||
>
|
||||
<div
|
||||
className='flex items-center gap-1 mt-0.5 cursor-pointer'
|
||||
onClick={() => {
|
||||
const current = record.remark || '';
|
||||
editingRemarkIdRef.current = record.id;
|
||||
originalRemarkRef.current = current;
|
||||
setEditingRemarkId(record.id);
|
||||
setEditingRemarkValue(current);
|
||||
}}
|
||||
>
|
||||
<Pencil
|
||||
size={10}
|
||||
className='text-gray-300 dark:text-gray-500 flex-shrink-0'
|
||||
/>
|
||||
{record.remark ? (
|
||||
<span className='text-xs text-amber-600 dark:text-amber-400 truncate max-w-[160px]'>
|
||||
{record.remark}
|
||||
</span>
|
||||
) : (
|
||||
<span className='text-xs text-gray-300 dark:text-gray-500 italic'>
|
||||
{t('添加备注')}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</Tooltip>
|
||||
) : record.remark ? (
|
||||
<div className='text-xs text-amber-600 dark:text-amber-400 truncate mt-0.5'>
|
||||
{record.remark}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
width: 180,
|
||||
fixed: 'left',
|
||||
render: (text, record) => (
|
||||
<div className='oc-member-identity'>
|
||||
<strong>{text || record.username}</strong>
|
||||
{record.email && <span>{record.email}</span>}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('角色'),
|
||||
dataIndex: 'role',
|
||||
width: 110,
|
||||
width: 150,
|
||||
render: (role, record) => {
|
||||
if (role === 'owner') return <Tag color='red'>{t('所有者')}</Tag>;
|
||||
if (role === 'owner')
|
||||
return (
|
||||
<Tag color='blue' bordered={false}>
|
||||
{t('所有者')}
|
||||
</Tag>
|
||||
);
|
||||
if (!canWrite) {
|
||||
return (
|
||||
<Tag
|
||||
bordered={false}
|
||||
color={
|
||||
role === 'admin'
|
||||
? 'blue'
|
||||
@@ -454,7 +428,7 @@ const OrgMembers = ({
|
||||
size='small'
|
||||
value={role}
|
||||
onChange={(v) => handleRoleChange(record.id, v)}
|
||||
style={{ width: 100 }}
|
||||
style={{ width: 120 }}
|
||||
>
|
||||
<Select.Option value='admin'>{t('Admin')}</Select.Option>
|
||||
<Select.Option value='dept_admin'>{t('Dept Admin')}</Select.Option>
|
||||
@@ -466,24 +440,18 @@ const OrgMembers = ({
|
||||
{
|
||||
title: t('已用额度'),
|
||||
dataIndex: 'used_quota',
|
||||
width: 100,
|
||||
render: (v) => (
|
||||
<span className='text-gray-700 dark:text-gray-300'>
|
||||
{renderQuota(v, 2)}
|
||||
</span>
|
||||
),
|
||||
width: 120,
|
||||
align: 'right',
|
||||
render: (v) => <span className='oc-number'>{renderQuota(v, 2)}</span>,
|
||||
},
|
||||
{
|
||||
title: t('额度上限'),
|
||||
dataIndex: 'quota_limit',
|
||||
width: 120,
|
||||
align: 'right',
|
||||
render: (v, record) => {
|
||||
if (!(v > 0)) {
|
||||
return (
|
||||
<span className='text-gray-400 dark:text-gray-500'>
|
||||
{t('不限')}
|
||||
</span>
|
||||
);
|
||||
return <span className='oc-number'>{t('不限')}</span>;
|
||||
}
|
||||
const periodic = ['daily', 'weekly', 'monthly'].includes(
|
||||
record.quota_period,
|
||||
@@ -497,15 +465,11 @@ const OrgMembers = ({
|
||||
? t('每月')
|
||||
: t('终身·不重置');
|
||||
return (
|
||||
<div>
|
||||
<div className='text-gray-700 dark:text-gray-300'>
|
||||
{renderQuota(v, 2)}
|
||||
</div>
|
||||
<div
|
||||
className={`text-[11px] ${periodic ? 'text-gray-400 dark:text-gray-500' : 'text-amber-500'}`}
|
||||
>
|
||||
<div className='oc-member-limit'>
|
||||
<span className='oc-number'>{renderQuota(v, 2)}</span>
|
||||
<small className={periodic ? '' : 'is-lifetime'}>
|
||||
{periodLabel}
|
||||
</div>
|
||||
</small>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
@@ -513,38 +477,27 @@ const OrgMembers = ({
|
||||
{
|
||||
title: t('模型限制'),
|
||||
dataIndex: 'model_limits_enabled',
|
||||
width: 90,
|
||||
render: (enabled, record) => (
|
||||
<span
|
||||
className={
|
||||
enabled
|
||||
? 'text-brand-deep dark:text-brand-from text-xs'
|
||||
: 'text-gray-400 dark:text-gray-500 text-xs'
|
||||
}
|
||||
>
|
||||
{enabled
|
||||
? `${record.model_limits.split(',').filter(Boolean).length} ${t('个模型')}`
|
||||
: t('不限')}
|
||||
</span>
|
||||
),
|
||||
width: 110,
|
||||
render: (enabled, record) =>
|
||||
enabled ? (
|
||||
`${record.model_limits.split(',').filter(Boolean).length} ${t('个模型')}`
|
||||
) : (
|
||||
<span className='oc-muted'>{t('不限')}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('分组'),
|
||||
dataIndex: 'groups',
|
||||
width: 120,
|
||||
width: 175,
|
||||
render: (_, record) => {
|
||||
const groups = parseMemberGroups(record);
|
||||
if (!groups.length) {
|
||||
return (
|
||||
<span className='text-xs text-gray-400 dark:text-gray-500'>
|
||||
{t('继承企业')}
|
||||
</span>
|
||||
);
|
||||
return <span className='oc-muted'>{t('无(继承企业)')}</span>;
|
||||
}
|
||||
return (
|
||||
<div className='flex flex-wrap gap-1'>
|
||||
<div className='oc-tags'>
|
||||
{groups.map((g) => (
|
||||
<Tag key={g} size='small' color='blue'>
|
||||
<Tag key={g} color='blue' bordered={false}>
|
||||
{g}
|
||||
</Tag>
|
||||
))}
|
||||
@@ -552,25 +505,50 @@ const OrgMembers = ({
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('备注'),
|
||||
dataIndex: 'remark',
|
||||
width: 165,
|
||||
render: (_, record) => renderRemark(record),
|
||||
},
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: 80,
|
||||
render: (status) => (
|
||||
<Tag color={status === 1 ? 'green' : 'red'}>
|
||||
{status === 1 ? t('正常') : t('禁用')}
|
||||
</Tag>
|
||||
),
|
||||
width: 92,
|
||||
render: (status, record) => {
|
||||
const locked = !canWrite || record.role === 'owner';
|
||||
return (
|
||||
<Tooltip
|
||||
content={
|
||||
record.role === 'owner'
|
||||
? t('所有者不可操作')
|
||||
: status === 1
|
||||
? t('禁用后该成员将无法使用企业资源')
|
||||
: t('启用该成员的企业访问权限')
|
||||
}
|
||||
>
|
||||
<Switch
|
||||
size='small'
|
||||
checked={status === 1}
|
||||
checkedText={t('启用')}
|
||||
uncheckedText={t('禁用')}
|
||||
disabled={locked}
|
||||
aria-label={`${record.display_name || record.username || ''}${t('状态')}`}
|
||||
onChange={(checked) =>
|
||||
handleStatusChange(record.id, checked ? 1 : 2)
|
||||
}
|
||||
/>
|
||||
</Tooltip>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('加入时间'),
|
||||
dataIndex: 'joined_at',
|
||||
width: 100,
|
||||
width: 125,
|
||||
render: (v) => (
|
||||
<Tooltip content={v ? new Date(v * 1000).toLocaleString('zh-CN') : '-'}>
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400 cursor-default'>
|
||||
{formatJoinTime(v)}
|
||||
</span>
|
||||
<span className='oc-number'>{formatJoinTime(v)}</span>
|
||||
</Tooltip>
|
||||
),
|
||||
},
|
||||
@@ -580,23 +558,18 @@ const OrgMembers = ({
|
||||
if (canWrite) {
|
||||
memberColumns.push({
|
||||
title: t('操作'),
|
||||
width: 360,
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
render: (_, record) => {
|
||||
if (record.role === 'owner') {
|
||||
return (
|
||||
<span className='text-xs text-gray-400 dark:text-gray-500 italic'>
|
||||
{t('所有者不可操作')}
|
||||
</span>
|
||||
);
|
||||
return <span className='oc-muted'>{t('所有者不可操作')}</span>;
|
||||
}
|
||||
const isSelf = Number(record.user_id) === currentUserId;
|
||||
return (
|
||||
<div className='flex items-center gap-1.5 flex-wrap'>
|
||||
<OrgRowActions>
|
||||
<Tooltip content={t('设置该成员的个人额度上限')}>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
icon={<Settings size={14} />}
|
||||
type='link'
|
||||
onClick={() => {
|
||||
setQuotaMemberId(record.id);
|
||||
setQuotaMemberName(
|
||||
@@ -612,9 +585,7 @@ const OrgMembers = ({
|
||||
</Tooltip>
|
||||
<Tooltip content={t('设置该成员可用的模型范围')}>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
icon={<Layers size={14} />}
|
||||
type='link'
|
||||
onClick={async () => {
|
||||
setModelLimitsMemberId(record.id);
|
||||
setModelLimitsMemberName(
|
||||
@@ -657,9 +628,7 @@ const OrgMembers = ({
|
||||
}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
icon={<Layers size={14} />}
|
||||
type='link'
|
||||
disabled={isSelf}
|
||||
onClick={() => {
|
||||
if (isSelf) return;
|
||||
@@ -677,9 +646,7 @@ const OrgMembers = ({
|
||||
{orgRole === 'owner' && record.role === 'admin' && (
|
||||
<Tooltip content={t('设置该管理员的细粒度权限')}>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
icon={<ShieldCheck size={14} />}
|
||||
type='link'
|
||||
onClick={() => {
|
||||
setPermMemberId(record.id);
|
||||
setPermMemberName(
|
||||
@@ -708,45 +675,17 @@ const OrgMembers = ({
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)}
|
||||
{record.status === 1 ? (
|
||||
<Tooltip content={t('禁用后该成员将无法使用企业资源')}>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
type='warning'
|
||||
icon={<Ban size={14} />}
|
||||
onClick={() => handleStatusChange(record.id, 2)}
|
||||
>
|
||||
{t('禁用')}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<Tooltip content={t('启用该成员的企业访问权限')}>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
type='primary'
|
||||
icon={<CheckCircle size={14} />}
|
||||
onClick={() => handleStatusChange(record.id, 1)}
|
||||
>
|
||||
{t('启用')}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)}
|
||||
<Tooltip content={t('从企业中移除该成员')}>
|
||||
<Popconfirm
|
||||
title={t('确定移除该成员?移除后该成员将失去企业访问权限。')}
|
||||
onConfirm={() => handleRemove(record.id)}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
type='danger'
|
||||
icon={<Trash2 size={14} />}
|
||||
/>
|
||||
<Button type='link' danger>
|
||||
{t('移除')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</OrgRowActions>
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -754,27 +693,39 @@ const OrgMembers = ({
|
||||
|
||||
const memberListContent = (
|
||||
<>
|
||||
{/* 管理员提示:当只有一个成员时显示 */}
|
||||
{/* 管理员提示:当只有一个成员时显示(原型无此状态 → Ant Design Alert 默认样式) */}
|
||||
{canWrite &&
|
||||
!loading &&
|
||||
members.length === 1 &&
|
||||
members[0]?.role === 'owner' && (
|
||||
<div className='mb-4 p-4 rounded-2xl bg-amber-50/80 border border-amber-200/70 text-amber-900 dark:bg-amber-500/10 dark:border-amber-500/20 dark:text-amber-100'>
|
||||
<p className='text-sm'>
|
||||
💡{' '}
|
||||
{t(
|
||||
'当前企业仅有您一位成员。成员可使用企业代码自助加入,或由系统管理员创建成员账号后即可在此管理成员角色、额度上限和访问权限。',
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<AntAlert
|
||||
className='oc-block-gap'
|
||||
type='info'
|
||||
showIcon
|
||||
message={t(
|
||||
'当前企业仅有您一位成员。成员可使用企业代码自助加入,或由系统管理员创建成员账号后即可在此管理成员角色、额度上限和访问权限。',
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<OrgPanel padding='p-2'>
|
||||
<OrgListCard
|
||||
title={t('员工列表')}
|
||||
tools={
|
||||
<Button
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => fetch(page)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<Table
|
||||
columns={memberColumns}
|
||||
dataSource={members}
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1500 }}
|
||||
empty={
|
||||
<div className='py-10 text-center'>
|
||||
<div className='inline-flex p-3 rounded-full bg-gray-100 dark:bg-neutral-800 mb-3'>
|
||||
@@ -790,49 +741,49 @@ const OrgMembers = ({
|
||||
pageSize: 20,
|
||||
total,
|
||||
onPageChange: setPage,
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
/>
|
||||
</OrgPanel>
|
||||
</OrgListCard>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='uc-page'>
|
||||
<div className='uc-page oc-page'>
|
||||
<OrgPageHeader
|
||||
icon={Users}
|
||||
title={t('员工管理')}
|
||||
subtitle={t('成员权限、额度配额与托管账号生命周期')}
|
||||
actions={
|
||||
showMemberList && (
|
||||
<Button
|
||||
icon={<RefreshCw size={14} />}
|
||||
onClick={() => fetch(page)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
{showMemberList && showAccounts ? (
|
||||
<OrgPanel>
|
||||
<Tabs type='button' activeKey={activeTab} onChange={setActiveTab}>
|
||||
<TabPane tab={t('员工权限')} itemKey='members'>
|
||||
<div className='pt-4'>{memberListContent}</div>
|
||||
</TabPane>
|
||||
<TabPane tab={t('员工账号')} itemKey='accounts'>
|
||||
<div className='pt-4'>
|
||||
// 原型 platform-list-tabs;原 Tabs 预渲染全部页签(lazyRender=false),员工账号页签保持随页面挂载
|
||||
<AntTabs
|
||||
className='oc-list-tabs'
|
||||
activeKey={activeTab}
|
||||
onChange={setActiveTab}
|
||||
items={[
|
||||
{
|
||||
key: 'members',
|
||||
label: t('员工权限'),
|
||||
forceRender: true,
|
||||
children: memberListContent,
|
||||
},
|
||||
{
|
||||
key: 'accounts',
|
||||
label: t('员工账号'),
|
||||
forceRender: true,
|
||||
children: (
|
||||
<OrgMemberAccounts
|
||||
orgId={orgId}
|
||||
orgRole={orgRole}
|
||||
embedded
|
||||
featureFlags={featureFlags}
|
||||
/>
|
||||
</div>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</OrgPanel>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
) : showMemberList ? (
|
||||
memberListContent
|
||||
) : showAccounts ? (
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { Button, Empty, Tag } from '@/components/ui';
|
||||
import { Button, Card, Empty, Tag, Typography } from 'antd';
|
||||
import { Cable, LockKeyhole } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { API } from '../../helpers/api';
|
||||
@@ -26,8 +26,14 @@ import {
|
||||
PageGuideDrawer,
|
||||
PageGuideTrigger,
|
||||
} from '../../components/common/PageGuide';
|
||||
import './org-connectors.css';
|
||||
import OrgBreadcrumb from './components/OrgBreadcrumb';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import './org-my-capabilities.css';
|
||||
|
||||
const confirmationLabels = {
|
||||
never: '无需确认',
|
||||
write: '写操作前确认',
|
||||
always: '每次调用都确认',
|
||||
};
|
||||
|
||||
const OrgMyConnectors = ({ orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -109,33 +115,58 @@ const OrgMyConnectors = ({ orgId }) => {
|
||||
],
|
||||
});
|
||||
return (
|
||||
<main className='org-connector-page'>
|
||||
<header className='org-connector-hero'>
|
||||
<div>
|
||||
<OrgBreadcrumb current={t('我的业务系统授权')} />
|
||||
<h1>{t('我的业务系统授权')}</h1>
|
||||
<p>{t('查看专家在任务中可代表你调用的业务系统、方法和确认策略。')}</p>
|
||||
</div>
|
||||
<div className='org-connector-actions'>
|
||||
<PageGuideTrigger guide={guide} />
|
||||
</div>
|
||||
</header>
|
||||
<main className='uc-page org-capabilities-page'>
|
||||
<OrgPageHeader
|
||||
title={t('我的业务系统授权')}
|
||||
subtitle={t('查看专家在任务中可代表你调用的业务系统、方法和确认策略。')}
|
||||
actions={<PageGuideTrigger guide={guide} />}
|
||||
/>
|
||||
<PageGuideDrawer guide={guide} />
|
||||
{loadError ? (
|
||||
<Empty title={t('授权列表加载失败')} description={loadError} />
|
||||
<Card>
|
||||
<Empty
|
||||
description={
|
||||
<>
|
||||
<Typography.Text>{t('授权列表加载失败')}</Typography.Text>
|
||||
<Typography.Paragraph type='secondary'>
|
||||
{loadError}
|
||||
</Typography.Paragraph>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</Card>
|
||||
) : items.length === 0 ? (
|
||||
<Empty
|
||||
title={t('当前没有 Connector 授权')}
|
||||
description={t('管理员发布授权并覆盖到你后会显示在这里。')}
|
||||
/>
|
||||
<Card>
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={
|
||||
<>
|
||||
<Typography.Text>
|
||||
{t('当前没有 Connector 授权')}
|
||||
</Typography.Text>
|
||||
<Typography.Paragraph type='secondary'>
|
||||
{t('管理员发布授权并覆盖到你后会显示在这里。')}
|
||||
</Typography.Paragraph>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</Card>
|
||||
) : (
|
||||
<section className='org-connector-grid'>
|
||||
<section className='org-capability-grid'>
|
||||
{items.map((item) => (
|
||||
<article className='org-connector-card' key={item.grant.id}>
|
||||
<div className='org-connector-card-top'>
|
||||
<span className='org-connector-icon'>
|
||||
<Card className='org-capability-card' key={item.grant.id}>
|
||||
<div className='org-capability-card-head'>
|
||||
<span className='org-capability-icon'>
|
||||
<Cable size={20} />
|
||||
</span>
|
||||
<div className='org-capability-card-name'>
|
||||
<Typography.Title level={5}>
|
||||
{item.connector_name}
|
||||
</Typography.Title>
|
||||
<Typography.Text type='secondary'>
|
||||
{item.definition_name}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
<Tag
|
||||
color={
|
||||
item.grant.access_level === 'write' ? 'orange' : 'green'
|
||||
@@ -144,23 +175,29 @@ const OrgMyConnectors = ({ orgId }) => {
|
||||
{item.grant.access_level}
|
||||
</Tag>
|
||||
</div>
|
||||
<h3>{item.connector_name}</h3>
|
||||
<p>{item.definition_name}</p>
|
||||
<div className='org-connector-tags'>
|
||||
<div className='org-capability-methods'>
|
||||
{item.methods.map((method) => (
|
||||
<Tag key={method}>{method}</Tag>
|
||||
))}
|
||||
</div>
|
||||
<p>
|
||||
<LockKeyhole size={14} /> {t('确认策略')}:{' '}
|
||||
{item.grant.confirmation_policy}
|
||||
</p>
|
||||
<Button disabled={!item.revocable}>
|
||||
{item.revocable
|
||||
? t('撤销个人委托')
|
||||
: t('企业服务账号由管理员管理')}
|
||||
</Button>
|
||||
</article>
|
||||
<div className='org-capability-confirmation'>
|
||||
<LockKeyhole size={14} aria-hidden='true' />
|
||||
<Typography.Text type='secondary'>
|
||||
{t('确认策略')}:{' '}
|
||||
{t(
|
||||
confirmationLabels[item.grant.confirmation_policy] ||
|
||||
item.grant.confirmation_policy,
|
||||
)}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
<div className='org-capability-card-footer'>
|
||||
<Button disabled={!item.revocable}>
|
||||
{item.revocable
|
||||
? t('撤销个人委托')
|
||||
: t('企业服务账号由管理员管理')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
|
||||
@@ -18,25 +18,36 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Switch, Toast, Typography } from '@/components/ui';
|
||||
import { LockKeyhole } from 'lucide-react';
|
||||
import { Card, Empty, Switch, Tag, Tooltip, Typography } from 'antd';
|
||||
import { Toast } from '@/components/ui';
|
||||
import { Link2, LockKeyhole, Sparkles } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { API } from '../../helpers';
|
||||
import {
|
||||
AssignmentModeTag,
|
||||
ScopeSourceBadge,
|
||||
SkillEmptyGuide,
|
||||
} from '../../components/skill';
|
||||
import {
|
||||
usePageGuide,
|
||||
PageGuideDrawer,
|
||||
PageGuideTrigger,
|
||||
} from '../../components/common/PageGuide';
|
||||
import './org-skills.css';
|
||||
import OrgBreadcrumb from './components/OrgBreadcrumb';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import './org-my-capabilities.css';
|
||||
|
||||
const { Title, Paragraph, Text } = Typography;
|
||||
|
||||
const modes = {
|
||||
required_locked: { label: '必需锁定', color: 'warning' },
|
||||
default_on: { label: '默认开启', color: 'processing' },
|
||||
recommended: { label: '推荐', color: 'success' },
|
||||
optional: { label: '可选', color: 'default' },
|
||||
};
|
||||
const scopes = {
|
||||
org: '企业',
|
||||
department: '部门',
|
||||
dept: '部门',
|
||||
project: '项目',
|
||||
role: '角色',
|
||||
member: '成员',
|
||||
};
|
||||
|
||||
const OrgMySkills = ({ orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
const headers = useMemo(() => ({ 'X-Org-Id': String(orgId) }), [orgId]);
|
||||
@@ -114,67 +125,93 @@ const OrgMySkills = ({ orgId }) => {
|
||||
],
|
||||
});
|
||||
return (
|
||||
<main className='org-skills-page'>
|
||||
<header className='org-skills-hero'>
|
||||
<div>
|
||||
<OrgBreadcrumb current={t('我的技能')} />
|
||||
<Title heading={3}>{t('我的技能')}</Title>
|
||||
<Paragraph>
|
||||
{t(
|
||||
'这里展示与任务运行时相同的有效能力集,以及每项技能为什么对你生效。',
|
||||
)}
|
||||
</Paragraph>
|
||||
</div>
|
||||
<div className='org-skills-hero-actions'>
|
||||
<PageGuideTrigger guide={guide} />
|
||||
</div>
|
||||
</header>
|
||||
<main className='uc-page org-capabilities-page'>
|
||||
<OrgPageHeader
|
||||
title={t('我的技能')}
|
||||
subtitle={t(
|
||||
'这里展示与任务运行时相同的有效能力集,以及每项技能为什么对你生效。',
|
||||
)}
|
||||
actions={<PageGuideTrigger guide={guide} />}
|
||||
/>
|
||||
<PageGuideDrawer guide={guide} />
|
||||
{items.length === 0 ? (
|
||||
<SkillEmptyGuide
|
||||
title={t('当前没有可用技能')}
|
||||
description={t('企业管理员启用并分发后会显示在这里。')}
|
||||
/>
|
||||
<Card>
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={
|
||||
<>
|
||||
<Text>{t('当前没有可用技能')}</Text>
|
||||
<Paragraph type='secondary'>
|
||||
{t('企业管理员启用并分发后会显示在这里。')}
|
||||
</Paragraph>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</Card>
|
||||
) : (
|
||||
<section className='org-my-skills'>
|
||||
<section className='org-capability-grid'>
|
||||
{items
|
||||
.filter((item) => item.mode !== 'forbidden')
|
||||
.map((item) => {
|
||||
const locked = item.mode === 'required_locked';
|
||||
const mode = modes[item.mode] || {
|
||||
label: item.mode,
|
||||
color: 'default',
|
||||
};
|
||||
return (
|
||||
<article key={item.skill_id}>
|
||||
<div>
|
||||
<span className='org-my-skill-title'>
|
||||
{locked && <LockKeyhole size={16} />}
|
||||
<Text strong>
|
||||
{item.customization?.display_name || item.canonical_id}
|
||||
</Text>
|
||||
<AssignmentModeTag mode={item.mode} />
|
||||
<Card key={item.skill_id} className='org-capability-card'>
|
||||
<div className='org-capability-card-head'>
|
||||
<span className='org-capability-icon'>
|
||||
<Sparkles size={20} />
|
||||
</span>
|
||||
<Paragraph>
|
||||
{item.customization?.description_zh ||
|
||||
item.customization?.usage_boundary ||
|
||||
t('企业已审核的方法能力')}
|
||||
</Paragraph>
|
||||
<div className='org-my-skill-sources'>
|
||||
{(item.sources || []).map((source) => (
|
||||
<ScopeSourceBadge
|
||||
key={source.id}
|
||||
source={`${source.scope_type}:${source.scope_id || source.scope_value || 'all'}`}
|
||||
detail={`${source.mode} / ${source.activation}`}
|
||||
/>
|
||||
))}
|
||||
<div className='org-capability-card-name'>
|
||||
<Title level={5}>
|
||||
{item.customization?.display_name || item.canonical_id}
|
||||
</Title>
|
||||
<Text type='secondary'>v#{item.version_id}</Text>
|
||||
</div>
|
||||
<Tag
|
||||
color={mode.color}
|
||||
icon={locked ? <LockKeyhole size={12} /> : undefined}
|
||||
>
|
||||
{t(mode.label)}
|
||||
</Tag>
|
||||
</div>
|
||||
<div>
|
||||
<Text type='tertiary'>v#{item.version_id}</Text>
|
||||
<Paragraph
|
||||
type='secondary'
|
||||
className='org-capability-description'
|
||||
>
|
||||
{item.customization?.description_zh ||
|
||||
item.customization?.usage_boundary ||
|
||||
t('企业已审核的方法能力')}
|
||||
</Paragraph>
|
||||
<div className='org-capability-sources'>
|
||||
{(item.sources || []).map((source) => (
|
||||
<Tooltip
|
||||
key={source.id}
|
||||
title={`${t(modes[source.mode]?.label || source.mode)} / ${source.activation}`}
|
||||
>
|
||||
<Tag icon={<Link2 size={12} />}>
|
||||
{t(scopes[source.scope_type] || source.scope_type)} ·{' '}
|
||||
{source.scope_id || source.scope_value || t('全部')}
|
||||
</Tag>
|
||||
</Tooltip>
|
||||
))}
|
||||
</div>
|
||||
<div className='org-capability-card-footer'>
|
||||
<Text type='secondary'>
|
||||
{t(item.enabled ? '已启用' : '已停用')}
|
||||
</Text>
|
||||
<Switch
|
||||
aria-label={
|
||||
item.customization?.display_name || item.canonical_id
|
||||
}
|
||||
disabled={locked}
|
||||
checked={item.enabled}
|
||||
onChange={(enabled) => choose(item, enabled)}
|
||||
/>
|
||||
</div>
|
||||
</article>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
|
||||
@@ -19,22 +19,14 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React, { useCallback, useContext, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Button,
|
||||
InputNumber,
|
||||
Spin,
|
||||
Tabs,
|
||||
TabPane,
|
||||
Typography,
|
||||
} from '@/components/ui';
|
||||
import {
|
||||
Bell,
|
||||
Building2,
|
||||
KeyRound,
|
||||
Pencil,
|
||||
UserRound,
|
||||
UserCog,
|
||||
Wallet,
|
||||
} from 'lucide-react';
|
||||
Avatar as AntAvatar,
|
||||
Card as AntCard,
|
||||
Progress as AntProgress,
|
||||
Tabs as AntTabs,
|
||||
Tag as AntTag,
|
||||
} from 'antd';
|
||||
import { Button, InputNumber, Spin, Typography } from '@/components/ui';
|
||||
import { UserCog } from 'lucide-react';
|
||||
import { API } from '../../helpers/api';
|
||||
import {
|
||||
showError,
|
||||
@@ -44,13 +36,16 @@ import {
|
||||
USER_AVATAR_TYPES,
|
||||
getAvatarPresetById,
|
||||
getDefaultAvatarPresetId,
|
||||
getUserAvatarUrl,
|
||||
} from '../../helpers';
|
||||
import { renderQuota } from '../../helpers/render';
|
||||
import { UserContext } from '../../context/User';
|
||||
import NotifyChannelForm from '../../components/settings/NotifyChannelForm';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import OrgAvatarSection from './components/OrgAvatarSection';
|
||||
import AvatarSection from '../../components/settings/personal/sections/AvatarSection';
|
||||
import SectionHeader from '../../components/settings/personal/components/SectionHeader';
|
||||
import '../../components/settings/personal/personal-settings.css';
|
||||
import '../../styles/org-center.css';
|
||||
import OrgNicknameModal from './components/OrgNicknameModal';
|
||||
import OrgPasswordModal from './components/OrgPasswordModal';
|
||||
|
||||
@@ -82,20 +77,6 @@ const quotaPeriodHint = (t, period) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 信息行:label + 右侧内容(个人资料/企业身份卡片共用)
|
||||
const InfoRow = ({ label, children, last = false }) => (
|
||||
<div
|
||||
className={`flex items-center justify-between gap-3 py-3 ${
|
||||
last ? '' : 'border-b border-[var(--border-subtle)]'
|
||||
}`}
|
||||
>
|
||||
<Text type='tertiary' className='flex-shrink-0'>
|
||||
{label}
|
||||
</Text>
|
||||
<div className='flex items-center gap-2 min-w-0'>{children}</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
/*
|
||||
* 成员个人设置页(/org/personal-settings,全员可见)。
|
||||
* 企业中心是独立空间:改密/昵称走企业端接口,通知为企业维度的成员配额预警,
|
||||
@@ -302,8 +283,12 @@ const OrgPersonalSettings = ({ orgId }) => {
|
||||
),
|
||||
);
|
||||
// 进度条随用量升温:正常品牌色,≥80% 转琥珀,≥95% 转红,给成员用尽预警
|
||||
const quotaBarClass =
|
||||
usedPct >= 95 ? 'bg-red-500' : usedPct >= 80 ? 'bg-amber-500' : 'bg-brand';
|
||||
const quotaBarColor =
|
||||
usedPct >= 95
|
||||
? 'var(--ui-color-danger)'
|
||||
: usedPct >= 80
|
||||
? 'var(--ui-color-warning)'
|
||||
: 'var(--oc-brand)';
|
||||
const displayName =
|
||||
member.display_name ||
|
||||
userState?.user?.display_name ||
|
||||
@@ -318,189 +303,209 @@ const OrgPersonalSettings = ({ orgId }) => {
|
||||
);
|
||||
}
|
||||
|
||||
// 个人资料页签(原型 profile 面板):昵称 / 密码设置行 + 个人配额卡;企业身份信息归入资料头卡
|
||||
const profilePanel = (
|
||||
<div className='oc-ps-panel'>
|
||||
<SectionHeader
|
||||
title={t('基本资料')}
|
||||
description={t('管理企业内展示的个人信息')}
|
||||
/>
|
||||
<div className='ui-settings-rows'>
|
||||
<div className='ui-settings-row'>
|
||||
<div className='ui-settings-row-text'>
|
||||
<h3>{t('昵称管理')}</h3>
|
||||
<p>
|
||||
{t('当前昵称:')}
|
||||
{displayName || t('未设置')}
|
||||
</p>
|
||||
</div>
|
||||
<div className='ui-settings-row-actions'>
|
||||
<Button onClick={() => setNickModal(true)}>{t('修改昵称')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className='ui-settings-row'>
|
||||
<div className='ui-settings-row-text'>
|
||||
<h3>{t('密码管理')}</h3>
|
||||
<p>{t('定期更改密码可以提高账户安全性')}</p>
|
||||
</div>
|
||||
<div className='ui-settings-row-actions'>
|
||||
<Button onClick={() => setPwdModal(true)}>{t('修改密码')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='oc-ps-info-grid'>
|
||||
<AntCard size='small' title={t('个人配额')}>
|
||||
{quotaLimit > 0 ? (
|
||||
<>
|
||||
<div className='oc-ps-quota'>
|
||||
<span>{t('剩余可用')}</span>
|
||||
<strong>{renderQuota(remainQuota)}</strong>
|
||||
</div>
|
||||
<AntProgress
|
||||
percent={usedPct}
|
||||
showInfo={false}
|
||||
strokeColor={quotaBarColor}
|
||||
/>
|
||||
<div className='oc-ps-quota-meta'>
|
||||
<span>
|
||||
{t('已用')} {renderQuota(usedQuota)} / {t('总额')}{' '}
|
||||
{renderQuota(quotaLimit)}({usedPct}%)
|
||||
</span>
|
||||
{isPeriodic && (
|
||||
<span>{quotaPeriodHint(t, myQuota.quota_period)}</span>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className='oc-ps-unlimited'>
|
||||
<AntTag color='gold' bordered={false}>
|
||||
{t('不限额')}
|
||||
</AntTag>
|
||||
<span>{t('企业未对你设置配额上限')}</span>
|
||||
</div>
|
||||
)}
|
||||
</AntCard>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
// 通知设置页签(原型 notice 面板):渠道表单 + 预警阈值;保存回调不变
|
||||
const notifyPanel = (
|
||||
<div className='oc-ps-panel'>
|
||||
<SectionHeader
|
||||
title={t('配额预警通知')}
|
||||
description={t(
|
||||
'企业分配给你的额度即将用尽或已用尽时,通过以下渠道提醒你',
|
||||
)}
|
||||
extra={
|
||||
<Button
|
||||
theme='solid'
|
||||
loading={savingNotify}
|
||||
onClick={saveNotifySettings}
|
||||
>
|
||||
{t('保存通知设置')}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<div className='oc-ps-notice-form'>
|
||||
<NotifyChannelForm
|
||||
value={notifyValue}
|
||||
onChange={setNotifyValue}
|
||||
channels={['email', 'webhook']}
|
||||
emailPlaceholder={t('必填,用于接收预警通知')}
|
||||
/>
|
||||
<div className='oc-ps-threshold'>
|
||||
<label>{t('预警阈值')}</label>
|
||||
{quotaLimit > 0 ? (
|
||||
<>
|
||||
<InputNumber
|
||||
value={alertThreshold}
|
||||
onChange={(v) => setAlertThreshold(v)}
|
||||
min={0}
|
||||
step={1000}
|
||||
style={{ width: '100%', maxWidth: 260 }}
|
||||
/>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('剩余额度低于该值时提醒,0 表示关闭')}
|
||||
{Number(alertThreshold) > 0 &&
|
||||
` · ${t('约合')} ${renderQuota(Number(alertThreshold))}`}
|
||||
{` · ${t('当前剩余')} ${renderQuota(remainQuota)}`}
|
||||
</Text>
|
||||
</>
|
||||
) : (
|
||||
<Text type='tertiary'>
|
||||
{t('企业未对你设置配额上限,无需配置预警')}
|
||||
</Text>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='uc-page'>
|
||||
<div className='uc-page oc-page ui-personal-settings oc-personal-settings'>
|
||||
<OrgPageHeader
|
||||
icon={UserCog}
|
||||
title={t('个人设置')}
|
||||
subtitle={t('管理你的头像、昵称、密码与通知偏好')}
|
||||
/>
|
||||
|
||||
<Tabs type='line' className='mt-2'>
|
||||
<TabPane tab={t('个人资料')} itemKey='profile'>
|
||||
{/* 头像设置上移至页面上半部分,作为视觉锚点,保存走企业端接口 */}
|
||||
<div className='mt-4'>
|
||||
<OrgAvatarSection
|
||||
t={t}
|
||||
userState={userState}
|
||||
avatarSettings={avatarSettings}
|
||||
handleAvatarSettingChange={handleAvatarSettingChange}
|
||||
saveAvatarSettings={saveAvatarSettings}
|
||||
saving={savingAvatar}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 基本资料 / 企业身份 / 个人配额:三栏均分,卡片等高,避免高度失衡 */}
|
||||
<div className='mt-4 grid grid-cols-1 lg:grid-cols-3 gap-4'>
|
||||
{/* 基本资料:昵称 + 登录密码(复用工作台同款弹窗与企业端接口) */}
|
||||
<OrgPanel title={t('基本资料')} icon={UserRound} padding='px-5 py-2'>
|
||||
<InfoRow label={t('昵称')}>
|
||||
<Text className='truncate'>{displayName || t('未设置')}</Text>
|
||||
<Button
|
||||
theme='light'
|
||||
size='small'
|
||||
icon={<Pencil size={13} />}
|
||||
onClick={() => setNickModal(true)}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
</InfoRow>
|
||||
<InfoRow label={t('登录密码')} last>
|
||||
<Text type='tertiary'>••••••••</Text>
|
||||
<Button
|
||||
theme='light'
|
||||
size='small'
|
||||
icon={<KeyRound size={13} />}
|
||||
onClick={() => setPwdModal(true)}
|
||||
>
|
||||
{t('修改密码')}
|
||||
</Button>
|
||||
</InfoRow>
|
||||
</OrgPanel>
|
||||
|
||||
{/* 企业身份只读信息(数据源 /api/org/me/summary,与工作台一致) */}
|
||||
<OrgPanel title={t('企业身份')} icon={Building2} padding='px-5 py-2'>
|
||||
<InfoRow label={t('所属企业')}>
|
||||
<Text className='truncate'>
|
||||
{summary?.organization?.name || '-'}
|
||||
</Text>
|
||||
</InfoRow>
|
||||
<InfoRow label={t('我的角色')}>
|
||||
<span className='inline-flex items-center rounded-full bg-brand/10 text-brand px-2.5 py-0.5 text-xs font-medium'>
|
||||
{roleLabel(t, member.role)}
|
||||
</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t('所属部门')} last>
|
||||
<Text className='truncate'>
|
||||
{member.department_name || t('未分配')}
|
||||
</Text>
|
||||
</InfoRow>
|
||||
</OrgPanel>
|
||||
|
||||
{/* 个人配额:成员高频关注项,抽成带进度条的重点块 */}
|
||||
<OrgPanel title={t('个人配额')} icon={Wallet} padding='p-5'>
|
||||
{quotaLimit > 0 ? (
|
||||
<div>
|
||||
<div className='flex items-end justify-between gap-3'>
|
||||
<div className='min-w-0'>
|
||||
<div className='text-xs text-[var(--text-secondary)]'>
|
||||
{t('剩余可用')}
|
||||
</div>
|
||||
<div className='mt-0.5 text-2xl font-semibold text-[var(--text-primary)] truncate'>
|
||||
{renderQuota(remainQuota)}
|
||||
</div>
|
||||
</div>
|
||||
<div className='shrink-0 text-right text-xs text-gray-500 dark:text-gray-400 leading-relaxed'>
|
||||
<div>
|
||||
{t('已用')} {renderQuota(usedQuota)}
|
||||
</div>
|
||||
<div>
|
||||
{t('总额')} {renderQuota(quotaLimit)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='mt-3 h-2 w-full overflow-hidden rounded-full bg-gray-100 dark:bg-white/[0.08]'>
|
||||
<div
|
||||
className={`h-full rounded-full transition-all duration-300 ${quotaBarClass}`}
|
||||
style={{ width: `${usedPct}%` }}
|
||||
/>
|
||||
</div>
|
||||
<div className='mt-2 flex items-center justify-between text-xs'>
|
||||
<span className='text-gray-500 dark:text-gray-400'>
|
||||
{t('已用')} {usedPct}%
|
||||
</span>
|
||||
{isPeriodic && (
|
||||
<span className='text-brand font-medium'>
|
||||
{quotaPeriodHint(t, myQuota.quota_period)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className='flex items-center gap-2 py-1.5'>
|
||||
<span className='inline-flex items-center rounded-full bg-brand/10 text-brand px-2.5 py-0.5 text-xs font-medium'>
|
||||
{t('不限额')}
|
||||
</span>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('企业未对你设置配额上限')}
|
||||
</Text>
|
||||
</div>
|
||||
)}
|
||||
</OrgPanel>
|
||||
</div>
|
||||
</TabPane>
|
||||
|
||||
<TabPane
|
||||
tab={t('通知设置')}
|
||||
itemKey='notify'
|
||||
disabled={isSuperAdminView}
|
||||
>
|
||||
<OrgPanel
|
||||
title={t('配额预警通知')}
|
||||
subtitle={t(
|
||||
'企业分配给你的额度即将用尽或已用尽时,通过以下渠道提醒你',
|
||||
)}
|
||||
icon={Bell}
|
||||
padding='p-5'
|
||||
className='mt-4'
|
||||
actions={
|
||||
<Button
|
||||
theme='solid'
|
||||
loading={savingNotify}
|
||||
onClick={saveNotifySettings}
|
||||
>
|
||||
{t('保存通知设置')}
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<NotifyChannelForm
|
||||
value={notifyValue}
|
||||
onChange={setNotifyValue}
|
||||
channels={['email', 'webhook']}
|
||||
emailPlaceholder={t('必填,用于接收预警通知')}
|
||||
/>
|
||||
|
||||
<div className='mt-5 pt-4 border-t border-[var(--border-subtle)]'>
|
||||
<label className='block text-sm font-medium text-[var(--text-primary)] mb-2'>
|
||||
{t('预警阈值')}
|
||||
</label>
|
||||
{quotaLimit > 0 ? (
|
||||
<>
|
||||
<InputNumber
|
||||
value={alertThreshold}
|
||||
onChange={(v) => setAlertThreshold(v)}
|
||||
min={0}
|
||||
step={1000}
|
||||
style={{ width: '100%', maxWidth: 260 }}
|
||||
/>
|
||||
<div className='mt-2'>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('剩余额度低于该值时提醒,0 表示关闭')}
|
||||
{Number(alertThreshold) > 0 &&
|
||||
` · ${t('约合')} ${renderQuota(Number(alertThreshold))}`}
|
||||
{` · ${t('当前剩余')} ${renderQuota(remainQuota)}`}
|
||||
</Text>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<Text type='tertiary'>
|
||||
{t('企业未对你设置配额上限,无需配置预警')}
|
||||
</Text>
|
||||
)}
|
||||
{/* 资料头卡(原型 .ps-profile):头像 / 昵称 / 角色 / 企业 · 部门 + 配额概览,数据源 /api/org/me/summary */}
|
||||
<AntCard className='ui-personal-profile'>
|
||||
<div className='ui-profile-identity'>
|
||||
<span className='ui-profile-avatar'>
|
||||
<AntAvatar
|
||||
shape='square'
|
||||
size={54}
|
||||
src={getUserAvatarUrl(userState?.user)}
|
||||
>
|
||||
{(displayName || '?').slice(0, 2).toUpperCase()}
|
||||
</AntAvatar>
|
||||
</span>
|
||||
<div className='ui-profile-meta'>
|
||||
<div className='ui-profile-name'>
|
||||
<strong>{displayName || t('未设置')}</strong>
|
||||
<AntTag color='gold' bordered={false}>
|
||||
{roleLabel(t, member.role)}
|
||||
</AntTag>
|
||||
</div>
|
||||
</OrgPanel>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
<div className='ui-profile-sub'>
|
||||
<span>{summary?.organization?.name || '-'}</span>
|
||||
<span aria-hidden='true'>·</span>
|
||||
<span>{member.department_name || t('部门未分配')}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='ui-profile-stats'>
|
||||
<div>
|
||||
<span>{t('剩余配额')}</span>
|
||||
<strong>
|
||||
{quotaLimit > 0 ? renderQuota(remainQuota) : t('不限额')}
|
||||
</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>{t('已用额度')}</span>
|
||||
<strong>{renderQuota(usedQuota)}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</AntCard>
|
||||
|
||||
{/* 设置卡(原型 .ps-workspace):头像设置 / 个人资料 / 通知设置 */}
|
||||
<AntCard className='ui-personal-content'>
|
||||
<AntTabs
|
||||
defaultActiveKey='avatar'
|
||||
items={[
|
||||
{
|
||||
key: 'avatar',
|
||||
label: t('头像设置'),
|
||||
forceRender: true,
|
||||
children: (
|
||||
<AvatarSection
|
||||
t={t}
|
||||
userState={userState}
|
||||
avatarSettings={avatarSettings}
|
||||
handleAvatarSettingChange={handleAvatarSettingChange}
|
||||
saveAvatarSettings={saveAvatarSettings}
|
||||
savingAvatarSettings={savingAvatar}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'profile',
|
||||
label: t('个人资料'),
|
||||
forceRender: true,
|
||||
children: profilePanel,
|
||||
},
|
||||
{
|
||||
key: 'notify',
|
||||
label: t('通知设置'),
|
||||
disabled: isSuperAdminView,
|
||||
forceRender: true,
|
||||
children: notifyPanel,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</AntCard>
|
||||
|
||||
<OrgNicknameModal
|
||||
visible={nickModal}
|
||||
|
||||
@@ -18,6 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Switch } from 'antd';
|
||||
import {
|
||||
Table,
|
||||
Button,
|
||||
@@ -27,11 +28,11 @@ import {
|
||||
Tag,
|
||||
Select,
|
||||
} from '@/components/ui';
|
||||
import { RefreshCw, Plus, Users } from 'lucide-react';
|
||||
import { RefreshCw, Plus } from 'lucide-react';
|
||||
import { API } from '../../helpers/api';
|
||||
import { showError, collectPagedItems } from '../../helpers';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
import OrgScopedLimitButtons from './components/OrgScopedLimitButtons';
|
||||
|
||||
@@ -42,6 +43,7 @@ const OrgProjects = ({ orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
const [list, setList] = useState([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [updatingProjectId, setUpdatingProjectId] = useState(null);
|
||||
const [members, setMembers] = useState([]); // 企业全部成员(用于成员选择)
|
||||
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
@@ -53,7 +55,7 @@ const OrgProjects = ({ orgId }) => {
|
||||
const [addMemberIds, setAddMemberIds] = useState([]); // 支持一次添加多个成员
|
||||
const [addMemberRole, setAddMemberRole] = useState('project_member');
|
||||
|
||||
const [tokenModal, setTokenModal] = useState(null); // 当前管理令牌的项目
|
||||
const [tokenModal, setTokenModal] = useState(null); // 当前管理密钥的项目
|
||||
const [orgTokens, setOrgTokens] = useState([]);
|
||||
|
||||
const fetchList = useCallback(async () => {
|
||||
@@ -158,19 +160,34 @@ const OrgProjects = ({ orgId }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleDisable = async (record) => {
|
||||
const handleStatusChange = async (record, enabled) => {
|
||||
if (updatingProjectId !== null) return;
|
||||
setUpdatingProjectId(record.id);
|
||||
try {
|
||||
const res = await API.delete(`/api/org/project/${record.id}`, {
|
||||
headers: getOrgHeaders(orgId),
|
||||
});
|
||||
const url = `/api/org/project/${record.id}`;
|
||||
const config = { headers: getOrgHeaders(orgId) };
|
||||
const res = enabled
|
||||
? await API.put(
|
||||
url,
|
||||
{ code: record.code, name: record.name, status: 1 },
|
||||
config,
|
||||
)
|
||||
: await API.delete(url, config);
|
||||
if (res.data.success) {
|
||||
Toast.success(t('项目已停用'));
|
||||
fetchList();
|
||||
Toast.success(t('项目已更新'));
|
||||
setList((items) =>
|
||||
items.map((item) =>
|
||||
item.id === record.id ? { ...item, status: enabled ? 1 : 2 } : item,
|
||||
),
|
||||
);
|
||||
await fetchList();
|
||||
} else {
|
||||
showError(res.data.message);
|
||||
}
|
||||
} catch (err) {
|
||||
showError(err.message);
|
||||
} finally {
|
||||
setUpdatingProjectId(null);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -287,104 +304,116 @@ const OrgProjects = ({ orgId }) => {
|
||||
}));
|
||||
}, [members, projectMembers]);
|
||||
|
||||
// 列宽与渲染对齐原型 EnterpriseProjects(150/350/120/140/300,scroll.x 1060);
|
||||
const columns = [
|
||||
{ title: t('项目编码'), dataIndex: 'code' },
|
||||
{ title: t('项目名称'), dataIndex: 'name' },
|
||||
{
|
||||
title: t('项目编码'),
|
||||
dataIndex: 'code',
|
||||
width: 150,
|
||||
render: (v) => <span className='oc-number'>{v}</span>,
|
||||
},
|
||||
{ title: t('项目名称'), dataIndex: 'name', width: 350 },
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: 90,
|
||||
render: (v) => (
|
||||
<Tag color={v === 1 ? 'green' : 'grey'}>
|
||||
{v === 1 ? t('启用') : t('停用')}
|
||||
</Tag>
|
||||
width: 120,
|
||||
render: (v, record) => (
|
||||
<Popconfirm
|
||||
title={t('确认停用该项目?')}
|
||||
content={t('停用后保留历史,不再接受新调用绑定')}
|
||||
disabled={v !== 1 || updatingProjectId !== null}
|
||||
onConfirm={() => handleStatusChange(record, false)}
|
||||
>
|
||||
<Switch
|
||||
size='small'
|
||||
checked={v === 1}
|
||||
checkedChildren={t('启用')}
|
||||
unCheckedChildren={t('禁用')}
|
||||
aria-label={`${record.name} ${t('状态')}`}
|
||||
loading={updatingProjectId === record.id}
|
||||
disabled={updatingProjectId !== null}
|
||||
onChange={(checked) => {
|
||||
if (checked) handleStatusChange(record, true);
|
||||
}}
|
||||
/>
|
||||
</Popconfirm>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('到期时间'),
|
||||
dataIndex: 'expired_at',
|
||||
width: 120,
|
||||
width: 140,
|
||||
render: (v) => (v ? new Date(v * 1000).toLocaleDateString() : '-'),
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 420,
|
||||
width: 300,
|
||||
render: (_, record) => (
|
||||
<div className='flex items-center gap-2 flex-wrap'>
|
||||
<OrgRowActions>
|
||||
<OrgScopedLimitButtons
|
||||
orgId={orgId}
|
||||
record={record}
|
||||
apiBase='/api/org/project'
|
||||
scopeLabel='项目'
|
||||
onSaved={fetchList}
|
||||
variant='link'
|
||||
/>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
icon={<Users size={14} />}
|
||||
onClick={() => openMembers(record)}
|
||||
>
|
||||
<Button type='link' onClick={() => openMembers(record)}>
|
||||
{t('成员')}
|
||||
</Button>
|
||||
<Button size='small' theme='light' onClick={() => openTokens(record)}>
|
||||
{t('令牌')}
|
||||
<Button type='link' onClick={() => openTokens(record)}>
|
||||
{t('密钥')}
|
||||
</Button>
|
||||
<Button size='small' theme='light' onClick={() => openEdit(record)}>
|
||||
<Button type='link' onClick={() => openEdit(record)}>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
{record.status === 1 && (
|
||||
<Popconfirm
|
||||
title={t('确认停用该项目?')}
|
||||
content={t('停用后保留历史,不再接受新调用绑定')}
|
||||
onConfirm={() => handleDisable(record)}
|
||||
>
|
||||
<Button size='small' theme='light' type='danger'>
|
||||
{t('停用')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
)}
|
||||
</div>
|
||||
</OrgRowActions>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className='uc-page'>
|
||||
<div className='uc-page oc-page'>
|
||||
<OrgPageHeader
|
||||
title={t('项目管理')}
|
||||
subtitle={t('项目成员与项目预算')}
|
||||
actions={
|
||||
subtitle={t('管理项目成员、模型范围与密钥归属')}
|
||||
/>
|
||||
|
||||
<OrgListCard
|
||||
title={t('项目列表')}
|
||||
tools={
|
||||
<>
|
||||
<Button
|
||||
theme='light'
|
||||
icon={<RefreshCw size={14} />}
|
||||
onClick={fetchList}
|
||||
>
|
||||
<Button icon={<RefreshCw size={16} />} onClick={fetchList}>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='solid'
|
||||
icon={<Plus size={14} />}
|
||||
icon={<Plus size={16} />}
|
||||
onClick={openCreate}
|
||||
>
|
||||
{t('新建项目')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
<OrgPanel padding='p-2'>
|
||||
>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
loading={loading}
|
||||
pagination={{ pageSize: 15, showSizeChanger: false }}
|
||||
pagination={{
|
||||
pageSize: 15,
|
||||
showSizeChanger: false,
|
||||
showTotal: (total) => t('共 {{total}} 条', { total }),
|
||||
}}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1060 }}
|
||||
/>
|
||||
</OrgPanel>
|
||||
</OrgListCard>
|
||||
|
||||
{/* 项目创建/编辑 */}
|
||||
<OrgModal
|
||||
className='oc-dialog'
|
||||
width={560}
|
||||
title={editing ? t('编辑项目') : t('新建项目')}
|
||||
visible={modalVisible}
|
||||
onOk={handleSubmit}
|
||||
@@ -420,6 +449,8 @@ const OrgProjects = ({ orgId }) => {
|
||||
|
||||
{/* 项目成员管理 */}
|
||||
<OrgModal
|
||||
className='oc-dialog oc-dialog-table'
|
||||
width={760}
|
||||
title={`${t('项目成员')} - ${memberModal?.name || ''}`}
|
||||
visible={!!memberModal}
|
||||
onCancel={() => setMemberModal(null)}
|
||||
@@ -489,17 +520,18 @@ const OrgProjects = ({ orgId }) => {
|
||||
/>
|
||||
</OrgModal>
|
||||
|
||||
{/* 项目令牌绑定 */}
|
||||
{/* 项目密钥绑定 */}
|
||||
<OrgModal
|
||||
title={`${t('项目令牌')} - ${tokenModal?.name || ''}`}
|
||||
className='oc-dialog oc-dialog-table'
|
||||
title={`${t('项目密钥')} - ${tokenModal?.name || ''}`}
|
||||
visible={!!tokenModal}
|
||||
onCancel={() => setTokenModal(null)}
|
||||
footer={null}
|
||||
width={560}
|
||||
width={760}
|
||||
>
|
||||
<Table
|
||||
columns={[
|
||||
{ title: t('令牌'), dataIndex: 'name' },
|
||||
{ title: t('密钥'), dataIndex: 'name' },
|
||||
{
|
||||
title: t('当前归属'),
|
||||
dataIndex: 'project_id',
|
||||
|
||||
@@ -118,7 +118,7 @@ const PromptCallDetails = ({ orgId, groupKey }) => {
|
||||
{calls.length >= 200 ? '+' : ''})
|
||||
<span className='ml-2 font-normal text-gray-400 dark:text-gray-500'>
|
||||
{t(
|
||||
'明细为该提示词的全部调用;跨 30 分钟统计桶或多令牌时,条数可能多于本行调用次数',
|
||||
'明细为该提示词的全部调用;跨 30 分钟统计桶或多密钥时,条数可能多于本行调用次数',
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -28,17 +28,8 @@ import {
|
||||
InputNumber,
|
||||
Select,
|
||||
} from '@/components/ui';
|
||||
import {
|
||||
CreditCard,
|
||||
Wallet,
|
||||
TrendingUp,
|
||||
Coins,
|
||||
History,
|
||||
CheckCircle,
|
||||
Clock,
|
||||
XCircle,
|
||||
Pencil,
|
||||
} from 'lucide-react';
|
||||
import { Check, CheckCircle, Clock, XCircle } from 'lucide-react';
|
||||
import { Button as AntButton } from 'antd';
|
||||
import {
|
||||
API,
|
||||
showError,
|
||||
@@ -48,10 +39,11 @@ import {
|
||||
getQuotaPerUnit,
|
||||
} from '../../helpers';
|
||||
import AmountCard from '../Recharge/AmountCard';
|
||||
import usePayPalQuote from '../../hooks/common/usePayPalQuote';
|
||||
import WechatQRModal from '../../components/topup/modals/WechatQRModal';
|
||||
import PaymentConfirmModal from '../../components/topup/modals/PaymentConfirmModal';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import '../../styles/org-center.css';
|
||||
import { orgStatusColor } from './components/orgStatus';
|
||||
import {
|
||||
formatPayPalUSD,
|
||||
@@ -61,7 +53,7 @@ import {
|
||||
removePayPalReturnState,
|
||||
} from '../../helpers/paypalPayment';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const { Text } = Typography;
|
||||
|
||||
const OrgRecharge = ({ orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -85,7 +77,6 @@ const OrgRecharge = ({ orgId }) => {
|
||||
const [confirmOpen, setConfirmOpen] = useState(false);
|
||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
||||
const [amountLoading, setAmountLoading] = useState(false);
|
||||
const [payPalQuote, setPayPalQuote] = useState(null);
|
||||
|
||||
// 自定义充值(与预设档位互斥;自定义金额无折扣,原价到账)
|
||||
const [isCustomMode, setIsCustomMode] = useState(false);
|
||||
@@ -108,6 +99,22 @@ const OrgRecharge = ({ orgId }) => {
|
||||
: selectedPresetObj?.discount || 1.0;
|
||||
const effectiveBonus = isCustomMode ? 0 : selectedPresetObj?.bonus || 0;
|
||||
|
||||
const {
|
||||
quote: payPalQuote,
|
||||
setQuote: setPayPalQuote,
|
||||
loading: quoteLoading,
|
||||
refresh: refreshPayPalQuote,
|
||||
} = usePayPalQuote(
|
||||
'/api/org/topup/paypal/amount',
|
||||
isCustomMode
|
||||
? { custom_amount: customEffectiveAmount }
|
||||
: { amount_option_id: selectedPresetObj?.id },
|
||||
payWay === 'paypal' &&
|
||||
effectiveAmountYuan > 0 &&
|
||||
(!isCustomMode || customValid),
|
||||
orgId,
|
||||
);
|
||||
|
||||
// 微信二维码
|
||||
const [wechatQRVisible, setWechatQRVisible] = useState(false);
|
||||
const [wechatOrderData, setWechatOrderData] = useState(null);
|
||||
@@ -292,15 +299,7 @@ const OrgRecharge = ({ orgId }) => {
|
||||
}
|
||||
setAmountLoading(true);
|
||||
try {
|
||||
const response = await API.post(
|
||||
'/api/org/topup/paypal/amount',
|
||||
buildPayBody(),
|
||||
{ headers: orgHeaders },
|
||||
);
|
||||
if (!response.data.success) {
|
||||
throw new Error(response.data.message || t('获取金额失败'));
|
||||
}
|
||||
setPayPalQuote(parsePayPalQuote(response));
|
||||
if (!(await refreshPayPalQuote())) return;
|
||||
} catch (error) {
|
||||
showError(error?.message || t('获取金额失败'));
|
||||
return;
|
||||
@@ -456,8 +455,8 @@ const OrgRecharge = ({ orgId }) => {
|
||||
return (
|
||||
<Tag
|
||||
color={orgStatusColor(status)}
|
||||
size='small'
|
||||
className='flex items-center gap-1'
|
||||
bordered={false}
|
||||
className='oc-recharge-status'
|
||||
>
|
||||
{s.icon}
|
||||
{s.text}
|
||||
@@ -469,341 +468,317 @@ const OrgRecharge = ({ orgId }) => {
|
||||
{
|
||||
title: t('订单号'),
|
||||
dataIndex: 'trade_no',
|
||||
render: (v) => (
|
||||
<Text size='small' className='font-mono'>
|
||||
{v}
|
||||
</Text>
|
||||
),
|
||||
width: 320,
|
||||
ellipsis: true,
|
||||
render: (v) => <span className='oc-rc-order-id'>{v}</span>,
|
||||
},
|
||||
{
|
||||
title: t('金额'),
|
||||
dataIndex: 'money',
|
||||
render: (v) => <Text size='small'>¥{Number(v).toFixed(2)}</Text>,
|
||||
width: 90,
|
||||
width: 140,
|
||||
render: (v) => `¥${Number(v).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
title: t('获得额度'),
|
||||
dataIndex: 'amount',
|
||||
render: (v) => <Text size='small'>{renderQuota(v)}</Text>,
|
||||
width: 110,
|
||||
width: 140,
|
||||
render: (v) => renderQuota(v),
|
||||
},
|
||||
{
|
||||
title: t('支付方式'),
|
||||
dataIndex: 'payment_channel',
|
||||
render: (v) => (
|
||||
<Text size='small'>
|
||||
{v === 'paypal_checkout' ? 'PayPal' : v || '-'}
|
||||
</Text>
|
||||
),
|
||||
width: 110,
|
||||
width: 120,
|
||||
render: (v) => (v === 'paypal_checkout' ? 'PayPal' : v || '-'),
|
||||
},
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: 110,
|
||||
render: (v) => renderStatus(v),
|
||||
width: 90,
|
||||
},
|
||||
{
|
||||
title: t('时间'),
|
||||
dataIndex: 'create_time',
|
||||
render: (v) => <Text size='small'>{timestamp2string(v)}</Text>,
|
||||
width: 160,
|
||||
width: 190,
|
||||
render: (v) => timestamp2string(v),
|
||||
},
|
||||
];
|
||||
|
||||
const hasAnyPayment =
|
||||
enableWechatTopUp || enableAlipayTopUp || enablePayPalTopUp;
|
||||
|
||||
// 充值订单卡(原型 .rp-checkout):展示当前选择的到账额度 / 支付方式 / 应付金额;
|
||||
// “立即充值”与点击支付方式相同,进入原有 handlePreTopUp 预充值校验与确认弹窗
|
||||
const selectedMethod = payMethods.find((m) => m.type === payWay);
|
||||
const quotaPerUnit = getQuotaPerUnit() || 500000;
|
||||
// 到账额度:自定义沿用原实时预览 customPreviewQuota;档位与确认弹窗 renderQuotaWithAmount 同口径
|
||||
const arrivalQuota =
|
||||
effectiveAmountYuan <= 0
|
||||
? '-'
|
||||
: isCustomMode
|
||||
? renderQuota(customPreviewQuota)
|
||||
: renderQuota(effectiveAmountYuan * quotaPerUnit + effectiveBonus);
|
||||
const payableYuan = effectiveAmountYuan * effectiveDiscount;
|
||||
const payableValue =
|
||||
payWay === 'paypal' ? payPalQuote?.payAmount : payableYuan;
|
||||
const canCheckout =
|
||||
effectiveAmountYuan > 0 &&
|
||||
(!isCustomMode || customValid) &&
|
||||
Boolean(selectedMethod) &&
|
||||
!amountLoading &&
|
||||
!quoteLoading &&
|
||||
(payWay !== 'paypal' || Boolean(payPalQuote));
|
||||
const customInvalid = customEffectiveAmount > 0 && !customValid;
|
||||
|
||||
const renderPayIcon = (type) =>
|
||||
type === 'wxpay' ? (
|
||||
<i className='oc-pay-dot' aria-hidden='true' />
|
||||
) : type === 'paypal' ? (
|
||||
<strong className='oc-pay-pal' aria-hidden='true'>
|
||||
P
|
||||
</strong>
|
||||
) : null;
|
||||
|
||||
return (
|
||||
<div className='uc-page space-y-6'>
|
||||
<div className='uc-page oc-page oc-recharge'>
|
||||
<OrgPageHeader title={t('企业充值')} subtitle={t('为企业账户充值额度')} />
|
||||
|
||||
{/* 签名时刻:余额展示区(本页唯一的品牌渐变区,渐变走 --brand-* token 随预设切换) */}
|
||||
<div className='relative overflow-hidden bg-gradient-to-r from-brand-from via-brand-via to-brand-to rounded-xl p-5 shadow-[var(--elevation-md)]'>
|
||||
<div className='flex items-center justify-between gap-4 flex-wrap'>
|
||||
<div className='flex items-center gap-3'>
|
||||
<div className='p-2 bg-white/15 rounded-lg'>
|
||||
<Wallet size={20} className='text-white' />
|
||||
<div className='oc-rc-layout'>
|
||||
{/* 企业钱包(原型 .rlc-account-rail) */}
|
||||
<aside className='oc-rc-rail'>
|
||||
<h2>{t('企业钱包')}</h2>
|
||||
<div className='oc-rc-rule' />
|
||||
<div className='oc-rc-account'>
|
||||
<div>
|
||||
<span>{t('企业可用余额')}</span>
|
||||
<strong className='oc-rc-balance'>{renderQuota(orgQuota)}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<Text className='!text-white/80 text-xs font-medium block'>
|
||||
{t('企业可用余额')}
|
||||
</Text>
|
||||
<Title heading={4} className='!text-white !mb-0 tabular-nums'>
|
||||
{renderQuota(orgQuota)}
|
||||
</Title>
|
||||
<span>{t('累计消耗')}</span>
|
||||
<strong>{renderQuota(orgUsedQuota)}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className='w-px h-10 bg-white/20 flex-shrink-0' />
|
||||
<div className='flex items-center gap-3'>
|
||||
<div className='p-2 bg-white/10 rounded-lg'>
|
||||
<TrendingUp size={18} className='text-white/80' />
|
||||
</div>
|
||||
<div>
|
||||
<Text className='!text-white/60 text-xs block'>
|
||||
{t('累计消耗')}
|
||||
</Text>
|
||||
<Text className='!text-white font-semibold text-sm tabular-nums'>
|
||||
{renderQuota(orgUsedQuota)}
|
||||
</Text>
|
||||
</div>
|
||||
<div className='oc-rc-rail-foot'>
|
||||
<i aria-hidden='true' />
|
||||
<span>{t('余额用于模型调用')}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{/* 充值区域 */}
|
||||
<OrgPanel icon={Coins} title={t('选择充值档位')}>
|
||||
{infoLoading ? (
|
||||
<div className='py-10 flex justify-center'>
|
||||
<Spin />
|
||||
</div>
|
||||
) : presetAmounts.length > 0 ? (
|
||||
<>
|
||||
<div className='grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-2.5 mb-4'>
|
||||
{presetAmounts.map((preset, idx) => (
|
||||
<AmountCard
|
||||
key={idx}
|
||||
preset={preset}
|
||||
selected={selectedPreset === preset.id}
|
||||
onClick={() => selectPreset(preset)}
|
||||
topupInfo={{ amount_options: [], discount: {} }}
|
||||
priceRatio={1}
|
||||
t={t}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
{/* 充值工作区(原型 .rlc-workspace) */}
|
||||
<section className='oc-rc-workspace'>
|
||||
<header className='oc-rc-workspace-head'>
|
||||
<h2>{t('为下一次调用补充能量')}</h2>
|
||||
<p>{t('为企业账户补充额度,支持团队持续调用模型。')}</p>
|
||||
</header>
|
||||
|
||||
{/* 自定义充值(与档位互斥;自定义金额无折扣,原价到账) */}
|
||||
<div
|
||||
className={`mb-5 rounded-xl border-2 border-dashed transition-all ${
|
||||
isCustomMode
|
||||
? 'border-emerald-400 bg-gradient-to-br from-emerald-50/60 to-emerald-50/25 dark:from-emerald-900/15 dark:to-emerald-900/10 dark:border-emerald-600 shadow-sm shadow-emerald-500/5'
|
||||
: 'border-gray-200 dark:border-neutral-700 hover:border-emerald-300 dark:hover:border-emerald-700'
|
||||
}`}
|
||||
>
|
||||
{/* 头部 */}
|
||||
<div className='px-4 pt-3.5 pb-2.5 flex items-center justify-between flex-wrap gap-1.5'>
|
||||
<div className='flex items-center gap-1.5'>
|
||||
<div className='p-1 rounded-md bg-emerald-100 dark:bg-emerald-900/40'>
|
||||
<Pencil
|
||||
size={12}
|
||||
className='text-emerald-600 dark:text-emerald-400'
|
||||
{infoLoading ? (
|
||||
<div className='oc-rc-loading'>
|
||||
<Spin />
|
||||
</div>
|
||||
) : presetAmounts.length > 0 ? (
|
||||
<div className='oc-rc-purchase'>
|
||||
<div className='oc-rc-content'>
|
||||
<div className='oc-rc-section-heading'>
|
||||
<h3>{t('选择充值额度')}</h3>
|
||||
<p>{t('为企业账户充值,额度用于团队模型调用。')}</p>
|
||||
</div>
|
||||
<div className='oc-rc-amount-grid'>
|
||||
{presetAmounts.map((preset, idx) => (
|
||||
<AmountCard
|
||||
key={idx}
|
||||
preset={preset}
|
||||
selected={selectedPreset === preset.id}
|
||||
onClick={() => selectPreset(preset)}
|
||||
topupInfo={{ amount_options: [], discount: {} }}
|
||||
priceRatio={1}
|
||||
t={t}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* 自定义充值(与档位互斥;自定义金额无折扣,原价到账) */}
|
||||
<div
|
||||
className={`oc-rc-custom${isCustomMode ? ' selected' : ''}`}
|
||||
>
|
||||
<h3>
|
||||
{t('自定义充值')}
|
||||
{isCustomMode && (
|
||||
<Tag color='green' bordered={false}>
|
||||
{t('已选')}
|
||||
</Tag>
|
||||
)}
|
||||
</h3>
|
||||
<div className='oc-rc-custom-input'>
|
||||
<InputNumber
|
||||
value={customAmount}
|
||||
onChange={handleCustomAmountChange}
|
||||
min={1}
|
||||
precision={0}
|
||||
hideButtons
|
||||
placeholder={t('请输入整数,如 1、5、10')}
|
||||
status={customInvalid ? 'error' : undefined}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
<Select
|
||||
value={customUnit}
|
||||
onChange={handleCustomUnitChange}
|
||||
optionList={[
|
||||
{ label: t('千'), value: 1000 },
|
||||
{ label: t('万'), value: 10000 },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
<Text
|
||||
strong
|
||||
className='text-gray-800 dark:text-gray-200 text-sm'
|
||||
<div className='oc-rc-quick'>
|
||||
<span>{t('快速选择:')}</span>
|
||||
{customQuickPicks.map((pick) => {
|
||||
const active =
|
||||
isCustomMode &&
|
||||
Number(customAmount) === pick.amount &&
|
||||
customUnit === pick.unit;
|
||||
return (
|
||||
<AntButton
|
||||
key={`${pick.amount}-${pick.unit}`}
|
||||
size='small'
|
||||
aria-pressed={active}
|
||||
className={active ? 'is-active' : ''}
|
||||
onClick={() =>
|
||||
applyCustomQuickPick(pick.amount, pick.unit)
|
||||
}
|
||||
>
|
||||
{`${pick.amount}${pick.unit === 1000 ? t('千') : t('万')}`}
|
||||
</AntButton>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{/* 底部说明(金额不达标时变为错误提示) */}
|
||||
<p
|
||||
className={customInvalid ? 'oc-rc-error' : ''}
|
||||
role={customInvalid ? 'alert' : undefined}
|
||||
>
|
||||
{t('自定义充值')}
|
||||
</Text>
|
||||
{isCustomMode && (
|
||||
<Tag color='green' size='small'>
|
||||
{t('已选')}
|
||||
</Tag>
|
||||
{customInvalid
|
||||
? `${t('当前 ¥')}${customEffectiveAmount.toLocaleString()}${t(',未达到最低 ¥1,000')}`
|
||||
: `${t('最少 1000 元,必须为 1000 元的整倍数')};${t('原价到账,不参与折扣')}`}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 支付方式(点击沿用 handlePreTopUp:校验后进入确认弹窗) */}
|
||||
<div className='oc-rc-pay'>
|
||||
<h3>{t('支付方式')}</h3>
|
||||
{hasAnyPayment ? (
|
||||
<div className='oc-rc-pay-methods'>
|
||||
{payMethods.map((method) => {
|
||||
const isWechat = method.type === 'wxpay';
|
||||
const isAlipay = method.type === 'alipay';
|
||||
const isPayPal = method.type === 'paypal';
|
||||
const disabled =
|
||||
(isWechat && !enableWechatTopUp) ||
|
||||
(isAlipay && !enableAlipayTopUp) ||
|
||||
(isPayPal && !enablePayPalTopUp);
|
||||
const selected = payWay === method.type;
|
||||
return (
|
||||
<AntButton
|
||||
key={method.type}
|
||||
disabled={disabled}
|
||||
loading={amountLoading && selected}
|
||||
aria-pressed={selected}
|
||||
icon={renderPayIcon(method.type)}
|
||||
className={`oc-rc-pay-method${selected ? ' is-selected' : ''}`}
|
||||
onClick={() => handlePreTopUp(method.type)}
|
||||
>
|
||||
{method.name}
|
||||
{selected && <Check size={14} />}
|
||||
</AntButton>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<p className='oc-rc-pay-empty'>
|
||||
{t('暂无可用的支付方式,请联系管理员配置')}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('原价到账,不参与折扣')}
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
{/* 输入区 */}
|
||||
<div className='px-4 pb-3'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<InputNumber
|
||||
value={customAmount}
|
||||
onChange={handleCustomAmountChange}
|
||||
min={1}
|
||||
precision={0}
|
||||
hideButtons
|
||||
size='large'
|
||||
placeholder={t('请输入整数,如 1、5、10')}
|
||||
className='!flex-1'
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
<Select
|
||||
value={customUnit}
|
||||
onChange={handleCustomUnitChange}
|
||||
size='large'
|
||||
style={{ width: 96 }}
|
||||
optionList={[
|
||||
{ label: t('千'), value: 1000 },
|
||||
{ label: t('万'), value: 10000 },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 快速选择 */}
|
||||
<div className='mt-2.5 flex items-center gap-1.5 flex-wrap'>
|
||||
<Text
|
||||
type='tertiary'
|
||||
size='small'
|
||||
className='!text-xs flex-shrink-0'
|
||||
>
|
||||
{t('快速选择:')}
|
||||
</Text>
|
||||
{customQuickPicks.map((pick) => {
|
||||
const active =
|
||||
isCustomMode &&
|
||||
Number(customAmount) === pick.amount &&
|
||||
customUnit === pick.unit;
|
||||
const label = `${pick.amount}${pick.unit === 1000 ? t('千') : t('万')}`;
|
||||
return (
|
||||
<button
|
||||
key={`${pick.amount}-${pick.unit}`}
|
||||
type='button'
|
||||
onClick={() =>
|
||||
applyCustomQuickPick(pick.amount, pick.unit)
|
||||
}
|
||||
className={`px-2.5 py-0.5 rounded-md text-xs font-medium transition-colors border ${
|
||||
active
|
||||
? 'bg-emerald-500 text-white border-emerald-500 shadow-sm shadow-emerald-500/20'
|
||||
: 'bg-white dark:bg-neutral-800 text-gray-600 dark:text-gray-300 border-gray-200 dark:border-neutral-700 hover:border-emerald-300 hover:text-emerald-600 dark:hover:border-emerald-700 dark:hover:text-emerald-400'
|
||||
}`}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 实时预览(仅在金额合法时显示) */}
|
||||
{customEffectiveAmount > 0 && customValid && (
|
||||
<div className='mx-4 mb-3 rounded-lg p-3 bg-[var(--surface-card)] border border-[var(--border-subtle)]'>
|
||||
<div className='flex items-center justify-between gap-3 flex-wrap'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<div className='w-7 h-7 rounded-lg bg-rose-500/10 text-rose-600 dark:text-rose-400 flex items-center justify-center'>
|
||||
<Wallet size={14} />
|
||||
</div>
|
||||
<div>
|
||||
<Text
|
||||
type='tertiary'
|
||||
size='small'
|
||||
className='!text-xs block leading-tight'
|
||||
>
|
||||
{t('实付金额')}
|
||||
</Text>
|
||||
<Text
|
||||
strong
|
||||
className='!text-rose-600 dark:!text-rose-400 text-base leading-tight'
|
||||
>
|
||||
¥{customEffectiveAmount.toLocaleString()}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex items-center gap-2'>
|
||||
<div className='w-7 h-7 rounded-lg bg-amber-500/10 text-amber-600 dark:text-amber-400 flex items-center justify-center'>
|
||||
<Coins size={14} />
|
||||
</div>
|
||||
<div className='text-right'>
|
||||
<Text
|
||||
type='tertiary'
|
||||
size='small'
|
||||
className='!text-xs block leading-tight'
|
||||
>
|
||||
{t('获得额度')}
|
||||
</Text>
|
||||
<Text
|
||||
strong
|
||||
className='!text-amber-600 dark:!text-amber-400 text-base leading-tight'
|
||||
>
|
||||
{renderQuota(customPreviewQuota)}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
{/* 企业充值订单(原型 .rlc-checkout-card) */}
|
||||
<aside className='oc-rc-checkout'>
|
||||
<h3>{t('企业充值订单')}</h3>
|
||||
<dl>
|
||||
<div>
|
||||
<dt>{t('到账额度')}</dt>
|
||||
<dd>{arrivalQuota}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{t('优惠金额')}</dt>
|
||||
<dd>¥{(effectiveAmountYuan - payableYuan).toFixed(2)}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{t('支付方式')}</dt>
|
||||
<dd>{selectedMethod?.name || '-'}</dd>
|
||||
</div>
|
||||
{payWay === 'paypal' && payPalQuote && (
|
||||
<div>
|
||||
<dt>{t('支付服务费')}</dt>
|
||||
<dd>{formatPayPalUSD(payPalQuote.serviceFee)}</dd>
|
||||
</div>
|
||||
)}
|
||||
</dl>
|
||||
<div className='oc-rc-payable'>
|
||||
<span>{t('应付金额')}</span>
|
||||
<strong>
|
||||
{payableValue > 0 ? (
|
||||
<>
|
||||
<span>{payWay === 'paypal' ? '$' : '¥'}</span>
|
||||
<b>
|
||||
{payableValue.toLocaleString('en-US', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</b>
|
||||
{payWay === 'paypal' && <span> USD</span>}
|
||||
</>
|
||||
) : (
|
||||
'-'
|
||||
)}
|
||||
</strong>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 底部说明(金额不达标时变橙色) */}
|
||||
<div className='px-4 pb-3'>
|
||||
<Text
|
||||
size='small'
|
||||
className={`!text-xs ${
|
||||
customEffectiveAmount > 0 && !customValid
|
||||
? '!text-amber-600 dark:!text-amber-400'
|
||||
: '!text-gray-400 dark:!text-gray-500'
|
||||
}`}
|
||||
<Button
|
||||
type='primary'
|
||||
size='large'
|
||||
block
|
||||
disabled={!canCheckout}
|
||||
loading={amountLoading || quoteLoading}
|
||||
onClick={() => handlePreTopUp(payWay)}
|
||||
>
|
||||
{customEffectiveAmount > 0 && !customValid
|
||||
? `${t('当前 ¥')}${customEffectiveAmount.toLocaleString()}${t(',未达到最低 ¥1,000')}`
|
||||
: t('最少 1000 元,必须为 1000 元的整倍数')}
|
||||
</Text>
|
||||
</div>
|
||||
{t('立即充值')}
|
||||
</Button>
|
||||
</aside>
|
||||
</div>
|
||||
) : (
|
||||
<p className='oc-rc-pay-empty'>
|
||||
{t('暂无充值档位,请联系管理员配置')}
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{/* 支付方式 */}
|
||||
<div className='flex items-center gap-2 mb-3'>
|
||||
<div className='p-1.5 rounded-lg bg-brand/10 text-brand'>
|
||||
<CreditCard size={14} />
|
||||
</div>
|
||||
<Text strong className='text-gray-800 dark:text-gray-200'>
|
||||
{t('支付方式')}
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
{hasAnyPayment ? (
|
||||
<div className='flex flex-wrap gap-3'>
|
||||
{payMethods.map((method) => {
|
||||
const isWechat = method.type === 'wxpay';
|
||||
const isAlipay = method.type === 'alipay';
|
||||
const isPayPal = method.type === 'paypal';
|
||||
const disabled =
|
||||
(isWechat && !enableWechatTopUp) ||
|
||||
(isAlipay && !enableAlipayTopUp) ||
|
||||
(isPayPal && !enablePayPalTopUp);
|
||||
return (
|
||||
<Button
|
||||
key={method.type}
|
||||
theme={payWay === method.type ? 'solid' : 'light'}
|
||||
type={payWay === method.type ? 'primary' : 'tertiary'}
|
||||
disabled={disabled}
|
||||
loading={amountLoading && payWay === method.type}
|
||||
onClick={() => handlePreTopUp(method.type)}
|
||||
className={`!rounded-lg !px-5 !py-2.5 !h-auto transition-colors ${
|
||||
payWay === method.type
|
||||
? ''
|
||||
: 'hover:!bg-brand/5 dark:hover:!bg-brand-deep/20 hover:!border-brand-from'
|
||||
}`}
|
||||
>
|
||||
{method.name}
|
||||
</Button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('暂无可用的支付方式,请联系管理员配置')}
|
||||
</Text>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<Text type='tertiary'>{t('暂无充值档位,请联系管理员配置')}</Text>
|
||||
)}
|
||||
</OrgPanel>
|
||||
|
||||
{/* 充值记录 */}
|
||||
<OrgPanel
|
||||
icon={History}
|
||||
title={t('充值记录')}
|
||||
bodyClassName='overflow-x-auto'
|
||||
>
|
||||
{/* 充值记录(原型 .rlc-history) */}
|
||||
<section className='oc-rc-history' aria-label={t('充值记录')}>
|
||||
<Table
|
||||
rowKey={(record) => record.id ?? record.trade_no}
|
||||
columns={historyColumns}
|
||||
dataSource={history}
|
||||
loading={historyLoading}
|
||||
scroll={{ x: 900 }}
|
||||
pagination={{
|
||||
currentPage: historyPage,
|
||||
total: historyTotal,
|
||||
pageSize: 10,
|
||||
onPageChange: setHistoryPage,
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
size='small'
|
||||
empty={<Text type='tertiary'>{t('暂无充值记录')}</Text>}
|
||||
/>
|
||||
</OrgPanel>
|
||||
</section>
|
||||
|
||||
{/* 支付确认弹窗 */}
|
||||
<PaymentConfirmModal
|
||||
@@ -823,7 +798,7 @@ const OrgRecharge = ({ orgId }) => {
|
||||
const baseQuota = effectiveAmountYuan * quotaPerUnit;
|
||||
return renderQuota(baseQuota + effectiveBonus);
|
||||
}}
|
||||
amountLoading={amountLoading}
|
||||
amountLoading={amountLoading || quoteLoading}
|
||||
renderAmount={renderAmount}
|
||||
payWay={payWay}
|
||||
payMethods={payMethods}
|
||||
|
||||
@@ -18,21 +18,14 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Table,
|
||||
Button,
|
||||
Tag,
|
||||
Toast,
|
||||
Input,
|
||||
Empty,
|
||||
Popconfirm,
|
||||
} from '@/components/ui';
|
||||
import { RefreshCw, Check, X } from 'lucide-react';
|
||||
import { Form as AntForm, Tabs as AntTabs } from 'antd';
|
||||
import { Table, Button, Tag, Toast, Input, Popconfirm } from '@/components/ui';
|
||||
import { RefreshCw } from 'lucide-react';
|
||||
import { API } from '../../helpers/api';
|
||||
import { showError, collectPagedItems } from '../../helpers';
|
||||
import { renderQuota } from '../../helpers/render';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
import { orgStatusColor } from './components/orgStatus';
|
||||
|
||||
@@ -56,7 +49,11 @@ const statusTag = (t, s) => {
|
||||
expired: { x: t('已过期') },
|
||||
};
|
||||
const v = m[s] || { x: s };
|
||||
return <Tag color={orgStatusColor(s)}>{v.x}</Tag>;
|
||||
return (
|
||||
<Tag color={orgStatusColor(s)} bordered={false}>
|
||||
{v.x}
|
||||
</Tag>
|
||||
);
|
||||
};
|
||||
|
||||
const parseDelta = (payload) => {
|
||||
@@ -135,8 +132,9 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 列宽与渲染对齐原型 EnterpriseApprovals(80/90/210/140/300/120/130,scroll.x 1080)
|
||||
const columns = [
|
||||
{ title: 'ID', dataIndex: 'id', width: 60 },
|
||||
{ title: 'ID', dataIndex: 'id', width: 80 },
|
||||
{
|
||||
title: t('类型'),
|
||||
dataIndex: 'request_type',
|
||||
@@ -145,7 +143,7 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
},
|
||||
{
|
||||
title: t('对象'),
|
||||
width: 160,
|
||||
width: 210,
|
||||
ellipsis: true,
|
||||
render: (_, r) => {
|
||||
const label =
|
||||
@@ -153,7 +151,7 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
project: t('项目'),
|
||||
department: t('部门'),
|
||||
member: t('成员'),
|
||||
token: t('令牌'),
|
||||
token: t('密钥'),
|
||||
org: t('企业'),
|
||||
}[r.subject_type] || r.subject_type;
|
||||
// 后端已富化 subject_name;主体被删除等极端情况回退为 #ID
|
||||
@@ -164,25 +162,34 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
},
|
||||
{
|
||||
title: t('提额'),
|
||||
width: 110,
|
||||
render: (_, r) =>
|
||||
r.request_type === 'quota'
|
||||
? renderQuota(parseDelta(r.payload), 2)
|
||||
: '-',
|
||||
width: 140,
|
||||
render: (_, r) => (
|
||||
<span className='oc-number'>
|
||||
{r.request_type === 'quota'
|
||||
? renderQuota(parseDelta(r.payload), 2)
|
||||
: '-'}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('理由'),
|
||||
dataIndex: 'reason',
|
||||
width: 300,
|
||||
ellipsis: true,
|
||||
render: (v) => v || '-',
|
||||
},
|
||||
{ title: t('理由'), dataIndex: 'reason', ellipsis: true },
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: 90,
|
||||
width: 120,
|
||||
render: (v) => statusTag(t, v),
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 220,
|
||||
width: 130,
|
||||
render: (_, r) =>
|
||||
isApprover && r.status === 'pending' ? (
|
||||
<div className='flex items-center gap-2'>
|
||||
<OrgRowActions>
|
||||
<Popconfirm
|
||||
title={t('确认通过该提额申请?')}
|
||||
content={
|
||||
@@ -206,27 +213,14 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
position='topRight'
|
||||
onConfirm={() => decide(r.id, 'approved')}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
theme='solid'
|
||||
type='primary'
|
||||
icon={<Check size={14} />}
|
||||
>
|
||||
{t('通过')}
|
||||
</Button>
|
||||
<Button type='link'>{t('通过')}</Button>
|
||||
</Popconfirm>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
type='danger'
|
||||
icon={<X size={14} />}
|
||||
onClick={() => setRejectFor(r.id)}
|
||||
>
|
||||
<Button type='link' danger onClick={() => setRejectFor(r.id)}>
|
||||
{t('拒绝')}
|
||||
</Button>
|
||||
</div>
|
||||
</OrgRowActions>
|
||||
) : (
|
||||
<span className='text-xs text-gray-400'>-</span>
|
||||
'-'
|
||||
),
|
||||
},
|
||||
];
|
||||
@@ -234,56 +228,60 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
const filters = ['pending', 'approved', 'rejected', ''];
|
||||
|
||||
return (
|
||||
<div className='uc-page'>
|
||||
<div className='uc-page oc-page'>
|
||||
<OrgPageHeader
|
||||
title={isApprover ? t('审批中心') : t('我的申请')}
|
||||
subtitle={t('提额申请与审批')}
|
||||
actions={
|
||||
/>
|
||||
|
||||
{/* 原型 platform-list-tabs:状态筛选页签(只切换筛选,不承载内容),回调沿用 setStatusFilter */}
|
||||
<AntTabs
|
||||
className='oc-list-tabs oc-tabs-nav-only'
|
||||
activeKey={statusFilter || 'all'}
|
||||
onChange={(key) => setStatusFilter(key === 'all' ? '' : key)}
|
||||
items={filters.map((f) => ({
|
||||
key: f || 'all',
|
||||
label:
|
||||
f === 'pending'
|
||||
? t('待审批')
|
||||
: f === 'approved'
|
||||
? t('已通过')
|
||||
: f === 'rejected'
|
||||
? t('已拒绝')
|
||||
: t('全部'),
|
||||
}))}
|
||||
/>
|
||||
|
||||
<OrgListCard
|
||||
title={t('申请列表')}
|
||||
tools={
|
||||
<Button
|
||||
theme='light'
|
||||
icon={<RefreshCw size={14} />}
|
||||
icon={<RefreshCw size={16} />}
|
||||
loading={loading}
|
||||
onClick={fetchList}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
<div className='flex items-center gap-2 mb-3'>
|
||||
{filters.map((f) => (
|
||||
<Button
|
||||
key={f || 'all'}
|
||||
size='small'
|
||||
theme={statusFilter === f ? 'solid' : 'light'}
|
||||
onClick={() => setStatusFilter(f)}
|
||||
>
|
||||
{f === 'pending'
|
||||
? t('待审批')
|
||||
: f === 'approved'
|
||||
? t('已通过')
|
||||
: f === 'rejected'
|
||||
? t('已拒绝')
|
||||
: t('全部')}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<OrgPanel padding='p-2'>
|
||||
{list.length === 0 && !loading ? (
|
||||
<Empty description={t('暂无申请')} style={{ padding: 40 }} />
|
||||
) : (
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
loading={loading}
|
||||
pagination={{ pageSize: 15, showSizeChanger: false }}
|
||||
rowKey='id'
|
||||
/>
|
||||
)}
|
||||
</OrgPanel>
|
||||
>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
loading={loading}
|
||||
empty={t('暂无申请')}
|
||||
pagination={{
|
||||
pageSize: 15,
|
||||
showSizeChanger: false,
|
||||
showTotal: (total) => t('共 {{total}} 条', { total }),
|
||||
}}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1080 }}
|
||||
/>
|
||||
</OrgListCard>
|
||||
|
||||
<OrgModal
|
||||
className='oc-dialog oc-reject-dialog'
|
||||
width={520}
|
||||
title={t('拒绝申请')}
|
||||
visible={!!rejectFor}
|
||||
onOk={() => decide(rejectFor, 'rejected', rejectComment)}
|
||||
@@ -294,11 +292,16 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
okText={t('确认拒绝')}
|
||||
cancelText={t('取消')}
|
||||
>
|
||||
<Input
|
||||
placeholder={t('拒绝理由(可选)')}
|
||||
value={rejectComment}
|
||||
onChange={setRejectComment}
|
||||
/>
|
||||
{/* 原型:竖排表单项“拒绝理由(可选)”;仅布局,取值与提交沿用 rejectComment / decide */}
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('拒绝理由(可选)')}>
|
||||
<Input
|
||||
placeholder={t('请输入拒绝理由')}
|
||||
value={rejectComment}
|
||||
onChange={setRejectComment}
|
||||
/>
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
</OrgModal>
|
||||
</div>
|
||||
);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,8 +20,7 @@ import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
BarChart2,
|
||||
Users,
|
||||
BarChart3,
|
||||
Key,
|
||||
FileSearch,
|
||||
Receipt,
|
||||
@@ -29,15 +28,11 @@ import {
|
||||
ChevronDown,
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
Building2,
|
||||
Search,
|
||||
X,
|
||||
CreditCard,
|
||||
Network,
|
||||
FolderKanban,
|
||||
Folder,
|
||||
LayoutGrid,
|
||||
Wallet,
|
||||
FileClock,
|
||||
UserRound,
|
||||
BrainCircuit,
|
||||
LibraryBig,
|
||||
@@ -47,7 +42,8 @@ import {
|
||||
ShieldCheck,
|
||||
Cable,
|
||||
Gauge,
|
||||
Sparkles,
|
||||
Zap,
|
||||
Check,
|
||||
Activity,
|
||||
} from 'lucide-react';
|
||||
import { useSidebarCollapsed } from '../../hooks/common/useSidebarCollapsed';
|
||||
@@ -176,7 +172,7 @@ const OrgSidebar = ({
|
||||
// 让「AI 能力管理」成为纯管理员分组。
|
||||
itemKey: '/org/my-capabilities',
|
||||
text: t('我的 AI 能力'),
|
||||
icon: Sparkles,
|
||||
icon: Zap,
|
||||
group: 'overview',
|
||||
},
|
||||
{
|
||||
@@ -237,14 +233,14 @@ const OrgSidebar = ({
|
||||
{
|
||||
itemKey: '/org/dashboard',
|
||||
text: t('数据看板'),
|
||||
icon: BarChart2,
|
||||
icon: BarChart3,
|
||||
group: 'overview',
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
itemKey: '/org/members',
|
||||
text: t('员工管理'),
|
||||
icon: Users,
|
||||
icon: UserRound,
|
||||
group: 'org',
|
||||
adminOnly: true,
|
||||
},
|
||||
@@ -258,13 +254,13 @@ const OrgSidebar = ({
|
||||
{
|
||||
itemKey: '/org/project-manage',
|
||||
text: t('我的项目'),
|
||||
icon: FolderKanban,
|
||||
icon: Folder,
|
||||
group: 'org',
|
||||
projectScope: true,
|
||||
},
|
||||
{
|
||||
itemKey: '/org/departments',
|
||||
text: t('部门管理'),
|
||||
text: t('组织架构'),
|
||||
icon: Network,
|
||||
group: 'org',
|
||||
adminOnly: true,
|
||||
@@ -272,7 +268,7 @@ const OrgSidebar = ({
|
||||
{
|
||||
itemKey: '/org/projects',
|
||||
text: t('项目管理'),
|
||||
icon: FolderKanban,
|
||||
icon: Folder,
|
||||
group: 'org',
|
||||
adminOnly: true,
|
||||
},
|
||||
@@ -286,12 +282,12 @@ const OrgSidebar = ({
|
||||
{
|
||||
itemKey: '/org/requests',
|
||||
text: isAdmin ? t('审批中心') : t('我的申请'),
|
||||
icon: FileClock,
|
||||
icon: Check,
|
||||
group: 'governance',
|
||||
},
|
||||
{
|
||||
itemKey: '/org/tokens',
|
||||
text: t('令牌管理'),
|
||||
text: t('密钥管理'),
|
||||
icon: Key,
|
||||
group: 'governance',
|
||||
},
|
||||
@@ -448,20 +444,7 @@ const OrgSidebar = ({
|
||||
[groups, items],
|
||||
);
|
||||
|
||||
// 菜单搜索:命中项按分组展示;搜索中忽略折叠状态,保证结果可见
|
||||
const [searchText, setSearchText] = useState('');
|
||||
const searchInputRef = useRef(null);
|
||||
const navRef = useRef(null);
|
||||
const query = searchText.trim().toLowerCase();
|
||||
const visibleGroups = useMemo(() => {
|
||||
if (!query) return groupedItems;
|
||||
return groupedItems
|
||||
.map((g) => ({
|
||||
...g,
|
||||
items: g.items.filter((it) => it.text.toLowerCase().includes(query)),
|
||||
}))
|
||||
.filter((g) => g.items.length > 0);
|
||||
}, [groupedItems, query]);
|
||||
|
||||
// 二级分组折叠:仅记录用户手动收起的组,跨会话记忆
|
||||
const FOLDED_GROUPS_KEY = 'org_sidebar_folded_groups';
|
||||
@@ -519,265 +502,92 @@ const OrgSidebar = ({
|
||||
el?.scrollIntoView({ block: 'nearest' });
|
||||
}, [selectedKey]);
|
||||
|
||||
// 搜索命中片段高亮
|
||||
const renderItemText = (text) => {
|
||||
if (!query) return text;
|
||||
const idx = text.toLowerCase().indexOf(query);
|
||||
if (idx === -1) return text;
|
||||
return (
|
||||
<>
|
||||
{text.slice(0, idx)}
|
||||
<mark className='rounded-sm bg-brand/20 px-0.5 text-inherit'>
|
||||
{text.slice(idx, idx + query.length)}
|
||||
</mark>
|
||||
{text.slice(idx + query.length)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`
|
||||
relative flex flex-col h-full transition-all duration-300 ease-out
|
||||
bg-[var(--surface-sidebar)]
|
||||
border-r border-[var(--border-subtle)]
|
||||
${collapsed ? 'w-[64px]' : 'w-[216px]'}
|
||||
`}
|
||||
<aside
|
||||
className='ui-center-sidebar ui-org-sidebar'
|
||||
data-collapsed={collapsed}
|
||||
data-mobile={mobile || undefined}
|
||||
>
|
||||
{/* 标题区域 */}
|
||||
{!collapsed && (
|
||||
<div className='px-4 pt-5 pb-3'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<div className='p-1.5 rounded-lg bg-brand/10 text-brand'>
|
||||
<Building2 size={16} />
|
||||
</div>
|
||||
<div className='min-w-0'>
|
||||
<span className='font-bold text-gray-900 dark:text-white block truncate text-sm'>
|
||||
{orgName || t('企业中心')}
|
||||
</span>
|
||||
{orgRole && (
|
||||
<span className='text-[10px] text-gray-500 dark:text-gray-400'>
|
||||
{roleLabel}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className='ui-org-identity'>
|
||||
<LayoutGrid size={22} strokeWidth={1.5} aria-hidden='true' />
|
||||
<div className='ui-org-identity-copy'>
|
||||
<span className='ui-org-name' title={orgName || t('企业中心')}>
|
||||
{orgName || t('企业中心')}
|
||||
</span>
|
||||
{orgRole && <span className='ui-org-role'>{roleLabel}</span>}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 菜单搜索(折叠态显示放大镜按钮,点击先展开侧栏再聚焦输入框) */}
|
||||
{!collapsed ? (
|
||||
<div className='px-3 pb-1'>
|
||||
<div className='relative'>
|
||||
<Search
|
||||
size={14}
|
||||
className='pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400 dark:text-gray-500'
|
||||
/>
|
||||
<input
|
||||
ref={searchInputRef}
|
||||
type='text'
|
||||
value={searchText}
|
||||
onChange={(e) => setSearchText(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Escape') setSearchText('');
|
||||
}}
|
||||
placeholder={t('搜索菜单')}
|
||||
aria-label={t('搜索菜单')}
|
||||
className='h-8 w-full rounded-lg border border-transparent bg-[var(--ui-color-fill-0)] pl-8 pr-7 text-sm text-[var(--text-primary)] outline-none transition-colors duration-200 placeholder:text-gray-400 focus:border-brand/40 focus:bg-[var(--surface-card)] dark:placeholder:text-gray-500'
|
||||
/>
|
||||
{searchText && (
|
||||
<button
|
||||
type='button'
|
||||
onClick={() => setSearchText('')}
|
||||
aria-label={t('清空搜索')}
|
||||
className='absolute right-2 top-1/2 -translate-y-1/2 rounded p-0.5 text-gray-400 transition-colors hover:text-gray-700 dark:hover:text-gray-200'
|
||||
>
|
||||
<X size={13} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className='px-3 pb-1 pt-3'>
|
||||
<button
|
||||
type='button'
|
||||
onClick={() => {
|
||||
toggleCollapsed();
|
||||
setTimeout(() => searchInputRef.current?.focus(), 350);
|
||||
}}
|
||||
aria-label={t('搜索菜单')}
|
||||
className='flex w-full items-center justify-center rounded-lg p-2 text-gray-500 transition-colors duration-200 hover:bg-brand/10 hover:text-brand-deep dark:text-gray-400 dark:hover:bg-brand/15 dark:hover:text-brand-from'
|
||||
>
|
||||
<Search size={16} />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 导航区域 */}
|
||||
<nav
|
||||
ref={navRef}
|
||||
className='app-scrollbar relative flex-1 px-3 pt-1 pb-2 overflow-y-auto overflow-x-hidden'
|
||||
>
|
||||
{query && visibleGroups.length === 0 && (
|
||||
<div className='px-2 py-8 text-center text-xs text-gray-400 dark:text-gray-500'>
|
||||
{t('没有匹配的菜单')}
|
||||
</div>
|
||||
)}
|
||||
{visibleGroups.map((group, gi) => {
|
||||
// 搜索中强制展开,保证命中项可见;平时遵循用户的折叠选择
|
||||
const folded = !query && foldedGroups.includes(group.key);
|
||||
<nav ref={navRef} className='ui-center-sidebar-nav'>
|
||||
{groupedItems.map((group) => {
|
||||
const folded = foldedGroups.includes(group.key);
|
||||
return (
|
||||
<div key={group.key} className={gi > 0 ? 'mt-3' : ''}>
|
||||
{/* 分组标题(展开态,可点击折叠)/ 分隔线(折叠态) */}
|
||||
{!collapsed ? (
|
||||
<div key={group.key} className='ui-org-nav-group'>
|
||||
{!collapsed && (
|
||||
<button
|
||||
type='button'
|
||||
onClick={() => toggleGroup(group.key)}
|
||||
aria-expanded={!folded}
|
||||
className='mb-1 flex w-full select-none items-center gap-1.5 rounded-md px-2 py-1 text-[11px] font-semibold uppercase tracking-wider text-gray-400 transition-colors duration-200 hover:bg-[var(--ui-color-fill-0)] hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300'
|
||||
className='ui-org-group-toggle'
|
||||
>
|
||||
<span className='truncate'>{group.label}</span>
|
||||
<span className='ml-auto text-[10px] font-normal tabular-nums opacity-70'>
|
||||
{group.items.length}
|
||||
</span>
|
||||
<span>{group.label}</span>
|
||||
<ChevronDown
|
||||
size={13}
|
||||
className={`shrink-0 transition-transform duration-200 ${folded ? '-rotate-90' : ''}`}
|
||||
className={folded ? 'is-folded' : ''}
|
||||
aria-hidden='true'
|
||||
/>
|
||||
</button>
|
||||
) : (
|
||||
gi > 0 && (
|
||||
<div className='mx-2 mb-3 h-px bg-gray-200/50 dark:bg-neutral-700/50' />
|
||||
)
|
||||
)}
|
||||
|
||||
{/* grid-rows 0fr→1fr 实现平滑的折叠动画 */}
|
||||
<div
|
||||
className={`grid transition-[grid-template-rows] duration-200 ease-out ${
|
||||
folded && !collapsed ? 'grid-rows-[0fr]' : 'grid-rows-[1fr]'
|
||||
}`}
|
||||
>
|
||||
<div className='overflow-hidden'>
|
||||
<div className='space-y-1.5 pb-0.5'>
|
||||
{group.items.map((item) => {
|
||||
const isSelected = selectedKey === item.itemKey;
|
||||
const IconComponent = item.icon;
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={item.itemKey}
|
||||
to={item.itemKey}
|
||||
onClick={() => onNavigate?.()}
|
||||
data-active={isSelected || undefined}
|
||||
className={`
|
||||
group relative flex items-center gap-3 rounded-lg transition-colors duration-200
|
||||
${collapsed ? 'justify-center p-3' : 'px-3 py-2'}
|
||||
${
|
||||
isSelected
|
||||
? 'bg-brand/10 dark:bg-brand/15'
|
||||
: 'hover:bg-brand/5 dark:hover:bg-brand/10'
|
||||
}
|
||||
`}
|
||||
>
|
||||
{isSelected && (
|
||||
<div className='absolute left-0 top-1/2 -translate-y-1/2 w-0.5 h-5 rounded-r-full bg-brand transition-all duration-200' />
|
||||
<div className='ui-org-group-items' hidden={folded && !collapsed}>
|
||||
{group.items.map((item) => {
|
||||
const isSelected = selectedKey === item.itemKey;
|
||||
const IconComponent = item.icon;
|
||||
return (
|
||||
<Link
|
||||
key={item.itemKey}
|
||||
to={item.itemKey}
|
||||
onClick={() => onNavigate?.()}
|
||||
data-active={isSelected || undefined}
|
||||
aria-current={isSelected ? 'page' : undefined}
|
||||
title={collapsed ? item.text : undefined}
|
||||
className='ui-center-menu-item'
|
||||
>
|
||||
<IconComponent
|
||||
size={16}
|
||||
strokeWidth={1.5}
|
||||
aria-hidden='true'
|
||||
/>
|
||||
{!collapsed && (
|
||||
<>
|
||||
<span className='ui-center-menu-label'>
|
||||
{item.text}
|
||||
</span>
|
||||
{item.beta && (
|
||||
<span className='ui-org-beta'>BETA</span>
|
||||
)}
|
||||
|
||||
<div
|
||||
className={`
|
||||
relative flex-shrink-0 p-1.5 rounded-lg transition-colors duration-200
|
||||
${
|
||||
isSelected
|
||||
? 'bg-brand text-white'
|
||||
: 'text-gray-500 dark:text-gray-400 group-hover:text-brand-deep dark:group-hover:text-brand-from'
|
||||
}
|
||||
`}
|
||||
>
|
||||
<IconComponent size={18} strokeWidth={2} />
|
||||
</div>
|
||||
|
||||
{!collapsed && (
|
||||
<span className='flex min-w-0 items-center gap-2'>
|
||||
<span
|
||||
className={`
|
||||
text-sm transition-colors truncate
|
||||
${
|
||||
isSelected
|
||||
? 'text-brand-deep dark:text-brand-from font-semibold'
|
||||
: 'font-medium text-gray-600 dark:text-gray-300 group-hover:text-brand-deep dark:group-hover:text-brand-from'
|
||||
}
|
||||
`}
|
||||
>
|
||||
{renderItemText(item.text)}
|
||||
</span>
|
||||
{item.beta && (
|
||||
<span className='shrink-0 rounded-full border border-orange-300/70 bg-orange-50 px-1.5 py-0.5 font-mono text-[8px] font-bold tracking-wider text-orange-700 dark:border-orange-700/50 dark:bg-orange-950/40 dark:text-orange-300'>
|
||||
BETA
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
|
||||
{collapsed && (
|
||||
<div
|
||||
className='
|
||||
absolute left-full ml-2 px-2.5 py-1.5
|
||||
bg-gray-900 dark:bg-white text-white dark:text-gray-900
|
||||
text-xs font-medium rounded-lg shadow-lg
|
||||
opacity-0 invisible group-hover:opacity-100 group-hover:visible
|
||||
transition-all duration-200 whitespace-nowrap z-50
|
||||
'
|
||||
>
|
||||
{item.text}
|
||||
<div
|
||||
className='absolute left-0 top-1/2 -translate-x-1 -translate-y-1/2
|
||||
border-4 border-transparent border-r-gray-900 dark:border-r-white'
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
|
||||
{/* 底部分隔线 */}
|
||||
{!mobile && (
|
||||
<div className='mx-4 h-px bg-gradient-to-r from-transparent via-gray-200/60 dark:via-neutral-700/60 to-transparent' />
|
||||
<button
|
||||
type='button'
|
||||
onClick={toggleCollapsed}
|
||||
className='ui-center-sidebar-collapse'
|
||||
aria-label={collapsed ? t('展开导航') : t('收起导航')}
|
||||
>
|
||||
{collapsed ? <ChevronRight size={16} /> : <ChevronLeft size={16} />}
|
||||
{!collapsed && <span>{t('收起导航')}</span>}
|
||||
</button>
|
||||
)}
|
||||
|
||||
{/* 折叠按钮(移动端抽屉里不显示) */}
|
||||
{!mobile && (
|
||||
<div className='relative p-3'>
|
||||
<button
|
||||
onClick={toggleCollapsed}
|
||||
className={`
|
||||
flex items-center justify-center gap-2 w-full py-2 rounded-lg
|
||||
text-gray-500 dark:text-gray-400 text-sm font-medium
|
||||
border border-[var(--border-subtle)]
|
||||
hover:bg-brand/10 dark:hover:bg-brand/15
|
||||
hover:text-brand-deep dark:hover:text-brand-from
|
||||
hover:border-brand/30 transition-colors duration-200
|
||||
${collapsed ? 'px-2' : 'px-3'}
|
||||
`}
|
||||
>
|
||||
{collapsed ? (
|
||||
<ChevronRight size={16} strokeWidth={2.5} />
|
||||
) : (
|
||||
<>
|
||||
<ChevronLeft size={16} strokeWidth={2.5} />
|
||||
<span>{t('收起')}</span>
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,29 +17,23 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Breadcrumb } from 'antd';
|
||||
import {
|
||||
Breadcrumb,
|
||||
Card as AntCard,
|
||||
Progress as AntProgress,
|
||||
Tag as AntTag,
|
||||
} from 'antd';
|
||||
import { timestamp2string } from '../../helpers/utils';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Button,
|
||||
Tag,
|
||||
Progress,
|
||||
Form,
|
||||
Toast,
|
||||
Empty,
|
||||
Spin,
|
||||
Typography,
|
||||
} from '@/components/ui';
|
||||
import { Button, Tag, Form, Toast, Empty, Spin } from '@/components/ui';
|
||||
import {
|
||||
Wallet,
|
||||
Key,
|
||||
FileClock,
|
||||
Plus,
|
||||
RefreshCw,
|
||||
Pencil,
|
||||
Clock,
|
||||
TrendingUp,
|
||||
BarChart3,
|
||||
Coins,
|
||||
KeyRound,
|
||||
} from 'lucide-react';
|
||||
@@ -55,8 +49,8 @@ import OrgModal from './components/OrgModal';
|
||||
import OrgNicknameModal from './components/OrgNicknameModal';
|
||||
import OrgPasswordModal from './components/OrgPasswordModal';
|
||||
import { orgStatusColor } from './components/orgStatus';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import StatCard from './components/OrgStatCard';
|
||||
import '../../styles/org-center.css';
|
||||
|
||||
// 时段问候(工作台 hero 签名区的 eyebrow)
|
||||
const getGreeting = (t) => {
|
||||
@@ -68,7 +62,6 @@ const getGreeting = (t) => {
|
||||
return t('晚上好');
|
||||
};
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const getOrgHeaders = (orgId) => ({ 'X-Org-Id': String(orgId) });
|
||||
const PERIODIC_QUOTA_PERIODS = new Set(['daily', 'weekly', 'monthly']);
|
||||
|
||||
@@ -119,7 +112,11 @@ const reqStatusTag = (t, status) => {
|
||||
expired: { text: t('已过期') },
|
||||
};
|
||||
const s = map[status] || { text: status };
|
||||
return <Tag color={orgStatusColor(status)}>{s.text}</Tag>;
|
||||
return (
|
||||
<Tag color={orgStatusColor(status)} bordered={false}>
|
||||
{s.text}
|
||||
</Tag>
|
||||
);
|
||||
};
|
||||
|
||||
const isFeatureEnabled = (flags, key) => {
|
||||
@@ -127,23 +124,35 @@ const isFeatureEnabled = (flags, key) => {
|
||||
return value === true || value === 'true' || value === '1' || value === 1;
|
||||
};
|
||||
|
||||
// 用量趋势小块:窗口标题 + 消耗 + 请求数
|
||||
const UsageBlock = ({ t, title, data }) => (
|
||||
<div className='org-workbench-usage-block'>
|
||||
<div className='text-xs font-medium text-gray-500 dark:text-gray-400 mb-1'>
|
||||
{title}
|
||||
</div>
|
||||
<div className='text-lg font-semibold tabular-nums text-[var(--text-primary)]'>
|
||||
{renderQuota(data?.quota || 0, 2)}
|
||||
</div>
|
||||
<div className='text-xs text-gray-500 mt-0.5'>
|
||||
{t('请求数')} {data?.requests || 0} · {t('Token 总量')}{' '}
|
||||
{data?.tokens || 0}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
// 金额拆分货币符号(原型 <small>¥</small>742.17);无符号时原样展示
|
||||
const splitAmount = (text) => {
|
||||
const s = String(text ?? '');
|
||||
const m = s.match(/^([^\d\-−]+)(.*)$/);
|
||||
return m ? [m[1].trim(), m[2]] : ['', s];
|
||||
};
|
||||
const formatCount = (v) => Number(v || 0).toLocaleString('en-US');
|
||||
|
||||
// 企业工作台:员工自助门户(§36.1)——个人额度/用量统计/令牌/申请。
|
||||
// 个人用量块:窗口标题 + 消耗 + 请求数 + Token 总量(原型 .ew-usage-grid article)
|
||||
const UsageBlock = ({ t, title, data }) => {
|
||||
const [symbol, amount] = splitAmount(renderQuota(data?.quota || 0, 2));
|
||||
return (
|
||||
<article>
|
||||
<span>{title}</span>
|
||||
<strong>
|
||||
{symbol && <small>{symbol}</small>}
|
||||
{amount}
|
||||
</strong>
|
||||
<div>
|
||||
{t('请求数')} <b>{formatCount(data?.requests)}</b>
|
||||
</div>
|
||||
<div>
|
||||
{t('Token 总量')} <b>{formatCount(data?.tokens)}</b>
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
};
|
||||
|
||||
// 企业工作台:员工自助门户(§36.1)——个人额度/用量统计/密钥/申请。
|
||||
const OrgWorkbench = ({ orgId, orgRole, featureFlags }) => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
@@ -386,7 +395,7 @@ const OrgWorkbench = ({ orgId, orgRole, featureFlags }) => {
|
||||
summary?.member?.display_name || summary?.member?.username || '';
|
||||
|
||||
return (
|
||||
<div className='org-stagger org-workbench'>
|
||||
<div className='org-stagger org-workbench oc-page oc-workbench'>
|
||||
<Breadcrumb
|
||||
className='org-workbench-breadcrumb'
|
||||
items={[{ title: t('企业中心') }, { title: t('工作台') }]}
|
||||
@@ -394,26 +403,27 @@ const OrgWorkbench = ({ orgId, orgRole, featureFlags }) => {
|
||||
<OrgHero
|
||||
eyebrow={`${getGreeting(t)}${memberName ? ',' + memberName : ''}`}
|
||||
title={summary?.organization?.name || t('企业工作台')}
|
||||
subtitle={`${t('个人工作台')} · ${t('我的角色')}:${roleLabel(t, role)}${summary?.member?.department_name ? ' · ' + summary.member.department_name : ''}`}
|
||||
subtitle={
|
||||
// 原型以标签呈现身份信息(个人工作台 / 角色 / 部门),数据同原副标题
|
||||
<span className='oc-wb-tags'>
|
||||
<AntTag>{t('个人工作台')}</AntTag>
|
||||
<AntTag>{roleLabel(t, role)}</AntTag>
|
||||
{summary?.member?.department_name && (
|
||||
<AntTag>{summary.member.department_name}</AntTag>
|
||||
)}
|
||||
</span>
|
||||
}
|
||||
actions={
|
||||
<>
|
||||
<Button
|
||||
theme='light'
|
||||
icon={<Pencil size={14} />}
|
||||
onClick={openNickModal}
|
||||
>
|
||||
<Button theme='light' onClick={openNickModal}>
|
||||
{t('编辑昵称')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='light'
|
||||
icon={<KeyRound size={14} />}
|
||||
onClick={() => setPwdModal(true)}
|
||||
>
|
||||
<Button theme='light' onClick={() => setPwdModal(true)}>
|
||||
{t('修改密码')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='light'
|
||||
icon={<RefreshCw size={14} />}
|
||||
icon={<RefreshCw size={16} />}
|
||||
loading={loading}
|
||||
onClick={() => {
|
||||
fetchSummary();
|
||||
@@ -454,121 +464,146 @@ const OrgWorkbench = ({ orgId, orgRole, featureFlags }) => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 我的额度进度 + 我的令牌 */}
|
||||
<div className='org-workbench-middle'>
|
||||
<OrgPanel className='org-workbench-quota'>
|
||||
<div className='flex items-center gap-2 mb-3'>
|
||||
<Wallet size={18} className='text-brand-deep' />
|
||||
<Text strong>{t('我的额度')}</Text>
|
||||
{/* 我的额度 + 我的密钥(原型 .ew-middle) */}
|
||||
<div className='oc-wb-middle'>
|
||||
<AntCard className='oc-wb-card oc-wb-quota'>
|
||||
<div className='oc-wb-heading'>
|
||||
<h2>
|
||||
<Wallet size={16} />
|
||||
{t('我的额度')}
|
||||
</h2>
|
||||
{quotaLimit > 0 && <span>{quotaLimitLabel}</span>}
|
||||
</div>
|
||||
{quotaLimit > 0 ? (
|
||||
<>
|
||||
<Progress
|
||||
<div className='oc-wb-quota-main'>
|
||||
<div>
|
||||
<strong>
|
||||
{renderQuota(Math.max(0, quotaLimit - usedQuota), 2)}
|
||||
</strong>
|
||||
<span>
|
||||
{t('可用')} / {renderQuota(quotaLimit, 2)}
|
||||
</span>
|
||||
</div>
|
||||
<div className='oc-wb-percent'>
|
||||
{quotaPercent}%<span>{t('已使用')}</span>
|
||||
</div>
|
||||
</div>
|
||||
<AntProgress
|
||||
percent={quotaPercent}
|
||||
stroke={
|
||||
quotaPercent >= 90 ? 'var(--ui-color-danger)' : undefined
|
||||
showInfo={false}
|
||||
size='small'
|
||||
strokeColor={
|
||||
quotaPercent >= 90
|
||||
? 'var(--ui-color-danger)'
|
||||
: {
|
||||
'0%': 'var(--oc-quota-from)',
|
||||
'100%': 'var(--oc-quota-to)',
|
||||
}
|
||||
}
|
||||
style={{ marginBottom: 8 }}
|
||||
/>
|
||||
<Text type='tertiary' size='small'>
|
||||
{quotaIsPeriodic ? t('本周期已用') : t('已用')}{' '}
|
||||
{renderQuota(usedQuota, 2)} / {renderQuota(quotaLimit, 2)}
|
||||
{quotaIsPeriodic
|
||||
? ` · ${t('累计已用')} ${renderQuota(totalUsedQuota, 2)}`
|
||||
: ''}
|
||||
</Text>
|
||||
<div className='oc-wb-quota-caption'>
|
||||
<span>
|
||||
{quotaIsPeriodic ? t('本周期已用') : t('已用')}{' '}
|
||||
{renderQuota(usedQuota, 2)}
|
||||
</span>
|
||||
{quotaIsPeriodic && (
|
||||
<span>
|
||||
{t('累计已用')} {renderQuota(totalUsedQuota, 2)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<Text type='tertiary' size='small'>
|
||||
<p className='oc-wb-quota-empty'>
|
||||
{t('未设个人上限,使用企业统一额度池')}
|
||||
</Text>
|
||||
</p>
|
||||
)}
|
||||
<div className='mt-2'>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('实际可用还受所在部门/项目及企业预算约束。')}
|
||||
</Text>
|
||||
</div>
|
||||
<div className='mt-3'>
|
||||
<div className='oc-wb-quota-bottom'>
|
||||
<span>{t('实际可用还受所在部门/项目及企业预算约束。')}</span>
|
||||
<Button
|
||||
size='small'
|
||||
icon={<Plus size={14} />}
|
||||
theme='solid'
|
||||
onClick={openReqModal}
|
||||
disabled={!approvalEnabled || subjectOptions.length === 0}
|
||||
>
|
||||
{t('申请提额')}
|
||||
</Button>
|
||||
</div>
|
||||
</OrgPanel>
|
||||
</AntCard>
|
||||
|
||||
<OrgPanel className='org-workbench-tokens'>
|
||||
<div className='flex items-center gap-2 mb-3'>
|
||||
<Key size={18} className='text-brand-deep' />
|
||||
<Text strong>{t('我的令牌')}</Text>
|
||||
<AntCard className='oc-wb-card oc-wb-tokens'>
|
||||
<div className='oc-wb-heading'>
|
||||
<h2>
|
||||
<Key size={16} />
|
||||
{t('我的密钥')}
|
||||
</h2>
|
||||
</div>
|
||||
<Title heading={2} style={{ margin: '4px 0' }}>
|
||||
{summary?.token_count ?? 0}
|
||||
</Title>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
onClick={() => navigate('/org/tokens')}
|
||||
>
|
||||
{t('管理令牌')}
|
||||
<div className='oc-wb-token-content'>
|
||||
<span className='oc-wb-token-art' aria-hidden='true'>
|
||||
<KeyRound size={40} />
|
||||
</span>
|
||||
<div>
|
||||
<strong>{summary?.token_count ?? 0}</strong>
|
||||
<span>{t('个密钥')}</span>
|
||||
</div>
|
||||
</div>
|
||||
<Button theme='light' onClick={() => navigate('/org/tokens')}>
|
||||
{t('管理密钥')}
|
||||
</Button>
|
||||
</OrgPanel>
|
||||
</AntCard>
|
||||
</div>
|
||||
|
||||
{/* 个人用量趋势 */}
|
||||
<OrgPanel className='org-workbench-usage'>
|
||||
<div className='flex items-center gap-2 mb-3'>
|
||||
<TrendingUp size={18} className='text-brand-deep' />
|
||||
<Text strong>{t('个人用量趋势')}</Text>
|
||||
{/* 个人用量(原型 .ew-usage) */}
|
||||
<AntCard className='oc-wb-card oc-wb-usage'>
|
||||
<div className='oc-wb-heading'>
|
||||
<h2>
|
||||
<BarChart3 size={16} />
|
||||
{t('个人用量')}
|
||||
</h2>
|
||||
<span>{t('消费与调用概览')}</span>
|
||||
</div>
|
||||
<div className='org-workbench-usage-grid'>
|
||||
<div className='oc-wb-usage-grid'>
|
||||
<UsageBlock t={t} title={t('今日')} data={usage.today} />
|
||||
<UsageBlock t={t} title={t('近 7 天')} data={usage.last7d} />
|
||||
<UsageBlock t={t} title={t('近 30 天')} data={usage.last30d} />
|
||||
<UsageBlock t={t} title={t('累计')} data={usage.total} />
|
||||
</div>
|
||||
</OrgPanel>
|
||||
</AntCard>
|
||||
|
||||
{/* 最近申请 */}
|
||||
<OrgPanel>
|
||||
<div className='flex items-center gap-2 mb-3'>
|
||||
<FileClock size={18} className='text-brand-deep' />
|
||||
<Text strong>{t('最近申请')}</Text>
|
||||
{/* 最近申请(原型 .ew-requests) */}
|
||||
<AntCard className='oc-wb-card oc-wb-requests'>
|
||||
<div className='oc-wb-heading'>
|
||||
<h2>
|
||||
<FileClock size={16} />
|
||||
{t('最近申请')}
|
||||
</h2>
|
||||
</div>
|
||||
{summary?.recent_requests?.length ? (
|
||||
<div className='flex flex-col divide-y divide-[var(--ui-color-border)]'>
|
||||
{summary.recent_requests.map((r) => (
|
||||
<div
|
||||
key={r.id}
|
||||
className='flex items-center justify-between py-2.5'
|
||||
>
|
||||
<div>
|
||||
<Text>
|
||||
{r.request_type === 'quota'
|
||||
? t('提额申请')
|
||||
: r.request_type}
|
||||
{r.reason ? ` · ${r.reason}` : ''}
|
||||
</Text>
|
||||
<div>
|
||||
<Text type='tertiary' size='small'>
|
||||
{r.created_at ? timestamp2string(r.created_at) : ''}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
{reqStatusTag(t, r.status)}
|
||||
summary.recent_requests.map((r) => (
|
||||
<article key={r.id}>
|
||||
<span className='oc-wb-request-icon' aria-hidden='true'>
|
||||
<FileClock size={16} />
|
||||
</span>
|
||||
<div>
|
||||
<h3>
|
||||
{r.request_type === 'quota' ? t('提额申请') : r.request_type}
|
||||
{r.reason ? ` · ${r.reason}` : ''}
|
||||
</h3>
|
||||
<span>
|
||||
{r.created_at ? timestamp2string(r.created_at) : ''}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{reqStatusTag(t, r.status)}
|
||||
</article>
|
||||
))
|
||||
) : (
|
||||
<Empty description={t('暂无申请记录')} />
|
||||
)}
|
||||
</OrgPanel>
|
||||
</AntCard>
|
||||
|
||||
{/* 提额申请弹窗 */}
|
||||
<OrgModal
|
||||
className='oc-dialog'
|
||||
title={t('申请提额')}
|
||||
visible={reqModal}
|
||||
onOk={submitRequest}
|
||||
@@ -576,20 +611,19 @@ const OrgWorkbench = ({ orgId, orgRole, featureFlags }) => {
|
||||
okText={t('提交申请')}
|
||||
cancelText={t('取消')}
|
||||
>
|
||||
<Form getFormApi={setFormApi}>
|
||||
{/* 原型 .ew 提额弹窗:竖排表单、不显示必填星号(校验规则不变),说明为字段 extra */}
|
||||
<Form getFormApi={setFormApi} requiredMark={false}>
|
||||
<Form.Select
|
||||
field='subject'
|
||||
label={t('提额对象')}
|
||||
initValue={subjectOptions[0]?.value}
|
||||
optionList={subjectOptions}
|
||||
rules={[{ required: true, message: t('请选择提额对象') }]}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t(
|
||||
extraText={t(
|
||||
'个人额度用于解除您自己的使用上限;部门/项目额度属于预算上限,可能有独立周期。',
|
||||
)}
|
||||
</Text>
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
<Form.InputNumber
|
||||
field='delta'
|
||||
label={deltaLabel}
|
||||
@@ -612,7 +646,13 @@ const OrgWorkbench = ({ orgId, orgRole, featureFlags }) => {
|
||||
]}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
<Form.TextArea field='reason' label={t('申请理由')} maxCount={200} />
|
||||
<Form.TextArea
|
||||
field='reason'
|
||||
label={t('申请理由')}
|
||||
maxCount={200}
|
||||
rows={4}
|
||||
showCount
|
||||
/>
|
||||
</Form>
|
||||
</OrgModal>
|
||||
|
||||
|
||||
@@ -19,30 +19,23 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Table,
|
||||
Button,
|
||||
Select,
|
||||
Empty,
|
||||
Spin,
|
||||
Progress,
|
||||
Typography,
|
||||
} from '@/components/ui';
|
||||
import OrgPanel from './OrgPanel';
|
||||
Button as AntButton,
|
||||
Card as AntCard,
|
||||
Segmented,
|
||||
Select as AntSelect,
|
||||
Tabs as AntTabs,
|
||||
Tag as AntTag,
|
||||
} from 'antd';
|
||||
import { Table, Empty, Spin, Progress } from '@/components/ui';
|
||||
import '../../../styles/org-center.css';
|
||||
import { VChart } from '@visactor/react-vchart';
|
||||
import { initVChartTheme } from '@/components/ui/chartTheme';
|
||||
import {
|
||||
RefreshCw,
|
||||
PieChart,
|
||||
TrendingUp,
|
||||
BarChart3,
|
||||
Crown,
|
||||
} from 'lucide-react';
|
||||
import { RefreshCw } from 'lucide-react';
|
||||
import { API } from '../../../helpers/api';
|
||||
import { showError } from '../../../helpers';
|
||||
import { renderQuota } from '../../../helpers/render';
|
||||
import { useActualTheme } from '../../../context/Theme';
|
||||
|
||||
const { Text } = Typography;
|
||||
const getOrgHeaders = (orgId) => ({ 'X-Org-Id': String(orgId) });
|
||||
|
||||
/* 系列色运行时读取品牌 token(--brand-*),随主题预设整套切换。
|
||||
@@ -95,37 +88,20 @@ const chartGrid = (tokens) => ({
|
||||
style: { stroke: tokens.grid, lineDash: [4, 4] },
|
||||
});
|
||||
|
||||
// 环比徽标:本期 vs 上期。增长绿、下降红;无上期数据时灰显。
|
||||
// 状态色统一走 Semi 语义 token(与页面各处使用进度条同一套红绿,且随明暗主题自适应)。
|
||||
// 环比徽标:本期 vs 上期。增长绿、下降红;无上期数据时灰显(语义色沿用原实现)。
|
||||
const DeltaBadge = ({ cur, prev, t }) => {
|
||||
if (!prev || prev <= 0) {
|
||||
return <span className='text-xs text-gray-400'>{t('无上期对比')}</span>;
|
||||
return <small>{t('无上期对比')}</small>;
|
||||
}
|
||||
const pct = ((cur - prev) / prev) * 100;
|
||||
const up = pct >= 0;
|
||||
return (
|
||||
<span
|
||||
className='text-xs font-medium'
|
||||
style={{
|
||||
color: up ? 'var(--ui-color-success)' : 'var(--ui-color-danger)',
|
||||
}}
|
||||
>
|
||||
{up ? '▲' : '▼'} {Math.abs(pct).toFixed(1)}%
|
||||
<span className='text-gray-400 ml-1'>{t('较上期')}</span>
|
||||
</span>
|
||||
<small className={up ? 'is-up' : 'is-down'}>
|
||||
{up ? '↑' : '↓'} {Math.abs(pct).toFixed(1)}%<em>{t('较上期')}</em>
|
||||
</small>
|
||||
);
|
||||
};
|
||||
|
||||
const KpiCard = ({ label, value, sub }) => (
|
||||
<div className='px-4 py-3 rounded-xl bg-[var(--ui-color-fill-0)]'>
|
||||
<div className='text-xs text-gray-500 mb-1'>{label}</div>
|
||||
<div className='text-lg font-semibold text-gray-900 dark:text-white truncate'>
|
||||
{value}
|
||||
</div>
|
||||
{sub ? <div className='mt-0.5'>{sub}</div> : null}
|
||||
</div>
|
||||
);
|
||||
|
||||
// 把 time 维度的小时行聚合成趋势序列:>7 天按天汇总,否则按小时。
|
||||
const buildTrend = (rows, rangeDays, field) => {
|
||||
if (!rows || rows.length === 0) return [];
|
||||
@@ -156,20 +132,28 @@ const localizeAnalyticsRows = (rows, dimension, t) =>
|
||||
department: t('未分配部门'),
|
||||
project: t('未绑定项目'),
|
||||
member: t('未归属成员'),
|
||||
token: t('未绑定令牌'),
|
||||
token: t('未绑定密钥'),
|
||||
}[dimension];
|
||||
if (zeroName) name = zeroName;
|
||||
} else if (dimension === 'member' && name === `成员#${row.key}`) {
|
||||
name = `${t('成员')}#${row.key}`;
|
||||
} else if (dimension === 'token' && name === `令牌#${row.key}`) {
|
||||
name = `${t('令牌')}#${row.key}`;
|
||||
} else if (dimension === 'token' && name === `\u4ee4\u724c#${row.key}`) {
|
||||
name = `${t('密钥')}#${row.key}`;
|
||||
}
|
||||
return name === row.name ? row : { ...row, name };
|
||||
});
|
||||
|
||||
// 多维用量分析面板(§5.6):经营看板视角——KPI+环比、消耗趋势折线、维度分布柱状、明细表。
|
||||
// 仅 admin + analytics 特性开启时挂载(前端门控),后端接口仍 admin+feature 鉴权。
|
||||
const OrgAnalyticsPanel = ({ orgId }) => {
|
||||
// memberUsage:数据看板传入的“成员用量明细”卡,作为明细页签之一(原型 .ea-detail-tabs);
|
||||
// detailTab / onDetailTabChange:明细页签受控(数据看板“成员用量”按钮切换并定位)。
|
||||
const OrgAnalyticsPanel = ({
|
||||
orgId,
|
||||
memberUsage = null,
|
||||
detailTab,
|
||||
onDetailTabChange,
|
||||
detailsRef,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const actualTheme = useActualTheme();
|
||||
const isDarkMode = actualTheme === 'dark';
|
||||
@@ -189,6 +173,11 @@ const OrgAnalyticsPanel = ({ orgId }) => {
|
||||
const [trendRows, setTrendRows] = useState([]);
|
||||
const [prevRows, setPrevRows] = useState([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [detailPage, setDetailPage] = useState(1);
|
||||
|
||||
useEffect(() => {
|
||||
setDetailPage(1);
|
||||
}, [breakdownRows, dimension, rangeDays]);
|
||||
|
||||
useEffect(() => {
|
||||
initVChartTheme({ isWatchingThemeSwitch: true });
|
||||
@@ -200,7 +189,7 @@ const OrgAnalyticsPanel = ({ orgId }) => {
|
||||
{ label: t('项目'), value: 'project' },
|
||||
{ label: t('部门'), value: 'department' },
|
||||
{ label: t('成员'), value: 'member' },
|
||||
{ label: t('令牌'), value: 'token' },
|
||||
{ label: t('密钥'), value: 'token' },
|
||||
{ label: t('时间'), value: 'time' },
|
||||
],
|
||||
[t],
|
||||
@@ -298,7 +287,11 @@ const OrgAnalyticsPanel = ({ orgId }) => {
|
||||
data: [{ id: 'trend', values: trendData }],
|
||||
xField: 'date',
|
||||
yField: 'value',
|
||||
point: { visible: trendData.length <= 60, size: 3 },
|
||||
point: {
|
||||
visible: trendData.length <= 60,
|
||||
size: 3,
|
||||
style: { fill: brandColors.brand },
|
||||
},
|
||||
line: { style: { lineWidth: 2, stroke: brandColors.brand } },
|
||||
area: {
|
||||
style: {
|
||||
@@ -375,7 +368,7 @@ const OrgAnalyticsPanel = ({ orgId }) => {
|
||||
direction: 'horizontal',
|
||||
xField: 'value',
|
||||
yField: 'name',
|
||||
color: [brandColors.brand2],
|
||||
color: [brandColors.brand],
|
||||
barMaxWidth: 22,
|
||||
label: {
|
||||
visible: true,
|
||||
@@ -428,33 +421,52 @@ const OrgAnalyticsPanel = ({ orgId }) => {
|
||||
);
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
{ title: dimLabel, dataIndex: 'name', width: 200 },
|
||||
{
|
||||
title: t('消耗占比'),
|
||||
title: dimLabel,
|
||||
dataIndex: 'name',
|
||||
width: 228,
|
||||
render: (v) => <span className='oc-ea-model-name'>{v}</span>,
|
||||
},
|
||||
{
|
||||
title: t('消费占比'),
|
||||
width: 300,
|
||||
render: (_, r) => {
|
||||
const pct =
|
||||
breakdownTotal > 0 ? ((r.quota || 0) / breakdownTotal) * 100 : 0;
|
||||
return (
|
||||
<div className='flex items-center gap-2'>
|
||||
<div className='oc-ea-cost-share'>
|
||||
<div>
|
||||
<strong>{renderQuota(r.quota || 0, 2)}</strong>
|
||||
<span>{pct.toFixed(1)}%</span>
|
||||
</div>
|
||||
<Progress
|
||||
percent={Math.round(pct)}
|
||||
style={{ flex: 1 }}
|
||||
stroke={brandColors.brand2}
|
||||
size='small'
|
||||
stroke={brandColors.brand}
|
||||
showInfo={false}
|
||||
/>
|
||||
<span className='text-xs text-gray-500 whitespace-nowrap'>
|
||||
{renderQuota(r.quota || 0, 2)} ({pct.toFixed(1)}%)
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{ title: t('请求数'), dataIndex: 'request_count', width: 100 },
|
||||
{
|
||||
title: t('Token (入/出)'),
|
||||
width: 160,
|
||||
render: (_, r) =>
|
||||
`${r.prompt_tokens || 0} / ${r.completion_tokens || 0}`,
|
||||
title: t('请求数'),
|
||||
dataIndex: 'request_count',
|
||||
width: 110,
|
||||
align: 'right',
|
||||
render: (v) => Number(v || 0).toLocaleString(),
|
||||
},
|
||||
{
|
||||
title: t('Token(入 / 出)'),
|
||||
width: 240,
|
||||
align: 'right',
|
||||
render: (_, r) => (
|
||||
<span className='oc-ea-token-pair'>
|
||||
{Number(r.prompt_tokens || 0).toLocaleString()}
|
||||
<small> / </small>
|
||||
{Number(r.completion_tokens || 0).toLocaleString()}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
],
|
||||
[dimLabel, breakdownTotal, t, brandColors],
|
||||
@@ -466,180 +478,215 @@ const OrgAnalyticsPanel = ({ orgId }) => {
|
||||
{ label: t('近 90 天'), value: 90 },
|
||||
];
|
||||
|
||||
const [innerTab, setInnerTab] = useState('models');
|
||||
const activeDetail = detailTab ?? innerTab;
|
||||
const changeDetail = (key) => {
|
||||
setInnerTab(key);
|
||||
onDetailTabChange?.(key);
|
||||
};
|
||||
|
||||
const detailCard = (
|
||||
<AntCard className='oc-ea-detail-card'>
|
||||
<div className='oc-ea-table-toolbar'>
|
||||
<h2>{t('{{dim}}明细', { dim: dimLabel })}</h2>
|
||||
</div>
|
||||
{loading ? (
|
||||
<div className='oc-ea-loading'>
|
||||
<Spin size='large' />
|
||||
</div>
|
||||
) : breakdownRows.length === 0 ? (
|
||||
<Empty
|
||||
description={t('该时间范围暂无用量数据')}
|
||||
style={{ padding: 40 }}
|
||||
/>
|
||||
) : (
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={breakdownRows}
|
||||
rowKey='key'
|
||||
scroll={{ x: 880 }}
|
||||
pagination={{
|
||||
currentPage: Math.min(
|
||||
detailPage,
|
||||
Math.max(1, Math.ceil(breakdownRows.length / 10)),
|
||||
),
|
||||
pageSize: 10,
|
||||
showSizeChanger: false,
|
||||
onPageChange: setDetailPage,
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</AntCard>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='space-y-4'>
|
||||
{/* 控制区 */}
|
||||
<OrgPanel>
|
||||
<div className='flex flex-wrap items-center justify-between gap-3'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<PieChart size={18} className='text-brand-deep' />
|
||||
<Text strong>{t('企业用量分析')}</Text>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('趋势 · 结构 · 与消耗明细一致')}
|
||||
</Text>
|
||||
<>
|
||||
{/* 多维用量分析(原型 .ea-analysis):标题 + 维度 / 时间 / 刷新 */}
|
||||
<section className='oc-ea-analysis'>
|
||||
<div className='oc-ea-analysis-heading'>
|
||||
<div>
|
||||
<h2>{t('多维用量分析')}</h2>
|
||||
<p>{t('趋势、结构与调用明细')}</p>
|
||||
</div>
|
||||
<div className='flex items-center gap-2'>
|
||||
<Select
|
||||
<div className='oc-ea-filters'>
|
||||
<AntSelect
|
||||
className='oc-ea-dimension-select'
|
||||
aria-label={t('维度')}
|
||||
value={dimension}
|
||||
onChange={setDimension}
|
||||
optionList={dimensions}
|
||||
style={{ width: 110 }}
|
||||
options={dimensions}
|
||||
/>
|
||||
<Select
|
||||
<AntSelect
|
||||
className='oc-ea-range-select'
|
||||
aria-label={t('时间范围')}
|
||||
value={rangeDays}
|
||||
onChange={setRangeDays}
|
||||
optionList={rangeOptions}
|
||||
style={{ width: 110 }}
|
||||
options={rangeOptions}
|
||||
/>
|
||||
<Button
|
||||
theme='light'
|
||||
icon={<RefreshCw size={14} />}
|
||||
<AntButton
|
||||
className='oc-ea-refresh'
|
||||
aria-label={t('刷新分析')}
|
||||
icon={<RefreshCw size={16} />}
|
||||
loading={loading}
|
||||
onClick={() => fetchAll(true)}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* KPI + 环比 */}
|
||||
<div className='grid grid-cols-2 lg:grid-cols-4 gap-4 mt-4'>
|
||||
<KpiCard
|
||||
label={t('本期总消耗')}
|
||||
value={renderQuota(curQuota, 2)}
|
||||
sub={<DeltaBadge cur={curQuota} prev={prevQuota} t={t} />}
|
||||
/>
|
||||
<KpiCard
|
||||
label={t('本期总请求')}
|
||||
value={curReq.toLocaleString()}
|
||||
sub={<DeltaBadge cur={curReq} prev={prevReq} t={t} />}
|
||||
/>
|
||||
<KpiCard
|
||||
label={t('日均消耗')}
|
||||
value={renderQuota(rangeDays > 0 ? curQuota / rangeDays : 0, 2)}
|
||||
sub={
|
||||
<span className='text-xs text-gray-400'>
|
||||
{t('近 {{n}} 天均值', { n: rangeDays })}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
<KpiCard
|
||||
label={t('消耗最高')}
|
||||
value={topRow ? topRow.name : '-'}
|
||||
sub={
|
||||
topRow ? (
|
||||
<span className='text-xs text-amber-500 inline-flex items-center gap-1'>
|
||||
<Crown size={11} /> {renderQuota(topRow.quota || 0, 2)}
|
||||
</span>
|
||||
) : (
|
||||
<span className='text-xs text-gray-400'>
|
||||
{dimension === 'time' ? t('按时间维度无排名') : '-'}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</OrgPanel>
|
||||
|
||||
{/* 消耗趋势折线 */}
|
||||
<OrgPanel>
|
||||
<div className='flex items-center justify-between mb-3'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<TrendingUp size={16} className='text-brand-deep' />
|
||||
<Text strong>{t('用量趋势')}</Text>
|
||||
</div>
|
||||
<Select
|
||||
value={trendMetric}
|
||||
onChange={setTrendMetric}
|
||||
optionList={[
|
||||
{ label: t('消耗'), value: 'quota' },
|
||||
{ label: t('请求数'), value: 'requests' },
|
||||
]}
|
||||
style={{ width: 100 }}
|
||||
size='small'
|
||||
/>
|
||||
</div>
|
||||
{loading ? (
|
||||
<div className='flex justify-center py-12'>
|
||||
<Spin size='large' />
|
||||
</div>
|
||||
) : trendSpec ? (
|
||||
<div className='rounded-2xl border border-gray-100/70 dark:border-white/5 bg-white/60 dark:bg-slate-950/25 p-2'>
|
||||
<VChart
|
||||
key={`trend-${actualTheme}`}
|
||||
spec={trendSpec}
|
||||
option={{ mode: 'desktop-browser' }}
|
||||
style={{ height: 280 }}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<Empty
|
||||
description={t('该时间范围暂无用量数据')}
|
||||
style={{ padding: 40 }}
|
||||
/>
|
||||
)}
|
||||
</OrgPanel>
|
||||
</div>
|
||||
|
||||
{/* 维度分布柱状(time 维度不展示,趋势图已覆盖) */}
|
||||
{dimension !== 'time' && (
|
||||
<OrgPanel>
|
||||
<div className='flex items-center gap-2 mb-3'>
|
||||
<BarChart3 size={16} className='text-brand-deep' />
|
||||
<Text strong>{t('{{dim}}消耗分布', { dim: dimLabel })}</Text>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('Top 10')}
|
||||
</Text>
|
||||
{/* 汇总指标(原型 .ea-summary) */}
|
||||
<div className='oc-ea-summary'>
|
||||
<div>
|
||||
<span>{t('本期总消费')}</span>
|
||||
<strong>{renderQuota(curQuota, 2)}</strong>
|
||||
<DeltaBadge cur={curQuota} prev={prevQuota} t={t} />
|
||||
</div>
|
||||
{loading ? (
|
||||
<div className='flex justify-center py-12'>
|
||||
<Spin size='large' />
|
||||
</div>
|
||||
) : barSpec ? (
|
||||
<div className='rounded-2xl border border-gray-100/70 dark:border-white/5 bg-white/60 dark:bg-slate-950/25 p-2'>
|
||||
<VChart
|
||||
key={`bar-${actualTheme}`}
|
||||
spec={barSpec}
|
||||
option={{ mode: 'desktop-browser' }}
|
||||
style={{ height: Math.max(220, barData.length * 34 + 60) }}
|
||||
<div>
|
||||
<span>{t('本期总请求')}</span>
|
||||
<strong>{curReq.toLocaleString()}</strong>
|
||||
<DeltaBadge cur={curReq} prev={prevReq} t={t} />
|
||||
</div>
|
||||
<div>
|
||||
<span>{t('日均消费')}</span>
|
||||
<strong>
|
||||
{renderQuota(rangeDays > 0 ? curQuota / rangeDays : 0, 2)}
|
||||
</strong>
|
||||
<small>{t('近 {{n}} 天均值', { n: rangeDays })}</small>
|
||||
</div>
|
||||
<div>
|
||||
<span>{t('消费最高')}</span>
|
||||
<strong className='oc-ea-top'>{topRow ? topRow.name : '-'}</strong>
|
||||
<small>
|
||||
{topRow
|
||||
? renderQuota(topRow.quota || 0, 2)
|
||||
: dimension === 'time'
|
||||
? t('按时间维度无排名')
|
||||
: '-'}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={`oc-ea-charts${dimension === 'time' ? ' is-single' : ''}`}
|
||||
>
|
||||
{/* 用量趋势 */}
|
||||
<AntCard className='oc-ea-trend'>
|
||||
<div className='oc-ea-panel-heading'>
|
||||
<div>
|
||||
<h2>{t('用量趋势')}</h2>
|
||||
<span>
|
||||
{rangeDays > 7
|
||||
? t('按天查看企业调用消耗')
|
||||
: t('逐小时查看企业调用消耗')}
|
||||
</span>
|
||||
</div>
|
||||
<Segmented
|
||||
size='small'
|
||||
value={trendMetric}
|
||||
onChange={setTrendMetric}
|
||||
options={[
|
||||
{ label: t('消费'), value: 'quota' },
|
||||
{ label: t('请求数'), value: 'requests' },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<Empty
|
||||
description={t('该时间范围暂无用量数据')}
|
||||
style={{ padding: 40 }}
|
||||
/>
|
||||
)}
|
||||
</OrgPanel>
|
||||
)}
|
||||
{loading ? (
|
||||
<div className='oc-ea-loading'>
|
||||
<Spin size='large' />
|
||||
</div>
|
||||
) : trendSpec ? (
|
||||
<VChart
|
||||
key={`trend-${actualTheme}`}
|
||||
spec={trendSpec}
|
||||
option={{ mode: 'desktop-browser' }}
|
||||
style={{ height: 306 }}
|
||||
/>
|
||||
) : (
|
||||
<Empty
|
||||
description={t('该时间范围暂无用量数据')}
|
||||
style={{ padding: 40 }}
|
||||
/>
|
||||
)}
|
||||
</AntCard>
|
||||
|
||||
{/* 明细表 */}
|
||||
<OrgPanel>
|
||||
<div className='flex items-center gap-2 mb-3'>
|
||||
<Text strong>{t('{{dim}}明细', { dim: dimLabel })}</Text>
|
||||
{/* 维度分布柱状(time 维度不展示,趋势图已覆盖) */}
|
||||
{dimension !== 'time' && (
|
||||
<AntCard className='oc-ea-rank'>
|
||||
<div className='oc-ea-panel-heading'>
|
||||
<div>
|
||||
<h2>{t('{{dim}}消费分布', { dim: dimLabel })}</h2>
|
||||
<span>{t('Top 10')}</span>
|
||||
</div>
|
||||
<AntTag bordered={false}>{t('按消费排序')}</AntTag>
|
||||
</div>
|
||||
{loading ? (
|
||||
<div className='oc-ea-loading'>
|
||||
<Spin size='large' />
|
||||
</div>
|
||||
) : barSpec ? (
|
||||
<VChart
|
||||
key={`bar-${actualTheme}`}
|
||||
spec={barSpec}
|
||||
option={{ mode: 'desktop-browser' }}
|
||||
style={{ height: Math.max(306, barData.length * 34 + 60) }}
|
||||
/>
|
||||
) : (
|
||||
<Empty
|
||||
description={t('该时间范围暂无用量数据')}
|
||||
style={{ padding: 40 }}
|
||||
/>
|
||||
)}
|
||||
</AntCard>
|
||||
)}
|
||||
</div>
|
||||
{loading ? (
|
||||
<div className='flex justify-center py-12'>
|
||||
<Spin size='large' />
|
||||
</div>
|
||||
) : breakdownRows.length === 0 ? (
|
||||
<Empty
|
||||
description={t('该时间范围暂无用量数据')}
|
||||
style={{ padding: 40 }}
|
||||
/>
|
||||
) : (
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={breakdownRows}
|
||||
rowKey='key'
|
||||
pagination={
|
||||
breakdownRows.length > 20
|
||||
? { pageSize: 20, showSizeChanger: false }
|
||||
: false
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</OrgPanel>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* 明细(原型 .ea-details:维度明细 / 成员用量 页签) */}
|
||||
<section className='oc-ea-details' ref={detailsRef}>
|
||||
<AntTabs
|
||||
className='oc-ea-detail-tabs'
|
||||
activeKey={memberUsage ? activeDetail : 'models'}
|
||||
onChange={changeDetail}
|
||||
items={[
|
||||
{
|
||||
key: 'models',
|
||||
label: t('{{dim}}明细', { dim: dimLabel }),
|
||||
children: detailCard,
|
||||
},
|
||||
...(memberUsage
|
||||
? [
|
||||
{
|
||||
key: 'members',
|
||||
label: t('成员用量'),
|
||||
forceRender: true,
|
||||
children: memberUsage,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
]}
|
||||
/>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user