Browse Source

fix: 5/15bug修复及其优化

lvkun 3 years ago
parent
commit
90d667f50c

+ 11 - 3
src/api/rts/stream.ts

@@ -138,14 +138,22 @@ export const getConfig = (name: 'RTSP' | 'RTMP' | 'HLS' | 'HDL' | 'GB28181') =>
   })
 }
 
-export const updateConfig = (name: 'RTSP' | 'RTMP' | 'HLS' | 'HDL' | 'GB28181', data: string) => {
-  return request<string>({
-    url: `/api/getconfig?name=${name}`,
+/** 保存配置 RTSP */
+export const postConfig = (name: 'RTSP' | 'RTMP' | 'HLS' | 'HDL' | 'GB28181', data: string) => {
+  return request<any>({
+    url: `/api/modifyconfig?name=${name}`,
     method: 'POST',
     data
   })
 }
 
+export const updateConfig = (name: 'RTSP' | 'RTMP' | 'HLS' | 'HDL' | 'GB28181') => {
+  return request<string>({
+    url: `/api/updateconfig?name=${name}`,
+    method: 'GET'
+  })
+}
+
 /** 系统监控 */
 export const getSummary = () => {
   return request<RTS.SUMMARY.Detail>({

+ 8 - 3
src/controller/rts/rts.ts

@@ -1,4 +1,4 @@
-import { closeStream, createRtmpPull, createRtmpPush, createRtspPull, createRtspPush, getConfig, getPullList, getPushList, getRecording, getRecordList, getStreams, getSummary, playRecord, postRecord, stopPull, stopPush, stopRecord, updateConfig } from '@/api/rts/stream'
+import { closeStream, createRtmpPull, createRtmpPush, createRtspPull, createRtspPush, getConfig, getPullList, getPushList, getRecording, getRecordList, getStreams, getSummary, playRecord, postConfig, postRecord, stopPull, stopPush, stopRecord, updateConfig } from '@/api/rts/stream'
 import { message } from 'ant-design-vue'
 
 export class RtsController {
@@ -84,11 +84,16 @@ export class RtsController {
     return await getConfig(name)
   }
 
-  static async updateProtocol (name: 'RTSP' | 'RTMP' | 'HLS' | 'HDL' | 'GB28181', data: string) {
-    await updateConfig(name, data)
+  static async postProtocol (name: 'RTSP' | 'RTMP' | 'HLS' | 'HDL' | 'GB28181', data: string) {
+    await postConfig(name, data)
     message.success('修改协议成功')
   }
 
+  static async updateProtocol (name: 'RTSP' | 'RTMP' | 'HLS' | 'HDL' | 'GB28181') {
+    await updateConfig(name)
+    message.success('更新成功')
+  }
+
   static async summary () {
     return await getSummary()
   }

+ 14 - 4
src/pages/Iot/rule/linkRules.vue

@@ -50,12 +50,13 @@
 
   <modal-pro
     style="width: 1400px;"
-    :label=" state.opraState !== 'preview' ? '创建转发规则' : '查看详情'"
+    :label=" state.opraState !== 'preview' ? '创建联动规则' : '查看详情'"
     :visible="state.visible"
+    destroyOnClose
     @cancel="state.visible = false"
     @ok="ok"
   >
-    <div style="height: 750px;overflow: hidden;overflow-y: auto;">
+    <div style="height: 550px;overflow: hidden; overflow-y: auto;">
       <a-card
         title="基本信息"
         :bordered="false"
@@ -938,9 +939,19 @@ const changeConditionLogic = (record: string) => {
 }
 
 const openModal = (_opraState: 'add' | 'update' | 'preview', record: any) => {
+  resetFields({
+    ruleLabel: '',
+    ruleDescription: ''
+  })
+  bodyParamsState.conditionLogic = 'AND'
+  bodyParamsState.actions = []
+  bodyParamsState.conditions = []
+  bodyParamsState.id = ''
   state.visible = true
   state.opraState = _opraState
-  getLinkPageById(record.id)
+  if (record.id) {
+    getLinkPageById(record.id)
+  }
 }
 
 const ok = async () => {
@@ -1036,7 +1047,6 @@ const getModelList = async () => {
 
 const getLinkPageById = async (id: string) => {
   const { data } = await RuleController.getLinkById(id)
-  console.log(data)
   resetFields({
     ruleLabel: data.ruleLabel,
     ruleDescription: data.ruleDescription

+ 9 - 3
src/pages/rts/protocol/index.vue

@@ -15,7 +15,10 @@
         </a-select>
       </a-col>
       <a-col  >
-        <a-button type="primary" @click="saveProtocol"> 保存 </a-button>
+        <a-space>
+          <a-button type="primary" @click="saveProtocol"> 保存 </a-button>
+          <a-button type="primary" @click="reloadProtocol"> 更新 </a-button>
+        </a-space>
       </a-col>
     </a-row>
     <code-mirror-tsx
@@ -57,9 +60,12 @@ watch(
 )
 const { start, stop } = useScheduler(() => state.loading = false, 2000)
 
+const reloadProtocol = async () => {
+  await RtsController.updateProtocol(state.name as RTS.protocol)
+}
+
 const saveProtocol = async () => {
-  console.log()
-  await RtsController.updateProtocol(state.name as RTS.protocol, codeMirrorRef.value.getValue())
+  await RtsController.postProtocol(state.name as RTS.protocol, codeMirrorRef.value.getValue())
 }
 
 const getProtocol = async () => {