From 8ea6e192d9f986045adbaeab54ea062938e9693e Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期二, 22 十一月 2022 17:17:35 +0800 Subject: [PATCH] 优化拉流代理表单以及逻辑 --- src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java | 1 web_src/src/components/StreamProxyList.vue | 69 ++++++------- src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java | 33 ++---- sql/mysql.sql | 2 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java | 12 - src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java | 6 src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java | 10 +- sql/update.sql | 5 + web_src/src/components/dialog/StreamProxyEdit.vue | 80 ++++++++-------- src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java | 31 +---- 10 files changed, 108 insertions(+), 141 deletions(-) diff --git a/sql/mysql.sql b/sql/mysql.sql index b5ca016..869482c 100644 --- a/sql/mysql.sql +++ b/sql/mysql.sql @@ -446,7 +446,7 @@ `ffmpeg_cmd_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `rtp_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `mediaServerId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `enable_hls` bit(1) DEFAULT NULL, + `enable_audio` bit(1) DEFAULT NULL, `enable_mp4` bit(1) DEFAULT NULL, `enable` bit(1) NOT NULL, `status` bit(1) NOT NULL, diff --git a/sql/update.sql b/sql/update.sql index 405cb3a..877e247 100644 --- a/sql/update.sql +++ b/sql/update.sql @@ -36,3 +36,8 @@ alter table device modify hostAddress varchar(50) null; + +alter table stream_proxy + change enable_hls enable_audio bit null; + + diff --git a/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java b/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java index 0c7c3d2..728afb9 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java @@ -1,12 +1,12 @@ package com.genersoft.iot.vmp.conf; import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEventListener; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseStatus; @@ -40,8 +40,8 @@ */ @ExceptionHandler(ControllerException.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public WVPResult<String> exceptionHandler(ControllerException e) { - return WVPResult.fail(e.getCode(), e.getMsg()); + public ResponseEntity<WVPResult<String>> exceptionHandler(ControllerException e) { + return new ResponseEntity<>(WVPResult.fail(e.getCode(), e.getMsg()), HttpStatus.OK); } /** @@ -51,7 +51,7 @@ */ @ExceptionHandler(BadCredentialsException.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public WVPResult<String> exceptionHandler(BadCredentialsException e) { - return WVPResult.fail(ErrorCode.ERROR100.getCode(), e.getMessage()); + public ResponseEntity<WVPResult<String>> exceptionHandler(BadCredentialsException e) { + return new ResponseEntity<>(WVPResult.fail(ErrorCode.ERROR100.getCode(), e.getMessage()), HttpStatus.OK); } } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java index a314554..54a2890 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java @@ -505,6 +505,7 @@ // 淇敼鏁版嵁 streamProxyService.stop(param.getApp(), param.getStream()); }else { + // 鏃犱汉瑙傜湅涓嶅仛澶勭悊 ret.put("close", false); } return ret; diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java index 7d3510f..bf9551d 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java @@ -236,14 +236,13 @@ } public JSONObject addFFmpegSource(MediaServerItem mediaServerItem, String src_url, String dst_url, String timeout_ms, - boolean enable_hls, boolean enable_mp4, String ffmpeg_cmd_key){ + boolean enable_audio, boolean enable_mp4, String ffmpeg_cmd_key){ logger.info(src_url); logger.info(dst_url); Map<String, Object> param = new HashMap<>(); param.put("src_url", src_url); param.put("dst_url", dst_url); param.put("timeout_ms", timeout_ms); - param.put("enable_hls", enable_hls); param.put("enable_mp4", enable_mp4); param.put("ffmpeg_cmd_key", ffmpeg_cmd_key); return sendPost(mediaServerItem, "addFFmpegSource",param, null); @@ -287,19 +286,14 @@ return sendPost(mediaServerItem, "restartServer",null, null); } - public JSONObject addStreamProxy(MediaServerItem mediaServerItem, String app, String stream, String url, boolean enable_hls, boolean enable_mp4, String rtp_type) { + public JSONObject addStreamProxy(MediaServerItem mediaServerItem, String app, String stream, String url, boolean enable_audio, boolean enable_mp4, String rtp_type) { Map<String, Object> param = new HashMap<>(); param.put("vhost", "__defaultVhost__"); param.put("app", app); param.put("stream", stream); param.put("url", url); - param.put("enable_hls", enable_hls?1:0); param.put("enable_mp4", enable_mp4?1:0); - param.put("enable_rtmp", 1); - param.put("enable_fmp4", 1); - param.put("enable_audio", 1); - param.put("enable_rtsp", 1); - param.put("add_mute_audio", 1); + param.put("enable_audio", enable_audio?1:0); param.put("rtp_type", rtp_type); return sendPost(mediaServerItem, "addStreamProxy",param, null); } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java index ea0bdca..b0e74e8 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java @@ -31,8 +31,8 @@ private String rtp_type; @Schema(description = "鏄惁鍚敤") private boolean enable; - @Schema(description = "鏄惁鍚敤HLS") - private boolean enable_hls; + @Schema(description = "鏄惁鍚敤闊抽") + private boolean enable_audio; @Schema(description = "鏄惁鍚敤MP4") private boolean enable_mp4; @Schema(description = "鏄惁 鏃犱汉瑙傜湅鏃跺垹闄�") @@ -40,8 +40,6 @@ @Schema(description = "鏄惁 鏃犱汉瑙傜湅鏃惰嚜鍔ㄥ仠鐢�") private boolean enable_disable_none_reader; - @Schema(description = "涓婄骇骞冲彴鍥芥爣ID") - private String platformGbId; @Schema(description = "鍒涘缓鏃堕棿") private String createTime; @@ -139,14 +137,6 @@ this.enable = enable; } - public boolean isEnable_hls() { - return enable_hls; - } - - public void setEnable_hls(boolean enable_hls) { - this.enable_hls = enable_hls; - } - public boolean isEnable_mp4() { return enable_mp4; } @@ -155,19 +145,12 @@ this.enable_mp4 = enable_mp4; } - - public String getPlatformGbId() { - return platformGbId; - } - - public void setPlatformGbId(String platformGbId) { - this.platformGbId = platformGbId; - } - + @Override public String getCreateTime() { return createTime; } + @Override public void setCreateTime(String createTime) { this.createTime = createTime; } @@ -187,4 +170,12 @@ public void setEnable_disable_none_reader(boolean enable_disable_none_reader) { this.enable_disable_none_reader = enable_disable_none_reader; } + + public boolean isEnable_audio() { + return enable_audio; + } + + public void setEnable_audio(boolean enable_audio) { + this.enable_audio = enable_audio; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java index 3183e3d..7dcd7f2 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java @@ -5,23 +5,22 @@ import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; import com.genersoft.iot.vmp.service.IGbStreamService; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IMediaService; +import com.genersoft.iot.vmp.service.IStreamProxyService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; -import com.genersoft.iot.vmp.service.IStreamProxyService; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; @@ -35,7 +34,9 @@ import org.springframework.transaction.TransactionStatus; import org.springframework.util.ObjectUtils; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * 瑙嗛浠g悊涓氬姟 @@ -107,7 +108,6 @@ param.getStream() ); param.setDst_url(dstUrl); StringBuffer resultMsg = new StringBuffer(); - boolean streamLive = false; param.setMediaServerId(mediaInfo.getId()); boolean saveResult; // 鏇存柊 @@ -124,7 +124,6 @@ if (param.isEnable()) { JSONObject jsonObject = addStreamProxyToZlm(param); if (jsonObject == null || jsonObject.getInteger("code") != 0) { - streamLive = false; resultMsg.append(", 浣嗘槸鍚敤澶辫触锛岃妫�鏌ユ祦鍦板潃鏄惁鍙敤"); param.setEnable(false); // 鐩存帴绉婚櫎 @@ -134,26 +133,10 @@ updateStreamProxy(param); } - }else { - streamLive = true; resultForStreamInfo = mediaService.getStreamInfoByAppAndStream( mediaInfo, param.getApp(), param.getStream(), null, null); - } - } - if ( !ObjectUtils.isEmpty(param.getPlatformGbId()) && streamLive) { - List<GbStream> gbStreams = new ArrayList<>(); - gbStreams.add(param); - if (gbStreamService.addPlatformInfo(gbStreams, param.getPlatformGbId(), param.getCatalogId())){ - return resultForStreamInfo; - }else { - resultMsg.append(", 鍏宠仈鍥芥爣骞冲彴[ " + param.getPlatformGbId() + " ]澶辫触"); - throw new ControllerException(ErrorCode.ERROR100.getCode(), resultMsg.toString()); - } - }else { - if (!streamLive) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), resultMsg.toString()); } } return resultForStreamInfo; @@ -245,10 +228,10 @@ } if ("default".equals(param.getType())){ result = zlmresTfulUtils.addStreamProxy(mediaServerItem, param.getApp(), param.getStream(), param.getUrl(), - param.isEnable_hls(), param.isEnable_mp4(), param.getRtp_type()); + param.isEnable_audio(), param.isEnable_mp4(), param.getRtp_type()); }else if ("ffmpeg".equals(param.getType())) { result = zlmresTfulUtils.addFFmpegSource(mediaServerItem, param.getSrc_url(), param.getDst_url(), - param.getTimeout_ms() + "", param.isEnable_hls(), param.isEnable_mp4(), + param.getTimeout_ms() + "", param.isEnable_audio(), param.isEnable_mp4(), param.getFfmpeg_cmd_key()); } return result; diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java index 448a358..4ed214d 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java @@ -12,9 +12,9 @@ public interface StreamProxyMapper { @Insert("INSERT INTO stream_proxy (type, name, app, stream,mediaServerId, url, src_url, dst_url, " + - "timeout_ms, ffmpeg_cmd_key, rtp_type, enable_hls, enable_mp4, enable, status, enable_remove_none_reader, enable_disable_none_reader, createTime) VALUES" + + "timeout_ms, ffmpeg_cmd_key, rtp_type, enable_audio, enable_mp4, enable, status, enable_remove_none_reader, enable_disable_none_reader, createTime) VALUES" + "('${type}','${name}', '${app}', '${stream}', '${mediaServerId}','${url}', '${src_url}', '${dst_url}', " + - "'${timeout_ms}', '${ffmpeg_cmd_key}', '${rtp_type}', ${enable_hls}, ${enable_mp4}, ${enable}, ${status}, " + + "'${timeout_ms}', '${ffmpeg_cmd_key}', '${rtp_type}', ${enable_audio}, ${enable_mp4}, ${enable}, ${status}, " + "${enable_remove_none_reader}, ${enable_disable_none_reader}, '${createTime}' )") int add(StreamProxyItem streamProxyDto); @@ -30,7 +30,7 @@ "timeout_ms=#{timeout_ms}, " + "ffmpeg_cmd_key=#{ffmpeg_cmd_key}, " + "rtp_type=#{rtp_type}, " + - "enable_hls=#{enable_hls}, " + + "enable_audio=#{enable_audio}, " + "enable=#{enable}, " + "status=#{status}, " + "enable_remove_none_reader=#{enable_remove_none_reader}, " + diff --git a/web_src/src/components/StreamProxyList.vue b/web_src/src/components/StreamProxyList.vue index 5eff9d5..47ccde8 100644 --- a/web_src/src/components/StreamProxyList.vue +++ b/web_src/src/components/StreamProxyList.vue @@ -32,7 +32,7 @@ <el-table-column label="绫诲瀷" width="100" > <template slot-scope="scope"> <div slot="reference" class="name-wrapper"> - <el-tag size="medium">{{scope.row.type}}</el-tag> + <el-tag size="medium">{{scope.row.type === "default"? "鐩存帴浠g悊":"FFMPEG浠g悊"}}</el-tag> </div> </template> </el-table-column> @@ -55,15 +55,15 @@ </template> </el-table-column> <el-table-column prop="createTime" label="鍒涘缓鏃堕棿" min-width="150" show-overflow-tooltip/> - <el-table-column label="杞琀LS" min-width="120" > + <el-table-column label="闊抽" min-width="120" > <template slot-scope="scope"> <div slot="reference" class="name-wrapper"> - <el-tag size="medium" v-if="scope.row.enable_hls">宸插惎鐢�</el-tag> - <el-tag size="medium" type="info" v-if="!scope.row.enable_hls">鏈惎鐢�</el-tag> + <el-tag size="medium" v-if="scope.row.enable_audio">宸插惎鐢�</el-tag> + <el-tag size="medium" type="info" v-if="!scope.row.enable_audio">鏈惎鐢�</el-tag> </div> </template> </el-table-column> - <el-table-column label="MP4褰曞埗" min-width="120" > + <el-table-column label="褰曞埗" min-width="120" > <template slot-scope="scope"> <div slot="reference" class="name-wrapper"> <el-tag size="medium" v-if="scope.row.enable_mp4">宸插惎鐢�</el-tag> @@ -71,11 +71,12 @@ </div> </template> </el-table-column> - <el-table-column label="鏃犱汉瑙傜湅鑷姩鍒犻櫎" min-width="160" > + <el-table-column label="鏃犱汉瑙傜湅" min-width="160" > <template slot-scope="scope"> <div slot="reference" class="name-wrapper"> - <el-tag size="medium" v-if="scope.row.enable_remove_none_reader">宸插惎鐢�</el-tag> - <el-tag size="medium" type="info" v-if="!scope.row.enable_remove_none_reader">鏈惎鐢�</el-tag> + <el-tag size="medium" v-if="scope.row.enable_remove_none_reader">绉婚櫎</el-tag> + <el-tag size="medium" v-if="scope.row.enable_disable_none_reader">鍋滅敤</el-tag> + <el-tag size="medium" type="info" v-if="!scope.row.enable_remove_none_reader && !scope.row.enable_disable_none_reader">涓嶅仛澶勭悊</el-tag> </div> </template> </el-table-column> @@ -131,7 +132,6 @@ currentPage:1, count:15, total:0, - getListLoading: false, startBtnLoading: false }; }, @@ -139,7 +139,7 @@ }, mounted() { this.initData(); - this.updateLooper = setInterval(this.initData, 1000); + this.startUpdateList() }, destroyed() { this.$destroy('videojs'); @@ -149,6 +149,12 @@ initData: function() { this.getStreamProxyList(); }, + stopUpdateList: function (){ + window.clearInterval(this.updateLooper) + }, + startUpdateList: function (){ + this.updateLooper = setInterval(this.initData, 1000); + }, currentChange: function(val){ this.currentPage = val; this.getStreamProxyList(); @@ -159,7 +165,6 @@ }, getStreamProxyList: function() { let that = this; - this.getListLoading = true; this.$axios({ method: 'get', url:`/api/proxy/list`, @@ -175,23 +180,18 @@ } that.streamProxyList = res.data.data.list; } - that.getListLoading = false; }).catch(function (error) { console.log(error); - that.getListLoading = false; }); }, addStreamProxy: function(){ this.$refs.streamProxyEdit.openDialog(null, this.initData) }, addOnvif: function(){ - this.getListLoading = true; - this.getListLoading = true; this.$axios({ method: 'get', url:`/api/onvif/search?timeout=3000`, }).then((res) =>{ - this.getListLoading = false; if (res.data.code === 0 ){ if (res.data.data.length > 0) { this.$refs.onvifEdit.openDialog(res.data.data, (url)=>{ @@ -208,7 +208,6 @@ } }).catch((error)=> { - this.getListLoading = false; this.$message.error(error.response.data.msg); }); @@ -217,7 +216,6 @@ }, play: function(row){ let that = this; - this.getListLoading = true; this.$axios({ method: 'get', url:`/api/push/getPlayUrl`, @@ -227,7 +225,6 @@ mediaServerId: row.mediaServerId } }).then(function (res) { - that.getListLoading = false; if (res.data.code === 0) { that.$refs.devicePlayer.openDialog("streamPlay", null, null, { streamInfo: res.data.data, @@ -243,13 +240,11 @@ }).catch(function (error) { console.log(error); - that.getListLoading = false; }); }, deleteStreamProxy: function(row){ let that = this; - this.getListLoading = true; that.$axios({ method:"delete", url:"/api/proxy/del", @@ -258,16 +253,13 @@ stream: row.stream } }).then((res)=>{ - that.getListLoading = false; that.initData() }).catch(function (error) { console.log(error); - that.getListLoading = false; }); }, start: function(row){ - let that = this; - this.getListLoading = true; + this.stopUpdateList() this.$set(row, 'startBtnLoading', true) this.$axios({ method: 'get', @@ -276,28 +268,31 @@ app: row.app, stream: row.stream } - }).then(function (res) { - that.getListLoading = false; - that.$set(row, 'startBtnLoading', false) + }).then((res)=> { if (res.data.code === 0){ - that.initData() + this.initData() }else { - that.$message({ + this.$message({ showClose: true, - message: "淇濆瓨澶辫触锛岃妫�鏌ュ湴鍧�鏄惁鍙敤锛�", + message: "鍚姩澶辫触锛岃妫�鏌ュ湴鍧�鏄惁鍙敤锛�", type: "error", }); } - - }).catch(function (error) { + this.$set(row, 'startBtnLoading', false) + this.startUpdateList() + }).catch((error)=> { console.log(error); - that.getListLoading = false; - that.$set(row, 'startBtnLoading', false) + this.$message({ + showClose: true, + message: "鍚姩澶辫触锛岃妫�鏌ュ湴鍧�鏄惁鍙敤锛�", + type: "error", + }); + this.$set(row, 'startBtnLoading', false) + this.startUpdateList() }); }, stop: function(row){ let that = this; - this.getListLoading = true; this.$axios({ method: 'get', url:`/api/proxy/stop`, @@ -306,11 +301,9 @@ stream: row.stream } }).then(function (res) { - that.getListLoading = false; that.initData() }).catch(function (error) { console.log(error); - that.getListLoading = false; }); }, refresh: function (){ diff --git a/web_src/src/components/dialog/StreamProxyEdit.vue b/web_src/src/components/dialog/StreamProxyEdit.vue index 1270999..76011fa 100644 --- a/web_src/src/components/dialog/StreamProxyEdit.vue +++ b/web_src/src/components/dialog/StreamProxyEdit.vue @@ -83,31 +83,23 @@ <el-option label="缁勬挱" value="2"></el-option> </el-select> </el-form-item> - - <el-form-item label="鍥芥爣骞冲彴"> - <el-select - v-model="proxyParam.platformGbId" - style="width: 100%" - placeholder="璇烽�夋嫨鍥芥爣骞冲彴" - > - <el-option - v-for="item in platformList" - :key="item.name" - :label="item.name" - :value="item.serverGBId"> - <span style="float: left">{{ item.name }}</span> - <span style="float: right; color: #8492a6; font-size: 13px">{{ item.serverGBId }}</span> - </el-option> - </el-select> - </el-form-item> + <el-form-item label="鏃犱汉瑙傜湅" prop="rtp_type" > + <el-select + @change="noneReaderHandler" + v-model="proxyParam.none_reader" + style="width: 100%" + placeholder="璇烽�夋嫨鏃犱汉瑙傜湅鐨勫鐞嗘柟寮�" + > + <el-option label="涓嶅仛澶勭悊" value="0"></el-option> + <el-option label="鍋滅敤" value="1"></el-option> + <el-option label="绉婚櫎" value="2"></el-option> + </el-select> + </el-form-item> <el-form-item label="鍏朵粬閫夐」"> <div style="float: left;"> <el-checkbox label="鍚敤" v-model="proxyParam.enable" ></el-checkbox> - <el-checkbox label="杞琀LS" v-model="proxyParam.enable_hls" ></el-checkbox> - <el-checkbox label="MP4褰曞埗" v-model="proxyParam.enable_mp4" ></el-checkbox> - <el-checkbox label="鏃犱汉瑙傜湅鑷姩鍒犻櫎" v-model="proxyParam.enable_remove_none_reader" @change="removeNoneReader"></el-checkbox> - <el-checkbox label="鏃犱汉瑙傜湅鍋滄鎷夋祦" v-model="proxyParam.enable_disable_none_reader" @change="disableNoneReaderHandType"></el-checkbox> - + <el-checkbox label="寮�鍚煶棰�" v-model="proxyParam.enable_audio" ></el-checkbox> + <el-checkbox label="褰曞埗" v-model="proxyParam.enable_mp4" ></el-checkbox> </div> </el-form-item> @@ -169,10 +161,11 @@ gbId: null, rtp_type: null, enable: true, - enable_hls: true, + enable_audio: true, enable_mp4: false, + none_reader: null, enable_remove_none_reader: false, - enable_disable_none_reader: true, + enable_disable_none_reader: false, platformGbId: null, mediaServerId: null, }, @@ -196,6 +189,7 @@ this.listChangeCallback = callback; if (proxyParam != null) { this.proxyParam = proxyParam; + this.proxyParam.none_reader = null; } let that = this; @@ -233,26 +227,26 @@ }, onSubmit: function () { this.dialogLoading = true; - var that = this; - that.$axios({ + this.noneReaderHandler(); + this.$axios({ method: 'post', url:`/api/proxy/save`, - data: that.proxyParam - }).then(function (res) { - that.dialogLoading = false; + data: this.proxyParam + }).then((res)=> { + this.dialogLoading = false; if (typeof (res.data.code) != "undefined" && res.data.code === 0) { - that.$message({ + this.$message({ showClose: true, message: res.data.msg, type: "success", }); - that.showDialog = false; - if (that.listChangeCallback != null) { - that.listChangeCallback(); - that.dialogLoading = false; + this.showDialog = false; + if (this.listChangeCallback != null) { + this.listChangeCallback(); + this.dialogLoading = false; } } - }).catch(function (error) { + }).catch((error) =>{ console.log(error); this.dialogLoading = false; }); @@ -280,12 +274,18 @@ this.platform.expires = "300"; } }, - removeNoneReader: function(checked) { - this.proxyParam.enable_disable_none_reader = !checked; + noneReaderHandler: function() { + if (this.proxyParam.none_reader === null || this.proxyParam.none_reader === "0") { + this.proxyParam.enable_disable_none_reader = false; + this.proxyParam.enable_remove_none_reader = false; + }else if (this.proxyParam.none_reader === "1"){ + this.proxyParam.enable_disable_none_reader = true; + this.proxyParam.enable_remove_none_reader = false; + }else if (this.proxyParam.none_reader ==="2"){ + this.proxyParam.enable_disable_none_reader = false; + this.proxyParam.enable_remove_none_reader = true; + } }, - disableNoneReaderHandType: function(checked) { - this.proxyParam.enable_remove_none_reader = !checked; - } }, }; </script> -- Gitblit v1.8.0