Initial import of weiyuan frontend
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Button, Tag } from '@douyinfe/semi-ui';
|
||||
import { isAdmin } from '../../../helpers';
|
||||
|
||||
const AdminTokensActions = ({
|
||||
selectedRowKeys,
|
||||
onBatchAction,
|
||||
onRefresh,
|
||||
t,
|
||||
}) => {
|
||||
const hasSelection = selectedRowKeys && selectedRowKeys.length > 0;
|
||||
|
||||
return (
|
||||
<div className='flex flex-wrap items-center gap-2 w-full md:w-auto order-2 md:order-1'>
|
||||
{hasSelection && (
|
||||
<Tag color='violet' shape='circle' size='small'>
|
||||
{t('已选 {{count}} 项', { count: selectedRowKeys.length })}
|
||||
</Tag>
|
||||
)}
|
||||
{isAdmin() && hasSelection && (
|
||||
<>
|
||||
<Button size='small' onClick={() => onBatchAction('enable')}>
|
||||
{t('批量启用')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
type='warning'
|
||||
onClick={() => onBatchAction('disable')}
|
||||
>
|
||||
{t('批量禁用')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
type='danger'
|
||||
onClick={() => onBatchAction('delete')}
|
||||
>
|
||||
{t('批量删除')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
<Button size='small' type='tertiary' onClick={onRefresh}>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminTokensActions;
|
||||
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
Button,
|
||||
Space,
|
||||
Tag,
|
||||
Typography,
|
||||
Popover,
|
||||
Dropdown,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { IconMore } from '@douyinfe/semi-icons';
|
||||
import {
|
||||
renderGroup,
|
||||
renderQuota,
|
||||
isAdmin,
|
||||
timestamp2string,
|
||||
} from '../../../helpers';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const statusMeta = {
|
||||
1: { color: 'green', label: '已启用' },
|
||||
2: { color: 'grey', label: '已禁用' },
|
||||
3: { color: 'red', label: '已过期' },
|
||||
4: { color: 'orange', label: '已耗尽' },
|
||||
};
|
||||
|
||||
const renderStatus = (status, t) => {
|
||||
const meta = statusMeta[status] || { color: 'red', label: t('未知状态') };
|
||||
return (
|
||||
<Tag color={meta.color} shape='circle' size='small'>
|
||||
{t(meta.label)}
|
||||
</Tag>
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* 用户列:display_name 主显,user_id 与 username 小字辅显
|
||||
*/
|
||||
const renderUserCell = (text, record, t) => {
|
||||
const displayName = record.display_name || record.username || t('未知用户');
|
||||
return (
|
||||
<div className='flex flex-col leading-tight'>
|
||||
<Text strong className='!text-sm'>
|
||||
{displayName}
|
||||
</Text>
|
||||
<div className='flex items-center gap-1 text-xs text-[var(--semi-color-text-2)]'>
|
||||
<span>#{record.user_id}</span>
|
||||
{record.username && record.username !== displayName && (
|
||||
<span className='truncate max-w-[120px]'>@{record.username}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const renderKey = (text, record) => {
|
||||
// 后端已脱敏,前端再加 sk- 前缀
|
||||
return (
|
||||
<code className='text-xs bg-[var(--semi-color-fill-0)] px-2 py-0.5 rounded font-mono'>
|
||||
sk-{text}
|
||||
</code>
|
||||
);
|
||||
};
|
||||
|
||||
const renderQuotaCell = (text, record, t) => {
|
||||
if (record.unlimited_quota) {
|
||||
return (
|
||||
<Tag color='violet' shape='circle' size='small'>
|
||||
{t('无限制')}
|
||||
</Tag>
|
||||
);
|
||||
}
|
||||
const used = record.used_quota || 0;
|
||||
const remain = record.remain_quota || 0;
|
||||
const popoverContent = (
|
||||
<div className='text-xs p-2'>
|
||||
<div>
|
||||
{t('已用')}: {renderQuota(used)}
|
||||
</div>
|
||||
<div>
|
||||
{t('剩余')}: {renderQuota(remain)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<Popover content={popoverContent} position='top'>
|
||||
<Tag color='white' shape='circle' size='small'>
|
||||
{renderQuota(remain)}
|
||||
</Tag>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
const renderTime = (ts, t) => {
|
||||
if (!ts || ts === 0)
|
||||
return <span className='text-[var(--semi-color-text-2)]'>—</span>;
|
||||
if (ts === -1)
|
||||
return (
|
||||
<Tag color='blue' shape='circle' size='small'>
|
||||
{t('永不过期')}
|
||||
</Tag>
|
||||
);
|
||||
return <span className='text-xs'>{timestamp2string(ts)}</span>;
|
||||
};
|
||||
|
||||
const renderScope = (orgId, t) => {
|
||||
if (!orgId || orgId === 0) {
|
||||
return (
|
||||
<Tag color='blue' shape='circle' size='small'>
|
||||
{t('个人')}
|
||||
</Tag>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Tag color='purple' shape='circle' size='small'>
|
||||
{t('企业')} #{orgId}
|
||||
</Tag>
|
||||
);
|
||||
};
|
||||
|
||||
const renderOperations = (
|
||||
text,
|
||||
record,
|
||||
{ showEditTokenModal, showEnableDisableModal, showDeleteTokenModal, t },
|
||||
) => {
|
||||
if (record.DeletedAt) return <></>;
|
||||
const isEnabled = record.status === 1;
|
||||
if (!isAdmin()) return null;
|
||||
return (
|
||||
<Space>
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
onClick={() => showEditTokenModal(record)}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
{isEnabled ? (
|
||||
<Button
|
||||
size='small'
|
||||
type='danger'
|
||||
onClick={() => showEnableDisableModal(record, 'disable')}
|
||||
>
|
||||
{t('禁用')}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
size='small'
|
||||
onClick={() => showEnableDisableModal(record, 'enable')}
|
||||
>
|
||||
{t('启用')}
|
||||
</Button>
|
||||
)}
|
||||
<Dropdown
|
||||
trigger='click'
|
||||
position='bottomRight'
|
||||
menu={[
|
||||
{
|
||||
node: 'item',
|
||||
name: t('删除'),
|
||||
type: 'danger',
|
||||
onClick: () => showDeleteTokenModal(record),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Button size='small' type='tertiary' icon={<IconMore />} />
|
||||
</Dropdown>
|
||||
</Space>
|
||||
);
|
||||
};
|
||||
|
||||
export const getAdminTokensColumns = ({
|
||||
t,
|
||||
showEditTokenModal,
|
||||
showEnableDisableModal,
|
||||
showDeleteTokenModal,
|
||||
}) => {
|
||||
return [
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
width: 70,
|
||||
},
|
||||
{
|
||||
title: t('用户'),
|
||||
dataIndex: 'user',
|
||||
width: 180,
|
||||
render: (text, record) => renderUserCell(text, record, t),
|
||||
},
|
||||
{
|
||||
title: t('秘钥名称'),
|
||||
dataIndex: 'name',
|
||||
render: (text) => (
|
||||
<span className='truncate inline-block max-w-[160px]' title={text}>
|
||||
{text || <Text type='tertiary'>—</Text>}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('秘钥'),
|
||||
dataIndex: 'key',
|
||||
render: renderKey,
|
||||
},
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: 90,
|
||||
render: (text) => renderStatus(text, t),
|
||||
},
|
||||
{
|
||||
title: t('归属'),
|
||||
dataIndex: 'organization_id',
|
||||
width: 100,
|
||||
render: (text) => renderScope(text, t),
|
||||
},
|
||||
{
|
||||
title: t('分组'),
|
||||
dataIndex: 'group',
|
||||
width: 110,
|
||||
render: (text) => <div>{renderGroup(text)}</div>,
|
||||
},
|
||||
{
|
||||
title: t('剩余额度'),
|
||||
dataIndex: 'remain_quota',
|
||||
width: 110,
|
||||
render: (text, record) => renderQuotaCell(text, record, t),
|
||||
},
|
||||
{
|
||||
title: t('已用额度'),
|
||||
dataIndex: 'used_quota',
|
||||
width: 110,
|
||||
render: (text) => (
|
||||
<Text type='tertiary' size='small'>
|
||||
{renderQuota(text || 0)}
|
||||
</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('创建时间'),
|
||||
dataIndex: 'created_time',
|
||||
width: 160,
|
||||
render: (text) => renderTime(text, t),
|
||||
},
|
||||
{
|
||||
title: t('过期时间'),
|
||||
dataIndex: 'expired_time',
|
||||
width: 160,
|
||||
render: (text) => renderTime(text, t),
|
||||
},
|
||||
{
|
||||
title: t('最近访问'),
|
||||
dataIndex: 'accessed_time',
|
||||
width: 160,
|
||||
render: (text) => renderTime(text, t),
|
||||
},
|
||||
{
|
||||
title: '',
|
||||
dataIndex: 'operate',
|
||||
fixed: 'right',
|
||||
width: 200,
|
||||
render: (text, record) =>
|
||||
renderOperations(text, record, {
|
||||
showEditTokenModal,
|
||||
showEnableDisableModal,
|
||||
showDeleteTokenModal,
|
||||
t,
|
||||
}),
|
||||
},
|
||||
];
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Typography, Tag } from '@douyinfe/semi-ui';
|
||||
import { IconKey } from '@douyinfe/semi-icons';
|
||||
import CompactModeToggle from '../../common/ui/CompactModeToggle';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const AdminTokensDescription = ({ compactMode, setCompactMode, t }) => {
|
||||
return (
|
||||
<div className='flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full'>
|
||||
<div className='flex items-center gap-2 text-brand'>
|
||||
<IconKey />
|
||||
<Text>{t('秘钥管理')}</Text>
|
||||
<Tag color='orange' shape='circle' size='small'>
|
||||
{t('管理员')}
|
||||
</Tag>
|
||||
</div>
|
||||
<CompactModeToggle
|
||||
compactMode={compactMode}
|
||||
setCompactMode={setCompactMode}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminTokensDescription;
|
||||
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useRef } from 'react';
|
||||
import { Form, Button } from '@douyinfe/semi-ui';
|
||||
import { IconSearch } from '@douyinfe/semi-icons';
|
||||
|
||||
const AdminTokensFilters = ({
|
||||
formInitValues,
|
||||
setFormApi,
|
||||
searchTokens,
|
||||
debouncedSearch,
|
||||
loadTokens,
|
||||
pageSize,
|
||||
groupOptions,
|
||||
loading,
|
||||
searching,
|
||||
t,
|
||||
}) => {
|
||||
const formApiRef = useRef(null);
|
||||
|
||||
const handleReset = () => {
|
||||
if (!formApiRef.current) return;
|
||||
formApiRef.current.reset();
|
||||
// 重置后立即用初始值刷新(不走 debounce)
|
||||
loadTokens(1, pageSize, formInitValues);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
initValues={formInitValues}
|
||||
getFormApi={(api) => {
|
||||
setFormApi(api);
|
||||
formApiRef.current = api;
|
||||
}}
|
||||
onSubmit={() => searchTokens(pageSize)}
|
||||
allowEmpty
|
||||
autoComplete='off'
|
||||
layout='horizontal'
|
||||
trigger='change'
|
||||
className='w-full md:w-auto order-1 md:order-2'
|
||||
>
|
||||
<div className='flex flex-col md:flex-row items-center gap-2 w-full md:w-auto flex-wrap'>
|
||||
<div className='w-full md:w-56'>
|
||||
<Form.Input
|
||||
field='keyword'
|
||||
prefix={<IconSearch />}
|
||||
placeholder={t('秘钥名称 / Key 片段')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
</div>
|
||||
<div className='w-full md:w-44'>
|
||||
<Form.Input
|
||||
field='user_keyword'
|
||||
placeholder={t('用户名/昵称')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
</div>
|
||||
<div className='w-full md:w-28'>
|
||||
<Form.Input
|
||||
field='user_id'
|
||||
placeholder={t('用户ID')}
|
||||
type='number'
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
</div>
|
||||
<div className='w-full md:w-44'>
|
||||
<Form.Select
|
||||
field='statuses'
|
||||
placeholder={t('状态(多选)')}
|
||||
multiple
|
||||
optionList={[
|
||||
{ label: t('已启用'), value: 1 },
|
||||
{ label: t('已禁用'), value: 2 },
|
||||
{ label: t('已过期'), value: 3 },
|
||||
{ label: t('已耗尽'), value: 4 },
|
||||
]}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
className='w-full'
|
||||
onChange={debouncedSearch}
|
||||
/>
|
||||
</div>
|
||||
<div className='w-full md:w-36'>
|
||||
<Form.Select
|
||||
field='group'
|
||||
placeholder={t('分组')}
|
||||
optionList={groupOptions}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
className='w-full'
|
||||
onChange={debouncedSearch}
|
||||
/>
|
||||
</div>
|
||||
<div className='w-full md:w-32'>
|
||||
<Form.Select
|
||||
field='unlimited'
|
||||
placeholder={t('额度类型')}
|
||||
optionList={[
|
||||
{ label: t('无限额度'), value: true },
|
||||
{ label: t('有限额度'), value: false },
|
||||
]}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
className='w-full'
|
||||
onChange={debouncedSearch}
|
||||
/>
|
||||
</div>
|
||||
<div className='w-full md:w-32'>
|
||||
<Form.Select
|
||||
field='org_scope'
|
||||
placeholder={t('归属')}
|
||||
optionList={[
|
||||
{ label: t('全部'), value: 'all' },
|
||||
{ label: t('个人'), value: 'personal' },
|
||||
{ label: t('企业'), value: 'org' },
|
||||
]}
|
||||
showClear={false}
|
||||
pure
|
||||
size='small'
|
||||
className='w-full'
|
||||
onChange={debouncedSearch}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex gap-2 w-full md:w-auto'>
|
||||
<Button
|
||||
type='tertiary'
|
||||
htmlType='submit'
|
||||
loading={loading || searching}
|
||||
size='small'
|
||||
>
|
||||
{t('查询')}
|
||||
</Button>
|
||||
<Button type='tertiary' onClick={handleReset} size='small'>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminTokensFilters;
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import { Empty } from '@douyinfe/semi-ui';
|
||||
import CardTable from '../../common/ui/CardTable';
|
||||
import {
|
||||
IllustrationNoResult,
|
||||
IllustrationNoResultDark,
|
||||
} from '../../common/illustrations';
|
||||
import { getAdminTokensColumns } from './AdminTokensColumnDefs';
|
||||
|
||||
const AdminTokensTable = ({
|
||||
tokens,
|
||||
loading,
|
||||
activePage,
|
||||
pageSize,
|
||||
tokenCount,
|
||||
compactMode,
|
||||
selectedRowKeys,
|
||||
setSelectedRowKeys,
|
||||
handlePageChange,
|
||||
handlePageSizeChange,
|
||||
handleRow,
|
||||
setEditingToken,
|
||||
setShowEdit,
|
||||
setModalToken,
|
||||
setEnableDisableAction,
|
||||
setShowEnableDisable,
|
||||
setShowDelete,
|
||||
t,
|
||||
}) => {
|
||||
const showEditTokenModal = (token) => {
|
||||
setEditingToken(token);
|
||||
setShowEdit(true);
|
||||
};
|
||||
const showEnableDisableModal = (token, action) => {
|
||||
setModalToken(token);
|
||||
setEnableDisableAction(action);
|
||||
setShowEnableDisable(true);
|
||||
};
|
||||
const showDeleteTokenModal = (token) => {
|
||||
setModalToken(token);
|
||||
setShowDelete(true);
|
||||
};
|
||||
|
||||
const columns = useMemo(
|
||||
() =>
|
||||
getAdminTokensColumns({
|
||||
t,
|
||||
showEditTokenModal,
|
||||
showEnableDisableModal,
|
||||
showDeleteTokenModal,
|
||||
}),
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[t],
|
||||
);
|
||||
|
||||
const tableColumns = useMemo(
|
||||
() =>
|
||||
compactMode
|
||||
? columns.map((col) => {
|
||||
if (col.dataIndex === 'operate') {
|
||||
const { fixed, ...rest } = col;
|
||||
return rest;
|
||||
}
|
||||
return col;
|
||||
})
|
||||
: columns,
|
||||
[compactMode, columns],
|
||||
);
|
||||
|
||||
const rowSelection = {
|
||||
selectedRowKeys,
|
||||
onChange: (keys) => setSelectedRowKeys(keys),
|
||||
};
|
||||
|
||||
return (
|
||||
<CardTable
|
||||
columns={tableColumns}
|
||||
dataSource={tokens}
|
||||
rowKey='id'
|
||||
scroll={compactMode ? undefined : { x: 'max-content' }}
|
||||
pagination={{
|
||||
currentPage: activePage,
|
||||
pageSize: pageSize,
|
||||
total: tokenCount,
|
||||
pageSizeOpts: [10, 20, 50, 100],
|
||||
showSizeChanger: true,
|
||||
onPageSizeChange: handlePageSizeChange,
|
||||
onPageChange: handlePageChange,
|
||||
}}
|
||||
hidePagination={true}
|
||||
loading={loading}
|
||||
onRow={handleRow}
|
||||
rowSelection={rowSelection}
|
||||
empty={
|
||||
<Empty
|
||||
image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
|
||||
darkModeImage={
|
||||
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
|
||||
}
|
||||
description={t('搜索无结果')}
|
||||
style={{ padding: 30 }}
|
||||
/>
|
||||
}
|
||||
className='overflow-hidden'
|
||||
size='middle'
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminTokensTable;
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import CardPro from '../../common/ui/CardPro';
|
||||
import AdminTokensTable from './AdminTokensTable';
|
||||
import AdminTokensActions from './AdminTokensActions';
|
||||
import AdminTokensFilters from './AdminTokensFilters';
|
||||
import AdminTokensDescription from './AdminTokensDescription';
|
||||
import AdminEditTokenModal from './modals/AdminEditTokenModal';
|
||||
import AdminEnableDisableTokenModal from './modals/AdminEnableDisableTokenModal';
|
||||
import AdminDeleteTokenModal from './modals/AdminDeleteTokenModal';
|
||||
import AdminBatchActionModal from './modals/AdminBatchActionModal';
|
||||
import { useAdminTokensData } from '../../../hooks/admin-tokens/useAdminTokensData';
|
||||
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
||||
import { createCardProPagination } from '../../../helpers/utils';
|
||||
|
||||
const AdminTokensPage = () => {
|
||||
const data = useAdminTokensData();
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
const {
|
||||
tokens,
|
||||
loading,
|
||||
searching,
|
||||
activePage,
|
||||
pageSize,
|
||||
tokenCount,
|
||||
groupOptions,
|
||||
|
||||
selectedRowKeys,
|
||||
setSelectedRowKeys,
|
||||
|
||||
showEdit,
|
||||
editingToken,
|
||||
setEditingToken,
|
||||
setShowEdit,
|
||||
closeEdit,
|
||||
|
||||
showEnableDisable,
|
||||
setShowEnableDisable,
|
||||
enableDisableAction,
|
||||
setEnableDisableAction,
|
||||
showDelete,
|
||||
setShowDelete,
|
||||
showBatchAction,
|
||||
setShowBatchAction,
|
||||
batchAction,
|
||||
setBatchAction,
|
||||
modalToken,
|
||||
setModalToken,
|
||||
|
||||
formInitValues,
|
||||
setFormApi,
|
||||
|
||||
loadTokens,
|
||||
searchTokens,
|
||||
debouncedSearch,
|
||||
refresh,
|
||||
manageToken,
|
||||
batchManageTokens,
|
||||
handlePageChange,
|
||||
handlePageSizeChange,
|
||||
handleRow,
|
||||
|
||||
compactMode,
|
||||
setCompactMode,
|
||||
|
||||
t,
|
||||
} = data;
|
||||
|
||||
const handleBatchClick = (action) => {
|
||||
setBatchAction(action);
|
||||
setShowBatchAction(true);
|
||||
};
|
||||
|
||||
const handleBatchConfirm = async () => {
|
||||
await batchManageTokens(selectedRowKeys, batchAction);
|
||||
setShowBatchAction(false);
|
||||
};
|
||||
|
||||
const handleEnableDisableConfirm = async () => {
|
||||
if (!modalToken) return;
|
||||
await manageToken(modalToken.id, enableDisableAction);
|
||||
setShowEnableDisable(false);
|
||||
};
|
||||
|
||||
const handleDeleteConfirm = async () => {
|
||||
if (!modalToken) return;
|
||||
await manageToken(modalToken.id, 'delete');
|
||||
setShowDelete(false);
|
||||
};
|
||||
|
||||
const handleEditConfirm = async () => {
|
||||
closeEdit();
|
||||
await refresh();
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<AdminEditTokenModal
|
||||
visible={showEdit}
|
||||
onCancel={closeEdit}
|
||||
onConfirm={handleEditConfirm}
|
||||
token={editingToken}
|
||||
groupOptions={groupOptions}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<AdminEnableDisableTokenModal
|
||||
visible={showEnableDisable}
|
||||
onCancel={() => setShowEnableDisable(false)}
|
||||
onConfirm={handleEnableDisableConfirm}
|
||||
token={modalToken}
|
||||
action={enableDisableAction}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<AdminDeleteTokenModal
|
||||
visible={showDelete}
|
||||
onCancel={() => setShowDelete(false)}
|
||||
onConfirm={handleDeleteConfirm}
|
||||
token={modalToken}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<AdminBatchActionModal
|
||||
visible={showBatchAction}
|
||||
onCancel={() => setShowBatchAction(false)}
|
||||
onConfirm={handleBatchConfirm}
|
||||
action={batchAction}
|
||||
count={selectedRowKeys.length}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<CardPro
|
||||
type='type1'
|
||||
descriptionArea={
|
||||
<AdminTokensDescription
|
||||
compactMode={compactMode}
|
||||
setCompactMode={setCompactMode}
|
||||
t={t}
|
||||
/>
|
||||
}
|
||||
actionsArea={
|
||||
<div className='flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full'>
|
||||
<AdminTokensActions
|
||||
selectedRowKeys={selectedRowKeys}
|
||||
onBatchAction={handleBatchClick}
|
||||
onRefresh={refresh}
|
||||
t={t}
|
||||
/>
|
||||
<AdminTokensFilters
|
||||
formInitValues={formInitValues}
|
||||
setFormApi={setFormApi}
|
||||
searchTokens={searchTokens}
|
||||
debouncedSearch={debouncedSearch}
|
||||
loadTokens={loadTokens}
|
||||
pageSize={pageSize}
|
||||
groupOptions={groupOptions}
|
||||
loading={loading}
|
||||
searching={searching}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
paginationArea={createCardProPagination({
|
||||
currentPage: activePage,
|
||||
pageSize: pageSize,
|
||||
total: tokenCount,
|
||||
onPageChange: handlePageChange,
|
||||
onPageSizeChange: handlePageSizeChange,
|
||||
isMobile: isMobile,
|
||||
t,
|
||||
})}
|
||||
t={t}
|
||||
>
|
||||
<AdminTokensTable
|
||||
tokens={tokens}
|
||||
loading={loading}
|
||||
activePage={activePage}
|
||||
pageSize={pageSize}
|
||||
tokenCount={tokenCount}
|
||||
compactMode={compactMode}
|
||||
selectedRowKeys={selectedRowKeys}
|
||||
setSelectedRowKeys={setSelectedRowKeys}
|
||||
handlePageChange={handlePageChange}
|
||||
handlePageSizeChange={handlePageSizeChange}
|
||||
handleRow={handleRow}
|
||||
setEditingToken={setEditingToken}
|
||||
setShowEdit={setShowEdit}
|
||||
setModalToken={setModalToken}
|
||||
setEnableDisableAction={setEnableDisableAction}
|
||||
setShowEnableDisable={setShowEnableDisable}
|
||||
setShowDelete={setShowDelete}
|
||||
t={t}
|
||||
/>
|
||||
</CardPro>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminTokensPage;
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Modal, Banner } from '@douyinfe/semi-ui';
|
||||
|
||||
const actionMeta = {
|
||||
enable: { title: '批量启用', danger: false, hint: '将选中秘钥批量启用' },
|
||||
disable: {
|
||||
title: '批量禁用',
|
||||
danger: true,
|
||||
hint: '将选中秘钥批量禁用,用户将无法使用',
|
||||
},
|
||||
delete: {
|
||||
title: '批量删除',
|
||||
danger: true,
|
||||
hint: '将选中秘钥批量删除,操作不可恢复',
|
||||
},
|
||||
};
|
||||
|
||||
const AdminBatchActionModal = ({
|
||||
visible,
|
||||
onCancel,
|
||||
onConfirm,
|
||||
action,
|
||||
count,
|
||||
t,
|
||||
}) => {
|
||||
const meta = actionMeta[action] || {
|
||||
title: '批量操作',
|
||||
danger: false,
|
||||
hint: '',
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t(meta.title)}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={onConfirm}
|
||||
type={meta.danger ? 'danger' : 'warning'}
|
||||
okType={meta.danger ? 'danger' : 'primary'}
|
||||
okText={t('确认执行')}
|
||||
>
|
||||
<div className='space-y-2'>
|
||||
<div>{t('共选中 {{count}} 个秘钥', { count })}</div>
|
||||
<Banner
|
||||
type={meta.danger ? 'danger' : 'info'}
|
||||
description={t(meta.hint)}
|
||||
closeIcon={null}
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminBatchActionModal;
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Modal, Typography, Banner } from '@douyinfe/semi-ui';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const AdminDeleteTokenModal = ({ visible, onCancel, onConfirm, token, t }) => {
|
||||
if (!token) return null;
|
||||
const isOrgToken = token.organization_id && token.organization_id > 0;
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('确定要删除此秘钥吗?')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={onConfirm}
|
||||
type='danger'
|
||||
okType='danger'
|
||||
okText={t('确认删除')}
|
||||
>
|
||||
<div className='space-y-2'>
|
||||
{isOrgToken && (
|
||||
<Banner
|
||||
type='warning'
|
||||
description={t(
|
||||
'该秘钥属于企业 Token,删除将影响企业内多用户的使用',
|
||||
)}
|
||||
closeIcon={null}
|
||||
/>
|
||||
)}
|
||||
<div>{t('删除后将无法恢复,且会立即终止使用此秘钥的所有调用')}</div>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('秘钥名称')}:{token.name || '—'}
|
||||
</Text>
|
||||
<br />
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('所属用户')}:{token.display_name || token.username || '—'} (ID:{' '}
|
||||
{token.user_id})
|
||||
</Text>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminDeleteTokenModal;
|
||||
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { Modal, Form, Typography, Banner, Spin, Tag } from '@douyinfe/semi-ui';
|
||||
import { API, showError, renderQuotaWithPrompt } from '../../../../helpers';
|
||||
import {
|
||||
quotaToMoney,
|
||||
moneyToQuota,
|
||||
} from '../../../common/ui/QuotaInput';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const statusMeta = {
|
||||
1: { color: 'green', label: '已启用' },
|
||||
2: { color: 'grey', label: '已禁用' },
|
||||
3: { color: 'red', label: '已过期' },
|
||||
4: { color: 'orange', label: '已耗尽' },
|
||||
};
|
||||
|
||||
/**
|
||||
* 管理员编辑秘钥弹窗
|
||||
* 允许修改:name / group / unlimited_quota / remain_quota / expired_time
|
||||
* 不修改:
|
||||
* - status —— 启用/禁用走专用按钮,避免在编辑路径上绕过状态校验
|
||||
* - user_id / key / used_quota / model_limits / allow_ips —— 由用户自管
|
||||
*/
|
||||
const AdminEditTokenModal = ({
|
||||
visible,
|
||||
onCancel,
|
||||
onConfirm,
|
||||
token,
|
||||
groupOptions,
|
||||
t,
|
||||
}) => {
|
||||
const formApiRef = useRef(null);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const [unlimited, setUnlimited] = useState(false);
|
||||
const [neverExpire, setNeverExpire] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (visible && token) {
|
||||
// expired_time 视为"永不过期"的情况:-1(约定)或 0(旧数据兜底)
|
||||
const isNeverExpire =
|
||||
token.expired_time === -1 || token.expired_time === 0;
|
||||
setUnlimited(!!token.unlimited_quota);
|
||||
setNeverExpire(isNeverExpire);
|
||||
setTimeout(() => {
|
||||
formApiRef.current?.setValues({
|
||||
name: token.name || '',
|
||||
group: token.group || '',
|
||||
unlimited_quota: !!token.unlimited_quota,
|
||||
// remain_quota 内部单位是 token 数;UI 用元(quota_per_unit 额度 = ¥1)
|
||||
remain_quota_amount: token.unlimited_quota
|
||||
? 0
|
||||
: quotaToMoney(token.remain_quota || 0) || 0,
|
||||
expired_time:
|
||||
!isNeverExpire && token.expired_time > 0
|
||||
? new Date(token.expired_time * 1000)
|
||||
: null,
|
||||
never_expire: isNeverExpire,
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
}, [visible, token]);
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!formApiRef.current) return;
|
||||
let values;
|
||||
try {
|
||||
values = await formApiRef.current.validate();
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
if (!token) return;
|
||||
|
||||
// 显式校验:未勾选"永不过期"时必须选过期时间,避免被默默改为 -1
|
||||
if (!values.never_expire && !values.expired_time) {
|
||||
showError(t('请选择过期时间'));
|
||||
return;
|
||||
}
|
||||
setSubmitting(true);
|
||||
|
||||
// 注意:不传 status / model_limits / allow_ips / model_limits_enabled
|
||||
// status 由专用按钮处理;其余字段由 Token 所属用户自行管理
|
||||
// 后端 AdminUpdateTokenById 会保留 DB 中的原值
|
||||
const payload = {
|
||||
id: token.id,
|
||||
name: values.name || '',
|
||||
group: values.group || '',
|
||||
unlimited_quota: !!values.unlimited_quota,
|
||||
remain_quota: values.unlimited_quota
|
||||
? token.remain_quota
|
||||
: moneyToQuota(values.remain_quota_amount || 0) || 0,
|
||||
expired_time: values.never_expire
|
||||
? -1
|
||||
: Math.floor(new Date(values.expired_time).getTime() / 1000),
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await API.put('/api/token/admin', payload);
|
||||
const { success, message } = res.data;
|
||||
if (success) {
|
||||
onConfirm && onConfirm();
|
||||
} else {
|
||||
showError(message);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[AdminEditToken] save failed:', e);
|
||||
showError(e.message || t('保存失败'));
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (!token) return null;
|
||||
|
||||
const isOrgToken = token.organization_id && token.organization_id > 0;
|
||||
const curStatusMeta = statusMeta[token.status] || statusMeta[2];
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('编辑秘钥')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={handleSubmit}
|
||||
confirmLoading={submitting}
|
||||
okText={t('保存')}
|
||||
cancelText={t('取消')}
|
||||
width={560}
|
||||
>
|
||||
<Spin spinning={submitting}>
|
||||
<div className='mb-3'>
|
||||
<Banner
|
||||
type='info'
|
||||
description={
|
||||
<span>
|
||||
{t('正在以管理员身份编辑')}{' '}
|
||||
<Text strong>
|
||||
{token.display_name || token.username || '—'}
|
||||
</Text>{' '}
|
||||
(ID: {token.user_id}) {t('的秘钥')}
|
||||
<Tag
|
||||
color={curStatusMeta.color}
|
||||
shape='circle'
|
||||
size='small'
|
||||
className='!ml-2'
|
||||
>
|
||||
{t(curStatusMeta.label)}
|
||||
</Tag>
|
||||
</span>
|
||||
}
|
||||
closeIcon={null}
|
||||
/>
|
||||
{isOrgToken && (
|
||||
<Banner
|
||||
type='warning'
|
||||
description={t(
|
||||
'该秘钥属于企业 Token,修改额度或过期时间将影响企业内多用户的使用',
|
||||
)}
|
||||
closeIcon={null}
|
||||
className='!mt-2'
|
||||
/>
|
||||
)}
|
||||
<div className='mt-2 text-xs text-[var(--semi-color-text-2)]'>
|
||||
{t('启用 / 禁用请使用列表中的专用按钮')}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Form
|
||||
getFormApi={(api) => (formApiRef.current = api)}
|
||||
labelPosition='left'
|
||||
labelWidth={110}
|
||||
>
|
||||
<Form.Input
|
||||
field='name'
|
||||
label={t('秘钥名称')}
|
||||
placeholder={t('给秘钥起个名字')}
|
||||
maxLength={30}
|
||||
rules={[{ required: true, message: t('请输入秘钥名称') }]}
|
||||
/>
|
||||
|
||||
<Form.Select
|
||||
field='group'
|
||||
label={t('分组')}
|
||||
optionList={groupOptions}
|
||||
allowClear
|
||||
placeholder={t('使用用户默认分组')}
|
||||
className='w-full'
|
||||
/>
|
||||
|
||||
<Form.Switch
|
||||
field='unlimited_quota'
|
||||
label={t('无限额度')}
|
||||
onChange={(v) => setUnlimited(v)}
|
||||
/>
|
||||
|
||||
{!unlimited && (
|
||||
<Form.InputNumber
|
||||
field='remain_quota_amount'
|
||||
label={t('剩余额度(元)')}
|
||||
min={0}
|
||||
precision={2}
|
||||
step={1}
|
||||
suffix='¥'
|
||||
extraText={
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('当前已用')}:{' '}
|
||||
{renderQuotaWithPrompt(token.used_quota || 0)}
|
||||
</Text>
|
||||
}
|
||||
className='w-full'
|
||||
/>
|
||||
)}
|
||||
|
||||
<Form.Switch
|
||||
field='never_expire'
|
||||
label={t('永不过期')}
|
||||
onChange={(v) => setNeverExpire(v)}
|
||||
/>
|
||||
|
||||
{!neverExpire && (
|
||||
<Form.DatePicker
|
||||
field='expired_time'
|
||||
label={t('过期时间')}
|
||||
type='dateTime'
|
||||
className='w-full'
|
||||
/>
|
||||
)}
|
||||
</Form>
|
||||
</Spin>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminEditTokenModal;
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Modal, Typography } from '@douyinfe/semi-ui';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const AdminEnableDisableTokenModal = ({
|
||||
visible,
|
||||
onCancel,
|
||||
onConfirm,
|
||||
token,
|
||||
action,
|
||||
t,
|
||||
}) => {
|
||||
const isDisable = action === 'disable';
|
||||
if (!token) return null;
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={isDisable ? t('确定要禁用此秘钥吗?') : t('确定要启用此秘钥吗?')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={onConfirm}
|
||||
type='warning'
|
||||
>
|
||||
<div className='space-y-1'>
|
||||
<div>
|
||||
{isDisable
|
||||
? t('禁用后用户将无法使用此秘钥调用 API')
|
||||
: t('启用后用户即可重新使用此秘钥')}
|
||||
</div>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('秘钥名称')}:{token.name || '—'}
|
||||
</Text>
|
||||
<br />
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('所属用户')}:{token.display_name || token.username || '—'} (ID:{' '}
|
||||
{token.user_id})
|
||||
</Text>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminEnableDisableTokenModal;
|
||||
Reference in New Issue
Block a user