feat: add config endpoint
This commit is contained in:
parent
48254b06dd
commit
fb5e10fe04
2 changed files with 26 additions and 0 deletions
23
src/stores/config/index.ts
Normal file
23
src/stores/config/index.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { defineStore } from 'pinia';
|
||||
import { api } from 'src/boot/axios';
|
||||
import { ref } from 'vue';
|
||||
|
||||
export const useConfigStore = defineStore('config-store', () => {
|
||||
const data = ref<AppConfig>();
|
||||
|
||||
return {
|
||||
data,
|
||||
|
||||
async getConfig() {
|
||||
if (data.value) return data.value;
|
||||
|
||||
const res = await api.get<AppConfig>('/config');
|
||||
|
||||
if (res.status < 400) {
|
||||
data.value = res.data;
|
||||
}
|
||||
|
||||
return data.value;
|
||||
},
|
||||
};
|
||||
});
|
||||
3
src/stores/config/types.ts
Normal file
3
src/stores/config/types.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
type AppConfig = {
|
||||
vat: number;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue