แก้ restore ส่ง name

This commit is contained in:
Net 2024-07-16 14:59:33 +07:00
parent 9e44592a1e
commit fc1f30b6b4

View file

@ -79,7 +79,7 @@ export const useDataStore = defineStore("systemStore", () => {
async function restore(filename: string) {
await http
.post<string>(config.API.restore, {
filename: filename,
name: filename,
})
.then(async (res) => {
const tempValue = dataBackUp.value.find((item) => {
@ -122,6 +122,8 @@ export const useDataStore = defineStore("systemStore", () => {
dataBackUp.value.unshift({
id: item.created_at.toString(),
name: "-",
databaseSize: 0,
storageSize: 0,
timestamp: item.created_at,
status: item.running ? "running" : "success",
});
@ -163,6 +165,19 @@ export const useDataStore = defineStore("systemStore", () => {
});
}
function getSize(size: number): string {
if (size === undefined) return "Unknow size";
const units = ["B", "KB", "MB", "GB", "TB"];
let i = 0;
let sizeNumber = typeof size === "string" ? parseFloat(size) : size;
while (sizeNumber >= 1024 && i++ < units.length - 1) {
sizeNumber /= 1024;
}
return sizeNumber.toFixed(2) + " " + units[i];
}
return {
dataBackUp,
backupRunTotal,
@ -175,5 +190,7 @@ export const useDataStore = defineStore("systemStore", () => {
backupRunningList,
restoreRunningList,
getSize,
};
});