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

debug

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