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
e455268d
Commit
e455268d
authored
Apr 01, 2025
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: debug
parent
0df0e33e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
251 additions
and
260 deletions
+251
-260
form.component.html
form/src/app/form/form.component.html
+4
-0
form.component.ts
form/src/app/form/form.component.ts
+247
-260
No files found.
form/src/app/form/form.component.html
View file @
e455268d
...
@@ -6,6 +6,10 @@
...
@@ -6,6 +6,10 @@
亲子互动
亲子互动
</h1>
</h1>
<button
nz-button
nzType=
"primary"
style=
"margin: 30px"
(
click
)="
autoFill
()"
[
disabled
]="
bookTextList
.
length =
=
0
"
>
自动填充
</button>
<!-- <div style="margin-left: 30px; margin-top:30px; display: flex; align-items: center; ">
<!-- <div style="margin-left: 30px; margin-top:30px; display: flex; align-items: center; ">
<h3 style="margin-right: 20px;">标题文本:</h3>
<h3 style="margin-right: 20px;">标题文本:</h3>
<input type="text" nz-input [(ngModel)]="item.title" (blur)="save()" style=" width: 500px;">
<input type="text" nz-input [(ngModel)]="item.title" (blur)="save()" style=" width: 500px;">
...
...
form/src/app/form/form.component.ts
View file @
e455268d
...
@@ -55,7 +55,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -55,7 +55,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
curBookWords
=
[];
curBookWords
=
[];
selectedWord
:
any
;
selectedWord
:
any
;
bookTextList
=
[];
bookTextList
=
[];
randomSentenceList
=
[];
constructor
(
private
appRef
:
ApplicationRef
,
private
changeDetectorRef
:
ChangeDetectorRef
,
constructor
(
private
appRef
:
ApplicationRef
,
private
changeDetectorRef
:
ChangeDetectorRef
,
...
@@ -97,6 +98,32 @@ bookTextList = [];
...
@@ -97,6 +98,32 @@ bookTextList = [];
}
}
autoFill
()
{
this
.
item
.
quesArr
=
[];
this
.
addOnePageBtnClick
();
const
ques
=
this
.
item
.
quesArr
[
0
];
this
.
randomSentenceList
=
this
.
getRandomList
(
this
.
bookTextList
);
if
(
this
.
randomSentenceList
.
length
>
10
)
{
this
.
randomSentenceList
.
length
=
10
;
}
console
.
log
(
'
this.randomSentenceList :
'
+
this
.
randomSentenceList
);
ques
.
optionArr
=
[];
for
(
let
i
=
0
;
i
<
this
.
randomSentenceList
.
length
;
i
++
)
{
ques
.
optionArr
.
push
({
text
:
this
.
randomSentenceList
[
i
].
text
,
});
}
console
.
log
(
'
this.item:
'
,
this
.
item
);
}
init
()
{
init
()
{
if
(
!
this
.
item
.
quesArr
)
{
if
(
!
this
.
item
.
quesArr
)
{
...
@@ -106,7 +133,7 @@ bookTextList = [];
...
@@ -106,7 +133,7 @@ bookTextList = [];
// this.getDataPromise('e-library/v1/factory/word-exercise-cards', {
// this.getDataPromise('e-library/v1/factory/word-exercise-cards', {
// });
// });
this
.
curBookWords
=
this
.
getBookDefalutData
();
//
this.curBookWords = this.getBookDefalutData();
}
}
...
@@ -123,122 +150,8 @@ bookTextList = [];
...
@@ -123,122 +150,8 @@ bookTextList = [];
return
(
word1
&&
word2
)
?
word1
.
word
===
word2
.
word
:
word1
===
word2
;
return
(
word1
&&
word2
)
?
word1
.
word
===
word2
.
word
:
word1
===
word2
;
}
}
onSelectWordChange
(
e
,
ques
,
key
=
'
data
'
)
{
console
.
log
(
'
e:
'
,
e
);
ques
[
key
]
=
e
;
ques
.
text
=
null
;
ques
.
translation
=
null
;
ques
.
audio_url
=
null
;
ques
.
pic_url
=
null
;
ques
.
optionCount
=
0
;
ques
.
optionArr
=
[];
this
.
refreshQuesRes
(
ques
);
this
.
autoFillOption
(
ques
);
this
.
save
();
}
setOptionCount
(
e
,
ques
)
{
// 判断 最小0 最大10
ques
.
optionCount
=
Number
(
e
.
target
.
value
<
0
?
0
:
e
.
target
.
value
);
console
.
log
(
'
ques.optionArr.length:
'
,
ques
.
optionArr
.
length
);
this
.
autoFillOption
(
ques
);
this
.
save
();
}
autoFillText
(
ques
)
{
const
tempList
=
ques
.
text
.
split
(
''
);
ques
.
optionCount
=
tempList
.
length
;
ques
.
optionArr
=
[];
for
(
let
i
=
0
;
i
<
ques
.
optionCount
;
i
++
)
{
ques
.
optionArr
.
push
({
text
:
tempList
[
i
],
});
}
this
.
save
();
}
autoFillOption
(
ques
)
{
if
(
ques
.
optionTypeText
)
{
if
(
ques
.
optionCount
<=
0
)
{
const
tempList
=
ques
.
text
.
split
(
'
'
);
ques
.
optionCount
=
tempList
.
length
;
for
(
let
i
=
0
;
i
<
ques
.
optionCount
;
i
++
)
{
ques
.
optionArr
.
push
({
text
:
tempList
[
i
],
});
}
}
}
if
(
ques
.
optionArr
.
length
>
ques
.
optionCount
)
{
ques
.
optionArr
.
length
=
ques
.
optionCount
;
}
else
if
(
ques
.
optionArr
.
length
<
ques
.
optionCount
)
{
for
(
let
i
=
ques
.
optionArr
.
length
;
i
<
ques
.
optionCount
;
i
++
)
{
ques
.
optionArr
.
push
({
});
}
}
// if (ques.optionArr.length == 0) {
// console.log('add ...');
// ques.optionArr.push(
// {
// wordData: ques.wordData,
// answer: 'isRight'
// }
// );
// }
// if (ques.optionArr.length > ques.optionCount) {
// ques.optionArr.length = ques.optionCount;
// } else if (ques.optionArr.length < ques.optionCount) {
// for (let i = ques.optionArr.length; i < ques.optionCount; i++) {
// ques.optionArr.push({
// answer: 'isWrong',
// wordData: this.getUnusedWord(ques),
// });
// }
// }
// this.refreshOptionRes(ques);
}
/**
* 获取一个未在选项数组中使用过的单词
* @param ques 问题对象,包含 optionArr 选项数组
* @returns 返回一个未使用的单词对象,如果所有单词都已使用则返回 null
*/
getUnusedWord
(
ques
:
any
):
any
{
// 获取选项数组中已使用的所有单词
const
usedWords
=
ques
.
optionArr
.
map
(
option
=>
option
.
wordData
?.
word
);
// 从 curBookWords 中过滤出未使用的单词
const
availableWords
=
this
.
curBookWords
.
filter
(
word
=>
!
usedWords
.
includes
(
word
.
word
)
);
// 如果没有可用的未使用单词,返回 null
if
(
availableWords
.
length
===
0
)
{
return
null
;
}
// 从可用单词中随机返回一个
const
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
availableWords
.
length
);
return
availableWords
[
randomIndex
];
}
...
@@ -465,149 +378,6 @@ getUnusedWord(ques: any): any {
...
@@ -465,149 +378,6 @@ getUnusedWord(ques: any): any {
}
}
// 使用Promise方式的GET请求
getDataPromise
(
url
,
params
:
any
):
Promise
<
any
>
{
let
httpParams
=
new
HttpParams
();
Object
.
keys
(
params
).
forEach
(
key
=>
{
httpParams
=
httpParams
.
append
(
key
,
params
[
key
]);
});
return
this
.
http
.
get
(
`
${
this
.
baseUrl
}
/
${
url
}
`
,
{
params
:
httpParams
})
.
toPromise
()
.
then
(
response
=>
{
this
.
message
.
success
(
'
获取成功
'
);
return
response
;
})
.
catch
(
error
=>
{
this
.
message
.
error
(
'
获取失败
'
);
throw
error
;
});
}
getBookDefalutData
()
{
return
[
{
"
id
"
:
1
,
"
pictureBookId
"
:
101
,
"
word
"
:
"
elephant
"
,
"
partOfSpeech
"
:
"
noun
"
,
"
wordTranslation
"
:
"
大象
"
,
"
exampleSentence
"
:
"
The elephant is the largest land animal.
"
,
"
wordAudioUrl
"
:
"
https://staging-teach.cdn.ireadabc.com/614039db2e4c4798c4b47f9d7f10a07f.mp3
"
,
"
exampleSentenceAudioUrl
"
:
"
https://audio.com/elephant-sentence.mp3
"
,
"
exampleSentenceTranslation
"
:
"
大象是最大的陆地动物。
"
,
"
imageUrl
"
:
"
https://staging-teach.cdn.ireadabc.com/deecc7b9fcbb93cdd40cf6f8a07f7942.jpeg
"
,
"
britishPhonetic
"
:
"
ˈelɪfənt
"
,
"
americanPhonetic
"
:
"
ˈeləfənt
"
,
"
englishDefinition
"
:
"
A very large plant-eating mammal with a prehensile trunk
"
,
"
backContent
"
:
{},
"
createdTime
"
:
"
2024-03-15T08:30:00.000Z
"
},
{
"
id
"
:
2
,
"
pictureBookId
"
:
101
,
"
word
"
:
"
giraffe
"
,
"
partOfSpeech
"
:
"
noun
"
,
"
wordTranslation
"
:
"
长颈鹿
"
,
"
exampleSentence
"
:
"
The giraffe has a very long neck.
"
,
"
wordAudioUrl
"
:
"
https://staging-teach.cdn.ireadabc.com/c18e34fbfe55871a998136eaa7f66e38.mp3
"
,
"
exampleSentenceAudioUrl
"
:
"
https://audio.com/giraffe-sentence.mp3
"
,
"
exampleSentenceTranslation
"
:
"
长颈鹿有着很长的脖子。
"
,
"
imageUrl
"
:
"
https://staging-teach.cdn.ireadabc.com/954c6daccc0ab7da9c80f2d48c339a16.jpeg
"
,
"
britishPhonetic
"
:
"
dʒɪˈrɑːf
"
,
"
americanPhonetic
"
:
"
dʒəˈræf
"
,
"
englishDefinition
"
:
"
A large African mammal with a very long neck and legs
"
,
"
backContent
"
:
{},
"
createdTime
"
:
"
2024-03-15T08:31:00.000Z
"
},
{
"
id
"
:
3
,
"
pictureBookId
"
:
101
,
"
word
"
:
"
penguin
"
,
"
partOfSpeech
"
:
"
noun
"
,
"
wordTranslation
"
:
"
企鹅
"
,
"
exampleSentence
"
:
"
The penguin waddles across the ice.
"
,
"
wordAudioUrl
"
:
"
https://staging-teach.cdn.ireadabc.com/7ef29a4858d8f8593ddd14b78b114620.mp3
"
,
"
exampleSentenceAudioUrl
"
:
"
https://audio.com/penguin-sentence.mp3
"
,
"
exampleSentenceTranslation
"
:
"
企鹅在冰面上摇摇摆摆地走。
"
,
"
imageUrl
"
:
"
https://staging-teach.cdn.ireadabc.com/73c1a51a2727df3e296d6f682e0f74c0.jpeg
"
,
"
britishPhonetic
"
:
"
ˈpeŋɡwɪn
"
,
"
americanPhonetic
"
:
"
ˈpeŋɡwɪn
"
,
"
englishDefinition
"
:
"
A flightless aquatic bird of the Southern Hemisphere
"
,
"
backContent
"
:
{},
"
createdTime
"
:
"
2024-03-15T08:32:00.000Z
"
},
{
"
id
"
:
4
,
"
pictureBookId
"
:
101
,
"
word
"
:
"
butterfly
"
,
"
partOfSpeech
"
:
"
noun
"
,
"
wordTranslation
"
:
"
蝴蝶
"
,
"
exampleSentence
"
:
"
A beautiful butterfly landed on the flower.
"
,
"
wordAudioUrl
"
:
"
https://staging-teach.cdn.ireadabc.com/b195f83341ea48c59bb1d7bc36224703.mp3
"
,
"
exampleSentenceAudioUrl
"
:
"
https://audio.com/butterfly-sentence.mp3
"
,
"
exampleSentenceTranslation
"
:
"
一只美丽的蝴蝶落在花朵上。
"
,
"
imageUrl
"
:
"
https://staging-teach.cdn.ireadabc.com/d084a9eaa9cccd4b94f96f1220c2bd4b.jpeg
"
,
"
britishPhonetic
"
:
"
ˈbʌtəflaɪ
"
,
"
americanPhonetic
"
:
"
ˈbʌtərflaɪ
"
,
"
englishDefinition
"
:
"
An insect with two pairs of large wings that are often brightly colored
"
,
"
backContent
"
:
{},
"
createdTime
"
:
"
2024-03-15T08:33:00.000Z
"
},
{
"
id
"
:
5
,
"
pictureBookId
"
:
101
,
"
word
"
:
"
dolphin
"
,
"
partOfSpeech
"
:
"
noun
"
,
"
wordTranslation
"
:
"
海豚
"
,
"
exampleSentence
"
:
"
The dolphin jumped high out of the water.
"
,
"
wordAudioUrl
"
:
"
https://staging-teach.cdn.ireadabc.com/8ce06364d3384544e136e3d8579f520b.mp3
"
,
"
exampleSentenceAudioUrl
"
:
"
https://audio.com/dolphin-sentence.mp3
"
,
"
exampleSentenceTranslation
"
:
"
海豚从水中高高跃起。
"
,
"
imageUrl
"
:
"
https://staging-teach.cdn.ireadabc.com/84995798a53e78f74a9e297c684fa890.jpeg
"
,
"
britishPhonetic
"
:
"
ˈdɒlfɪn
"
,
"
americanPhonetic
"
:
"
ˈdɑːlfɪn
"
,
"
englishDefinition
"
:
"
A marine mammal known for its intelligence and playfulness
"
,
"
backContent
"
:
{},
"
createdTime
"
:
"
2024-03-15T08:34:00.000Z
"
}
]
}
// callAPIGetData(url, params: any) {
// // 构建查询参数
// let httpParams = new HttpParams();
// Object.keys(params).forEach(key => {
// httpParams = httpParams.append(key, params[key]);
// });
// // 配置请求头
// const headers = new HttpHeaders()
// // .set('Authorization', 'Bearer ' + localStorage.getItem('token'));
// // 发起GET请求
// this.http.get(`${this.baseUrl}/url`, {
// headers,
// params: httpParams
// }).subscribe({
// next: (response: any) => {
// console.log('获取数据成功:', response);
// this.message.success('获取成功');
// // 处理返回的数据
// return response;
// },
// error: (error) => {
// console.error('获取数据失败:', error);
// this.message.error('获取失败: ' + error.message);
// }
// });
// }
/**
/**
* 储存数据
* 储存数据
...
@@ -635,9 +405,206 @@ getUnusedWord(ques: any): any {
...
@@ -635,9 +405,206 @@ getUnusedWord(ques: any): any {
getBookTextLis
()
{
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;
// return;
console
.
log
(
'
in getBookTextLis
'
);
console
.
log
(
'
in getBookTextLis
'
);
const
call_back
=
(
res
)
=>
{
const
call_back
=
(
res
)
=>
{
console
.
log
(
'
getBookTextLis res:
'
,
res
);
console
.
log
(
'
getBookTextLis res:
'
,
res
);
const
resData
=
JSON
.
parse
(
res
);
if
(
resData
.
msg
==
'
success
'
)
{
this
.
bookTextList
=
resData
.
data
;
// this.getRandomList(resData.data);
}
};
};
// 检查方法是否存在
// 检查方法是否存在
...
@@ -647,11 +614,31 @@ getUnusedWord(ques: any): any {
...
@@ -647,11 +614,31 @@ getUnusedWord(ques: any): any {
action
:
'
getPictureBookTextList
'
action
:
'
getPictureBookTextList
'
},
call_back
);
},
call_back
);
}
else
{
}
else
{
setTimeout
(
checkAndCall
,
100
);
//
setTimeout(checkAndCall, 100);
}
}
};
};
checkAndCall
();
checkAndCall
();
}
}
getRandomList
(
arr
)
{
if
(
!
arr
||
arr
.
length
<=
4
)
{
return
arr
;
}
// 计算需要返回的数组长度(原数组长度减4,并确保是双数)
let
targetLength
=
arr
.
length
-
4
;
if
(
targetLength
%
2
!==
0
)
{
targetLength
--
;
// 确保是双数
}
// // 计算可以开始截取的最大起始位置
// const maxStartIndex = arr.length - targetLength;
// 随机选择一个起始位置
const
startIndex
=
Math
.
floor
(
Math
.
random
()
*
targetLength
);
// 截取数组
return
arr
.
slice
(
startIndex
,
startIndex
+
targetLength
);
}
}
}
\ No newline at end of file
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