Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴婷
jinfa-platform
Commits
c67c0d56
Commit
c67c0d56
authored
Sep 29, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改路由
parent
9d9639da
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
20 deletions
+38
-20
tranactionRoute.ts
config/routes/tranactionRoute.ts
+0
-1
app.tsx
src/app.tsx
+2
-1
BasicLayout.tsx
src/layouts/BasicLayout.tsx
+11
-17
useGlobal.ts
src/models/useGlobal.ts
+21
-0
request.ts
src/utils/request.ts
+4
-1
No files found.
config/routes/tranactionRoute.ts
View file @
c67c0d56
...
...
@@ -283,7 +283,6 @@ const TranactionRoute = {
{
path
:
'/memberCenter/tranactionAbility/purchaseOrder'
,
name
:
'purchaseOrder'
,
key
:
'purchaseOrder'
,
routes
:
[
{
path
:
'/memberCenter/tranactionAbility/purchaseOrder/orderList'
,
...
...
src/app.tsx
View file @
c67c0d56
...
...
@@ -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
>
}
/**
...
...
src/layouts/BasicLayout.tsx
View file @
c67c0d56
...
...
@@ -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'
}
}
...
...
src/models/useGlobal.ts
0 → 100644
View file @
c67c0d56
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
src/utils/request.ts
View file @
c67c0d56
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment