Commit 22295de0 authored by liujiangnan's avatar liujiangnan

feat

parent 9d944887
我有一个JSON数据,字段解释如下:
```
{
"audio_points": {
"说明": "音频相关的信息",
"字段": {
"audio_url": "音频文件的URL地址",
"points": {
"说明": "音频断点信息数组",
"包含字段": {
"start": "该段音频的开始时间(秒)",
"end": "该段音频的结束时间(秒)",
"text": "该段音频对应的英文文本",
"words": {
"说明": "单词级别的时间轴信息",
"包含字段": {
"start": "单词开始时间",
"end": "单词结束时间",
"word": "具体单词"
}
}
}
}
}
},
"pages": {
"说明": "书籍页面信息数组",
"字段": {
"image_url": "页面图片的URL地址",
"page": "页码",
"start": "该页面内容在音频中的开始时间",
"end": "该页面内容在音频中的结束时间",
"groups": {
"说明": "页面中的文本组信息",
"包含字段": {
"sentence": "识别出的英文句子",
"sentence_cn": "对应的中文翻译",
"start": "句子在音频中的开始时间",
"end": "句子在音频中的结束时间",
"reason": "时间戳缺失或特殊情况的解释说明",
"group": {
"说明": "文本在图片中的位置信息",
"包含字段": {
"rect": {
"x": "文本框左上角的X坐标(相对值)",
"y": "文本框左上角的Y坐标(相对值)",
"width": "文本框的宽度(相对值)",
"height": "文本框的高度(相对值)"
},
"text": "实际文本内容"
}
}
}
}
}
}
}
```
# 需求
我希望你基于 ./form/index.htm ./form/index.css ./form/index.js 帮我实现上面数据的可视化编辑功能,主要包含如下:
一、对于音频
1、要展示出音频的波形图,波形图能横向的放大和缩小,方便我查看毫秒级的细节
2、要把音频断点信息都展示出来,还有断点区间、断点区间的文本
3、能够通过拖拽微调断点区间
4、能够播放音频,播放的时候有个标识同步显示到波形图的位置上
二、对于书籍页面
1、要能展示每一页,显示所有的页面索引,通过点击能够跳转到对应的页
2、当点击跳转到某一页时,音频也定位到对应的位置,开始时间和结束时间都缩放到能够直观看到的程度
3、要把位置信息通过矩形标注到图片的对应位置上,并且能够调整矩形的位置和大小,方便我进行手动修正
4、要有个编辑区,能够修改对应的英文句子、翻译、开始时间、结束时间
5、开始时间与结束时间要和对应的音频区间联动,就是手动调整音频区间,这个时间也要同步变
6、要能在页上新建矩形框,然后手动填写英文句子、翻译、开始时间、结束时间
7、要能删除矩形框,点击删除的话弹一个确认框,如果确认就连同矩形对应的数据都删除掉就行了
# 技术框架描述
vue2、element-ui 2.12、jQuery 1.12.3
都是通过CDN的方式引入好的,你就不要用组件的形式新建其他文件了,都在 ./form/index.js 通过new VUE()的方式 全部实现逻辑部分就好。
我还给你提供了一个真实的数据文件 ./form/defaultData.json
This diff is collapsed.
html, body {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
#app {
height: 100vh;
}
.el-container {
height: 100%;
}
.el-main {
padding: 10px;
height: calc(100vh - 255px); /* 减去音频控制器和分页器的高度 */
display: flex;
flex-direction: column;
}
/* 主要内容区域 */
.el-row {
flex: 1;
display: flex;
flex-direction: row;
height: 100%;
}
.el-col {
display: flex;
flex-direction: column;
min-height: 0; /* 允许内容压缩 */
}
.edit-data{ /* 卡片样式 */
.el-card {
display: flex;
flex-direction: column;
height: 100%;
}
.el-card__header {
padding: 10px;
min-height: 20px;
}
.el-card__body {
flex: 1;
padding: 10px;
overflow: hidden;
display: flex;
flex-direction: column;
}
/* 图片编辑区域 */
.image-editor {
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
}
.image-editor .image-container {
flex: 1;
position: relative;
overflow: auto;
border: 2px dashed #dcdfe6;
border-radius: 4px;
padding: 10px; padding: 10px;
background-color: #fff;
display: flex;
justify-content: center;
align-items: flex-start;
}
.image-editor img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
position: relative;
}
/* 图片包装器,用于定位矩形 */
.image-wrapper {
position: relative;
display: inline-block;
line-height: 0;
}
/* 文本编辑区域 */
.text-editor {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
.text-editor .el-card__body {
overflow-y: auto;
}
.text-editor .el-table {
margin-bottom: 10px;
}
.text-editor .el-divider {
margin: 16px 0;
}
.text-editor .el-table .cell {
word-break: break-all;
}
/* 音频控制区域 */
.audio-control {
height: 200px;
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 1000;
margin: 0;
border-radius: 0;
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}
.audio-control .el-card__body {
padding: 10px 20px;
}
.waveform-container {
height: 100%;
display: flex;
flex-direction: column;
}
#waveform {
flex: 1;
min-height: 120px;
}
#wave-timeline {
height: 30px;
margin-bottom: 5px;
}
.audio-controls {
padding: 5px 0;
display: flex;
align-items: center;
}
/* 分页器样式 */
.pagination-container {
position: fixed;
bottom: 200px; /* 音频控制器的高度 */
left: 0;
right: 0;
z-index: 1000;
padding: 10px 0;
text-align: center;
background: rgba(255, 255, 255, 0.9);
border-top: 1px solid #EBEEF5;
}
/* 矩形框样式 */
.text-rect {
position: absolute;
border: 2px dashed #409EFF;
background-color: rgba(64, 158, 255, 0.1);
cursor: move;
transform-origin: top left;
user-select: none;
}
.text-rect.selected {
border-color: #67C23A;
background-color: rgba(103, 194, 58, 0.1);
z-index: 2;
}
.text-rect.highlighted {
border-color: #E6A23C;
background-color: rgba(230, 162, 60, 0.2);
z-index: 3;
}
.text-content {
position: absolute;
bottom: -20px;
left: 0;
width: 100%;
text-align: center;
font-size: 12px;
color: #606266;
background-color: rgba(255, 255, 255, 0.8);
padding: 2px 4px;
border-radius: 2px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.resize-handle {
position: absolute;
right: -5px;
bottom: -5px;
width: 10px;
height: 10px;
background-color: #fff;
border: 2px solid #409EFF;
cursor: se-resize;
z-index: 3;
}
.text-rect.selected .resize-handle {
border-color: #67C23A;
}
.text-rect .delete-rect-btn {
position: absolute;
right: -10px;
top: -10px;
padding: 4px;
opacity: 0;
transition: opacity 0.3s;
}
.text-rect:hover .delete-rect-btn {
opacity: 1;
}
.text-rect .delete-rect-btn i {
font-size: 12px;
}
/* Element UI 组件调整 */
.el-form-item {
margin-bottom: 10px;
}
.el-form-item__label {
line-height: 32px;
}
.el-input-number {
width: 100%;
}
.el-aside {
background-color: #f5f7fa;
padding: 20px;
}
.page-list {
height: 100%;
}
.image-container {
position: relative;
width: 100%;
overflow: hidden;
}
.image-container img {
width: 100%;
height: auto;
border-radius: 4px;
}
.line {
text-align: center;
line-height: 40px;
}
.wavesurfer-region {
z-index: 3 !important;
}
.wavesurfer-handle {
background-color: #409EFF !important;
width: 4px !important;
}
.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;
} }
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>h5-template-generator</title> <title>音频文本编辑器</title>
<link href="./index.css" rel="stylesheet" > <link href="./index.css" rel="stylesheet" >
<script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/jquery-1.12.3.min.js"></script> <script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/jquery-1.12.3.min.js"></script>
<script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js"></script> <script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js"></script>
...@@ -13,12 +13,192 @@ ...@@ -13,12 +13,192 @@
<link href="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/element-ui/theme-chalk/index.css" rel="stylesheet"> <link href="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/element-ui/theme-chalk/index.css" rel="stylesheet">
<!-- 引入组件库 --> <!-- 引入组件库 -->
<script src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/element-ui/index.js"></script> <script src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/element-ui/index.js"></script>
<!-- 引入波形图组件 -->
<script src="https://unpkg.com/wavesurfer.js@2.0.4/dist/wavesurfer.min.js"></script>
<script src="https://unpkg.com/wavesurfer.js@2.0.4/dist/plugin/wavesurfer.regions.min.js"></script>
<script src="https://unpkg.com/wavesurfer.js@2.0.4/dist/plugin/wavesurfer.timeline.min.js"></script>
<style>
.text-editor {
padding: 20px;
border: 2px dashed #dcdfe6;
border-radius: 4px;
height: calc(100vh - 40px);
overflow-y: auto;
}
</style>
</head> </head>
<body> <body>
<div class="edit-data"> <div id="app" v-loading.fullscreen.lock="loading">
<!-- 简单的例子,一个输入框+一个按钮,保存输入框的信息 --> <el-container>
test: <input type="text" name="test" /> <!-- 主要内容区域 -->
<input id="save" type="button" value="保存" > <el-main>
<el-row :gutter="20">
<!-- 左侧图片编辑区域 -->
<el-col :span="12">
<div class="image-editor" v-if="currentPage">
<div class="image-container" ref="imageContainer">
<div class="image-wrapper">
<img :src="currentPage.image_url" ref="pageImage" @load="handleImageLoad">
<template v-for="(group, groupIndex) in currentPage.groups">
<div
v-for="(item, itemIndex) in group.group"
:key="groupIndex + '-' + itemIndex"
class="text-rect"
:class="{
'selected': selectedGroup === groupIndex,
'highlighted': selectedGroup === groupIndex && selectedItemIndex === itemIndex
}"
:style="getRectStyle(item.rect)"
@mousedown="startDrag($event, groupIndex, itemIndex)">
<div class="resize-handle" @mousedown.stop="startResize($event, groupIndex, itemIndex)"></div>
<div class="text-content">{{ item.text }}</div>
<el-button
class="delete-rect-btn"
type="danger"
size="mini"
circle
@click.stop="deleteRect(groupIndex, itemIndex)">
<i class="el-icon-delete"></i>
</el-button>
</div>
</template>
</div>
<el-button
class="add-rect-btn"
type="primary"
circle
size="small"
@click="addNewRect">
<i class="el-icon-plus"></i>
</el-button>
</div>
</div>
</el-col>
<!-- 右侧文本编辑区域 -->
<el-col :span="12">
<div class="text-editor">
<!-- 页面时间范围 -->
<el-form label-width="70px" v-if="currentPage" style="padding: 10px;">
<el-form-item label="页面时间">
<el-col :span="11">
<el-input-number
v-model="currentPage.start"
:precision="2"
:step="0.1"
placeholder="开始时间">
</el-input-number>
</el-col>
<el-col class="line" :span="2">-</el-col>
<el-col :span="11">
<el-input-number
v-model="currentPage.end"
:precision="2"
:step="0.1"
placeholder="结束时间">
</el-input-number>
</el-col>
</el-form-item>
</el-form>
<!-- 选中组的编辑区域 -->
<template v-if="currentPage && selectedGroup !== null && currentGroup">
<el-divider>组编辑</el-divider>
<el-form label-width="100px">
<el-form-item label="英文句子">
<el-input v-model="currentGroup.sentence"></el-input>
</el-form-item>
<el-form-item label="中文翻译">
<el-input v-model="currentGroup.sentence_cn"></el-input>
</el-form-item>
<el-form-item label="时间范围">
<el-col :span="11">
<el-input-number
v-model="currentGroup.start"
:precision="2"
:step="0.1"
@change="updateAudioRegion">
</el-input-number>
</el-col>
<el-col class="line" :span="2">-</el-col>
<el-col :span="11">
<el-input-number
v-model="currentGroup.end"
:precision="2"
:step="0.1"
@change="updateAudioRegion">
</el-input-number>
</el-col>
</el-form-item>
<el-form-item label="矩形列表">
<el-table
:data="currentGroup.group"
size="mini"
border
highlight-current-row
@current-change="handleRectRowClick">
<el-table-column prop="text" label="文本内容"></el-table-column>
<el-table-column label="操作" width="80">
<template slot-scope="scope">
<el-button
type="danger"
size="mini"
icon="el-icon-delete"
circle
@click="deleteRectFromGroup(selectedGroup, scope.$index)">
</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
<el-form-item>
<el-button type="danger" @click="deleteGroup">删除整组</el-button>
</el-form-item>
</el-form>
</template>
</div>
</el-col>
</el-row>
</el-main>
</el-container>
<!-- 分页器 -->
<div class="pagination-container" v-if="currentPage">
<el-pagination
background
@current-change="handlePageChange"
:current-page.sync="currentPageIndex"
:page-size="1"
layout="prev, pager, next"
:total="pages.length">
</el-pagination>
</div>
<!-- 音频控制区域 -->
<el-card class="audio-control" v-loading="audioLoading">
<div class="waveform-container">
<div id="waveform"></div>
<div id="wave-timeline"></div>
<div class="audio-controls">
<el-button-group>
<el-button size="small" @click="playAudio" :disabled="audioLoading">
<i :class="isPlaying ? 'el-icon-video-pause' : 'el-icon-video-play'"></i>
</el-button>
<el-button size="small" @click="stopAudio" :disabled="audioLoading">
<i class="el-icon-video-stop"></i>
</el-button>
</el-button-group>
<el-slider
v-model="zoomLevel"
:min="1"
:max="500"
@change="handleZoom"
:disabled="audioLoading"
style="width: 200px; margin-left: 20px;">
</el-slider>
</div>
</div>
</el-card>
</div> </div>
</body> </body>
<script src="./index.js"></script> <script src="./index.js"></script>
......
This diff is collapsed.
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