mirror of
https://gitee.com/fit2cloud-feizhiyun/1Panel.git
synced 2024-11-30 02:47:51 +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',
|
||||
disableLeech: 'Disable anti-leech',
|
||||
ipv6: 'Listen IPV6',
|
||||
leechReturnError: 'Please fill in the HTTP status code',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: 'Short tag support',
|
||||
|
@ -1379,6 +1379,7 @@ const message = {
|
||||
disableLeechHelper: '是否禁用防盗链',
|
||||
disableLeech: '禁用防盗链',
|
||||
ipv6: '监听 IPV6 端口',
|
||||
leechReturnError: '请填写 HTTP 状态码',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: '短标签支持',
|
||||
|
@ -37,7 +37,7 @@
|
||||
<el-form-item :label="$t('website.noneRef')" prop="noneRef">
|
||||
<el-switch v-model="form.noneRef" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('website.accessDomain')" prop="serverNames">
|
||||
<el-form-item :label="$t('website.accessDomain')" prop="domains">
|
||||
<el-input
|
||||
v-model="form.domains"
|
||||
type="textarea"
|
||||
@ -64,7 +64,7 @@ import { FormInstance } from 'element-plus';
|
||||
import { computed, onMounted, reactive } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
import { Units } from '@/global/mimetype';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { MsgSuccess, MsgError } from '@/utils/message';
|
||||
import i18n from '@/lang';
|
||||
|
||||
const loading = ref(false);
|
||||
@ -100,6 +100,7 @@ const rules = ref({
|
||||
extends: [Rules.requiredInput, Rules.leechExts],
|
||||
cacheTime: [Rules.requiredInput, checkNumberRange(1, 65535)],
|
||||
return: [Rules.requiredInput],
|
||||
domains: [Rules.requiredInput],
|
||||
});
|
||||
|
||||
const changeEnable = (enable: boolean) => {
|
||||
@ -177,6 +178,9 @@ const update = async (enable: boolean) => {
|
||||
if (enable) {
|
||||
form.serverNames = form.domains.split('\n');
|
||||
}
|
||||
if (!checkReturn()) {
|
||||
return;
|
||||
}
|
||||
form.enable = enable;
|
||||
loading.value = true;
|
||||
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(() => {
|
||||
search();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user