Files
AIProd/store/index.js
2025-10-24 15:45:38 +08:00

30 lines
758 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//默认就是根store不需要namespacedtrue访问的时候直接写根级别的key : this.$store.dispatch('example)
export const state = () => ({
bannerConfig: {}
})
export const mutations = {
SET_BANNER_CONFIG(state, config) {
state.bannerConfig = config
}
}
export const actions = {
// 只在服务端渲染时运行一次
async nuxtServerInit({ dispatch, commit }, { app, req }) {
await dispatch('getBannerConfig');
},
async getBannerConfig({ commit }) {
const {data: res} = await this.$api.config.getModuleConfigKey('banner')
const {code, data} = res;
if (code === 0 && data.banner) {
commit('SET_BANNER_CONFIG', data.banner);
}
}
}
export const getters = {
bannerConfig: (state) => state.bannerConfig
}