从现有站点恢复重命名为从指定站点恢复

This commit is contained in:
jingrow 2025-10-21 05:01:20 +08:00
parent da3f814451
commit 057d8164f5
3 changed files with 190 additions and 158 deletions

View File

@ -45,7 +45,7 @@ function getSiteActionHandler(action) {
'使用文件恢复': defineAsyncComponent(() => '使用文件恢复': defineAsyncComponent(() =>
import('./SiteDatabaseRestoreDialog.vue') import('./SiteDatabaseRestoreDialog.vue')
), ),
'从现有站点恢复': defineAsyncComponent(() => '从指定站点恢复': defineAsyncComponent(() =>
import('./site/SiteDatabaseRestoreFromURLDialog.vue') import('./site/SiteDatabaseRestoreFromURLDialog.vue')
), ),
'管理数据库用户': defineAsyncComponent(() => '管理数据库用户': defineAsyncComponent(() =>

View File

@ -1,7 +1,7 @@
<template> <template>
<Dialog <Dialog
:options="{ :options="{
title: '从现有站点恢复' title: '从指定站点恢复'
}" }"
v-model="showRestoreDialog" v-model="showRestoreDialog"
> >
@ -144,12 +144,44 @@ export default {
if (!this.$resources.getBackupLinks.data) return ''; if (!this.$resources.getBackupLinks.data) return '';
let backup = this.$resources.getBackupLinks.data[0]; let backup = this.$resources.getBackupLinks.data[0];
let timestamp_string = backup.file_name if (!backup || !backup.file_name) return '';
.split('-')[0]
.split('_')
.join('T');
return date(timestamp_string); let timestamp_string = '';
// YYYYMMDD_HHMMSS
let timestampMatch = backup.file_name.match(/(\d{8}_\d{6})/);
if (timestampMatch) {
let match = timestampMatch[1];
let year = match.substring(0, 4);
let month = match.substring(4, 6);
let day = match.substring(6, 8);
let hour = match.substring(9, 11);
let minute = match.substring(11, 13);
let second = match.substring(13, 15);
timestamp_string = `${year}-${month}-${day}T${hour}:${minute}:${second}`;
} else {
// YYYY-MM-DD_HH-MM-SS
let oldFormatMatch = backup.file_name.match(/(\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2})/);
if (oldFormatMatch) {
timestamp_string = oldFormatMatch[1].replace('_', 'T').replace(/-/g, '-');
} else {
// YYYY-MM-DD
let dateMatch = backup.file_name.match(/(\d{4}-\d{2}-\d{2})/);
if (dateMatch) {
timestamp_string = dateMatch[1] + 'T00:00:00';
} else {
//
return backup.file_name;
}
}
}
try {
return date(timestamp_string);
} catch (e) {
//
return backup.file_name;
}
} }
} }
}; };

View File

@ -2783,8 +2783,8 @@ class Site(Page, TagHelpers):
"group": "危险操作", "group": "危险操作",
}, },
{ {
"action": "现有站点恢复", "action": "指定站点恢复",
"description": "另一个站点恢复数据库、公共和私有文件", "description": "指定站点的备份文件恢复数据库、公共和私有文件",
"button_label": "恢复", "button_label": "恢复",
"pg_method": "restore_site_from_files", "pg_method": "restore_site_from_files",
"group": "危险操作", "group": "危险操作",