StreamProxyList.vue 12 KB

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