Pārlūkot izejas kodu

refactor: change the format of recoveryCardIP to rtsp address

Casper Dai 3 gadi atpakaļ
vecāks
revīzija
380847b6ba

+ 4 - 0
src/utils/validate.js

@@ -18,6 +18,10 @@ export function validIPv4 (ip) {
   return /^((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))).){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))$/.test(ip)
 }
 
+export function validIPv4Address (address) {
+  return /^[a-z]+:\/\/((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))).){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))(:[1-9]\d{1,4})?$/.test(address)
+}
+
 export function validIPv6 (ip) {
   if (ip === '::') {
     return true

+ 5 - 1
src/views/realm/debug/simulator/simulate.js

@@ -54,12 +54,16 @@ function createProxyClient ({ productId, deviceId, username, password }, resolve
   })
 
   client.on('error', e => {
-    console.log('Simulate MQTT connection error: ', e)
+    console.log('Simulate MQTT error: ', e)
     client?.end(true)
   })
 
   client.on('connect', () => {
     console.log('Simulate MQTT connected')
+    if (!client) {
+      console.log('Simulate MQTT client released')
+      return
+    }
     clearTimeout(timer)
     timer = setTimeout(() => {
       reconnect = 0

+ 11 - 12
src/views/realm/device/settings/components/AttributeConfigDialog.vue

@@ -4,21 +4,20 @@
     title="属性配置"
     @confirm="onSave"
   >
-    <div class="c-grid-form mini u-align-self--center">
-      <span class="c-grid-form__label">回采卡IP</span>
-      <div class="l-flex--row c-grid-form__option">
-        <el-input
-          v-model.trim="attributes.recoveryCardIP"
-          placeholder="192.168.0.11"
-          maxlength="15"
-        />
-      </div>
+    <div class="c-grid-form medium u-align-self--center">
+      <span class="c-grid-form__label">回采卡推流地址</span>
+      <el-input
+        v-model.trim="attributes.recoveryCardIP"
+        class="c-grid-form__option"
+        placeholder="rtsp://192.168.0.11:8554"
+        clearable
+      />
     </div>
   </confirm-dialog>
 </template>
 
 <script>
-import { validIPv4 } from '@/utils/validate'
+import { validIPv4Address } from '@/utils/validate'
 import {
   getAttributes,
   updateAttributes
@@ -26,8 +25,8 @@ import {
 
 const attributeSet = [
   { key: 'recoveryCardIP', valid (val) {
-    if (val && !validIPv4(val)) {
-      return '回采卡IP格式错误'
+    if (val && !validIPv4Address(val)) {
+      return '回采卡推流地址格式错误'
     }
     return null
   } }