diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts
index f871daaa0..6a787f635 100644
--- a/frontend/src/lang/modules/en.ts
+++ b/frontend/src/lang/modules/en.ts
@@ -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',
diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts
index 14ab77384..7908085f8 100644
--- a/frontend/src/lang/modules/zh.ts
+++ b/frontend/src/lang/modules/zh.ts
@@ -1379,6 +1379,7 @@ const message = {
disableLeechHelper: '是否禁用防盗链',
disableLeech: '禁用防盗链',
ipv6: '监听 IPV6 端口',
+ leechReturnError: '请填写 HTTP 状态码',
},
php: {
short_open_tag: '短标签支持',
diff --git a/frontend/src/views/website/website/config/basic/anti-Leech/index.vue b/frontend/src/views/website/website/config/basic/anti-Leech/index.vue
index 4eff3dfb0..ff148ba12 100644
--- a/frontend/src/views/website/website/config/basic/anti-Leech/index.vue
+++ b/frontend/src/views/website/website/config/basic/anti-Leech/index.vue
@@ -37,7 +37,7 @@
-
+
{
@@ -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();
});