Commit 0c073857 authored by hewenhao's avatar hewenhao

feat: update

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