@@ -1,6 +1,6 @@ | |||||
export default [ | export default [ | ||||
{ path: '/user', layout: false, routes: [{ path: '/user/login', component: './user/login' }] }, | { path: '/user', layout: false, routes: [{ path: '/user/login', component: './user/login' }] }, | ||||
{ path: '/', icon: 'SmileOutlined', component: './welcome', name: '欢迎页' }, | |||||
{ path: '/', icon: 'SmileOutlined', component: './welcome', name: '欢迎页', routes: []}, | |||||
{ | { | ||||
icon: 'SettingOutlined', | icon: 'SettingOutlined', | ||||
path: '/system', | path: '/system', | ||||
@@ -13,13 +13,13 @@ | |||||
], | ], | ||||
}, | }, | ||||
{ | { | ||||
path: '/wmx', icon: 'SettingOutlined', name: '设备模型管理', | |||||
path: '/deviceModal', icon: 'SettingOutlined', name: '设备模型管理', | |||||
routes: [{ | routes: [{ | ||||
name: '设备建模', | name: '设备建模', | ||||
path: '/wmx/deviceProduct', | |||||
path: '/deviceModal/deviceProduct', | |||||
component: './deviceProductInfo/index', | component: './deviceProductInfo/index', | ||||
}, | }, | ||||
{ path: '/wmx/deviceinfo', name: '设备管理', component: './deviceInfo/index' }, | |||||
{ path: '/deviceModal/deviceinfo', name: '设备管理', component: './deviceInfo/index' }, | |||||
] | ] | ||||
}, | }, | ||||
{ | { | ||||
@@ -38,10 +38,10 @@ | |||||
{ path: '/production/final', name: '成品管理', component: './final/index' }, | { path: '/production/final', name: '成品管理', component: './final/index' }, | ||||
] | ] | ||||
}, | }, | ||||
{ path: '/work', icon: 'SettingOutlined', name: '生产计划管理', | |||||
{ path: '/work',icon: 'SmileOutlined', name: '生产计划管理', | |||||
routes: [ | routes: [ | ||||
{ path: '/work/workPlan', name: '生产计划', component: './workInfo/plan' }, | |||||
{ path: '/work/workInfo', name: '工单管理', component: './workInfo/index' }, | |||||
{ path: '/work/workPlan', name: '生产计划', component: './workInfo/plan', }, | |||||
{ path: '/work/workInfo', name: '工单管理', component: './workInfo/index', }, | |||||
] | ] | ||||
}, | }, | ||||
@@ -11,23 +11,45 @@ import * as Icon from '@ant-design/icons'; | |||||
const isDev = process.env.NODE_ENV === 'development'; | const isDev = process.env.NODE_ENV === 'development'; | ||||
const loopMenuItem = (menus: MenuDataItem[]): MenuDataItem[] => { | const loopMenuItem = (menus: MenuDataItem[]): MenuDataItem[] => { | ||||
return menus?.map(({ icon, routes, ...item }) => ({ | |||||
...item, | |||||
icon: icon && React.createElement(Icon && (Icon as any)[item.icon]), | |||||
routes: routes && loopMenuItem(routes), | |||||
// menus.map((item:any)=>{ | |||||
// item.icon = React.createElement((Icon as any)[item.icon]) | |||||
// }) | |||||
return menus?.map(({ icon, routes, ...item }) => ( | |||||
{ | |||||
...item, | |||||
icon: (icon as string).trim() ? React.createElement((Icon as any)[icon as string]):React.createElement((Icon as any)['SettingOutlined']), | |||||
routes: routes && loopMenuItem(routes), | |||||
})); | })); | ||||
}; | }; | ||||
const formartRoutes = (menuTree: any[]) => { | const formartRoutes = (menuTree: any[]) => { | ||||
menuTree.forEach((item) => { | menuTree.forEach((item) => { | ||||
item.path = item.url; | item.path = item.url; | ||||
if (item.children && item.children.length > 0 && item.category < 2) { | |||||
formartRoutes(item.children); | |||||
item.component = item.component; | |||||
// item.icon = item.icon || 'SettingOutlined' | |||||
if (item.routes && item.routes.length > 0 && item.category < 2) { | |||||
formartRoutes(item.routes); | |||||
} else { | } else { | ||||
delete item.children; | |||||
delete item.routes; | |||||
} | |||||
}); | |||||
// menuTree = menuTree.filter((item,index)=>item.routes.length = 0 && item.component == null&& item.category < 2) | |||||
// 要保留的属性列表 | |||||
const keepProps = ['name', 'path','routes','icon']; | |||||
// 使用map和扩展运算符删除多余的属性 | |||||
const filteredEntities = menuTree.map(entity => { | |||||
// 创建一个只包含要保留属性的对象 | |||||
const filtered:any = {}; | |||||
keepProps.forEach(prop => { | |||||
if (entity.hasOwnProperty(prop)) { | |||||
filtered[prop] = entity[prop]; | |||||
} | } | ||||
}); | }); | ||||
return menuTree; | |||||
return filtered; | |||||
}); | |||||
return filteredEntities; | |||||
}; | }; | ||||
/** | /** | ||||
@@ -50,8 +72,8 @@ export async function getInitialState(): Promise<{ | |||||
}; | }; | ||||
const response = await fetchUserInfo(); | const response = await fetchUserInfo(); | ||||
if (response) { | if (response) { | ||||
localStorage.setItem('USER_INFO', JSON.stringify(response.userInfo)); | |||||
localStorage.setItem('USER_MENU', JSON.stringify(response.menus)); | |||||
sessionStorage.setItem(`USER_INFO-${response.userInfo.userId}`, JSON.stringify(response.userInfo)); | |||||
sessionStorage.setItem(`USER_MENU-${response.userInfo.userId}`, JSON.stringify(response.menus)); | |||||
return { | return { | ||||
menuData: formartRoutes(response.menus), | menuData: formartRoutes(response.menus), | ||||
currentUser: response.userInfo, | currentUser: response.userInfo, | ||||
@@ -74,8 +96,8 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => { | |||||
content: '黑菠萝科技研发部', | content: '黑菠萝科技研发部', | ||||
}, | }, | ||||
token: { | token: { | ||||
layout:{ | |||||
bgLayout:'#001529' | |||||
layout: { | |||||
bgLayout: '#001529' | |||||
}, | }, | ||||
// colorBgAppListIconHover: '#fff', | // colorBgAppListIconHover: '#fff', | ||||
// colorTextAppListIconHover: 'rgba(255,255,255,0.95)', | // colorTextAppListIconHover: 'rgba(255,255,255,0.95)', | ||||
@@ -86,7 +108,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => { | |||||
// colorTextCollapsedButton: '#fff', | // colorTextCollapsedButton: '#fff', | ||||
colorMenuBackground: '#001529',//菜单背景色 | colorMenuBackground: '#001529',//菜单背景色 | ||||
//colorBgMenuItemCollapsedHover: '#fff', | //colorBgMenuItemCollapsedHover: '#fff', | ||||
colorBgMenuItemCollapsedElevated:'#001529', | |||||
colorBgMenuItemCollapsedElevated: '#001529', | |||||
colorBgMenuItemCollapsedSelected: '#0960bd', | colorBgMenuItemCollapsedSelected: '#0960bd', | ||||
colorMenuItemDivider: 'rgba(255,255,255,0.15)', | colorMenuItemDivider: 'rgba(255,255,255,0.15)', | ||||
colorBgMenuItemHover: '#0960bd', | colorBgMenuItemHover: '#0960bd', | ||||
@@ -116,7 +138,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => { | |||||
headerContentRender: () => <ProBreadcrumb />, | headerContentRender: () => <ProBreadcrumb />, | ||||
footerRender: () => <Footer />, | footerRender: () => <Footer />, | ||||
onPageChange: () => { | onPageChange: () => { | ||||
const userToken = localStorage.getItem('USER_TOKEN'); | |||||
const userToken = sessionStorage.getItem('USER_TOKEN'); | |||||
if (userToken) { | if (userToken) { | ||||
const userInfo = JSON.parse(userToken); | const userInfo = JSON.parse(userToken); | ||||
//如果Token不存在跳转登录页面 | //如果Token不存在跳转登录页面 | ||||
@@ -139,9 +161,11 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => { | |||||
}, | }, | ||||
...initialState?.settings, | ...initialState?.settings, | ||||
}; | }; | ||||
if (config.menuDataRender) { | |||||
delete config.menuDataRender; | |||||
} | |||||
// if (process.env.NODE_ENV === 'development') { | |||||
// if (config.menuDataRender) { | |||||
// delete config.menuDataRender; | |||||
// } | |||||
// } | |||||
return config; | return config; | ||||
}; | }; | ||||
@@ -18,7 +18,9 @@ const HeaderRight: React.FC = () => { | |||||
switch (key) { | switch (key) { | ||||
case 'logout': | case 'logout': | ||||
localStorage.clear(); | localStorage.clear(); | ||||
sessionStorage.clear(); | |||||
history.push('/user/login'); | history.push('/user/login'); | ||||
history.go(0); | |||||
case 'edit': | case 'edit': | ||||
setIsEditPwd(true); | setIsEditPwd(true); | ||||
break; | break; | ||||
@@ -90,7 +90,7 @@ const SystemManagement: React.FC = () => { | |||||
title: '操作', | title: '操作', | ||||
valueType: 'option', | valueType: 'option', | ||||
key: 'option', | key: 'option', | ||||
fixed:'right', | |||||
fixed: 'right', | |||||
render: (_, record) => [ | render: (_, record) => [ | ||||
<a key="edit" onClick={() => { | <a key="edit" onClick={() => { | ||||
setCurrentMenu(record); | setCurrentMenu(record); | ||||
@@ -217,15 +217,15 @@ const SystemManagement: React.FC = () => { | |||||
actionRef={tableRef} | actionRef={tableRef} | ||||
columns={menuColumns} | columns={menuColumns} | ||||
cardBordered | cardBordered | ||||
bordered | |||||
scroll={{ x: true }} | |||||
rowClassName={(record: any, index: number, indent: number) => { | |||||
if (index % 2 === 0) { | |||||
return ''; // 偶数行的类名 | |||||
} else { | |||||
return 'even-row-background'; // 奇数行的类名 | |||||
} | |||||
}} | |||||
bordered | |||||
scroll={{ x: true }} | |||||
rowClassName={(record: any, index: number, indent: number) => { | |||||
if (index % 2 === 0) { | |||||
return ''; // 偶数行的类名 | |||||
} else { | |||||
return 'even-row-background'; // 奇数行的类名 | |||||
} | |||||
}} | |||||
request={async (values) => { | request={async (values) => { | ||||
const params = JSON.parse(JSON.stringify(values)); | const params = JSON.parse(JSON.stringify(values)); | ||||
delete params.current; | delete params.current; | ||||
@@ -270,7 +270,7 @@ const SystemManagement: React.FC = () => { | |||||
pagination={{ | pagination={{ | ||||
current: currentPage, | current: currentPage, | ||||
pageSize: 10, | pageSize: 10, | ||||
showSizeChanger:false, | |||||
showSizeChanger: false, | |||||
onChange: (page) => setCurrentPage(page), | onChange: (page) => setCurrentPage(page), | ||||
}} | }} | ||||
dateFormatter="string" | dateFormatter="string" | ||||
@@ -282,8 +282,21 @@ const SystemManagement: React.FC = () => { | |||||
]} | ]} | ||||
/> | /> | ||||
<Modal | <Modal | ||||
maskClosable={false} footer={null} width={1000} title={currentMenu.id ? '编辑菜单' : '新建菜单'} open={isModalVisible} onCancel={() => setIsModalVisible(false)}> | |||||
maskClosable={false} footer={[ | |||||
<Button | |||||
key="back" | |||||
onClick={() => { | |||||
setIsModalVisible(false) | |||||
}} | |||||
> | |||||
返回 | |||||
</Button>, | |||||
<Button key="submit" form="moduleForm" type="primary" htmlType="submit"> | |||||
提交 | |||||
</Button>, | |||||
]} width={1000} title={currentMenu.id ? '编辑菜单' : '新建菜单'} open={isModalVisible} onCancel={() => setIsModalVisible(false)}> | |||||
<Form | <Form | ||||
id='moduleForm' | |||||
form={menuForm} | form={menuForm} | ||||
onFinish={onFinishMenu} | onFinish={onFinishMenu} | ||||
> | > | ||||
@@ -347,11 +360,6 @@ const SystemManagement: React.FC = () => { | |||||
</Form.Item> | </Form.Item> | ||||
</Col> | </Col> | ||||
</Row> | </Row> | ||||
<Form.Item> | |||||
<Button type="primary" htmlType="submit"> | |||||
确定 | |||||
</Button> | |||||
</Form.Item> | |||||
</Form> | </Form> | ||||
</Modal> | </Modal> | ||||
</div> | </div> | ||||
@@ -50,8 +50,8 @@ export const errorConfig: RequestConfig<MyResponse.Content> = { | |||||
config.url = config.url?.replace("/api", '/api/api') | config.url = config.url?.replace("/api", '/api/api') | ||||
} | } | ||||
// 拦截请求配置,进行个性化处理。 | // 拦截请求配置,进行个性化处理。 | ||||
const userToken = localStorage.getItem('USER_TOKEN'); | |||||
const x_Token = localStorage.getItem('USER_X_TOKEN'); | |||||
const userToken = sessionStorage.getItem('USER_TOKEN'); | |||||
const x_Token = sessionStorage.getItem('USER_X_TOKEN'); | |||||
if (userToken && config.headers) { | if (userToken && config.headers) { | ||||
const userInfo = JSON.parse(userToken); | const userInfo = JSON.parse(userToken); | ||||
const x_Tokens = JSON.parse(x_Token!); | const x_Tokens = JSON.parse(x_Token!); | ||||
@@ -74,12 +74,17 @@ export const errorConfig: RequestConfig<MyResponse.Content> = { | |||||
[ | [ | ||||
(response: AxiosResponse) => { | (response: AxiosResponse) => { | ||||
const userToken = response.headers["access-token"] | const userToken = response.headers["access-token"] | ||||
if (userToken) { | if (userToken) { | ||||
localStorage.setItem('USER_TOKEN', JSON.stringify(userToken)); | |||||
const jwtinfo = jwt.ecryptJWT(userToken); | |||||
sessionStorage.setItem(`USER_TOKEN-${jwtinfo.UserId}`, JSON.stringify(userToken)); | |||||
sessionStorage.setItem(`USER_TOKEN`, JSON.stringify(userToken)); | |||||
} | } | ||||
const xAuth = response.headers["x-access-token"]; | const xAuth = response.headers["x-access-token"]; | ||||
if (xAuth) { | if (xAuth) { | ||||
localStorage.setItem('USER_X_TOKEN', JSON.stringify(xAuth)); | |||||
const jwtinfo = jwt.ecryptJWT(userToken); | |||||
sessionStorage.setItem(`USER_X_TOKEN-${jwtinfo.UserId}`, JSON.stringify(xAuth)); | |||||
sessionStorage.setItem(`USER_X_TOKEN`, JSON.stringify(xAuth)); | |||||
} | } | ||||
return response; | return response; | ||||
}, | }, | ||||