index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <a-card>
  3. <a-row justify="end" >
  4. <a-col >
  5. <a-button type="primary" @click="openModal">创建拉流</a-button>
  6. </a-col>
  7. </a-row>
  8. <a-table
  9. style="margin-top: 20px;"
  10. :columns="columns"
  11. :data-source="state.dataSource"
  12. :loading="state.loading"
  13. >
  14. <template #bodyCell="{column, record}" >
  15. <template v-if="column.key === 'StartTime'" >
  16. {{dayjs(record.StartTime).format('YYYY/MM/DD HH:mm:ss')}}
  17. </template>
  18. <template v-if="column.key === 'action'" >
  19. <a-space>
  20. <a @click="stopPull(record.RemoteURL)" >停止</a>
  21. </a-space>
  22. </template>
  23. </template>
  24. </a-table>
  25. </a-card>
  26. <modal-pro
  27. label="创建拉流"
  28. :open="state.visible"
  29. @cancel="state.visible = false "
  30. @ok="ok"
  31. >
  32. <a-form :label-col="{span: 5}" >
  33. <a-form-item label="拉流类型" >
  34. <a-select v-model:value="bodyParamsState.name" >
  35. <a-select-option
  36. v-for="item in pullList"
  37. :key="item.key"
  38. :value="item.value"
  39. >
  40. {{item.value}}
  41. </a-select-option>
  42. </a-select>
  43. </a-form-item>
  44. <a-form-item label="拉流地址" v-bind='validateInfos.target' >
  45. <a-input v-model:value="bodyParamsState.target" > </a-input>
  46. </a-form-item>
  47. <a-form-item label="视频流标识" v-bind='validateInfos.streamPath' >
  48. <a-input v-model:value="bodyParamsState.streamPath" > </a-input>
  49. </a-form-item>
  50. </a-form>
  51. </modal-pro>
  52. </template>
  53. <script lang="ts" setup >
  54. import { RtsController } from '@/controller/rts'
  55. import { onMounted, reactive } from 'vue'
  56. import { Form } from 'ant-design-vue'
  57. import dayjs from 'dayjs'
  58. const columns = [
  59. {
  60. title: 'ID',
  61. dataIndex: 'ID'
  62. },
  63. {
  64. title: '拉流类型',
  65. dataIndex: 'Type'
  66. },
  67. {
  68. title: '流地址',
  69. dataIndex: 'StreamPath'
  70. },
  71. {
  72. title: '被拉流地址',
  73. dataIndex: 'RemoteURL'
  74. },
  75. {
  76. title: '重联次数',
  77. dataIndex: 'ReConnectCount'
  78. },
  79. {
  80. title: '拉流参数',
  81. dataIndex: 'Args'
  82. },
  83. {
  84. title: '开始时间',
  85. dataIndex: 'StartTime',
  86. key: 'StartTime'
  87. },
  88. {
  89. title: '操作',
  90. dataIndex: 'action',
  91. key: 'action'
  92. }
  93. ]
  94. const useForm = Form.useForm
  95. const pullList = [
  96. {
  97. key: 'RTSP',
  98. value: 'RTSP'
  99. },
  100. {
  101. key: 'RTMP',
  102. value: 'RTMP'
  103. }
  104. ]
  105. const bodyParamsState = reactive({
  106. name: 'RTSP',
  107. target: '',
  108. streamPath: '',
  109. save: 2
  110. })
  111. const state = reactive<{
  112. dataSource: RTS.PullStream.Detail[]
  113. loading: boolean
  114. visible: boolean
  115. detail: Partial<RTS.PullStream.Detail>
  116. }>({
  117. loading: false,
  118. visible: false,
  119. detail: {},
  120. dataSource: []
  121. })
  122. const { resetFields, validate, validateInfos } = useForm(bodyParamsState, reactive({
  123. streamPath: [{ required: 'true', message: '请填写视频流标识' }],
  124. target: [{ required: 'true', message: '请填写流地址' }]
  125. }))
  126. const openModal = () => {
  127. state.visible = true
  128. }
  129. const ok = () => {
  130. validate().then(async () => {
  131. await RtsController.createPull(bodyParamsState)
  132. state.visible = false
  133. getPullList()
  134. })
  135. }
  136. const stopPull = async (remoteurl: string) => {
  137. await RtsController.stopPull(remoteurl)
  138. }
  139. const getPullList = async () => {
  140. const { data } = await RtsController.listPullList()
  141. state.dataSource = data
  142. }
  143. onMounted(() => {
  144. getPullList()
  145. })
  146. </script>
  147. <style lang="less" scoped >
  148. </style>