From 3f52c079af2e8bebfbc25a3a07fbc1a1979d78af Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Tue, 6 Dec 2022 16:50:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0URL=E9=BB=91=E7=99=BD?= =?UTF-8?q?=E5=90=8D=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/lang/modules/zh.ts | 4 +- .../index.vue | 46 ++---- .../website/website/config/safety/index.vue | 22 ++- .../{ip-white-list => ip-list}/index.vue | 12 +- .../website/config/safety/url-list/index.vue | 134 ++++++++++++++++++ 5 files changed, 175 insertions(+), 43 deletions(-) rename frontend/src/views/website/website/config/safety/{ip-block-list => file-block-list}/index.vue (74%) rename frontend/src/views/website/website/config/safety/{ip-white-list => ip-list}/index.vue (94%) create mode 100644 frontend/src/views/website/website/config/safety/url-list/index.vue diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index fa2eafe60..38b243be7 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -856,7 +856,9 @@ export default { ccHelper: '{0} 秒内累计请求同一URL超过 {1} 次,触发CC防御,封锁此IP', seconds: '秒', count: '次', - mustSave: '修改之后需要保存才能生效,不合法的IP不会保存', + mustSave: '修改之后需要保存才能生效', + fileExt: '文件扩展名', + fileExtBlock: '文件扩展名黑名单', }, nginx: { serverNamesHashBucketSizeHelper: '服务器名字的hash表大小', diff --git a/frontend/src/views/website/website/config/safety/ip-block-list/index.vue b/frontend/src/views/website/website/config/safety/file-block-list/index.vue similarity index 74% rename from frontend/src/views/website/website/config/safety/ip-block-list/index.vue rename to frontend/src/views/website/website/config/safety/file-block-list/index.vue index 50f00ecbd..f0ca4d8a4 100644 --- a/frontend/src/views/website/website/config/safety/ip-block-list/index.vue +++ b/frontend/src/views/website/website/config/safety/file-block-list/index.vue @@ -7,18 +7,18 @@ {{ $t('commons.button.add') }} - + @@ -41,7 +41,6 @@ import ComplexTable from '@/components/complex-table/index.vue'; import { SaveFileContent } from '@/api/modules/files'; import { ElMessage } from 'element-plus'; import i18n from '@/lang'; -import { checkIp } from '@/utils/util'; const props = defineProps({ id: { @@ -58,7 +57,7 @@ let data = ref([]); let req = ref({ websiteId: 0, key: '', - rule: 'ipBlocklist', + rule: 'blackfileExt', }); let fileUpdate = reactive({ path: '', @@ -75,7 +74,7 @@ const get = async () => { const ipList = JSON.parse(res.data.content); ipList.forEach((value) => { data.value.push({ - ip: value, + file: value, eidt: false, error: '', }); @@ -85,51 +84,34 @@ const get = async () => { fileUpdate.path = res.data.filePath; }; -const removeIp = (index: number) => { +const remove = (index: number) => { data.value.splice(index, 1); }; const openCreate = () => { - data.value.unshift({ id: '', edit: true, error: '' }); + data.value.unshift({ file: '', edit: true, error: '' }); }; const submit = async () => { - let canCommit = true; - for (const row of data.value) { - console.log(row.ip); - console.log(row.error); - if (row.ip != '' && row.error != '') { - row.edit = true; - canCommit = false; - } - } - if (!canCommit) { - return; - } - let ipArray = []; + let fileArray = []; data.value.forEach((row) => { - ipArray.push(row.ip); + if (row.file != '') { + fileArray.push(row.file); + } }); - fileUpdate.content = JSON.stringify(ipArray); + fileUpdate.content = JSON.stringify(fileArray); loading.value = true; SaveFileContent(fileUpdate) .then(() => { ElMessage.success(i18n.global.t('commons.msg.updateSuccess')); + get(); }) .finally(() => { loading.value = false; }); }; -const checkIpRule = (row: any) => { - if (checkIp(row.ip)) { - row.error = i18n.global.t('commons.rule.ip'); - } else { - row.error = ''; - } -}; - onMounted(() => { req.value.websiteId = id.value; get(); diff --git a/frontend/src/views/website/website/config/safety/index.vue b/frontend/src/views/website/website/config/safety/index.vue index 2901467fd..1acfd2cd4 100644 --- a/frontend/src/views/website/website/config/safety/index.vue +++ b/frontend/src/views/website/website/config/safety/index.vue @@ -3,22 +3,30 @@ - - + + - + + + + + + + + + + - - diff --git a/frontend/src/views/website/website/config/safety/url-list/index.vue b/frontend/src/views/website/website/config/safety/url-list/index.vue new file mode 100644 index 000000000..75aea688a --- /dev/null +++ b/frontend/src/views/website/website/config/safety/url-list/index.vue @@ -0,0 +1,134 @@ + +