Commit 2ca3ea70 authored by Jeff nan's avatar Jeff nan

feat: 添加安全验证

parent 6e693dc1
......@@ -211,6 +211,15 @@ function initVueApp(savedData) {
};
return map[key] || key;
},
async getAuthKey() {
const resp = await callServerMethod('getAuthKey');
if (resp.msg == 'success') {
return resp.data;
} else {
this.$message.error(resp.data);
return '';
}
},
// 结果 key -> 中文名称(去人声)
getVocalKeyZh(key) {
const map = {
......@@ -260,6 +269,15 @@ function initVueApp(savedData) {
return isStaging ? 'https://stagingopensource.iteachabc.com' : 'https://opensource.iteachabc.com';
},
// open API 鉴权 headers
async getApiAuthHeaders(extra) {
const authKey = await this.getAuthKey();
return Object.assign({
auth_key: authKey || '',
user_sign: 'syllabus_cw_make',
}, extra || {});
},
// 开始字幕任务轮询
startSubtitlePolling(taskUuid) {
const uuid = taskUuid || this.task_uuid;
......@@ -273,7 +291,8 @@ function initVueApp(savedData) {
const resp = await fetch(`${base}/open/api/ai/dpe/v1/common/task?task_uuid=${encodeURIComponent(uuid)}`, {
method: 'GET',
mode: 'cors',
cache: 'no-cache'
cache: 'no-cache',
headers: await this.getApiAuthHeaders(),
});
const json = await resp.json();
if (json && json.code === 200 && json.data) {
......@@ -330,7 +349,8 @@ function initVueApp(savedData) {
const resp = await fetch(`${base}/open/api/ai/dpe/v1/common/task?task_uuid=${encodeURIComponent(uuid)}`, {
method: 'GET',
mode: 'cors',
cache: 'no-cache'
cache: 'no-cache',
headers: await this.getApiAuthHeaders(),
});
const json = await resp.json();
if (json && json.code === 200 && json.data) {
......@@ -631,7 +651,7 @@ function initVueApp(savedData) {
try {
const resp = await fetch(`${base}/open/api/ai/dpe/v1/video/subtitles`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
headers: await this.getApiAuthHeaders({ 'Content-Type': 'application/json' }),
body: JSON.stringify({ video_url: videoUrl })
});
const json = await resp.json();
......@@ -684,7 +704,7 @@ function initVueApp(savedData) {
try {
const resp = await fetch(`${base}/open/api/ai/dpe/v1/video/vocalbgmute`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
headers: await this.getApiAuthHeaders({ 'Content-Type': 'application/json' }),
body: JSON.stringify({ video_url: videoUrl })
});
const json = await resp.json();
......@@ -2388,7 +2408,7 @@ function initVueApp(savedData) {
try {
const resp = await fetch(`${base}/open/api/ai/dpe/v1/video/subtitles/fromjson`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
headers: await this.getApiAuthHeaders({ '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