diff --git a/backend/app/service/clam.go b/backend/app/service/clam.go index d30f76efb..d96c0dc0b 100644 --- a/backend/app/service/clam.go +++ b/backend/app/service/clam.go @@ -81,7 +81,6 @@ func (c *ClamService) LoadBaseInfo() (dto.ClamBaseInfo, error) { } if !cmd.Which("clamdscan") { baseInfo.IsActive = false - stopAllCronJob() } if baseInfo.IsActive { @@ -93,6 +92,8 @@ func (c *ClamService) LoadBaseInfo() (dto.ClamBaseInfo, error) { baseInfo.Version = strings.TrimPrefix(version, "ClamAV ") } } + } else { + _ = StopAllCronJob(false) } if baseInfo.FreshIsActive { version, err := cmd.Exec("freshclam --version") @@ -269,8 +270,7 @@ func (c *ClamService) Delete(req dto.ClamDelete) error { } func (c *ClamService) HandleOnce(req dto.OperateByID) error { - if !cmd.Which("clamdscan") { - stopAllCronJob() + if cleaned := StopAllCronJob(true); cleaned { return buserr.New("ErrClamdscanNotFound") } clam, _ := clamRepo.Get(commonRepo.WithByID(req.ID)) @@ -475,12 +475,27 @@ func (c *ClamService) UpdateFile(req dto.UpdateByNameAndFile) error { return nil } -func stopAllCronJob() { +func StopAllCronJob(withCheck bool) bool { + if withCheck { + isActive := false + exist1, _ := systemctl.IsExist(clamServiceNameCentOs) + if exist1 { + isActive, _ = systemctl.IsActive(clamServiceNameCentOs) + } + exist2, _ := systemctl.IsExist(clamServiceNameUbuntu) + if exist2 { + isActive, _ = systemctl.IsActive(clamServiceNameUbuntu) + } + if isActive { + return false + } + } clams, _ := clamRepo.List(commonRepo.WithByStatus(constant.StatusEnable)) for i := 0; i < len(clams); i++ { global.Cron.Remove(cron.EntryID(clams[i].EntryID)) _ = clamRepo.Update(clams[i].ID, map[string]interface{}{"status": constant.StatusDisable, "entry_id": 0}) } + return true } func loadFileByName(name string) []string { diff --git a/frontend/src/components/system-upgrade/index.vue b/frontend/src/components/system-upgrade/index.vue index 1852c316b..8f2fb4377 100644 --- a/frontend/src/components/system-upgrade/index.vue +++ b/frontend/src/components/system-upgrade/index.vue @@ -17,10 +17,7 @@ {{ isProductPro ? $t('license.pro') : $t('license.community') }} - - {{ copied ? $t('commons.msg.copySuccess') : version }} - - {{ version }} + {{ version }} ({{ $t('setting.hasNewVersion') }}) @@ -84,15 +81,14 @@ import MdEditor from 'md-editor-v3'; import i18n from '@/lang'; import 'md-editor-v3/lib/style.css'; import { MsgSuccess } from '@/utils/message'; +import { copyText } from '@/utils/util'; import { onMounted, ref } from 'vue'; import { GlobalStore } from '@/store'; import { ElMessageBox } from 'element-plus'; import { storeToRefs } from 'pinia'; -import { useClipboard } from '@vueuse/core'; const globalStore = GlobalStore(); const { isDarkTheme } = storeToRefs(globalStore); -const { copied, copy, isSupported } = useClipboard(); const version = ref(''); const isProductPro = ref(); diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 154778e8a..ad0df6139 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1524,6 +1524,7 @@ const message = { allowIPEgs: 'If multiple ip authorizations exist, newlines need to be displayed. For example, \n172.16.10.111 \n172.16.10.0/24', mfa: 'MFA', + mfaClose: 'Disabling MFA will reduce the security of the service. Do you want to continue?', secret: 'Secret', mfaInterval: 'Refresh interval (s)', mfaTitleHelper: diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 4e7188b4a..eb9ca89da 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -19,7 +19,7 @@ const message = { delete: '刪除', edit: '編輯', enable: '啟用', - disable: '禁用', + disable: '停用', confirm: '確認', cancel: '取消', reset: '重置', @@ -1467,6 +1467,7 @@ const message = { allowIPsHelper1: '授權 IP 為空時,則取消授權 IP', allowIPEgs: '當存在多個授權 IP 時,需要換行顯示,例: \n172.16.10.111 \n172.16.10.0/24', mfa: '兩步驗證', + mfaClose: '關閉兩步驗證將導致服務安全性降低,是否繼續?', secret: '密鑰', mfaAlert: '兩步驗證密碼是基於當前時間生成,請確保服務器時間已同步', mfaHelper: '開啟後會驗證手機應用驗證碼', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 946fd647b..1525227bf 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -19,7 +19,7 @@ const message = { delete: '删除', edit: '编辑', enable: '启用', - disable: '禁用', + disable: '停用', confirm: '确认', cancel: '取消', reset: '重置', @@ -1469,6 +1469,7 @@ const message = { allowIPsHelper1: '授权 IP 为空时,则取消授权 IP', allowIPEgs: '当存在多个授权 IP 时,需要换行显示,例: \n172.16.10.111 \n172.16.10.0/24', mfa: '两步验证', + mfaClose: '关闭两步验证将导致服务安全性降低,是否继续?', secret: '密钥', mfaAlert: '两步验证密码是基于当前时间生成,请确保服务器时间已同步', mfaHelper: '开启后会验证手机应用验证码', diff --git a/frontend/src/views/cronjob/index.vue b/frontend/src/views/cronjob/index.vue index a72d44432..c16eb1b55 100644 --- a/frontend/src/views/cronjob/index.vue +++ b/frontend/src/views/cronjob/index.vue @@ -64,7 +64,7 @@ icon="VideoPlay" type="success" > - {{ $t('commons.status.enabled') }} + {{ $t('commons.button.enable') }} - {{ $t('commons.status.disabled') }} + {{ $t('commons.button.disable') }} diff --git a/frontend/src/views/setting/safe/index.vue b/frontend/src/views/setting/safe/index.vue index f04abb493..8e6219541 100644 --- a/frontend/src/views/setting/safe/index.vue +++ b/frontend/src/views/setting/safe/index.vue @@ -277,16 +277,21 @@ const handleMFA = async () => { mfaRef.value.acceptParams({ interval: form.mfaInterval }); return; } - loading.value = true; - await updateSetting({ key: 'MFAStatus', value: 'disable' }) - .then(() => { - loading.value = false; - search(); - MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); - }) - .catch(() => { - loading.value = false; - }); + ElMessageBox.confirm(i18n.global.t('setting.mfaClose'), i18n.global.t('setting.mfa'), { + confirmButtonText: i18n.global.t('commons.button.confirm'), + cancelButtonText: i18n.global.t('commons.button.cancel'), + }).then(async () => { + loading.value = true; + await updateSetting({ key: 'MFAStatus', value: 'disable' }) + .then(() => { + loading.value = false; + search(); + MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); + }) + .catch(() => { + loading.value = false; + }); + }); }; const onChangeEntrance = () => { diff --git a/frontend/src/views/toolbox/clam/status/index.vue b/frontend/src/views/toolbox/clam/status/index.vue index 01038bb40..2fcfde229 100644 --- a/frontend/src/views/toolbox/clam/status/index.vue +++ b/frontend/src/views/toolbox/clam/status/index.vue @@ -12,14 +12,14 @@ {{ $t('app.version') }}:{{ data.version }} - + {{ $t('app.start') }} - + {{ $t('app.stop') }} - + {{ $t('app.restart') }} @@ -45,14 +45,24 @@ {{ $t('app.version') }}:{{ data.freshVersion }} - + {{ $t('app.start') }} - + {{ $t('app.stop') }} - + {{ $t('app.restart') }} @@ -111,10 +121,10 @@ const changeShow = (val: boolean) => { localStorage.setItem('clam-fresh-show', showFresh.value ? 'show' : 'hide'); }; -const onOperate = async (operation: string) => { +const onOperate = async (service: string, operation: string) => { em('update:maskShow', false); ElMessageBox.confirm( - i18n.global.t('commons.msg.operatorHelper', [' ClamAV ', i18n.global.t('app.' + operation)]), + i18n.global.t('commons.msg.operatorHelper', [' ' + service + ' ', i18n.global.t('app.' + operation)]), i18n.global.t('app.' + operation), { confirmButtonText: i18n.global.t('commons.button.confirm'),