fix(ui): 修复登录与并发请求并统一表格、主题和页面展示
验证:868 项单测、ESLint、Prettier、UI 依赖审计和差异检查通过。
This commit is contained in:
@@ -18,6 +18,7 @@ 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 {
|
||||
@@ -729,142 +730,110 @@ export const getChannelsColumns = ({
|
||||
dataIndex: 'operate',
|
||||
fixed: 'right',
|
||||
render: (text, record, index) => {
|
||||
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),
|
||||
});
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
if (!isRoot()) return null;
|
||||
if (record.children !== undefined) {
|
||||
return (
|
||||
<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>
|
||||
<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>
|
||||
);
|
||||
}
|
||||
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>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import { formatIdReference } from '../../../../helpers/safeDisplay';
|
||||
|
||||
import { I18N_TECHNICAL_TEXT } from '../../../../i18n/technicalText.js';
|
||||
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
|
||||
@@ -290,11 +291,11 @@ const EditChannelModal = (props) => {
|
||||
if (ch.status !== 1) {
|
||||
return {
|
||||
value: ch.id,
|
||||
label: `#${ch.id} ${ch.name}${t('(已禁用)')}`,
|
||||
label: `${formatIdReference(ch.id)} ${ch.name}${t('(已禁用)')}`,
|
||||
disabled: true,
|
||||
};
|
||||
}
|
||||
const parts = [`#${ch.id} ${ch.name}`];
|
||||
const parts = [`${formatIdReference(ch.id)} ${ch.name}`];
|
||||
if (ch.group) parts.push(ch.group);
|
||||
if (ch.region) parts.push(ch.region);
|
||||
return { value: ch.id, label: parts.join(' · ') };
|
||||
@@ -345,7 +346,7 @@ const EditChannelModal = (props) => {
|
||||
.filter((id) => !known.has(id) && id !== channelId)
|
||||
.map((id) => ({
|
||||
value: id,
|
||||
label: `#${id}${t('(已删除)')}`,
|
||||
label: `${formatIdReference(id)}${t('(已删除)')}`,
|
||||
disabled: true,
|
||||
}));
|
||||
return missing.length
|
||||
|
||||
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import { formatIdReference } from '../../../../helpers/safeDisplay';
|
||||
|
||||
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
@@ -359,7 +360,7 @@ const MultiKeyManageModal = ({ visible, onCancel, channel, onRefresh }) => {
|
||||
{
|
||||
title: t('索引'),
|
||||
dataIndex: 'index',
|
||||
render: (text) => `#${text}`,
|
||||
render: (text) => formatIdReference(text),
|
||||
},
|
||||
// {
|
||||
// title: t('密钥预览'),
|
||||
|
||||
@@ -18,9 +18,10 @@ 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, Space, Tag, Modal, Tooltip } from '@/components/ui';
|
||||
import { Button, Tag, Modal, Tooltip } from '@/components/ui';
|
||||
import {
|
||||
timestamp2string,
|
||||
getLobeHubIcon,
|
||||
@@ -239,64 +240,57 @@ const renderOperations = (
|
||||
setDetailModel,
|
||||
) => {
|
||||
return (
|
||||
<Space wrap className='console-module-row-actions'>
|
||||
<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();
|
||||
})();
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
]
|
||||
: []
|
||||
}
|
||||
>
|
||||
<Button type='link' size='small' onClick={() => setDetailModel(record)}>
|
||||
{t('详情')}
|
||||
</Button>
|
||||
{isRoot() && (
|
||||
<>
|
||||
{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>
|
||||
</>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setEditingModel(record);
|
||||
setShowEdit(true);
|
||||
}}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
</TableRowActions>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -38,37 +38,21 @@ const RedemptionsActions = ({
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='flex flex-wrap gap-2 w-full md:w-auto order-2 md:order-1'>
|
||||
{isAdmin() && (
|
||||
<Button
|
||||
type='primary'
|
||||
className='flex-1 md:flex-initial'
|
||||
onClick={handleAddRedemption}
|
||||
size='small'
|
||||
>
|
||||
{t('添加兑换码')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Button
|
||||
type='tertiary'
|
||||
className='flex-1 md:flex-initial'
|
||||
onClick={batchCopyRedemptions}
|
||||
size='small'
|
||||
>
|
||||
<div className='console-list-tool-actions'>
|
||||
<Button onClick={batchCopyRedemptions}>
|
||||
{t('复制所选兑换码到剪贴板')}
|
||||
</Button>
|
||||
|
||||
{isAdmin() && (
|
||||
<Button
|
||||
type='danger'
|
||||
className='w-full md:w-auto'
|
||||
onClick={batchDeleteRedemptions}
|
||||
size='small'
|
||||
>
|
||||
<Button type='danger' onClick={batchDeleteRedemptions}>
|
||||
{t('清除失效兑换码')}
|
||||
</Button>
|
||||
)}
|
||||
{isAdmin() && (
|
||||
<Button type='primary' onClick={handleAddRedemption}>
|
||||
{t('添加兑换码')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -18,8 +18,8 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Tag, Button, Space, Popover, Dropdown } from '@/components/ui';
|
||||
import { IconMore } from '@/components/ui/icons';
|
||||
import { Tag, Button, Popover } from '@/components/ui';
|
||||
import { TableRowActions } from '@/components/common/table/TableToolbar';
|
||||
import {
|
||||
renderQuota,
|
||||
timestamp2string,
|
||||
@@ -144,46 +144,42 @@ export const getRedemptionsColumns = ({
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '',
|
||||
title: t('操作'),
|
||||
dataIndex: 'operate',
|
||||
fixed: 'right',
|
||||
width: 205,
|
||||
width: 215,
|
||||
render: (text, record) => {
|
||||
// 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)) {
|
||||
const moreMenuItems = [];
|
||||
if (isAdmin() && !isExpired(record)) {
|
||||
const unused = record.status === REDEMPTION_STATUS.UNUSED;
|
||||
moreMenuItems.push({
|
||||
node: 'item',
|
||||
name: t('禁用'),
|
||||
type: 'warning',
|
||||
onClick: () => {
|
||||
manageRedemption(record.id, REDEMPTION_ACTIONS.DISABLE, record);
|
||||
},
|
||||
});
|
||||
} else if (!isExpired(record)) {
|
||||
moreMenuItems.push({
|
||||
node: 'item',
|
||||
name: t('启用'),
|
||||
type: 'secondary',
|
||||
onClick: () => {
|
||||
manageRedemption(record.id, REDEMPTION_ACTIONS.ENABLE, record);
|
||||
},
|
||||
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,
|
||||
),
|
||||
});
|
||||
}
|
||||
moreMenuItems.unshift({
|
||||
key: 'copy',
|
||||
label: t('复制'),
|
||||
onClick: () => copyText(record.key),
|
||||
});
|
||||
if (isAdmin()) {
|
||||
moreMenuItems.push({
|
||||
key: 'delete',
|
||||
label: t('删除'),
|
||||
danger: true,
|
||||
onClick: () => showDeleteRedemptionModal(record),
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<Space>
|
||||
<TableRowActions items={moreMenuItems}>
|
||||
<Popover
|
||||
// 触屏必须 click:这是查看兑换码明文的唯一入口
|
||||
trigger={hoverOrClickTrigger()}
|
||||
@@ -191,41 +187,24 @@ export const getRedemptionsColumns = ({
|
||||
style={{ padding: 20 }}
|
||||
position='top'
|
||||
>
|
||||
<Button type='tertiary' size='small'>
|
||||
<Button type='link' size='small'>
|
||||
{t('查看')}
|
||||
</Button>
|
||||
</Popover>
|
||||
<Button
|
||||
size='small'
|
||||
onClick={async () => {
|
||||
await copyText(record.key);
|
||||
}}
|
||||
>
|
||||
{t('复制')}
|
||||
</Button>
|
||||
{isAdmin() && (
|
||||
<>
|
||||
<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>
|
||||
</>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setEditingRedemption(record);
|
||||
setShowEdit(true);
|
||||
}}
|
||||
disabled={record.status !== REDEMPTION_STATUS.UNUSED}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
</TableRowActions>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -51,28 +51,24 @@ const RedemptionsFilters = ({
|
||||
onSubmit={searchRedemptions}
|
||||
allowEmpty={true}
|
||||
autoComplete='off'
|
||||
layout='horizontal'
|
||||
layout='vertical'
|
||||
trigger='change'
|
||||
stopValidateWithError={false}
|
||||
className='w-full'
|
||||
className='console-filter-panel'
|
||||
>
|
||||
<div className='console-search-fields'>
|
||||
<div className='console-search-field'>
|
||||
<Form.Input
|
||||
field='searchKeyword'
|
||||
prefix={<IconSearch />}
|
||||
placeholder={t('关键字(id或者名称)')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
</div>
|
||||
<ConsoleSearchActions
|
||||
onReset={handleReset}
|
||||
loading={loading || searching}
|
||||
searchLabel='查询'
|
||||
<div className='console-filter-grid'>
|
||||
<Form.Input
|
||||
field='searchKeyword'
|
||||
prefix={<IconSearch />}
|
||||
label={t('搜索关键字')}
|
||||
placeholder={t('关键字(id或者名称)')}
|
||||
showClear
|
||||
/>
|
||||
</div>
|
||||
<ConsoleSearchActions
|
||||
onReset={handleReset}
|
||||
loading={loading || searching}
|
||||
/>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -18,12 +18,8 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { Empty } from '@/components/ui';
|
||||
import TableEmpty from '../../common/table/TableEmpty';
|
||||
import CardTable from '../../common/ui/CardTable';
|
||||
import {
|
||||
IllustrationNoResult,
|
||||
IllustrationNoResultDark,
|
||||
} from '../../common/illustrations';
|
||||
import { getRedemptionsColumns } from './RedemptionsColumnDefs';
|
||||
import DeleteRedemptionModal from './modals/DeleteRedemptionModal';
|
||||
|
||||
@@ -101,17 +97,8 @@ const RedemptionsTable = (redemptionsData) => {
|
||||
loading={loading}
|
||||
rowSelection={rowSelection}
|
||||
onRow={handleRow}
|
||||
empty={
|
||||
<Empty
|
||||
image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
|
||||
darkModeImage={
|
||||
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
|
||||
}
|
||||
description={t('搜索无结果')}
|
||||
style={{ padding: 30 }}
|
||||
/>
|
||||
}
|
||||
className='rounded-xl overflow-hidden'
|
||||
empty={<TableEmpty />}
|
||||
className='console-list-table overflow-hidden'
|
||||
size='middle'
|
||||
/>
|
||||
|
||||
|
||||
@@ -82,15 +82,13 @@ const RedemptionsPage = () => {
|
||||
/>
|
||||
}
|
||||
type='type1'
|
||||
descriptionArea={
|
||||
<RedemptionsDescription
|
||||
compactMode={compactMode}
|
||||
setCompactMode={setCompactMode}
|
||||
t={t}
|
||||
/>
|
||||
}
|
||||
actionsArea={
|
||||
<div className='flex flex-col md:flex-row justify-between items-center gap-2 w-full'>
|
||||
<div className='console-list-tools'>
|
||||
<RedemptionsDescription
|
||||
compactMode={compactMode}
|
||||
setCompactMode={setCompactMode}
|
||||
t={t}
|
||||
/>
|
||||
<RedemptionsActions
|
||||
selectedKeys={selectedKeys}
|
||||
setEditingRedemption={setEditingRedemption}
|
||||
|
||||
@@ -18,11 +18,10 @@ 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,
|
||||
@@ -40,12 +39,7 @@ import {
|
||||
getModelCategories,
|
||||
showError,
|
||||
} from '../../../helpers';
|
||||
import {
|
||||
IconTreeTriangleDown,
|
||||
IconCopy,
|
||||
IconEyeOpened,
|
||||
IconEyeClosed,
|
||||
} from '@/components/ui/icons';
|
||||
import { IconCopy, IconEyeOpened, IconEyeClosed } from '@/components/ui/icons';
|
||||
|
||||
// progress color helper
|
||||
const getProgressColor = (pct) => {
|
||||
@@ -327,7 +321,6 @@ const renderOperations = (
|
||||
const name = Object.keys(item)[0];
|
||||
if (!name) continue;
|
||||
chatsArray.push({
|
||||
node: 'item',
|
||||
key: i,
|
||||
name,
|
||||
value: item[name],
|
||||
@@ -340,87 +333,70 @@ const renderOperations = (
|
||||
}
|
||||
|
||||
return (
|
||||
<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);
|
||||
<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,
|
||||
);
|
||||
await refresh();
|
||||
}}
|
||||
>
|
||||
{t('禁用')}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
size='small'
|
||||
onClick={async () => {
|
||||
await manageToken(record.id, 'enable', record);
|
||||
await refresh();
|
||||
}}
|
||||
>
|
||||
{t('启用')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Button
|
||||
type='tertiary'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setEditingToken(record);
|
||||
setShowEdit(true);
|
||||
}}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type='danger'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
Modal.confirm({
|
||||
title: t('确定是否要删除此密钥?'),
|
||||
content: t('此修改将不可逆'),
|
||||
onOk: () => {
|
||||
(async () => {
|
||||
},
|
||||
},
|
||||
{
|
||||
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();
|
||||
})();
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
type='link'
|
||||
onClick={() => {
|
||||
if (chatsArray.length === 0) {
|
||||
showError(t('请联系管理员配置聊天链接'));
|
||||
} else {
|
||||
const first = chatsArray[0];
|
||||
onOpenLink(first.name, first.value, record);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t('删除')}
|
||||
{t('聊天')}
|
||||
</Button>
|
||||
</Space>
|
||||
</TableRowActions>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -26,10 +26,9 @@ import {
|
||||
Progress,
|
||||
Popover,
|
||||
Typography,
|
||||
Dropdown,
|
||||
} from '@/components/ui';
|
||||
import { Switch } from 'antd';
|
||||
import { IconMore } from '@/components/ui/icons';
|
||||
import { TableRowActions } from '@/components/common/table/TableToolbar';
|
||||
import {
|
||||
renderGroup,
|
||||
renderNumber,
|
||||
@@ -256,50 +255,48 @@ const renderOperations = (
|
||||
if (canChangeRole) {
|
||||
moreMenu.push(
|
||||
{
|
||||
node: 'item',
|
||||
name: t('提升'),
|
||||
key: 'promote',
|
||||
label: t('提升'),
|
||||
onClick: () => showPromoteModal(record),
|
||||
},
|
||||
{
|
||||
node: 'item',
|
||||
name: t('降级'),
|
||||
key: 'demote',
|
||||
label: t('降级'),
|
||||
onClick: () => showDemoteModal(record),
|
||||
},
|
||||
{ node: 'divider' },
|
||||
{ type: 'divider' },
|
||||
);
|
||||
}
|
||||
moreMenu.push({
|
||||
node: 'item',
|
||||
name: t('邀请记录'),
|
||||
key: 'invitations',
|
||||
label: t('邀请记录'),
|
||||
onClick: () => showInvitedUsersModal(record),
|
||||
});
|
||||
if (canManage) {
|
||||
moreMenu.push(
|
||||
{ node: 'divider' },
|
||||
{ type: 'divider' },
|
||||
{
|
||||
node: 'item',
|
||||
name: t('重置 Passkey'),
|
||||
key: 'reset-passkey',
|
||||
label: t('重置 Passkey'),
|
||||
onClick: () => showResetPasskeyModal(record),
|
||||
},
|
||||
{
|
||||
node: 'item',
|
||||
name: t('重置 2FA'),
|
||||
key: 'reset-2fa',
|
||||
label: t('重置 2FA'),
|
||||
onClick: () => showResetTwoFAModal(record),
|
||||
},
|
||||
{ node: 'divider' },
|
||||
{ type: 'divider' },
|
||||
{
|
||||
node: 'item',
|
||||
name: t('注销'),
|
||||
type: 'danger',
|
||||
key: 'delete',
|
||||
label: t('注销'),
|
||||
danger: true,
|
||||
onClick: () => showDeleteModal(record),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
// wrap 保留:移动端 CardTable 把按钮放进 ~280px 的卡片行里,Semi Space 默认
|
||||
// wrap:false 时溢出会被 .ant-card{overflow:hidden} 裁掉(不是滚动,是永久看不到)
|
||||
<Space wrap className='console-module-row-actions'>
|
||||
<TableRowActions items={moreMenu}>
|
||||
{canManage && (
|
||||
<>
|
||||
<Button
|
||||
@@ -314,15 +311,7 @@ const renderOperations = (
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
<Dropdown menu={moreMenu} trigger='click' position='bottomRight'>
|
||||
<Button
|
||||
type='tertiary'
|
||||
size='small'
|
||||
icon={<IconMore />}
|
||||
aria-label={t('更多操作')}
|
||||
/>
|
||||
</Dropdown>
|
||||
</Space>
|
||||
</TableRowActions>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -394,9 +383,7 @@ export const getUsersColumns = ({
|
||||
title: t('操作'),
|
||||
dataIndex: 'operate',
|
||||
fixed: 'right',
|
||||
// 200 而不是更窄:en 下「Edit + Disable + 更多」三控件 ≈ 190px,
|
||||
// 再窄会触发 Space wrap 折行,重新撑高行高(本次改版要消灭的问题)
|
||||
width: 120,
|
||||
width: 135,
|
||||
render: (text, record, index) =>
|
||||
renderOperations(text, record, {
|
||||
setEditingUser,
|
||||
|
||||
Reference in New Issue
Block a user