Просмотр исходного кода

优化网络配置修改的问题

liujintao 1 месяц назад
Родитель
Сommit
32d310a444

+ 4 - 4
src/views/settings/audioVideo/components/video/index.vue

@@ -207,10 +207,10 @@ const realtimeMode = ref(false)
 // 主码流分辨率选项
 const mainResolutionOptions = [
   {value: 5, label: '2880*1620 (5M)'},
-  {value: 4, label: '2560*1440 (4M)'},
-  {value: 3, label: '2304*1296 (3M)'},
-  {value: 2, label: '1920*1080 (1080P)'},
-  {value: 1, label: '1280*720 (720P)'}
+  // {value: 4, label: '2560*1440 (4M)'},
+  {value: 3, label: '2304*1296 (3M)'}
+  // {value: 2, label: '1920*1080 (1080P)'},
+  // {value: 1, label: '1280*720 (720P)'}
   // { value: 0, label: '640*360' },
 ]
 

+ 20 - 6
src/views/settings/netSettings/components/IP/index.vue

@@ -214,11 +214,14 @@ const switchChange = ($event: number) => {
 
 const param = { NIC: 1 }
 
+const originalIpAddress = ref('')
+
 /** 获取表单数据 */
 const fetchData = () => {
   getUserSettingApi(param.NIC).then((res) => {
     settingFormData.enableDHCP = res.data.enableDHCP
     settingFormData.ipAddress = res.data.ipAddress
+    originalIpAddress.value = res.data.ipAddress
     settingFormData.subNetAddress = res.data.subNetAddress
     settingFormData.gateWayAddress = res.data.gateWayAddress
     settingFormData.deviceMac = res.data.deviceMac
@@ -232,22 +235,33 @@ fetchData()
 const handleSave = () => {
   settingFormRef.value?.validate((valid: boolean, fields) => {
     if (valid) {
-      ElMessageBox.confirm('Changing the network configuration will restart the device', 'Note', {
+      const ipChanged = settingFormData.ipAddress !== originalIpAddress.value
+      const confirmMsg = ipChanged
+        ? 'The IP address has been changed. Please click OK to redirect to the new IP address.'
+        : 'Are you sure you want to save the changes?'
+      const confirmTitle = ipChanged ? 'IP Address Changed' : 'Confirm'
+      ElMessageBox.confirm(confirmMsg, confirmTitle, {
         confirmButtonText: 'OK',
         cancelButtonText: 'Cancel',
-        type: 'warning',
-        confirmButtonClass: 'el-button--danger'
+        type: 'warning'
       }).then(() => {
         loading.value = true
         putUserSettingApi(param.NIC, settingFormData)
           .then(() => {
-            ElMessage.success('Operation successful. Please wait a moment...')
-            useUserStore().logout()
-            router.push('/login')
+            if (ipChanged) {
+              const newUrl = window.location.href.replace(window.location.hostname, settingFormData.ipAddress)
+              window.location.href = newUrl
+            } else {
+              ElMessage.success('Operation successful')
+            }
           })
           .finally(() => {
             loading.value = false
           })
+      }).catch(() => {
+        if (ipChanged) {
+          settingFormData.ipAddress = originalIpAddress.value
+        }
       })
     }
   })