代码提交

This commit is contained in:
lixiaobang 2023-02-14 17:34:38 +08:00
parent 289844c46f
commit a91b9ad5ae
18 changed files with 9799 additions and 1303 deletions

View File

@ -7,23 +7,34 @@
"build": "vue-cli-service build"
},
"dependencies": {
"@ffmpeg-installer/ffmpeg": "^1.1.0",
"axios": "^1.1.3",
"core-js": "^2.6.5",
"echarts": "^5.4.0",
"element-ui": "^2.15.10",
"express": "^4.18.2",
"express-ws": "^5.0.2",
"fluent-ffmpeg": "^2.1.2",
"jsmpeg": "^1.0.0",
"less": "^4.1.3",
"less-loader": "^5.0.0",
"moment": "^2.29.4",
"rtsp2web": "^2.2.0",
"v-fit-columns": "^0.2.0",
"vue": "^2.6.10",
"vue-jsmpeg-player": "^1.1.0-beta",
"vue-router": "^3.0.3",
"vue-video-player": "^5.0.2",
"vuex": "^3.0.1"
"vuex": "^3.0.1",
"websocket-stream": "^5.5.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.0.4",
"@vue/cli-service": "^3.0.4",
"vue-template-compiler": "^2.6.10"
"express": "^4.18.2",
"express-ws": "^5.0.2",
"vue-template-compiler": "^2.6.10",
"websocket-stream": "^5.5.2"
},
"postcss": {
"plugins": {

View File

@ -4,6 +4,9 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<script type="text/javascript" src="../stactic/webrtcstreamer.js"></script>
<script type="text/javascript" src="../stactic/adapter.min.js"></script>
<script src="https://jsmpeg.com/jsmpeg.min.js" charset="utf-8"></script>
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>yanduscreen</title>
</head>

1006
public/json/data.json Normal file

File diff suppressed because it is too large Load Diff

3514
public/stactic/adapter.min.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,305 @@
var WebRtcStreamer = (function() {
/**
* Interface with WebRTC-streamer API
* @constructor
* @param {string} videoElement - id of the video element tag
* @param {string} srvurl - url of webrtc-streamer (default is current location)
*/
var WebRtcStreamer = function WebRtcStreamer (videoElement, srvurl) {
if (typeof videoElement === "string") {
this.videoElement = document.getElementById(videoElement);
} else {
this.videoElement = videoElement;
}
this.srvurl = srvurl || location.protocol+"//"+window.location.hostname+":"+window.location.port;
this.pc = null;
this.mediaConstraints = { offerToReceiveAudio: true, offerToReceiveVideo: true };
this.iceServers = null;
this.earlyCandidates = [];
}
WebRtcStreamer.prototype._handleHttpErrors = function (response) {
if (!response.ok) {
throw Error(response.statusText);
}
return response;
}
/**
* Connect a WebRTC Stream to videoElement
* @param {string} videourl - id of WebRTC video stream
* @param {string} audiourl - id of WebRTC audio stream
* @param {string} options - options of WebRTC call
* @param {string} stream - local stream to send
*/
WebRtcStreamer.prototype.connect = function(videourl, audiourl, options, localstream) {
this.disconnect();
// getIceServers is not already received
if (!this.iceServers) {
console.log("Get IceServers");
fetch(this.srvurl + "/api/getIceServers")
.then(this._handleHttpErrors)
.then( (response) => (response.json()) )
.then( (response) => this.onReceiveGetIceServers(response, videourl, audiourl, options, localstream))
.catch( (error) => this.onError("getIceServers " + error ))
} else {
this.onReceiveGetIceServers(this.iceServers, videourl, audiourl, options, localstream);
}
}
/**
* Disconnect a WebRTC Stream and clear videoElement source
*/
WebRtcStreamer.prototype.disconnect = function() {
if (this.videoElement?.srcObject) {
this.videoElement.srcObject.getTracks().forEach(track => {
track.stop()
this.videoElement.srcObject.removeTrack(track);
});
}
if (this.pc) {
fetch(this.srvurl + "/api/hangup?peerid=" + this.pc.peerid)
.then(this._handleHttpErrors)
.catch( (error) => this.onError("hangup " + error ))
try {
this.pc.close();
}
catch (e) {
console.log ("Failure close peer connection:" + e);
}
this.pc = null;
}
}
/*
* GetIceServers callback
*/
WebRtcStreamer.prototype.onReceiveGetIceServers = function(iceServers, videourl, audiourl, options, stream) {
this.iceServers = iceServers;
this.pcConfig = iceServers || {"iceServers": [] };
try {
this.createPeerConnection();
var callurl = this.srvurl + "/api/call?peerid=" + this.pc.peerid + "&url=" + encodeURIComponent(videourl);
if (audiourl) {
callurl += "&audiourl="+encodeURIComponent(audiourl);
}
if (options) {
callurl += "&options="+encodeURIComponent(options);
}
if (stream) {
this.pc.addStream(stream);
}
// clear early candidates
this.earlyCandidates.length = 0;
// create Offer
this.pc.createOffer(this.mediaConstraints).then((sessionDescription) => {
console.log("Create offer:" + JSON.stringify(sessionDescription));
this.pc.setLocalDescription(sessionDescription)
.then(() => {
fetch(callurl, { method: "POST", body: JSON.stringify(sessionDescription) })
.then(this._handleHttpErrors)
.then( (response) => (response.json()) )
.catch( (error) => this.onError("call " + error ))
.then( (response) => this.onReceiveCall(response) )
.catch( (error) => this.onError("call " + error ))
}, (error) => {
console.log ("setLocalDescription error:" + JSON.stringify(error));
});
}, (error) => {
alert("Create offer error:" + JSON.stringify(error));
});
} catch (e) {
this.disconnect();
alert("connect error: " + e);
}
}
WebRtcStreamer.prototype.getIceCandidate = function() {
fetch(this.srvurl + "/api/getIceCandidate?peerid=" + this.pc.peerid)
.then(this._handleHttpErrors)
.then( (response) => (response.json()) )
.then( (response) => this.onReceiveCandidate(response))
.catch( (error) => this.onError("getIceCandidate " + error ))
}
/*
* create RTCPeerConnection
*/
WebRtcStreamer.prototype.createPeerConnection = function() {
console.log("createPeerConnection config: " + JSON.stringify(this.pcConfig));
this.pc = new RTCPeerConnection(this.pcConfig);
var pc = this.pc;
pc.peerid = Math.random();
pc.onicecandidate = (evt) => this.onIceCandidate(evt);
pc.onaddstream = (evt) => this.onAddStream(evt);
pc.oniceconnectionstatechange = (evt) => {
console.log("oniceconnectionstatechange state: " + pc.iceConnectionState);
if (this.videoElement) {
if (pc.iceConnectionState === "connected") {
this.videoElement.style.opacity = "1.0";
}
else if (pc.iceConnectionState === "disconnected") {
this.videoElement.style.opacity = "0.25";
}
else if ( (pc.iceConnectionState === "failed") || (pc.iceConnectionState === "closed") ) {
this.videoElement.style.opacity = "0.5";
} else if (pc.iceConnectionState === "new") {
this.getIceCandidate();
}
}
}
pc.ondatachannel = function(evt) {
console.log("remote datachannel created:"+JSON.stringify(evt));
evt.channel.onopen = function () {
console.log("remote datachannel open");
this.send("remote channel openned");
}
evt.channel.onmessage = function (event) {
console.log("remote datachannel recv:"+JSON.stringify(event.data));
}
}
pc.onicegatheringstatechange = function() {
if (pc.iceGatheringState === "complete") {
const recvs = pc.getReceivers();
recvs.forEach((recv) => {
if (recv.track && recv.track.kind === "video") {
console.log("codecs:" + JSON.stringify(recv.getParameters().codecs))
}
});
}
}
try {
var dataChannel = pc.createDataChannel("ClientDataChannel");
dataChannel.onopen = function() {
console.log("local datachannel open");
this.send("local channel openned");
}
dataChannel.onmessage = function(evt) {
console.log("local datachannel recv:"+JSON.stringify(evt.data));
}
} catch (e) {
console.log("Cannor create datachannel error: " + e);
}
console.log("Created RTCPeerConnnection with config: " + JSON.stringify(this.pcConfig) );
return pc;
}
/*
* RTCPeerConnection IceCandidate callback
*/
WebRtcStreamer.prototype.onIceCandidate = function (event) {
if (event.candidate) {
if (this.pc.currentRemoteDescription) {
this.addIceCandidate(this.pc.peerid, event.candidate);
} else {
this.earlyCandidates.push(event.candidate);
}
}
else {
console.log("End of candidates.");
}
}
WebRtcStreamer.prototype.addIceCandidate = function(peerid, candidate) {
fetch(this.srvurl + "/api/addIceCandidate?peerid="+peerid, { method: "POST", body: JSON.stringify(candidate) })
.then(this._handleHttpErrors)
.then( (response) => (response.json()) )
.then( (response) => {console.log("addIceCandidate ok:" + response)})
.catch( (error) => this.onError("addIceCandidate " + error ))
}
/*
* RTCPeerConnection AddTrack callback
*/
WebRtcStreamer.prototype.onAddStream = function(event) {
console.log("Remote track added:" + JSON.stringify(event));
this.videoElement.srcObject = event.stream;
var promise = this.videoElement.play();
if (promise !== undefined) {
promise.catch((error) => {
console.warn("error:"+error);
this.videoElement.setAttribute("controls", true);
});
}
}
/*
* AJAX /call callback
*/
WebRtcStreamer.prototype.onReceiveCall = function(dataJson) {
console.log("offer: " + JSON.stringify(dataJson));
var descr = new RTCSessionDescription(dataJson);
this.pc.setRemoteDescription(descr).then(() => {
console.log ("setRemoteDescription ok");
while (this.earlyCandidates.length) {
var candidate = this.earlyCandidates.shift();
this.addIceCandidate(this.pc.peerid, candidate);
}
this.getIceCandidate()
}
, (error) => {
console.log ("setRemoteDescription error:" + JSON.stringify(error));
});
}
/*
* AJAX /getIceCandidate callback
*/
WebRtcStreamer.prototype.onReceiveCandidate = function(dataJson) {
console.log("candidate: " + JSON.stringify(dataJson));
if (dataJson) {
for (var i=0; i<dataJson.length; i++) {
var candidate = new RTCIceCandidate(dataJson[i]);
console.log("Adding ICE candidate :" + JSON.stringify(candidate) );
this.pc.addIceCandidate(candidate).then( () => { console.log ("addIceCandidate OK"); }
, (error) => { console.log ("addIceCandidate error:" + JSON.stringify(error)); } );
}
this.pc.addIceCandidate();
}
}
/*
* AJAX callback for Error
*/
WebRtcStreamer.prototype.onError = function(status) {
console.log("onError:" + status);
}
return WebRtcStreamer;
})();
if (typeof window !== 'undefined' && typeof window.document !== 'undefined') {
window.WebRtcStreamer = WebRtcStreamer;
}
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = WebRtcStreamer;
}

View File

@ -1,8 +1,8 @@
body { padding: 0; margin: 0 }
#unity-container { position: absolute }
#unity-container.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%) }
#unity-container.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%);height: 100%; width: 100%; overflow: hidden;}
#unity-container.unity-mobile { width: 100%; height: 100% }
#unity-canvas { background: #231F20 }
#unity-canvas { background: #231F20;width: 100% !important; height: 100% !important;cursor: default; }
.unity-mobile #unity-canvas { width: 100%; height: 100% }
#unity-loading-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none }
#unity-logo { width: 154px; height: 130px; background: url('unity-logo-dark.png') no-repeat center }

6
serve/index.js Normal file
View File

@ -0,0 +1,6 @@
const RTSP2web = require('rtsp2web')
//服务端的端口号,端口号可以自定义
const port = 9999
new RTSP2web({
port
})

1
serve/jiaoben.bat Normal file
View File

@ -0,0 +1 @@
node index.js

View File

@ -32,7 +32,7 @@
<script>
import MinxinItem from "./mixins"
import axios from 'axios'
import {getWather,Weather} from "./api/index.js";
import {getWather,Weather,getToken} from "./api/index.js";
export default {
name: 'home',
mixins:[MinxinItem],
@ -55,6 +55,17 @@ export default {
this.handleWather()
let week = new Date(this.$moment().format("YYYY-MM-DD")).getDay()
this.week = this.weekList[week]
// let params = new URLSearchParams()
let params = {
appKey:'symnzwxdfu1ul8raqrykgbld7zonktga',
appSecret:'a3tdb6nxfciekxcgcl94ljvtmw2lsafx'
}
// params.append('appKey','symnzwxdfu1ul8raqrykgbld7zonktga')
// params.append('appSecret','a3tdb6nxfciekxcgcl94ljvtmw2lsafx')
getToken(params).then((res)=>{
localStorage.setItem('token',res.data.data.token)
// console.log(localStorage.getItem('token'),'token');
})
},
methods:{

View File

@ -1,57 +1,57 @@
import axios from 'axios'
// if (process.env.NODE_ENV === 'development') {
// axios.defaults.baseURL = '/api'
// axios.defaults.baseURL = '/app'
// } else if (process.env.NODE_ENV === 'production') {
// axios.defaults.baseURL = '/api'
// axios.defaults.baseURL = '/app'
// }
//设置请求头参数 common 为设置所有的接口 post为设置post请求的接口
// axios.defaults.headers.common['Authorization'] = `Bearer ${localStorage.getItem('access_token')}`;
// 电力概况
export const getCompanyInfo = (params) => {
return axios.get('api/Handler/Company.ashx', {
return axios.get('app/Handler/Company.ashx', {
params
})
};
// 路线查询 下拉
export const getLine = (params) => {
return axios.get('api/Handler/Line.ashx', {
return axios.get('app/Handler/Line.ashx', {
params
})
};
// 查询设备素材
export const getDevice = (params) => {
return axios.get('api/Handler/Device.ashx', {
return axios.get('app/Handler/Device.ashx', {
params
})
};
//班组故障查询
export const getBanzugz = (params) => {
return axios.get('api/Handler/Banzugz.ashx', {
return axios.get('app/Handler/Banzugz.ashx', {
params
})
};
//查询工单统计
export const getGdtj = (params) => {
return axios.get('api/Handler/gdtj.ashx', {
return axios.get('app/Handler/gdtj.ashx', {
params
})
};
//查询单位本周故障
export const getDwbzgz = (params) => {
return axios.get('api/Handler/Dwbzgz.ashx', {
return axios.get('app/Handler/Dwbzgz.ashx', {
params
})
};
//查询供电所供电质量情况
export const getGdsgdzl = (params) => {
return axios.get('api/Handler/Gdsgdzl.ashx', {
return axios.get('app/Handler/Gdsgdzl.ashx', {
params
})
};
//查询配变停运情况
export const getPbtyqk = (params) => {
return axios.get('api/Handler/Pbtyqk.ashx', {
return axios.get('app/Handler/Pbtyqk.ashx', {
params
})
};
@ -63,13 +63,38 @@ export const getPbtyqk = (params) => {
// };
//查询天气
// export const Weather = (params) => {
// return axios.get('api/Handler/Weather.ashx', {
// return axios.get('app/Handler/Weather.ashx', {
// params
// })
// };
//查询天气1
export const Weather = (params) => {
return axios.get('api/Handler/Data.ashx', {
return axios.get('app/Handler/Data.ashx', {
params
})
};
//获取token
export const getToken = (data) => {
return axios.post('aps/api/v1/token'+'?appKey='+data.appKey+'&appSecret='+data.appSecret,data
,{headers: { 'Content-Type': 'application/x-www-form-urlencoded' }})
};
//获取单个网柜信息
export const getCabinetInfo = (data) => {
return axios.post('aps/api/v1/cabinetInfo'+'?sn='+data.sn+'&token='+data.token,data
,{headers: { 'Content-Type': 'application/x-www-form-urlencoded' }})
};
//获取网柜列表
export const getCabinetList = (data) => {
return axios.post('aps/api/v1/cabinetList'+'?sn='+data.pageSize+'&token='+data.token,data
,{headers: { 'Content-Type': 'application/x-www-form-urlencoded' }})
};
//获取单个网柜数据
export const getCabinetData = (data) => {
return axios.post('aps/api/v1/cabinetData'+'?sn='+data.sn+'&token='+data.token,data
,{headers: { 'Content-Type': 'application/x-www-form-urlencoded' }})
};
//获取单个网柜视频列表
export const getCabinetCameraList = (data) => {
return axios.post('aps/api/v1/cabinetCameraList'+'?sn='+data.sn+'&token='+data.token,data
,{headers: { 'Content-Type': 'application/x-www-form-urlencoded' }})
};

BIN
src/assets/images/zhifu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

View File

@ -30,7 +30,6 @@ Vue.mixin(Mixin)
Vue.config.productionTip = false
new Vue({
router,
store,

1
src/util/jsmpeg.min.js vendored Normal file

File diff suppressed because one or more lines are too long

3077
src/util/vue-jsmpeg.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,61 +1,81 @@
<template>
<div class="stationBuilding">
<video-player
<!-- <video-player
class="video-player vjs-custom-skin"
style="heght:100%;width:100%"
ref="VideoPlayer"
:playsinline="true"
:options="playerOptions"
>
</video-player>
</video-player> -->
<div class="stationContent">
<div class="systemText">
<i class="el-icon-loading" style="color: #4bfffd; font-size: 80px"></i>
<p style="font-size: 30px;color:#fff">系统正在加载中...</p>
</div>
</div>
</div>
</template>
<script>
export default {
name:"stationBuilding",
data() {
return {
//
name: "stationBuilding",
data() {
return {
//
playerOptions: {
height: 400,
playbackRates: [0.7, 1.0, 1.5, 2.0], //
autoplay: false, // true,
muted: false, //
loop: false, //
preload: 'auto', // <video>auto,
language: 'zh-CN',
aspectRatio: '16:9', // 使 - "16:9""4:3"
preload: "auto", // <video>auto,
language: "zh-CN",
aspectRatio: "16:9", // 使 - "16:9""4:3"
fluid: true, // trueVideo.js player
sources: [
{
type: 'video/mp4', // git
src: require('../assets/videos/video.mp4'), // url
}
type: "video/mp4", // git
src: require("../assets/videos/video.mp4"), // url
},
],
poster: require('../assets/images/sun.png'), //
poster: require("../assets/images/sun.png"), //
// width: document.documentElement.clientWidth, //
notSupportedMessage: '此视频暂无法播放,请稍后再试', // Video.js
notSupportedMessage: "此视频暂无法播放,请稍后再试", // Video.js
controlBar: {
timeDivider: true,
durationDisplay: true,
remainingTimeDisplay: false,
fullscreenToggle: true //
}
}
}
}
}
fullscreenToggle: true, //
},
},
};
},
};
</script>
<style lang="less" scoped>
.stationBuilding{
.stationBuilding {
width: 1722px;
height: 982px;
background: url("../assets/images/stationBuildingKuang.png") no-repeat;
background-size: 100% 100%;
padding: 15px 25px;
z-index: 100;
.stationContent {
width: 100%;
height: 100%;
background: url("../assets/images/zhifu.png") no-repeat;
background-size: 100% 100%;
position: relative;
display: flex;
align-items: center;
justify-content: center;
.systemText {
position: absolute;
display: flex;
flex-direction: column;
}
}
}
</style>

View File

@ -14,24 +14,23 @@ module.exports = {
// host: "0.0.0.0", // 匹配本机IP地址(默认是0.0.0.0)
// port: 8989, // 开发服务器运行端口号
proxy: {
'/api': { //代理的名字
'/app': { //代理的名字
// target:'http://111.229.30.246:3111/',
target: 'http://172.16.1.254:3111/',
ws: true,
changeOrigin: true,
pathRewrite:{
'^/api':'',
'^/app':'',
}
},
// '/aps': { //代理的名字
// target:'http://www.jcznedu.com:5000/',
// // target: 'http://172.16.1.254:3111/',
// ws: true,
// changeOrigin: true,
// pathRewrite:{
// '^/aps':'',
// }
// }
'/aps': { //代理的名字
target:'http://221.231.99.214:99/',
ws: true,
changeOrigin: true,
pathRewrite:{
'^/aps':'',
}
}
}
}
}