From d59f518f466274b2caeb2e01c10c92deafe7c93b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 09 二月 2022 11:48:29 +0800 Subject: [PATCH] 2022-02-09 --- src/components/header/index.jsx | 78 +++++++++++++++++++++++---------------- 1 files changed, 46 insertions(+), 32 deletions(-) diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index 0c8f549..dca77b8 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -4,7 +4,8 @@ import {connect} from 'react-redux' import { is, fromJS } from 'immutable' import moment from 'moment' -import { Dropdown, Menu, Icon, Modal, Form, notification, Switch, Input } from 'antd' +import { Dropdown, Menu, Modal, Form, notification, Switch, Input } from 'antd' +import { SearchOutlined, DownOutlined, MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons' import { toggleCollapse, @@ -13,6 +14,7 @@ initMenuPermission, logout } from '@/store/action' +import asyncComponent from '@/utils/asyncComponent' import Api from '@/api' import MKEmitter from '@/utils/events.js' import options from '@/store/options.js' @@ -20,12 +22,12 @@ import enUS from '@/locales/en-US/main.js' import Utils from '@/utils/utils.js' import avatar from '@/assets/img/avatar.jpg' -import Resetpwd from './resetpwd' -import LoginForm from './loginform' import './index.scss' const { confirm } = Modal const { Search } = Input +const Resetpwd = asyncComponent(() => import('./resetpwd')) +const LoginForm = asyncComponent(() => import('./loginform')) class Header extends Component { static propTpyes = { @@ -87,9 +89,14 @@ if (result.status) { notification.success({ top: 92, - message: this.state.dict['main.password.resetsuccess'], + message: '淇敼鎴愬姛锛岃閲嶆柊鐧诲綍銆�', duration: 2 }) + setTimeout(() => { + sessionStorage.clear() + this.props.logout() + this.props.history.replace('/login') + }, 2000) } else { notification.warning({ top: 92, @@ -136,31 +143,33 @@ // 鑾峰彇瑙掕壊鏉冮檺 let roledefer = new Promise(resolve => { // edition_type 鎺ュ彛鐗堟湰鎺у埗 ''銆�'Y'銆�'A' - Api.getSystemConfig({ - func: 's_Get_TrdMenu_Role', - edition_type: 'A', - pro_sys: window.GLOB.systemType === 'production' ? 'Y' : '' - }).then(result => { - let _permAction = {loaded: true} // 鎸夐挳鏉冮檺 - - if (result && result.status) { - if (result.UserRoles_Menu) { - result.UserRoles_Menu.forEach(menu => { - if (!menu.MenuID) return - _permAction[menu.MenuID] = true + setTimeout(() => { + Api.getSystemConfig({ + func: 's_Get_TrdMenu_Role', + edition_type: 'A', + pro_sys: window.GLOB.systemType === 'production' ? 'Y' : '' + }).then(result => { + let _permAction = {loaded: true} // 鎸夐挳鏉冮檺 + + if (result && result.status) { + if (result.UserRoles_Menu) { + result.UserRoles_Menu.forEach(menu => { + if (!menu.MenuID) return + _permAction[menu.MenuID] = true + }) + } + } else if (result) { + notification.error({ + top: 92, + message: result.message, + duration: 10 }) } - } else if (result) { - notification.error({ - top: 92, - message: result.message, - duration: 10 - }) - } - - this.props.initActionPermission(_permAction) - resolve() - }) + + this.props.initActionPermission(_permAction) + resolve() + }) + }, 50) }) // 鑾峰彇涓昏彍鍗曞弬鏁� @@ -397,6 +406,12 @@ sessionStorage.setItem('role_id', res.role_id || '') sessionStorage.setItem('dataM', res.dataM ? 'true' : '') sessionStorage.setItem('isEditState', 'true') + + if (param.remember) { + let _url = window.location.href.split('#')[0] + 'cloud' + + localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify({time: new Date().getTime(), username: param.username, password: param.password})))) + } this.setSystemFuncs() this.props.modifyMainMenu(null) @@ -687,7 +702,7 @@ <header className="header-container ant-menu-dark" id="main-header-container"> <div className={'header-logo ' + (collapse && navBar !== 'topmenu' ? 'collapse' : '')}><img src={this.state.logourl} alt=""/></div> <div className={'header-collapse ' + (collapse && navBar !== 'topmenu' ? 'collapse' : '')}> - {navBar !== 'topmenu' ? <Icon type={collapse ? 'menu-unfold' : 'menu-fold'} onClick={this.handleCollapse}/> : null} + {navBar !== 'topmenu' ? (collapse ? <MenuUnfoldOutlined onClick={this.handleCollapse}/> : <MenuFoldOutlined onClick={this.handleCollapse}/>) : null} </div> {/* 姝e父鑿滃崟 */} {navBar !== 'topmenu' && menulist ? @@ -787,7 +802,7 @@ <div> <img src={this.state.avatar || avatar} alt=""/> <span> - <span className="username">{this.state.userName}</span> <Icon type="down" /> + <span className="username">{this.state.userName}</span> <DownOutlined /> </span> </div> </Dropdown> @@ -824,7 +839,7 @@ </div> </div> } trigger={['click']} className="search-menu" placement="bottomRight" onVisibleChange={this.dropdownMenuChange}> - <Icon className="search-menu" type="search" /> + <SearchOutlined className="search-menu" /> </Dropdown> : null } {/* 淇敼瀵嗙爜 */} @@ -858,8 +873,7 @@ const mapStateToProps = (state) => { return { collapse: state.collapse, - mainMenu: state.mainMenu, - permAction: state.permAction, + mainMenu: state.mainMenu } } -- Gitblit v1.8.0