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
b68f5171
Commit
b68f5171
authored
Jun 12, 2025
by
chunsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 优化音频录制组件,重构文件名处理逻辑并支持更多音频格式
parent
c73939fa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
audio-recorder.component.ts
...src/app/common/audio-recorder/audio-recorder.component.ts
+11
-8
No files found.
form/src/app/common/audio-recorder/audio-recorder.component.ts
View file @
b68f5171
...
...
@@ -214,10 +214,8 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
case
'
success
'
:
this
.
isUploading
=
false
;
let
url
=
info
.
file
.
response
.
url
;
// 获取文件扩展名
const
extension
=
url
.
substring
(
url
.
lastIndexOf
(
"
.
"
));
// 保留原始文件格式,只添加_l前缀
url
=
url
.
substring
(
0
,
url
.
lastIndexOf
(
"
.
"
))
+
"
_l
"
+
extension
;
url
=
this
.
replaceAudioUrl
(
url
)
;
info
.
file
.
response
.
url
=
url
;
this
.
uploadSuccess
(
info
.
file
.
response
);
this
.
audioUploaded
.
emit
(
info
.
file
.
response
);
...
...
@@ -228,6 +226,13 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
break
;
}
}
replaceAudioUrl
(
url
:
string
)
{
const
ext
=
url
.
substring
(
url
.
lastIndexOf
(
"
.
"
)).
toLowerCase
();
if
(
ext
===
"
.mp3
"
)
{
url
=
url
.
substring
(
0
,
url
.
lastIndexOf
(
"
.
"
))
+
"
_l.mp3
"
;
}
return
url
;
}
checkSelectFile
(
file
:
any
)
{
if
(
!
file
)
{
return
;
...
...
@@ -280,10 +285,8 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
}
linkInputed
(
url
,
name
)
{
// 获取文件扩展名
const
extension
=
url
.
substring
(
url
.
lastIndexOf
(
"
.
"
));
// 保留原始文件格式,只添加_l前缀
url
=
url
.
substring
(
0
,
url
.
lastIndexOf
(
"
.
"
))
+
"
_l
"
+
extension
;
url
=
this
.
replaceAudioUrl
(
url
);
this
.
audioUrl
=
url
;
this
.
audioUploaded
.
emit
({
url
});
this
.
audioName
.
emit
(
name
);
...
...
@@ -304,7 +307,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
if
(
url
.
indexOf
(
"
teach
"
)
<
0
||
url
.
indexOf
(
"
cdn
"
)
<
0
)
{
return
;
}
const
white
=
[
"
.mp3
"
,
"
.m4a
"
];
const
white
=
[
"
.mp3
"
,
"
.m4a
"
,
"
.wav
"
,
"
.ogg
"
];
if
(
!
white
.
includes
(
url
.
substr
(
url
.
lastIndexOf
(
"
.
"
))))
{
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