From ac1e9887ae81f7dbabc14b78e10f711124a9e354 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Mon, 29 May 2023 14:10:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A1=94=E5=90=8A=E7=9A=84?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- console/client/assets/env.js | 2 +- .../src/sections/console/containers/index.js | 114 +++++++++--------- .../src/sections/console/containers/setUp.js | 76 ++++++++++-- console/package.json | 2 +- 4 files changed, 125 insertions(+), 69 deletions(-) diff --git a/console/client/assets/env.js b/console/client/assets/env.js index 48039f9..a7647fe 100644 --- a/console/client/assets/env.js +++ b/console/client/assets/env.js @@ -1 +1 @@ -window.FS_API_ROOT = 'http://10.8.30.183:4100' \ No newline at end of file +window.FS_API_ROOT = 'http://127.0.0.1:4100' \ No newline at end of file diff --git a/console/client/src/sections/console/containers/index.js b/console/client/src/sections/console/containers/index.js index efb92da..28810de 100644 --- a/console/client/src/sections/console/containers/index.js +++ b/console/client/src/sections/console/containers/index.js @@ -573,62 +573,66 @@ function Index (props) { if ( res.success ) { - setVideo(res.payload.data) - const container = document.getElementById('video-play'); - console.log(`准备播放`); - // 播放方式 1 - // const jessibuca = new window.Jessibuca({ - // container: container, - // videoBuffer: 0.2, // 缓存时长 - // isResize: false, - // text: "", - // loadingText: "加载中", - // debug: true, - // showBandwidth: false, // 显示网速 - // operateBtns: { - // fullscreen: false, - // screenshot: false, - // play: false, - // audio: false, - // }, - // forceNoOffscreen: false, - // controlAutoHide: true, - // isNotMute: false, - // }); - // jessibucas.current = jessibuca - // jessibuca.play( - // `${res.payload.data.ws_flv}` - // ); - - // 播放方式 2 - const flv = flvjs.createPlayer({ - type: 'flv', - url: `${res.payload.data.ws_flv}`, - isLive: true, - hasAudio: false, - hasVideo: true, - }, { - enableWorker: false, - enalleStashBuffer: true, - stashInitialSize: 128, - lazyLoadMaxDuration: 3 * 60, - seekType: 'range', - autoCleanupSourceBuffer: true, - cors: true, - }); - flv.attachMediaElement(container); - flv.load(); - - // 初始化 _remuxer - let controller = flv._transmuxer._controller - controller._remuxer = { - flushStashedSamples: function () { - console.log("flushStashedSamples") + try { + setVideo(res.payload.data) + const container = document.getElementById('video-play'); + console.log(`准备播放`); + // 播放方式 1 + // const jessibuca = new window.Jessibuca({ + // container: container, + // videoBuffer: 0.2, // 缓存时长 + // isResize: false, + // text: "", + // loadingText: "加载中", + // debug: true, + // showBandwidth: false, // 显示网速 + // operateBtns: { + // fullscreen: false, + // screenshot: false, + // play: false, + // audio: false, + // }, + // forceNoOffscreen: false, + // controlAutoHide: true, + // isNotMute: false, + // }); + // jessibucas.current = jessibuca + // jessibuca.play( + // `${res.payload.data.ws_flv}` + // ); + + // 播放方式 2 + const flv = flvjs.createPlayer({ + type: 'flv', + url: `${res.payload.data.ws_flv}`, + isLive: true, + hasAudio: false, + hasVideo: true, + }, { + enableWorker: false, + enalleStashBuffer: true, + stashInitialSize: 128, + lazyLoadMaxDuration: 3 * 60, + seekType: 'range', + autoCleanupSourceBuffer: true, + cors: true, + }); + flv.attachMediaElement(container); + flv.load(); + + // 初始化 _remuxer + let controller = flv?._transmuxer?._controller + controller._remuxer = { + flushStashedSamples: function () { + console.log("flushStashedSamples") + } } + + flv.play(); + flvPlayer.current = flv + } catch (error) { + console.error(error); } - - flv.play(); - flvPlayer.current = flv } }) @@ -819,7 +823,7 @@ function Index (props) { { s.dataFrom === 'live' ? ( - craneParams[s.v]?.Value || '-' + craneParams[s.v]?.Value || craneParams[s.v]?.Value == 0 ? craneParams[s.v]?.Value : '-' ) + ( craneParams[s.v] && s.unit ? s.unit : '' ) diff --git a/console/client/src/sections/console/containers/setUp.js b/console/client/src/sections/console/containers/setUp.js index daccdec..79731bd 100644 --- a/console/client/src/sections/console/containers/setUp.js +++ b/console/client/src/sections/console/containers/setUp.js @@ -2,14 +2,14 @@ import React, { useEffect, useState, useRef } from 'react' import { push } from 'react-router-redux'; import request from 'superagent'; import { connect } from 'react-redux'; -import { editCrane } from '../actions' +import { editCrane, getCrane } from '../actions' import { BorderlessTableOutlined, BlockOutlined, RollbackOutlined, SaveOutlined } from '@ant-design/icons'; -import { Col, Row, Button, Modal, Form, Input, InputNumber, message } from 'antd'; +import { Col, Row, Button, Modal, Form, Input, InputNumber, message, Switch } from 'antd'; import '../style.less' -function SetUp ({ dispatch }) { +function SetUp ({ dispatch, craneData }) { const [form] = Form.useForm(); const [renderMenu, setRenderMenu] = useState([]) const [renderForm, setRenderForm] = useState(false) @@ -24,7 +24,40 @@ function SetUp ({ dispatch }) { } }, { n: '限位告警参数', - ic: + ic: , + click: () => { + setRenderForm(true) + setFormIndex(1) + setFormItems([ + { + label: '设备编号', + name: 'device_no', + type: 'string', + disabled: true, + }, + { + label: '1级碰撞距离', + name: 'dis_level_1', + type: 'number', + }, + { + label: '3级碰撞距离', + name: 'dis_level_3', + type: 'number', + }, + { + label: '是否静音', + name: 'mute', + type: 'boolean', + }, + { + label: '2级碰撞距离', + name: 'dis_level_2', + type: 'number', + }, + ]) + initData() + } }, { n: '返回', ic: , @@ -48,6 +81,7 @@ function SetUp ({ dispatch }) { label: '设备编号', name: 'device_no', type: 'string', + disabled: true, }, { label: '经度', @@ -115,6 +149,7 @@ function SetUp ({ dispatch }) { type: 'number', }, ]) + initData() } }, { n: '返回', @@ -141,6 +176,19 @@ function SetUp ({ dispatch }) { ) } + const initData = () => { + console.log(craneData); + setTimeout(() => { + form.setFieldsValue({ + ...craneData + }) + }, 0) + } + + useEffect(() => { + initData() + }, [craneData]) + return (
{ @@ -162,7 +210,7 @@ function SetUp ({ dispatch }) { wrapperCol: { span: 18, }, - }} name="control-hooks" size='large'> + }} name="control-hooks" size='large' style={{ display: 'flex', flexDirection: 'column', height: '95%', justifyContent: 'space-between', }}> { (() => { @@ -183,8 +231,12 @@ function SetUp ({ dispatch }) { > { item.type === 'number' ? - : - + + : + item.type == 'boolean' ? + + : + } @@ -210,10 +262,11 @@ function SetUp ({ dispatch }) { ic: , click: () => { if (formIndex == 1) { - const values = form.getFieldsValue() - dispatch(editCrane(values)).then(res => { + let values = form.getFieldsValue() + dispatch(editCrane({ ...craneData, ...values })).then(res => { if (res.success) { message.success('修改配置信息成功') + dispatch(getCrane()) } else { message.error('修改配置信息失败') } @@ -238,15 +291,14 @@ function SetUp ({ dispatch }) {
-
) } function mapStateToProps (state) { - const { auth } = state; + const { crane } = state; return { - + craneData: crane.data || {} } } diff --git a/console/package.json b/console/package.json index 73ee51e..8f7f86d 100644 --- a/console/package.json +++ b/console/package.json @@ -8,7 +8,7 @@ "test": "mocha", "start-elctr-forge": "electron-forge start", "start": "cross-env NODE_ENV=development npm run start-params", - "start-params": "node server -p 5400 -u http://10.8.30.183:4100", + "start-params": "node server -p 5400 -u http://127.0.0.1:4100", "deploy": "export NODE_ENV=production && npm run build && node server", "build-dev": "set NODE_ENV=development&&webpack --config webpack.config.js", "build": "set NODE_ENV=production&&webpack --config webpack.config.prod.js",