Commit 046c2acc authored by Jeff nan's avatar Jeff nan

debug

parent 2ca3ea70
...@@ -269,13 +269,11 @@ function initVueApp(savedData) { ...@@ -269,13 +269,11 @@ function initVueApp(savedData) {
return isStaging ? 'https://stagingopensource.iteachabc.com' : 'https://opensource.iteachabc.com'; return isStaging ? 'https://stagingopensource.iteachabc.com' : 'https://opensource.iteachabc.com';
}, },
// open API 鉴权 headers // open API 鉴权 query:auth_key / user_sign
async getApiAuthHeaders(extra) { async appendApiAuthQuery(url) {
const authKey = await this.getAuthKey(); const authKey = await this.getAuthKey();
return Object.assign({ const sep = url.includes('?') ? '&' : '?';
auth_key: authKey || '', return `${url}${sep}auth_key=${encodeURIComponent(authKey || '')}&user_sign=${encodeURIComponent('syllabus_cw_make')}`;
user_sign: 'syllabus_cw_make',
}, extra || {});
}, },
// 开始字幕任务轮询 // 开始字幕任务轮询
...@@ -288,11 +286,13 @@ function initVueApp(savedData) { ...@@ -288,11 +286,13 @@ function initVueApp(savedData) {
this.loadingText = '字幕任务已创建,正在处理...'; this.loadingText = '字幕任务已创建,正在处理...';
this.subtitlePollTimer = setInterval(async () => { this.subtitlePollTimer = setInterval(async () => {
try { try {
const resp = await fetch(`${base}/open/api/ai/dpe/v1/common/task?task_uuid=${encodeURIComponent(uuid)}`, { const url = await this.appendApiAuthQuery(
`${base}/open/api/ai/dpe/v1/common/task?task_uuid=${encodeURIComponent(uuid)}`
);
const resp = await fetch(url, {
method: 'GET', method: 'GET',
mode: 'cors', mode: 'cors',
cache: 'no-cache', cache: 'no-cache',
headers: await this.getApiAuthHeaders(),
}); });
const json = await resp.json(); const json = await resp.json();
if (json && json.code === 200 && json.data) { if (json && json.code === 200 && json.data) {
...@@ -346,11 +346,13 @@ function initVueApp(savedData) { ...@@ -346,11 +346,13 @@ function initVueApp(savedData) {
this.vocalLoadingText = '去人声任务已创建,正在处理...'; this.vocalLoadingText = '去人声任务已创建,正在处理...';
this.vocalPollTimer = setInterval(async () => { this.vocalPollTimer = setInterval(async () => {
try { try {
const resp = await fetch(`${base}/open/api/ai/dpe/v1/common/task?task_uuid=${encodeURIComponent(uuid)}`, { const url = await this.appendApiAuthQuery(
`${base}/open/api/ai/dpe/v1/common/task?task_uuid=${encodeURIComponent(uuid)}`
);
const resp = await fetch(url, {
method: 'GET', method: 'GET',
mode: 'cors', mode: 'cors',
cache: 'no-cache', cache: 'no-cache',
headers: await this.getApiAuthHeaders(),
}); });
const json = await resp.json(); const json = await resp.json();
if (json && json.code === 200 && json.data) { if (json && json.code === 200 && json.data) {
...@@ -649,9 +651,10 @@ function initVueApp(savedData) { ...@@ -649,9 +651,10 @@ function initVueApp(savedData) {
const base = this.getApiBase(); const base = this.getApiBase();
const loading = this.$loading({ lock: true, text: '正在提交字幕任务...', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }); const loading = this.$loading({ lock: true, text: '正在提交字幕任务...', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' });
try { try {
const resp = await fetch(`${base}/open/api/ai/dpe/v1/video/subtitles`, { const url = await this.appendApiAuthQuery(`${base}/open/api/ai/dpe/v1/video/subtitles`);
const resp = await fetch(url, {
method: 'POST', method: 'POST',
headers: await this.getApiAuthHeaders({ 'Content-Type': 'application/json' }), headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ video_url: videoUrl }) body: JSON.stringify({ video_url: videoUrl })
}); });
const json = await resp.json(); const json = await resp.json();
...@@ -702,9 +705,10 @@ function initVueApp(savedData) { ...@@ -702,9 +705,10 @@ function initVueApp(savedData) {
const base = this.getApiBase(); const base = this.getApiBase();
const loading = this.$loading({ lock: true, text: '正在提交去人声任务...', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }); const loading = this.$loading({ lock: true, text: '正在提交去人声任务...', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' });
try { try {
const resp = await fetch(`${base}/open/api/ai/dpe/v1/video/vocalbgmute`, { const url = await this.appendApiAuthQuery(`${base}/open/api/ai/dpe/v1/video/vocalbgmute`);
const resp = await fetch(url, {
method: 'POST', method: 'POST',
headers: await this.getApiAuthHeaders({ 'Content-Type': 'application/json' }), headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ video_url: videoUrl }) body: JSON.stringify({ video_url: videoUrl })
}); });
const json = await resp.json(); const json = await resp.json();
...@@ -2406,9 +2410,10 @@ function initVueApp(savedData) { ...@@ -2406,9 +2410,10 @@ function initVueApp(savedData) {
const base = this.getApiBase(); const base = this.getApiBase();
const loading = this.$loading({ lock: true, text: '正在重新生成歌词(约3-5分钟)...', spinner: 'el-icon-loading', background: 'rgba(0,0,0,0.7)' }); const loading = this.$loading({ lock: true, text: '正在重新生成歌词(约3-5分钟)...', spinner: 'el-icon-loading', background: 'rgba(0,0,0,0.7)' });
try { try {
const resp = await fetch(`${base}/open/api/ai/dpe/v1/video/subtitles/fromjson`, { const url = await this.appendApiAuthQuery(`${base}/open/api/ai/dpe/v1/video/subtitles/fromjson`);
const resp = await fetch(url, {
method: 'POST', method: 'POST',
headers: await this.getApiAuthHeaders({ 'Content-Type': 'application/json' }), headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ body: JSON.stringify({
subtitleJsonUrl: subUrl.replace('http://', 'https://'), subtitleJsonUrl: subUrl.replace('http://', 'https://'),
translatedJsonUrl: transUrl.replace('http://', 'https://') translatedJsonUrl: transUrl.replace('http://', 'https://')
......
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