Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
c1c36b61
Commit
c1c36b61
authored
May 31, 2018
by
jim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix menu click exception
parent
2c0e700f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
18 deletions
+27
-18
.webpackrc.js
.webpackrc.js
+2
-3
package.json
package.json
+6
-6
src/components/Sidebar/index.js
src/components/Sidebar/index.js
+1
-1
src/components/SiderMenu/SiderMenu.js
src/components/SiderMenu/SiderMenu.js
+18
-8
No files found.
.webpackrc.js
View file @
c1c36b61
...
...
@@ -2,9 +2,7 @@ const path = require('path');
export
default
{
entry
:
'
src/index.js
'
,
extraBabelPlugins
:
[
[
'
import
'
,
{
libraryName
:
'
antd
'
,
libraryDirectory
:
'
es
'
,
style
:
true
}],
],
extraBabelPlugins
:
[[
'
import
'
,
{
libraryName
:
'
antd
'
,
libraryDirectory
:
'
es
'
,
style
:
true
}]],
env
:
{
development
:
{
extraBabelPlugins
:
[
'
dva-hmr
'
],
...
...
@@ -19,5 +17,6 @@ export default {
template
:
'
./src/index.ejs
'
,
},
publicPath
:
'
/
'
,
disableDynamicImport
:
true
,
hash
:
true
,
};
package.json
View file @
c1c36b61
...
...
@@ -39,7 +39,7 @@
"
path-to-regexp
"
:
"
^2.1.0
"
,
"
prop-types
"
:
"
^15.5.10
"
,
"
qs
"
:
"
^6.5.0
"
,
"
rc-drawer-menu
"
:
"
^
0.5
.0
"
,
"
rc-drawer-menu
"
:
"
^
1.1
.0
"
,
"
react
"
:
"
^16.3.1
"
,
"
react-container-query
"
:
"
^0.11.0
"
,
"
react-document-title
"
:
"
^2.0.3
"
,
...
...
@@ -51,14 +51,14 @@
"devDependencies"
:
{
"
@types/react
"
:
"
^16.3.8
"
,
"
@types/react-dom
"
:
"
^16.0.5
"
,
"
antd-theme-webpack-plugin
"
:
"
^1.0.8
"
,
"
babel-eslint
"
:
"
^8.1.2
"
,
"
babel-plugin-dva-hmr
"
:
"
^0.4.1
"
,
"
babel-plugin-import
"
:
"
^1.6.7
"
,
"
babel-plugin-module-resolver
"
:
"
^3.1.1
"
,
"
cross-env
"
:
"
^5.1.1
"
,
"
antd-theme-webpack-plugin
"
:
"
^1.0.8
"
,
"
babel-plugin-transform-decorators-legacy
"
:
"
^1.3.4
"
,
"
babel-runtime
"
:
"
^6.9.2
"
,
"
cross-env
"
:
"
^5.1.1
"
,
"
cross-port-killer
"
:
"
^1.0.1
"
,
"
enzyme
"
:
"
^3.1.0
"
,
"
eslint
"
:
"
^4.14.0
"
,
...
...
@@ -74,13 +74,13 @@
"
husky
"
:
"
^0.14.3
"
,
"
lint-staged
"
:
"
^7.0.5
"
,
"
mockjs
"
:
"
^1.0.1-beta3
"
,
"
prettier
"
:
"
1.1
2.1
"
,
"
prettier
"
:
"
1.1
3.2
"
,
"
pro-download
"
:
"
^1.0.1
"
,
"
redbox-react
"
:
"
^1.5.0
"
,
"
regenerator-runtime
"
:
"
^0.11.1
"
,
"
roadhog
"
:
"
^2.4.1
"
,
"
roadhog
"
:
"
2.3.0
"
,
"
roadhog-api-doc
"
:
"
^1.0.3
"
,
"
stylelint
"
:
"
^
8.4.0
"
,
"
stylelint
"
:
"
^
9.2.1
"
,
"
stylelint-config-prettier
"
:
"
^3.0.4
"
,
"
stylelint-config-standard
"
:
"
^18.0.0
"
},
...
...
src/components/Sidebar/index.js
View file @
c1c36b61
...
...
@@ -136,7 +136,7 @@ class Sidebar extends PureComponent {
<
DrawerMenu
parent
=
{
null
}
level
=
{
null
}
icon
Child
=
{
null
}
handle
Child
=
{
null
}
open
=
{
collapse
}
placement
=
"
right
"
width
=
"
336px
"
...
...
src/components/SiderMenu/SiderMenu.js
View file @
c1c36b61
...
...
@@ -65,16 +65,22 @@ export const getMenuMatchKeys = (flatMenuKeys, paths) =>
);
export
default
class
SiderMenu
extends
PureComponent
{
static
getDerivedStateFromProps
(
nextProps
)
{
static
getDerivedStateFromProps
(
props
,
state
)
{
const
{
pathname
}
=
state
;
if
(
props
.
location
.
pathname
!==
pathname
)
{
return
{
openKeys
:
getDefaultCollapsedSubMenus
(
nextProps
),
pathname
:
props
.
location
.
pathname
,
openKeys
:
getDefaultCollapsedSubMenus
(
props
),
};
}
return
null
;
}
constructor
(
props
)
{
super
(
props
);
this
.
menus
=
props
.
menuData
;
this
.
flatMenuKeys
=
getFlatMenuKeys
(
props
.
menuData
);
this
.
state
=
{
pathname
:
props
.
location
.
pathname
,
openKeys
:
getDefaultCollapsedSubMenus
(
props
),
};
}
...
...
@@ -113,7 +119,7 @@ export default class SiderMenu extends PureComponent {
<
Link
to
=
{
itemPath
}
target
=
{
target
}
replace
=
{
itemPath
===
this
.
props
.
location
.
pathname
}
replace
=
{
itemPath
===
this
.
state
.
pathname
}
onClick
=
{
this
.
props
.
isMobile
?
()
=>
{
...
...
@@ -200,13 +206,17 @@ export default class SiderMenu extends PureComponent {
return
ItemDom
;
};
isMainMenu
=
key
=>
{
return
this
.
props
.
menuData
.
some
(
item
=>
key
&&
(
item
.
key
===
key
||
item
.
path
===
key
));
return
this
.
props
.
menuData
.
some
(
item
=>
{
if
(
key
)
{
return
item
.
key
===
key
||
item
.
path
===
key
;
}
return
false
;
});
};
handleOpenChange
=
openKeys
=>
{
const
lastOpenKey
=
openKeys
[
openKeys
.
length
-
1
];
const
moreThanOne
=
openKeys
.
filter
(
openKey
=>
this
.
isMainMenu
(
openKey
)).
length
>
1
;
this
.
setState
({
openKeys
:
moreThanOne
?
[
lastOpenKey
]
:
[...
openKeys
],
openKeys
:
moreThanOne
?
[
openKeys
.
pop
()
]
:
[...
openKeys
],
});
};
render
()
{
...
...
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