55 lines
1.6 KiB
JavaScript
55 lines
1.6 KiB
JavaScript
// 获取生成接口URL
|
|
export function getGenerateUrl() {
|
|
return process.env.RunningHub_URL
|
|
}
|
|
|
|
// 获取生成接口请求头
|
|
export function getGenerateHeader(){
|
|
return {
|
|
'Content-Type': 'application/json',
|
|
'Host': 'www.runninghub.cn'
|
|
};
|
|
}
|
|
|
|
// 获取生成接口请求体
|
|
export function getGenerateBody(task) {
|
|
const taskData = JSON.parse(task.payload)
|
|
const payload = {...taskData,apiKey:task.apikey,webhookUrl: process.env.CALLBACK_URL}
|
|
// console.log('getGenerteBody', payload);
|
|
return JSON.stringify(payload);
|
|
}
|
|
|
|
// 获取回调接口
|
|
export function getQueryUrl() {
|
|
return process.env.CALLBACK_URL
|
|
}
|
|
|
|
// 获取任务状态
|
|
export function getTaskStatus() {
|
|
if(response.task_status === 'SUCCESS') return true;
|
|
}
|
|
|
|
// 提交任务后对返回的数据处理 从返回的数据里筛选成功的任务数据并返回相应外部平台的任务ID
|
|
export async function getSuccessTasks(response) {
|
|
const res = await response.json()
|
|
console.log('runninghub:\n', res)
|
|
if(res.msg === 'success' && res.code === 0) {
|
|
return res.data.taskId
|
|
} else {
|
|
return {message:res, type: 2}
|
|
}
|
|
}
|
|
|
|
// 获取结果后对返回的数据处理 从返回的数据里筛选成功的任务数据并返回相应外部平台的任务ID
|
|
export async function getTaskResult(response) {
|
|
const res = await JSON.parse(response)
|
|
const files = []
|
|
if(res.msg === 'success' && res.code === 0) {
|
|
for(const file of res.data)
|
|
files.push(file.fileUrl)
|
|
// console.log('files',files)
|
|
return {files: files[0], type: 1}
|
|
} else {
|
|
return {message:res.msg, type: 2}
|
|
}
|
|
} |