Files
likeadmin_java/pc/stores/app.ts
damonyuan 11aa66ef8d feat 更新UI
feat article 和 artcate 新表的关联更新
2024-10-13 17:51:34 +08:00

29 lines
899 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: {}
}),
getters: {
getImageUrl: (state) => (url: string) =>
url ? `${state.config.domain}${url}` : '',
getWebsiteConfig: (state) => state.config.website || {},
getLoginConfig: (state) => state.config.login || {},
getCopyrightConfig: (state) => state.config.copyright || [],
getQrcodeConfig: (state) => state.config.qrcode || {},
getAdminUrl: (state) => state.config.admin_url,
getSiteStatistics: (state) => state.config.siteStatistics || {}
},
actions: {
async getConfig() {
const config = await getConfig()
this.config = config
}
}
})