Commit 44a1929d authored by raca's avatar raca
parents b2ba157d 8e2d9dae
......@@ -37,6 +37,7 @@ const startCounter = () => getCounter()?.start()
interface GameModelState {
/** 题目列表 */
questionList: QuestionType[];
stageDetailPre: StageDetail | null;
stageDetail: StageDetail | null;
gameResult: CompleteStageDetail | null;
gameStartTime: number;
......@@ -97,6 +98,7 @@ const gameModel: GameModel = {
rightIcon: null,
stageDetail: null,
stageDetailPre: null,
updateState: action((state, obj) => {
for (const key in obj) {
......@@ -237,11 +239,15 @@ const gameModel: GameModel = {
}
}),
getStageDetail: thunk(async (actions, round) => {
getStageDetail: thunk(async (actions, round, helpers) => {
try {
showLoading()
let { stageDetail: pre } = helpers.getState()
const { data: stageDetail } = await getStageDetail(round)
actions.updateState({ stageDetail })
if (pre?.id !== stageDetail?.id) {
pre = null
}
actions.updateState({ stageDetail, stageDetailPre: pre })
hideLoading()
} catch (err) {
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