fix(ui): 统一表格筛选分页和用量明细,升级 ESLint
This commit is contained in:
@@ -24,6 +24,27 @@ import { useIsMobile } from '../../hooks/common/useIsMobile';
|
||||
import { ConsoleCard, ConsoleSearchBar } from './ConsolePrimitives';
|
||||
import { TableTitle } from '../common/table/TableToolbar';
|
||||
|
||||
export function ConsoleCollectionSearch({ children, className }) {
|
||||
const { t } = useTranslation();
|
||||
const isMobile = useIsMobile();
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
return (
|
||||
<>
|
||||
{isMobile && (
|
||||
<Button
|
||||
onClick={() => setExpanded((value) => !value)}
|
||||
aria-expanded={expanded}
|
||||
>
|
||||
{t(expanded ? '隐藏操作项' : '显示操作项')}
|
||||
</Button>
|
||||
)}
|
||||
<ConsoleSearchBar className={className} hidden={isMobile && !expanded}>
|
||||
{children}
|
||||
</ConsoleSearchBar>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default function ConsoleCollection({
|
||||
children,
|
||||
statsArea,
|
||||
@@ -36,27 +57,13 @@ export default function ConsoleCollection({
|
||||
tableActionsOffset = false,
|
||||
paginationArea,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const isMobile = useIsMobile();
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const showSearch = !isMobile || expanded;
|
||||
return (
|
||||
<div className='console-collection'>
|
||||
{statsArea && (
|
||||
<ConsoleCard className='console-stats'>{statsArea}</ConsoleCard>
|
||||
)}
|
||||
{searchArea && (
|
||||
<>
|
||||
{isMobile && (
|
||||
<Button
|
||||
onClick={() => setExpanded(!expanded)}
|
||||
aria-expanded={expanded}
|
||||
>
|
||||
{t(expanded ? '隐藏操作项' : '显示操作项')}
|
||||
</Button>
|
||||
)}
|
||||
<ConsoleSearchBar hidden={!showSearch}>{searchArea}</ConsoleSearchBar>
|
||||
</>
|
||||
<ConsoleCollectionSearch>{searchArea}</ConsoleCollectionSearch>
|
||||
)}
|
||||
<ConsoleCard>
|
||||
{tabsArea && <div className='console-list-tabs'>{tabsArea}</div>}
|
||||
|
||||
@@ -32,6 +32,8 @@ import {
|
||||
} from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import TableEmpty from '../common/table/TableEmpty';
|
||||
import FilterSearchButton from '../common/table/FilterSearchButton';
|
||||
import './console.css';
|
||||
import {
|
||||
ConsoleSearchContext,
|
||||
useConsolePage,
|
||||
@@ -96,38 +98,32 @@ export function ConsoleSearchBar({ children, className, formProps, ...props }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function ConsoleSearchActions({
|
||||
onReset,
|
||||
onSearch,
|
||||
loading,
|
||||
searchLabel = '搜索',
|
||||
}) {
|
||||
export function ConsoleSearchActions({ onReset, loading }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className='console-search-actions'>
|
||||
{onReset && <Button onClick={onReset}>{t('重置')}</Button>}
|
||||
<Button
|
||||
type='primary'
|
||||
htmlType={onSearch ? 'button' : 'submit'}
|
||||
onClick={onSearch}
|
||||
loading={loading}
|
||||
>
|
||||
{t(searchLabel)}
|
||||
</Button>
|
||||
{onReset && (
|
||||
<Button htmlType='button' onClick={onReset}>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
)}
|
||||
<FilterSearchButton loading={loading} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function ConsoleFilterGrid({ children, onReset, onSearch, loading }) {
|
||||
return (
|
||||
<div className='console-filter-panel'>
|
||||
<form
|
||||
className='console-filter-panel'
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
onSearch();
|
||||
}}
|
||||
>
|
||||
<div className='console-filter-grid'>{children}</div>
|
||||
<ConsoleSearchActions
|
||||
onReset={onReset}
|
||||
onSearch={onSearch}
|
||||
loading={loading}
|
||||
/>
|
||||
</div>
|
||||
<ConsoleSearchActions onReset={onReset} loading={loading} />
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@
|
||||
justify-content: flex-end;
|
||||
flex: 0 0 auto;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--console-space-1);
|
||||
gap: var(--console-space-1, 8px);
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
.console-filter-panel {
|
||||
@@ -253,7 +253,7 @@
|
||||
}
|
||||
.console-filter-field > label,
|
||||
.console-page .console-filter-grid .ant-form-item-label > label {
|
||||
color: var(--console-muted);
|
||||
color: var(--console-muted, var(--ui-color-text-2));
|
||||
font-size: 13px;
|
||||
}
|
||||
.console-filter-field > :is(.ant-input-number, .ant-picker) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import {
|
||||
Plus as ActionPlus,
|
||||
Upload as ActionUpload,
|
||||
} from '@/components/common/icons/ActionIcons';
|
||||
import { TableRowActions } from '@/components/common/table/TableToolbar';
|
||||
import React, { useState, useEffect, useCallback } from 'react';
|
||||
import {
|
||||
Card,
|
||||
@@ -32,6 +31,7 @@ import {
|
||||
Select,
|
||||
Tag,
|
||||
Avatar,
|
||||
Popconfirm,
|
||||
Typography,
|
||||
Space,
|
||||
Banner,
|
||||
@@ -307,34 +307,28 @@ const CustomerServiceSetting = () => {
|
||||
title: t('操作'),
|
||||
dataIndex: 'action',
|
||||
render: (_, record) => (
|
||||
<TableRowActions
|
||||
items={[
|
||||
{
|
||||
key: 'status',
|
||||
label: record.status === 1 ? t('下线') : t('上线'),
|
||||
onClick: () => handleToggleStatus(record),
|
||||
danger: (record.status === 1 ? 'danger' : 'primary') === 'danger',
|
||||
},
|
||||
{
|
||||
key: 'delete',
|
||||
label: t('删除'),
|
||||
danger: true,
|
||||
onClick: () =>
|
||||
Modal.confirm({
|
||||
title: t('确认删除'),
|
||||
content: t('确定要删除这个客服吗?'),
|
||||
okText: t('确认'),
|
||||
cancelText: t('取消'),
|
||||
okButtonProps: { danger: true },
|
||||
onOk: () => handleDelete(record.id),
|
||||
}),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Space>
|
||||
<Button
|
||||
onClick={() => handleToggleStatus(record)}
|
||||
type='link'
|
||||
size='small'
|
||||
danger={(record.status === 1 ? 'danger' : 'primary') === 'danger'}
|
||||
>
|
||||
{record.status === 1 ? t('下线') : t('上线')}
|
||||
</Button>
|
||||
<Button onClick={() => openModal(record)} type='link' size='small'>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
</TableRowActions>
|
||||
<Popconfirm
|
||||
title={t('确认删除')}
|
||||
content={t('确定要删除这个客服吗?')}
|
||||
onConfirm={() => handleDelete(record.id)}
|
||||
>
|
||||
<Button type='link' size='small' danger>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
ChevronDown as ActionChevronDown,
|
||||
ChevronRight as ActionChevronRight,
|
||||
} from '@/components/common/icons/ActionIcons';
|
||||
import { TableRowActions } from '@/components/common/table/TableToolbar';
|
||||
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
||||
import {
|
||||
Card,
|
||||
@@ -990,31 +989,7 @@ const LevelPolicySetting = () => {
|
||||
title: t('操作'),
|
||||
width: 260,
|
||||
render: (_, r) => (
|
||||
<TableRowActions
|
||||
items={[
|
||||
{
|
||||
key: 'copy',
|
||||
label: t('复制'),
|
||||
onClick: () => duplicateLevel(type, r.code),
|
||||
title: t('以该等级为模板新建'),
|
||||
},
|
||||
{
|
||||
key: 'delete',
|
||||
label: t('删除'),
|
||||
disabled: deletingCode === `${type}/${r.code}`,
|
||||
danger: true,
|
||||
onClick: () =>
|
||||
Modal.confirm({
|
||||
title: t('确认删除该等级?'),
|
||||
content: t('被用户/企业/默认等级引用时会被拒绝'),
|
||||
okText: t('确认'),
|
||||
cancelText: t('取消'),
|
||||
okButtonProps: { danger: true },
|
||||
onOk: () => deleteLevel(type, r.code),
|
||||
}),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Space>
|
||||
<Button
|
||||
onClick={() => openEditor(type, r.code)}
|
||||
type='link'
|
||||
@@ -1022,7 +997,30 @@ const LevelPolicySetting = () => {
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
</TableRowActions>
|
||||
<Tooltip content={t('以该等级为模板新建')}>
|
||||
<Button
|
||||
onClick={() => duplicateLevel(type, r.code)}
|
||||
type='link'
|
||||
size='small'
|
||||
>
|
||||
{t('复制')}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Popconfirm
|
||||
title={t('确认删除该等级?')}
|
||||
content={t('被用户/企业/默认等级引用时会被拒绝')}
|
||||
onConfirm={() => deleteLevel(type, r.code)}
|
||||
>
|
||||
<Button
|
||||
loading={deletingCode === `${type}/${r.code}`}
|
||||
type='link'
|
||||
size='small'
|
||||
danger
|
||||
>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -18,7 +18,6 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
|
||||
import { TableRowActions } from '@/components/common/table/TableToolbar';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
@@ -28,6 +27,7 @@ import {
|
||||
Modal,
|
||||
Form,
|
||||
Toast,
|
||||
Popconfirm,
|
||||
Switch,
|
||||
Tag,
|
||||
Progress,
|
||||
@@ -262,29 +262,7 @@ const TutorialVideoSetting = () => {
|
||||
title: t('操作'),
|
||||
width: 180,
|
||||
render: (_, record) => (
|
||||
<TableRowActions
|
||||
items={[
|
||||
{
|
||||
key: 'edit',
|
||||
label: t('编辑'),
|
||||
onClick: () => handleEdit(record),
|
||||
},
|
||||
{
|
||||
key: 'delete',
|
||||
label: t('删除'),
|
||||
danger: true,
|
||||
onClick: () =>
|
||||
Modal.confirm({
|
||||
title: t('确定删除这个视频吗?'),
|
||||
content: t('删除后将无法恢复'),
|
||||
okText: t('确认'),
|
||||
cancelText: t('取消'),
|
||||
okButtonProps: { danger: true },
|
||||
onOk: () => handleDelete(record.id),
|
||||
}),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<div style={{ display: 'flex', gap: 8 }}>
|
||||
<Button
|
||||
onClick={() => handlePreview(record)}
|
||||
type='link'
|
||||
@@ -292,7 +270,19 @@ const TutorialVideoSetting = () => {
|
||||
>
|
||||
{t('预览')}
|
||||
</Button>
|
||||
</TableRowActions>
|
||||
<Button onClick={() => handleEdit(record)} type='link' size='small'>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title={t('确定删除这个视频吗?')}
|
||||
content={t('删除后将无法恢复')}
|
||||
onConfirm={() => handleDelete(record.id)}
|
||||
>
|
||||
<Button type='link' size='small' danger>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -30,6 +30,7 @@ const DecisionTable = ({ mode, orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
const [data, setData] = useState({ items: [], total: 0 });
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState('');
|
||||
|
||||
@@ -38,7 +39,10 @@ const DecisionTable = ({ mode, orgId }) => {
|
||||
setError('');
|
||||
try {
|
||||
setData(
|
||||
(await listDecisions(mode, orgId, { p: page, page_size: 20 })) || {
|
||||
(await listDecisions(mode, orgId, {
|
||||
p: page,
|
||||
page_size: pageSize,
|
||||
})) || {
|
||||
items: [],
|
||||
total: 0,
|
||||
},
|
||||
@@ -48,7 +52,7 @@ const DecisionTable = ({ mode, orgId }) => {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [mode, orgId, page, t]);
|
||||
}, [mode, orgId, page, pageSize, t]);
|
||||
|
||||
useEffect(() => {
|
||||
load();
|
||||
@@ -147,12 +151,18 @@ const DecisionTable = ({ mode, orgId }) => {
|
||||
/>
|
||||
}
|
||||
pagination={{
|
||||
// 接口固定 page_size=20,不提供每页条数切换
|
||||
current: page,
|
||||
pageSize: 20,
|
||||
pageSize,
|
||||
total: data.total || 0,
|
||||
size: 'small',
|
||||
showSizeChanger: false,
|
||||
showSizeChanger: mode === 'org',
|
||||
onPageSizeChange:
|
||||
mode === 'org'
|
||||
? (size) => {
|
||||
setPage(1);
|
||||
setPageSize(size);
|
||||
}
|
||||
: undefined,
|
||||
showTotal: (total) => t('共 {{total}} 条', { total }),
|
||||
onChange: setPage,
|
||||
}}
|
||||
|
||||
@@ -19,8 +19,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button, Empty, Modal, Space, Tag, Typography } from 'antd';
|
||||
import { TableRowActions } from '@/components/common/table/TableToolbar';
|
||||
import { Button, Empty, Popconfirm, Space, Tag, Typography } from 'antd';
|
||||
import { Table } from '@/components/ui';
|
||||
import { ConsoleAlert as Alert } from '../console/ConsolePrimitives';
|
||||
import { Plus } from '../common/icons/ActionIcons';
|
||||
@@ -149,37 +148,7 @@ const ProfileTable = ({ mode, orgId, canWrite = true, emptyHint }) => {
|
||||
fixed: 'right',
|
||||
width: 180,
|
||||
render: (_, r) => (
|
||||
<TableRowActions
|
||||
items={[
|
||||
canWrite && {
|
||||
key: 'edit',
|
||||
label: t('编辑'),
|
||||
onClick: () => setEditing(r),
|
||||
},
|
||||
canWrite && {
|
||||
key: 'delete',
|
||||
label: t('删除'),
|
||||
danger: true,
|
||||
onClick: () =>
|
||||
Modal.confirm({
|
||||
title: t('确认删除该集合?'),
|
||||
content: t('使用该虚拟模型名的请求将返回"模型不存在"。'),
|
||||
okText: t('确认'),
|
||||
cancelText: t('取消'),
|
||||
okButtonProps: { danger: true },
|
||||
onOk: async () => {
|
||||
try {
|
||||
await deleteProfile(mode, orgId, r.id);
|
||||
showSuccess(t('已删除'));
|
||||
load();
|
||||
} catch (e) {
|
||||
if (e?.message) showError(e.message);
|
||||
}
|
||||
},
|
||||
}),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Space size={8} wrap>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
@@ -188,7 +157,32 @@ const ProfileTable = ({ mode, orgId, canWrite = true, emptyHint }) => {
|
||||
>
|
||||
{t('试路由')}
|
||||
</Button>
|
||||
</TableRowActions>
|
||||
{canWrite && (
|
||||
<>
|
||||
<Button type='link' size='small' onClick={() => setEditing(r)}>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title={t('确认删除该集合?')}
|
||||
description={t('使用该虚拟模型名的请求将返回"模型不存在"。')}
|
||||
okButtonProps={{ danger: true }}
|
||||
onConfirm={async () => {
|
||||
try {
|
||||
await deleteProfile(mode, orgId, r.id);
|
||||
showSuccess(t('已删除'));
|
||||
load();
|
||||
} catch (e) {
|
||||
if (e?.message) showError(e.message);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Button type='link' size='small' danger>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
@@ -227,7 +221,7 @@ const ProfileTable = ({ mode, orgId, canWrite = true, emptyHint }) => {
|
||||
loading={loading}
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
pagination={false}
|
||||
pagination={mode === 'org' ? { resetOnDataChange: true } : false}
|
||||
scroll={{ x: 'max-content' }}
|
||||
empty={
|
||||
<Empty
|
||||
|
||||
@@ -18,9 +18,9 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useRef } from 'react';
|
||||
import { Form, Button } from '@/components/ui';
|
||||
import { Form } from '@/components/ui';
|
||||
import { IconSearch } from '@/components/ui/icons';
|
||||
import FilterSearchButton from '../../common/table/FilterSearchButton';
|
||||
import { ConsoleSearchActions } from '../../console/ConsolePrimitives';
|
||||
import { useFilterSearch } from '../../../hooks/common/useFilterSearch';
|
||||
|
||||
const AdminTokensFilters = ({
|
||||
@@ -67,93 +67,85 @@ const AdminTokensFilters = ({
|
||||
autoComplete='off'
|
||||
layout='vertical'
|
||||
trigger='change'
|
||||
className='admin-tokens-filter-form'
|
||||
className='console-filter-panel'
|
||||
>
|
||||
<div className='admin-tokens-filter-grid'>
|
||||
<div className='admin-tokens-filter-field'>
|
||||
<Form.Input
|
||||
field='keyword'
|
||||
label={t('密钥名称 / Key 片段')}
|
||||
prefix={<IconSearch />}
|
||||
placeholder={t('密钥名称 / Key 片段')}
|
||||
showClear
|
||||
/>
|
||||
</div>
|
||||
<div className='admin-tokens-filter-field'>
|
||||
<Form.Input
|
||||
field='user_keyword'
|
||||
label={t('用户名/昵称')}
|
||||
placeholder={t('用户名/昵称')}
|
||||
showClear
|
||||
/>
|
||||
</div>
|
||||
<div className='admin-tokens-filter-field'>
|
||||
<Form.Input
|
||||
field='user_id'
|
||||
label={t('用户ID')}
|
||||
placeholder={t('用户ID')}
|
||||
type='number'
|
||||
showClear
|
||||
/>
|
||||
</div>
|
||||
<div className='admin-tokens-filter-field'>
|
||||
<Form.Select
|
||||
field='statuses'
|
||||
label={t('状态')}
|
||||
placeholder={t('状态(多选)')}
|
||||
multiple
|
||||
optionList={[
|
||||
{ label: t('已启用'), value: 1 },
|
||||
{ label: t('已禁用'), value: 2 },
|
||||
{ label: t('已过期'), value: 3 },
|
||||
{ label: t('已耗尽'), value: 4 },
|
||||
]}
|
||||
showClear
|
||||
className='w-full'
|
||||
/>
|
||||
</div>
|
||||
<div className='admin-tokens-filter-field'>
|
||||
<Form.Select
|
||||
field='group'
|
||||
label={t('分组')}
|
||||
placeholder={t('分组')}
|
||||
optionList={groupOptions}
|
||||
showClear
|
||||
className='w-full'
|
||||
/>
|
||||
</div>
|
||||
<div className='admin-tokens-filter-field'>
|
||||
<Form.Select
|
||||
field='unlimited'
|
||||
label={t('剩余额度')}
|
||||
placeholder={t('剩余额度')}
|
||||
optionList={[
|
||||
{ label: t('无限额度'), value: true },
|
||||
{ label: t('有限额度'), value: false },
|
||||
]}
|
||||
showClear
|
||||
className='w-full'
|
||||
/>
|
||||
</div>
|
||||
<div className='admin-tokens-filter-field'>
|
||||
<Form.Select
|
||||
field='org_scope'
|
||||
label={t('归属')}
|
||||
placeholder={t('归属')}
|
||||
optionList={[
|
||||
{ label: t('全部'), value: 'all' },
|
||||
{ label: t('个人'), value: 'personal' },
|
||||
{ label: t('企业'), value: 'org' },
|
||||
]}
|
||||
showClear={false}
|
||||
className='w-full'
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className='admin-tokens-filter-actions'>
|
||||
<Button onClick={handleReset}>{t('重置')}</Button>
|
||||
<FilterSearchButton loading={loading || searching} />
|
||||
<div className='console-filter-grid'>
|
||||
<Form.Input
|
||||
field='keyword'
|
||||
label={t('密钥名称 / Key 片段')}
|
||||
prefix={<IconSearch />}
|
||||
placeholder={t('密钥名称 / Key 片段')}
|
||||
showClear
|
||||
/>
|
||||
|
||||
<Form.Input
|
||||
field='user_keyword'
|
||||
label={t('用户名/昵称')}
|
||||
placeholder={t('用户名/昵称')}
|
||||
showClear
|
||||
/>
|
||||
|
||||
<Form.Input
|
||||
field='user_id'
|
||||
label={t('用户ID')}
|
||||
placeholder={t('用户ID')}
|
||||
type='number'
|
||||
showClear
|
||||
/>
|
||||
|
||||
<Form.Select
|
||||
field='statuses'
|
||||
label={t('状态')}
|
||||
placeholder={t('状态(多选)')}
|
||||
multiple
|
||||
optionList={[
|
||||
{ label: t('已启用'), value: 1 },
|
||||
{ label: t('已禁用'), value: 2 },
|
||||
{ label: t('已过期'), value: 3 },
|
||||
{ label: t('已耗尽'), value: 4 },
|
||||
]}
|
||||
showClear
|
||||
className='w-full'
|
||||
/>
|
||||
|
||||
<Form.Select
|
||||
field='group'
|
||||
label={t('分组')}
|
||||
placeholder={t('分组')}
|
||||
optionList={groupOptions}
|
||||
showClear
|
||||
className='w-full'
|
||||
/>
|
||||
|
||||
<Form.Select
|
||||
field='unlimited'
|
||||
label={t('剩余额度')}
|
||||
placeholder={t('剩余额度')}
|
||||
optionList={[
|
||||
{ label: t('无限额度'), value: true },
|
||||
{ label: t('有限额度'), value: false },
|
||||
]}
|
||||
showClear
|
||||
className='w-full'
|
||||
/>
|
||||
|
||||
<Form.Select
|
||||
field='org_scope'
|
||||
label={t('归属')}
|
||||
placeholder={t('归属')}
|
||||
optionList={[
|
||||
{ label: t('全部'), value: 'all' },
|
||||
{ label: t('个人'), value: 'personal' },
|
||||
{ label: t('企业'), value: 'org' },
|
||||
]}
|
||||
showClear={false}
|
||||
className='w-full'
|
||||
/>
|
||||
</div>
|
||||
<ConsoleSearchActions
|
||||
onReset={handleReset}
|
||||
loading={loading || searching}
|
||||
/>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,32 +1,3 @@
|
||||
.console-page .console-search-card .admin-tokens-filter-form {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.admin-tokens-filter-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 1rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.console-page .admin-tokens-filter-grid .ant-form-item-label > label {
|
||||
color: var(--console-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.admin-tokens-filter-actions,
|
||||
.admin-tokens-tools {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.admin-tokens-filter-actions {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.admin-tokens-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -39,6 +10,11 @@
|
||||
|
||||
.admin-tokens-tools {
|
||||
margin-inline-start: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.console-page .console-table.admin-tokens-table .ant-table-thead > tr > th {
|
||||
@@ -78,15 +54,3 @@
|
||||
padding: 0 4px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.admin-tokens-filter-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.admin-tokens-filter-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { writeClipboardText } from '../../../helpers/clipboard';
|
||||
import { TableRowActions } from '@/components/common/table/TableToolbar';
|
||||
import React, { useState } from 'react';
|
||||
import { Switch } from 'antd';
|
||||
import {
|
||||
@@ -730,110 +729,142 @@ export const getChannelsColumns = ({
|
||||
dataIndex: 'operate',
|
||||
fixed: 'right',
|
||||
render: (text, record, index) => {
|
||||
if (!isRoot()) return null;
|
||||
if (record.children !== undefined) {
|
||||
if (record.children === undefined) {
|
||||
const moreMenuItems = [
|
||||
{
|
||||
node: 'item',
|
||||
name: t('删除'),
|
||||
type: 'danger',
|
||||
onClick: async () => {
|
||||
const content = await buildDeleteConfirmContent(record.id, t);
|
||||
Modal.confirm({
|
||||
title: t('确定是否要删除此渠道?'),
|
||||
content,
|
||||
onOk: () => {
|
||||
(async () => {
|
||||
await manageChannel(record.id, 'delete', record);
|
||||
await refresh();
|
||||
setTimeout(() => {
|
||||
if (channels.length === 0 && activePage > 1) {
|
||||
refresh(activePage - 1);
|
||||
}
|
||||
}, 100);
|
||||
})();
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
node: 'item',
|
||||
name: t('复制'),
|
||||
type: 'tertiary',
|
||||
onClick: () => {
|
||||
Modal.confirm({
|
||||
title: t('确定是否要复制此渠道?'),
|
||||
content: t('复制渠道的所有信息'),
|
||||
onOk: () => copySelectedChannel(record),
|
||||
});
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<TableRowActions
|
||||
items={[
|
||||
{
|
||||
key: 'enable',
|
||||
label: t('启用全部'),
|
||||
onClick: () => manageTag(record.key, 'enable'),
|
||||
},
|
||||
{
|
||||
key: 'disable',
|
||||
label: t('禁用全部'),
|
||||
onClick: () => manageTag(record.key, 'disable'),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setShowEditTag(true);
|
||||
setEditingTag(record.key);
|
||||
}}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
</TableRowActions>
|
||||
<Space wrap className='console-module-row-actions'>
|
||||
{isRoot() && (
|
||||
<>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => testChannel(record, '')}
|
||||
>
|
||||
{t('测试')}
|
||||
</Button>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setCurrentTestChannel(record);
|
||||
setShowModelTestModal(true);
|
||||
}}
|
||||
>
|
||||
{t('批量测试')}
|
||||
</Button>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setEditingChannel(record);
|
||||
setShowEdit(true);
|
||||
}}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
<Button
|
||||
type='link'
|
||||
danger
|
||||
size='small'
|
||||
onClick={moreMenuItems[0].onClick}
|
||||
>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={moreMenuItems[1].onClick}
|
||||
>
|
||||
{t('复制')}
|
||||
</Button>
|
||||
{record.channel_info?.is_multi_key && (
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setCurrentMultiKeyChannel(record);
|
||||
setShowMultiKeyManageModal(true);
|
||||
}}
|
||||
>
|
||||
{t('多密钥管理')}
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Space>
|
||||
);
|
||||
} else {
|
||||
// 标签操作按钮
|
||||
return (
|
||||
<Space wrap>
|
||||
{isRoot() && (
|
||||
<>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => manageTag(record.key, 'enable')}
|
||||
>
|
||||
{t('启用全部')}
|
||||
</Button>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => manageTag(record.key, 'disable')}
|
||||
>
|
||||
{t('禁用全部')}
|
||||
</Button>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setShowEditTag(true);
|
||||
setEditingTag(record.key);
|
||||
}}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<TableRowActions
|
||||
items={[
|
||||
{
|
||||
key: 'batch-test',
|
||||
label: t('批量测试'),
|
||||
onClick: () => {
|
||||
setCurrentTestChannel(record);
|
||||
setShowModelTestModal(true);
|
||||
},
|
||||
},
|
||||
record.channel_info?.is_multi_key && {
|
||||
key: 'multi-key',
|
||||
label: t('多密钥管理'),
|
||||
onClick: () => {
|
||||
setCurrentMultiKeyChannel(record);
|
||||
setShowMultiKeyManageModal(true);
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'copy',
|
||||
label: t('复制'),
|
||||
onClick: () => {
|
||||
Modal.confirm({
|
||||
title: t('确定是否要复制此渠道?'),
|
||||
content: t('复制渠道的所有信息'),
|
||||
onOk: () => copySelectedChannel(record),
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'delete',
|
||||
label: t('删除'),
|
||||
danger: true,
|
||||
onClick: async () => {
|
||||
const content = await buildDeleteConfirmContent(record.id, t);
|
||||
Modal.confirm({
|
||||
title: t('确定是否要删除此渠道?'),
|
||||
content,
|
||||
onOk: () => {
|
||||
(async () => {
|
||||
await manageChannel(record.id, 'delete', record);
|
||||
await refresh();
|
||||
setTimeout(() => {
|
||||
if (channels.length === 0 && activePage > 1) {
|
||||
refresh(activePage - 1);
|
||||
}
|
||||
}, 100);
|
||||
})();
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => testChannel(record, '')}
|
||||
>
|
||||
{t('测试')}
|
||||
</Button>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setEditingChannel(record);
|
||||
setShowEdit(true);
|
||||
}}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
</TableRowActions>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -18,10 +18,9 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { Copy as ActionCopy } from '@/components/common/icons/ActionIcons';
|
||||
import { TableRowActions } from '@/components/common/table/TableToolbar';
|
||||
import React from 'react';
|
||||
import { Button as AntButton, Tooltip as AntTooltip } from 'antd';
|
||||
import { Button, Tag, Modal, Tooltip } from '@/components/ui';
|
||||
import { Button, Space, Tag, Modal, Tooltip } from '@/components/ui';
|
||||
import {
|
||||
timestamp2string,
|
||||
getLobeHubIcon,
|
||||
@@ -240,57 +239,64 @@ const renderOperations = (
|
||||
setDetailModel,
|
||||
) => {
|
||||
return (
|
||||
<TableRowActions
|
||||
items={
|
||||
isRoot()
|
||||
? [
|
||||
{
|
||||
key: 'toggle-status',
|
||||
label: record.status === 1 ? t('禁用') : t('启用'),
|
||||
onClick: () =>
|
||||
manageModel(
|
||||
record.id,
|
||||
record.status === 1 ? 'disable' : 'enable',
|
||||
record,
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'delete',
|
||||
label: t('删除'),
|
||||
danger: true,
|
||||
onClick: () => {
|
||||
Modal.confirm({
|
||||
title: t('确定是否要删除此模型?'),
|
||||
content: t('此修改将不可逆'),
|
||||
onOk: () => {
|
||||
(async () => {
|
||||
await manageModel(record.id, 'delete', record);
|
||||
await refresh();
|
||||
})();
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
]
|
||||
: []
|
||||
}
|
||||
>
|
||||
<Space wrap className='console-module-row-actions'>
|
||||
<Button type='link' size='small' onClick={() => setDetailModel(record)}>
|
||||
{t('详情')}
|
||||
</Button>
|
||||
{isRoot() && (
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setEditingModel(record);
|
||||
setShowEdit(true);
|
||||
}}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
<>
|
||||
{record.status === 1 ? (
|
||||
<Button
|
||||
type='link'
|
||||
danger
|
||||
size='small'
|
||||
onClick={() => manageModel(record.id, 'disable', record)}
|
||||
>
|
||||
{t('禁用')}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => manageModel(record.id, 'enable', record)}
|
||||
>
|
||||
{t('启用')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setEditingModel(record);
|
||||
setShowEdit(true);
|
||||
}}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type='link'
|
||||
danger
|
||||
size='small'
|
||||
onClick={() => {
|
||||
Modal.confirm({
|
||||
title: t('确定是否要删除此模型?'),
|
||||
content: t('此修改将不可逆'),
|
||||
onOk: () => {
|
||||
(async () => {
|
||||
await manageModel(record.id, 'delete', record);
|
||||
await refresh();
|
||||
})();
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</TableRowActions>
|
||||
</Space>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Copy, Plus, Trash2 } from '@/components/common/icons/ActionIcons';
|
||||
import { Button } from '@/components/ui';
|
||||
import { isAdmin } from '../../../helpers';
|
||||
|
||||
@@ -39,17 +40,25 @@ const RedemptionsActions = ({
|
||||
|
||||
return (
|
||||
<div className='console-list-tool-actions'>
|
||||
<Button onClick={batchCopyRedemptions}>
|
||||
<Button icon={<Copy size={16} />} onClick={batchCopyRedemptions}>
|
||||
{t('复制所选兑换码到剪贴板')}
|
||||
</Button>
|
||||
|
||||
{isAdmin() && (
|
||||
<Button type='danger' onClick={batchDeleteRedemptions}>
|
||||
<Button
|
||||
type='danger'
|
||||
icon={<Trash2 size={16} />}
|
||||
onClick={batchDeleteRedemptions}
|
||||
>
|
||||
{t('清除失效兑换码')}
|
||||
</Button>
|
||||
)}
|
||||
{isAdmin() && (
|
||||
<Button type='primary' onClick={handleAddRedemption}>
|
||||
<Button
|
||||
type='primary'
|
||||
icon={<Plus size={16} />}
|
||||
onClick={handleAddRedemption}
|
||||
>
|
||||
{t('添加兑换码')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@@ -18,8 +18,8 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Tag, Button, Popover } from '@/components/ui';
|
||||
import { TableRowActions } from '@/components/common/table/TableToolbar';
|
||||
import { Tag, Button, Space, Popover, Dropdown } from '@/components/ui';
|
||||
import { IconMore } from '@/components/ui/icons';
|
||||
import {
|
||||
renderQuota,
|
||||
timestamp2string,
|
||||
@@ -147,39 +147,43 @@ export const getRedemptionsColumns = ({
|
||||
title: t('操作'),
|
||||
dataIndex: 'operate',
|
||||
fixed: 'right',
|
||||
width: 215,
|
||||
width: 205,
|
||||
render: (text, record) => {
|
||||
const moreMenuItems = [];
|
||||
if (isAdmin() && !isExpired(record)) {
|
||||
const unused = record.status === REDEMPTION_STATUS.UNUSED;
|
||||
// Create dropdown menu items for more operations
|
||||
const moreMenuItems = [
|
||||
{
|
||||
node: 'item',
|
||||
name: t('删除'),
|
||||
type: 'danger',
|
||||
onClick: () => {
|
||||
showDeleteRedemptionModal(record);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
if (record.status === REDEMPTION_STATUS.UNUSED && !isExpired(record)) {
|
||||
moreMenuItems.push({
|
||||
key: 'toggle-status',
|
||||
label: unused ? t('禁用') : t('启用'),
|
||||
disabled: record.status === REDEMPTION_STATUS.USED,
|
||||
onClick: () =>
|
||||
manageRedemption(
|
||||
record.id,
|
||||
unused ? REDEMPTION_ACTIONS.DISABLE : REDEMPTION_ACTIONS.ENABLE,
|
||||
record,
|
||||
),
|
||||
node: 'item',
|
||||
name: t('禁用'),
|
||||
type: 'warning',
|
||||
onClick: () => {
|
||||
manageRedemption(record.id, REDEMPTION_ACTIONS.DISABLE, record);
|
||||
},
|
||||
});
|
||||
}
|
||||
moreMenuItems.unshift({
|
||||
key: 'copy',
|
||||
label: t('复制'),
|
||||
onClick: () => copyText(record.key),
|
||||
});
|
||||
if (isAdmin()) {
|
||||
} else if (!isExpired(record)) {
|
||||
moreMenuItems.push({
|
||||
key: 'delete',
|
||||
label: t('删除'),
|
||||
danger: true,
|
||||
onClick: () => showDeleteRedemptionModal(record),
|
||||
node: 'item',
|
||||
name: t('启用'),
|
||||
type: 'secondary',
|
||||
onClick: () => {
|
||||
manageRedemption(record.id, REDEMPTION_ACTIONS.ENABLE, record);
|
||||
},
|
||||
disabled: record.status === REDEMPTION_STATUS.USED,
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<TableRowActions items={moreMenuItems}>
|
||||
<Space>
|
||||
<Popover
|
||||
// 触屏必须 click:这是查看兑换码明文的唯一入口
|
||||
trigger={hoverOrClickTrigger()}
|
||||
@@ -187,24 +191,41 @@ export const getRedemptionsColumns = ({
|
||||
style={{ padding: 20 }}
|
||||
position='top'
|
||||
>
|
||||
<Button type='link' size='small'>
|
||||
<Button type='tertiary' size='small'>
|
||||
{t('查看')}
|
||||
</Button>
|
||||
</Popover>
|
||||
<Button
|
||||
size='small'
|
||||
onClick={async () => {
|
||||
await copyText(record.key);
|
||||
}}
|
||||
>
|
||||
{t('复制')}
|
||||
</Button>
|
||||
{isAdmin() && (
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setEditingRedemption(record);
|
||||
setShowEdit(true);
|
||||
}}
|
||||
disabled={record.status !== REDEMPTION_STATUS.UNUSED}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
<>
|
||||
<Button
|
||||
type='tertiary'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setEditingRedemption(record);
|
||||
setShowEdit(true);
|
||||
}}
|
||||
disabled={record.status !== REDEMPTION_STATUS.UNUSED}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
<Dropdown
|
||||
trigger='click'
|
||||
position='bottomRight'
|
||||
menu={moreMenuItems}
|
||||
>
|
||||
<Button type='tertiary' size='small' icon={<IconMore />} />
|
||||
</Dropdown>
|
||||
</>
|
||||
)}
|
||||
</TableRowActions>
|
||||
</Space>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -18,10 +18,11 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { TableRowActions } from '@/components/common/table/TableToolbar';
|
||||
import {
|
||||
Button,
|
||||
Dropdown,
|
||||
Space,
|
||||
SplitButtonGroup,
|
||||
Tag,
|
||||
AvatarGroup,
|
||||
Avatar,
|
||||
@@ -39,7 +40,12 @@ import {
|
||||
getModelCategories,
|
||||
showError,
|
||||
} from '../../../helpers';
|
||||
import { IconCopy, IconEyeOpened, IconEyeClosed } from '@/components/ui/icons';
|
||||
import {
|
||||
IconTreeTriangleDown,
|
||||
IconCopy,
|
||||
IconEyeOpened,
|
||||
IconEyeClosed,
|
||||
} from '@/components/ui/icons';
|
||||
|
||||
// progress color helper
|
||||
const getProgressColor = (pct) => {
|
||||
@@ -321,6 +327,7 @@ const renderOperations = (
|
||||
const name = Object.keys(item)[0];
|
||||
if (!name) continue;
|
||||
chatsArray.push({
|
||||
node: 'item',
|
||||
key: i,
|
||||
name,
|
||||
value: item[name],
|
||||
@@ -333,70 +340,87 @@ const renderOperations = (
|
||||
}
|
||||
|
||||
return (
|
||||
<TableRowActions
|
||||
items={[
|
||||
chatsArray.length > 0 && {
|
||||
key: 'chat-links',
|
||||
label: t('聊天链接'),
|
||||
children: chatsArray.map((item) => ({
|
||||
key: `chat-${item.key}`,
|
||||
label: item.name,
|
||||
onClick: item.onClick,
|
||||
})),
|
||||
},
|
||||
{
|
||||
key: 'status',
|
||||
label: record.status === 1 ? t('禁用') : t('启用'),
|
||||
danger: record.status === 1,
|
||||
onClick: async () => {
|
||||
await manageToken(
|
||||
record.id,
|
||||
record.status === 1 ? 'disable' : 'enable',
|
||||
record,
|
||||
);
|
||||
<Space wrap>
|
||||
<SplitButtonGroup
|
||||
className='overflow-hidden'
|
||||
aria-label={t('项目操作按钮组')}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
onClick={() => {
|
||||
if (chatsArray.length === 0) {
|
||||
showError(t('请联系管理员配置聊天链接'));
|
||||
} else {
|
||||
const first = chatsArray[0];
|
||||
onOpenLink(first.name, first.value, record);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t('聊天')}
|
||||
</Button>
|
||||
<Dropdown trigger='click' position='bottomRight' menu={chatsArray}>
|
||||
<Button
|
||||
type='tertiary'
|
||||
icon={<IconTreeTriangleDown />}
|
||||
size='small'
|
||||
></Button>
|
||||
</Dropdown>
|
||||
</SplitButtonGroup>
|
||||
|
||||
{record.status === 1 ? (
|
||||
<Button
|
||||
type='danger'
|
||||
size='small'
|
||||
onClick={async () => {
|
||||
await manageToken(record.id, 'disable', record);
|
||||
await refresh();
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'edit',
|
||||
label: t('编辑'),
|
||||
onClick: () => {
|
||||
setEditingToken(record);
|
||||
setShowEdit(true);
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'delete',
|
||||
label: t('删除'),
|
||||
danger: true,
|
||||
onClick: () =>
|
||||
Modal.confirm({
|
||||
title: t('确定是否要删除此密钥?'),
|
||||
content: t('此修改将不可逆'),
|
||||
okButtonProps: { danger: true },
|
||||
onOk: async () => {
|
||||
await manageToken(record.id, 'delete', record);
|
||||
await refresh();
|
||||
},
|
||||
}),
|
||||
},
|
||||
]}
|
||||
>
|
||||
}}
|
||||
>
|
||||
{t('禁用')}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
size='small'
|
||||
onClick={async () => {
|
||||
await manageToken(record.id, 'enable', record);
|
||||
await refresh();
|
||||
}}
|
||||
>
|
||||
{t('启用')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Button
|
||||
type='tertiary'
|
||||
size='small'
|
||||
type='link'
|
||||
onClick={() => {
|
||||
if (chatsArray.length === 0) {
|
||||
showError(t('请联系管理员配置聊天链接'));
|
||||
} else {
|
||||
const first = chatsArray[0];
|
||||
onOpenLink(first.name, first.value, record);
|
||||
}
|
||||
setEditingToken(record);
|
||||
setShowEdit(true);
|
||||
}}
|
||||
>
|
||||
{t('聊天')}
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
</TableRowActions>
|
||||
|
||||
<Button
|
||||
type='danger'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
Modal.confirm({
|
||||
title: t('确定是否要删除此密钥?'),
|
||||
content: t('此修改将不可逆'),
|
||||
onOk: () => {
|
||||
(async () => {
|
||||
await manageToken(record.id, 'delete', record);
|
||||
await refresh();
|
||||
})();
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
</Space>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -33,6 +33,29 @@
|
||||
color: var(--ui-color-primary);
|
||||
}
|
||||
|
||||
.usage-logs-table .ant-table-cell.usage-record-cell-use_time {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.usage-record-use-time {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
vertical-align: middle;
|
||||
gap: 6px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.usage-logs-table .usage-record-use-time .ant-tag {
|
||||
margin-inline-end: 0;
|
||||
padding: 0 6px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.usage-logs-table-shell {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@@ -130,93 +130,6 @@ function renderType(type, t) {
|
||||
);
|
||||
}
|
||||
|
||||
function renderIsStream(bool, t) {
|
||||
if (bool) {
|
||||
return (
|
||||
<span className='inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs font-medium bg-blue-50 dark:bg-blue-950/30 text-blue-600 dark:text-blue-400 border border-blue-200/50 dark:border-blue-800/50'>
|
||||
<span className='w-1 h-1 rounded-full bg-blue-500 animate-pulse' />
|
||||
{t('流')}
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<span className='inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium bg-gray-50 dark:bg-gray-900/30 text-gray-500 dark:text-gray-400 border border-gray-200/50 dark:border-gray-700/50'>
|
||||
{t('非流')}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function renderUseTime(type, t) {
|
||||
const time = parseInt(type);
|
||||
let colorConfig;
|
||||
|
||||
if (time < 101) {
|
||||
colorConfig = {
|
||||
bg: 'bg-emerald-50 dark:bg-emerald-950/30',
|
||||
text: 'text-emerald-600 dark:text-emerald-400',
|
||||
border: 'border-emerald-200/50 dark:border-emerald-800/50',
|
||||
dot: 'bg-emerald-500',
|
||||
};
|
||||
} else if (time < 300) {
|
||||
colorConfig = {
|
||||
bg: 'bg-amber-50 dark:bg-amber-950/30',
|
||||
text: 'text-amber-600 dark:text-amber-400',
|
||||
border: 'border-amber-200/50 dark:border-amber-800/50',
|
||||
dot: 'bg-amber-500',
|
||||
};
|
||||
} else {
|
||||
colorConfig = {
|
||||
bg: 'bg-rose-50 dark:bg-rose-950/30',
|
||||
text: 'text-rose-600 dark:text-rose-400',
|
||||
border: 'border-rose-200/50 dark:border-rose-800/50',
|
||||
dot: 'bg-rose-500',
|
||||
};
|
||||
}
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs font-medium ${colorConfig.bg} ${colorConfig.text} border ${colorConfig.border}`}
|
||||
>
|
||||
{time}s
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function renderFirstUseTime(type, t) {
|
||||
let time = parseFloat(type) / 1000.0;
|
||||
time = time.toFixed(1);
|
||||
let colorConfig;
|
||||
|
||||
if (time < 3) {
|
||||
colorConfig = {
|
||||
bg: 'bg-teal-50 dark:bg-teal-950/30',
|
||||
text: 'text-teal-600 dark:text-teal-400',
|
||||
border: 'border-teal-200/50 dark:border-teal-800/50',
|
||||
};
|
||||
} else if (time < 10) {
|
||||
colorConfig = {
|
||||
bg: 'bg-orange-50 dark:bg-orange-950/30',
|
||||
text: 'text-orange-600 dark:text-orange-400',
|
||||
border: 'border-orange-200/50 dark:border-orange-800/50',
|
||||
};
|
||||
} else {
|
||||
colorConfig = {
|
||||
bg: 'bg-red-50 dark:bg-red-950/30',
|
||||
text: 'text-red-600 dark:text-red-400',
|
||||
border: 'border-red-200/50 dark:border-red-800/50',
|
||||
};
|
||||
}
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium ${colorConfig.bg} ${colorConfig.text} border ${colorConfig.border}`}
|
||||
>
|
||||
{time}s
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function renderModelName(record, copyText, t, isRootUser) {
|
||||
let other = getLogOther(record.other);
|
||||
let modelMapped =
|
||||
@@ -384,7 +297,7 @@ const applyUsageRecordPresentation = (
|
||||
...baseColumn,
|
||||
width: RECORD_COLUMN_WIDTHS[baseColumn.key],
|
||||
fixed: undefined,
|
||||
className: `usage-record-cell-${baseColumn.key}`,
|
||||
className: baseColumn.className ?? `usage-record-cell-${baseColumn.key}`,
|
||||
};
|
||||
switch (column.key) {
|
||||
case COLUMN_KEYS.TIME:
|
||||
@@ -449,15 +362,6 @@ const applyUsageRecordPresentation = (
|
||||
</button>
|
||||
) : null,
|
||||
};
|
||||
case COLUMN_KEYS.USE_TIME:
|
||||
return {
|
||||
...column,
|
||||
title: t('用时/首字').replace('/', ' / '),
|
||||
render: (text, record) =>
|
||||
record.type === 2 || record.type === 5
|
||||
? renderRecordUseTime(record, t)
|
||||
: null,
|
||||
};
|
||||
case COLUMN_KEYS.PROMPT:
|
||||
case COLUMN_KEYS.COMPLETION:
|
||||
return {
|
||||
@@ -693,34 +597,14 @@ export const getLogsColumns = ({
|
||||
},
|
||||
{
|
||||
key: COLUMN_KEYS.USE_TIME,
|
||||
title: t('用时/首字'),
|
||||
title: t('用时/首字').replace('/', ' / '),
|
||||
dataIndex: 'use_time',
|
||||
render: (text, record, index) => {
|
||||
if (!(record.type === 2 || record.type === 5)) {
|
||||
return <></>;
|
||||
}
|
||||
if (record.is_stream) {
|
||||
let other = getLogOther(record.other);
|
||||
return (
|
||||
<>
|
||||
<Space>
|
||||
{renderUseTime(text, t)}
|
||||
{renderFirstUseTime(other?.frt, t)}
|
||||
{renderIsStream(record.is_stream, t)}
|
||||
</Space>
|
||||
</>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<>
|
||||
<Space>
|
||||
{renderUseTime(text, t)}
|
||||
{renderIsStream(record.is_stream, t)}
|
||||
</Space>
|
||||
</>
|
||||
);
|
||||
}
|
||||
},
|
||||
align: 'center',
|
||||
className: 'usage-record-cell-use_time',
|
||||
render: (_, record) =>
|
||||
record.type === 2 || record.type === 5
|
||||
? renderRecordUseTime(record, t)
|
||||
: null,
|
||||
},
|
||||
{
|
||||
key: COLUMN_KEYS.PROMPT,
|
||||
|
||||
@@ -435,7 +435,7 @@ const LogsTable = (logsData) => {
|
||||
if (canView) setDetailRecord(record);
|
||||
}}
|
||||
>
|
||||
{t('查看')}
|
||||
{t('详情')}
|
||||
</AntButton>
|
||||
);
|
||||
}
|
||||
@@ -449,7 +449,7 @@ const LogsTable = (logsData) => {
|
||||
if (canView) setDetailRecord(record);
|
||||
}}
|
||||
>
|
||||
{t('查看')}
|
||||
{t('详情')}
|
||||
</AntButton>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -288,6 +288,7 @@ export function Table({
|
||||
expandedRowKeys,
|
||||
onExpand,
|
||||
expandRowByClick,
|
||||
expandable: nativeExpandable,
|
||||
pagination,
|
||||
size,
|
||||
onChange,
|
||||
@@ -305,7 +306,7 @@ export function Table({
|
||||
onExpand,
|
||||
expandRowByClick,
|
||||
}
|
||||
: undefined;
|
||||
: nativeExpandable;
|
||||
return (
|
||||
<Component
|
||||
{...props}
|
||||
@@ -348,10 +349,15 @@ function CenterPaginatedTable({
|
||||
...props
|
||||
}) {
|
||||
const isMobile = useIsMobile();
|
||||
const config = legacyPagination;
|
||||
const { resetOnDataChange, ...config } = legacyPagination;
|
||||
const local = config.total === undefined;
|
||||
const [localPage, setLocalPage] = React.useState(config.currentPage ?? 1);
|
||||
const [localSize, setLocalSize] = React.useState(config.pageSize ?? 10);
|
||||
const resetLocalPage = local && resetOnDataChange;
|
||||
const resetSource = resetLocalPage ? props.dataSource : undefined;
|
||||
React.useEffect(() => {
|
||||
if (resetLocalPage) setLocalPage(1);
|
||||
}, [resetLocalPage, resetSource]);
|
||||
const pageSize =
|
||||
local && !config.onPageSizeChange ? localSize : (config.pageSize ?? 10);
|
||||
const total = config.total ?? props.dataSource?.length ?? 0;
|
||||
|
||||
@@ -21,7 +21,9 @@ import i18next from 'i18next';
|
||||
|
||||
export const isCenterPaginationScope = () =>
|
||||
typeof window !== 'undefined' &&
|
||||
/^\/(console|org)(\/|$)/.test(window.location?.pathname || '');
|
||||
/^\/(?:console|org|user-center\/key-management)(?:\/|$)/.test(
|
||||
window.location?.pathname || '',
|
||||
);
|
||||
|
||||
export const centerPaginationOptions = (config, isMobile = false) => ({
|
||||
...config,
|
||||
|
||||
Reference in New Issue
Block a user