From ce47dbadcfe4db983452608518d0896bbce26fa9 Mon Sep 17 00:00:00 2001
From: yuan_yi <1650192445@qq.com>
Date: Wed, 1 Jun 2022 19:12:30 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84sider=E9=80=89=E6=8B=A9?=
=?UTF-8?q?=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/layout/components/sider/index.jsx | 105 +++++++-----
.../src/sections/auth/containers/login.jsx | 152 +++++++++---------
2 files changed, 138 insertions(+), 119 deletions(-)
diff --git a/code/VideoAccess-VCMP/web/client/src/layout/components/sider/index.jsx b/code/VideoAccess-VCMP/web/client/src/layout/components/sider/index.jsx
index fd1170a..3424b40 100644
--- a/code/VideoAccess-VCMP/web/client/src/layout/components/sider/index.jsx
+++ b/code/VideoAccess-VCMP/web/client/src/layout/components/sider/index.jsx
@@ -6,54 +6,71 @@ import { push } from 'react-router-redux';
let scrollbar = null
const Sider = props => {
- const { collapsed, clientHeight, dispatch } = props
- const [items, setItems] = useState([])
- const [selectedKeys, setSelectedKeys] = useState([])
- const [openKeys, setOpenKeys] = useState([])
-
- useEffect(() => {
- const { sections, dispatch, user } = props;
- let nextItems = []
- for (let c of sections) {
- if (typeof c.getNavItem == 'function') {
- let item = c.getNavItem(user, dispatch);
- if (item) {
- nextItems.push.apply(nextItems, item)
- }
+ const { collapsed, clientHeight, dispatch } = props
+ const [items, setItems] = useState([])
+ const [selectedKeys, setSelectedKeys] = useState([])
+ const [openKeys, setOpenKeys] = useState([])
+
+ useEffect(() => {
+ const { sections, dispatch, user } = props;
+ let nextItems = []
+ for (let c of sections) {
+ if (typeof c.getNavItem == 'function') {
+ let item = c.getNavItem(user, dispatch);
+ if (item) {
+ nextItems.push.apply(nextItems, item)
}
- }
- setItems(nextItems)
-
- scrollbar = new PerfectScrollbar('#page-slider', { suppressScrollX: true });
- }, [])
-
- useEffect(() => {
- if (scrollbar) {
- scrollbar.update();
- }
- })
-
- return (
-
-
- )
+ }
+ }
+ setItems(nextItems)
+
+ const lastSelectedKeys = localStorage.getItem('vcmp_selected_sider')
+ if (lastSelectedKeys) {
+ setSelectedKeys(JSON.parse(lastSelectedKeys))
+ }
+ const lastOpenKeys = localStorage.getItem('vcmp_open_sider')
+ if (lastOpenKeys) {
+ setOpenKeys(JSON.parse(lastOpenKeys))
+ }
+
+ scrollbar = new PerfectScrollbar('#page-slider', { suppressScrollX: true });
+ }, [])
+
+ useEffect(() => {
+ if (scrollbar) {
+ scrollbar.update();
+ }
+ })
+
+ return (
+
+
+ )
}
function mapStateToProps (state) {
- const { global } = state;
- return {
- clientHeight: global.clientHeight,
- };
+ const { global } = state;
+ return {
+ clientHeight: global.clientHeight,
+ };
}
export default connect(mapStateToProps)(Sider);
\ No newline at end of file
diff --git a/code/VideoAccess-VCMP/web/client/src/sections/auth/containers/login.jsx b/code/VideoAccess-VCMP/web/client/src/sections/auth/containers/login.jsx
index 67bafa6..43eb1f7 100644
--- a/code/VideoAccess-VCMP/web/client/src/sections/auth/containers/login.jsx
+++ b/code/VideoAccess-VCMP/web/client/src/sections/auth/containers/login.jsx
@@ -4,92 +4,94 @@ import { connect } from 'react-redux';
import { push } from 'react-router-redux';
import { Form, Button, Toast } from '@douyinfe/semi-ui';
import { login, LOGIN_SUCCESS } from '../actions/auth';
-import { IconLock,IconUser } from '@douyinfe/semi-icons';
+import { IconLock, IconUser } from '@douyinfe/semi-icons';
import '../style.less'
const Login = props => {
- const { dispatch, user, error, actions, apiRoot, isRequesting } = props
- const form = useRef();
+ const { dispatch, user, error, actions, apiRoot, isRequesting } = props
+ const form = useRef();
- useEffect(() => {
- if (error) {
- Toast.error(error);
- form.current.setValue('password', '')
- }
- }, [error])
+ useEffect(() => {
+ if (error) {
+ Toast.error(error);
+ form.current.setValue('password', '')
+ }
+ }, [error])
- useEffect(() => {
- if (user && user.authorized) {
- dispatch(push('/equipmentWarehouse/nvr'));
- }
- }, [user])
+ useEffect(() => {
+ if (user && user.authorized) {
+ dispatch(push('/equipmentWarehouse/nvr'));
+ localStorage.setItem('vcmp_selected_sider', JSON.stringify(['nvr']))
+ localStorage.setItem('vcmp_open_sider', JSON.stringify(['equipmentWarehouse']))
+ }
+ }, [user])
- return (
-
+
-
-
-
-
-
}
- style={{background:'rgba(24, 89, 193, 0.08)',height:40,marginTop:26}}
- />
- }
- style={{background:'rgba(24, 89, 193, 0.08)',height:40}}
- />
-
-
+ position: 'absolute',
+ top: '33.89%',
+ right: '16.43%',
+ }}>
+
+
-
- );
+
}
+ style={{ background: 'rgba(24, 89, 193, 0.08)', height: 40, marginTop: 26 }}
+ />
+
}
+ style={{ background: 'rgba(24, 89, 193, 0.08)', height: 40 }}
+ />
+
+
+
+
+ );
}
function mapStateToProps (state) {
- const { auth, global } = state;
- return {
- user: auth.user,
- error: auth.error,
- actions: global.actions,
- apiRoot: global.apiRoot,
- isRequesting: auth.isRequesting
- }
+ const { auth, global } = state;
+ return {
+ user: auth.user,
+ error: auth.error,
+ actions: global.actions,
+ apiRoot: global.apiRoot,
+ isRequesting: auth.isRequesting
+ }
}
export default connect(mapStateToProps)(Login);
\ No newline at end of file