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") { if !cmd.Which("clamdscan") {
baseInfo.IsActive = false baseInfo.IsActive = false
stopAllCronJob()
} }
if baseInfo.IsActive { if baseInfo.IsActive {
@ -93,6 +92,8 @@ func (c *ClamService) LoadBaseInfo() (dto.ClamBaseInfo, error) {
baseInfo.Version = strings.TrimPrefix(version, "ClamAV ") baseInfo.Version = strings.TrimPrefix(version, "ClamAV ")
} }
} }
} else {
_ = StopAllCronJob(false)
} }
if baseInfo.FreshIsActive { if baseInfo.FreshIsActive {
version, err := cmd.Exec("freshclam --version") 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 { func (c *ClamService) HandleOnce(req dto.OperateByID) error {
if !cmd.Which("clamdscan") { if cleaned := StopAllCronJob(true); cleaned {
stopAllCronJob()
return buserr.New("ErrClamdscanNotFound") return buserr.New("ErrClamdscanNotFound")
} }
clam, _ := clamRepo.Get(commonRepo.WithByID(req.ID)) clam, _ := clamRepo.Get(commonRepo.WithByID(req.ID))
@ -475,12 +475,27 @@ func (c *ClamService) UpdateFile(req dto.UpdateByNameAndFile) error {
return nil 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)) clams, _ := clamRepo.List(commonRepo.WithByStatus(constant.StatusEnable))
for i := 0; i < len(clams); i++ { for i := 0; i < len(clams); i++ {
global.Cron.Remove(cron.EntryID(clams[i].EntryID)) global.Cron.Remove(cron.EntryID(clams[i].EntryID))
_ = clamRepo.Update(clams[i].ID, map[string]interface{}{"status": constant.StatusDisable, "entry_id": 0}) _ = clamRepo.Update(clams[i].ID, map[string]interface{}{"status": constant.StatusDisable, "entry_id": 0})
} }
return true
} }
func loadFileByName(name string) []string { func loadFileByName(name string) []string {

View File

@ -17,10 +17,7 @@
<el-button type="primary" link @click="toHalo"> <el-button type="primary" link @click="toHalo">
<span class="font-normal">{{ isProductPro ? $t('license.pro') : $t('license.community') }}</span> <span class="font-normal">{{ isProductPro ? $t('license.pro') : $t('license.community') }}</span>
</el-button> </el-button>
<span v-if="isSupported" class="version" @click="copy(version)"> <span class="version" @click="copyText(version)">{{ version }}</span>
{{ copied ? $t('commons.msg.copySuccess') : version }}
</span>
<span class="version" v-else>{{ version }}</span>
<el-badge is-dot style="margin-top: -3px" v-if="version !== 'Waiting' && globalStore.hasNewVersion"> <el-badge is-dot style="margin-top: -3px" v-if="version !== 'Waiting' && globalStore.hasNewVersion">
<el-button type="primary" link @click="onLoadUpgradeInfo"> <el-button type="primary" link @click="onLoadUpgradeInfo">
<span class="font-normal">({{ $t('setting.hasNewVersion') }})</span> <span class="font-normal">({{ $t('setting.hasNewVersion') }})</span>
@ -84,15 +81,14 @@ import MdEditor from 'md-editor-v3';
import i18n from '@/lang'; import i18n from '@/lang';
import 'md-editor-v3/lib/style.css'; import 'md-editor-v3/lib/style.css';
import { MsgSuccess } from '@/utils/message'; import { MsgSuccess } from '@/utils/message';
import { copyText } from '@/utils/util';
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { GlobalStore } from '@/store'; import { GlobalStore } from '@/store';
import { ElMessageBox } from 'element-plus'; import { ElMessageBox } from 'element-plus';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useClipboard } from '@vueuse/core';
const globalStore = GlobalStore(); const globalStore = GlobalStore();
const { isDarkTheme } = storeToRefs(globalStore); const { isDarkTheme } = storeToRefs(globalStore);
const { copied, copy, isSupported } = useClipboard();
const version = ref<string>(''); const version = ref<string>('');
const isProductPro = ref(); const isProductPro = ref();

View File

@ -1524,6 +1524,7 @@ const message = {
allowIPEgs: allowIPEgs:
'If multiple ip authorizations exist, newlines need to be displayed. For example, \n172.16.10.111 \n172.16.10.0/24', 'If multiple ip authorizations exist, newlines need to be displayed. For example, \n172.16.10.111 \n172.16.10.0/24',
mfa: 'MFA', mfa: 'MFA',
mfaClose: 'Disabling MFA will reduce the security of the service. Do you want to continue?',
secret: 'Secret', secret: 'Secret',
mfaInterval: 'Refresh interval (s)', mfaInterval: 'Refresh interval (s)',
mfaTitleHelper: mfaTitleHelper:

View File

@ -19,7 +19,7 @@ const message = {
delete: '', delete: '',
edit: '', edit: '',
enable: '', enable: '',
disable: '', disable: '',
confirm: '', confirm: '',
cancel: '', cancel: '',
reset: '', reset: '',
@ -1467,6 +1467,7 @@ const message = {
allowIPsHelper1: ' IP IP', allowIPsHelper1: ' IP IP',
allowIPEgs: ' IP \n172.16.10.111 \n172.16.10.0/24', allowIPEgs: ' IP \n172.16.10.111 \n172.16.10.0/24',
mfa: '', mfa: '',
mfaClose: '',
secret: '', secret: '',
mfaAlert: '', mfaAlert: '',
mfaHelper: '', mfaHelper: '',

View File

@ -19,7 +19,7 @@ const message = {
delete: '', delete: '',
edit: '', edit: '',
enable: '', enable: '',
disable: '', disable: '',
confirm: '', confirm: '',
cancel: '', cancel: '',
reset: '', reset: '',
@ -1469,6 +1469,7 @@ const message = {
allowIPsHelper1: ' IP IP', allowIPsHelper1: ' IP IP',
allowIPEgs: ' IP \n172.16.10.111 \n172.16.10.0/24', allowIPEgs: ' IP \n172.16.10.111 \n172.16.10.0/24',
mfa: '', mfa: '',
mfaClose: '',
secret: '', secret: '',
mfaAlert: '', mfaAlert: '',
mfaHelper: '', mfaHelper: '',

View File

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

View File

@ -277,6 +277,10 @@ const handleMFA = async () => {
mfaRef.value.acceptParams({ interval: form.mfaInterval }); mfaRef.value.acceptParams({ interval: form.mfaInterval });
return; return;
} }
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; loading.value = true;
await updateSetting({ key: 'MFAStatus', value: 'disable' }) await updateSetting({ key: 'MFAStatus', value: 'disable' })
.then(() => { .then(() => {
@ -287,6 +291,7 @@ const handleMFA = async () => {
.catch(() => { .catch(() => {
loading.value = false; loading.value = false;
}); });
});
}; };
const onChangeEntrance = () => { const onChangeEntrance = () => {

View File

@ -12,14 +12,14 @@
</el-tag> </el-tag>
<el-tag class="status-content w-24">{{ $t('app.version') }}:{{ data.version }}</el-tag> <el-tag class="status-content w-24">{{ $t('app.version') }}:{{ data.version }}</el-tag>
<span class="buttons"> <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') }} {{ $t('app.start') }}
</el-button> </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') }} {{ $t('app.stop') }}
</el-button> </el-button>
<el-divider direction="vertical" /> <el-divider direction="vertical" />
<el-button type="primary" link @click="onOperate('restart')"> <el-button type="primary" link @click="onOperate('ClamAV', 'restart')">
{{ $t('app.restart') }} {{ $t('app.restart') }}
</el-button> </el-button>
<el-divider direction="vertical" /> <el-divider direction="vertical" />
@ -45,14 +45,24 @@
</el-tag> </el-tag>
<el-tag class="status-content w-24">{{ $t('app.version') }}:{{ data.freshVersion }}</el-tag> <el-tag class="status-content w-24">{{ $t('app.version') }}:{{ data.freshVersion }}</el-tag>
<span class="buttons"> <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') }} {{ $t('app.start') }}
</el-button> </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') }} {{ $t('app.stop') }}
</el-button> </el-button>
<el-divider direction="vertical" /> <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') }} {{ $t('app.restart') }}
</el-button> </el-button>
</span> </span>
@ -111,10 +121,10 @@ const changeShow = (val: boolean) => {
localStorage.setItem('clam-fresh-show', showFresh.value ? 'show' : 'hide'); 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); em('update:maskShow', false);
ElMessageBox.confirm( 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), i18n.global.t('app.' + operation),
{ {
confirmButtonText: i18n.global.t('commons.button.confirm'), confirmButtonText: i18n.global.t('commons.button.confirm'),