StreamProxyList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <div id="streamProxyList">
  3. <el-container>
  4. <el-header>
  5. <uiHeader></uiHeader>
  6. </el-header>
  7. <el-main>
  8. <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;">
  9. <span style="font-size: 1rem; font-weight: bold;">拉流代理列表</span>
  10. </div>
  11. <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;">
  12. <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="addStreamProxy">添加代理</el-button>
  13. <el-button v-if="false" icon="el-icon-search" size="mini" style="margin-right: 1rem;" type="primary" @click="addOnvif">搜索ONVIF</el-button>
  14. </div>
  15. <devicePlayer ref="devicePlayer"></devicePlayer>
  16. <el-table :data="streamProxyList" border style="width: 100%" :height="winHeight">
  17. <el-table-column prop="name" label="名称" align="center" show-overflow-tooltip/>
  18. <el-table-column prop="app" label="流应用名" align="center" show-overflow-tooltip/>
  19. <el-table-column prop="stream" label="流ID" align="center" show-overflow-tooltip/>
  20. <el-table-column label="流地址" width="400" align="center" show-overflow-tooltip >
  21. <template slot-scope="scope">
  22. <div slot="reference" class="name-wrapper">
  23. <el-tag size="medium" v-if="scope.row.type == 'default'">
  24. <i class="cpoy-btn el-icon-document-copy" title="点击拷贝" v-clipboard="scope.row.url" @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></i>
  25. {{scope.row.url}}
  26. </el-tag>
  27. <el-tag size="medium" v-if="scope.row.type != 'default'">
  28. <i class="cpoy-btn el-icon-document-copy" title="点击拷贝" v-clipboard="scope.row.src_url" @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></i>
  29. {{scope.row.src_url}}
  30. </el-tag>
  31. </div>
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="mediaServerId" label="流媒体" width="150" align="center"></el-table-column>
  35. <el-table-column label="类型" width="100" align="center">
  36. <template slot-scope="scope">
  37. <div slot="reference" class="name-wrapper">
  38. <el-tag size="medium">{{scope.row.type}}</el-tag>
  39. </div>
  40. </template>
  41. </el-table-column>
  42. <el-table-column prop="gbId" label="国标编码" width="180" align="center" show-overflow-tooltip/>
  43. <el-table-column label="启用" width="120" align="center">
  44. <template slot-scope="scope">
  45. <div slot="reference" class="name-wrapper">
  46. <el-tag size="medium" v-if="scope.row.enable">已启用</el-tag>
  47. <el-tag size="medium" type="info" v-if="!scope.row.enable">未启用</el-tag>
  48. </div>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="转HLS" width="120" align="center">
  52. <template slot-scope="scope">
  53. <div slot="reference" class="name-wrapper">
  54. <el-tag size="medium" v-if="scope.row.enable_hls">已启用</el-tag>
  55. <el-tag size="medium" type="info" v-if="!scope.row.enable_hls">未启用</el-tag>
  56. </div>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="MP4录制" width="120" align="center">
  60. <template slot-scope="scope">
  61. <div slot="reference" class="name-wrapper">
  62. <el-tag size="medium" v-if="scope.row.enable_mp4">已启用</el-tag>
  63. <el-tag size="medium" type="info" v-if="!scope.row.enable_mp4">未启用</el-tag>
  64. </div>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="操作" width="360" align="center" fixed="right">
  68. <template slot-scope="scope">
  69. <el-button-group>
  70. <el-button size="mini" icon="el-icon-video-play" v-if="scope.row.enable" @click="play(scope.row)">播放</el-button>
  71. <el-button size="mini" icon="el-icon-close" type="success" v-if="scope.row.enable" @click="stop(scope.row)">停用</el-button>
  72. <el-button size="mini" icon="el-icon-check" type="primary" :loading="startBtnLaoding" v-if="!scope.row.enable" @click="start(scope.row)">启用</el-button>
  73. <el-button size="mini" icon="el-icon-delete" type="danger" @click="deleteStreamProxy(scope.row)">删除</el-button>
  74. </el-button-group>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. <el-pagination
  79. style="float: right"
  80. @size-change="handleSizeChange"
  81. @current-change="currentChange"
  82. :current-page="currentPage"
  83. :page-size="count"
  84. :page-sizes="[15, 25, 35, 50]"
  85. layout="total, sizes, prev, pager, next"
  86. :total="total">
  87. </el-pagination>
  88. <streamProxyEdit ref="streamProxyEdit" ></streamProxyEdit>
  89. <onvifEdit ref="onvifEdit" ></onvifEdit>
  90. </el-main>
  91. </el-container>
  92. </div>
  93. </template>
  94. <script>
  95. import streamProxyEdit from './dialog/StreamProxyEdit.vue'
  96. import onvifEdit from './dialog/onvifEdit.vue'
  97. import devicePlayer from './dialog/devicePlayer.vue'
  98. import uiHeader from './UiHeader.vue'
  99. export default {
  100. name: 'streamProxyList',
  101. components: {
  102. devicePlayer,
  103. streamProxyEdit,
  104. onvifEdit,
  105. uiHeader
  106. },
  107. data() {
  108. return {
  109. streamProxyList: [],
  110. currentPusher: {}, //当前操作设备对象
  111. updateLooper: 0, //数据刷新轮训标志
  112. currentDeviceChannelsLenth:0,
  113. winHeight: window.innerHeight - 250,
  114. currentPage:1,
  115. count:15,
  116. total:0,
  117. getListLoading: false,
  118. startBtnLaoding: false
  119. };
  120. },
  121. computed: {
  122. },
  123. mounted() {
  124. this.initData();
  125. this.updateLooper = setInterval(this.initData, 1000);
  126. },
  127. destroyed() {
  128. this.$destroy('videojs');
  129. clearTimeout(this.updateLooper);
  130. },
  131. methods: {
  132. initData: function() {
  133. this.getStreamProxyList();
  134. },
  135. currentChange: function(val){
  136. this.currentPage = val;
  137. this.getStreamProxyList();
  138. },
  139. handleSizeChange: function(val){
  140. this.count = val;
  141. this.getStreamProxyList();
  142. },
  143. getStreamProxyList: function() {
  144. let that = this;
  145. this.getListLoading = true;
  146. this.$axios({
  147. method: 'get',
  148. url:`/api/proxy/list`,
  149. params: {
  150. page: that.currentPage,
  151. count: that.count
  152. }
  153. }).then(function (res) {
  154. that.total = res.data.total;
  155. that.streamProxyList = res.data.list;
  156. that.getListLoading = false;
  157. }).catch(function (error) {
  158. console.log(error);
  159. that.getListLoading = false;
  160. });
  161. },
  162. addStreamProxy: function(){
  163. this.$refs.streamProxyEdit.openDialog(null, this.initData)
  164. },
  165. addOnvif: function(){
  166. this.getListLoading = true;
  167. this.getListLoading = true;
  168. this.$axios({
  169. method: 'get',
  170. url:`/api/onvif/search?timeout=3000`,
  171. }).then((res) =>{
  172. this.getListLoading = false;
  173. if (res.data.code == 0 ){
  174. if (res.data.data.length > 0) {
  175. this.$refs.onvifEdit.openDialog(res.data.data, (url)=>{
  176. if (url != null) {
  177. this.$refs.onvifEdit.close();
  178. this.$refs.streamProxyEdit.openDialog({type: "default", url: url, src_url: url}, this.initData())
  179. }
  180. })
  181. }else {
  182. this.$message.success("未找到可用设备");
  183. }
  184. }else {
  185. this.$message.error(res.data.msg);
  186. }
  187. }).catch((error)=> {
  188. this.getListLoading = false;
  189. this.$message.error(error.response.data.msg);
  190. });
  191. },
  192. saveStreamProxy: function(){
  193. },
  194. play: function(row){
  195. let that = this;
  196. this.getListLoading = true;
  197. this.$axios({
  198. method: 'get',
  199. url:`/api/media/stream_info_by_app_and_stream`,
  200. params: {
  201. app: row.app,
  202. stream: row.stream,
  203. mediaServerId: row.mediaServerId
  204. }
  205. }).then(function (res) {
  206. that.getListLoading = false;
  207. if (res.data.code === 0) {
  208. that.$refs.devicePlayer.openDialog("streamPlay", null, null, {
  209. streamInfo: res.data.data,
  210. hasAudio: true
  211. });
  212. }else {
  213. that.$message({
  214. showClose: true,
  215. message: "获取地址失败:" + res.data.msg,
  216. type: "error",
  217. });
  218. }
  219. }).catch(function (error) {
  220. console.log(error);
  221. that.getListLoading = false;
  222. });
  223. },
  224. deleteStreamProxy: function(row){
  225. let that = this;
  226. this.getListLoading = true;
  227. that.$axios({
  228. method:"delete",
  229. url:"/api/proxy/del",
  230. params:{
  231. app: row.app,
  232. stream: row.stream
  233. }
  234. }).then((res)=>{
  235. that.getListLoading = false;
  236. that.initData()
  237. }).catch(function (error) {
  238. console.log(error);
  239. that.getListLoading = false;
  240. });
  241. },
  242. start: function(row){
  243. let that = this;
  244. this.getListLoading = true;
  245. this.startBtnLaoding = true;
  246. this.$axios({
  247. method: 'get',
  248. url:`/api/proxy/start`,
  249. params: {
  250. app: row.app,
  251. stream: row.stream
  252. }
  253. }).then(function (res) {
  254. that.getListLoading = false;
  255. that.startBtnLaoding = false;
  256. if (res.data == "success"){
  257. that.initData()
  258. }else {
  259. that.$message({
  260. showClose: true,
  261. message: "保存失败,请检查地址是否可用!",
  262. type: "error",
  263. });
  264. }
  265. }).catch(function (error) {
  266. console.log(error);
  267. that.getListLoading = false;
  268. that.startBtnLaoding = false;
  269. });
  270. },
  271. stop: function(row){
  272. let that = this;
  273. this.getListLoading = true;
  274. this.$axios({
  275. method: 'get',
  276. url:`/api/proxy/stop`,
  277. params: {
  278. app: row.app,
  279. stream: row.stream
  280. }
  281. }).then(function (res) {
  282. that.getListLoading = false;
  283. that.initData()
  284. }).catch(function (error) {
  285. console.log(error);
  286. that.getListLoading = false;
  287. });
  288. }
  289. }
  290. };
  291. </script>
  292. <style>
  293. .videoList {
  294. display: flex;
  295. flex-wrap: wrap;
  296. align-content: flex-start;
  297. }
  298. .video-item {
  299. position: relative;
  300. width: 15rem;
  301. height: 10rem;
  302. margin-right: 1rem;
  303. background-color: #000000;
  304. }
  305. .video-item-img {
  306. position: absolute;
  307. top: 0;
  308. bottom: 0;
  309. left: 0;
  310. right: 0;
  311. margin: auto;
  312. width: 100%;
  313. height: 100%;
  314. }
  315. .video-item-img:after {
  316. content: "";
  317. display: inline-block;
  318. position: absolute;
  319. z-index: 2;
  320. top: 0;
  321. bottom: 0;
  322. left: 0;
  323. right: 0;
  324. margin: auto;
  325. width: 3rem;
  326. height: 3rem;
  327. background-image: url("../assets/loading.png");
  328. background-size: cover;
  329. background-color: #000000;
  330. }
  331. .video-item-title {
  332. position: absolute;
  333. bottom: 0;
  334. color: #000000;
  335. background-color: #ffffff;
  336. line-height: 1.5rem;
  337. padding: 0.3rem;
  338. width: 14.4rem;
  339. }
  340. .cpoy-btn {
  341. cursor: pointer;
  342. margin-right: 10px;
  343. }
  344. </style>