Browse Source

统一提示

release_0.0.2
yuan_yi 3 years ago
parent
commit
7801359f73
  1. BIN
      code/VideoAccess-VCMP/web/client/assets/images/logo/figure.png
  2. 208
      code/VideoAccess-VCMP/web/client/src/layout/containers/layout/index.jsx

BIN
code/VideoAccess-VCMP/web/client/assets/images/logo/figure.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 KiB

208
code/VideoAccess-VCMP/web/client/src/layout/containers/layout/index.jsx

@ -2,7 +2,7 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Layout, Toast } from '@douyinfe/semi-ui'; import { Layout, Notification } from '@douyinfe/semi-ui';
import Sider from '../../components/sider'; import Sider from '../../components/sider';
import Header from '../../components/header'; import Header from '../../components/header';
import Footer from '../../components/footer'; import Footer from '../../components/footer';
@ -11,7 +11,7 @@ import * as NProgress from 'nprogress';
import PerfectScrollbar from 'perfect-scrollbar'; import PerfectScrollbar from 'perfect-scrollbar';
NProgress.configure({ NProgress.configure({
template: ` template: `
<div class="bar" style="height:2px" role="bar"> <div class="bar" style="height:2px" role="bar">
<div class="peg"></div> <div class="peg"></div>
</div> </div>
@ -24,113 +24,121 @@ NProgress.configure({
let scrollbar let scrollbar
const LayoutContainer = props => { const LayoutContainer = props => {
const { const {
dispatch, msg, user, copyright, children, sections, clientWidth, clientHeight, dispatch, msg, user, copyright, children, sections, clientWidth, clientHeight,
location, match, routes, history location, match, routes, history
} = props } = props
const [collapsed, setCollapsed] = useState(false) const [collapsed, setCollapsed] = useState(false)
NProgress.start(); NProgress.start();
const resize_ = () => { const resize_ = () => {
dispatch(resize( dispatch(resize(
document.body.clientHeight, document.body.clientHeight,
document.body.clientWidth - (collapsed ? 120 : 240) document.body.clientWidth - (collapsed ? 120 : 240)
)); ));
} }
useEffect(() => { useEffect(() => {
scrollbar = new PerfectScrollbar('#page-content', { suppressScrollX: true }); scrollbar = new PerfectScrollbar('#page-content', { suppressScrollX: true });
window.addEventListener('resize', resize_); window.addEventListener('resize', resize_);
return () => { return () => {
window.removeEventListener('resize', resize_); window.removeEventListener('resize', resize_);
} }
}, []) }, [])
useEffect(() => { useEffect(() => {
NProgress.done(); NProgress.done();
if (!user || !user.authorized) { if (!user || !user.authorized) {
history.push('/signin'); history.push('/signin');
} }
if (msg) { if (msg) {
if (msg.done) { if (msg.done) {
Toast.success(msg.done); Notification.success({
} // title: msg.done,
if (msg.error) { content: msg.done,
Toast.error(msg.error); duration: 2,
} })
} }
const dom = document.getElementById('page-content'); if (msg.error) {
if (dom) { Notification.error({
scrollbar.update(); // title: msg.error,
dom.scrollTop = 0; content: msg.error,
} duration: 2,
}) })
}
}
const dom = document.getElementById('page-content');
if (dom) {
scrollbar.update();
dom.scrollTop = 0;
}
})
return ( return (
<Layout id="layout"> <Layout id="layout">
<Layout.Header> <Layout.Header>
<Header <Header
user={user} user={user}
pathname={location.pathname} pathname={location.pathname}
toggleCollapsed={() => { toggleCollapsed={() => {
setCollapsed(!collapsed); setCollapsed(!collapsed);
}} }}
collapsed={collapsed} collapsed={collapsed}
history={history} history={history}
/> />
</Layout.Header> </Layout.Header>
<Layout> <Layout>
<Layout.Sider> <Layout.Sider>
<Sider <Sider
sections={sections} sections={sections}
dispatch={dispatch} dispatch={dispatch}
user={user} user={user}
pathname={location.pathname} pathname={location.pathname}
collapsed={collapsed} collapsed={collapsed}
/> />
</Layout.Sider> </Layout.Sider>
<Layout.Content> <Layout.Content>
<div style={{ <div style={{
margin: '12px 12px 0px', margin: '12px 12px 0px',
background: "#F6FAFF", background: "#F6FAFF",
}}> }}>
<div id="page-content" style={{ <div id="page-content" style={{
height: clientHeight - 12, height: clientHeight - 12,
minWidth: 520, minWidth: 520,
position: 'relative', position: 'relative',
}}> }}>
<div style={{ <div style={{
minHeight: clientHeight - 32 - 12, minHeight: clientHeight - 32 - 12,
position: 'relative', position: 'relative',
padding: '12px 8px', padding: '12px 8px',
}}> }}>
{children} {children}
</div> </div>
<Layout.Footer> <Layout.Footer>
<Footer /> <Footer />
</Layout.Footer> </Layout.Footer>
</div> </div>
</div> </div>
</Layout.Content> </Layout.Content>
</Layout> </Layout>
</Layout > </Layout >
) )
} }
function mapStateToProps (state) { function mapStateToProps (state) {
const { global, auth, ajaxResponse } = state; const { global, auth, ajaxResponse } = state;
return { return {
title: global.title, title: global.title,
copyright: global.copyright, copyright: global.copyright,
sections: global.sections, sections: global.sections,
actions: global.actions, actions: global.actions,
clientWidth: global.clientWidth, clientWidth: global.clientWidth,
clientHeight: global.clientHeight, clientHeight: global.clientHeight,
msg: ajaxResponse.msg, msg: ajaxResponse.msg,
user: auth.user user: auth.user
}; };
} }
export default connect(mapStateToProps)(LayoutContainer); export default connect(mapStateToProps)(LayoutContainer);
Loading…
Cancel
Save