Commit 36519112 authored by liujiangnan's avatar liujiangnan

feat

parent 62c3f146
...@@ -1008,8 +1008,8 @@ function initVueApp(savedData) { ...@@ -1008,8 +1008,8 @@ function initVueApp(savedData) {
this.$message.success('新歌词文件已上传并更新链接(避免CDN缓存)'); this.$message.success('新歌词文件已上传并更新链接(避免CDN缓存)');
// 可选刷新 CDN 或在URL后追加时间戳避免缓存 // 可选刷新 CDN 或在URL后追加时间戳避免缓存
// TODO(lyrics): 补全覆盖后触发“重新生成歌词文件”的后端调用逻辑 // 触发后端生成歌词并保存返回结果
// this.regenerateLyricsAfterUpload(); await this.regenerateLyricsAfterUpload();
} catch (e) { } catch (e) {
console.error(e); console.error(e);
this.$message.error('覆盖上传失败'); this.$message.error('覆盖上传失败');
...@@ -1057,6 +1057,42 @@ function initVueApp(savedData) { ...@@ -1057,6 +1057,42 @@ function initVueApp(savedData) {
return out.slice(0, len); return out.slice(0, len);
}, },
// 调后端接口:基于最新JSON生成歌词,并保存返回链接
async regenerateLyricsAfterUpload() {
const subUrl = (this.subtitlesResult && this.subtitlesResult.subtitleJsonUrl) || '';
const transUrl = (this.subtitlesResult && this.subtitlesResult.translatedJsonUrl) || '';
if (!subUrl || !transUrl) {
this.$message.error('缺少最新字幕/翻译 JSON 链接,无法生成歌词');
return;
}
const base = this.getApiBase();
const loading = this.$loading({ lock: true, text: '正在重新生成歌词(约3-5分钟)...', spinner: 'el-icon-loading', background: 'rgba(0,0,0,0.7)' });
try {
const resp = await fetch(`${base}/open/api/ai/dpe/v1/video/subtitles/fromjson`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
subtitleJsonUrl: subUrl.replace('http://', 'https://'),
translatedJsonUrl: transUrl.replace('http://', 'https://')
})
});
const json = await resp.json();
// 兼容两种返回结构:{code, data} 或 直接返回链接对象
const data = (json && json.code === 200 && json.data) ? json.data : json;
if (data && (data.assUrl || data.srtUrl || data.vttUrl)) {
this.subtitlesResult = Object.assign({}, this.subtitlesResult || {}, data);
this.saveData();
this.$message.success('歌词生成完成,已保存返回结果');
} else {
this.$message.error('生成歌词失败:返回数据异常');
}
} catch (e) {
console.error(e);
this.$message.error('生成歌词失败');
} finally {
loading.close();
}
},
// 工具:创建并下载JSON文件 // 工具:创建并下载JSON文件
createAndDownloadJson(filename, data) { createAndDownloadJson(filename, data) {
try { try {
......
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