Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GeekLearnMathWeapp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
frontend
GeekLearnMathWeapp
Commits
e9301aa7
Commit
e9301aa7
authored
Apr 22, 2023
by
666
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 优化代码
parent
83123b6f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
+22
-12
scene-2.tsx
src/pages/prepare/guide/complete/scene-2.tsx
+22
-12
No files found.
src/pages/prepare/guide/complete/scene-2.tsx
View file @
e9301aa7
...
...
@@ -11,20 +11,27 @@ import wrapStyles from '../../components/main-header.module.scss'
const
useStepDetails
=
(
stageDetail
,
targetSteps
)
=>
{
return
useMemo
(()
=>
{
const
details
=
targetSteps
.
map
(
targetStep
=>
{
const
details
=
targetSteps
.
reduce
((
result
,
targetStep
)
=>
{
const
detail
=
stageDetail
?.
nextSteps
?.
find
(
step
=>
step
.
nextStep
===
targetStep
)
const
index
=
stageDetail
?.
nextSteps
?.
findIndex
(
step
=>
step
.
nextStep
===
targetStep
)
return
{
detail
,
index
,
if
(
detail
!==
undefined
&&
index
!==
-
1
)
{
if
([
'S'
,
'A'
,
'B'
].
includes
(
targetStep
))
{
result
.
level
=
{
detail
,
index
}
}
else
if
([
'10'
,
'20'
,
'30'
].
includes
(
targetStep
))
{
result
.
gear
=
{
detail
,
index
}
}
else
if
(
targetStep
===
'upGear'
)
{
result
.
upGear
=
{
detail
,
index
}
}
})
.
filter
(
item
=>
item
.
detail
!==
undefined
&&
item
.
index
!==
-
1
)
}
return
result
},
{})
return
details
},
[
stageDetail
?.
nextSteps
,
targetSteps
])
}
...
...
@@ -33,7 +40,7 @@ const MessageRenderer = ({ step, level, gear, upGear }) => {
const
renderMessage
=
useCallback
(()
=>
{
const
detailIndexMap
=
{
level
,
gear
,
upGear
}
const
targetStep
=
Object
.
keys
(
detailIndexMap
).
find
(
key
=>
detailIndexMap
[
key
].
index
+
2
===
step
key
=>
detailIndexMap
[
key
]
?
.
index
+
2
===
step
)
if
(
!
targetStep
)
{
...
...
@@ -88,8 +95,7 @@ export const Scene = ({ children, index }: { index: number, children: React.Reac
const
guideComplete
=
useStoreState
(
state
=>
state
.
prepareModel
.
passGuideComplete
)
const
updateState
=
useStoreActions
(
actions
=>
actions
.
prepareModel
.
updateState
)
const
stageDetail
=
useStoreState
(
state
=>
state
.
gameModel
.
stageDetail
)
const
[
level
,
gear
,
upGear
]
=
useStepDetails
(
stageDetail
,
[
'S'
,
'A'
,
'B'
,
'10'
,
'20'
,
'30'
,
'upGear'
])
const
{
level
,
gear
,
upGear
}
=
useStepDetails
(
stageDetail
,
[
'S'
,
'A'
,
'B'
,
'10'
,
'20'
,
'30'
,
'upGear'
])
const
scrollToBottom
=
useCallback
((
scrollTop
?:
number
)
=>
{
pageScrollTo
({
duration
:
600
,
...
...
@@ -109,15 +115,19 @@ export const Scene = ({ children, index }: { index: number, children: React.Reac
},
[
guideComplete
,
updateState
])
const
onClick
=
()
=>
{
const
stepDetails
=
[
level
,
gear
,
upGear
]
const
activeSteps
=
stepDetails
.
filter
(
item
=>
item
.
detail
)
const
stepDetails
=
{
level
,
gear
,
upGear
}
const
activeSteps
=
Object
.
values
(
stepDetails
).
filter
(
item
=>
item
)
const
activeStepIndex
=
activeSteps
.
length
if
(
step
===
activeStepIndex
+
1
)
{
if
(
activeStepIndex
>=
2
)
{
scrollToBottom
(
0
)
setTimeout
(()
=>
{
updateState
({
passStep
:
-
1
})
},
666
)
}
else
{
updateState
({
passStep
:
-
1
})
}
}
else
{
scrollToBottom
()
updateState
({
passStep
:
step
+
1
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment