Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JJ_Game_Parent_Child
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
JJ_Game_Parent_Child
Commits
9e994b29
Commit
9e994b29
authored
Apr 03, 2025
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: debug
parent
3d5c914f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
219 additions
and
195 deletions
+219
-195
form.component.ts
form/src/app/form/form.component.ts
+219
-195
No files found.
form/src/app/form/form.component.ts
View file @
9e994b29
...
...
@@ -67,7 +67,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
ngOnInit
()
{
this
.
getBookTextLis
();
this
.
getBookTextLis
t
();
...
...
@@ -108,9 +108,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
const
ques
=
this
.
item
.
quesArr
[
0
];
this
.
randomSentenceList
=
this
.
getRandomList
(
this
.
bookTextList
);
if
(
this
.
randomSentenceList
.
length
>
10
)
{
this
.
randomSentenceList
.
length
=
10
;
}
//
if (this.randomSentenceList.length > 10) {
//
this.randomSentenceList.length = 10;
//
}
console
.
log
(
'
this.randomSentenceList :
'
+
this
.
randomSentenceList
);
...
...
@@ -125,6 +125,24 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this
.
save
();
}
filterDuplicateText
(
arr
:
any
[]):
any
[]
{
// 使用 Map 来记录已经出现过的 text
const
textMap
=
new
Map
();
// 使用 filter 过滤数组
return
arr
.
filter
(
item
=>
{
// 如果这个 text 还没有出现过,就把它加入 Map 并保留这个元素
if
(
!
textMap
.
has
(
item
.
text
))
{
textMap
.
set
(
item
.
text
,
true
);
return
true
;
}
// 如果这个 text 已经出现过,就过滤掉这个元素
return
false
;
});
}
init
()
{
if
(
!
this
.
item
.
quesArr
)
{
...
...
@@ -406,201 +424,204 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
},
1
);
}
getBookTextLis
()
{
let
resData1
=
{
"
msg
"
:
"
success
"
,
"
data
"
:
[
{
"
number
"
:
4
,
"
text
"
:
"
Hank Hammer
"
},
{
"
number
"
:
5
,
"
text
"
:
"
MEET THE TOOL TEAM
"
},
{
"
number
"
:
5
,
"
text
"
:
"
Tia Tape Measure
"
},
{
"
number
"
:
5
,
"
text
"
:
"
Hank Hammer
"
},
{
"
number
"
:
6
,
"
text
"
:
"
Sammy Saw
"
},
{
"
number
"
:
6
,
"
text
"
:
"
Sophie Screwdriver
"
},
{
"
number
"
:
7
,
"
text
"
:
"
Today is the big contest. Hank is very excited! He jumps out of bed.
"
},
{
"
number
"
:
8
,
"
text
"
:
"
He brushes his teeth and gets ready.
"
},
{
"
number
"
:
9
,
"
text
"
:
"
\"
Have a fun day,
\"
his mom says.
"
},
{
"
number
"
:
9
,
"
text
"
:
"
“Good luck at the contest.
\"
"
},
{
"
number
"
:
10
,
"
text
"
:
"
\"
Thanks, Mom,
\"
Hank says as he rushes out the door.
"
},
{
"
number
"
:
11
,
"
text
"
:
"
\"
Hi, everyone! Are you ready for the big contest?
\"
asks Hank.
"
},
{
"
number
"
:
12
,
"
text
"
:
"
\"
We're ready!
\"
they yell.
"
},
{
"
number
"
:
13
,
"
text
"
:
"
\"
I have the wood,
\"
says Sammy.
"
},
{
"
number
"
:
13
,
"
text
"
:
"
\"
I have the nails,
\"
says Tia.
"
},
{
"
number
"
:
14
,
"
text
"
:
"
“I have the red paint and the blue paint,
\"
says Sophie.
"
},
{
"
number
"
:
15
,
"
text
"
:
"
“And I have the plans,
\"
says Hank.
"
},
{
"
number
"
:
16
,
"
text
"
:
"
“We are going to build the best birdhouse!
\"
says Sammy.
"
},
{
"
number
"
:
17
,
"
text
"
:
"
\"
It's time to start,
\"
says Sophie.
"
},
{
"
number
"
:
17
,
"
text
"
:
"
\"
What do we do?
\"
asks Tia.
"
},
{
"
number
"
:
18
,
"
text
"
:
"
“Just follow my plan,
\"
says Hank.
"
},
{
"
number
"
:
18
,
"
text
"
:
"
“I have everything mapped out right here.
\"
"
},
{
"
number
"
:
19
,
"
text
"
:
"
“First, we measure everything,
\"
"
},
{
"
number
"
:
19
,
"
text
"
:
"
says Hank.
"
},
{
"
number
"
:
20
,
"
text
"
:
"
\"
That's my job,
\"
says Tia.
"
},
{
"
number
"
:
20
,
"
text
"
:
"
“Great!
\"
says Hank.
"
},
{
"
number
"
:
21
,
"
text
"
:
"
\"
Next, we cut the wood,
\"
"
},
{
"
number
"
:
21
,
"
text
"
:
"
says Hank.
"
},
{
"
number
"
:
22
,
"
text
"
:
"
\"
That's my job,
\"
says Sammy.
"
},
{
"
number
"
:
22
,
"
text
"
:
"
\"
Great!
\"
says Hank.
"
},
{
"
number
"
:
23
,
"
text
"
:
"
\"
Then, we put the house together,
\"
"
},
{
"
number
"
:
23
,
"
text
"
:
"
says Hank.
"
},
{
"
number
"
:
24
,
"
text
"
:
"
“I'll hold the nails. You can pound them in,
\"
says Sophie.
"
},
{
"
number
"
:
24
,
"
text
"
:
"
\"
Great!
\"
says Hank.
"
},
{
"
number
"
:
25
,
"
text
"
:
"
\"
Now we paint it,
\"
says Hank.
"
},
{
"
number
"
:
26
,
"
text
"
:
"
\"
We can all do that,
\"
says Sophie.
"
},
{
"
number
"
:
26
,
"
text
"
:
"
\"
Great!
\"
says Hank.
"
},
{
"
number
"
:
27
,
"
text
"
:
"
The birdhouse is done. The tool team sets it on the table next to the other ones.
"
},
{
"
number
"
:
28
,
"
text
"
:
"
\"
It's prefect,
\"
says Hank.
"
},
{
"
number
"
:
29
,
"
text
"
:
"
“I think we built the best one,
\"
"
},
{
"
number
"
:
29
,
"
text
"
:
"
says Sammy.
"
},
{
"
number
"
:
30
,
"
text
"
:
"
\"
And we did it together,
\"
says Tia.
"
},
{
"
number
"
:
31
,
"
text
"
:
"
\"
I have one more thing to add,
\"
"
},
{
"
number
"
:
31
,
"
text
"
:
"
says Hank.
"
},
{
"
number
"
:
32
,
"
text
"
:
"
\"
Now it's perfect,
\"
says Sammy.
"
}
]
}
this
.
bookTextList
=
resData1
.
data
;
getBookTextLis
t
()
{
//
let resData1 = {
//
"msg": "success",
//
"data": [
//
{
//
"number": 4,
//
"text": "Hank Hammer"
//
},
//
{
//
"number": 5,
//
"text": "MEET THE TOOL TEAM"
//
},
//
{
//
"number": 5,
//
"text": "Tia Tape Measure"
//
},
//
{
//
"number": 5,
//
"text": "Hank Hammer"
//
},
//
{
//
"number": 6,
//
"text": "Sammy Saw"
//
},
//
{
//
"number": 6,
//
"text": "Sophie Screwdriver"
//
},
//
{
//
"number": 7,
//
"text": "Today is the big contest. Hank is very excited! He jumps out of bed."
//
},
//
{
//
"number": 8,
//
"text": "He brushes his teeth and gets ready."
//
},
//
{
//
"number": 9,
//
"text": "\"Have a fun day,\" his mom says."
//
},
//
{
//
"number": 9,
//
"text": "“Good luck at the contest.\""
//
},
//
{
//
"number": 10,
//
"text": "\"Thanks, Mom,\" Hank says as he rushes out the door."
//
},
//
{
//
"number": 11,
//
"text": "\"Hi, everyone! Are you ready for the big contest?\" asks Hank."
//
},
//
{
//
"number": 12,
//
"text": "\"We're ready!\" they yell."
//
},
//
{
//
"number": 13,
//
"text": "\"I have the wood,\" says Sammy."
//
},
//
{
//
"number": 13,
//
"text": "\"I have the nails,\" says Tia."
//
},
//
{
//
"number": 14,
//
"text": "“I have the red paint and the blue paint,\"says Sophie."
//
},
//
{
//
"number": 15,
//
"text": "“And I have the plans,\" says Hank."
//
},
//
{
//
"number": 16,
//
"text": "“We are going to build the best birdhouse!\"says Sammy."
//
},
//
{
//
"number": 17,
//
"text": "\"It's time to start,\"says Sophie."
//
},
//
{
//
"number": 17,
//
"text": "\"What do we do?\" asks Tia."
//
},
//
{
//
"number": 18,
//
"text": "“Just follow my plan,\" says Hank."
//
},
//
{
//
"number": 18,
//
"text": "“I have everything mapped out right here.\""
//
},
//
{
//
"number": 19,
//
"text": "“First, we measure everything,\""
//
},
//
{
//
"number": 19,
//
"text": "says Hank."
//
},
//
{
//
"number": 20,
//
"text": "\"That's my job,\" says Tia."
//
},
//
{
//
"number": 20,
//
"text": "“Great!\"says Hank."
//
},
//
{
//
"number": 21,
//
"text": "\"Next, we cut the wood,\""
//
},
//
{
//
"number": 21,
//
"text": "says Hank."
//
},
//
{
//
"number": 22,
//
"text": "\"That's my job,\" says Sammy."
//
},
//
{
//
"number": 22,
//
"text": "\"Great!\" says Hank."
//
},
//
{
//
"number": 23,
//
"text": "\"Then, we put the house together,\""
//
},
//
{
//
"number": 23,
//
"text": "says Hank."
//
},
//
{
//
"number": 24,
//
"text": "“I'll hold the nails. You can pound them in,\"says Sophie."
//
},
//
{
//
"number": 24,
//
"text": "\"Great!\"says Hank."
//
},
//
{
//
"number": 25,
//
"text": "\"Now we paint it,\" says Hank."
//
},
//
{
//
"number": 26,
//
"text": "\"We can all do that,\" says Sophie."
//
},
//
{
//
"number": 26,
//
"text": "\"Great!\" says Hank."
//
},
//
{
//
"number": 27,
//
"text": "The birdhouse is done. The tool team sets it on the table next to the other ones."
//
},
//
{
//
"number": 28,
//
"text": "\"It's prefect,\"says Hank."
//
},
//
{
//
"number": 29,
//
"text": "“I think we built the best one,\""
//
},
//
{
//
"number": 29,
//
"text": "says Sammy."
//
},
//
{
//
"number": 30,
//
"text": "\"And we did it together,\" says Tia."
//
},
//
{
//
"number": 31,
//
"text": "\"I have one more thing to add,\""
//
},
//
{
//
"number": 31,
//
"text": "says Hank."
//
},
//
{
//
"number": 32,
//
"text": "\"Now it's perfect,\" says Sammy."
//
}
//
]
//
}
//
this.bookTextList = resData1.data;
// this.bookTextList = this.filterDuplicateText( this.bookTextList);
return
;
//
return;
console
.
log
(
'
in getBookTextLis
'
);
console
.
log
(
'
in getBookTextLis
t
'
);
const
call_back
=
(
res
)
=>
{
console
.
log
(
'
getBookTextLis res:
'
,
res
);
console
.
log
(
'
getBookTextLis
t
res:
'
,
res
);
const
resData
=
JSON
.
parse
(
res
);
if
(
resData
.
msg
==
'
success
'
)
{
...
...
@@ -622,6 +643,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
};
checkAndCall
();
this
.
bookTextList
=
this
.
filterDuplicateText
(
this
.
bookTextList
);
}
getRandomList
(
arr
)
{
...
...
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