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
c73939fa
Commit
c73939fa
authored
Jun 10, 2025
by
chunsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 更新音频录制组件,支持更多音频格式上传并优化文件名处理逻辑
parent
91b24323
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
audio-recorder.component.html
...c/app/common/audio-recorder/audio-recorder.component.html
+1
-1
audio-recorder.component.ts
...src/app/common/audio-recorder/audio-recorder.component.ts
+11
-5
No files found.
form/src/app/common/audio-recorder/audio-recorder.component.html
View file @
c73939fa
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
Record Audio
Record Audio
</div>
</div>
<nz-upload
<nz-upload
[
nzAccept
]
=
"'.
mp3
'"
[
nzAccept
]
=
"'.
mp3
,.
m4a
,.
wav
,.
ogg
'"
[
nzShowUploadList
]="
false
"
[
nzShowUploadList
]="
false
"
[
nzAction
]="
uploadUrl
"
[
nzAction
]="
uploadUrl
"
[
nzData
]="
uploadData
"
[
nzData
]="
uploadData
"
...
...
form/src/app/common/audio-recorder/audio-recorder.component.ts
View file @
c73939fa
...
@@ -214,7 +214,10 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -214,7 +214,10 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
case
'
success
'
:
case
'
success
'
:
this
.
isUploading
=
false
;
this
.
isUploading
=
false
;
let
url
=
info
.
file
.
response
.
url
;
let
url
=
info
.
file
.
response
.
url
;
url
=
url
.
substring
(
0
,
url
.
lastIndexOf
(
"
.
"
))
+
"
_l.mp3
"
;
// 获取文件扩展名
const
extension
=
url
.
substring
(
url
.
lastIndexOf
(
"
.
"
));
// 保留原始文件格式,只添加_l前缀
url
=
url
.
substring
(
0
,
url
.
lastIndexOf
(
"
.
"
))
+
"
_l
"
+
extension
;
info
.
file
.
response
.
url
=
url
;
info
.
file
.
response
.
url
=
url
;
this
.
uploadSuccess
(
info
.
file
.
response
);
this
.
uploadSuccess
(
info
.
file
.
response
);
this
.
audioUploaded
.
emit
(
info
.
file
.
response
);
this
.
audioUploaded
.
emit
(
info
.
file
.
response
);
...
@@ -229,9 +232,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -229,9 +232,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
if
(
!
file
)
{
if
(
!
file
)
{
return
;
return
;
}
}
const
isAudio
=
[
'
audio/mp3
'
,
'
audio/wav
'
,
'
audio/ogg
'
].
includes
(
file
.
type
);
const
isAudio
=
[
'
audio/mp3
'
,
'
audio/wav
'
,
'
audio/ogg
'
,
'
audio/m4a
'
,
'
audio/x-m4a
'
].
includes
(
file
.
type
);
if
(
!
isAudio
)
{
if
(
!
isAudio
)
{
this
.
nzMessageService
.
error
(
'
You can only upload Audio file ( mp3 | wav |
ogg
)
'
);
this
.
nzMessageService
.
error
(
'
You can only upload Audio file ( mp3 | wav |
ogg | m4a
)
'
);
return
;
return
;
}
}
const
delta
=
25
;
const
delta
=
25
;
...
@@ -277,7 +280,10 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -277,7 +280,10 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
}
}
linkInputed
(
url
,
name
)
{
linkInputed
(
url
,
name
)
{
url
=
url
.
substring
(
0
,
url
.
lastIndexOf
(
"
.
"
))
+
"
_l.mp3
"
;
// 获取文件扩展名
const
extension
=
url
.
substring
(
url
.
lastIndexOf
(
"
.
"
));
// 保留原始文件格式,只添加_l前缀
url
=
url
.
substring
(
0
,
url
.
lastIndexOf
(
"
.
"
))
+
"
_l
"
+
extension
;
this
.
audioUrl
=
url
;
this
.
audioUrl
=
url
;
this
.
audioUploaded
.
emit
({
url
});
this
.
audioUploaded
.
emit
({
url
});
this
.
audioName
.
emit
(
name
);
this
.
audioName
.
emit
(
name
);
...
@@ -298,7 +304,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -298,7 +304,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
if
(
url
.
indexOf
(
"
teach
"
)
<
0
||
url
.
indexOf
(
"
cdn
"
)
<
0
)
{
if
(
url
.
indexOf
(
"
teach
"
)
<
0
||
url
.
indexOf
(
"
cdn
"
)
<
0
)
{
return
;
return
;
}
}
const
white
=
[
"
.mp3
"
];
const
white
=
[
"
.mp3
"
,
"
.m4a
"
];
if
(
!
white
.
includes
(
url
.
substr
(
url
.
lastIndexOf
(
"
.
"
))))
{
if
(
!
white
.
includes
(
url
.
substr
(
url
.
lastIndexOf
(
"
.
"
))))
{
return
;
return
;
}
}
...
...
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