|
|
|
@ -41,6 +41,13 @@ export const ensureW6sAuth = () => { |
|
|
|
|
|
|
|
const signature = sha1(str).toString().toLowerCase() |
|
|
|
|
|
|
|
// SDK 默认接口超时仅 5s,getLocation 等 API 未在 5s 内回调会报"接口调用超时"
|
|
|
|
// 且 takePhotoAndAddWaterMark 内部会先调 getLocation,必须放宽超时
|
|
|
|
w6s.init({ |
|
|
|
auth: true, |
|
|
|
timeout: 5 * 60 * 1000, // 5 分钟,覆盖拍照+定位全流程
|
|
|
|
}) |
|
|
|
|
|
|
|
w6s.config({ |
|
|
|
access_key: access_key, |
|
|
|
nonce: nonce, |
|
|
|
@ -80,8 +87,10 @@ export const takePhotoWithWaterMark = async () => { |
|
|
|
locationEnable: true, |
|
|
|
success: (res) => { |
|
|
|
console.log('[w6sMedia] takePhotoAndAddWaterMark success 原始返回:', res) |
|
|
|
console.log('[w6sMedia] 返回字段 imageURL:', res?.imageURL, 'key:', res?.key, 'imageInfo:', res?.imageInfo) |
|
|
|
resolve(res) |
|
|
|
// 实际返回结构为 { result: { imageURL, key, imageInfo, mediaId } }(SDK jsonParser 包了一层 result)
|
|
|
|
const result = res?.result || res || {} |
|
|
|
console.log('[w6sMedia] 返回字段 imageURL:', result?.imageURL, 'key:', result?.key, 'imageInfo:', result?.imageInfo) |
|
|
|
resolve(result) |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
console.error('[w6sMedia] takePhotoAndAddWaterMark fail:', err) |
|
|
|
@ -110,15 +119,21 @@ export const startVideoRecorder = async ({ |
|
|
|
front, |
|
|
|
success: (res) => { |
|
|
|
console.log('[w6sMedia] startVideoRecoder success 原始返回:', res) |
|
|
|
const info = res?.info || {} |
|
|
|
// 实际返回结构为 { result: { code, message, info } }(SDK jsonParser 会包一层 result),而非 d.ts 声明的 { info }
|
|
|
|
const result = res?.result || res || {} |
|
|
|
const info = result?.info || {} |
|
|
|
if (!info.video_path) { |
|
|
|
reject(new Error('录制未生成视频文件')) |
|
|
|
return |
|
|
|
} |
|
|
|
// 客户端返回的是裸绝对路径(如 /data/data/.../xxx.mp4),FileTransfer 需要 file:// 前缀
|
|
|
|
const rawPath = info.video_path |
|
|
|
const videoPath = /^file:\/\//.test(rawPath) ? rawPath : `file://${rawPath}` |
|
|
|
// 从路径提取文件名(可能带查询参数)
|
|
|
|
const name = (info.video_path.split('/').pop() || '').split('?')[0] || `video-${Date.now()}.mp4` |
|
|
|
const name = (videoPath.split('/').pop() || '').split('?')[0] || `video-${Date.now()}.mp4` |
|
|
|
console.log('[w6sMedia] 解析出 video_path:', videoPath, 'name:', name) |
|
|
|
resolve({ |
|
|
|
video_path: info.video_path, |
|
|
|
video_path: videoPath, |
|
|
|
video_duration: info.video_duration, |
|
|
|
video_size: info.video_size, |
|
|
|
video_thumbnail: info.video_thumbnail, |
|
|
|
|