fix: 修改版本号复制方式 (#6187)

pull/6190/head
ssongliu 2024-08-20 17:38:47 +08:00 committed by GitHub
parent 32cd684307
commit 8187a19e6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 61 additions and 32 deletions

View File

@ -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 {

View File

@ -17,10 +17,7 @@
<el-button type="primary" link @click="toHalo">
<span class="font-normal">{{ isProductPro ? $t('license.pro') : $t('license.community') }}</span>
</el-button>
<span v-if="isSupported" class="version" @click="copy(version)">
{{ copied ? $t('commons.msg.copySuccess') : version }}
</span>
<span class="version" v-else>{{ version }}</span>
<span class="version" @click="copyText(version)">{{ version }}</span>
<el-badge is-dot style="margin-top: -3px" v-if="version !== 'Waiting' && globalStore.hasNewVersion">
<el-button type="primary" link @click="onLoadUpgradeInfo">
<span class="font-normal">({{ $t('setting.hasNewVersion') }})</span>
@ -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<string>('');
const isProductPro = ref();

View File

@ -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:

View File

@ -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: '',

View File

@ -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: '',

View File

@ -64,7 +64,7 @@
icon="VideoPlay"
type="success"
>
{{ $t('commons.status.enabled') }}
{{ $t('commons.button.enable') }}
</el-button>
<el-button
v-else
@ -73,7 +73,7 @@
type="danger"
@click="onChangeStatus(row.id, 'enable')"
>
{{ $t('commons.status.disabled') }}
{{ $t('commons.button.disable') }}
</el-button>
</template>
</el-table-column>

View File

@ -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 = () => {

View File

@ -12,14 +12,14 @@
</el-tag>
<el-tag class="status-content w-24">{{ $t('app.version') }}:{{ data.version }}</el-tag>
<span class="buttons">
<el-button type="primary" v-if="!data.isActive" link @click="onOperate('start')">
<el-button type="primary" v-if="!data.isActive" link @click="onOperate('ClamAV', 'start')">
{{ $t('app.start') }}
</el-button>
<el-button type="primary" v-if="data.isActive" link @click="onOperate('stop')">
<el-button type="primary" v-if="data.isActive" link @click="onOperate('ClamAV', 'stop')">
{{ $t('app.stop') }}
</el-button>
<el-divider direction="vertical" />
<el-button type="primary" link @click="onOperate('restart')">
<el-button type="primary" link @click="onOperate('ClamAV', 'restart')">
{{ $t('app.restart') }}
</el-button>
<el-divider direction="vertical" />
@ -45,14 +45,24 @@
</el-tag>
<el-tag class="status-content w-24">{{ $t('app.version') }}:{{ data.freshVersion }}</el-tag>
<span class="buttons">
<el-button type="primary" v-if="!data.freshIsActive" link @click="onOperate('fresh-start')">
<el-button
type="primary"
v-if="!data.freshIsActive"
link
@click="onOperate('FreshClam', 'start')"
>
{{ $t('app.start') }}
</el-button>
<el-button type="primary" v-if="data.freshIsActive" link @click="onOperate('fresh-stop')">
<el-button
type="primary"
v-if="data.freshIsActive"
link
@click="onOperate('FreshClam', 'stop')"
>
{{ $t('app.stop') }}
</el-button>
<el-divider direction="vertical" />
<el-button type="primary" link @click="onOperate('fresh-restart')">
<el-button type="primary" link @click="onOperate('FreshClam', 'restart')">
{{ $t('app.restart') }}
</el-button>
</span>
@ -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'),