fix(ui): 统一表格筛选分页和用量明细,升级 ESLint
This commit is contained in:
@@ -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>
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user