mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-12 11:30:07 +08:00
feat: 防盗链响应增加状态码判断 (#1242)
This commit is contained in:
parent
b88303d36a
commit
b2e17d4c42
@ -1410,6 +1410,7 @@ const message = {
|
|||||||
disableLeechHelper: 'Whether to disable the anti-leech',
|
disableLeechHelper: 'Whether to disable the anti-leech',
|
||||||
disableLeech: 'Disable anti-leech',
|
disableLeech: 'Disable anti-leech',
|
||||||
ipv6: 'Listen IPV6',
|
ipv6: 'Listen IPV6',
|
||||||
|
leechReturnError: 'Please fill in the HTTP status code',
|
||||||
},
|
},
|
||||||
php: {
|
php: {
|
||||||
short_open_tag: 'Short tag support',
|
short_open_tag: 'Short tag support',
|
||||||
|
@ -1379,6 +1379,7 @@ const message = {
|
|||||||
disableLeechHelper: '是否禁用防盗链',
|
disableLeechHelper: '是否禁用防盗链',
|
||||||
disableLeech: '禁用防盗链',
|
disableLeech: '禁用防盗链',
|
||||||
ipv6: '监听 IPV6 端口',
|
ipv6: '监听 IPV6 端口',
|
||||||
|
leechReturnError: '请填写 HTTP 状态码',
|
||||||
},
|
},
|
||||||
php: {
|
php: {
|
||||||
short_open_tag: '短标签支持',
|
short_open_tag: '短标签支持',
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
<el-form-item :label="$t('website.noneRef')" prop="noneRef">
|
<el-form-item :label="$t('website.noneRef')" prop="noneRef">
|
||||||
<el-switch v-model="form.noneRef" />
|
<el-switch v-model="form.noneRef" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('website.accessDomain')" prop="serverNames">
|
<el-form-item :label="$t('website.accessDomain')" prop="domains">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.domains"
|
v-model="form.domains"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
@ -64,7 +64,7 @@ import { FormInstance } from 'element-plus';
|
|||||||
import { computed, onMounted, reactive } from 'vue';
|
import { computed, onMounted, reactive } from 'vue';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { Units } from '@/global/mimetype';
|
import { Units } from '@/global/mimetype';
|
||||||
import { MsgSuccess } from '@/utils/message';
|
import { MsgSuccess, MsgError } from '@/utils/message';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
@ -100,6 +100,7 @@ const rules = ref({
|
|||||||
extends: [Rules.requiredInput, Rules.leechExts],
|
extends: [Rules.requiredInput, Rules.leechExts],
|
||||||
cacheTime: [Rules.requiredInput, checkNumberRange(1, 65535)],
|
cacheTime: [Rules.requiredInput, checkNumberRange(1, 65535)],
|
||||||
return: [Rules.requiredInput],
|
return: [Rules.requiredInput],
|
||||||
|
domains: [Rules.requiredInput],
|
||||||
});
|
});
|
||||||
|
|
||||||
const changeEnable = (enable: boolean) => {
|
const changeEnable = (enable: boolean) => {
|
||||||
@ -177,6 +178,9 @@ const update = async (enable: boolean) => {
|
|||||||
if (enable) {
|
if (enable) {
|
||||||
form.serverNames = form.domains.split('\n');
|
form.serverNames = form.domains.split('\n');
|
||||||
}
|
}
|
||||||
|
if (!checkReturn()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
form.enable = enable;
|
form.enable = enable;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
form.websiteID = id.value;
|
form.websiteID = id.value;
|
||||||
@ -190,6 +194,25 @@ const update = async (enable: boolean) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkReturn = (): boolean => {
|
||||||
|
let returns = form.return.split(' ');
|
||||||
|
if (returns[0]) {
|
||||||
|
if (isHttpStatusCode(returns[0])) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
MsgError(i18n.global.t('website.leechReturnError'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function isHttpStatusCode(input: string): boolean {
|
||||||
|
const statusCodeRegex = /^[1-5][0-9]{2}$/;
|
||||||
|
return statusCodeRegex.test(input);
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
search();
|
search();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user