Commit 0c073857 authored by hewenhao's avatar hewenhao

feat: update

parent 95dcb112
......@@ -92,6 +92,6 @@ export function getNickNameWords (url = 'nickname-words') {
method: 'GET',
url: `https://cdn.jkwljy.com/pk-math/setting/${url}.json?d=${Date.now()}`,
header: { 'Cache-Control': 'no-cache' },
timeout: 800
timeout: 30000
}).then(({ data }) => data)
}
......@@ -29,7 +29,7 @@ const Scene6 = (props: Scene6Props) => {
const genName = useCallback(() => {
const { noun, adj } = dataRef.current
const nam = `${randomPick(adj)}${randomPick(noun)}`
const nam = [randomPick(adj), randomPick(noun)].filter(Boolean).join('')
setName(nam)
}, [])
......@@ -52,9 +52,19 @@ const Scene6 = (props: Scene6Props) => {
})
}, [updateNickNameAndPhone, onNext, name])
const _getNickNameWords = useCallback(async () => {
const words = await getNickNameWords()
dataRef.current = words
genName()
}, [genName])
const handleGen = useCallback(() => {
genActions.setTrue()
genName()
if (dataRef.current.adj.length < 1) {
_getNickNameWords()
} else {
genName()
}
if (timerRef.current) {
clearTimeout(timerRef.current)
}
......@@ -62,16 +72,11 @@ const Scene6 = (props: Scene6Props) => {
genActions.setFalse()
timerRef.current = null
}, 1000)
}, [genName, genActions])
}, [genName, genActions, _getNickNameWords])
useEffect(() => {
const fn = async () => {
const words = await getNickNameWords()
dataRef.current = words
genName()
}
fn()
}, [genName])
_getNickNameWords()
}, [_getNickNameWords])
return (
<View className={cs.viewport}>
......
......@@ -38,6 +38,7 @@ const Prepare = () => {
const tribeInfo = useStoreState(state => state.groupModel.tribeInfo)
const stageList = useStoreState(state => state.mainModel.stageList)
const setting = useStoreState(state => state.userModel.setting)
const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount)
const getStageDetail = useStoreActions(actions => actions.gameModel.getStageDetail)
const getQuestionList = useStoreActions(actions => actions.gameModel.getQuestionList)
const updateState = useStoreActions(actions => actions.gameModel.updateState)
......@@ -66,6 +67,7 @@ const Prepare = () => {
}, [nav.height, nav.top])
useDidShow(async () => {
fetchAccount()
toggleLoad()
await getStageDetail(+router.params.id || 1)
toggleLoad()
......
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