Commit 8e2d9dae authored by hewenhao's avatar hewenhao

feat: update

parent a751e545
...@@ -37,6 +37,7 @@ const startCounter = () => getCounter()?.start() ...@@ -37,6 +37,7 @@ const startCounter = () => getCounter()?.start()
interface GameModelState { interface GameModelState {
/** 题目列表 */ /** 题目列表 */
questionList: QuestionType[]; questionList: QuestionType[];
stageDetailPre: StageDetail | null;
stageDetail: StageDetail | null; stageDetail: StageDetail | null;
gameResult: CompleteStageDetail | null; gameResult: CompleteStageDetail | null;
gameStartTime: number; gameStartTime: number;
...@@ -97,6 +98,7 @@ const gameModel: GameModel = { ...@@ -97,6 +98,7 @@ const gameModel: GameModel = {
rightIcon: null, rightIcon: null,
stageDetail: null, stageDetail: null,
stageDetailPre: null,
updateState: action((state, obj) => { updateState: action((state, obj) => {
for (const key in obj) { for (const key in obj) {
...@@ -237,11 +239,15 @@ const gameModel: GameModel = { ...@@ -237,11 +239,15 @@ const gameModel: GameModel = {
} }
}), }),
getStageDetail: thunk(async (actions, round) => { getStageDetail: thunk(async (actions, round, helpers) => {
try { try {
showLoading() showLoading()
let { stageDetail: pre } = helpers.getState()
const { data: stageDetail } = await getStageDetail(round) const { data: stageDetail } = await getStageDetail(round)
actions.updateState({ stageDetail }) if (pre?.id !== stageDetail?.id) {
pre = null
}
actions.updateState({ stageDetail, stageDetailPre: pre })
hideLoading() hideLoading()
} catch (err) { } catch (err) {
hideLoading() hideLoading()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment