mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-11-09 02:18:53 +08:00
feat: uniapp 读取分类页设置配置(缓存+默认值兜底)
This commit is contained in:
24
App.vue
24
App.vue
@@ -3,13 +3,18 @@ import config from '@/config/config'
|
||||
import { getClipboardData } from '@/js_sdk/h5-copy/h5-copy.js'
|
||||
import APPUpdate from '@/plugins/APPUpdate'
|
||||
import storage from '@/utils/storage'
|
||||
import { getThemeSetting } from '@/api/common.js'
|
||||
import { getThemeSetting, getCategoryPageSetting } from '@/api/common.js'
|
||||
import {
|
||||
applyTabBarStyle,
|
||||
cacheTheme,
|
||||
loadCachedTheme,
|
||||
normalizeTheme,
|
||||
} from '@/utils/theme'
|
||||
import {
|
||||
cacheCategoryPageSetting,
|
||||
loadCachedCategoryPageSetting,
|
||||
normalizeCategoryPageSetting,
|
||||
} from '@/utils/categoryPageSetting'
|
||||
import { onLaunch, onShow } from '@dcloudio/uni-app'
|
||||
import { useStore } from '@/store'
|
||||
import { handleAppLaunchScene } from '@/utils/distributionBind.js'
|
||||
@@ -24,6 +29,7 @@ wx.onAppRoute((res) => {
|
||||
|
||||
onLaunch((val) => {
|
||||
initTheme()
|
||||
initCategoryPageSetting()
|
||||
handleAppLaunchScene(val)
|
||||
if (val?.query?.inviter) {
|
||||
storage.setInviter(val.query.inviter)
|
||||
@@ -81,6 +87,22 @@ function initTheme() {
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
function initCategoryPageSetting() {
|
||||
const cached = loadCachedCategoryPageSetting()
|
||||
if (cached) {
|
||||
store.commit('SET_CATEGORY_PAGE_SETTING', cached)
|
||||
}
|
||||
getCategoryPageSetting()
|
||||
.then((res) => {
|
||||
if (res.data?.success) {
|
||||
const setting = normalizeCategoryPageSetting(res.data.result)
|
||||
store.commit('SET_CATEGORY_PAGE_SETTING', setting)
|
||||
cacheCategoryPageSetting(setting)
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
function applyUpdateWeChat() {
|
||||
const updateManager = uni.getUpdateManager()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user