refactor(types): 重构类型系统,统一共享类型定义
feat(types): 新增共享类型中心,包含用户、产品、订单等核心领域类型 fix(types): 修复类型定义错误,统一各模块类型引用 style(types): 优化类型文件格式和注释 docs(types): 更新类型文档和变更日志 test(types): 添加类型测试用例 build(types): 配置类型共享路径 chore(types): 清理重复类型定义文件
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Card, Typography, Table, Button, Form, Input, Checkbox, Modal, message, Popconfirm, Tree } from 'antd';
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined, SettingOutlined } from '@ant-design/icons';
|
||||
import { Link } from 'umi';
|
||||
import { settingsDataSource, Role, Permission } from '@/services/settingsDataSource';
|
||||
import { settingsDataSource, Role } from '@/services/settingsDataSource';
|
||||
|
||||
interface PermissionNode {
|
||||
id: string;
|
||||
key: string;
|
||||
name: string;
|
||||
code: string;
|
||||
children?: PermissionNode[];
|
||||
}
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
const { Item } = Form;
|
||||
@@ -14,6 +21,7 @@ const RoleManagement: React.FC = () => {
|
||||
name: '管理员',
|
||||
code: 'ADMIN',
|
||||
description: '系统管理员,拥有所有权限',
|
||||
permissions: ['PRODUCT_MANAGE', 'ORDER_MANAGE', 'USER_MANAGE', 'SYSTEM_MANAGE'],
|
||||
status: 'active',
|
||||
createdAt: '2026-03-01',
|
||||
updatedAt: '2026-03-01',
|
||||
@@ -22,7 +30,8 @@ const RoleManagement: React.FC = () => {
|
||||
id: '2',
|
||||
name: '运营主管',
|
||||
code: 'MANAGER',
|
||||
description: '运营主管,拥有运营相关权限',
|
||||
description: '运营主管,拥有大部分权限',
|
||||
permissions: ['PRODUCT_MANAGE', 'ORDER_MANAGE', 'USER_MANAGE'],
|
||||
status: 'active',
|
||||
createdAt: '2026-03-02',
|
||||
updatedAt: '2026-03-02',
|
||||
@@ -31,54 +40,59 @@ const RoleManagement: React.FC = () => {
|
||||
id: '3',
|
||||
name: '运营专员',
|
||||
code: 'OPERATOR',
|
||||
description: '运营专员,拥有基础运营权限',
|
||||
description: '运营专员,拥有基础权限',
|
||||
permissions: ['PRODUCT_MANAGE', 'ORDER_MANAGE'],
|
||||
status: 'active',
|
||||
createdAt: '2026-03-03',
|
||||
updatedAt: '2026-03-03',
|
||||
},
|
||||
]);
|
||||
|
||||
const [permissions, setPermissions] = useState<Permission[]>([
|
||||
const [permissions, setPermissions] = useState<PermissionNode[]>([
|
||||
{
|
||||
id: '1',
|
||||
key: '1',
|
||||
name: '商品管理',
|
||||
code: 'PRODUCT_MANAGE',
|
||||
children: [
|
||||
{ id: '1-1', name: '商品列表', code: 'PRODUCT_LIST' },
|
||||
{ id: '1-2', name: '商品添加', code: 'PRODUCT_ADD' },
|
||||
{ id: '1-3', name: '商品编辑', code: 'PRODUCT_EDIT' },
|
||||
{ id: '1-4', name: '商品删除', code: 'PRODUCT_DELETE' },
|
||||
{ id: '1-1', key: '1-1', name: '商品列表', code: 'PRODUCT_LIST' },
|
||||
{ id: '1-2', key: '1-2', name: '商品添加', code: 'PRODUCT_ADD' },
|
||||
{ id: '1-3', key: '1-3', name: '商品编辑', code: 'PRODUCT_EDIT' },
|
||||
{ id: '1-4', key: '1-4', name: '商品删除', code: 'PRODUCT_DELETE' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
key: '2',
|
||||
name: '订单管理',
|
||||
code: 'ORDER_MANAGE',
|
||||
children: [
|
||||
{ id: '2-1', name: '订单列表', code: 'ORDER_LIST' },
|
||||
{ id: '2-2', name: '订单详情', code: 'ORDER_DETAIL' },
|
||||
{ id: '2-3', name: '订单处理', code: 'ORDER_PROCESS' },
|
||||
{ id: '2-1', key: '2-1', name: '订单列表', code: 'ORDER_LIST' },
|
||||
{ id: '2-2', key: '2-2', name: '订单详情', code: 'ORDER_DETAIL' },
|
||||
{ id: '2-3', key: '2-3', name: '订单处理', code: 'ORDER_PROCESS' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
key: '3',
|
||||
name: '用户管理',
|
||||
code: 'USER_MANAGE',
|
||||
children: [
|
||||
{ id: '3-1', name: '用户列表', code: 'USER_LIST' },
|
||||
{ id: '3-2', name: '用户添加', code: 'USER_ADD' },
|
||||
{ id: '3-3', name: '用户编辑', code: 'USER_EDIT' },
|
||||
{ id: '3-4', name: '用户删除', code: 'USER_DELETE' },
|
||||
{ id: '3-1', key: '3-1', name: '用户列表', code: 'USER_LIST' },
|
||||
{ id: '3-2', key: '3-2', name: '用户添加', code: 'USER_ADD' },
|
||||
{ id: '3-3', key: '3-3', name: '用户编辑', code: 'USER_EDIT' },
|
||||
{ id: '3-4', key: '3-4', name: '用户删除', code: 'USER_DELETE' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
key: '4',
|
||||
name: '系统管理',
|
||||
code: 'SYSTEM_MANAGE',
|
||||
children: [
|
||||
{ id: '4-1', name: '角色管理', code: 'ROLE_MANAGE' },
|
||||
{ id: '4-2', name: '权限管理', code: 'PERMISSION_MANAGE' },
|
||||
{ id: '4-3', name: '系统配置', code: 'SYSTEM_CONFIG' },
|
||||
{ id: '4-1', key: '4-1', name: '角色管理', code: 'ROLE_MANAGE' },
|
||||
{ id: '4-2', key: '4-2', name: '权限管理', code: 'PERMISSION_MANAGE' },
|
||||
{ id: '4-3', key: '4-3', name: '系统配置', code: 'SYSTEM_CONFIG' },
|
||||
],
|
||||
},
|
||||
]);
|
||||
@@ -281,7 +295,7 @@ const RoleManagement: React.FC = () => {
|
||||
onOk={handleSavePermissions}
|
||||
width={800}
|
||||
>
|
||||
<Tree
|
||||
<Tree<PermissionNode>
|
||||
checkable
|
||||
treeData={permissions}
|
||||
defaultExpandAll
|
||||
|
||||
Reference in New Issue
Block a user