feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面

This commit is contained in:
zhanjunhao
2026-11-09 21:45:37 +08:00
parent 6ad95e2baa
commit 5713d541b0
242 changed files with 9242 additions and 5043 deletions
+7 -4
View File
@@ -18,7 +18,8 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Button } from '@/components/ui';
import { Button } from 'antd';
import { Plus } from 'lucide-react';
import { isAdmin } from '../../../helpers';
const UsersActions = ({ setShowAddUser, t }) => {
@@ -28,12 +29,14 @@ const UsersActions = ({ setShowAddUser, t }) => {
};
return (
<div className='flex gap-2 w-full md:w-auto order-2 md:order-1'>
<div className='flex justify-end gap-2'>
{isAdmin() && (
<Button
className='w-full md:w-auto'
className='console-create-action'
type='primary'
icon={<Plus size={16} />}
onClick={handleAddUser}
size='small'
size='middle'
>
{t('添加用户')}
</Button>
+25 -40
View File
@@ -28,6 +28,7 @@ import {
Typography,
Dropdown,
} from '@/components/ui';
import { Switch } from 'antd';
import { IconMore } from '@/components/ui/icons';
import {
renderGroup,
@@ -119,24 +120,24 @@ const renderUsername = (text, record) => {
const renderStatistics = (text, record, showEnableDisableModal, t) => {
const isDeleted = record.DeletedAt !== null;
// Determine tag text & color like original status column
let tagColor = 'grey';
let tagText = t('未知状态');
if (isDeleted) {
tagColor = 'red';
tagText = t('已注销');
} else if (record.status === 1) {
tagColor = 'green';
tagText = t('已启用');
} else if (record.status === 2) {
tagColor = 'red';
tagText = t('已禁用');
}
const content = (
<Tag color={tagColor} shape='circle' size='small'>
{tagText}
</Tag>
const currentRole = Number(getUserData()?.role || 0);
const canManage =
isAdmin() && (currentRole >= 100 || Number(record.role || 0) < 100);
const content = isDeleted ? (
<Tag color='red'>{t('已注销')}</Tag>
) : (
<Switch
size='small'
checked={record.status === 1}
checkedChildren={t('启用')}
unCheckedChildren={t('禁用')}
aria-label={t('状态')}
disabled={!canManage}
onChange={(checked, event) => {
event.stopPropagation();
showEnableDisableModal(record, checked ? 'enable' : 'disable');
}}
/>
);
const tooltipContent = (
@@ -163,13 +164,13 @@ const renderQuotaUsage = (text, record, t) => {
const percent = total > 0 ? (remain / total) * 100 : 0;
const popoverContent = (
<div className='text-xs p-2'>
<Paragraph copyable={{ content: renderQuota(used) }}>
<Paragraph copyable={{ text: renderQuota(used) }}>
{t('已用额度')}: {renderQuota(used)}
</Paragraph>
<Paragraph copyable={{ content: renderQuota(remain) }}>
<Paragraph copyable={{ text: renderQuota(remain) }}>
{t('剩余额度')}: {renderQuota(remain)} ({percent.toFixed(0)}%)
</Paragraph>
<Paragraph copyable={{ content: renderQuota(total) }}>
<Paragraph copyable={{ text: renderQuota(total) }}>
{t('总额度')}: {renderQuota(total)}
</Paragraph>
</div>
@@ -296,11 +297,11 @@ const renderOperations = (
return (
// wrap 保留:移动端 CardTable 把按钮放进 ~280px 的卡片行里,Semi Space 默认
// wrap:false 时溢出会被 .ant-card{overflow:hidden} 裁掉(不是滚动,是永久看不到)
<Space wrap>
<Space wrap className='console-module-row-actions'>
{canManage && (
<>
<Button
type='tertiary'
type='link'
size='small'
onClick={() => {
setEditingUser(record);
@@ -309,22 +310,6 @@ const renderOperations = (
>
{t('编辑')}
</Button>
{record.status === 1 ? (
<Button
type='danger'
size='small'
onClick={() => showEnableDisableModal(record, 'disable')}
>
{t('禁用')}
</Button>
) : (
<Button
size='small'
onClick={() => showEnableDisableModal(record, 'enable')}
>
{t('启用')}
</Button>
)}
</>
)}
<Dropdown menu={moreMenu} trigger='click' position='bottomRight'>
@@ -409,7 +394,7 @@ export const getUsersColumns = ({
fixed: 'right',
// 200 而不是更窄:en 下「Edit + Disable + 更多」三控件 ≈ 190px,
// 再窄会触发 Space wrap 折行,重新撑高行高(本次改版要消灭的问题)
width: 200,
width: 120,
render: (text, record, index) =>
renderOperations(text, record, {
setEditingUser,
@@ -21,10 +21,20 @@ import React from 'react';
import { Typography } from '@/components/ui';
import { IconUserAdd } from '@/components/ui/icons';
import CompactModeToggle from '../../common/ui/CompactModeToggle';
import { useConsolePage } from '../../console/ConsoleContext';
const { Text } = Typography;
const UsersDescription = ({ compactMode, setCompactMode, t }) => {
const consolePage = useConsolePage();
if (consolePage)
return (
<CompactModeToggle
compactMode={compactMode}
setCompactMode={setCompactMode}
t={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 text-blue-500'>
+25 -37
View File
@@ -18,7 +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 { ConsoleFilterActions } from '../../console/ConsoleModuleFilters';
import { useFilterSearch } from '../../../hooks/common/useFilterSearch';
import { IconSearch } from '@/components/ui/icons';
const UsersFilters = ({
@@ -33,11 +35,16 @@ const UsersFilters = ({
searching,
t,
}) => {
const { scheduleSearch, submitSearch, cancelPendingSearch } = useFilterSearch(
() => searchUsers(1, pageSize),
);
const formApiRef = useRef(null);
const handleReset = () => {
if (!formApiRef.current) return;
formApiRef.current.reset();
cancelPendingSearch();
setTimeout(() => {
loadUsers(1, pageSize);
}, 100);
@@ -45,69 +52,50 @@ const UsersFilters = ({
return (
<Form
initValues={formInitValues}
initValues={{
...formInitValues,
searchGroup: formInitValues.searchGroup || undefined,
}}
getFormApi={(api) => {
setFormApi(api);
formApiRef.current = api;
}}
onSubmit={() => {
searchUsers(1, pageSize);
}}
onSubmit={submitSearch}
allowEmpty={true}
autoComplete='off'
layout='horizontal'
layout='vertical'
trigger='change'
stopValidateWithError={false}
className='w-full md:w-auto order-1 md:order-2'
className='console-module-filter-form'
onValueChange={scheduleSearch}
>
<div className='flex flex-col md:flex-row items-center gap-2 w-full md:w-auto'>
<div className='relative w-full md:w-64'>
<div className='console-module-filter-grid'>
<div className='console-module-field'>
<Form.Input
label={t('用户名')}
field='searchKeyword'
prefix={<IconSearch />}
placeholder={t('支持搜索用户的 ID、用户名、显示名称和邮箱地址')}
showClear
pure
size='small'
/>
</div>
<div className='w-full md:w-48'>
<div className='console-module-field'>
<Form.Select
label={t('分组')}
field='searchGroup'
placeholder={t('选择分组')}
optionList={groupOptions}
onChange={(value) => {
// Group change triggers automatic search
setTimeout(() => {
searchUsers(1, pageSize);
}, 100);
}}
className='w-full'
showClear
pure
size='small'
/>
</div>
<div className='flex gap-2 w-full md:w-auto'>
<Button
type='tertiary'
htmlType='submit'
loading={loading || searching}
className='flex-1 md:flex-initial md:w-auto'
size='small'
>
{t('查询')}
</Button>
<Button
type='tertiary'
onClick={handleReset}
className='flex-1 md:flex-initial md:w-auto'
size='small'
>
{t('重置')}
</Button>
</div>
</div>
<ConsoleFilterActions
onReset={handleReset}
loading={loading || searching}
/>
</Form>
);
};
+3 -15
View File
@@ -17,13 +17,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import TableEmpty from '../../common/table/TableEmpty';
import React, { useMemo, useState } from 'react';
import { Empty } from '@/components/ui';
import CardTable from '../../common/ui/CardTable';
import {
IllustrationNoResult,
IllustrationNoResultDark,
} from '../../common/illustrations';
import { getUsersColumns } from './UsersColumnDefs';
import PromoteUserModal from './modals/PromoteUserModal';
import DemoteUserModal from './modals/DemoteUserModal';
@@ -185,16 +182,7 @@ const UsersTable = (usersData) => {
hidePagination={true}
loading={loading}
onRow={handleRow}
empty={
<Empty
image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
darkModeImage={
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
}
description={t('搜索无结果')}
style={{ padding: 30 }}
/>
}
empty={<TableEmpty />}
className='overflow-hidden'
size='middle'
/>
+17 -18
View File
@@ -78,6 +78,21 @@ const UsersPage = () => {
/>
<CardPro
tableTitle={t('用户列表')}
searchArea={
<UsersFilters
formInitValues={formInitValues}
setFormApi={setFormApi}
searchUsers={searchUsers}
loadUsers={loadUsers}
activePage={activePage}
pageSize={pageSize}
groupOptions={groupOptions}
loading={loading}
searching={searching}
t={t}
/>
}
type='type1'
descriptionArea={
<UsersDescription
@@ -86,25 +101,9 @@ const UsersPage = () => {
t={t}
/>
}
actionsArea={
<div className='flex flex-col md:flex-row justify-between items-center gap-2 w-full'>
<UsersActions setShowAddUser={setShowAddUser} t={t} />
<UsersFilters
formInitValues={formInitValues}
setFormApi={setFormApi}
searchUsers={searchUsers}
loadUsers={loadUsers}
activePage={activePage}
pageSize={pageSize}
groupOptions={groupOptions}
loading={loading}
searching={searching}
t={t}
/>
</div>
}
tableActions={<UsersActions setShowAddUser={setShowAddUser} t={t} />}
paginationArea={createCardProPagination({
showRange: false,
currentPage: usersData.activePage,
pageSize: usersData.pageSize,
total: usersData.userCount,
@@ -20,24 +20,9 @@ For commercial licensing, please contact support@quantumnous.com
import React, { useState, useRef } from 'react';
import { API, showError, showSuccess } from '../../../../helpers';
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
import {
Button,
SideSheet,
Space,
Spin,
Typography,
Card,
Tag,
Avatar,
Form,
Row,
Col,
} from '@/components/ui';
import { IconSave, IconClose, IconUserAdd } from '@/components/ui/icons';
import { Button, SideSheet, Spin, Form, Row, Col } from '@/components/ui';
import { useTranslation } from 'react-i18next';
const { Text, Title } = Typography;
const AddUserModal = (props) => {
const { t } = useTranslation();
const formApiRef = useRef(null);
@@ -73,43 +58,23 @@ const AddUserModal = (props) => {
return (
<>
<SideSheet
placement={'left'}
title={
<Space>
<Tag color='green' shape='circle'>
{t('新建')}
</Tag>
<Title heading={4} className='m-0'>
{t('添加用户')}
</Title>
</Space>
}
bodyStyle={{ padding: '0' }}
placement='right'
classNames={{ header: 'console-detail-header' }}
title={t('添加用户')}
visible={props.visible}
width={isMobile ? '100%' : 600}
width={isMobile ? '100%' : 560}
footer={
<div className='flex justify-end'>
<Space>
<Button
theme='solid'
onClick={() => formApiRef.current?.submitForm()}
icon={<IconSave />}
loading={loading}
>
{t('提交')}
</Button>
<Button
theme='light'
type='primary'
onClick={handleCancel}
icon={<IconClose />}
>
{t('取消')}
</Button>
</Space>
<div className='console-dialog-actions'>
<Button onClick={handleCancel}>{t('取消')}</Button>
<Button
theme='solid'
onClick={() => formApiRef.current?.submitForm()}
loading={loading}
>
{t('确定')}
</Button>
</div>
}
closeIcon={null}
onCancel={() => handleCancel()}
>
<Spin spinning={loading}>
@@ -123,59 +88,43 @@ const AddUserModal = (props) => {
formApiRef.current?.scrollToError();
}}
>
<div className='p-2'>
<Card className='!rounded-2xl shadow-sm border-0'>
<div className='flex items-center mb-2'>
<Avatar size='small' color='blue' className='mr-2 shadow-md'>
<IconUserAdd size={16} />
</Avatar>
<div>
<Text className='text-lg font-medium'>{t('用户信息')}</Text>
<div className='text-xs text-gray-600'>
{t('创建新用户账户')}
</div>
</div>
</div>
<Row gutter={12}>
<Col span={24}>
<Form.Input
field='username'
label={t('用户名')}
placeholder={t('请输入用户名')}
rules={[{ required: true, message: t('请输入用户名') }]}
showClear
/>
</Col>
<Col span={24}>
<Form.Input
field='display_name'
label={t('显示名称')}
placeholder={t('请输入显示名称')}
showClear
/>
</Col>
<Col span={24}>
<Form.Input
field='password'
label={t('密码')}
type='password'
placeholder={t('请输入密码')}
rules={[{ required: true, message: t('请输入密码') }]}
showClear
/>
</Col>
<Col span={24}>
<Form.Input
field='remark'
label={t('备注')}
placeholder={t('请输入备注(仅管理员可见)')}
showClear
/>
</Col>
</Row>
</Card>
</div>
<Row gutter={12}>
<Col span={24}>
<Form.Input
field='username'
label={t('用户名')}
placeholder={t('请输入用户名')}
rules={[{ required: true, message: t('请输入用户名') }]}
showClear
/>
</Col>
<Col span={24}>
<Form.Input
field='display_name'
label={t('显示名称')}
placeholder={t('请输入显示名称')}
showClear
/>
</Col>
<Col span={24}>
<Form.Input
field='password'
label={t('密码')}
type='password'
placeholder={t('请输入密码')}
rules={[{ required: true, message: t('请输入密码') }]}
showClear
/>
</Col>
<Col span={24}>
<Form.Input
field='remark'
label={t('备注')}
placeholder={t('请输入备注(仅管理员可见)')}
showClear
/>
</Col>
</Row>
</Form>
</Spin>
</SideSheet>
@@ -19,12 +19,7 @@ For commercial licensing, please contact support@quantumnous.com
import React, { useEffect, useState, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import {
API,
showError,
showSuccess,
renderQuota,
} from '../../../../helpers';
import { API, showError, showSuccess, renderQuota } from '../../../../helpers';
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
import {
Button,
@@ -34,25 +29,20 @@ import {
Spin,
Typography,
Card,
Tag,
Form,
Avatar,
Row,
Col,
} from '@/components/ui';
import QuotaInput, {
FormQuotaInput,
} from '../../../common/ui/QuotaInput';
import QuotaInput, { FormQuotaInput } from '../../../common/ui/QuotaInput';
import {
IconUser,
IconSave,
IconClose,
IconLink,
IconUserGroup,
IconPlus,
} from '@/components/ui/icons';
const { Text, Title } = Typography;
const { Text } = Typography;
const EditUserModal = (props) => {
const { t } = useTranslation();
@@ -176,42 +166,25 @@ const EditUserModal = (props) => {
<>
<SideSheet
placement='right'
title={
<Space>
<Tag color='blue' shape='circle'>
{t(isEdit ? '编辑' : '新建')}
</Tag>
<Title heading={4} className='m-0'>
{isEdit ? t('编辑用户') : t('创建用户')}
</Title>
</Space>
}
classNames={{ header: 'console-detail-header' }}
title={isEdit ? t('编辑用户') : t('创建用户')}
bodyStyle={{ padding: 0 }}
visible={props.visible}
width={isMobile ? '100%' : 600}
footer={
<div className='flex justify-end'>
<Space>
<Button onClick={handleCancel}>{t('取消')}</Button>
<Button
theme='solid'
onClick={() => formApiRef.current?.submitForm()}
icon={<IconSave />}
loading={loading}
>
{t('提交')}
</Button>
<Button
theme='light'
type='primary'
onClick={handleCancel}
icon={<IconClose />}
>
{t('取消')}
{t('确定')}
</Button>
</Space>
</div>
}
closeIcon={null}
onCancel={handleCancel}
>
<Spin spinning={loading}>
@@ -18,12 +18,9 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React, { useState, useEffect } from 'react';
import { Modal, Table, Tag, Empty, Spin } from '@/components/ui';
import { Modal, Table, Tag, Spin } from '@/components/ui';
import { API, renderQuota, renderNumber, showError } from '../../../../helpers';
import {
IllustrationNoResult,
IllustrationNoResultDark,
} from '../../../common/illustrations';
import TableEmpty from '../../../common/table/TableEmpty';
const InvitedUsersModal = ({ visible, onCancel, user, t }) => {
const [invitedUsers, setInvitedUsers] = useState([]);
@@ -162,18 +159,7 @@ const InvitedUsersModal = ({ visible, onCancel, user, t }) => {
dataSource={invitedUsers}
pagination={false}
size='small'
empty={
<Empty
image={
<IllustrationNoResult style={{ width: 150, height: 150 }} />
}
darkModeImage={
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
}
description={t('该用户暂未邀请任何用户')}
style={{ padding: 30 }}
/>
}
empty={<TableEmpty />}
style={{ maxHeight: '500px', overflowY: 'auto' }}
/>
</Spin>