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
a0f24073
Commit
a0f24073
authored
Apr 21, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 错题页guide
parent
8c76a101
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
282 additions
and
38 deletions
+282
-38
.oss
assets/complete/.oss
+6
-0
err-arrow.png
assets/complete/err-arrow.png
+0
-0
assets-complete.ts
src/assets/oss/assets-complete.ts
+5
-0
complete-head.module.scss
src/pages/game/complete/components/complete-head.module.scss
+109
-1
complete-head.tsx
src/pages/game/complete/components/complete-head.tsx
+98
-27
index.ts
src/pages/game/play/model/index.ts
+23
-5
utils.ts
src/pages/game/play/model/utils.ts
+25
-4
stage.tsx
src/pages/main/components/scene/stage.tsx
+1
-1
model.ts
src/pages/main/model.ts
+11
-0
storage.ts
src/utils/storage.ts
+4
-0
No files found.
assets/complete/.oss
View file @
a0f24073
...
...
@@ -100,5 +100,11 @@
"w": 686,
"h": 320,
"ossName": "/pk-math/36jdXR2vuZH8FpKTZAji36dtpFfr/686x320"
},
"err-arrow.png": {
"u": "https://cdn.jkwljy.com/pk-math/4HgeLGu9D9s7M1gQ8K7huUcx9sW5/20x20",
"w": 20,
"h": 20,
"ossName": "/pk-math/4HgeLGu9D9s7M1gQ8K7huUcx9sW5/20x20"
}
}
assets/complete/err-arrow.png
0 → 100644
View file @
a0f24073
323 Bytes
src/assets/oss/assets-complete.ts
View file @
a0f24073
...
...
@@ -85,5 +85,10 @@ export default {
"u"
:
"https://cdn.jkwljy.com/pk-math/36jdXR2vuZH8FpKTZAji36dtpFfr/686x320"
,
"w"
:
686
,
"h"
:
320
},
"err-arrow.png"
:
{
"u"
:
"https://cdn.jkwljy.com/pk-math/4HgeLGu9D9s7M1gQ8K7huUcx9sW5/20x20"
,
"w"
:
20
,
"h"
:
20
}
}
as
const
src/pages/game/complete/components/complete-head.module.scss
View file @
a0f24073
...
...
@@ -55,10 +55,103 @@
padding
:
0
70px
;
display
:
flex
;
align-items
:
center
;
justify-content
:
space-between
;
margin-top
:
-14px
;
}
.guide_inner
{
width
:
100vw
;
display
:
flex
;
}
.guide
{
position
:
absolute
;
left
:
0
;
right
:
0
;
bottom
:
0
;
transform
:
translateY
(
100%
);
display
:
flex
;
justify-content
:
center
;
animation-name
:
fadeIn_2
;
animation-duration
:
.5s
;
animation-timing-function
:
ease-out
;
animation-iteration-count
:
1
;
animation-fill-mode
:
backwards
;
animation-delay
:
0s
;
}
@keyframes
fadeIn_2
{
0
%
{
opacity
:
0
;
}
100
%
{
opacity
:
1
;
}
}
.guide_icon
{
width
:
200px
;
height
:
300px
;
}
.guide_modal
{
width
:
510px
;
padding
:
24px
20px
0
42px
;
box-sizing
:
border-box
;
background-size
:
100%
100%
;
margin-top
:
60px
;
height
:
184px
;
background-image
:
url(https://cdn.jkwljy.com/pk-math/2LZyrqzLwgYFGvJEb1vteEo4KL2r/510x184)
;
font-size
:
28px
;
font-weight
:
500
;
color
:
rgba
(
70
,
81
,
100
,
0
.8
);
line-height
:
44px
;
.em
{
color
:
#FFC056
;
}
}
.continue
{
display
:
flex
;
justify-content
:
flex-end
;
}
.continue_btn
{
display
:
flex
;
justify-content
:
flex-end
;
align-items
:
center
;
font-size
:
28px
;
font-weight
:
500
;
color
:
#1786F7
;
padding
:
2px
8px
2px
20px
;
margin-right
:
-8px
;
line-height
:
40px
;
}
.continue_icon
{
width
:
28px
;
height
:
28px
;
display
:
block
;
margin-left
:
4px
;
}
.content_wrap
{
border-radius
:
40px
;
&
:
:
after
{
content
:
" "
;
position
:
absolute
;
left
:
-16px
;
right
:
-16px
;
top
:
-16px
;
bottom
:
-16px
;
pointer-events
:
none
;
border
:
4px
dashed
#fff
;
border-radius
:
58px
;
}
}
.item
{
display
:
flex
;
align-items
:
center
;
...
...
@@ -68,6 +161,11 @@
animation-timing-function
:
ease-out
;
animation-fill-mode
:
backwards
;
animation-iteration-count
:
1
;
margin-right
:
38px
;
&
:last-child
{
margin-right
:
0px
;
}
&
:nth-child
(
1
)
{
animation-delay
:
0
;
...
...
@@ -115,6 +213,16 @@
margin-left
:
-30px
;
}
.err_icon
{
width
:
20px
;
height
:
20px
;
margin-left
:
2px
;
}
.err
{
padding-left
:
32px
;
box-sizing
:
border-box
;
color
:
#FF7770
;
min-width
:
164px
;
padding-right
:
20px
;
}
src/pages/game/complete/components/complete-head.tsx
View file @
a0f24073
import
{
View
,
Image
}
from
'@tarojs/components'
import
{
useMemo
,
useEffect
}
from
'react'
import
{
View
,
Image
,
Text
}
from
'@tarojs/components'
import
{
useMemo
,
useEffect
,
useState
}
from
'react'
import
{
getMenuButtonBoundingClientRect
,
navigateTo
}
from
'@tarojs/taro'
import
classNames
from
'classnames'
import
assets
from
'@/assets/oss/assets-complete'
import
{
useFormatTick
}
from
'@/hooks/use-format-tick'
import
{
StageLevel
,
StageType
}
from
'@/api'
import
{
useStoreState
}
from
'@/store/hooks'
import
{
StageLevel
}
from
'@/api'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
{
palyAudio
}
from
'@/utils/play-audio'
import
audio
from
'@/assets/oss/assets-audio'
import
tutorialAssets
from
'@/assets/oss/assets-tutorial'
import
{
UserGuideView
}
from
'@/components'
import
styles
from
'./complete-head.module.scss'
...
...
@@ -27,21 +29,21 @@ const getLevelBigBg = (s?: StageLevel | null): string => {
return
assets
[
'level-big-fail.png'
].
u
}
const
getWeight
=
(
s
?:
StageLevel
|
null
)
=>
{
switch
(
s
)
{
case
StageLevel
.
S
:
{
return
100
}
case
StageLevel
.
A
:
{
return
50
}
case
StageLevel
.
B
:
{
return
25
}
}
return
0
}
//
const getWeight = (s?: StageLevel | null) => {
//
switch (s) {
//
case StageLevel.S: {
//
return 100
//
}
//
case StageLevel.A: {
//
return 50
//
}
//
case StageLevel.B: {
//
return 25
//
}
//
}
//
return 0
//
}
const
getAudioSrc
=
(
s
?:
StageLevel
|
null
)
=>
{
if
(
!
s
)
{
...
...
@@ -102,11 +104,14 @@ const getInearGradient = (s?: StageLevel | null) => {
const
GameCompleteHead
=
()
=>
{
const
nav
=
useMemo
(
getMenuButtonBoundingClientRect
,
[])
const
gameResult
=
useStoreState
(
state
=>
state
.
gameModel
.
gameResult
)
const
stageDetail
=
useStoreState
(
state
=>
state
.
gameModel
.
stageDetail
)
const
time
=
useFormatTick
((
gameResult
?.
resultTime
??
0
)
*
1000
)
const
au
=
useMemo
(()
=>
getAudioSrc
(
gameResult
?.
level
),
[
gameResult
?.
level
])
const
errQuestionGuideComplete
=
useStoreState
(
state
=>
state
.
mainModel
.
errQuestionGuideComplete
)
const
completeErrQuestionGuide
=
useStoreActions
(
actions
=>
actions
.
mainModel
.
completeErrQuestionGuide
)
const
[
isActive
,
setIsActive
]
=
useState
(
false
)
useEffect
(()
=>
{
palyAudio
(
au
)
...
...
@@ -133,8 +138,6 @@ const GameCompleteHead = () => {
return
{
text
:
_text
,
color
}
},
[
gameResult
])
const
isOneStop
=
useMemo
(()
=>
stageDetail
?.
type
===
StageType
.
OneStop
,
[
stageDetail
?.
type
])
const
style
=
useMemo
(()
=>
{
return
{
paddingTop
:
`
${
nav
.
top
-
5
}
px`
...
...
@@ -149,6 +152,45 @@ const GameCompleteHead = () => {
}
}
const
completeGuide
=
()
=>
{
completeErrQuestionGuide
()
setIsActive
(
false
)
}
const
completeGuideAndGo
=
()
=>
{
completeGuide
()
goWrong
()
}
const
errCountMsg
=
useMemo
(()
=>
{
if
(
!
gameResult
)
{
return
'-'
}
if
(
gameResult
.
isTimeout
)
{
return
'-'
}
if
(
gameResult
.
errNum
===
0
)
{
return
'全对'
}
return
`错
${
gameResult
.
errNum
}
题`
},
[
gameResult
])
useEffect
(()
=>
{
if
(
!
gameResult
)
return
let
timer
if
(
!
errQuestionGuideComplete
&&
gameResult
.
errNum
>
0
&&
!
gameResult
.
isTimeout
)
{
timer
=
setTimeout
(()
=>
{
setIsActive
(
true
)
},
1000
)
}
return
()
=>
{
if
(
timer
)
{
clearTimeout
(
timer
)
}
}
},
[
errQuestionGuideComplete
,
gameResult
])
if
(
!
gameResult
)
{
return
null
}
...
...
@@ -162,12 +204,41 @@ const GameCompleteHead = () => {
<
Image
src=
{
require
(
'../assets/bonus.png'
)
}
className=
{
styles
.
icon
}
></
Image
>
<
View
className=
{
styles
.
item_text
}
>
+
{
bonus
}
</
View
>
</
View
>
{
!
isOneStop
&&
(
<
View
className=
{
styles
.
item
}
onClick=
{
goWrong
}
>
<
Image
src=
{
require
(
'../assets/right-count.png'
)
}
className=
{
styles
.
icon
}
></
Image
>
<
View
className=
{
classNames
(
styles
.
item_text
,
gameResult
.
errNum
>
0
&&
styles
.
err
)
}
>
{
gameResult
.
errNum
===
0
?
'全对'
:
`错${gameResult.errNum}题`
}
</
View
>
<
UserGuideView
className=
{
styles
.
item
}
onClick=
{
goWrong
}
isActive=
{
isActive
}
compnent=
{
View
}
wrapClass=
{
styles
.
content_wrap
}
verticalPadding=
{
5
}
horizonPadding=
{
10
}
onClickConent=
{
completeGuideAndGo
}
guideContent=
{
(
<
View
className=
{
styles
.
guide
}
>
<
View
className=
{
styles
.
guide_inner
}
>
<
Image
src=
{
tutorialAssets
[
'cat.png'
].
u
}
className=
{
styles
.
guide_icon
}
></
Image
>
<
View
className=
{
styles
.
guide_modal
}
>
<
View
>
点击此处,可以查看
<
Text
className=
{
styles
.
em
}
>
本次闯关的错题
</
Text
>
哦~
</
View
>
<
View
className=
{
styles
.
continue
}
>
<
View
className=
{
styles
.
continue_btn
}
onClick=
{
completeGuide
}
>
我知道了
<
Image
src=
{
tutorialAssets
[
'continue-arrow.png'
].
u
}
className=
{
styles
.
continue_icon
}
/>
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
)
}
>
<
Image
src=
{
require
(
'../assets/right-count.png'
)
}
className=
{
styles
.
icon
}
></
Image
>
<
View
className=
{
classNames
(
styles
.
item_text
,
gameResult
.
errNum
>
0
&&
styles
.
err
)
}
>
{
errCountMsg
}
{
!
gameResult
.
isTimeout
&&
gameResult
.
errNum
>
0
&&
(
<
Image
src=
{
assets
[
'err-arrow.png'
].
u
}
className=
{
styles
.
err_icon
}
></
Image
>
)
}
</
View
>
)
}
</
UserGuideView
>
<
View
className=
{
styles
.
item
}
>
<
Image
src=
{
require
(
'../assets/time.png'
)
}
className=
{
styles
.
icon
}
></
Image
>
<
View
className=
{
classNames
(
styles
.
item_text
,
gameResult
.
isTimeout
&&
styles
.
err
)
}
>
{
time
.
minutes
}
:
{
time
.
seconds
}
</
View
>
...
...
src/pages/game/play/model/index.ts
View file @
a0f24073
import
{
action
,
Action
,
computed
,
Computed
,
Thunk
,
thunk
}
from
'easy-peasy'
import
{
AppStoreModel
}
from
'@/store/store-model'
import
{
getQuestionList
,
type
StageDetail
,
getStageDetail
,
completeStage
,
StageType
,
type
CompleteStageOut
,
resumeGame
}
from
'@/api'
import
{
getQuestionList
,
StageLevel
,
type
StageDetail
,
getStageDetail
,
completeStage
,
StageType
,
type
CompleteStageOut
,
resumeGame
}
from
'@/api'
import
{
showLoading
,
hideLoading
,
showModal
,
redirectTo
,
vibrateShort
,
getCurrentInstance
,
disableAlertBeforeUnload
}
from
'@tarojs/taro'
import
assets
from
'@/assets/oss/assets-complete'
import
{
palyAudio
}
from
'@/utils/play-audio'
...
...
@@ -92,8 +92,26 @@ export interface GameModel extends GameModelState {
const
gameModel
:
GameModel
=
{
counterId
:
COUNTER_ID
,
questionList
:
[],
errList
:
[{
questionType
:
'选择题'
,
contentText
:
'一家超市有50个西瓜,要将它们装入箱子中,如果每个箱子最多只装8个西瓜,下面说法不正确的是'
,
simpleType
:
false
,
questionItems
:
null
,
answers
:
[{
contentText
:
'B'
,
sort
:
1
}],
options
:
[{
index
:
'A'
,
contentText
:
'超市至少需要7个箱子才能将西瓜装下'
,
answer
:
false
,
userAnswer
:
false
},
{
index
:
'B'
,
contentText
:
'超市需要6个箱子就能将西瓜装下'
,
answer
:
true
,
userAnswer
:
false
},
{
index
:
'C'
,
contentText
:
'如果超市只有6个箱子的话,还有2个西瓜装不下'
,
answer
:
false
,
userAnswer
:
true
}],
userAnswers
:
null
,
sort
:
5
,
index
:
1
},
{
questionType
:
'选择题'
,
contentText
:
'33根甘蔗平均分给5只大象,下面说法不正确的是'
,
simpleType
:
false
,
questionItems
:
null
,
answers
:
[{
contentText
:
'B'
,
sort
:
1
}],
options
:
[{
index
:
'A'
,
contentText
:
'最终剩下了3根甘蔗没有分'
,
answer
:
false
,
userAnswer
:
false
},
{
index
:
'B'
,
contentText
:
'最终5只大象共分了33根甘蔗'
,
answer
:
true
,
userAnswer
:
false
},
{
index
:
'C'
,
contentText
:
'最终5只大象共分了30根甘蔗'
,
answer
:
false
,
userAnswer
:
true
}],
userAnswers
:
null
,
sort
:
12
,
index
:
3
},
{
questionType
:
'选择题'
,
contentText
:
'五月奇奇班上去春游,加上老师一共49人,由小车来运送,每辆小车只能坐6名客人,下面说法不正确的是'
,
simpleType
:
false
,
questionItems
:
null
,
answers
:
[{
contentText
:
'C'
,
sort
:
1
}],
options
:
[{
index
:
'A'
,
contentText
:
'如果只有8辆车,那么有1人不能上车'
,
answer
:
false
,
userAnswer
:
true
},
{
index
:
'B'
,
contentText
:
'需要9辆车,全班出游才够'
,
answer
:
false
,
userAnswer
:
false
},
{
index
:
'C'
,
contentText
:
'必须要10辆车,全班才能出游'
,
answer
:
true
,
userAnswer
:
false
}],
userAnswers
:
null
,
sort
:
16
,
index
:
4
},
{
questionType
:
'选择题'
,
contentText
:
'乐乐有38个玻璃球,要将它们平均存放进5个罐子上,下面说法不正确的是'
,
simpleType
:
false
,
questionItems
:
null
,
answers
:
[{
contentText
:
'B'
,
sort
:
1
}],
options
:
[{
index
:
'A'
,
contentText
:
'乐乐无法把所有玻璃球平均放进5个罐子里'
,
answer
:
false
,
userAnswer
:
false
},
{
index
:
'B'
,
contentText
:
'乐乐可以将所有玻璃球平均地放到5个罐子里'
,
answer
:
true
,
userAnswer
:
false
},
{
index
:
'C'
,
contentText
:
'如果每个罐子可以放8个玻璃球,那么所有玻璃球都可以放下'
,
answer
:
false
,
userAnswer
:
true
}],
userAnswers
:
null
,
sort
:
28
,
index
:
5
}]
as
unknown
as
QuestionType
[],
gameResult
:
null
,
errList
:
[],
gameResult
:
{
/** 排名档位 */
gear
:
10
,
isTimeout
:
false
,
gearReward
:
10
,
levelBefore
:
StageLevel
.
B
,
levelReward
:
20
,
upGearReward
:
40
,
errNum
:
12
,
/** 成就等级:SAB */
level
:
StageLevel
.
S
,
levelTime
:
50
,
/** 排名 */
ranks
:
[],
/** 耗时 */
resultTime
:
60
,
/** 是否升档奖励 */
upGear
:
true
},
bornTimes
:
3
,
modalContinueVisible
:
false
,
gameStartTime
:
0
,
...
...
@@ -306,14 +324,14 @@ const gameModel: GameModel = {
actions
.
updateState
({
isSubmit
:
true
})
stopCounter
()
const
{
questionList
,
stageDetail
}
=
helpers
.
getState
()
const
{
errList
,
...
rest
}
=
buildCompleteStageParam
(
questionList
,
stageDetail
!
,
getCounter
()?.
getCount
()
??
0
)
const
{
errList
,
errNum
,
...
rest
}
=
buildCompleteStageParam
(
questionList
,
stageDetail
!
,
getCounter
()?.
getCount
()
??
0
)
const
{
data
:
gameResult
}
=
await
completeStage
(
rest
)
actions
.
updateState
({
errList
,
gameResult
:
{
...
gameResult
,
isTimeout
:
rest
.
isTimeout
,
errNum
:
rest
.
num
-
rest
.
correctNum
,
errNum
,
levelTime
:
rest
.
levelTime
}
})
...
...
src/pages/game/play/model/utils.ts
View file @
a0f24073
...
...
@@ -44,12 +44,15 @@ export function convertQuestion (question: QuestionType, itemIndex: number): Que
}
type
BuildParamsOut
=
CompleteStageParam
&
{
errList
:
QuestionType
[]
errList
:
QuestionType
[];
errNum
:
number
;
}
export
function
buildCompleteStageParam
(
questionList
:
QuestionType
[],
stageDetail
:
StageDetail
,
resultTime
:
number
):
BuildParamsOut
{
const
wrongList
=
questionList
.
filter
(
c
=>
!
determinQuestion
(
c
))
const
isAnsweredList
=
questionList
.
filter
(
answeredQuestion
)
const
wrongList
=
isAnsweredList
.
filter
(
c
=>
!
determinQuestion
(
c
))
const
wrongLength
=
wrongList
.
length
const
answeredLength
=
isAnsweredList
.
length
if
(
wrongLength
>
0
)
{
logger
.
debug
(
getStorage
(
StorageKeys
.
userInfo
)?.
userId
,
'错误列表'
,
wrongList
)
...
...
@@ -65,7 +68,7 @@ export function buildCompleteStageParam (questionList: QuestionType[], stageDeta
const
isTimeout
=
resultTime
>
bTime
const
correctNum
=
num
-
wrongLength
const
correctNum
=
answeredLength
-
wrongLength
if
(
correctNum
===
num
)
{
if
(
resultTime
<=
sTime
)
{
...
...
@@ -82,6 +85,7 @@ export function buildCompleteStageParam (questionList: QuestionType[], stageDeta
return
{
correctNum
,
errNum
:
wrongList
.
length
,
level
,
isTimeout
,
levelTime
,
...
...
@@ -118,6 +122,23 @@ function convert (inQuestion: QuestionType): CompleteQuestion {
throw
new
Error
(
'question not supported'
)
}
/** 已答题目 */
export
function
answeredQuestion
(
question
:
QuestionType
)
{
if
(
isBlankQuestion
(
question
))
{
return
question
.
answers
.
every
(
c
=>
c
.
userAnswer
)
}
if
(
isSelectionQuestion
(
question
))
{
return
question
.
options
.
some
(
c
=>
c
.
userAnswer
)
}
if
(
isVerticalDivisionQuestion
(
question
))
{
return
question
.
answers
.
every
(
c
=>
c
.
userAnswer
)
}
throw
new
Error
(
'question type not supported'
)
}
/** 判题 */
export
function
determinQuestion
(
question
:
QuestionType
)
{
if
(
isBlankQuestion
(
question
))
{
...
...
@@ -132,5 +153,5 @@ export function determinQuestion (question: QuestionType) {
return
question
.
answers
.
every
(
c
=>
c
.
userAnswer
===
c
.
contentText
)
}
throw
new
Error
(
'question not supported'
)
throw
new
Error
(
'question
type
not supported'
)
}
src/pages/main/components/scene/stage.tsx
View file @
a0f24073
...
...
@@ -112,7 +112,7 @@ const StageComp = (props: StageProps) => {
const
guideActive
=
useStoreState
(
state
=>
state
.
mainModel
.
guideActive
)
const
handleClick
=
()
=>
{
if
(
stage
.
status
!
==
StageStatus
.
DISABLED
)
{
if
(
stage
.
status
=
==
StageStatus
.
DISABLED
)
{
/** 从首页进入更新状态 */
updateState
({
isSubmit
:
false
})
navigateTo
({
url
:
`/pages/prepare/index?id=
${
stage
.
id
}
`
})
...
...
src/pages/main/model.ts
View file @
a0f24073
...
...
@@ -22,11 +22,14 @@ export interface MainModel {
player
:
InnerAudioContext
;
/** 完成首页引导 */
mainGuideComplete
:
boolean
|
null
;
/** 完成查看错题引导 */
errQuestionGuideComplete
:
boolean
|
null
;
updateState
:
Action
<
MainModel
,
Partial
<
State
<
MainModel
>>>
;
updateReady
:
Action
<
MainModel
,
boolean
>
;
updateGuideActive
:
Action
<
MainModel
,
boolean
>
;
updateStageList
:
Action
<
MainModel
,
Stage
[]
>
;
completeMainGuide
:
Thunk
<
MainModel
,
void
,
void
,
AppStoreModel
>
;
completeErrQuestionGuide
:
Thunk
<
MainModel
,
void
,
void
,
AppStoreModel
>
;
fetchStage
:
Thunk
<
MainModel
,
void
,
void
,
AppStoreModel
,
Promise
<
[
Stage
[],
Stage
[]]
>>
;
}
...
...
@@ -34,6 +37,7 @@ const mainModel: MainModel = {
isReady
:
false
,
guideActive
:
false
,
mainGuideComplete
:
getStorage
(
StorageKeys
.
mainGuideComplete
),
errQuestionGuideComplete
:
getStorage
(
StorageKeys
.
errQuestionGuideComplete
),
player
:
getPlayer
(),
stageList
:
[],
updateState
:
action
((
state
,
payload
)
=>
{
...
...
@@ -41,6 +45,13 @@ const mainModel: MainModel = {
state
[
k
]
=
payload
[
k
]
}
}),
completeErrQuestionGuide
:
thunk
(
async
(
actions
)
=>
{
actions
.
updateState
({
errQuestionGuideComplete
:
true
,
})
updateStorage
(
StorageKeys
.
errQuestionGuideComplete
,
true
)
}),
completeMainGuide
:
thunk
(
async
(
actions
)
=>
{
actions
.
updateState
({
mainGuideComplete
:
true
,
...
...
src/utils/storage.ts
View file @
a0f24073
...
...
@@ -11,12 +11,15 @@ export enum StorageKeys {
/** 完成首页引导 */
mainGuideComplete
,
/** 完成页查看错题引导 */
errQuestionGuideComplete
,
}
type
Storage
=
{
[
StorageKeys
.
userInfo
]:
UserInfo
|
null
;
[
StorageKeys
.
openid
]:
string
|
null
|
undefined
;
[
StorageKeys
.
mainGuideComplete
]:
boolean
|
null
;
[
StorageKeys
.
errQuestionGuideComplete
]:
boolean
|
null
;
}
const
store
:
Storage
=
{}
as
Storage
...
...
@@ -32,6 +35,7 @@ export function reloadStore () {
StorageKeys
.
openid
,
StorageKeys
.
userInfo
,
StorageKeys
.
mainGuideComplete
,
StorageKeys
.
errQuestionGuideComplete
,
].
forEach
((
element
)
=>
{
updateStorage
(
element
,
Taro
.
getStorageSync
(
`
${
storagePrefix
}${
element
}
`
)
??
null
)
})
...
...
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