Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
AI_BOOK_TOOL
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_BOOK_TOOL
Commits
3f1b1d59
Commit
3f1b1d59
authored
May 13, 2025
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
parent
0177e9da
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
556 additions
and
398 deletions
+556
-398
index.css
form/index.css
+251
-132
index.html
form/index.html
+42
-35
index.js
form/index.js
+263
-231
No files found.
form/index.css
View file @
3f1b1d59
...
@@ -134,40 +134,50 @@ html, body {
...
@@ -134,40 +134,50 @@ html, body {
/* 音频控制区域 */
/* 音频控制区域 */
.audio-control
{
.audio-control
{
height
:
200
px
;
height
:
185
px
;
position
:
fixed
;
position
:
fixed
;
bottom
:
0
;
bottom
:
0
;
left
:
0
;
left
:
0
;
right
:
0
;
right
:
0
;
z-index
:
1000
;
z-index
:
1000
;
margin
:
0
;
margin
:
0
;
border-radius
:
0
;
background
:
#fff
;
box-shadow
:
0
-2px
10px
rgba
(
0
,
0
,
0
,
0.1
);
border-top
:
1px
dashed
#DCDFE6
;
}
.audio-control
.el-card__body
{
padding
:
10px
20px
;
padding
:
10px
20px
;
}
}
.waveform-container
{
.waveform-container
{
height
:
100%
;
height
:
90px
;
display
:
flex
;
display
:
flex
;
flex-direction
:
column
;
flex-direction
:
column
;
position
:
relative
;
position
:
relative
;
background
:
white
;
background
:
white
;
}
}
/* 波形图区域样式 */
.waveform-wrapper
{
position
:
relative
;
padding
:
10px
10px
0
;
background
:
#fff
;
height
:
116px
;
overflow
:
visible
;
}
#waveform
{
#waveform
{
flex
:
1
;
height
:
116px
!important
;
min-height
:
120px
;
position
:
relative
;
position
:
relative
;
background
:
white
;
background
:
white
;
margin-bottom
:
5px
;
overflow
:
hidden
;
}
}
#wave-timeline
{
#wave-timeline
{
height
:
30px
;
height
:
20px
!important
;
margin-bottom
:
5px
;
position
:
absolute
;
position
:
relative
;
left
:
0px
;
right
:
0px
;
bottom
:
0px
;
overflow
:
visible
;
}
}
.audio-controls
{
.audio-controls
{
...
@@ -178,7 +188,44 @@ html, body {
...
@@ -178,7 +188,44 @@ html, body {
z-index
:
4
;
z-index
:
4
;
}
}
/* 添加时间调整控件样式 */
/* 控制按钮区域样式 */
.control-wrapper
{
position
:
absolute
;
bottom
:
0
;
left
:
0
;
right
:
0
;
z-index
:
1000
;
padding
:
10px
;
background
:
#fff
;
}
.basic-controls
{
display
:
flex
;
align-items
:
center
;
gap
:
10px
;
margin-bottom
:
10px
;
}
.basic-controls
.el-button-group
{
margin-right
:
20px
;
display
:
inline-flex
;
}
.basic-controls
.el-button-group
.el-button
{
margin
:
0
;
}
.basic-controls
.el-slider
{
margin
:
0
20px
;
width
:
200px
;
flex-shrink
:
0
;
}
.basic-controls
.el-button
:not
(
.el-button-group
.el-button
)
{
margin-left
:
10px
;
}
/* 时间调整控件样式 */
.time-adjust-controls
{
.time-adjust-controls
{
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
...
@@ -197,6 +244,158 @@ html, body {
...
@@ -197,6 +244,158 @@ html, body {
margin
:
0
5px
;
margin
:
0
5px
;
}
}
/* 确保滑块和按钮在最上层 */
.el-slider
{
position
:
relative
;
z-index
:
1000
;
}
.el-slider__runway
{
z-index
:
1000
;
}
.el-slider__bar
{
z-index
:
1000
;
}
.el-slider__button-wrapper
{
z-index
:
1000
;
}
.el-button-group
{
position
:
relative
;
z-index
:
1000
;
}
.el-button
{
position
:
relative
;
z-index
:
1000
;
}
/* 锁定按钮特殊样式 */
.el-button--danger.is-active
,
.el-button--danger
:active
{
background
:
#f56c6c
;
border-color
:
#f56c6c
;
color
:
#fff
;
}
/* 其他样式 */
.app
{
position
:
relative
;
top
:
0px
;
left
:
0px
;
width
:
100%
;
height
:
100%
;
}
/* 新建矩形框按钮 */
.add-rect-btn
{
position
:
absolute
;
right
:
15px
;
bottom
:
15px
;
z-index
:
100
;
opacity
:
0.8
;
transition
:
opacity
0.3s
;
box-shadow
:
0
2px
12px
0
rgba
(
0
,
0
,
0
,
0.1
);
}
.add-rect-btn
:hover
{
opacity
:
1
;
}
.group-header
{
display
:
flex
;
align-items
:
center
;
justify-content
:
space-between
;
padding
:
0
10px
;
margin
:
16px
0
;
border-bottom
:
1px
solid
#DCDFE6
;
}
.group-title
{
font-size
:
14px
;
font-weight
:
500
;
color
:
#303133
;
padding
:
0
8px
8px
;
position
:
relative
;
}
.group-title
::after
{
content
:
''
;
position
:
absolute
;
bottom
:
-1px
;
left
:
0
;
right
:
0
;
height
:
2px
;
background-color
:
#409EFF
;
}
/* 全屏按钮 */
.fullscreen-btn
{
position
:
absolute
;
right
:
15px
;
top
:
15px
;
z-index
:
100
;
opacity
:
0.8
;
transition
:
opacity
0.3s
;
box-shadow
:
0
2px
12px
0
rgba
(
0
,
0
,
0
,
0.1
);
}
.fullscreen-btn
:hover
{
opacity
:
1
;
}
/* 全屏编辑器 */
.fullscreen-editor
{
position
:
fixed
;
top
:
0
;
left
:
0
;
right
:
0
;
bottom
:
0
;
background-color
:
rgba
(
0
,
0
,
0
,
0.7
);
z-index
:
2000
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
padding
:
20px
;
}
.fullscreen-content
{
background-color
:
#fff
;
border-radius
:
4px
;
width
:
100%
;
height
:
100%
;
display
:
flex
;
flex-direction
:
column
;
overflow
:
hidden
;
}
.fullscreen-content
.image-container
{
flex
:
1
;
margin
:
0
;
border
:
none
;
border-radius
:
0
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
background-color
:
#f5f7fa
;
}
.fullscreen-content
.image-wrapper
{
position
:
relative
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
line-height
:
0
;
}
.fullscreen-content
img
{
display
:
block
;
max-width
:
100%
;
max-height
:
100%
;
}
/* 分页器样式 */
/* 分页器样式 */
.pagination-container
{
.pagination-container
{
position
:
fixed
;
position
:
fixed
;
...
@@ -325,28 +524,16 @@ html, body {
...
@@ -325,28 +524,16 @@ html, body {
line-height
:
40px
;
line-height
:
40px
;
}
}
/* 区域样式 */
.wavesurfer-region
{
.wavesurfer-region
{
z-index
:
2
!important
;
z-index
:
2
!important
;
border
:
1px
solid
rgba
(
0
,
0
,
0
,
0.1
);
box-shadow
:
0
1px
3px
rgba
(
0
,
0
,
0
,
0.1
);
transition
:
background-color
0.2s
ease
;
pointer-events
:
all
!important
;
pointer-events
:
all
!important
;
cursor
:
pointer
!important
;
}
/* 页面区间样式 */
.wavesurfer-region
[
data-id
^=
"page-"
]
{
z-index
:
3
!important
;
background
:
rgba
(
255
,
192
,
203
,
0.3
)
!important
;
border
:
2px
solid
rgba
(
255
,
192
,
203
,
0.8
)
!important
;
pointer-events
:
all
!important
;
cursor
:
pointer
!important
;
}
/* 组区间样式 */
.wavesurfer-region
:not
([
data-id
^=
"page-"
])
{
z-index
:
1
!important
;
cursor
:
pointer
!important
;
}
}
/*
区间拖拽
手柄样式 */
/*
波形图的拖动
手柄样式 */
.wavesurfer-handle
{
.wavesurfer-handle
{
display
:
block
!important
;
display
:
block
!important
;
position
:
absolute
!important
;
position
:
absolute
!important
;
...
@@ -366,122 +553,54 @@ html, body {
...
@@ -366,122 +553,54 @@ html, body {
right
:
0
!important
;
right
:
0
!important
;
}
}
/* 禁用状态下的手柄样式 */
/* 波形图的进度条样式 */
.wavesurfer-region
[
data-drag
=
"false"
]
.wavesurfer-handle
{
.wavesurfer-cursor
{
display
:
none
!important
;
z-index
:
4
!important
;
}
.app
{
position
:
relative
;
top
:
0px
;
left
:
0px
;
width
:
100%
;
height
:
100%
;
}
}
/* 新建矩形框按钮 */
/* 页面区间样式 */
.add-rect-btn
{
.wavesurfer-region
[
data-id
^=
"page-"
]
{
position
:
absolute
;
z-index
:
3
!important
;
right
:
15px
;
background-color
:
rgba
(
255
,
0
,
0
,
0.2
)
!important
;
bottom
:
15px
;
pointer-events
:
all
!important
;
z-index
:
100
;
cursor
:
pointer
!important
;
opacity
:
0.8
;
transition
:
opacity
0.3s
;
box-shadow
:
0
2px
12px
0
rgba
(
0
,
0
,
0
,
0.1
);
}
.add-rect-btn
:hover
{
opacity
:
1
;
}
.group-header
{
display
:
flex
;
align-items
:
center
;
justify-content
:
space-between
;
padding
:
0
10px
;
margin
:
16px
0
;
border-bottom
:
1px
solid
#DCDFE6
;
}
.group-title
{
font-size
:
14px
;
font-weight
:
500
;
color
:
#303133
;
padding
:
0
8px
8px
;
position
:
relative
;
}
}
.group-title
::after
{
.wavesurfer-region
[
data-id
^=
"page-"
]
:hover
{
content
:
''
;
background-color
:
rgba
(
255
,
0
,
0
,
0.3
)
!important
;
position
:
absolute
;
bottom
:
-1px
;
left
:
0
;
right
:
0
;
height
:
2px
;
background-color
:
#409EFF
;
}
}
/* 全屏按钮 */
/* 组区间样式 */
.fullscreen-btn
{
.wavesurfer-region
:not
([
data-id
^=
"page-"
])
{
position
:
absolute
;
background-color
:
rgba
(
64
,
158
,
255
,
0.2
);
right
:
15px
;
border
:
2px
solid
rgba
(
64
,
158
,
255
,
0.5
);
top
:
15px
;
z-index
:
2
!important
;
z-index
:
100
;
cursor
:
pointer
!important
;
opacity
:
0.8
;
transition
:
opacity
0.3s
;
box-shadow
:
0
2px
12px
0
rgba
(
0
,
0
,
0
,
0.1
);
}
.fullscreen-btn
:hover
{
opacity
:
1
;
}
}
/* 全屏编辑器 */
.wavesurfer-region
:not
([
data-id
^=
"page-"
])
:hover
{
.fullscreen-editor
{
background-color
:
rgba
(
64
,
158
,
255
,
0.3
)
!important
;
position
:
fixed
;
top
:
0
;
left
:
0
;
right
:
0
;
bottom
:
0
;
background-color
:
rgba
(
0
,
0
,
0
,
0.7
);
z-index
:
2000
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
padding
:
20px
;
}
}
.fullscreen-content
{
/* 锁定状态下的标记样式 */
background-color
:
#fff
;
.wavesurfer-region
[
data-id
$
=
"-start"
]
{
border-radius
:
4px
;
background-color
:
rgba
(
0
,
255
,
0
,
0.8
)
!important
;
width
:
100%
;
width
:
1px
!important
;
height
:
100%
;
z-index
:
5
!important
;
display
:
flex
;
flex-direction
:
column
;
overflow
:
hidden
;
}
}
.fullscreen-content
.image-container
{
.wavesurfer-region
[
data-id
$
=
"-end"
]
{
flex
:
1
;
background-color
:
rgba
(
255
,
0
,
0
,
0.8
)
!important
;
margin
:
0
;
width
:
1px
!important
;
border
:
none
;
z-index
:
5
!important
;
border-radius
:
0
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
background-color
:
#f5f7fa
;
}
}
.fullscreen-content
.image-wrapper
{
/* 锁定状态下隐藏非当前页面的区间 */
position
:
relative
;
.page-locked
.wavesurfer-region
:not
([
data-id
*=
"-start"
])
:not
([
data-id
*=
"-end"
])
:not
([
data-id
$
=
"-${currentPageIndex-1}"
])
{
display
:
flex
;
display
:
none
!important
;
justify-content
:
center
;
align-items
:
center
;
line-height
:
0
;
}
}
.fullscreen-content
img
{
/* 锁定状态下禁用区间拖动 */
display
:
block
;
.page-locked
.wavesurfer-region
.wavesurfer-handle
{
max-width
:
100%
;
display
:
none
!important
;
max-height
:
100%
;
}
}
\ No newline at end of file
form/index.html
View file @
3f1b1d59
...
@@ -278,11 +278,16 @@
...
@@ -278,11 +278,16 @@
</div>
</div>
<!-- 音频控制区域 -->
<!-- 音频控制区域 -->
<el-card
class=
"audio-control"
v-loading=
"audioLoading"
>
<div
class=
"audio-control"
v-loading=
"audioLoading"
>
<div
class=
"waveform-container"
>
<!-- 波形图区域 -->
<div
class=
"waveform-wrapper"
:class=
"{ 'page-locked': isPageLocked }"
>
<div
id=
"waveform"
></div>
<div
id=
"waveform"
></div>
<div
id=
"wave-timeline"
></div>
<div
id=
"wave-timeline"
></div>
<div
class=
"audio-controls"
>
</div>
<!-- 控制按钮区域 -->
<div
class=
"control-wrapper"
>
<div
class=
"basic-controls"
>
<el-button-group>
<el-button-group>
<el-button
size=
"small"
@
click=
"playAudio"
:disabled=
"audioLoading"
>
<el-button
size=
"small"
@
click=
"playAudio"
:disabled=
"audioLoading"
>
<i
:class=
"isPlaying ? 'el-icon-video-pause' : 'el-icon-video-play'"
></i>
<i
:class=
"isPlaying ? 'el-icon-video-pause' : 'el-icon-video-play'"
></i>
...
@@ -291,22 +296,25 @@
...
@@ -291,22 +296,25 @@
<i
class=
"el-icon-video-stop"
></i>
<i
class=
"el-icon-video-stop"
></i>
</el-button>
</el-button>
</el-button-group>
</el-button-group>
<el-slider
<el-slider
v-model=
"zoomLevel"
v-model=
"zoomLevel"
:min=
"1"
:min=
"1"
:max=
"500"
:max=
"500"
@
change=
"handleZoom"
@
change=
"handleZoom"
:disabled=
"audioLoading"
:disabled=
"audioLoading"
style=
"width: 200px;
margin-left: 20px;
"
>
style=
"width: 200px;"
>
</el-slider>
</el-slider>
<el-button
<el-button
size=
"small"
size=
"small"
:type=
"isPageLocked ? 'danger' : 'primary'"
:type=
"isPageLocked ? 'danger' : 'primary'"
@
click=
"togglePageLock"
@
click=
"togglePageLock"
style=
"margin-left: 20px;
"
>
:class=
"{ 'is-active': isPageLocked }
"
>
<i
:class=
"isPageLocked ? 'el-icon-lock' : 'el-icon-unlock'"
></i>
<i
:class=
"isPageLocked ? 'el-icon-lock' : 'el-icon-unlock'"
></i>
{{ isPageLocked ? '解锁页面' : '锁定页面' }}
{{ isPageLocked ? '解锁页面' : '锁定页面' }}
</el-button>
</el-button>
</div>
<!-- 添加时间调整控件 -->
<!-- 添加时间调整控件 -->
<div
class=
"time-adjust-controls"
v-if=
"currentGroup"
>
<div
class=
"time-adjust-controls"
v-if=
"currentGroup"
>
...
@@ -337,7 +345,6 @@
...
@@ -337,7 +345,6 @@
</div>
</div>
</div>
</div>
</div>
</div>
</el-card>
</div>
</div>
</body>
</body>
<script
src=
"./index.js"
></script>
<script
src=
"./index.js"
></script>
...
...
form/index.js
View file @
3f1b1d59
...
@@ -50,6 +50,7 @@ new Vue({
...
@@ -50,6 +50,7 @@ new Vue({
isPageLocked
:
false
,
isPageLocked
:
false
,
lockedPageStart
:
null
,
lockedPageStart
:
null
,
lockedPageEnd
:
null
,
lockedPageEnd
:
null
,
previousZoomLevel
:
null
,
},
},
mounted
()
{
mounted
()
{
...
@@ -209,10 +210,11 @@ new Vue({
...
@@ -209,10 +210,11 @@ new Vue({
container
:
'
#wave-timeline
'
,
container
:
'
#wave-timeline
'
,
height
:
20
,
height
:
20
,
notchPercentHeight
:
50
,
notchPercentHeight
:
50
,
primaryFontColor
:
'
#666
'
,
primaryFontColor
:
'
rgba(102, 102, 102, 0.7)
'
,
secondaryFontColor
:
'
#888
'
,
secondaryFontColor
:
'
rgba(136, 136, 136, 0.5)
'
,
primaryColor
:
'
#666
'
,
primaryColor
:
'
rgba(102, 102, 102, 0.7)
'
,
secondaryColor
:
'
#888
'
secondaryColor
:
'
rgba(136, 136, 136, 0.5)
'
,
style
:
'
background-color: rgba(255, 255, 255, 0.1);
'
})
})
]
]
});
});
...
@@ -308,53 +310,22 @@ new Vue({
...
@@ -308,53 +310,22 @@ new Vue({
this
.
wavesurfer
.
clearRegions
();
this
.
wavesurfer
.
clearRegions
();
this
.
audioRegions
=
{};
this
.
audioRegions
=
{};
// 先收集所有有效的页面时间范围
// 创建页面区间
const
pageRanges
=
[];
this
.
pages
.
forEach
((
page
,
pageIndex
)
=>
{
this
.
pages
.
forEach
((
page
,
pageIndex
)
=>
{
// 只为有组的页面创建区间
if
(
page
.
groups
&&
page
.
groups
.
length
>
0
)
{
if
(
page
.
groups
&&
page
.
groups
.
length
>
0
)
{
// 找出所有有效的时间点
const
pageRegionId
=
`page-
${
pageIndex
}
`
;
const
validTimes
=
page
.
groups
.
reduce
((
acc
,
group
)
=>
{
if
(
typeof
group
.
start
===
'
number
'
&&
!
isNaN
(
group
.
start
))
{
acc
.
starts
.
push
(
Number
(
group
.
start
.
toFixed
(
3
)));
}
if
(
typeof
group
.
end
===
'
number
'
&&
!
isNaN
(
group
.
end
))
{
acc
.
ends
.
push
(
Number
(
group
.
end
.
toFixed
(
3
)));
}
return
acc
;
},
{
starts
:
[],
ends
:
[]
});
if
(
validTimes
.
starts
.
length
>
0
&&
validTimes
.
ends
.
length
>
0
)
{
const
start
=
Math
.
min
(...
validTimes
.
starts
);
const
end
=
Math
.
max
(...
validTimes
.
ends
);
if
(
start
<
end
)
{
pageRanges
.
push
({
pageIndex
,
start
,
end
});
}
}
}
});
// 按开始时间排序
pageRanges
.
sort
((
a
,
b
)
=>
a
.
start
-
b
.
start
);
// 创建页面区间,确保不重叠
pageRanges
.
forEach
((
range
,
index
)
=>
{
const
pageRegionId
=
`page-
${
range
.
pageIndex
}
`
;
try
{
try
{
// 创建区域
// 创建区域,使用页面自身的时间
const
region
=
this
.
wavesurfer
.
addRegion
({
const
region
=
this
.
wavesurfer
.
addRegion
({
id
:
pageRegionId
,
id
:
pageRegionId
,
start
:
ran
ge
.
start
,
start
:
pa
ge
.
start
,
end
:
ran
ge
.
end
,
end
:
pa
ge
.
end
,
color
:
'
rgba(255, 192, 203, 0.3)
'
,
color
:
'
rgba(255, 192, 203, 0.3)
'
,
drag
:
!
this
.
isPageLocked
,
drag
:
!
this
.
isPageLocked
,
resize
:
!
this
.
isPageLocked
,
resize
:
!
this
.
isPageLocked
,
attributes
:
{
attributes
:
{
label
:
`Page
${
range
.
pageIndex
+
1
}
`
label
:
`Page
${
pageIndex
+
1
}
`
}
}
});
});
...
@@ -366,65 +337,69 @@ new Vue({
...
@@ -366,65 +337,69 @@ new Vue({
event
.
stopPropagation
();
event
.
stopPropagation
();
event
.
preventDefault
();
event
.
preventDefault
();
if
(
this
.
isPageLocked
&&
range
.
pageIndex
!==
this
.
currentPageIndex
-
1
)
{
if
(
this
.
isPageLocked
&&
pageIndex
!==
this
.
currentPageIndex
-
1
)
{
this
.
$message
.
warning
(
'
页面已锁定,请先解锁
'
);
this
.
$message
.
warning
(
'
页面已锁定,请先解锁
'
);
return
;
return
;
}
}
this
.
currentPageIndex
=
range
.
pageIndex
+
1
;
this
.
currentPageIndex
=
pageIndex
+
1
;
this
.
currentPage
=
this
.
pages
[
range
.
pageIndex
];
this
.
currentPage
=
this
.
pages
[
pageIndex
];
this
.
selectedGroup
=
null
;
this
.
selectedGroup
=
null
;
this
.
currentGroup
=
null
;
this
.
currentGroup
=
null
;
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
startRegionPlayback
(
range
.
start
,
ran
ge
.
end
,
pageRegionId
);
this
.
startRegionPlayback
(
page
.
start
,
pa
ge
.
end
,
pageRegionId
);
this
.
updateRegionsStyle
();
this
.
updateRegionsStyle
();
});
});
};
};
region
.
element
.
removeEventListener
(
'
click
'
,
handleClick
);
region
.
element
.
removeEventListener
(
'
click
'
,
handleClick
);
region
.
element
.
addEventListener
(
'
click
'
,
handleClick
);
region
.
element
.
addEventListener
(
'
click
'
,
handleClick
);
// 添加区间更新事件处理
region
.
on
(
'
update-end
'
,
()
=>
{
// 直接更新页面时间
page
.
start
=
Number
(
region
.
start
.
toFixed
(
3
));
page
.
end
=
Number
(
region
.
end
.
toFixed
(
3
));
// 如果是当前页面,更新视图
if
(
pageIndex
===
this
.
currentPageIndex
-
1
)
{
this
.
updatePageTimeRange
();
}
});
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
`Error creating page region
${
pageRegionId
}
:`
,
err
);
console
.
error
(
`Error creating page region
${
pageRegionId
}
:`
,
err
);
}
}
}
});
});
// 创建组区间
// 创建组区间
this
.
pages
.
forEach
((
page
,
pageIndex
)
=>
{
this
.
pages
.
forEach
((
page
,
pageIndex
)
=>
{
if
(
page
.
groups
)
{
if
(
page
.
groups
)
{
page
.
groups
.
forEach
((
group
,
groupIndex
)
=>
{
page
.
groups
.
forEach
((
group
,
groupIndex
)
=>
{
const
start
=
typeof
group
.
start
===
'
number
'
&&
!
isNaN
(
group
.
start
)
?
if
(
typeof
group
.
start
===
'
number
'
&&
typeof
group
.
end
===
'
number
'
)
{
Number
(
group
.
start
.
toFixed
(
3
))
:
null
;
const
end
=
typeof
group
.
end
===
'
number
'
&&
!
isNaN
(
group
.
end
)
?
Number
(
group
.
end
.
toFixed
(
3
))
:
null
;
if
(
start
!==
null
&&
end
!==
null
&&
start
<
end
)
{
const
groupRegionId
=
`
${
pageIndex
}
-
${
groupIndex
}
`
;
const
groupRegionId
=
`
${
pageIndex
}
-
${
groupIndex
}
`
;
const
isCurrentPage
=
pageIndex
===
this
.
currentPageIndex
-
1
;
const
isCurrentPage
=
pageIndex
===
this
.
currentPageIndex
-
1
;
try
{
try
{
// 更新区间创建逻辑,添加左右边界拖拽功能
const
region
=
this
.
wavesurfer
.
addRegion
({
const
region
=
this
.
wavesurfer
.
addRegion
({
id
:
groupRegionId
,
id
:
groupRegionId
,
start
:
start
,
start
:
group
.
start
,
end
:
end
,
end
:
group
.
end
,
color
:
isCurrentPage
?
'
rgba(64, 158, 255, 0.2)
'
:
'
rgba(144, 147, 153, 0.1)
'
,
color
:
isCurrentPage
?
'
rgba(64, 158, 255, 0.2)
'
:
'
rgba(144, 147, 153, 0.1)
'
,
drag
:
isCurrentPage
&&
!
this
.
isPageLocked
,
drag
:
true
,
resize
:
isCurrentPage
&&
!
this
.
isPageLocked
,
resize
:
true
,
dragLeft
:
isCurrentPage
&&
!
this
.
isPageLocked
,
// 允许拖动左边界
dragRight
:
isCurrentPage
&&
!
this
.
isPageLocked
,
// 允许拖动右边界
opacity
:
(
!
this
.
isPageLocked
||
isCurrentPage
)
?
1
:
0.3
,
handleStyle
:
{
handleStyle
:
{
left
:
{
left
:
{
backgroundColor
:
'
#409EFF
'
,
backgroundColor
:
'
#409EFF
'
,
width
:
'
8
px
'
,
width
:
'
4
px
'
,
height
:
'
100%
'
,
height
:
'
100%
'
,
cursor
:
'
ew-resize
'
cursor
:
'
ew-resize
'
},
},
right
:
{
right
:
{
backgroundColor
:
'
#409EFF
'
,
backgroundColor
:
'
#409EFF
'
,
width
:
'
8
px
'
,
width
:
'
4
px
'
,
height
:
'
100%
'
,
height
:
'
100%
'
,
cursor
:
'
ew-resize
'
cursor
:
'
ew-resize
'
}
}
...
@@ -434,34 +409,24 @@ new Vue({
...
@@ -434,34 +409,24 @@ new Vue({
if
(
region
)
{
if
(
region
)
{
this
.
audioRegions
[
groupRegionId
]
=
region
;
this
.
audioRegions
[
groupRegionId
]
=
region
;
const
handleGroupClick
=
(
event
)
=>
{
// 添加点击事件
const
handleClick
=
(
event
)
=>
{
event
.
stopPropagation
();
event
.
stopPropagation
();
event
.
preventDefault
();
event
.
preventDefault
();
this
.
startRegionPlayback
(
group
.
start
,
group
.
end
,
groupRegionId
);
// 锁定状态下只允许播放当前页面的区间
if
(
this
.
isPageLocked
&&
!
isCurrentPage
)
{
this
.
$message
.
warning
(
'
页面已锁定,只能播放当前页面的区间
'
);
return
;
}
this
.
startRegionPlayback
(
start
,
end
,
groupRegionId
);
};
};
region
.
element
.
removeEventListener
(
'
click
'
,
handleClick
);
region
.
element
.
removeEventListener
(
'
click
'
,
handleGroupClick
);
region
.
element
.
addEventListener
(
'
click
'
,
handleClick
);
region
.
element
.
addEventListener
(
'
click
'
,
handleGroupClick
);
// 添加区间更新事件处理
// 添加区间更新事件处理
region
.
on
(
'
update-end
'
,
()
=>
{
region
.
on
(
'
update-end
'
,
()
=>
{
const
group
=
this
.
currentPage
.
groups
[
groupIndex
];
if
(
group
)
{
group
.
start
=
Number
(
region
.
start
.
toFixed
(
3
));
group
.
start
=
Number
(
region
.
start
.
toFixed
(
3
));
group
.
end
=
Number
(
region
.
end
.
toFixed
(
3
));
group
.
end
=
Number
(
region
.
end
.
toFixed
(
3
));
// 如果当前选中的就是这个组,更新编辑器中的值
// 如果当前选中的就是这个组,更新编辑器中的值
if
(
this
.
selectedGroup
===
group
Index
)
{
if
(
this
.
selectedGroup
===
groupIndex
&&
this
.
currentPageIndex
-
1
===
page
Index
)
{
this
.
currentGroup
=
group
;
this
.
currentGroup
=
group
;
}
}
}
});
});
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1280,119 +1245,181 @@ new Vue({
...
@@ -1280,119 +1245,181 @@ new Vue({
if
(
!
this
.
currentPage
)
return
;
if
(
!
this
.
currentPage
)
return
;
if
(
!
this
.
isPageLocked
)
{
if
(
!
this
.
isPageLocked
)
{
// 获取当前页面的时间范围
// 保存当前缩放级别
const
times
=
this
.
currentPage
.
groups
.
reduce
((
acc
,
group
)
=>
{
this
.
previousZoomLevel
=
this
.
zoomLevel
;
if
(
typeof
group
.
start
===
'
number
'
&&
!
isNaN
(
group
.
start
))
{
acc
.
starts
.
push
(
group
.
start
);
}
if
(
typeof
group
.
end
===
'
number
'
&&
!
isNaN
(
group
.
end
))
{
acc
.
ends
.
push
(
group
.
end
);
}
return
acc
;
},
{
starts
:
[],
ends
:
[]
});
if
(
times
.
starts
.
length
>
0
&&
times
.
ends
.
length
>
0
)
{
// 使用当前页面的实际时间范围
this
.
lockedPageStart
=
Math
.
min
(...
times
.
starts
)
;
this
.
lockedPageStart
=
this
.
currentPage
.
start
;
this
.
lockedPageEnd
=
Math
.
max
(...
times
.
ends
)
;
this
.
lockedPageEnd
=
this
.
currentPage
.
end
;
this
.
isPageLocked
=
true
;
this
.
isPageLocked
=
true
;
this
.
$message
.
success
(
'
页面已锁定
'
);
}
else
{
this
.
$message
.
warning
(
'
当前页面没有有效的时间范围
'
);
return
;
}
}
else
{
// 解锁页面
this
.
isPageLocked
=
false
;
this
.
lockedPageStart
=
null
;
this
.
lockedPageEnd
=
null
;
this
.
$message
.
success
(
'
页面已解锁
'
);
}
// 更新波形图区域样式
// 添加锁定状态的类名
this
.
updateRegionsStyle
();
document
.
body
.
classList
.
add
(
'
page-locked
'
);
},
// 新增:更新区域样式的统一方法
// 清除所有现有区间
updateRegionsStyle
()
{
Object
.
keys
(
this
.
audioRegions
).
forEach
(
regionId
=>
{
Object
.
keys
(
this
.
audioRegions
).
forEach
(
regionId
=>
{
const
region
=
this
.
audioRegions
[
regionId
];
const
region
=
this
.
audioRegions
[
regionId
];
if
(
!
region
)
return
;
if
(
region
)
{
region
.
remove
();
}
});
this
.
audioRegions
=
{};
// 如果是页面区间
// 为当前页创建开始和结束标记
if
(
regionId
.
startsWith
(
'
page-
'
))
{
const
pageRegionId
=
`page-
${
this
.
currentPageIndex
-
1
}
`
;
const
pageIndex
=
parseInt
(
regionId
.
split
(
'
-
'
)[
1
]);
const
isCurrentPage
=
pageIndex
===
this
.
currentPageIndex
-
1
;
const
isClickable
=
!
this
.
isPageLocked
||
isCurrentPage
;
region
.
update
({
// 创建开始标记(绿色竖线)
color
:
'
rgba(255, 192, 203, 0.3)
'
,
const
startMarker
=
this
.
wavesurfer
.
addRegion
({
drag
:
!
this
.
isPageLocked
,
// 锁定状态下不可拖动
id
:
`
${
pageRegionId
}
-start`
,
resize
:
!
this
.
isPageLocked
,
// 锁定状态下不可调整大小
start
:
this
.
lockedPageStart
,
opacity
:
(
!
this
.
isPageLocked
||
isCurrentPage
)
?
1
:
0.3
end
:
this
.
lockedPageStart
+
0.0001
,
color
:
'
rgba(0, 255, 0, 0.8)
'
,
drag
:
false
,
resize
:
false
});
});
// 更新点击事件处理
// 创建结束标记(红色竖线)
if
(
region
.
element
)
{
const
endMarker
=
this
.
wavesurfer
.
addRegion
({
region
.
element
.
style
.
pointerEvents
=
isClickable
?
'
all
'
:
'
none
'
;
id
:
`
${
pageRegionId
}
-end`
,
}
start
:
this
.
lockedPageEnd
-
0.0001
,
return
;
end
:
this
.
lockedPageEnd
,
color
:
'
rgba(255, 0, 0, 0.8)
'
,
drag
:
false
,
resize
:
false
});
if
(
startMarker
&&
endMarker
)
{
this
.
audioRegions
[
`
${
pageRegionId
}
-start`
]
=
startMarker
;
this
.
audioRegions
[
`
${
pageRegionId
}
-end`
]
=
endMarker
;
}
}
// 处理组区间
// 重新创建组区间
const
[
pageIndex
,
groupIndex
]
=
regionId
.
split
(
'
-
'
).
map
(
Number
);
if
(
this
.
currentPage
.
groups
)
{
const
isCurrentPage
=
pageIndex
===
this
.
currentPageIndex
-
1
;
this
.
currentPage
.
groups
.
forEach
((
group
,
groupIndex
)
=>
{
if
(
typeof
group
.
start
===
'
number
'
&&
typeof
group
.
end
===
'
number
'
)
{
const
groupRegionId
=
`
${
this
.
currentPageIndex
-
1
}
-
${
groupIndex
}
`
;
const
region
=
this
.
wavesurfer
.
addRegion
({
id
:
groupRegionId
,
start
:
group
.
start
,
end
:
group
.
end
,
color
:
'
rgba(64, 158, 255, 0.4)
'
,
drag
:
false
,
resize
:
false
,
opacity
:
1
});
region
.
update
({
if
(
region
)
{
color
:
isCurrentPage
?
'
rgba(64, 158, 255, 0.2)
'
:
'
rgba(144, 147, 153, 0.1)
'
,
this
.
audioRegions
[
groupRegionId
]
=
region
;
drag
:
isCurrentPage
,
resize
:
isCurrentPage
,
// 添加点击事件
opacity
:
(
!
this
.
isPageLocked
||
isCurrentPage
)
?
1
:
0.3
const
handleClick
=
(
event
)
=>
{
event
.
stopPropagation
();
event
.
preventDefault
();
this
.
startRegionPlayback
(
group
.
start
,
group
.
end
,
groupRegionId
);
};
region
.
element
.
removeEventListener
(
'
click
'
,
handleClick
);
region
.
element
.
addEventListener
(
'
click
'
,
handleClick
);
}
}
});
});
}
// 计算并应用缩放
const
duration
=
this
.
lockedPageEnd
-
this
.
lockedPageStart
;
const
padding
=
duration
*
0.1
;
const
displayStart
=
Math
.
max
(
0
,
this
.
lockedPageStart
-
padding
);
const
displayEnd
=
Math
.
min
(
this
.
wavesurfer
.
getDuration
(),
this
.
lockedPageEnd
+
padding
);
const
displayDuration
=
displayEnd
-
displayStart
;
const
totalDuration
=
this
.
wavesurfer
.
getDuration
();
const
zoomLevel
=
Math
.
min
(
500
,
Math
.
floor
((
totalDuration
/
displayDuration
)
*
1.25
));
// 先设置缩放
this
.
zoomLevel
=
zoomLevel
;
this
.
wavesurfer
.
zoom
(
zoomLevel
);
// 等待缩放完成后再调整位置
this
.
$nextTick
(()
=>
{
// 将视图中心定位到锁定区间中心
const
center
=
(
this
.
lockedPageStart
+
this
.
lockedPageEnd
)
/
2
;
this
.
wavesurfer
.
seekTo
(
center
/
totalDuration
);
});
});
},
// 新增:更新页面时间范围
this
.
$message
.
success
(
'
页面已锁定
'
);
updatePageTimeRange
(
type
,
value
)
{
}
else
{
if
(
!
this
.
currentPage
||
this
.
isPageLocked
)
return
;
// 解除锁定状态
this
.
isPageLocked
=
false
;
const
time
=
Number
(
value
);
// 保存当前页面的时间范围到 pages 数组
if
(
isNaN
(
time
))
return
;
const
currentPageIndex
=
this
.
currentPageIndex
-
1
;
if
(
this
.
pages
[
currentPageIndex
])
{
this
.
pages
[
currentPageIndex
].
start
=
this
.
currentPage
.
start
;
this
.
pages
[
currentPageIndex
].
end
=
this
.
currentPage
.
end
;
}
// 获取当前页的区间ID
this
.
lockedPageStart
=
null
;
const
pageRegionId
=
`page-
${
this
.
currentPageIndex
-
1
}
`
;
this
.
lockedPageEnd
=
null
;
const
region
=
this
.
audioRegions
[
pageRegionId
];
if
(
!
region
)
return
;
if
(
type
===
'
start
'
)
{
// 移除锁定状态的类名
// 确保开始时间不大于结束时间
document
.
body
.
classList
.
remove
(
'
page-locked
'
);
if
(
time
<
region
.
end
)
{
region
.
update
({
// 重新创建所有区间
start
:
time
this
.
createAllAudioRegions
();
// 恢复到之前的缩放级别
if
(
this
.
previousZoomLevel
!==
null
)
{
this
.
zoomLevel
=
this
.
previousZoomLevel
;
this
.
wavesurfer
.
zoom
(
this
.
previousZoomLevel
);
this
.
previousZoomLevel
=
null
;
}
this
.
$message
.
success
(
'
页面已解锁
'
);
}
},
// 更新页面时间范围的方法
updatePageTimeRange
()
{
if
(
!
this
.
currentPage
)
return
;
// 如果页面已锁定,更新锁定范围和标记
if
(
this
.
isPageLocked
)
{
this
.
lockedPageStart
=
this
.
currentPage
.
start
;
this
.
lockedPageEnd
=
this
.
currentPage
.
end
;
const
pageIndex
=
this
.
currentPageIndex
-
1
;
const
pageRegionId
=
`page-
${
pageIndex
}
`
;
const
startMarker
=
this
.
audioRegions
[
`
${
pageRegionId
}
-start`
];
const
endMarker
=
this
.
audioRegions
[
`
${
pageRegionId
}
-end`
];
if
(
startMarker
)
{
startMarker
.
update
({
start
:
this
.
currentPage
.
start
,
end
:
this
.
currentPage
.
start
+
0.0001
});
});
this
.
currentPage
.
start
=
time
;
}
else
{
this
.
$message
.
warning
(
'
开始时间不能大于结束时间
'
);
// 重置输入值
this
.
currentPage
.
start
=
region
.
start
;
}
}
}
else
if
(
type
===
'
end
'
)
{
// 确保结束时间不小于开始时间
if
(
endMarker
)
{
if
(
time
>
region
.
start
)
{
endMarker
.
update
(
{
region
.
update
({
start
:
this
.
currentPage
.
end
-
0.0001
,
end
:
t
ime
end
:
t
his
.
currentPage
.
end
});
});
this
.
currentPage
.
end
=
time
;
}
else
{
this
.
$message
.
warning
(
'
结束时间不能小于开始时间
'
);
// 重置输入值
this
.
currentPage
.
end
=
region
.
end
;
}
}
}
}
// 更新页面区间
const
pageIndex
=
this
.
currentPageIndex
-
1
;
const
pageRegionId
=
`page-
${
pageIndex
}
`
;
const
pageRegion
=
this
.
audioRegions
[
pageRegionId
];
if
(
pageRegion
)
{
pageRegion
.
update
({
start
:
this
.
currentPage
.
start
,
end
:
this
.
currentPage
.
end
});
}
},
},
// 处理
时间调整
// 处理
页面时间变化
handleTimeChange
(
type
,
value
)
{
handle
Page
TimeChange
(
type
,
value
)
{
if
(
!
this
.
current
Group
||
!
this
.
wavesurfer
||
this
.
isPageLocked
)
return
;
if
(
!
this
.
current
Page
||
!
this
.
wavesurfer
)
return
;
try
{
try
{
// 确保时间值有效
// 确保时间值有效
...
@@ -1406,41 +1433,46 @@ new Vue({
...
@@ -1406,41 +1433,46 @@ new Vue({
// 更新时间值
// 更新时间值
if
(
type
===
'
start
'
)
{
if
(
type
===
'
start
'
)
{
if
(
newTime
>=
this
.
current
Group
.
end
)
{
if
(
newTime
>=
this
.
current
Page
.
end
)
{
this
.
$message
.
warning
(
'
开始时间不能大于或等于结束时间
'
);
this
.
$message
.
warning
(
'
开始时间不能大于或等于结束时间
'
);
this
.
currentGroup
.
start
=
Number
((
this
.
currentGroup
.
end
-
0.1
).
toFixed
(
3
));
return
;
return
;
}
}
this
.
current
Group
.
start
=
newTime
;
this
.
current
Page
.
start
=
newTime
;
}
else
{
}
else
{
if
(
newTime
<=
this
.
current
Group
.
start
)
{
if
(
newTime
<=
this
.
current
Page
.
start
)
{
this
.
$message
.
warning
(
'
结束时间不能小于或等于开始时间
'
);
this
.
$message
.
warning
(
'
结束时间不能小于或等于开始时间
'
);
this
.
currentGroup
.
end
=
Number
((
this
.
currentGroup
.
start
+
0.1
).
toFixed
(
3
));
return
;
return
;
}
}
this
.
current
Group
.
end
=
newTime
;
this
.
current
Page
.
end
=
newTime
;
}
}
// 更新音频区域
// 更新页面时间范围(这会同步更新区间和锁定标记)
if
(
this
.
selectedGroup
!==
null
)
{
this
.
updatePageTimeRange
();
const
regionId
=
`
${
this
.
currentPageIndex
-
1
}
-
${
this
.
selectedGroup
}
`
;
}
catch
(
err
)
{
console
.
error
(
'
Error handling page time change:
'
,
err
);
this
.
$message
.
error
(
'
时间调整失败
'
);
}
},
// 更新区域样式的方法
updateRegionsStyle
()
{
if
(
!
this
.
wavesurfer
)
return
;
Object
.
keys
(
this
.
audioRegions
).
forEach
(
regionId
=>
{
// 跳过页面区间
if
(
regionId
.
startsWith
(
'
page-
'
))
return
;
const
[
pageIndex
,
groupIndex
]
=
regionId
.
split
(
'
-
'
).
map
(
Number
);
const
region
=
this
.
audioRegions
[
regionId
];
const
region
=
this
.
audioRegions
[
regionId
];
const
isCurrentPage
=
pageIndex
===
this
.
currentPageIndex
-
1
;
if
(
region
)
{
if
(
region
)
{
region
.
update
({
region
.
update
({
start
:
this
.
currentGroup
.
start
,
color
:
isCurrentPage
?
'
rgba(64, 158, 255, 0.2)
'
:
'
rgba(144, 147, 153, 0.1)
'
,
end
:
this
.
currentGroup
.
end
opacity
:
(
!
this
.
isPageLocked
||
isCurrentPage
)
?
1
:
0.3
});
});
}
}
}
});
// 如果正在播放该区间,重新开始播放
if
(
this
.
currentPlayingRegion
===
`
${
this
.
currentPageIndex
-
1
}
-
${
this
.
selectedGroup
}
`
)
{
this
.
startRegionPlayback
(
this
.
currentGroup
.
start
,
this
.
currentGroup
.
end
,
this
.
currentPlayingRegion
);
}
}
catch
(
err
)
{
console
.
error
(
'
Error handling time change:
'
,
err
);
this
.
$message
.
error
(
'
时间调整失败
'
);
}
},
},
},
},
...
...
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