2022-09-07 12:58:01 +00:00
|
|
|
import { defineStore } from 'pinia'
|
2022-09-08 08:28:56 +00:00
|
|
|
import { getConfig } from '@/api/app'
|
2022-09-07 12:58:01 +00:00
|
|
|
|
2022-09-08 08:28:56 +00:00
|
|
|
interface AppSate {
|
|
|
|
|
config: Record<string, any>
|
|
|
|
|
}
|
2022-09-07 12:58:01 +00:00
|
|
|
export const useAppStore = defineStore({
|
2022-09-08 08:28:56 +00:00
|
|
|
id: 'appStore',
|
|
|
|
|
state: (): AppSate => ({
|
|
|
|
|
config: {}
|
|
|
|
|
}),
|
2022-09-07 12:58:01 +00:00
|
|
|
getters: {},
|
2022-09-08 08:28:56 +00:00
|
|
|
actions: {
|
|
|
|
|
getImageUrl(url: string) {
|
|
|
|
|
return url ? `${this.config.domain}${url}` : ''
|
|
|
|
|
},
|
|
|
|
|
async getConfig() {
|
|
|
|
|
const data = await getConfig()
|
|
|
|
|
this.config = data
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-07 12:58:01 +00:00
|
|
|
})
|