ต่อ api backUp
This commit is contained in:
parent
3ad75ba890
commit
f28d426b17
1 changed files with 68 additions and 0 deletions
68
src/modules/04_system/stores/main.ts
Normal file
68
src/modules/04_system/stores/main.ts
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import { defineStore } from "pinia";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
import type { DataBackup } from "@/modules/04_system/interface/response/Main";
|
||||
|
||||
import { ref } from "vue";
|
||||
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
dialogRemove,
|
||||
messageError,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
success,
|
||||
dialogConfirm,
|
||||
} = mixin;
|
||||
|
||||
export const useDataStore = defineStore("storeData", () => {
|
||||
const dataBackUp = ref<DataBackup[]>([]);
|
||||
|
||||
async function fetchListBackup() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.backup)
|
||||
.then((res) => {
|
||||
dataBackUp.value = res.data;
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
async function createBackUp() {
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.backup + "/create")
|
||||
.then(async (res) => {
|
||||
fetchListBackup();
|
||||
})
|
||||
.finally(() => {
|
||||
console.log("aye");
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
async function restore(filename: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.restore + "?filename=" + filename + "")
|
||||
.then((res) => {
|
||||
fetchListBackup();
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
dataBackUp,
|
||||
|
||||
fetchListBackup,
|
||||
createBackUp,
|
||||
restore,
|
||||
};
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue