diff --git a/Admin.NET/Admin.NET.Core/Service/DataBase/SysDbBackupService.cs b/Admin.NET/Admin.NET.Core/Service/DataBase/SysDbBackupService.cs
index 29ae36b6..e1defcf6 100644
--- a/Admin.NET/Admin.NET.Core/Service/DataBase/SysDbBackupService.cs
+++ b/Admin.NET/Admin.NET.Core/Service/DataBase/SysDbBackupService.cs
@@ -50,6 +50,8 @@ public class SysDbBackupService : IDynamicApiController, ITransient
});
}
+ dbBackupList = dbBackupList.OrderByDescending(u => u.CreateTime).ToList();
+
return dbBackupList;
}
catch
@@ -156,4 +158,19 @@ public class SysDbBackupService : IDynamicApiController, ITransient
}
}
}
+
+ ///
+ /// 下载备份 🔖
+ ///
+ ///
+ [ApiDescriptionSettings(Name = "Download"), HttpGet]
+ [DisplayName("下载备份")]
+ [AllowAnonymous]
+ [NonUnify]
+ public IActionResult Download(string fileName)
+ {
+ var path = Path.Combine(_backupDir, fileName);
+ var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+ return new FileStreamResult(fs, "application/octet-stream") { FileDownloadName = fileName };
+ }
}
\ No newline at end of file
diff --git a/Web/src/views/system/database/dbBackup.vue b/Web/src/views/system/database/dbBackup.vue
index cabd5197..72a3c525 100644
--- a/Web/src/views/system/database/dbBackup.vue
+++ b/Web/src/views/system/database/dbBackup.vue
@@ -28,6 +28,7 @@
删除
+ 下载
@@ -127,6 +128,23 @@ const handleDelete = async (row: any) => {
state.loading = false;
}
};
+
+// 下载备份
+const handleDownload = (row: any) => {
+ const baseUrl = import.meta.env.VITE_API_URL;
+ let url = `${baseUrl}/api/sysDbBackup/download/${row.fileName}`;
+
+ const tempLink = document.createElement('a');
+ tempLink.style.display = 'none';
+ tempLink.href = url;
+ tempLink.setAttribute('download', row.fileName);
+ if (typeof tempLink.download === 'undefined') {
+ tempLink.setAttribute('target', '_blank');
+ }
+ document.body.appendChild(tempLink);
+ tempLink.click();
+ document.body.removeChild(tempLink);
+};