feat(challenges): 优化挑战列表与详情页交互体验

- 替换 Image 为 expo-image 并启用缓存策略
- 调整礼物按钮尺寸与图标大小
- 加入挑战失败时弹出 Toast 提示
- 统一异步流程并移除冗余状态监听
- 清理调试日志与多余空行
This commit is contained in:
richarjiang
2025-09-29 09:59:47 +08:00
parent 7259bd7a2c
commit b80af23f4f
3 changed files with 37 additions and 22 deletions

View File

@@ -1,4 +1,3 @@
import { createAsyncThunk, createSelector, createSlice } from '@reduxjs/toolkit';
import {
type ChallengeDetailDto,
type ChallengeListItemDto,
@@ -11,6 +10,7 @@ import {
listChallenges,
reportChallengeProgress as reportChallengeProgressApi,
} from '@/services/challengesApi';
import { createAsyncThunk, createSelector, createSlice } from '@reduxjs/toolkit';
import type { RootState } from './index';
type AsyncStatus = 'idle' | 'loading' | 'succeeded' | 'failed';
@@ -81,8 +81,11 @@ export const fetchChallengeDetail = createAsyncThunk<ChallengeDetail, string, {
'challenges/fetchDetail',
async (id, { rejectWithValue }) => {
try {
return await getChallengeDetail(id);
const ret = await getChallengeDetail(id);
return ret;
} catch (error) {
console.log('######', error);
return rejectWithValue(toErrorMessage(error));
}
}
@@ -290,6 +293,8 @@ const formatMonthDay = (input: string | undefined): string | undefined => {
};
const buildDateRangeLabel = (challenge: ChallengeEntity): string => {
console.log('!!!!!', challenge);
const startLabel = formatMonthDay(challenge.startAt);
const endLabel = formatMonthDay(challenge.endAt);
if (startLabel && endLabel) {