Commit 6c0742f3 authored by hewenhao's avatar hewenhao

feat: update

parent a49df9b3
...@@ -4,7 +4,7 @@ import { useMemo, useState, useEffect, useRef, useCallback } from 'react' ...@@ -4,7 +4,7 @@ import { useMemo, useState, useEffect, useRef, useCallback } from 'react'
import Modal from '@/components/Modal' import Modal from '@/components/Modal'
import Button from '@/components/Button' import Button from '@/components/Button'
import { useBoolean, useRequest, useShare, useFocus } from '@/hooks' import { useBoolean, useRequest, useShare } from '@/hooks'
import { createTribe } from '@/api/group' import { createTribe } from '@/api/group'
import { useStoreActions, useStoreState } from '@/store/hooks' import { useStoreActions, useStoreState } from '@/store/hooks'
import type { TabbarRef } from '@/custom-tab-bar/index' import type { TabbarRef } from '@/custom-tab-bar/index'
...@@ -21,21 +21,6 @@ import ShareButton from './components/share-button' ...@@ -21,21 +21,6 @@ import ShareButton from './components/share-button'
import styles from './index.module.scss' import styles from './index.module.scss'
import memberStyles from './components/members.module.scss' import memberStyles from './components/members.module.scss'
function LazyPlayer () {
const player = useStoreState(state => state.mainModel.player)
const isFocus = useFocus()
useEffect(() => {
if (isFocus) {
player.play()
} else {
player.pause()
}
}, [player, isFocus])
return null
}
const randomPick = (arr: string[]) => { const randomPick = (arr: string[]) => {
const len = arr.length const len = arr.length
const randomIndex = Math.floor(Math.random() * len) const randomIndex = Math.floor(Math.random() * len)
...@@ -49,7 +34,6 @@ const Group = () => { ...@@ -49,7 +34,6 @@ const Group = () => {
const dataRef = useRef<NickNameWord>({ noun: [], adj: [] }) const dataRef = useRef<NickNameWord>({ noun: [], adj: [] })
const [groupNo, setGroupNo] = useState('') const [groupNo, setGroupNo] = useState('')
const [refresher, { toggle }] = useBoolean(false) const [refresher, { toggle }] = useBoolean(false)
const [isRender, renderAction] = useBoolean(false)
const userInfo = useStoreState(state => state.userModel.userInfo) const userInfo = useStoreState(state => state.userModel.userInfo)
const tribeInfo = useStoreState(state => state.groupModel.tribeInfo) const tribeInfo = useStoreState(state => state.groupModel.tribeInfo)
...@@ -67,12 +51,6 @@ const Group = () => { ...@@ -67,12 +51,6 @@ const Group = () => {
setGroupNo(nam) setGroupNo(nam)
}, []) }, [])
useEffect(() => {
setTimeout(() => {
renderAction.setTrue()
}, 0)
}, [renderAction])
useEffect(() => { useEffect(() => {
const fn = async () => { const fn = async () => {
const words = await getNickNameWords('words') const words = await getNickNameWords('words')
...@@ -134,7 +112,6 @@ const Group = () => { ...@@ -134,7 +112,6 @@ const Group = () => {
return ( return (
<View> <View>
{isRender && <LazyPlayer />}
<TopHeader /> <TopHeader />
<ScrollView <ScrollView
refresherEnabled={!!tribeInfo?.id} refresherEnabled={!!tribeInfo?.id}
......
...@@ -3,6 +3,7 @@ import { ...@@ -3,6 +3,7 @@ import {
getMenuButtonBoundingClientRect, getMenuButtonBoundingClientRect,
getCurrentInstance, getTabBar, pageScrollTo, getSystemInfoSync, getCurrentInstance, getTabBar, pageScrollTo, getSystemInfoSync,
nextTick, nextTick,
onAppHide,
} from '@tarojs/taro' } from '@tarojs/taro'
import { useMemo, useCallback, useEffect } from 'react' import { useMemo, useCallback, useEffect } from 'react'
import { useStoreActions, useStoreState } from '@/store/hooks' import { useStoreActions, useStoreState } from '@/store/hooks'
...@@ -40,12 +41,13 @@ const MainPage = () => { ...@@ -40,12 +41,13 @@ const MainPage = () => {
const isFocus = useFocus() const isFocus = useFocus()
onAppHide(() => {
player.pause()
})
useEffect(() => { useEffect(() => {
if (isFocus) { if (isFocus) {
player.play() player.play()
} else {
console.log(222)
player.pause()
} }
}, [player, isFocus]) }, [player, isFocus])
......
...@@ -106,6 +106,7 @@ const StageComp = (props: StageProps) => { ...@@ -106,6 +106,7 @@ const StageComp = (props: StageProps) => {
const { stage } = props const { stage } = props
const updateState = useStoreActions(actions => actions.gameModel.updateState) const updateState = useStoreActions(actions => actions.gameModel.updateState)
const isReady = useStoreState(state => state.mainModel.isReady) const isReady = useStoreState(state => state.mainModel.isReady)
const player = useStoreState(state => state.mainModel.player)
const renderRound = (ready: boolean) => { const renderRound = (ready: boolean) => {
switch (stage.status) { switch (stage.status) {
...@@ -149,6 +150,7 @@ const StageComp = (props: StageProps) => { ...@@ -149,6 +150,7 @@ const StageComp = (props: StageProps) => {
/** 从首页进入更新状态 */ /** 从首页进入更新状态 */
updateState({ isSubmit: false }) updateState({ isSubmit: false })
navigateTo({ url: `/pages/prepare/index?id=${stage.id}` }) navigateTo({ url: `/pages/prepare/index?id=${stage.id}` })
player.stop()
} }
} }
......
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