Commit b90180ed authored by hewenhao's avatar hewenhao

feat: 优化

parent fa11ce92
...@@ -29,7 +29,6 @@ const MainPage = () => { ...@@ -29,7 +29,6 @@ const MainPage = () => {
const stageList = useStoreState(state => state.mainModel.stageList) const stageList = useStoreState(state => state.mainModel.stageList)
const player = useStoreState(state => state.mainModel.player) const player = useStoreState(state => state.mainModel.player)
const isReady = useStoreState(state => state.mainModel.isReady) const isReady = useStoreState(state => state.mainModel.isReady)
const point = useStoreState(state => state.userModel.point)
const isGroupGuideComplete = useStoreState(state => state.guideModel.isGroupGuideComplete) const isGroupGuideComplete = useStoreState(state => state.guideModel.isGroupGuideComplete)
const isMainGuideComplete = useStoreState(state => state.guideModel.isMainGuideComplete) const isMainGuideComplete = useStoreState(state => state.guideModel.isMainGuideComplete)
const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount) const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount)
...@@ -64,6 +63,7 @@ const MainPage = () => { ...@@ -64,6 +63,7 @@ const MainPage = () => {
} }
const currentIndex = stageList.findIndex(c => c.status === StageStatus.CURRENT) const currentIndex = stageList.findIndex(c => c.status === StageStatus.CURRENT)
const point = await fetchAccount()
if (point < 50 || currentIndex >= 3) { if (point < 50 || currentIndex >= 3) {
const res = await fetchTribeInfo() const res = await fetchTribeInfo()
...@@ -73,7 +73,7 @@ const MainPage = () => { ...@@ -73,7 +73,7 @@ const MainPage = () => {
} }
} }
fn() fn()
}, [point, isGroupGuideComplete, stageList, updateGroupGuideActive, userInfo, fetchTribeInfo, isMainGuideComplete, isFocus]) }, [fetchAccount, isGroupGuideComplete, stageList, updateGroupGuideActive, userInfo, fetchTribeInfo, isMainGuideComplete, isFocus])
onAppHide(() => { onAppHide(() => {
player.pause() player.pause()
......
...@@ -18,7 +18,7 @@ export interface UserModel { ...@@ -18,7 +18,7 @@ export interface UserModel {
updating: boolean; updating: boolean;
isEyeProtectionMode: boolean; isEyeProtectionMode: boolean;
updateState: Action<UserModel, Partial<State<UserModel>>>; updateState: Action<UserModel, Partial<State<UserModel>>>;
fetchAccount: Thunk<UserModel, void, void, AppStoreModel>; fetchAccount: Thunk<UserModel, void, void, AppStoreModel, Promise<number>>;
setting: SettintType; setting: SettintType;
getSetting: Thunk<UserModel, void, void, AppStoreModel>; getSetting: Thunk<UserModel, void, void, AppStoreModel>;
updateUserInfo: Thunk<UserModel, Partial<UpdateUserInfoIn>, void, AppStoreModel>; updateUserInfo: Thunk<UserModel, Partial<UpdateUserInfoIn>, void, AppStoreModel>;
...@@ -144,8 +144,10 @@ const userModel: UserModel = { ...@@ -144,8 +144,10 @@ const userModel: UserModel = {
const cardNum = list.find(c => c.accountType === 'CARD')?.amount ?? 0 const cardNum = list.find(c => c.accountType === 'CARD')?.amount ?? 0
const point = list.find(c => c.accountType === 'POINT')?.amount ?? 0 const point = list.find(c => c.accountType === 'POINT')?.amount ?? 0
actions.updateState({ cardNum, point }) actions.updateState({ cardNum, point })
return point
} catch (err) { } catch (err) {
actions.updateState({ cardNum: 0, point: 0 }) actions.updateState({ cardNum: 0, point: 0 })
return 0
} }
}) })
} }
......
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