Commit 129fedbd authored by liujiangnan's avatar liujiangnan

feat

parent 19056cab
...@@ -297,20 +297,21 @@ ...@@ -297,20 +297,21 @@
</el-button> </el-button>
</el-button-group> </el-button-group>
<el-slider <el-button-group style="margin-left: 10px;">
v-model="zoomLevel" <el-button size="small" @click="handleZoomOut" :disabled="audioLoading">
:min="1" <i class="el-icon-zoom-out"></i>
:max="500" </el-button>
@change="handleZoom" <el-button size="small" @click="handleZoomIn" :disabled="audioLoading">
:disabled="audioLoading" <i class="el-icon-zoom-in"></i>
style="width: 200px;"> </el-button>
</el-slider> </el-button-group>
<el-button <el-button
size="small" size="small"
:type="isPageLocked ? 'danger' : 'primary'" :type="isPageLocked ? 'danger' : 'primary'"
@click="togglePageLock" @click="togglePageLock"
:class="{ 'is-active': isPageLocked }"> :class="{ 'is-active': isPageLocked }"
style="margin-left: 10px;">
<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>
......
...@@ -5,6 +5,9 @@ new Vue({ ...@@ -5,6 +5,9 @@ new Vue({
wavesurfer: null, wavesurfer: null,
isPlaying: false, isPlaying: false,
zoomLevel: 50, zoomLevel: 50,
minZoom: 1,
maxZoom: 500,
zoomStep: 20, // 每次放大/缩小的步长
audioRegions: {}, audioRegions: {},
// 数据相关 // 数据相关
...@@ -589,6 +592,27 @@ new Vue({ ...@@ -589,6 +592,27 @@ new Vue({
} }
}, },
// 缩放控制方法
handleZoomIn() {
if (!this.wavesurfer) return;
const newZoom = Math.min(this.maxZoom, this.zoomLevel + this.zoomStep);
if (newZoom !== this.zoomLevel) {
this.zoomLevel = newZoom;
this.handleZoom(this.zoomLevel);
}
},
handleZoomOut() {
if (!this.wavesurfer) return;
const newZoom = Math.max(this.minZoom, this.zoomLevel - this.zoomStep);
if (newZoom !== this.zoomLevel) {
this.zoomLevel = newZoom;
this.handleZoom(this.zoomLevel);
}
},
handleZoom(value) { handleZoom(value) {
if (!this.wavesurfer) return; if (!this.wavesurfer) return;
...@@ -599,7 +623,7 @@ new Vue({ ...@@ -599,7 +623,7 @@ new Vue({
const progress = currentTime / duration; const progress = currentTime / duration;
// 更新缩放设置 // 更新缩放设置
if (value === 1) { if (value === this.minZoom) {
// 最小缩放级别时,填充父容器 // 最小缩放级别时,填充父容器
this.wavesurfer.params.fillParent = true; this.wavesurfer.params.fillParent = true;
this.wavesurfer.params.scrollParent = false; this.wavesurfer.params.scrollParent = false;
...@@ -613,7 +637,7 @@ new Vue({ ...@@ -613,7 +637,7 @@ new Vue({
this.wavesurfer.zoom(value); this.wavesurfer.zoom(value);
// 重新定位到之前的位置 // 重新定位到之前的位置
if (value > 1) { if (value > this.minZoom) {
// 使用保存的进度或当前进度作为锚点 // 使用保存的进度或当前进度作为锚点
const targetProgress = this.currentProgress || progress; const targetProgress = this.currentProgress || progress;
this.wavesurfer.seekTo(targetProgress); this.wavesurfer.seekTo(targetProgress);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment