fix: 解决反代域名失败的问题 (#2821)

This commit is contained in:
zhengkunwang 2023-11-06 20:11:28 +08:00 committed by GitHub
parent ce38ae2544
commit 8d9b21e4a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 2 deletions

View file

@ -208,6 +208,18 @@ export function checkDomain(value: string): boolean {
}
}
export function isDomain(value: string): boolean {
if (value === '') {
return true;
}
const reg = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$/i;
if (value !== '' && reg.test(value)) {
return true;
} else {
return false;
}
}
export function checkIpV4V6(value: string): boolean {
if (value === '') {
return true;

View file

@ -38,7 +38,11 @@
<el-row :gutter="10">
<el-col :span="12">
<el-form-item :label="$t('website.proxyPass')" prop="proxyPass">
<el-input v-model.trim="proxy.proxyAddress" :placeholder="$t('website.proxyHelper')">
<el-input
v-model.trim="proxy.proxyAddress"
:placeholder="$t('website.proxyHelper')"
@blur="getProxyHost"
>
<template #prepend>
<el-select v-model="proxy.proxyProtocol" class="pre-select">
<el-option label="http" value="http://" />
@ -116,6 +120,7 @@ import { ref } from 'vue';
import { MsgError, MsgSuccess } from '@/utils/message';
import { Website } from '@/api/interface/website';
import { Units } from '@/global/mimetype';
import { isDomain } from '@/utils/util';
const proxyForm = ref<FormInstance>();
const rules = ref({
@ -193,6 +198,14 @@ const removeReplace = (index: number) => {
replaces.value.splice(index, 1);
};
const getProxyHost = () => {
if (isDomain(proxy.value.proxyAddress)) {
proxy.value.proxyHost = proxy.value.proxyAddress;
} else {
proxy.value.proxyHost = '$host';
}
};
const submit = async (formEl: FormInstance | undefined) => {
if (!formEl) return;
await formEl.validate((valid) => {

View file

@ -2,7 +2,7 @@
<el-row>
<el-col :xs="24" :sm="18" :md="14" :lg="14" :xl="14">
<el-form>
<el-form-item prop="enable" :label="$t('website.enable')">
<el-form-item prop="enable" :label="$t('website.enable')" v-if="rule != 'user_agent'">
<el-switch v-model="enableUpdate.enable" @change="updateEnable"></el-switch>
</el-form-item>
<el-form-item :label="$t('website.data')">