Files
sbnews/uniapp/src/stores/app.ts
T
2026-06-11 12:15:29 +08:00

45 lines
1.3 KiB
TypeScript

import { defineStore } from 'pinia'
import { getConfig } from '@/api/app'
interface AppSate {
config: Record<string, any>
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++
}
}
})