|
|
@@ -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
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
})
|