import { defineStore } from 'pinia' import { getConfig } from '@/api/app' interface AppSate { config: Record tabbarTick: number configLoaded: boolean popupPagePath: string popupTick: number } export const useAppStore = defineStore({ id: 'appStore', state: (): AppSate => ({ config: { domain: '' }, tabbarTick: 0, configLoaded: false, popupPagePath: '', popupTick: 0 }), 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 this.configLoaded = true }, updatePopupPath(path: string) { this.popupPagePath = path this.popupTick++ } } })