Files
zyt/uniapp/src/stores/app.ts
T
2026-03-01 14:17:59 +08:00

32 lines
938 B
TypeScript

import { defineStore } from 'pinia'
import { getConfig } from '@/api/app'
interface AppSate {
config: Record<string, any>
}
export const useAppStore = defineStore({
id: 'appStore',
state: (): AppSate => ({
config: {
domain: ''
}
}),
getters: {
getWebsiteConfig: (state) => state.config.website || {},
getLoginConfig: (state) => state.config.login || {},
getTabbarConfig: (state) => state.config.tabbar || [],
getStyleConfig: (state) => state.config.style || {},
getH5Config: (state) => state.config.webPage || {},
getCopyrightConfig: (state) => state.config.copyright || [],
},
actions: {
getImageUrl(url: string) {
return url.indexOf('http') ? `${this.config.domain}${url}` : url
},
async getConfig() {
const data = await getConfig()
this.config = data
}
}
})