Commit ec3615d7 authored by liujiangnan's avatar liujiangnan

feat

parent a81536e1
......@@ -122,22 +122,22 @@
/* 按钮样式美化 */
.el-button {
/* .el-button {
border-radius: 8px !important;
font-weight: 500 !important;
transition: all 0.3s ease !important;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}
} */
.el-button:hover {
/* .el-button:hover {
transform: translateY(-1px) !important;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}
} */
.el-button--primary {
/* .el-button--primary {
background: linear-gradient(135deg, #409eff 0%, #1890ff 100%) !important;
border: none !important;
}
} */
.el-button--success {
background: linear-gradient(135deg, #67c23a 0%, #52c41a 100%) !important;
......
......@@ -235,17 +235,27 @@
</el-tooltip>
</div>
<div v-if="subtitleEditor && subtitleEditor.mergedList">
<el-timeline>
<el-timeline>
<el-timeline-item
v-for="item in subtitleEditor.mergedList"
v-for="(item, idx) in subtitleEditor.mergedList"
:key="`tl-${item.index}`"
:timestamp="item.start"
placement="top"
>
<el-card shadow="never" body-style="padding:12px;">
<div style="display:flex; align-items:center; gap:8px; color:#909399; font-size:12px; margin-bottom:4px;">
<span>#{{ item.index }}</span>
<span>{{ item.start }} - {{ item.end }}</span>
<div style="display:flex; align-items:center; color:#909399; font-size:12px; margin-bottom:4px;">
<div style="display:flex; align-items:center; gap:8px;">
<span>#{{ item.index }}</span>
<span>{{ item.start }} - {{ item.end }}</span>
<el-button
v-if="idx > 0"
size="mini"
type="primary"
plain
@click="mergeWithPrevious(idx)"
:disabled="isAnyTaskRunning()"
>与上一句合并</el-button>
</div>
</div>
<div style="display:flex; align-items:center; gap:8px; font-size:16px; margin-bottom:4px;">
<span style="display:block; line-height:1.05; margin:0; padding:0;">
......
......@@ -28,13 +28,13 @@ document.addEventListener('DOMContentLoaded', () => {
window.courseware.getData(function (data) {
window.air.hideAirClassLoading(key, data);
// if (!data) {
// // 加载默认数据
// $.getJSON('../play/defaultData.json', function (defaultData) {
// initVueApp(defaultData);
// })
// return;
// }
if (!data) {
// 加载默认数据
$.getJSON('../play/defaultData.json', function (defaultData) {
initVueApp(defaultData);
})
return;
}
//数据加载完,才算页面加载完成
initVueApp(data);
}, key);
......@@ -75,7 +75,9 @@ function initVueApp(savedData) {
subtitleEditor: {
subtitleList: [],
translatedList: [],
mergedList: []
mergedList: [],
clearedSIndices: [],
clearedTIndices: []
},
},
mounted() {
......@@ -694,6 +696,48 @@ function initVueApp(savedData) {
}
},
// 将当前条目与上一条合并(仅编辑视图,最终以 applyEditorChanges 写回)
mergeWithPrevious(idx) {
if (!this.subtitleEditor || !Array.isArray(this.subtitleEditor.mergedList)) return;
if (idx <= 0) {
this.$message.warning('第一句无法再向前合并');
return;
}
if (this.isAnyTaskRunning && this.isAnyTaskRunning()) {
this.$message.warning('有任务进行中,合并已锁定');
return;
}
const list = this.subtitleEditor.mergedList;
const prev = list[idx - 1];
const curr = list[idx];
if (!prev || !curr) return;
// 合并分词(字幕与翻译)
if (Array.isArray(prev.sWordsRef) || Array.isArray(curr.sWordsRef)) {
prev.sWordsRef = (prev.sWordsRef || []).concat(curr.sWordsRef || []);
}
if (Array.isArray(prev.tItemsRef) || Array.isArray(curr.tItemsRef)) {
prev.tItemsRef = (prev.tItemsRef || []).concat(curr.tItemsRef || []);
}
// 更新时间(以当前的结束时间为准)
prev.end = curr.end;
// 标记当前条目的原始索引,在应用修改时清空其内容
if (curr.sIndex != null) {
if (!Array.isArray(this.subtitleEditor.clearedSIndices)) this.subtitleEditor.clearedSIndices = [];
if (this.subtitleEditor.clearedSIndices.indexOf(curr.sIndex) === -1) {
this.subtitleEditor.clearedSIndices.push(curr.sIndex);
}
}
if (curr.tIndex != null) {
if (!Array.isArray(this.subtitleEditor.clearedTIndices)) this.subtitleEditor.clearedTIndices = [];
if (this.subtitleEditor.clearedTIndices.indexOf(curr.tIndex) === -1) {
this.subtitleEditor.clearedTIndices.push(curr.tIndex);
}
}
// 从可视列表中移除当前条目
list.splice(idx, 1);
this.$message.success('已与上一句合并');
},
// 从任意 JSON 中提取数组(优先常见字段,其次深度搜索)
extractArrayFromJson(root, type) {
if (!root) return [];
......@@ -964,6 +1008,21 @@ function initVueApp(savedData) {
tList[tIdx].translated = this.buildSentenceFromTranslatedItems(m.tItemsRef);
}
}
// 清空被合并项的原始内容,避免导出时出现重复
const clearedS = Array.isArray(this.subtitleEditor.clearedSIndices) ? this.subtitleEditor.clearedSIndices : [];
const clearedT = Array.isArray(this.subtitleEditor.clearedTIndices) ? this.subtitleEditor.clearedTIndices : [];
for (const si of clearedS) {
if (sList[si]) {
sList[si].words = [];
sList[si].text = '';
}
}
for (const ti of clearedT) {
if (tList[ti]) {
tList[ti].translatedItems = [];
tList[ti].translated = '';
}
}
this.$message.success('修改已应用到内存');
},
......
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