แก้ restore ส่ง name
This commit is contained in:
parent
9e44592a1e
commit
fc1f30b6b4
1 changed files with 18 additions and 1 deletions
|
|
@ -79,7 +79,7 @@ export const useDataStore = defineStore("systemStore", () => {
|
||||||
async function restore(filename: string) {
|
async function restore(filename: string) {
|
||||||
await http
|
await http
|
||||||
.post<string>(config.API.restore, {
|
.post<string>(config.API.restore, {
|
||||||
filename: filename,
|
name: filename,
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const tempValue = dataBackUp.value.find((item) => {
|
const tempValue = dataBackUp.value.find((item) => {
|
||||||
|
|
@ -122,6 +122,8 @@ export const useDataStore = defineStore("systemStore", () => {
|
||||||
dataBackUp.value.unshift({
|
dataBackUp.value.unshift({
|
||||||
id: item.created_at.toString(),
|
id: item.created_at.toString(),
|
||||||
name: "-",
|
name: "-",
|
||||||
|
databaseSize: 0,
|
||||||
|
storageSize: 0,
|
||||||
timestamp: item.created_at,
|
timestamp: item.created_at,
|
||||||
status: item.running ? "running" : "success",
|
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 {
|
return {
|
||||||
dataBackUp,
|
dataBackUp,
|
||||||
backupRunTotal,
|
backupRunTotal,
|
||||||
|
|
@ -175,5 +190,7 @@ export const useDataStore = defineStore("systemStore", () => {
|
||||||
|
|
||||||
backupRunningList,
|
backupRunningList,
|
||||||
restoreRunningList,
|
restoreRunningList,
|
||||||
|
|
||||||
|
getSize,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue