feat: uniapp 读取分类页设置配置(缓存+默认值兜底)

This commit is contained in:
pikachu1995@126.com
2026-10-22 09:17:58 +08:00
parent 0a47f84c32
commit 1032b6e34d
4 changed files with 106 additions and 1 deletions

View File

@@ -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: {}
})