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
35c9e17b
Commit
35c9e17b
authored
Jun 20, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 竖式加减法
parent
a5e4db02
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
38 deletions
+81
-38
math-symbol.tsx
src/pages/game/play/components/math-symbol.tsx
+3
-2
question-vertical-add-minus.module.scss
...mponents/question/question-vertical-add-minus.module.scss
+7
-3
question-vertical-add-minus.tsx
.../play/components/question/question-vertical-add-minus.tsx
+69
-26
types.ts
src/pages/game/play/types.ts
+1
-6
create-pk.tsx
src/pages/main/main-underground/create-pk.tsx
+1
-1
No files found.
src/pages/game/play/components/math-symbol.tsx
View file @
35c9e17b
...
...
@@ -23,9 +23,10 @@ const SymbolMap = {
type
MathSymbolProps
=
{
value
:
'*'
|
'+'
|
'-'
|
'/'
|
'%'
|
'>'
|
'<'
|
'='
|
'=2'
|
'.'
|
'ADD'
|
'SUB'
;
size
?:
'small'
|
'big'
;
className
?:
string
;
}
const
MathSymbol
=
({
value
,
size
=
'big'
}:
MathSymbolProps
)
=>
{
const
MathSymbol
=
({
value
,
size
=
'big'
,
className
}:
MathSymbolProps
)
=>
{
const
url
=
useMemo
(()
=>
{
return
SymbolMap
[
value
]
},
[
value
])
...
...
@@ -37,7 +38,7 @@ const MathSymbol = ({ value, size = 'big' }: MathSymbolProps) => {
return
(
<
Image
src=
{
url
}
className=
{
classNames
(
styles
.
symbol
,
{
className=
{
classNames
(
styles
.
symbol
,
className
,
{
[
styles
.
is_remaind
]:
value
===
'%'
,
[
styles
.
is_pair
]:
isPair
,
[
styles
.
is_small
]:
size
===
'small'
,
...
...
src/pages/game/play/components/question/question-vertical-add-minus.module.scss
View file @
35c9e17b
...
...
@@ -21,7 +21,7 @@
}
.item_cell
{
min-width
:
1
12
px
;
min-width
:
1
28
px
;
height
:
112px
;
display
:
flex
;
align-items
:
center
;
...
...
@@ -30,6 +30,7 @@
font-weight
:
500
;
color
:
#465164
;
line-height
:
98px
;
margin
:
0
-8px
;
}
.sign_cell
{
...
...
@@ -37,6 +38,8 @@
align-items
:
center
;
justify-content
:
center
;
height
:
112px
;
min-width
:
128px
;
margin
:
0
-8px
;
}
.left
{
...
...
@@ -53,12 +56,13 @@
.split
{
height
:
8px
;
background
:
rgba
(
23
,
134
,
247
,
0
.9
);
margin
:
1
6px
0
;
margin
:
6px
0
;
}
.c
enter
{
.c
olumn_wrap
{
display
:
flex
;
flex-direction
:
column
;
gap
:
10px
;
}
.place_holder
{
...
...
src/pages/game/play/components/question/question-vertical-add-minus.tsx
View file @
35c9e17b
...
...
@@ -6,7 +6,6 @@ import htmlParser, { Node } from 'html-parse-stringify'
import
type
{
VerticalAddMinusQuestion
}
from
'../../types'
import
styles
from
'./question-vertical-add-minus.module.scss'
import
AnswerBlank
from
'../answer-blank'
import
{
renderRichText
}
from
'./render-tichtext'
import
MathSymbol
from
'../math-symbol'
...
...
@@ -14,19 +13,6 @@ type QuestionVerticalAddMinusProps = {
question
:
VerticalAddMinusQuestion
}
type
NumberLineProps
=
{
left
:
string
;
}
const
NumberLine
=
(
props
:
NumberLineProps
)
=>
{
return
(
<
View
>
<
View
></
View
>
<
View
></
View
>
</
View
>
)
}
const
genNewNode
=
(
src
:
string
):
Node
[]
=>
{
const
tree
=
htmlParser
.
parse
(
src
)
return
tree
.
reduce
<
Node
[]
>
((
ret
,
item
)
=>
{
...
...
@@ -68,29 +54,86 @@ function computeFinalData (top: Node[], center: Node[], bottom: Node[]) {
],
right
:
[
{
key
:
1
,
nodes
:
hasTopDot
?
top
.
slice
(
topDotIndex
+
1
,
top
.
length
)
:
[]
},
{
key
:
2
,
nodes
:
hasCenterDot
?
center
.
slice
(
top
DotIndex
+
1
,
center
.
length
)
:
[]
},
{
key
:
2
,
nodes
:
hasCenterDot
?
center
.
slice
(
center
DotIndex
+
1
,
center
.
length
)
:
[]
},
{
key
:
3
,
nodes
:
[],
isSplit
:
true
},
{
key
:
4
,
nodes
:
hasBottomDot
?
bottom
.
slice
(
top
DotIndex
+
1
,
bottom
.
length
)
:
[]
},
{
key
:
4
,
nodes
:
hasBottomDot
?
bottom
.
slice
(
bottom
DotIndex
+
1
,
bottom
.
length
)
:
[]
},
]
}
}
type
FormatContentRet
=
{
sign
:
'ADD'
|
'SUB'
,
top
:
Node
[];
center
:
Node
[];
bottom
:
Node
[];
}
const
formatContent
=
(
str
:
string
):
FormatContentRet
=>
{
if
(
!
str
)
{
return
{
sign
:
'ADD'
,
top
:
[],
center
:
[],
bottom
:
[]
}
}
const
list
=
genNewNode
(
str
)
let
signIndex
=
list
.
findIndex
(
c
=>
c
.
type
===
'text'
&&
c
.
content
===
'+'
)
let
signal
:
FormatContentRet
[
'sign'
]
=
'ADD'
if
(
signIndex
===
-
1
)
{
signIndex
=
list
.
findIndex
(
c
=>
c
.
type
===
'text'
&&
c
.
content
===
'-'
)
signal
=
'SUB'
}
if
(
signIndex
===
-
1
)
{
return
{
sign
:
signal
,
top
:
[],
center
:
[],
bottom
:
[]
}
}
const
top
=
list
.
slice
(
0
,
signIndex
)
const
rightAndCenter
=
list
.
slice
(
signIndex
+
1
,
list
.
length
)
const
equalIndex
=
rightAndCenter
.
findIndex
(
c
=>
c
.
type
===
'text'
&&
c
.
content
===
'='
)
if
(
equalIndex
===
-
1
)
{
return
{
sign
:
signal
,
top
:
[],
center
:
[],
bottom
:
[]
}
}
const
center
=
rightAndCenter
.
slice
(
0
,
equalIndex
)
const
bottom
=
rightAndCenter
.
slice
(
equalIndex
+
1
,
rightAndCenter
.
length
)
return
{
sign
:
signal
,
top
,
center
,
bottom
}
}
const
QuestionVerticalAddMinus
=
(
props
:
QuestionVerticalAddMinusProps
)
=>
{
const
{
question
}
=
props
const
sign
=
question
.
questionItems
[
3
].
contentText
const
preGen
=
useMemo
(()
=>
{
return
formatContent
(
question
.
contentText
)
},
[
question
.
contentText
])
const
contentTreeInfo
=
useMemo
(()
=>
{
const
top
=
genNewNode
(
question
.
questionItems
[
0
].
contentText
)
const
center
=
genNewNode
(
question
.
questionItems
[
1
].
contentText
)
const
bottom
=
genNewNode
(
question
.
questionItems
[
2
].
contentText
)
return
computeFinalData
(
top
,
center
,
bottom
)
},
[
question
.
questionItems
])
return
computeFinalData
(
preGen
.
top
,
preGen
.
center
,
preGen
.
bottom
)
},
[
preGen
])
return
(
<
View
className=
{
classNames
(
styles
.
content
)
}
>
<
View
className=
{
styles
.
gap
}
></
View
>
<
View
className=
{
styles
.
question_content
}
>
<
View
>
<
View
className=
{
styles
.
column_wrap
}
>
{
contentTreeInfo
.
left
.
map
(
item
=>
{
if
(
item
.
isSplit
)
{
return
(
...
...
@@ -102,7 +145,7 @@ const QuestionVerticalAddMinus = (props: QuestionVerticalAddMinusProps) => {
<
View
key=
{
item
.
key
}
className=
{
styles
.
left
}
>
{
item
.
hasSign
&&
(
<
View
className=
{
styles
.
sign_cell
}
>
<
MathSymbol
value=
{
sign
}
></
MathSymbol
>
<
MathSymbol
value=
{
preGen
.
sign
}
></
MathSymbol
>
</
View
>
)
}
{
item
.
nodes
.
map
((
node
,
index
)
=>
(
...
...
@@ -112,7 +155,7 @@ const QuestionVerticalAddMinus = (props: QuestionVerticalAddMinusProps) => {
)
})
}
</
View
>
<
View
className=
{
styles
.
c
enter
}
>
<
View
className=
{
styles
.
c
olumn_wrap
}
>
{
contentTreeInfo
.
center
.
map
(
item
=>
{
if
(
item
.
isSplit
)
{
return
(
...
...
@@ -131,7 +174,7 @@ const QuestionVerticalAddMinus = (props: QuestionVerticalAddMinusProps) => {
)
})
}
</
View
>
<
View
>
<
View
className=
{
styles
.
column_wrap
}
>
{
contentTreeInfo
.
right
.
map
(
item
=>
{
if
(
item
.
isSplit
)
{
return
(
...
...
src/pages/game/play/types.ts
View file @
35c9e17b
...
...
@@ -43,12 +43,7 @@ export interface VerticalDivisionQuestion extends QuestionItem {
export
interface
VerticalAddMinusQuestion
extends
QuestionItem
{
questionType
:
'竖式加减法'
;
questionItems
:
[
RandomQuestionItem
,
RandomQuestionItem
,
RandomQuestionItem
,
RandomQuestionSign
];
contentText
:
string
;
}
export
interface
FractionAddMinusQuestion
extends
QuestionItem
{
...
...
src/pages/main/main-underground/create-pk.tsx
View file @
35c9e17b
...
...
@@ -145,7 +145,7 @@ const CreatePk = (props: CreatePkProps) => {
)
}
>
<
Image
src=
{
assetsMainNext
[
'pk-wechat-logo.png'
].
u
}
className=
{
styles
.
wechat_logo
}
></
Image
>
<
View
>
发给同学好友进行P
k
</
View
>
<
View
>
发给同学好友进行P
K
</
View
>
</
UserGuideView
>
<
View
className=
{
styles
.
tips
}
>
会以你的最佳表现与对方答题数据进行PK
</
View
>
...
...
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