mirror of https://github.com/1Panel-dev/1Panel
fix: 修改版本号复制方式 (#6187)
parent
32cd684307
commit
8187a19e6e
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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: '開啟後會驗證手機應用驗證碼',
|
||||
|
|
|
@ -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: '开启后会验证手机应用验证码',
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 = () => {
|
||||
|
|
|
@ -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'),
|
||||
|
|
Loading…
Reference in New Issue