Skip to content

Commit d572c28

Browse files
ssongliuwanghe-fit2cloud
authored andcommitted
fix: 服务器地址支持设置为空 (#2016)
1 parent 7fac0fc commit d572c28

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

frontend/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html>
33
<head>
44
<meta charset="UTF-8" />
55
<link rel="icon" href="/public/favicon.png" />

frontend/src/views/setting/panel/systemip/index.vue

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44
<template #header>
55
<DrawerHeader :header="$t('setting.systemIP')" :back="handleClose" />
66
</template>
7-
<el-form ref="formRef" label-position="top" :model="form" @submit.prevent v-loading="loading">
7+
<el-form
8+
ref="formRef"
9+
label-position="top"
10+
:model="form"
11+
:rules="rules"
12+
@submit.prevent
13+
v-loading="loading"
14+
>
815
<el-row type="flex" justify="center">
916
<el-col :span="22">
10-
<el-form-item :label="$t('setting.systemIP')" prop="systemIP" :rules="Rules.ipV4V6OrDomain">
17+
<el-form-item :label="$t('setting.systemIP')" prop="systemIP">
1118
<el-input clearable v-model="form.systemIP" />
1219
<span class="input-help">{{ $t('commons.rule.hostHelper') }}</span>
1320
</el-form-item>
@@ -31,8 +38,8 @@ import i18n from '@/lang';
3138
import { MsgSuccess } from '@/utils/message';
3239
import { updateSetting } from '@/api/modules/setting';
3340
import { FormInstance } from 'element-plus';
34-
import { Rules } from '@/global/form-rules';
3541
import DrawerHeader from '@/components/drawer-header/index.vue';
42+
import { checkDomain, checkIpV4V6 } from '@/utils/util';
3643
3744
const emit = defineEmits<{ (e: 'search'): void }>();
3845
@@ -47,6 +54,18 @@ const form = reactive({
4754
});
4855
4956
const formRef = ref<FormInstance>();
57+
const rules = reactive({
58+
systemIP: [{ validator: checkSystemIP, trigger: 'blur' }],
59+
});
60+
61+
function checkSystemIP(rule: any, value: any, callback: any) {
62+
if (form.systemIP !== '') {
63+
if (checkIpV4V6(form.systemIP) && checkDomain(form.systemIP)) {
64+
return callback(new Error(i18n.global.t('commons.rule.host')));
65+
}
66+
}
67+
callback();
68+
}
5069
5170
const acceptParams = (params: DialogProps): void => {
5271
form.systemIP = params.systemIP;

0 commit comments

Comments
 (0)