diff --git a/backend/app/service/clam.go b/backend/app/service/clam.go index 4cfbec83c..bb020152c 100644 --- a/backend/app/service/clam.go +++ b/backend/app/service/clam.go @@ -135,6 +135,9 @@ func (f *ClamService) Create(req dto.ClamCreate) error { if err := copier.Copy(&clam, &req); err != nil { return errors.WithMessage(constant.ErrStructTransform, err.Error()) } + if clam.InfectedStrategy == "none" || clam.InfectedStrategy == "remove" { + clam.InfectedDir = "" + } if err := clamRepo.Create(&clam); err != nil { return err } @@ -146,9 +149,14 @@ func (f *ClamService) Update(req dto.ClamUpdate) error { if clam.ID == 0 { return constant.ErrRecordNotFound } + if req.InfectedStrategy == "none" || req.InfectedStrategy == "remove" { + req.InfectedDir = "" + } upMap := map[string]interface{}{} upMap["name"] = req.Name upMap["path"] = req.Path + upMap["infected_dir"] = req.InfectedDir + upMap["infected_strategy"] = req.InfectedStrategy upMap["description"] = req.Description if err := clamRepo.Update(req.ID, upMap); err != nil { return err diff --git a/frontend/src/api/modules/toolbox.ts b/frontend/src/api/modules/toolbox.ts index aa5f529d3..0fdcafce3 100644 --- a/frontend/src/api/modules/toolbox.ts +++ b/frontend/src/api/modules/toolbox.ts @@ -127,7 +127,7 @@ export const searchClamBaseInfo = () => { return http.post(`/toolbox/clam/base`); }; export const updateClamBaseInfo = (operate: string) => { - return http.post(`/toolbox/clam/operate`, { Operation: operate }); + return http.post(`/toolbox/clam/operate`, { Operation: operate }, TimeoutEnum.T_60S); }; export const searchClam = (param: ReqPage) => { return http.post>(`/toolbox/clam/search`, param); diff --git a/frontend/src/views/host/firewall/forward/operate/index.vue b/frontend/src/views/host/firewall/forward/operate/index.vue index 29b932581..6f2fe21c6 100644 --- a/frontend/src/views/host/firewall/forward/operate/index.vue +++ b/frontend/src/views/host/firewall/forward/operate/index.vue @@ -53,12 +53,12 @@ import { reactive, ref } from 'vue'; import { Rules } from '@/global/form-rules'; import i18n from '@/lang'; -import { ElForm, FormItemRule } from 'element-plus'; +import { ElForm } from 'element-plus'; import DrawerHeader from '@/components/drawer-header/index.vue'; import { MsgSuccess } from '@/utils/message'; import { Host } from '@/api/interface/host'; import { operateForwardRule } from '@/api/modules/host'; -import { checkCidr, checkIpV4V6, deepCopy } from '@/utils/util'; +import { checkCidr, checkIpV4V6, checkPort, deepCopy } from '@/utils/util'; const loading = ref(); const oldRule = ref(); @@ -87,23 +87,22 @@ const handleClose = () => { drawerVisible.value = false; }; -const strPortValidator: FormItemRule = { - required: true, - trigger: 'blur', - validator: (_, value: string) => { - const port = parseInt(value); - return port >= 1 && port <= 65535; - }, - message: i18n.global.t('commons.rule.port'), -}; - const rules = reactive({ protocol: [Rules.requiredSelect], - port: [Rules.requiredInput, strPortValidator], - targetPort: [Rules.requiredInput, strPortValidator], + port: [{ validator: checkPortRule, trigger: 'blur' }], + targetPort: [{ validator: checkPortRule, trigger: 'blur' }], targetIP: [{ validator: checkAddress, trigger: 'blur' }], }); +function checkPortRule(rule: any, value: string, callback: any) { + if (!value) { + return callback(); + } + if (checkPort(value)) { + return callback(new Error(i18n.global.t('firewall.portFormatError'))); + } + callback(); +} function checkAddress(rule: any, value: string, callback: any) { if (!value) { return callback(); diff --git a/frontend/src/views/toolbox/clam/index.vue b/frontend/src/views/toolbox/clam/index.vue index 7377d053b..d6eadbb95 100644 --- a/frontend/src/views/toolbox/clam/index.vue +++ b/frontend/src/views/toolbox/clam/index.vue @@ -151,7 +151,7 @@ const data = ref(); const paginationConfig = reactive({ cacheSizeKey: 'clam-page-size', currentPage: 1, - pageSize: Number(localStorage.getItem('ftp-page-size')) || 10, + pageSize: Number(localStorage.getItem('clam-page-size')) || 10, total: 0, orderBy: 'created_at', order: 'null',