Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ai_fundub
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
ai_fundub
Commits
b3330739
Commit
b3330739
authored
Sep 21, 2026
by
Jeff nan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
parent
6528acc9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
149 additions
and
14 deletions
+149
-14
index.css
form/index.css
+22
-0
index.html
form/index.html
+22
-1
index.js
form/index.js
+105
-13
No files found.
form/index.css
View file @
b3330739
...
@@ -322,10 +322,32 @@
...
@@ -322,10 +322,32 @@
.waveform-tune-meta
{
.waveform-tune-meta
{
display
:
flex
;
display
:
flex
;
justify-content
:
space-between
;
justify-content
:
space-between
;
align-items
:
center
;
gap
:
12px
;
gap
:
12px
;
margin-bottom
:
12px
;
margin-bottom
:
12px
;
color
:
#606266
;
color
:
#606266
;
font-size
:
13px
;
font-size
:
13px
;
flex-wrap
:
wrap
;
}
.waveform-tune-meta__window
{
display
:
flex
;
align-items
:
center
;
gap
:
8px
;
}
.waveform-tune-meta__label
{
color
:
#606266
;
white-space
:
nowrap
;
}
.waveform-tune-meta__sep
{
color
:
#909399
;
}
.waveform-tune-time-input
{
width
:
108px
;
}
.waveform-tune-time-input
.el-input__inner
{
padding
:
0
8px
;
text-align
:
center
;
font-variant-numeric
:
tabular-nums
;
}
}
.waveform-tune-canvas-wrap
{
.waveform-tune-canvas-wrap
{
position
:
relative
;
position
:
relative
;
...
...
form/index.html
View file @
b3330739
...
@@ -368,7 +368,28 @@
...
@@ -368,7 +368,28 @@
>
>
<div
v-loading=
"waveformDialog.loading"
element-loading-text=
"正在加载波形..."
>
<div
v-loading=
"waveformDialog.loading"
element-loading-text=
"正在加载波形..."
>
<div
class=
"waveform-tune-meta"
>
<div
class=
"waveform-tune-meta"
>
<span>
窗口:{{ formatTime(waveformDialog.windowStart) }} ~ {{ formatTime(waveformDialog.windowEnd) }}
</span>
<div
class=
"waveform-tune-meta__window"
>
<span
class=
"waveform-tune-meta__label"
>
窗口
</span>
<el-input
size=
"mini"
class=
"waveform-tune-time-input"
v-model=
"waveformDialog.windowStartText"
:disabled=
"!!waveformDialog.loading"
placeholder=
"00:00.000"
@
change=
"onWaveformWindowInput"
@
keyup
.
enter
.
native=
"onWaveformWindowInput"
></el-input>
<span
class=
"waveform-tune-meta__sep"
>
~
</span>
<el-input
size=
"mini"
class=
"waveform-tune-time-input"
v-model=
"waveformDialog.windowEndText"
:disabled=
"!!waveformDialog.loading"
placeholder=
"00:00.000"
@
change=
"onWaveformWindowInput"
@
keyup
.
enter
.
native=
"onWaveformWindowInput"
></el-input>
</div>
<span>
选中:{{ formatTime(waveformDialog.startSec) }} ~ {{ formatTime(waveformDialog.endSec) }}
</span>
<span>
选中:{{ formatTime(waveformDialog.startSec) }} ~ {{ formatTime(waveformDialog.endSec) }}
</span>
</div>
</div>
<div
<div
...
...
form/index.js
View file @
b3330739
...
@@ -28,13 +28,13 @@ document.addEventListener('DOMContentLoaded', () => {
...
@@ -28,13 +28,13 @@ document.addEventListener('DOMContentLoaded', () => {
window
.
courseware
.
getData
(
function
(
data
)
{
window
.
courseware
.
getData
(
function
(
data
)
{
window
.
air
.
hideAirClassLoading
(
key
,
data
);
window
.
air
.
hideAirClassLoading
(
key
,
data
);
//
if (!data) {
if
(
!
data
)
{
//
// 加载默认数据
// 加载默认数据
//
$.getJSON('../play/defaultData.json', function (defaultData) {
$
.
getJSON
(
'
../play/defaultData.json
'
,
function
(
defaultData
)
{
//
initVueApp(defaultData);
initVueApp
(
defaultData
);
//
})
})
//
return;
return
;
//
}
}
//数据加载完,才算页面加载完成
//数据加载完,才算页面加载完成
initVueApp
(
data
);
initVueApp
(
data
);
},
key
);
},
key
);
...
@@ -105,6 +105,9 @@ function initVueApp(savedData) {
...
@@ -105,6 +105,9 @@ function initVueApp(savedData) {
tlIndex
:
null
,
tlIndex
:
null
,
windowStart
:
0
,
windowStart
:
0
,
windowEnd
:
0
,
windowEnd
:
0
,
windowStartText
:
'
00:00.000
'
,
windowEndText
:
'
00:00.000
'
,
mediaDuration
:
0
,
startSec
:
0
,
startSec
:
0
,
endSec
:
0
,
endSec
:
0
,
peaks
:
[],
peaks
:
[],
...
@@ -1030,21 +1033,19 @@ function initVueApp(savedData) {
...
@@ -1030,21 +1033,19 @@ function initVueApp(savedData) {
this
.
waveformDialog
.
endSec
=
endSec
;
this
.
waveformDialog
.
endSec
=
endSec
;
this
.
waveformDialog
.
peaks
=
[];
this
.
waveformDialog
.
peaks
=
[];
this
.
waveformDialog
.
dragging
=
null
;
this
.
waveformDialog
.
dragging
=
null
;
this
.
syncWaveformWindowText
();
try
{
try
{
const
buffer
=
await
this
.
ensurePreviewAudioBuffer
();
const
buffer
=
await
this
.
ensurePreviewAudioBuffer
();
const
duration
=
buffer
.
duration
||
0
;
const
duration
=
buffer
.
duration
||
0
;
this
.
waveformDialog
.
mediaDuration
=
duration
;
if
(
duration
>
0
&&
this
.
waveformDialog
.
windowEnd
>
duration
)
{
if
(
duration
>
0
&&
this
.
waveformDialog
.
windowEnd
>
duration
)
{
this
.
waveformDialog
.
windowEnd
=
duration
;
this
.
waveformDialog
.
windowEnd
=
duration
;
}
}
if
(
this
.
waveformDialog
.
endSec
>
this
.
waveformDialog
.
windowEnd
)
{
if
(
this
.
waveformDialog
.
endSec
>
this
.
waveformDialog
.
windowEnd
)
{
this
.
waveformDialog
.
endSec
=
this
.
waveformDialog
.
windowEnd
;
this
.
waveformDialog
.
endSec
=
this
.
waveformDialog
.
windowEnd
;
}
}
this
.
waveformDialog
.
peaks
=
this
.
buildWaveformPeaks
(
this
.
syncWaveformWindowText
();
buffer
,
await
this
.
refreshWaveformPeaks
();
this
.
waveformDialog
.
windowStart
,
this
.
waveformDialog
.
windowEnd
,
500
);
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
drawWaveformCanvas
();
this
.
drawWaveformCanvas
();
this
.
bindWaveformDragListeners
();
this
.
bindWaveformDragListeners
();
...
@@ -1058,6 +1059,96 @@ function initVueApp(savedData) {
...
@@ -1058,6 +1059,96 @@ function initVueApp(savedData) {
}
}
},
},
syncWaveformWindowText
()
{
const
d
=
this
.
waveformDialog
;
d
.
windowStartText
=
this
.
formatTime
(
d
.
windowStart
);
d
.
windowEndText
=
this
.
formatTime
(
d
.
windowEnd
);
},
// 窗口起止输入变更:解析后重建波形显示区间
async
onWaveformWindowInput
()
{
const
d
=
this
.
waveformDialog
;
if
(
!
d
.
visible
||
d
.
loading
)
return
;
const
startSec
=
this
.
parseTimeToSeconds
(
d
.
windowStartText
);
const
endSec
=
this
.
parseTimeToSeconds
(
d
.
windowEndText
);
if
(
isNaN
(
startSec
)
||
isNaN
(
endSec
))
{
this
.
$message
.
warning
(
'
请输入合法时间,例如 00:12.340
'
);
this
.
syncWaveformWindowText
();
return
;
}
if
(
startSec
<
0
)
{
this
.
$message
.
warning
(
'
窗口开始时间不能小于 0
'
);
this
.
syncWaveformWindowText
();
return
;
}
if
(
!
(
endSec
>
startSec
))
{
this
.
$message
.
warning
(
'
窗口结束时间必须大于开始时间
'
);
this
.
syncWaveformWindowText
();
return
;
}
const
minSpan
=
0.05
;
if
(
endSec
-
startSec
<
minSpan
)
{
this
.
$message
.
warning
(
`窗口时长至少
${
minSpan
}
秒`
);
this
.
syncWaveformWindowText
();
return
;
}
let
nextStart
=
startSec
;
let
nextEnd
=
endSec
;
const
duration
=
d
.
mediaDuration
||
0
;
if
(
duration
>
0
)
{
if
(
nextStart
>=
duration
)
{
this
.
$message
.
warning
(
'
窗口开始时间超出音视频时长
'
);
this
.
syncWaveformWindowText
();
return
;
}
nextEnd
=
Math
.
min
(
nextEnd
,
duration
);
if
(
!
(
nextEnd
>
nextStart
))
{
this
.
$message
.
warning
(
'
窗口结束时间超出音视频时长
'
);
this
.
syncWaveformWindowText
();
return
;
}
}
// 选中区间尽量保留;若被新窗口裁切则夹紧到窗口内
const
minGap
=
0.001
;
let
selStart
=
d
.
startSec
;
let
selEnd
=
d
.
endSec
;
if
(
selStart
<
nextStart
)
selStart
=
nextStart
;
if
(
selEnd
>
nextEnd
)
selEnd
=
nextEnd
;
if
(
!
(
selEnd
>
selStart
))
{
selStart
=
nextStart
;
selEnd
=
Math
.
min
(
nextEnd
,
nextStart
+
Math
.
max
(
minGap
,
Math
.
min
(
0.5
,
nextEnd
-
nextStart
)));
}
else
if
(
selEnd
-
selStart
<
minGap
)
{
selEnd
=
Math
.
min
(
nextEnd
,
selStart
+
minGap
);
}
if
(
d
.
playing
)
this
.
stopSentencePreview
();
d
.
windowStart
=
nextStart
;
d
.
windowEnd
=
nextEnd
;
d
.
startSec
=
selStart
;
d
.
endSec
=
selEnd
;
this
.
syncWaveformWindowText
();
d
.
loading
=
true
;
try
{
await
this
.
refreshWaveformPeaks
();
this
.
$nextTick
(()
=>
this
.
drawWaveformCanvas
());
}
catch
(
e
)
{
console
.
error
(
e
);
this
.
$message
.
error
(
'
按新窗口重绘波形失败
'
);
}
finally
{
d
.
loading
=
false
;
this
.
$nextTick
(()
=>
this
.
drawWaveformCanvas
());
}
},
async
refreshWaveformPeaks
()
{
const
d
=
this
.
waveformDialog
;
const
buffer
=
await
this
.
ensurePreviewAudioBuffer
();
if
(
buffer
&&
buffer
.
duration
)
d
.
mediaDuration
=
buffer
.
duration
;
d
.
peaks
=
this
.
buildWaveformPeaks
(
buffer
,
d
.
windowStart
,
d
.
windowEnd
,
500
);
},
async
ensurePreviewAudioBuffer
()
{
async
ensurePreviewAudioBuffer
()
{
const
src
=
this
.
getPreviewMediaSrc
();
const
src
=
this
.
getPreviewMediaSrc
();
if
(
!
src
)
throw
new
Error
(
'
no media src
'
);
if
(
!
src
)
throw
new
Error
(
'
no media src
'
);
...
@@ -1312,6 +1403,7 @@ function initVueApp(savedData) {
...
@@ -1312,6 +1403,7 @@ function initVueApp(savedData) {
this
.
waveformDialog
.
peaks
=
[];
this
.
waveformDialog
.
peaks
=
[];
this
.
waveformDialog
.
error
=
''
;
this
.
waveformDialog
.
error
=
''
;
this
.
waveformDialog
.
loading
=
false
;
this
.
waveformDialog
.
loading
=
false
;
this
.
waveformDialog
.
mediaDuration
=
0
;
},
},
// 弹窗打开时加载数据
// 弹窗打开时加载数据
...
...
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