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.srcUrl" @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></i>
  25. {{scope.row.srcUrl}}
  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 === "default"? "直接代理":"FFMPEG代理"}}</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="音频" min-width="120" >
  57. <template slot-scope="scope">
  58. <div slot="reference" class="name-wrapper">
  59. <el-tag size="medium" v-if="scope.row.enableAudio">已启用</el-tag>
  60. <el-tag size="medium" type="info" v-if="!scope.row.enableAudio">未启用</el-tag>
  61. </div>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="录制" min-width="120" >
  65. <template slot-scope="scope">
  66. <div slot="reference" class="name-wrapper">
  67. <el-tag size="medium" v-if="scope.row.enableMp4">已启用</el-tag>
  68. <el-tag size="medium" type="info" v-if="!scope.row.enableMp4">未启用</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.enableRemoveNoneReader">移除</el-tag>
  76. <el-tag size="medium" v-if="scope.row.enableDisableNoneReader">停用</el-tag>
  77. <el-tag size="medium" type="info" v-if="!scope.row.enableRemoveNoneReader && !scope.row.enableDisableNoneReader">不做处理</el-tag>
  78. </div>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="操作" width="360" fixed="right">
  82. <template slot-scope="scope">
  83. <el-button size="medium" icon="el-icon-video-play" type="text" v-if="scope.row.enable" @click="play(scope.row)">播放</el-button>
  84. <el-divider direction="vertical"></el-divider>
  85. <el-button size="medium" icon="el-icon-switch-button" type="text" v-if="scope.row.enable" @click="stop(scope.row)">停用</el-button>
  86. <el-divider direction="vertical"></el-divider>
  87. <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>
  88. <el-divider v-if="!scope.row.enable" direction="vertical"></el-divider>
  89. <el-button size="medium" icon="el-icon-delete" type="text" style="color: #f56c6c" @click="deleteStreamProxy(scope.row)">删除</el-button>
  90. </template>
  91. </el-table-column>
  92. </el-table>
  93. <el-pagination
  94. style="float: right"
  95. @size-change="handleSizeChange"
  96. @current-change="currentChange"
  97. :current-page="currentPage"
  98. :page-size="count"
  99. :page-sizes="[15, 25, 35, 50]"
  100. layout="total, sizes, prev, pager, next"
  101. :total="total">
  102. </el-pagination>
  103. <streamProxyEdit ref="streamProxyEdit" ></streamProxyEdit>
  104. <onvifEdit ref="onvifEdit" ></onvifEdit>
  105. </div>
  106. </template>
  107. <script>
  108. import streamProxyEdit from './dialog/StreamProxyEdit.vue'
  109. import onvifEdit from './dialog/onvifEdit.vue'
  110. import devicePlayer from './dialog/devicePlayer.vue'
  111. import uiHeader from '../layout/UiHeader.vue'
  112. export default {
  113. name: 'streamProxyList',
  114. components: {
  115. devicePlayer,
  116. streamProxyEdit,
  117. onvifEdit,
  118. uiHeader
  119. },
  120. data() {
  121. return {
  122. streamProxyList: [],
  123. currentPusher: {}, //当前操作设备对象
  124. updateLooper: 0, //数据刷新轮训标志
  125. currentDeviceChannelsLenth:0,
  126. winHeight: window.innerHeight - 250,
  127. currentPage:1,
  128. count:15,
  129. total:0,
  130. startBtnLoading: false
  131. };
  132. },
  133. computed: {
  134. },
  135. mounted() {
  136. this.initData();
  137. this.startUpdateList()
  138. },
  139. destroyed() {
  140. this.$destroy('videojs');
  141. clearTimeout(this.updateLooper);
  142. },
  143. methods: {
  144. initData: function() {
  145. this.getStreamProxyList();
  146. },
  147. stopUpdateList: function (){
  148. window.clearInterval(this.updateLooper)
  149. },
  150. startUpdateList: function (){
  151. this.updateLooper = setInterval(this.initData, 1000);
  152. },
  153. currentChange: function(val){
  154. this.currentPage = val;
  155. this.getStreamProxyList();
  156. },
  157. handleSizeChange: function(val){
  158. this.count = val;
  159. this.getStreamProxyList();
  160. },
  161. getStreamProxyList: function() {
  162. let that = this;
  163. this.$axios({
  164. method: 'get',
  165. url:`/api/proxy/list`,
  166. params: {
  167. page: that.currentPage,
  168. count: that.count
  169. }
  170. }).then(function (res) {
  171. if (res.data.code === 0) {
  172. that.total = res.data.data.total;
  173. for (let i = 0; i < res.data.data.list.length; i++) {
  174. res.data.data.list[i]["startBtnLoading"] = false;
  175. }
  176. that.streamProxyList = res.data.data.list;
  177. }
  178. }).catch(function (error) {
  179. console.log(error);
  180. });
  181. },
  182. addStreamProxy: function(){
  183. this.$refs.streamProxyEdit.openDialog(null, this.initData)
  184. },
  185. addOnvif: function(){
  186. this.$axios({
  187. method: 'get',
  188. url:`/api/onvif/search?timeout=3000`,
  189. }).then((res) =>{
  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, srcUrl: 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.$message.error(error.response.data.msg);
  206. });
  207. },
  208. saveStreamProxy: function(){
  209. },
  210. play: function(row){
  211. let that = this;
  212. this.$axios({
  213. method: 'get',
  214. url:`/api/push/getPlayUrl`,
  215. params: {
  216. app: row.app,
  217. stream: row.stream,
  218. mediaServerId: row.mediaServerId
  219. }
  220. }).then(function (res) {
  221. if (res.data.code === 0) {
  222. that.$refs.devicePlayer.openDialog("streamPlay", null, null, {
  223. streamInfo: res.data.data,
  224. hasAudio: true
  225. });
  226. }else {
  227. that.$message({
  228. showClose: true,
  229. message: "获取地址失败:" + res.data.msg,
  230. type: "error",
  231. });
  232. }
  233. }).catch(function (error) {
  234. console.log(error);
  235. });
  236. },
  237. deleteStreamProxy: function(row){
  238. let that = this;
  239. this.$confirm('确定删除此代理吗?', '提示', {
  240. confirmButtonText: '确定',
  241. cancelButtonText: '取消',
  242. type: 'warning'
  243. }).then(() => {
  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.initData()
  253. }).catch(function (error) {
  254. console.log(error);
  255. });
  256. }).catch(() => {
  257. });
  258. },
  259. start: function(row){
  260. this.stopUpdateList()
  261. this.$set(row, 'startBtnLoading', true)
  262. this.$axios({
  263. method: 'get',
  264. url:`/api/proxy/start`,
  265. params: {
  266. app: row.app,
  267. stream: row.stream
  268. }
  269. }).then((res)=> {
  270. if (res.data.code === 0){
  271. this.initData()
  272. }else {
  273. this.$message({
  274. showClose: true,
  275. message: "启动失败,请检查地址是否可用!",
  276. type: "error",
  277. });
  278. }
  279. this.$set(row, 'startBtnLoading', false)
  280. this.startUpdateList()
  281. }).catch((error)=> {
  282. console.log(error);
  283. this.$message({
  284. showClose: true,
  285. message: "启动失败,请检查地址是否可用!",
  286. type: "error",
  287. });
  288. this.$set(row, 'startBtnLoading', false)
  289. this.startUpdateList()
  290. });
  291. },
  292. stop: function(row){
  293. let that = this;
  294. this.$axios({
  295. method: 'get',
  296. url:`/api/proxy/stop`,
  297. params: {
  298. app: row.app,
  299. stream: row.stream
  300. }
  301. }).then(function (res) {
  302. that.initData()
  303. }).catch(function (error) {
  304. console.log(error);
  305. });
  306. },
  307. refresh: function (){
  308. this.initData();
  309. }
  310. }
  311. };
  312. </script>
  313. <style>
  314. .videoList {
  315. display: flex;
  316. flex-wrap: wrap;
  317. align-content: flex-start;
  318. }
  319. .video-item {
  320. position: relative;
  321. width: 15rem;
  322. height: 10rem;
  323. margin-right: 1rem;
  324. background-color: #000000;
  325. }
  326. .video-item-img {
  327. position: absolute;
  328. top: 0;
  329. bottom: 0;
  330. left: 0;
  331. right: 0;
  332. margin: auto;
  333. width: 100%;
  334. height: 100%;
  335. }
  336. .video-item-img:after {
  337. content: "";
  338. display: inline-block;
  339. position: absolute;
  340. z-index: 2;
  341. top: 0;
  342. bottom: 0;
  343. left: 0;
  344. right: 0;
  345. margin: auto;
  346. width: 3rem;
  347. height: 3rem;
  348. background-image: url("../assets/loading.png");
  349. background-size: cover;
  350. background-color: #000000;
  351. }
  352. .video-item-title {
  353. position: absolute;
  354. bottom: 0;
  355. color: #000000;
  356. background-color: #ffffff;
  357. line-height: 1.5rem;
  358. padding: 0.3rem;
  359. width: 14.4rem;
  360. }
  361. .cpoy-btn {
  362. cursor: pointer;
  363. margin-right: 10px;
  364. }
  365. </style>