Skip to content

Commit 8d9b21e

Browse files
fix: 解决反代域名失败的问题 (#2821)
1 parent ce38ae2 commit 8d9b21e

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

frontend/src/utils/util.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,18 @@ export function checkDomain(value: string): boolean {
208208
}
209209
}
210210

211+
export function isDomain(value: string): boolean {
212+
if (value === '') {
213+
return true;
214+
}
215+
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;
216+
if (value !== '' && reg.test(value)) {
217+
return true;
218+
} else {
219+
return false;
220+
}
221+
}
222+
211223
export function checkIpV4V6(value: string): boolean {
212224
if (value === '') {
213225
return true;

frontend/src/views/website/website/config/basic/proxy/create/index.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@
3838
<el-row :gutter="10">
3939
<el-col :span="12">
4040
<el-form-item :label="$t('website.proxyPass')" prop="proxyPass">
41-
<el-input v-model.trim="proxy.proxyAddress" :placeholder="$t('website.proxyHelper')">
41+
<el-input
42+
v-model.trim="proxy.proxyAddress"
43+
:placeholder="$t('website.proxyHelper')"
44+
@blur="getProxyHost"
45+
>
4246
<template #prepend>
4347
<el-select v-model="proxy.proxyProtocol" class="pre-select">
4448
<el-option label="http" value="http://" />
@@ -116,6 +120,7 @@ import { ref } from 'vue';
116120
import { MsgError, MsgSuccess } from '@/utils/message';
117121
import { Website } from '@/api/interface/website';
118122
import { Units } from '@/global/mimetype';
123+
import { isDomain } from '@/utils/util';
119124
120125
const proxyForm = ref<FormInstance>();
121126
const rules = ref({
@@ -193,6 +198,14 @@ const removeReplace = (index: number) => {
193198
replaces.value.splice(index, 1);
194199
};
195200
201+
const getProxyHost = () => {
202+
if (isDomain(proxy.value.proxyAddress)) {
203+
proxy.value.proxyHost = proxy.value.proxyAddress;
204+
} else {
205+
proxy.value.proxyHost = '$host';
206+
}
207+
};
208+
196209
const submit = async (formEl: FormInstance | undefined) => {
197210
if (!formEl) return;
198211
await formEl.validate((valid) => {

frontend/src/views/website/website/config/safety/value-list/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<el-row>
33
<el-col :xs="24" :sm="18" :md="14" :lg="14" :xl="14">
44
<el-form>
5-
<el-form-item prop="enable" :label="$t('website.enable')">
5+
<el-form-item prop="enable" :label="$t('website.enable')" v-if="rule != 'user_agent'">
66
<el-switch v-model="enableUpdate.enable" @change="updateEnable"></el-switch>
77
</el-form-item>
88
<el-form-item :label="$t('website.data')">

0 commit comments

Comments
 (0)