修复一堆问题
This commit is contained in:
@@ -20,7 +20,6 @@ interface DictionaryState {
|
||||
bannerDetailImage: string
|
||||
bannerListIndex: string
|
||||
} | null
|
||||
fetchBannerDictionary: () => Promise<void>
|
||||
}
|
||||
|
||||
// 创建字典Store
|
||||
@@ -36,7 +35,7 @@ export const useDictionaryStore = create<DictionaryState>()((set, get) => ({
|
||||
set({ isLoading: true, error: null })
|
||||
|
||||
try {
|
||||
const keys = 'publishing_requirements,court_type,court_surface,supplementary_information,game_play,fabu_tip,supported_cities';
|
||||
const keys = 'publishing_requirements,court_type,court_surface,supplementary_information,game_play,fabu_tip,supported_cities,bannerListImage,bannerDetailImage,bannerListIndex';
|
||||
const response = await commonApi.getDictionaryManyKey(keys)
|
||||
|
||||
if (response.code === 0 && response.data) {
|
||||
@@ -53,6 +52,15 @@ export const useDictionaryStore = create<DictionaryState>()((set, get) => ({
|
||||
dictionaryData: dictionaryData || {},
|
||||
isLoading: false
|
||||
})
|
||||
|
||||
set({
|
||||
bannerDict: {
|
||||
bannerListImage: response.data.bannerListImage || '',
|
||||
bannerDetailImage: response.data.bannerDetailImage || '',
|
||||
bannerListIndex: (response.data.bannerListIndex ?? '').toString(),
|
||||
}
|
||||
})
|
||||
|
||||
console.log('字典数据获取成功:', response.data)
|
||||
} else {
|
||||
throw new Error(response.message || '获取字典数据失败')
|
||||
@@ -67,26 +75,7 @@ export const useDictionaryStore = create<DictionaryState>()((set, get) => ({
|
||||
}
|
||||
},
|
||||
|
||||
// 获取 Banner 字典(启动时或手动调用)
|
||||
fetchBannerDictionary: async () => {
|
||||
try {
|
||||
const keys = 'bannerListImage,bannerDetailImage,bannerListIndex';
|
||||
const response = await commonApi.getDictionaryManyKey(keys)
|
||||
if (response.code === 0 && response.data) {
|
||||
const data = response.data || {};
|
||||
set({
|
||||
bannerDict: {
|
||||
bannerListImage: data.bannerListImage || '',
|
||||
bannerDetailImage: data.bannerDetailImage || '',
|
||||
bannerListIndex: (data.bannerListIndex ?? '').toString(),
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
// 保持静默,避免影响启动流程
|
||||
console.error('获取 Banner 字典失败:', error)
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// 获取字典值
|
||||
getDictionaryValue: (key: string, defaultValue?: any) => {
|
||||
|
||||
Reference in New Issue
Block a user