fix: 应用备份页面修改

This commit is contained in:
zhengkunwang223 2022-12-01 16:13:51 +08:00 committed by zhengkunwang223
parent 1496403ce9
commit 6d9217d419
4 changed files with 52 additions and 15 deletions

View file

@ -246,8 +246,8 @@ func backupInstall(ctx context.Context, install model.AppInstall) error {
backupDir := path.Join(constant.BackupDir, install.App.Key, install.Name)
fileOp := files.NewFileOp()
now := time.Now()
day := now.Format("2006-01-02-15-04")
fileName := fmt.Sprintf("%s-%s-%s%s", install.Name, install.Version, day, ".tar.gz")
day := now.Format("20060102150405")
fileName := fmt.Sprintf("%s_%s%s", install.Name, day, ".tar.gz")
if err := fileOp.Compress([]string{appPath}, backupDir, fileName, files.TarGz); err != nil {
return err
}

View file

@ -724,8 +724,8 @@ export default {
backupName: '文件名称',
backupPath: '文件路径',
backupdate: '备份时间',
restore: '回滚',
restoreWarn: '回滚操作会重启应用,并替换数据,此操作不可回滚,是否继续?',
restore: '恢复',
restoreWarn: '恢复操作会重启应用,并替换数据,此操作不可回滚,是否继续?',
update: '升级',
versioneSelect: '请选择版本',
operatorHelper: '将对选中应用进行 {0} 操作是否继续',

View file

@ -1,11 +1,38 @@
<template>
<el-dialog v-model="open" :title="$t('app.backup')" width="70%" :before-close="handleClose">
<ComplexTable :pagination-config="paginationConfig" :data="data" @search="search" v-loading="loading">
<el-dialog
v-model="open"
:title="$t('app.backup') + ' - ' + installData.appInstallName"
width="70%"
:before-close="handleClose"
:close-on-click-modal="false"
>
<ComplexTable
:pagination-config="paginationConfig"
:data="data"
@search="search"
v-loading="loading"
v-model:selects="selects"
>
<template #toolbar>
<el-button type="primary" plain @click="backup">{{ $t('app.backup') }}</el-button>
<el-button type="primary" @click="backup">{{ $t('app.backup') }}</el-button>
<el-button type="danger" plain :disabled="selects.length === 0" @click="onBatchDelete()">
{{ $t('commons.button.delete') }}
</el-button>
</template>
<el-table-column :label="$t('app.backupName')" prop="name"></el-table-column>
<el-table-column :label="$t('app.backupPath')" prop="path"></el-table-column>
<el-table-column type="selection" fix />
<el-table-column
:label="$t('app.backupName')"
min-width="120px"
prop="name"
show-overflow-tooltip
></el-table-column>
<el-table-column
:label="$t('app.backupPath')"
min-width="120px"
prop="path"
show-overflow-tooltip
></el-table-column>
<el-table-column
prop="createdAt"
:label="$t('app.backupdate')"
@ -48,10 +75,13 @@ import { useDeleteData } from '@/hooks/use-delete-data';
interface InstallRrops {
appInstallId: number;
appInstallName: string;
}
const installData = ref<InstallRrops>({
appInstallId: 0,
appInstallName: '',
});
const selects = ref<any>([]);
let open = ref(false);
let loading = ref(false);
let data = ref<any>();
@ -75,6 +105,7 @@ const handleClose = () => {
const acceptParams = (props: InstallRrops) => {
installData.value.appInstallId = props.appInstallId;
installData.value.appInstallName = props.appInstallName;
search();
open.value = true;
};
@ -128,13 +159,18 @@ const restore = async () => {
};
const deleteBackup = async (ids: number[]) => {
const req = {
ids: ids,
};
await useDeleteData(DelAppBackups, req, 'commons.msg.delete', loading.value);
await useDeleteData(DelAppBackups, { ids: ids }, 'commons.msg.delete', loading.value);
search();
};
const onBatchDelete = () => {
let ids: Array<number> = [];
selects.value.forEach((item: any) => {
ids.push(item.id);
});
deleteBackup(ids);
};
const buttons = [
{
label: i18n.global.t('app.delete'),

View file

@ -36,7 +36,7 @@
<el-table-column :label="$t('website.port')" prop="httpPort"></el-table-column>
<el-table-column :label="$t('app.backup')">
<template #default="{ row }">
<el-link :underline="false" @click="openBackups(row.id)" type="primary">
<el-link :underline="false" @click="openBackups(row.id, row.name)" type="primary">
{{ $t('app.backup') }} ({{ row.backups.length }})
</el-link>
</template>
@ -261,9 +261,10 @@ const buttons = [
},
];
const openBackups = (installId: number) => {
const openBackups = (installId: number, installName: string) => {
let params = {
appInstallId: installId,
appInstallName: installName,
};
backupRef.value.acceptParams(params);
};