1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 22:18:07 +08:00

feat: 增加应用备份跳转目录 (#4648)

This commit is contained in:
ssongliu 2024-04-23 11:20:08 +08:00 committed by GitHub
parent ac400c7188
commit 3156c84b19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 53 additions and 1 deletions

View File

@ -10,6 +10,19 @@
/>
<DrawerHeader v-else :header="$t('commons.button.backup')" :resource="name" :back="handleClose" />
</template>
<div class="mb-5" v-if="type === 'app'">
<el-alert :closable="false" type="warning">
<div class="mt-2 text-xs">
<span>{{ $t('setting.backupJump') }}</span>
<span class="jump" @click="goFile()">
<el-icon class="ml-2"><Position /></el-icon>
{{ $t('firewall.quickJump') }}
</span>
</div>
</el-alert>
</div>
<ComplexTable
v-loading="loading"
:pagination-config="paginationConfig"
@ -60,12 +73,13 @@
<script lang="ts" setup>
import { reactive, ref } from 'vue';
import { computeSize, dateFormat, downloadFile } from '@/utils/util';
import { handleBackup, handleRecover } from '@/api/modules/setting';
import { getBackupList, handleBackup, handleRecover } from '@/api/modules/setting';
import i18n from '@/lang';
import DrawerHeader from '@/components/drawer-header/index.vue';
import { deleteBackupRecord, downloadBackupRecord, searchBackupRecords } from '@/api/modules/setting';
import { Backup } from '@/api/interface/backup';
import { MsgSuccess } from '@/utils/message';
import router from '@/routers';
const selects = ref<any>([]);
const loading = ref();
@ -83,6 +97,7 @@ const backupVisible = ref(false);
const type = ref();
const name = ref();
const detailName = ref();
const backupPath = ref();
interface DialogProps {
type: string;
@ -91,6 +106,9 @@ interface DialogProps {
}
const acceptParams = (params: DialogProps): void => {
type.value = params.type;
if (type.value === 'app') {
loadBackupDir();
}
name.value = params.name;
detailName.value = params.detailName;
backupVisible.value = true;
@ -100,6 +118,26 @@ const handleClose = () => {
backupVisible.value = false;
};
const loadBackupDir = () => {
getBackupList().then((res) => {
let backupList = res.data || [];
for (const bac of backupList) {
if (bac.type !== 'LOCAL') {
continue;
}
if (bac.id !== 0) {
bac.varsJson = JSON.parse(bac.vars);
}
backupPath.value = bac.varsJson['dir'];
break;
}
});
};
const goFile = async () => {
router.push({ name: 'File', query: { path: `${backupPath.value}/app/${name.value}/${detailName.value}` } });
};
const search = async () => {
let params = {
page: paginationConfig.currentPage,
@ -241,3 +279,13 @@ defineExpose({
acceptParams,
});
</script>
<style lang="scss" scoped>
.jump {
color: $primary-color;
cursor: pointer;
&:hover {
color: #74a4f3;
}
}
</style>

View File

@ -1428,6 +1428,8 @@ const message = {
rootCrtDownload: 'Root certificate download',
primaryKey: 'Primary key',
certificate: 'Certificate',
backupJump:
'Backup files not in the current backup list, please try downloading from the file directory and importing for backup.',
snapshot: 'Snapshot',
status: 'Snapshot status',

View File

@ -1258,6 +1258,7 @@ const message = {
accountKey: '賬戶密鑰',
address: '地址',
path: '路徑',
backupJump: '未在當前備份列表中的備份檔案請嘗試從檔案目錄中下載後導入備份',
snapshot: '快照',
status: '快照狀態',

View File

@ -1259,6 +1259,7 @@ const message = {
accountKey: '账户密钥',
address: '地址',
path: '路径',
backupJump: '未在当前备份列表中的备份文件请尝试从文件目录中下载后导入备份',
snapshot: '快照',
ignoreRule: '排除规则',