feat: 优化
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
import createClientAxios from '@gold/api/axios/client'
|
||||
import { refreshToken } from '@/api/auth'
|
||||
import { clearUserInfoCache } from '@/api/userinfo'
|
||||
import router from '@/router'
|
||||
import tokenManager from '@gold/utils/token-manager'
|
||||
|
||||
/**
|
||||
* 处理401/403错误 - 清理凭证并跳转登录页
|
||||
*/
|
||||
const handleAuthError = (error) => {
|
||||
tokenManager.clearTokens()
|
||||
clearUserInfoCache()
|
||||
router.push('/login')
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建HTTP客户端实例
|
||||
@@ -16,8 +27,8 @@ export function createHttpClient(options = {}) {
|
||||
baseURL: '/',
|
||||
timeout: 180000,
|
||||
refreshTokenFn: refreshToken,
|
||||
on401: on401 || ((error) => router.push('/login')),
|
||||
on403: on403 || ((error) => router.push('/login')),
|
||||
on401: on401 || handleAuthError,
|
||||
on403: on403 || handleAuthError,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -90,17 +90,13 @@ export function getLipSyncTask(taskId) {
|
||||
* 识别已上传的视频
|
||||
*/
|
||||
export async function identifyUploadedVideo(videoFile) {
|
||||
try {
|
||||
const urlRes = await MaterialService.getVideoPlayUrl(videoFile.fileId)
|
||||
if (urlRes.code !== 0 || !urlRes.data) {
|
||||
throw new Error(urlRes.msg || '获取播放链接失败')
|
||||
}
|
||||
|
||||
const identifyData = await performFaceIdentification(urlRes.data)
|
||||
return buildIdentifyResponse(videoFile.id, urlRes.data, identifyData, false)
|
||||
} catch (error) {
|
||||
throw error
|
||||
const urlRes = await MaterialService.getVideoPlayUrl(videoFile.fileId)
|
||||
if (urlRes.code !== 0 || !urlRes.data) {
|
||||
throw new Error(urlRes.msg || '获取播放链接失败')
|
||||
}
|
||||
|
||||
const identifyData = await performFaceIdentification(urlRes.data)
|
||||
return buildIdentifyResponse(videoFile.id, urlRes.data, identifyData, false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,23 +105,19 @@ export async function identifyUploadedVideo(videoFile) {
|
||||
export async function uploadAndIdentifyVideo(file) {
|
||||
const coverBase64 = await extractVideoCoverOptional(file)
|
||||
|
||||
try {
|
||||
const uploadRes = await MaterialService.uploadFile(file, 'video', coverBase64, null, null)
|
||||
if (uploadRes.code !== 0) {
|
||||
throw new Error(uploadRes.msg || '上传失败')
|
||||
}
|
||||
|
||||
const fileId = uploadRes.data
|
||||
|
||||
const urlRes = await MaterialService.getVideoPlayUrl(fileId)
|
||||
if (urlRes.code !== 0) {
|
||||
throw new Error(urlRes.msg || '获取播放链接失败')
|
||||
}
|
||||
|
||||
const identifyData = await performFaceIdentification(urlRes.data)
|
||||
return buildIdentifyResponse(fileId, urlRes.data, identifyData, true)
|
||||
} catch (error) {
|
||||
throw error
|
||||
const uploadRes = await MaterialService.uploadFile(file, 'digital_human', coverBase64, null, null)
|
||||
if (uploadRes.code !== 0) {
|
||||
throw new Error(uploadRes.msg || '上传失败')
|
||||
}
|
||||
|
||||
const fileId = uploadRes.data
|
||||
|
||||
const urlRes = await MaterialService.getVideoPlayUrl(fileId)
|
||||
if (urlRes.code !== 0) {
|
||||
throw new Error(urlRes.msg || '获取播放链接失败')
|
||||
}
|
||||
|
||||
const identifyData = await performFaceIdentification(urlRes.data)
|
||||
return buildIdentifyResponse(fileId, urlRes.data, identifyData, true)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user