Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
YM5-15
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
template admin
YM5-15
Commits
7a700602
Commit
7a700602
authored
Mar 13, 2021
by
Chen Jiping
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:支持用户手动换行,并修复句子背景宽度问题
parent
54e3909a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
28 deletions
+43
-28
form.component.ts
src/app/form/form.component.ts
+1
-1
Exercises.spreat.ts
src/app/play/Exercises.spreat.ts
+4
-3
Unit.ts
src/app/play/Unit.ts
+35
-20
play.component.ts
src/app/play/play.component.ts
+3
-4
No files found.
src/app/form/form.component.ts
View file @
7a700602
...
...
@@ -39,7 +39,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
if
(
data
)
{
this
.
item
=
data
;
}
console
.
log
(
JSON
.
stringify
(
data
)
);
console
.
log
(
data
);
this
.
init
();
this
.
changeDetectorRef
.
markForCheck
();
this
.
changeDetectorRef
.
detectChanges
();
...
...
src/app/play/Exercises.spreat.ts
View file @
7a700602
...
...
@@ -12,6 +12,8 @@ export class Exercises {
index
:
number
;
bgWidth
:
number
;
bg
:
ShapeRect
;
answer
:
ShapeRect
;
...
...
@@ -56,12 +58,11 @@ export class Exercises {
this
.
initExercises
();
let
w
=
1280
*
this
.
scaleX
;
let
h
=
140
*
this
.
scaleY
;
h
=
this
.
answer
.
height
>
h
?
this
.
answer
.
height
:
h
;
this
.
bg
.
setSize
(
w
,
h
);
this
.
bg
.
setSize
(
this
.
bgWidth
,
h
);
this
.
answer
.
y
=
(
h
-
this
.
answer
.
height
)
/
2
;
...
...
@@ -189,7 +190,7 @@ export class Exercises {
text
.
boldFontName
=
'
GOTHICB
'
;
text
.
textArr
=
getTextArr
();
text
.
disH
=
20
;
text
.
maxWidth
=
980
;
text
.
maxWidth
=
1056
;
text
.
setScaleXY
(
this
.
scaleX
);
text
.
refreshSize
();
...
...
src/app/play/Unit.ts
View file @
7a700602
...
...
@@ -1193,34 +1193,49 @@ export class RichText extends Label {
let
text
=
this
.
textArr
[
i
];
let
c
=
this
.
textArr
[
i
].
val
;
if
(
text
.
val
!=
'
'
)
{
if
(
text
.
bold
)
{
this
.
ctx
.
font
=
`
${
this
.
fontSize
}
px
${
this
.
boldFontName
}
`
;
}
else
{
this
.
ctx
.
font
=
`
${
this
.
fontSize
}
px
${
this
.
fontName
}
`
;
}
this
.
textArr
[
i
].
width
=
this
.
ctx
.
measureText
(
c
).
width
;
tempStr
+=
text
.
val
;
tempArr
.
push
(
this
.
textArr
[
i
]);
continue
}
if
(
this
.
ctx
.
measureText
(
temp
).
width
<
w
&&
this
.
ctx
.
measureText
(
temp
+
(
tempStr
)).
width
<=
w
)
{
temp
+=
'
'
+
tempStr
;
tempArr
.
push
(
getBlank
());
tempArr
.
push
(
this
.
textArr
[
i
]);
var
re
=
/
\n
/
;
}
else
{
if
(
c
.
match
(
re
))
{
row
.
push
(
tempArr
);
temp
=
'
'
+
tempStr
;
tempArr
=
[];
tempArr
.
push
(
getBlank
());
tempArr
.
push
(
this
.
textArr
[
i
]);
tempStr
=
""
;
}
else
{
if
(
text
.
val
!=
'
'
)
{
if
(
text
.
bold
)
{
this
.
ctx
.
font
=
`
${
this
.
fontSize
}
px
${
this
.
boldFontName
}
`
;
}
else
{
this
.
ctx
.
font
=
`
${
this
.
fontSize
}
px
${
this
.
fontName
}
`
;
}
this
.
textArr
[
i
].
width
=
this
.
ctx
.
measureText
(
c
).
width
;
tempStr
+=
text
.
val
;
tempArr
.
push
(
this
.
textArr
[
i
]);
continue
}
if
(
this
.
ctx
.
measureText
(
temp
).
width
<
w
&&
this
.
ctx
.
measureText
(
temp
+
(
tempStr
)).
width
<=
w
)
{
temp
+=
'
'
+
tempStr
;
tempArr
.
push
(
getBlank
());
tempArr
.
push
(
this
.
textArr
[
i
]);
}
else
{
row
.
push
(
tempArr
);
temp
=
'
'
+
tempStr
;
tempArr
=
[];
tempArr
.
push
(
getBlank
());
tempArr
.
push
(
this
.
textArr
[
i
]);
}
tempStr
=
""
;
}
tempStr
=
""
;
}
if
(
temp
!=
'
'
)
{
...
...
src/app/play/play.component.ts
View file @
7a700602
...
...
@@ -107,7 +107,7 @@ export class PlayComponent implements OnInit, OnDestroy {
else
{
this
.
data
=
defaultVal
;
}
//console.log('data:', JSON.stringify(data)
);
console
.
log
(
'
data:
'
,
data
);
// 初始化 各事件监听
this
.
initListener
();
...
...
@@ -613,9 +613,8 @@ export class PlayComponent implements OnInit, OnDestroy {
let
exercises
=
new
Exercises
();
exercises
.
index
=
index
;
exercises
.
bgWidth
=
this
.
canvasWidth
;
exercises
.
init
(
this
.
images
,
this
.
data
.
backgroudColor
,
item
,
this
.
mapScale
,
this
.
mapScale
);
return
exercises
;
}
...
...
@@ -629,7 +628,7 @@ export class PlayComponent implements OnInit, OnDestroy {
let
dH
=
35
*
this
.
mapScale
;
let
w
=
1280
*
this
.
mapScale
;
let
w
=
this
.
canvasWidth
;
let
h
=
0
*
this
.
mapScale
;
...
...
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