mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-14 01:34:47 +08:00
fix: 面板设置支持设置服务器域名 (#1778)
This commit is contained in:
parent
489efb7ac1
commit
ed0923fd28
@ -26,7 +26,7 @@ import { getSettingInfo } from '@/api/modules/setting';
|
||||
import i18n from '@/lang';
|
||||
import { MsgError } from '@/utils/message';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { checkIp } from '@/utils/util';
|
||||
import { checkDomain, checkIp } from '@/utils/util';
|
||||
const router = useRouter();
|
||||
|
||||
const dialogVisiable = ref();
|
||||
@ -45,7 +45,7 @@ const acceptParams = async (params: DialogProps): Promise<void> => {
|
||||
dialogVisiable.value = true;
|
||||
return;
|
||||
}
|
||||
if (!checkIp(res.data.systemIP)) {
|
||||
if (!checkIp(res.data.systemIP) || !checkDomain(res.data.systemIP)) {
|
||||
window.open(`http://${res.data.systemIP}:${params.port}`, '_blank');
|
||||
return;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ const checkIp = (rule: any, value: any, callback: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
const checkIpV4V6 = (rule: any, value: any, callback: any) => {
|
||||
const checkIpV4V6OrDomain = (rule: any, value: any, callback: any) => {
|
||||
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||
callback(new Error(i18n.global.t('commons.rule.requiredInput')));
|
||||
} else {
|
||||
@ -35,7 +35,8 @@ const checkIpV4V6 = (rule: any, value: any, callback: any) => {
|
||||
`(?::((?::${IPv6SegmentFormat}){0,5}:${IPv4AddressFormat}|(?::${IPv6SegmentFormat}){1,7}|:))` +
|
||||
')(%[0-9a-zA-Z-.:]{1,})?$',
|
||||
);
|
||||
if (!IPv4AddressRegExp.test(value) && !IPv6AddressRegExp.test(value) && value !== '') {
|
||||
const regHost = /^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/;
|
||||
if (!regHost.test(value) && !IPv4AddressRegExp.test(value) && !IPv6AddressRegExp.test(value) && value !== '') {
|
||||
callback(new Error(i18n.global.t('commons.rule.ip')));
|
||||
} else {
|
||||
callback();
|
||||
@ -429,7 +430,7 @@ interface CommonRule {
|
||||
integerNumberWith0: FormItemRule;
|
||||
floatNumber: FormItemRule;
|
||||
ip: FormItemRule;
|
||||
ipV4V6: FormItemRule;
|
||||
ipV4V6OrDomain: FormItemRule;
|
||||
host: FormItemRule;
|
||||
illegal: FormItemRule;
|
||||
port: FormItemRule;
|
||||
@ -546,8 +547,8 @@ export const Rules: CommonRule = {
|
||||
required: true,
|
||||
trigger: 'blur',
|
||||
},
|
||||
ipV4V6: {
|
||||
validator: checkIpV4V6,
|
||||
ipV4V6OrDomain: {
|
||||
validator: checkIpV4V6OrDomain,
|
||||
required: true,
|
||||
trigger: 'blur',
|
||||
},
|
||||
|
@ -165,6 +165,7 @@ const message = {
|
||||
integer: 'Please enter the correct positive integer',
|
||||
ip: 'Please enter the correct IP address',
|
||||
host: 'Enter the correct IP address or domain name',
|
||||
hostHelper: 'Support input of IP address or domain',
|
||||
port: 'Please enter the correct port',
|
||||
selectHelper: 'Please select the correct {0} file',
|
||||
domain: 'domain name format error',
|
||||
@ -590,7 +591,6 @@ const message = {
|
||||
volumeDir: 'Volume dir',
|
||||
nfsEnable: 'Enable NFS storage',
|
||||
nfsAddress: 'Address',
|
||||
nfsAddressHelper: 'Support input of IP address or domain',
|
||||
mountpoint: 'Mountpoint',
|
||||
mountpointNFSHelper: 'e.g. /nfs, /nfs-share',
|
||||
options: 'Options',
|
||||
@ -961,8 +961,8 @@ const message = {
|
||||
sessionTimeoutError: 'The minimum timeout is 300 seconds',
|
||||
sessionTimeoutHelper:
|
||||
'If you do not operate the panel for more than {0} seconds, the panel automatically logs out',
|
||||
systemIP: 'System IP',
|
||||
systemIPWarning: 'The server IP is not currently set. Please set it in the control panel first!',
|
||||
systemIP: 'System Address',
|
||||
systemIPWarning: 'The server address is not currently set. Please set it in the control panel first!',
|
||||
syncTime: 'Server time',
|
||||
timeZone: 'Time Zone',
|
||||
timeZoneChangeHelper: 'Changing the time zone requires restarting the service. Do you want to continue?',
|
||||
|
@ -165,6 +165,7 @@ const message = {
|
||||
integer: '請輸入正確的正整數',
|
||||
ip: '請輸入正確的 IP 地址',
|
||||
host: '請輸入正確的 IP 或者域名',
|
||||
hostHelper: '支持輸入 ip 或者域名',
|
||||
port: '請輸入正確的端口,1-65535',
|
||||
selectHelper: '請選擇正確的 {0} 文件',
|
||||
domain: '域名格式錯誤',
|
||||
@ -580,7 +581,6 @@ const message = {
|
||||
volumeDir: '存儲卷目錄',
|
||||
nfsEnable: '啟用 NFS 存儲',
|
||||
nfsAddress: '地址',
|
||||
nfsAddressHelper: '支持輸入 ip 或者域名',
|
||||
mountpoint: '掛載點',
|
||||
mountpointNFSHelper: '例:/nfs, /nfs-share',
|
||||
options: '可選參數',
|
||||
@ -929,8 +929,8 @@ const message = {
|
||||
sessionTimeout: '超時時間',
|
||||
sessionTimeoutError: '最小超時時間為 300 秒',
|
||||
sessionTimeoutHelper: '如果用戶超過 {0} 秒未操作面板,面板將自動退出登錄',
|
||||
systemIP: '服務器 IP',
|
||||
systemIPWarning: '當前未設置服務器 IP,請先在面板設置中設置!',
|
||||
systemIP: '服務器地址',
|
||||
systemIPWarning: '當前未設置服務器地址,請先在面板設置中設置!',
|
||||
syncTime: '服務器時間',
|
||||
timeZone: '系統時區',
|
||||
timeZoneChangeHelper: '系統時區修改需要重啟服務,是否繼續?',
|
||||
|
@ -165,6 +165,7 @@ const message = {
|
||||
integer: '请输入正确的正整数',
|
||||
ip: '请输入正确的 IP 地址',
|
||||
host: '请输入正确的 IP 或者域名',
|
||||
hostHelper: '支持输入 ip 或者域名',
|
||||
port: '请输入正确的端口,1-65535',
|
||||
selectHelper: '请选择正确的 {0} 文件',
|
||||
domain: '域名格式错误',
|
||||
@ -580,7 +581,6 @@ const message = {
|
||||
volumeDir: '存储卷目录',
|
||||
nfsEnable: '启用 NFS 存储',
|
||||
nfsAddress: '地址',
|
||||
nfsAddressHelper: '支持输入 ip 或者域名',
|
||||
mountpoint: '挂载点',
|
||||
mountpointNFSHelper: '例:/nfs, /nfs-share',
|
||||
options: '可选参数',
|
||||
@ -929,8 +929,8 @@ const message = {
|
||||
sessionTimeout: '超时时间',
|
||||
sessionTimeoutError: '最小超时时间为 300 秒',
|
||||
sessionTimeoutHelper: '如果用户超过 {0} 秒未操作面板,面板将自动退出登录',
|
||||
systemIP: '服务器 IP',
|
||||
systemIPWarning: '当前未设置服务器 IP,请先在面板设置中设置!',
|
||||
systemIP: '服务器地址',
|
||||
systemIPWarning: '当前未设置服务器地址,请先在面板设置中设置!',
|
||||
syncTime: '服务器时间',
|
||||
timeZone: '系统时区',
|
||||
timeZoneChangeHelper: '系统时区修改需要重启服务,是否继续?',
|
||||
|
@ -185,6 +185,18 @@ export function checkIp(value: string): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
export function checkDomain(value: string): boolean {
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
const reg = /^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/;
|
||||
if (!reg.test(value) && value !== '') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function checkIpV4V6(value: string): boolean {
|
||||
if (value === '') {
|
||||
return true;
|
||||
|
@ -28,7 +28,7 @@
|
||||
<el-input
|
||||
clearable
|
||||
v-model.trim="form.nfsAddress"
|
||||
:placeholder="$t('container.nfsAddressHelper')"
|
||||
:placeholder="$t('commons.rule.hostHelper')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('container.version')" prop="nfsVersion">
|
||||
|
@ -13,7 +13,11 @@
|
||||
<el-form ref="formRef" label-position="top" :model="form" @submit.prevent v-loading="loading">
|
||||
<el-row type="flex" justify="center">
|
||||
<el-col :span="22">
|
||||
<el-form-item :label="$t('ssh.listenAddress')" prop="listenAddress" :rules="Rules.ipV4V6">
|
||||
<el-form-item
|
||||
:label="$t('ssh.listenAddress')"
|
||||
prop="listenAddress"
|
||||
:rules="Rules.ipV4V6OrDomain"
|
||||
>
|
||||
<el-input clearable v-model="form.listenAddress" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
@ -7,8 +7,9 @@
|
||||
<el-form ref="formRef" label-position="top" :model="form" @submit.prevent v-loading="loading">
|
||||
<el-row type="flex" justify="center">
|
||||
<el-col :span="22">
|
||||
<el-form-item :label="$t('setting.systemIP')" prop="systemIP" :rules="Rules.ipV4V6">
|
||||
<el-form-item :label="$t('setting.systemIP')" prop="systemIP" :rules="Rules.ipV4V6OrDomain">
|
||||
<el-input clearable v-model="form.systemIP" />
|
||||
<span class="input-help">{{ $t('commons.rule.hostHelper') }}</span>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
Loading…
x
Reference in New Issue
Block a user