Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jj_learn_word
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_learn_word
Commits
5a77febf
Commit
5a77febf
authored
May 09, 2025
by
chunsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 在表单组件中添加英美音标、英文定义和例句翻译字段,并优化课程ID获取逻辑
parent
d5e53c2b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
52 deletions
+58
-52
form.component.html
form/src/app/form/form.component.html
+24
-28
form.component.ts
form/src/app/form/form.component.ts
+34
-24
No files found.
form/src/app/form/form.component.html
View file @
5a77febf
...
...
@@ -70,8 +70,25 @@
<input
type=
"text"
nz-input
[(
ngModel
)]="
word
.
wordTranslation
"
(
blur
)="
save
()"
style=
"width: 250px;"
>
</div>
<!-- 英式音标 -->
<div
style=
"margin-bottom: 10px; display: flex; align-items: center;"
>
<span
style=
"width: 120px; text-align: right;"
>
英式音标:
</span>
<input
type=
"text"
nz-input
[(
ngModel
)]="
word
.
britishPhonetic
"
(
blur
)="
save
()"
style=
"width: 250px;"
>
</div>
<!-- 美式音标 -->
<div
style=
"margin-bottom: 10px; display: flex; align-items: center;"
>
<span
style=
"width: 120px; text-align: right;"
>
美式音标:
</span>
<input
type=
"text"
nz-input
[(
ngModel
)]="
word
.
americanPhonetic
"
(
blur
)="
save
()"
style=
"width: 250px;"
>
</div>
<div
style=
"margin-top: 20px; border-top: 1px dashed #eee; padding-top: 15px;"
>
<!-- 英文定义 -->
<div
style=
"margin-bottom: 10px; display: flex; align-items: center;"
>
<span
style=
"width: 120px; text-align: right;"
>
英文定义:
</span>
<input
type=
"text"
nz-input
[(
ngModel
)]="
word
.
englishDefinition
"
(
blur
)="
save
()"
style=
"width: 250px;"
>
</div>
<div
style=
"margin-top: 20px; border-top: 1px dashed #eee; padding-top: 15px;"
>
<div
style=
"margin-bottom: 10px; display: flex; align-items: center;"
>
<span
style=
"width: 120px; text-align: right;"
>
<span
style=
"color: #ff4d4f; margin-right: 4px;"
>
*
</span>
显示类型:
...
...
@@ -96,6 +113,12 @@
<input
type=
"text"
nz-input
[(
ngModel
)]="
word
.
exampleSentence
"
(
blur
)="
save
()"
style=
"width: 250px;"
>
</div>
<!-- 例句翻译 -->
<div
style=
"margin-bottom: 10px; display: flex; align-items: center;"
>
<span
style=
"width: 120px; text-align: right;"
>
例句翻译:
</span>
<input
type=
"text"
nz-input
[(
ngModel
)]="
word
.
exampleSentenceTranslation
"
(
blur
)="
save
()"
style=
"width: 250px;"
>
</div>
<!-- 例句音频 -->
<div
style=
"margin-bottom: 10px; display: flex; align-items: center;"
>
<span
style=
"width: 120px; text-align: right;"
>
例句音频:
</span>
...
...
@@ -119,33 +142,6 @@
x
</button>
</div>
<!-- 其他可选字段 -->
<div
style=
"margin-top: 20px; border-top: 1px dashed #eee; padding-top: 15px;"
>
<!-- 英式音标 -->
<div
style=
"margin-bottom: 10px; display: flex; align-items: center;"
>
<span
style=
"width: 120px; text-align: right;"
>
英式音标:
</span>
<input
type=
"text"
nz-input
[(
ngModel
)]="
word
.
britishPhonetic
"
(
blur
)="
save
()"
style=
"width: 250px;"
>
</div>
<!-- 美式音标 -->
<div
style=
"margin-bottom: 10px; display: flex; align-items: center;"
>
<span
style=
"width: 120px; text-align: right;"
>
美式音标:
</span>
<input
type=
"text"
nz-input
[(
ngModel
)]="
word
.
americanPhonetic
"
(
blur
)="
save
()"
style=
"width: 250px;"
>
</div>
<!-- 英文定义 -->
<div
style=
"margin-bottom: 10px; display: flex; align-items: center;"
>
<span
style=
"width: 120px; text-align: right;"
>
英文定义:
</span>
<input
type=
"text"
nz-input
[(
ngModel
)]="
word
.
englishDefinition
"
(
blur
)="
save
()"
style=
"width: 250px;"
>
</div>
<!-- 例句翻译 -->
<div
style=
"margin-bottom: 10px; display: flex; align-items: center;"
>
<span
style=
"width: 120px; text-align: right;"
>
例句翻译:
</span>
<input
type=
"text"
nz-input
[(
ngModel
)]="
word
.
exampleSentenceTranslation
"
(
blur
)="
save
()"
style=
"width: 250px;"
>
</div>
</div>
</div>
</div>
...
...
form/src/app/form/form.component.ts
View file @
5a77febf
...
...
@@ -37,7 +37,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
'
ordinal number
'
,
];
// 存储courseId
courseId
:
string
=
''
;
constructor
(
private
appRef
:
ApplicationRef
,
private
changeDetectorRef
:
ChangeDetectorRef
,
private
message
:
NzMessageService
)
{
...
...
@@ -61,19 +62,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
ngOnInit
()
{
this
.
item
=
{};
// 获取父窗口URL中的courseId参数作为pictureBookId
const
courseIdStr
=
this
.
getParentUrlParam
(
'
courseId
'
);
let
courseId
=
0
;
if
(
courseIdStr
)
{
courseId
=
parseInt
(
courseIdStr
,
10
);
if
(
isNaN
(
courseId
))
{
courseId
=
0
;
}
console
.
log
(
'
从父窗口URL获取到courseId:
'
,
courseId
);
}
// 获取课程ID
this
.
getCourseIdFromParent
();
// 获取存储的数据
(
<
any
>
window
).
courseware
.
getData
((
data
)
=>
{
if
(
data
)
{
...
...
@@ -87,15 +79,12 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this
.
initItem
();
// 确保pictureBookId存在并且是整数
if
(
courseId
>
0
)
{
this
.
item
.
pictureBookId
=
courseId
;
}
else
if
(
this
.
item
.
pictureBookId
)
{
// 确保现有的pictureBookId是整数
const
pictureBookId
=
parseInt
(
this
.
item
.
pictureBookId
,
10
);
this
.
item
.
pictureBookId
=
isNaN
(
pictureBookId
)
?
0
:
pictureBookId
;
}
else
{
this
.
item
.
pictureBookId
=
0
;
// 如果有courseId,设置为pictureBookId
if
(
this
.
courseId
)
{
const
courseIdNum
=
parseInt
(
this
.
courseId
,
10
);
if
(
!
isNaN
(
courseIdNum
))
{
this
.
item
.
pictureBookId
=
courseIdNum
;
}
}
// 确保每个单词都有正确的ID(pictureBookId + 索引)
...
...
@@ -201,7 +190,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
id
:
0
,
// 临时ID,将在ensureWordIds中设置正确的值
pictureBookId
:
pictureBookId
,
word
:
''
,
displayType
:
'
3
'
,
// 默认为"核心
单词"
displayType
:
1
,
// 默认为"词卡
单词"
partOfSpeech
:
''
,
exampleSentence
:
''
,
wordAudioUrl
:
''
,
...
...
@@ -318,7 +307,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
id
:
0
,
// 临时ID,将在ensureWordIds中设置正确的值
pictureBookId
:
pictureBookId
,
word
:
''
,
displayType
:
'
3
'
,
// 默认为"核心
单词"
displayType
:
1
,
// 默认为"词卡
单词"
partOfSpeech
:
''
,
exampleSentence
:
''
,
wordAudioUrl
:
''
,
...
...
@@ -566,6 +555,27 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this
.
message
.
info
(
`准备为题目生成音频`
);
}
// 获取课程ID
getCourseIdFromParent
()
{
const
call_back
=
(
res
)
=>
{
console
.
log
(
"
courseId res:
"
,
res
);
this
.
courseId
=
res
;
}
const
checkAndCall
=
()
=>
{
if
(
typeof
commonPostMessageWithCallback
===
"
function
"
)
{
commonPostMessageWithCallback
(
{
action
:
"
getCourseId
"
,
},
call_back
);
}
else
{
this
.
message
.
create
(
"
error
"
,
"
通信方法不可用
"
);
}
};
checkAndCall
();
}
// 生成选项音频
generateOptionAudio
(
option
,
word
)
{
if
(
!
option
.
answer
||
option
.
answer
.
trim
()
===
''
)
{
...
...
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