mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-11-08 01:48:55 +08:00
feat: uniapp 读取分类页设置配置(缓存+默认值兜底)
This commit is contained in:
@@ -2,8 +2,13 @@ import { createStore } from 'vuex'
|
||||
import storage from '@/utils/storage'
|
||||
import config from '@/config/config'
|
||||
import { DEFAULT_THEME, loadCachedTheme } from '@/utils/theme'
|
||||
import {
|
||||
DEFAULT_CATEGORY_PAGE_SETTING,
|
||||
loadCachedCategoryPageSetting,
|
||||
} from '@/utils/categoryPageSetting'
|
||||
|
||||
const cachedTheme = loadCachedTheme()
|
||||
const cachedCategoryPageSetting = loadCachedCategoryPageSetting()
|
||||
|
||||
const store = createStore({
|
||||
state: {
|
||||
@@ -17,6 +22,8 @@ const store = createStore({
|
||||
uuid: storage.getUuid(),
|
||||
token: '',
|
||||
theme: cachedTheme || { ...DEFAULT_THEME },
|
||||
categoryPageSetting:
|
||||
cachedCategoryPageSetting || { ...DEFAULT_CATEGORY_PAGE_SETTING },
|
||||
},
|
||||
getters: {
|
||||
mainColor: (state) => state.theme.mainColor,
|
||||
@@ -44,6 +51,9 @@ const store = createStore({
|
||||
aiderLightColor: theme.aiderLightColor || DEFAULT_THEME.aiderLightColor,
|
||||
}
|
||||
},
|
||||
SET_CATEGORY_PAGE_SETTING(state, setting) {
|
||||
state.categoryPageSetting = setting || { ...DEFAULT_CATEGORY_PAGE_SETTING }
|
||||
},
|
||||
},
|
||||
actions: {}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user