Commit c67c0d56 authored by 前端-许佳敏's avatar 前端-许佳敏

修改路由

parent 9d9639da
......@@ -283,7 +283,6 @@ const TranactionRoute = {
{
path: '/memberCenter/tranactionAbility/purchaseOrder',
name: 'purchaseOrder',
key: 'purchaseOrder',
routes: [
{
path: '/memberCenter/tranactionAbility/purchaseOrder/orderList',
......
......@@ -208,7 +208,8 @@ export function onRouteChange({ routes, matchedRoutes, location, action }) {
* @returns
*/
export function rootContainer(container: any) {
return React.createElement(MobxProvider, null, container);
// return React.createElement(MobxProvider, null, container);
return <MobxProvider>{container}</MobxProvider>
}
/**
......
......@@ -13,6 +13,7 @@ import RightContent from './components/RightContent';
import logo from '../../mockStatic/logo.png'
import MenuSlider from './components/MenuSlider'
import { getMatchMenu } from '@umijs/route-utils';
import { useGlobal } from '@/models/useGlobal';
export interface BasicLayoutProps extends ProLayoutProps {
breadcrumbNameMap: {
......@@ -51,7 +52,7 @@ export const getSelectedMenuKeys = (
const defaultFooterDom = (
<DefaultFooter
copyright={`${new Date().getFullYear()} 技术组体验出品`}
copyright={`瓴犀-${new Date().getFullYear()} 前端组体验出品`}
links={[]}
/>
);
......@@ -64,24 +65,14 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
settings,
location,
} = props;
const defaultSetting: Settings = {
navTheme: 'dark',
// 拂晓蓝
primaryColor: '#1890ff',
layout: 'topmenu',
contentWidth: 'Fluid',
fixedHeader: false,
fixSiderbar: true,
colorWeak: false,
menu: {
locale: true,
},
title: 'Ant Design Pro',
iconfontUrl: '',
};
const [openKeys, setOpenKeys] = useState<string[]>([])
const [collapsed, setCollapsed] = useState(false)
const [selectedKeys, setSelectedKeys] = useState<string[] | undefined>([]);
// 获取全局状态
const [globalState, globalDispatch] = useGlobal()
const handleMenuCollapse = (payload: boolean): void => {
setCollapsed(payload)
if (payload) {
......@@ -101,6 +92,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
const menuRouter = getMenuRouter(menuData, location.pathname)
// 当前路由信息, 可获取到config下的route配置
const currentRouter = basicInfo.breadcrumb[location.pathname];
useEffect(() => {
......@@ -116,8 +108,9 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
window.cancelAnimationFrame &&
window.cancelAnimationFrame(animationFrameId);
}, [location.pathname]);
useEffect(() => {
if (menuRouter && menuRouter.children) {
if (menuRouter && menuRouter.children && currentRouter) {
if (collapsed) {
setOpenKeys([])
} else {
......@@ -128,6 +121,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
setOpenKeys([])
}
}, [currentRouter, location.pathname, collapsed])
return (
<ProLayout
style={{ minHeight: '100vh' }}
......
import { useState, useReducer, useCallback } from 'react'
// 写入一些全局共享状态
export const useGlobal = () => {
const [GlobalState, dispatch] = useReducer((state, action) => {
switch (action.type) {
case 'SET_SELECT_KEY': {
return Object.assign({}, state, action.key)
}
default: return state
}
}, {menuSelectKey: ''})
return [
GlobalState,
dispatch
]
}
\ No newline at end of file
......@@ -41,10 +41,13 @@ const errorMessage: httpStatus = {
const errorHandler = (error: ResponseError): IRequestError => {
const { response } = error
// http状态码非200的错误处理
const messageText = response.status ? errorMessage[response.status] : ''
const messageText = response?.status ? errorMessage[response.status] : ''
if (response) {
message.destroy()
message.error('http请求错误: ' + response.status + '->' + messageText, 3)
} else {
// 请求超时, 会造成没有response
message.error('请求错误')
}
// throw可令响应promise走catch, 如需走resolve需直接return
throw {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment