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
f02a3818
Commit
f02a3818
authored
May 14, 2025
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 完成预览功能
parent
a2155bca
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
33 deletions
+43
-33
index.css
form/index.css
+5
-0
index.html
form/index.html
+2
-2
index.js
form/index.js
+36
-31
No files found.
form/index.css
View file @
f02a3818
...
...
@@ -695,6 +695,11 @@ html, body {
opacity
:
1
!important
;
}
.preview-mode
.el-slider
{
pointer-events
:
auto
!important
;
opacity
:
1
!important
;
}
/* 预览按钮激活状态 */
.basic-controls
.el-button.is-preview
{
color
:
#f56c6c
;
...
...
form/index.html
View file @
f02a3818
...
...
@@ -300,12 +300,12 @@
<el-button
@
click=
"handleZoomOut"
:disabled=
"!wavesurfer || audioLoading || zoomLevel <= minZoom"
>
<i
class=
"el-icon-zoom-out"
></i>
</el-button>
<el-button
@
click=
"togglePageLock"
:disabled=
"!wavesurfer || audioLoading || !currentPage"
>
<el-button
@
click=
"togglePageLock"
:disabled=
"!wavesurfer || audioLoading || !currentPage
|| isPreviewMode
"
>
<i
:class=
"isPageLocked ? 'el-icon-lock' : 'el-icon-unlock'"
></i>
</el-button>
<el-button
@
click=
"togglePreviewMode"
:disabled=
"!wavesurfer || audioLoading
|| isPageLocked
"
:disabled=
"!wavesurfer || audioLoading"
:type=
"isPreviewMode ? 'danger' : 'default'"
>
<i
:class=
"isPreviewMode ? 'el-icon-switch-button' : 'el-icon-view'"
></i>
...
...
form/index.js
View file @
f02a3818
...
...
@@ -313,6 +313,14 @@ new Vue({
}
}
}
// 在预览模式下,手动调整位置时也同步页面和组的选中状态
if
(
this
.
isPreviewMode
)
{
// 重置最后检查时间,确保定时器能立即开始新的检查
this
.
lastCheckedTime
=
0
;
this
.
checkAndSwitchPage
(
this
.
currentTime
);
this
.
checkAndSelectGroup
(
this
.
currentTime
);
}
});
// 加载音频
...
...
@@ -1839,6 +1847,7 @@ new Vue({
// 新增:切换预览模式
togglePreviewMode
()
{
// 如果页面处于锁定状态,提示用户先解锁
if
(
this
.
isPageLocked
)
{
this
.
$message
.
warning
(
'
请先解锁页面
'
);
return
;
...
...
@@ -1890,20 +1899,18 @@ new Vue({
// 创建新的监听定时器
this
.
previewTimer
=
setInterval
(()
=>
{
if
(
!
this
.
isP
laying
||
!
this
.
isP
reviewMode
)
return
;
if
(
!
this
.
isPreviewMode
)
return
;
const
currentTime
=
this
.
wavesurfer
.
getCurrentTime
();
// 优化:每
100ms才检查一次,避免过于频繁
if
(
currentTime
-
this
.
lastCheckedTime
<
0.
1
)
return
;
// 优化:每
50ms检查一次
if
(
currentTime
-
this
.
lastCheckedTime
<
0.
05
)
return
;
this
.
lastCheckedTime
=
currentTime
;
// 检查是否需要切换页面
// 检查是否需要切换页面
和选中组
this
.
checkAndSwitchPage
(
currentTime
);
// 检查是否需要选中组
this
.
checkAndSelectGroup
(
currentTime
);
},
100
);
// 100ms检查一次
},
50
);
},
// 新增:停止预览监听
...
...
@@ -1916,16 +1923,18 @@ new Vue({
// 新增:检查并切换页面
checkAndSwitchPage
(
currentTime
)
{
for
(
let
i
=
0
;
i
<
this
.
pages
.
length
;
i
++
)
{
const
page
=
this
.
pages
[
i
];
if
(
page
.
start
<=
currentTime
&&
currentTime
<=
page
.
end
)
{
if
(
this
.
currentPageIndex
!==
i
+
1
)
{
this
.
currentPageIndex
=
i
+
1
;
this
.
currentPage
=
page
;
this
.
selectedGroup
=
null
;
this
.
currentGroup
=
null
;
}
break
;
if
(
!
this
.
pages
||
!
this
.
pages
.
length
)
return
;
// 找到当前时间所在的页面
const
targetPage
=
this
.
pages
.
find
(
page
=>
currentTime
>=
page
.
start
&&
currentTime
<=
page
.
end
);
if
(
targetPage
)
{
const
targetIndex
=
this
.
pages
.
indexOf
(
targetPage
)
+
1
;
if
(
targetIndex
!==
this
.
currentPageIndex
)
{
this
.
currentPageIndex
=
targetIndex
;
this
.
currentPage
=
targetPage
;
}
}
},
...
...
@@ -1934,21 +1943,17 @@ new Vue({
checkAndSelectGroup
(
currentTime
)
{
if
(
!
this
.
currentPage
||
!
this
.
currentPage
.
groups
)
return
;
let
found
=
false
;
for
(
let
i
=
0
;
i
<
this
.
currentPage
.
groups
.
length
;
i
++
)
{
const
group
=
this
.
currentPage
.
groups
[
i
];
if
(
group
.
start
<=
currentTime
&&
currentTime
<=
group
.
end
)
{
if
(
this
.
selectedGroup
!==
i
)
{
this
.
selectedGroup
=
i
;
this
.
currentGroup
=
group
;
}
found
=
true
;
break
;
}
}
// 找到当前时间所在的组
const
targetGroup
=
this
.
currentPage
.
groups
.
findIndex
(
group
=>
currentTime
>=
group
.
start
&&
currentTime
<=
group
.
end
);
// 如果不在任何组的时间范围内,取消选中
if
(
!
found
&&
this
.
selectedGroup
!==
null
)
{
if
(
targetGroup
!==
-
1
)
{
if
(
this
.
selectedGroup
!==
targetGroup
)
{
this
.
selectedGroup
=
targetGroup
;
this
.
currentGroup
=
this
.
currentPage
.
groups
[
targetGroup
];
}
}
else
{
this
.
selectedGroup
=
null
;
this
.
currentGroup
=
null
;
}
...
...
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