From b2e17d4c4210ec6167a86e40681c8b1e115b3b71 Mon Sep 17 00:00:00 2001
From: zhengkunwang223 <31820853+zhengkunwang223@users.noreply.github.com>
Date: Sat, 3 Jun 2023 13:21:20 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E9=98=B2=E7=9B=97=E9=93=BE=E5=93=8D?=
=?UTF-8?q?=E5=BA=94=E5=A2=9E=E5=8A=A0=E7=8A=B6=E6=80=81=E7=A0=81=E5=88=A4?=
=?UTF-8?q?=E6=96=AD=20(#1242)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
frontend/src/lang/modules/en.ts | 1 +
frontend/src/lang/modules/zh.ts | 1 +
.../website/config/basic/anti-Leech/index.vue | 27 +++++++++++++++++--
3 files changed, 27 insertions(+), 2 deletions(-)
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();
});