|
@@ -3,7 +3,7 @@ import s from './index.less'
|
|
|
import { Layout, Menu, Icon, Avatar, Dropdown, ConfigProvider, Tooltip } from 'antd'
|
|
|
import zhCN from 'antd/es/locale/zh_CN'
|
|
|
import router from 'umi/router'
|
|
|
-import { connect } from 'dva';
|
|
|
+import { connect } from 'dva'
|
|
|
import logo from '@/assets/logo.jpg'
|
|
|
import { Link } from 'umi'
|
|
|
|
|
@@ -21,7 +21,7 @@ class MainLayout extends React.PureComponent {
|
|
|
defaultOpenKeys: this.getDefaultKeys()
|
|
|
}
|
|
|
|
|
|
- getDefaultKeys() {
|
|
|
+ getDefaultKeys () {
|
|
|
const { pathname } = window.location
|
|
|
const ps = pathname.split('/')
|
|
|
return [`/${ps[1]}`]
|
|
@@ -33,51 +33,63 @@ class MainLayout extends React.PureComponent {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- async componentDidMount() {
|
|
|
+ async componentDidMount () {
|
|
|
this.props.dispatch({
|
|
|
- type: 'user/fetchPower',
|
|
|
- });
|
|
|
+ type: 'user/fetchPower'
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
handleLogout = () => {
|
|
|
this.props.dispatch({
|
|
|
- type: 'user/logout',
|
|
|
- });
|
|
|
+ type: 'user/logout'
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
clearCache = () => {
|
|
|
- const { dispatch } = this.props;
|
|
|
+ const { dispatch } = this.props
|
|
|
if (dispatch) {
|
|
|
dispatch({
|
|
|
type: 'user/delColumnCache',
|
|
|
payload: {},
|
|
|
callback: () => {
|
|
|
- window.location.reload();
|
|
|
- },
|
|
|
- });
|
|
|
+ window.location.reload()
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
handleClick = (e) => {
|
|
|
+ if (/^http/.test(e.key)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
this.setState({ selectedKeys: [e.key] })
|
|
|
}
|
|
|
|
|
|
- getMenu(menuData) {
|
|
|
+ getMenu (menuData) {
|
|
|
return menuData.map(m => {
|
|
|
if (m.children && m.children.length) {
|
|
|
return <SubMenu key={m.url} title={m.name}>
|
|
|
{this.getMenu(m.children)}
|
|
|
</SubMenu>
|
|
|
} else {
|
|
|
+ if (/^http/.test(m.url)) {
|
|
|
+ return (
|
|
|
+ <Menu.Item key={m.url}>
|
|
|
+ <a href={m.url} rel="noopener noreferrer" target="_blank">
|
|
|
+ {m.name}
|
|
|
+ </a>
|
|
|
+ </Menu.Item>
|
|
|
+ )
|
|
|
+ }
|
|
|
return <Menu.Item key={m.url}><Link to={m.url}>{m.name}</Link></Menu.Item>
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- render() {
|
|
|
+ render () {
|
|
|
const { collapsed, selectedKeys, defaultOpenKeys } = this.state
|
|
|
- const { currentUser, user } = this.props;
|
|
|
-
|
|
|
+ const { currentUser, user } = this.props
|
|
|
+
|
|
|
const menu = (
|
|
|
<Menu>
|
|
|
<Menu.Item>
|