Commit 5361e814 authored by hewenhao's avatar hewenhao

feat: 接口修改

parent 55287d13
......@@ -43,6 +43,7 @@ export interface GameModel {
updateList: Action<GameModel, QuestionType[]>;
getQuestionList: Thunk<GameModel, number, void, AppStoreModel>;
getStageDetail: Thunk<GameModel, number, void, AppStoreModel>;
handleGoNext: Thunk<GameModel, void, void, AppStoreModel>;
isSubmit: boolean;
......@@ -189,6 +190,25 @@ const gameModel: GameModel = {
actions.updateCurrentIndex(currentQuestionIndex + 1)
}),
getStageDetail: thunk(async (actions, round) => {
try {
showLoading()
const { data: stageDetail } = await getStageDetail(round)
actions.updateState({ stageDetail })
hideLoading()
} catch (err) {
hideLoading()
showModal({
title: '提示',
content: err.message || '出错了',
showCancel: false,
})
actions.updateState({
stageDetail: null
})
}
}),
getQuestionList: thunk(async (actions, round) => {
try {
showLoading()
......
......@@ -12,13 +12,13 @@ import styles from './index.module.scss'
const Prepare: React.FC = () => {
const stageDetail = useStoreState(state => state.gameModel.stageDetail)
const getQuestionList = useStoreActions(actions => actions.gameModel.getQuestionList)
const getStageDetail = useStoreActions(actions => actions.gameModel.getStageDetail)
const router = useRouter<{ id: string }>()
useEffect(() => {
getQuestionList(+router.params.id || 1)
}, [router, getQuestionList])
getStageDetail(+router.params.id || 1)
}, [router, getStageDetail])
const tabs: TabItem[] = [
{ label: '成都排行榜', children: <ScrollRankList users={stageDetail?.ranks!} /> },
......
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