Browse Source

socket

release_0.0.2
wenlele 2 years ago
parent
commit
f69525056b
  1. 2
      code/VideoAccess-VCMP/web/client/src/app.jsx
  2. 21
      code/VideoAccess-VCMP/web/client/src/layout/containers/layout/index.jsx
  3. 4
      code/VideoAccess-VCMP/web/client/src/layout/index.jsx
  4. 1
      code/VideoAccess-VCMP/web/client/src/sections/example/containers/example.jsx

2
code/VideoAccess-VCMP/web/client/src/app.jsx

@ -25,7 +25,7 @@ const App = props => {
return (
<Layout
title={projectName}
sections={[
sections={[Example,
Auth, Monitor, EquipmentWarehouse, AiAbility, offline,
openness, journaling, archive, application, member, system
]}

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

@ -26,7 +26,7 @@ let scrollbar
const LayoutContainer = props => {
const {
dispatch, msg, user, copyright, children, sections, clientWidth, clientHeight,
location, match, routes, history, authCrossLoading
location, match, routes, history, authCrossLoading,socket
} = props
const [collapsed, setCollapsed] = useState(false)
@ -79,6 +79,20 @@ const LayoutContainer = props => {
}
})
// websocket 使
useEffect(() => {
console.log(socket)
if (socket) {
socket.on('CAMERA_ONLINE', function (msg) {
console.info(msg);
});
return () => {
socket.off("CAMERA_ONLINE");
}
}
}, [socket])
return (
<Layout id="layout">
{
@ -149,7 +163,7 @@ const LayoutContainer = props => {
}
function mapStateToProps (state) {
const { global, auth, ajaxResponse } = state;
const { global, auth, ajaxResponse , webSocket} = state;
return {
title: global.title,
copyright: global.copyright,
@ -158,7 +172,8 @@ function mapStateToProps (state) {
clientWidth: global.clientWidth,
clientHeight: global.clientHeight,
msg: ajaxResponse.msg,
user: auth.user
user: auth.user,
socket: webSocket.socket
};
}

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

@ -84,6 +84,10 @@ const Root = props => {
}
}
useEffect(async () => {
let innerRoutes = []
let outerRoutes = []

1
code/VideoAccess-VCMP/web/client/src/sections/example/containers/example.jsx

@ -6,6 +6,7 @@ const { Meta } = Card;
const Example = (props) => {
const { dispatch, actions, user, loading, socket } = props
console.log(props)
useEffect(() => {
// ACTION

Loading…
Cancel
Save