Browse Source

sider选中、展示字段调整

master
zmh 2 years ago
parent
commit
294a28ba07
  1. 14
      web/client/src/layout/components/sider/index.js
  2. 2
      web/client/src/layout/containers/layout/index.js
  3. 8
      web/client/src/sections/auth/actions/auth.js
  4. 4
      web/client/src/sections/auth/containers/login.js

14
web/client/src/layout/components/sider/index.js

@ -12,7 +12,7 @@ const Sider = (props) => {
useEffect(() => { useEffect(() => {
let jumpurlObj = JumpUrls.find(s => s.url == pathname && selectedKeys != s.keys) let jumpurlObj = JumpUrls.find(s => s.url == pathname && selectedKeys != s.keys)
if (jumpurlObj) { if (jumpurlObj) {
localStorage.setItem('zhongding_selected_sider', JSON.stringify([jumpurlObj.keys])) localStorage.setItem('governmentDataResourceCenter_selected_sider', JSON.stringify([jumpurlObj.keys]))
setSelectedKeys(jumpurlObj.keys) setSelectedKeys(jumpurlObj.keys)
} }
}, [pathname]) }, [pathname])
@ -36,11 +36,11 @@ const Sider = (props) => {
let selectedKeys = [] let selectedKeys = []
let openKeys = [] let openKeys = []
const lastSelectedKeys = localStorage.getItem('zhongding_selected_sider') const lastSelectedKeys = localStorage.getItem('governmentDataResourceCenter_selected_sider')
if (lastSelectedKeys) { if (lastSelectedKeys) {
selectedKeys = JSON.parse(lastSelectedKeys) selectedKeys = JSON.parse(lastSelectedKeys)
} }
const lastOpenKeys = localStorage.getItem('zhongding_open_sider') const lastOpenKeys = localStorage.getItem('governmentDataResourceCenter_open_sider')
if (lastOpenKeys) { if (lastOpenKeys) {
openKeys = JSON.parse(lastOpenKeys) openKeys = JSON.parse(lastOpenKeys)
} }
@ -60,9 +60,9 @@ const Sider = (props) => {
} }
} }
} }
localStorage.setItem('zhongding_selected_sider', JSON.stringify(selectedKeys)) localStorage.setItem('governmentDataResourceCenter_selected_sider', JSON.stringify(selectedKeys))
setSelectedKeys(selectedKeys) setSelectedKeys(selectedKeys)
localStorage.setItem('zhongding_open_sider', JSON.stringify(openKeys)) localStorage.setItem('governmentDataResourceCenter_open_sider', JSON.stringify(openKeys))
setOpenKeys(openKeys) setOpenKeys(openKeys)
}, []) }, [])
@ -75,11 +75,11 @@ const Sider = (props) => {
onSelect={(e) => { onSelect={(e) => {
const { selectedKeys } = e; const { selectedKeys } = e;
setSelectedKeys(selectedKeys) setSelectedKeys(selectedKeys)
localStorage.setItem('zhongding_selected_sider', JSON.stringify(selectedKeys)) localStorage.setItem('governmentDataResourceCenter_selected_sider', JSON.stringify(selectedKeys))
}} }}
onOpenChange={(openKeys) => { onOpenChange={(openKeys) => {
setOpenKeys(openKeys) setOpenKeys(openKeys)
localStorage.setItem('zhongding_open_sider', JSON.stringify(openKeys)) localStorage.setItem('governmentDataResourceCenter_open_sider', JSON.stringify(openKeys))
}} }}
> >
{items} {items}

2
web/client/src/layout/containers/layout/index.js

@ -102,7 +102,7 @@ const LayoutContainer = props => {
<div style={{ padding: '0px 16px 4px', borderBottom: '1px solid #e8e8e8' }}> <div style={{ padding: '0px 16px 4px', borderBottom: '1px solid #e8e8e8' }}>
<Breadcrumbs routes={routes} /> <Breadcrumbs routes={routes} />
</div> </div>
<div style={{ paddingTop: 12 }}> <div style={{ padding: '12px 12px 0px 12px' }}>
{children} {children}
</div> </div>
</div> </div>

8
web/client/src/sections/auth/actions/auth.js

@ -4,7 +4,7 @@ import { ApiTable } from '$utils'
import { Request } from '@peace/utils' import { Request } from '@peace/utils'
export const INIT_AUTH = 'INIT_AUTH'; export const INIT_AUTH = 'INIT_AUTH';
export function initAuth () { export function initAuth() {
const user = JSON.parse(sessionStorage.getItem('user')) || {}; const user = JSON.parse(sessionStorage.getItem('user')) || {};
return { return {
type: INIT_AUTH, type: INIT_AUTH,
@ -17,7 +17,7 @@ export function initAuth () {
export const REQUEST_LOGIN = 'REQUEST_LOGIN'; export const REQUEST_LOGIN = 'REQUEST_LOGIN';
export const LOGIN_SUCCESS = 'LOGIN_SUCCESS'; export const LOGIN_SUCCESS = 'LOGIN_SUCCESS';
export const LOGIN_ERROR = 'LOGIN_ERROR'; export const LOGIN_ERROR = 'LOGIN_ERROR';
export function login ({ username, password, phone, code }) { export function login({ username, password, phone, code }) {
return dispatch => { return dispatch => {
dispatch({ type: REQUEST_LOGIN }); dispatch({ type: REQUEST_LOGIN });
@ -41,10 +41,12 @@ export function login ({ username, password, phone, code }) {
} }
export const LOGOUT = 'LOGOUT'; export const LOGOUT = 'LOGOUT';
export function logout (user) { export function logout(user) {
const token = user.token; const token = user.token;
const url = ApiTable.logout; const url = ApiTable.logout;
sessionStorage.removeItem('user'); sessionStorage.removeItem('user');
localStorage.removeItem('governmentDataResourceCenter_selected_sider')
localStorage.removeItem('governmentDataResourceCenter_open_sider')
Request.put(url, { Request.put(url, {
token: token token: token
}); });

4
web/client/src/sections/auth/containers/login.js

@ -28,7 +28,9 @@ const Login = props => {
const codCountDownRef = useRef(0) const codCountDownRef = useRef(0)
useEffect(() => { useEffect(() => {
sessionStorage.removeItem('user');
localStorage.removeItem('governmentDataResourceCenter_selected_sider')
localStorage.removeItem('governmentDataResourceCenter_open_sider')
}, []) }, [])

Loading…
Cancel
Save