|
@@ -278,6 +278,7 @@ export default {
|
|
|
|
|
|
// 添加上传队列相关数据
|
|
|
uploadQueue: [], // 存储待上传的视频
|
|
|
+ backgroundUploadQueue: [], // 存储后台上传的视频
|
|
|
isUploading: false, // 标记是否正在上传
|
|
|
uploadProgress: {}, // 存储每个视频的上传进度
|
|
|
uploadStatus: {}, // 存储每个视频的上传状态
|
|
@@ -1391,7 +1392,7 @@ export default {
|
|
|
|
|
|
// 恢复原始问题的字幕
|
|
|
if (this.isFollowUpQuestion && this.currentFollowUpQuestion) {
|
|
|
- this.currentSubtitle = this.currentFollowUpQuestion.digital_human_video_subtitle || this.currentFollowUpQuestion.question;
|
|
|
+ this.currentSubtitle = this.currentFollowUpQuestion.question || this.currentFollowUpQuestion.question;
|
|
|
} else if (this.originalQuestionSubtitle) {
|
|
|
this.currentSubtitle = this.originalQuestionSubtitle;
|
|
|
}
|
|
@@ -1549,6 +1550,9 @@ export default {
|
|
|
// 记录录制开始时间
|
|
|
this.recordingStartTime = Date.now();
|
|
|
this.recordingTimerCount = 0;
|
|
|
+
|
|
|
+ // 获取当前问题的推荐录制时长
|
|
|
+ this.maxRecordingTime = this.getCurrentQuestionRecommendedDuration();
|
|
|
this.remainingTime = this.maxRecordingTime;
|
|
|
|
|
|
// 启动计时器,每秒更新计时
|
|
@@ -1561,11 +1565,11 @@ export default {
|
|
|
' / ' + this.formatTime(this.maxRecordingTime) */;
|
|
|
|
|
|
// 更新进度百分比 - 确保值在0-100之间
|
|
|
- this.progressPercent = (this.recordingTimerCount / this.maxRecordingTime) * 100;
|
|
|
+ this.progressPercent = Math.min((this.recordingTimerCount / this.maxRecordingTime) * 100, 100);
|
|
|
|
|
|
// 检查是否达到最大录制时间
|
|
|
if (this.recordingTimerCount >= this.maxRecordingTime) {
|
|
|
- console.log('已达到最大录制时间(5分钟),自动停止录制');
|
|
|
+ console.log(`已达到最大录制时间(${this.maxRecordingTime}秒),自动停止录制`);
|
|
|
this.stopRecordingAnswer();
|
|
|
}
|
|
|
}, 1000);
|
|
@@ -1662,9 +1666,10 @@ export default {
|
|
|
if (isIOS) {
|
|
|
console.log('iOS: 检查相机状态');
|
|
|
|
|
|
- // 使用最简单的选项,设置最大录制时间为5分钟
|
|
|
+ // 使用最简单的选项,设置最大录制时间为当前问题的推荐时长
|
|
|
+ const maxDuration = this.getCurrentQuestionRecommendedDuration() * 1000; // 转换为毫秒
|
|
|
const options = {
|
|
|
- timeout: 300000, // 300秒超时 (5分钟)
|
|
|
+ timeout: maxDuration, // 使用当前问题的推荐时长
|
|
|
quality: 'low', // 降低质量
|
|
|
compressed: true,
|
|
|
success: () => {
|
|
@@ -1686,9 +1691,10 @@ export default {
|
|
|
this.useAlternativeRecordingMethod();
|
|
|
}
|
|
|
} else {
|
|
|
- // Android使用标准选项,设置最大录制时间为5分钟
|
|
|
+ // Android使用标准选项,设置最大录制时间为当前问题的推荐时长
|
|
|
+ const maxDuration = this.getCurrentQuestionRecommendedDuration() * 1000; // 转换为毫秒
|
|
|
const options = {
|
|
|
- timeout: 300000, // 300秒超时 (5分钟)
|
|
|
+ timeout: maxDuration, // 使用当前问题的推荐时长
|
|
|
quality: 'medium',
|
|
|
compressed: true,
|
|
|
success: () => {
|
|
@@ -1722,7 +1728,7 @@ export default {
|
|
|
// 选择相册中的视频
|
|
|
uni.chooseVideo({
|
|
|
sourceType: ['album'],
|
|
|
- maxDuration: 300, // 从60秒改为300秒
|
|
|
+ maxDuration: this.getCurrentQuestionRecommendedDuration(), // 使用当前问题的推荐时长
|
|
|
camera: 'front',
|
|
|
success: (res) => {
|
|
|
console.log('选择视频成功:', res.tempFilePath);
|
|
@@ -2245,29 +2251,342 @@ export default {
|
|
|
// 更新上传状态文本
|
|
|
this.updateUploadStatusText();
|
|
|
|
|
|
- // 等待上传完成后再执行后续操作
|
|
|
- return new Promise((resolve) => {
|
|
|
- const checkUploadStatus = () => {
|
|
|
- if (!this.isUploading && this.uploadQueue.length === 0) {
|
|
|
- // 上传完成后执行后续操作
|
|
|
- this.handlePostUploadActions(uploadTask);
|
|
|
- resolve();
|
|
|
+ // 如果是追问问题,使用后台上传,不阻塞流程
|
|
|
+ if (isFollowUpQuestionUpload) {
|
|
|
+ console.log('追问问题使用后台上传,不阻塞流程');
|
|
|
+
|
|
|
+ // 立即执行后续操作,不等待上传完成
|
|
|
+ this.handlePostUploadActions(uploadTask);
|
|
|
+
|
|
|
+ // 启动后台上传
|
|
|
+ this.startBackgroundUpload(uploadTask);
|
|
|
+
|
|
|
+ // 返回立即解决的Promise
|
|
|
+ return Promise.resolve();
|
|
|
+ } else {
|
|
|
+ // 常规问题保持原有逻辑,等待上传完成
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ const checkUploadStatus = () => {
|
|
|
+ if (!this.isUploading && this.uploadQueue.length === 0) {
|
|
|
+ // 上传完成后执行后续操作
|
|
|
+ this.handlePostUploadActions(uploadTask);
|
|
|
+ resolve();
|
|
|
+ } else {
|
|
|
+ // 如果还在上传,继续检查
|
|
|
+ setTimeout(checkUploadStatus, 100);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 如果当前没有上传任务在进行,开始处理队列
|
|
|
+ if (!this.isUploading) {
|
|
|
+ this.processUploadQueue();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 开始检查上传状态
|
|
|
+ checkUploadStatus();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 添加新方法:启动后台上传
|
|
|
+ startBackgroundUpload(task) {
|
|
|
+ console.log('启动后台上传任务:', task.id);
|
|
|
+
|
|
|
+ // 标记为后台上传任务
|
|
|
+ task.isBackgroundUpload = true;
|
|
|
+
|
|
|
+ // 从主上传队列中移除,避免与常规上传冲突
|
|
|
+ const taskIndex = this.uploadQueue.findIndex(t => t.id === task.id);
|
|
|
+ if (taskIndex !== -1) {
|
|
|
+ this.uploadQueue.splice(taskIndex, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加到后台上传队列
|
|
|
+ if (!this.backgroundUploadQueue) {
|
|
|
+ this.backgroundUploadQueue = [];
|
|
|
+ }
|
|
|
+ this.backgroundUploadQueue.push(task);
|
|
|
+
|
|
|
+ // 启动后台上传处理
|
|
|
+ this.processBackgroundUploadQueue();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 添加新方法:处理后台上传队列
|
|
|
+ processBackgroundUploadQueue() {
|
|
|
+ // 如果后台上传队列为空,结束处理
|
|
|
+ if (!this.backgroundUploadQueue || this.backgroundUploadQueue.length === 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取队列中的第一个任务
|
|
|
+ const task = this.backgroundUploadQueue[0];
|
|
|
+
|
|
|
+ console.log('开始后台上传:', task.id);
|
|
|
+
|
|
|
+ // 更新任务状态
|
|
|
+ this.uploadStatus[task.id] = 'uploading';
|
|
|
+ this.updateUploadStatusText();
|
|
|
+
|
|
|
+ // 增加尝试次数
|
|
|
+ task.attempts++;
|
|
|
+
|
|
|
+ // 根据文件类型选择上传方法
|
|
|
+ if (typeof task.file === 'string') {
|
|
|
+ // 小程序环境,使用uni.uploadFile上传
|
|
|
+ this.uploadFileWithUniBackground(task);
|
|
|
+ } else {
|
|
|
+ // 浏览器环境,使用XMLHttpRequest上传
|
|
|
+ this.uploadFileWithXHRBackground(task);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 添加新方法:使用XMLHttpRequest后台上传文件
|
|
|
+ uploadFileWithXHRBackground(task) {
|
|
|
+ // 获取用户信息
|
|
|
+ const userInfo = uni.getStorageSync('userInfo');
|
|
|
+ const openid = userInfo ? (JSON.parse(userInfo).openid || '') : '';
|
|
|
+ const tenant_id = JSON.parse(uni.getStorageSync('userInfo')).tenant_id || '1';
|
|
|
+
|
|
|
+ // 创建FormData
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append('file', task.file);
|
|
|
+ formData.append('openid', openid);
|
|
|
+ formData.append('tenant_id', tenant_id);
|
|
|
+ formData.append('application_id', uni.getStorageSync('appId'));
|
|
|
+ formData.append('question_id', task.questionId);
|
|
|
+ formData.append('video_duration', task.videoDuration || 0);
|
|
|
+ formData.append('has_audio', 'true');
|
|
|
+
|
|
|
+ // 创建XMLHttpRequest
|
|
|
+ const xhr = new XMLHttpRequest();
|
|
|
+
|
|
|
+ // 监听上传进度
|
|
|
+ xhr.upload.onprogress = (event) => {
|
|
|
+ if (event.lengthComputable) {
|
|
|
+ const progress = Math.round((event.loaded / event.total) * 100);
|
|
|
+ this.uploadProgress[task.id] = progress;
|
|
|
+ this.updateUploadStatusText();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 监听请求完成
|
|
|
+ xhr.onload = () => {
|
|
|
+ if (xhr.status === 200) {
|
|
|
+ try {
|
|
|
+ const res = JSON.parse(xhr.responseText);
|
|
|
+ console.log('后台上传响应:', res);
|
|
|
+ if (res.code === 2000) {
|
|
|
+ // 获取上传后的视频URL
|
|
|
+ const videoUrl = res.data.url || res.data.photoUrl || '';
|
|
|
+ if (videoUrl) {
|
|
|
+ // 上传成功,更新状态
|
|
|
+ this.uploadStatus[task.id] = 'success';
|
|
|
+ this.updateUploadStatusText();
|
|
|
+
|
|
|
+ // 提交到面试接口
|
|
|
+ this.submitVideoToInterviewBackground(videoUrl, task);
|
|
|
+ } else {
|
|
|
+ this.handleBackgroundUploadFailure(task, '视频URL获取失败');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.handleBackgroundUploadFailure(task, res.msg || '上传失败');
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ this.handleBackgroundUploadFailure(task, '解析响应失败');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.handleBackgroundUploadFailure(task, 'HTTP状态: ' + xhr.status);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 监听错误
|
|
|
+ xhr.onerror = () => {
|
|
|
+ this.handleBackgroundUploadFailure(task, '网络错误');
|
|
|
+ };
|
|
|
+
|
|
|
+ // 监听超时
|
|
|
+ xhr.ontimeout = () => {
|
|
|
+ this.handleBackgroundUploadFailure(task, '上传超时');
|
|
|
+ };
|
|
|
+
|
|
|
+ // 发送请求
|
|
|
+ xhr.open('POST', `${apiBaseUrl}/api/upload/`);
|
|
|
+ xhr.send(formData);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 添加新方法:使用uni.uploadFile后台上传文件
|
|
|
+ uploadFileWithUniBackground(task) {
|
|
|
+ // 获取用户信息
|
|
|
+ const userInfo = uni.getStorageSync('userInfo');
|
|
|
+ const openid = userInfo ? (JSON.parse(userInfo).openid || '') : '';
|
|
|
+ const tenant_id = JSON.parse(uni.getStorageSync('userInfo')).tenant_id || '1';
|
|
|
+
|
|
|
+ // 创建上传任务
|
|
|
+ const uploadTask = uni.uploadFile({
|
|
|
+ url: `${apiBaseUrl}/api/upload/`,
|
|
|
+ filePath: task.file,
|
|
|
+ name: 'file',
|
|
|
+ formData: {
|
|
|
+ openid: openid,
|
|
|
+ tenant_id: tenant_id,
|
|
|
+ application_id: uni.getStorageSync('appId'),
|
|
|
+ question_id: task.questionId,
|
|
|
+ video_duration: task.videoDuration || 0,
|
|
|
+ has_audio: 'true'
|
|
|
+ },
|
|
|
+ success: (uploadRes) => {
|
|
|
+ try {
|
|
|
+ const res = JSON.parse(uploadRes.data);
|
|
|
+ console.log('后台上传响应:', res);
|
|
|
+ if (res.code === 2000) {
|
|
|
+ // 获取上传后的视频URL
|
|
|
+ const videoUrl = res.data.permanent_link || res.data.url || '';
|
|
|
+ if (videoUrl) {
|
|
|
+ // 上传成功,更新状态
|
|
|
+ this.uploadStatus[task.id] = 'success';
|
|
|
+ this.updateUploadStatusText();
|
|
|
+
|
|
|
+ // 提交到面试接口
|
|
|
+ this.submitVideoToInterviewBackground(videoUrl, task);
|
|
|
+ } else {
|
|
|
+ this.handleBackgroundUploadFailure(task, '视频URL获取失败');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.handleBackgroundUploadFailure(task, res.msg || '上传失败');
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ this.handleBackgroundUploadFailure(task, '解析响应失败');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ this.handleBackgroundUploadFailure(task, err.errMsg || '上传失败');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 监听上传进度
|
|
|
+ uploadTask.onProgressUpdate((res) => {
|
|
|
+ this.uploadProgress[task.id] = res.progress;
|
|
|
+ this.updateUploadStatusText();
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 添加新方法:处理后台上传失败
|
|
|
+ handleBackgroundUploadFailure(task, errorMsg) {
|
|
|
+ console.error('后台上传失败:', errorMsg);
|
|
|
+
|
|
|
+ // 更新任务状态
|
|
|
+ this.uploadStatus[task.id] = 'failed';
|
|
|
+ this.updateUploadStatusText();
|
|
|
+
|
|
|
+ // 检查是否还有重试机会
|
|
|
+ if (task.attempts < task.maxAttempts) {
|
|
|
+ console.log(`将在5秒后重试后台上传,当前尝试次数: ${task.attempts}/${task.maxAttempts}`);
|
|
|
+
|
|
|
+ // 5秒后重试
|
|
|
+ setTimeout(() => {
|
|
|
+ // 重置进度
|
|
|
+ this.uploadProgress[task.id] = 0;
|
|
|
+
|
|
|
+ // 重新开始上传
|
|
|
+ if (typeof task.file !== 'string') {
|
|
|
+ this.uploadFileWithXHRBackground(task);
|
|
|
} else {
|
|
|
- // 如果还在上传,继续检查
|
|
|
- setTimeout(checkUploadStatus, 100);
|
|
|
+ this.uploadFileWithUniBackground(task);
|
|
|
}
|
|
|
- };
|
|
|
+ }, 5000);
|
|
|
+ } else {
|
|
|
+ // 超过最大重试次数,移除任务
|
|
|
+ console.log('超过最大重试次数,放弃后台上传');
|
|
|
|
|
|
- // 如果当前没有上传任务在进行,开始处理队列
|
|
|
- if (!this.isUploading) {
|
|
|
- this.processUploadQueue();
|
|
|
+ // 从后台上传队列中移除当前任务
|
|
|
+ if (this.backgroundUploadQueue) {
|
|
|
+ const taskIndex = this.backgroundUploadQueue.findIndex(t => t.id === task.id);
|
|
|
+ if (taskIndex !== -1) {
|
|
|
+ this.backgroundUploadQueue.splice(taskIndex, 1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- // 开始检查上传状态
|
|
|
- checkUploadStatus();
|
|
|
+ // 继续处理队列中的下一个任务
|
|
|
+ this.processBackgroundUploadQueue();
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 添加新方法:后台上传提交到面试接口
|
|
|
+ submitVideoToInterviewBackground(videoUrl, task) {
|
|
|
+ // 准备请求参数
|
|
|
+ const followUpRequestData = {
|
|
|
+ application_id: uni.getStorageSync('appId'),
|
|
|
+ tenant_id: JSON.parse(uni.getStorageSync('userInfo')).tenant_id || '1',
|
|
|
+ video_url: videoUrl,
|
|
|
+ original_question_id: this.parentJobPositionQuestionId, // 使用保存的job_position_question_id
|
|
|
+ follow_up_question: task.questionText,
|
|
|
+ video_duration: task.videoDuration,
|
|
|
+ openid: JSON.parse(uni.getStorageSync('userInfo')).openid || ''
|
|
|
+ };
|
|
|
+
|
|
|
+ console.log('后台上传提交追问视频:', followUpRequestData);
|
|
|
+
|
|
|
+ uni.request({
|
|
|
+ url: `${apiBaseUrl}/voice_interview/upload_follow_up_video/`,
|
|
|
+ method: 'POST',
|
|
|
+ data: followUpRequestData,
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ if (res.data.code === 200 || res.data.code === 2000) {
|
|
|
+ console.log('后台上传追问视频提交成功');
|
|
|
+
|
|
|
+ // 从后台上传队列中移除任务
|
|
|
+ if (this.backgroundUploadQueue) {
|
|
|
+ const taskIndex = this.backgroundUploadQueue.findIndex(t => t.id === task.id);
|
|
|
+ if (taskIndex !== -1) {
|
|
|
+ this.backgroundUploadQueue.splice(taskIndex, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 继续处理下一个后台上传任务
|
|
|
+ this.processBackgroundUploadQueue();
|
|
|
+ } else {
|
|
|
+ this.handleBackgroundSubmitFailure(task, '提交失败: ' + (res.data.msg || '未知错误'));
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ console.error('后台上传提交失败:', err);
|
|
|
+ this.handleBackgroundSubmitFailure(task, '提交失败: ' + err.errMsg);
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ // 添加新方法:处理后台上传提交失败
|
|
|
+ handleBackgroundSubmitFailure(task, errorMsg) {
|
|
|
+ console.error('后台上传提交失败:', errorMsg);
|
|
|
+
|
|
|
+ // 检查是否还有重试机会
|
|
|
+ if (task.attempts < task.maxAttempts) {
|
|
|
+ console.log(`将在5秒后重试后台上传提交,当前尝试次数: ${task.attempts}/${task.maxAttempts}`);
|
|
|
+
|
|
|
+ // 5秒后重试
|
|
|
+ setTimeout(() => {
|
|
|
+ this.submitVideoToInterviewBackground(task.videoUrl, task);
|
|
|
+ }, 5000);
|
|
|
+ } else {
|
|
|
+ // 超过最大重试次数,移除任务
|
|
|
+ console.log('超过最大重试次数,放弃后台上传提交');
|
|
|
+
|
|
|
+ // 从后台上传队列中移除当前任务
|
|
|
+ if (this.backgroundUploadQueue) {
|
|
|
+ const taskIndex = this.backgroundUploadQueue.findIndex(t => t.id === task.id);
|
|
|
+ if (taskIndex !== -1) {
|
|
|
+ this.backgroundUploadQueue.splice(taskIndex, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 继续处理队列中的下一个任务
|
|
|
+ this.processBackgroundUploadQueue();
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
// 添加新方法:处理上传后的逻辑
|
|
|
handlePostUploadActions(task) {
|
|
|
// 隐藏思考中loading
|
|
@@ -2744,42 +3063,87 @@ export default {
|
|
|
|
|
|
// 添加新方法:更新上传状态文本
|
|
|
updateUploadStatusText() {
|
|
|
- if (this.uploadQueue.length === 0) {
|
|
|
- this.uploadStatusText = '';
|
|
|
- return;
|
|
|
+ // 检查主上传队列
|
|
|
+ let mainQueueText = '';
|
|
|
+ if (this.uploadQueue.length > 0) {
|
|
|
+ const currentTask = this.uploadQueue[0];
|
|
|
+ const progress = this.uploadProgress[currentTask.id] || 0;
|
|
|
+ const status = this.uploadStatus[currentTask.id] || 'pending';
|
|
|
+
|
|
|
+ let statusText = '';
|
|
|
+ switch (status) {
|
|
|
+ case 'pending':
|
|
|
+ statusText = '等待上传';
|
|
|
+ break;
|
|
|
+ case 'uploading':
|
|
|
+ statusText = `上传中 ${progress}%`;
|
|
|
+ break;
|
|
|
+ case 'success':
|
|
|
+ statusText = '上传成功,提交中...';
|
|
|
+ break;
|
|
|
+ case 'failed':
|
|
|
+ statusText = `上传失败,${currentTask.attempts < currentTask.maxAttempts ? '即将重试' : '已放弃'}`;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加问题类型和文本的中文释义
|
|
|
+ const questionTypeText = currentTask.isFollowUp ? '追问' : '问题';
|
|
|
+ const questionShortText = currentTask.questionText ?
|
|
|
+ (currentTask.questionText.length > 10 ? currentTask.questionText.substring(0, 10) + '...' : currentTask.questionText) :
|
|
|
+ `${questionTypeText}${currentTask.questionId}`;
|
|
|
+
|
|
|
+ mainQueueText = `${questionTypeText}「${questionShortText}」:${statusText}`;
|
|
|
+
|
|
|
+ // 如果队列中有多个任务,显示总数
|
|
|
+ if (this.uploadQueue.length > 1) {
|
|
|
+ mainQueueText += ` (${this.uploadQueue.length}个视频待处理)`;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- const currentTask = this.uploadQueue[0];
|
|
|
- const progress = this.uploadProgress[currentTask.id] || 0;
|
|
|
- const status = this.uploadStatus[currentTask.id] || 'pending';
|
|
|
-
|
|
|
- let statusText = '';
|
|
|
- switch (status) {
|
|
|
- case 'pending':
|
|
|
- statusText = '等待上传';
|
|
|
- break;
|
|
|
- case 'uploading':
|
|
|
- statusText = `上传中 ${progress}%`;
|
|
|
- break;
|
|
|
- case 'success':
|
|
|
- statusText = '上传成功,提交中...';
|
|
|
- break;
|
|
|
- case 'failed':
|
|
|
- statusText = `上传失败,${currentTask.attempts < currentTask.maxAttempts ? '即将重试' : '已放弃'}`;
|
|
|
- break;
|
|
|
+ // 检查后台上传队列
|
|
|
+ let backgroundQueueText = '';
|
|
|
+ if (this.backgroundUploadQueue && this.backgroundUploadQueue.length > 0) {
|
|
|
+ const currentTask = this.backgroundUploadQueue[0];
|
|
|
+ const progress = this.uploadProgress[currentTask.id] || 0;
|
|
|
+ const status = this.uploadStatus[currentTask.id] || 'pending';
|
|
|
+
|
|
|
+ let statusText = '';
|
|
|
+ switch (status) {
|
|
|
+ case 'pending':
|
|
|
+ statusText = '等待后台上传';
|
|
|
+ break;
|
|
|
+ case 'uploading':
|
|
|
+ statusText = `后台上传中 ${progress}%`;
|
|
|
+ break;
|
|
|
+ case 'success':
|
|
|
+ statusText = '后台上传成功,提交中...';
|
|
|
+ break;
|
|
|
+ case 'failed':
|
|
|
+ statusText = `后台上传失败,${currentTask.attempts < currentTask.maxAttempts ? '即将重试' : '已放弃'}`;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ const questionShortText = currentTask.questionText ?
|
|
|
+ (currentTask.questionText.length > 10 ? currentTask.questionText.substring(0, 10) + '...' : currentTask.questionText) :
|
|
|
+ `追问${currentTask.questionId}`;
|
|
|
+
|
|
|
+ backgroundQueueText = `追问「${questionShortText}」:${statusText}`;
|
|
|
+
|
|
|
+ // 如果后台上传队列中有多个任务,显示总数
|
|
|
+ if (this.backgroundUploadQueue.length > 1) {
|
|
|
+ backgroundQueueText += ` (${this.backgroundUploadQueue.length}个追问待后台上传)`;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- // 添加问题类型和文本的中文释义
|
|
|
- const questionTypeText = currentTask.isFollowUp ? '追问' : '问题';
|
|
|
- const questionShortText = currentTask.questionText ?
|
|
|
- (currentTask.questionText.length > 10 ? currentTask.questionText.substring(0, 10) + '...' : currentTask.questionText) :
|
|
|
- `${questionTypeText}${currentTask.questionId}`;
|
|
|
-
|
|
|
- this.uploadStatusText = `${questionTypeText}「${questionShortText}」:${statusText}`;
|
|
|
-
|
|
|
- // 如果队列中有多个任务,显示总数
|
|
|
- if (this.uploadQueue.length > 1) {
|
|
|
- this.uploadStatusText += ` (${this.uploadQueue.length}个视频待处理)`;
|
|
|
+ // 合并状态文本
|
|
|
+ if (mainQueueText && backgroundQueueText) {
|
|
|
+ this.uploadStatusText = `${mainQueueText} | ${backgroundQueueText}`;
|
|
|
+ } else if (mainQueueText) {
|
|
|
+ this.uploadStatusText = mainQueueText;
|
|
|
+ } else if (backgroundQueueText) {
|
|
|
+ this.uploadStatusText = backgroundQueueText;
|
|
|
+ } else {
|
|
|
+ this.uploadStatusText = '';
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -2912,7 +3276,7 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- }, 200);
|
|
|
+ }, 0);
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -3053,7 +3417,7 @@ export default {
|
|
|
currentSubtitles = this[subtitleKey] || [{
|
|
|
startTime: 0,
|
|
|
endTime: 30,
|
|
|
- text: this.currentFollowUpQuestion.digital_human_video_subtitle ||
|
|
|
+ text: this.currentFollowUpQuestion.question ||
|
|
|
this.currentFollowUpQuestion.question
|
|
|
}];
|
|
|
} else {
|
|
@@ -3581,7 +3945,7 @@ export default {
|
|
|
const subtitleArray = [{
|
|
|
startTime: 0,
|
|
|
endTime: 30, // 延长字幕显示时间到30秒
|
|
|
- text: question.digital_human_video_subtitle || question.question
|
|
|
+ text: question.question || question.question
|
|
|
}];
|
|
|
|
|
|
const videoIndex = this.videoList.length - 1;
|
|
@@ -3747,6 +4111,21 @@ export default {
|
|
|
return null;
|
|
|
},
|
|
|
|
|
|
+ // 添加新方法:获取当前问题的推荐录制时长
|
|
|
+ getCurrentQuestionRecommendedDuration() {
|
|
|
+ const currentQuestion = this.getCurrentQuestionByIndex(this.currentVideoIndex);
|
|
|
+ if (currentQuestion && currentQuestion.recommended_duration) {
|
|
|
+ // 如果问题有推荐时长,使用推荐时长(转换为秒)
|
|
|
+ const recommendedDuration = parseInt(currentQuestion.recommended_duration);
|
|
|
+ console.log(`使用问题推荐时长: ${recommendedDuration}秒`);
|
|
|
+ return recommendedDuration;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果没有推荐时长,使用默认值300秒(5分钟)
|
|
|
+ console.log('使用默认录制时长: 300秒');
|
|
|
+ return 300;
|
|
|
+ },
|
|
|
+
|
|
|
|
|
|
|
|
|
// 添加新方法:重置录制状态,准备重新回答
|
|
@@ -3772,6 +4151,9 @@ export default {
|
|
|
// 重置录制时间显示
|
|
|
this.recordingTimerCount = 0;
|
|
|
this.recordingTimeDisplay = '00:00 ';/* / 05:00 */
|
|
|
+
|
|
|
+ // 重新获取当前问题的推荐录制时长
|
|
|
+ this.maxRecordingTime = this.getCurrentQuestionRecommendedDuration();
|
|
|
this.remainingTime = this.maxRecordingTime;
|
|
|
|
|
|
// 如果是浏览器环境,停止MediaRecorder
|
|
@@ -3831,7 +4213,7 @@ export default {
|
|
|
// 获取下一题的字幕
|
|
|
const nextQuestion = this.getCurrentQuestionByIndex(this.currentVideoIndex);
|
|
|
if (nextQuestion) {
|
|
|
- this.currentSubtitle = nextQuestion.digital_human_video_subtitle || nextQuestion.question;
|
|
|
+ this.currentSubtitle = nextQuestion.question || nextQuestion.question;
|
|
|
}
|
|
|
// 播放下一题的视频
|
|
|
this.videoUrl = this.videoList[this.currentVideoIndex];
|
|
@@ -3863,7 +4245,7 @@ export default {
|
|
|
|
|
|
// 保存当前问题的字幕
|
|
|
const currentQuestion = this.getCurrentQuestionByIndex(this.currentVideoIndex);
|
|
|
- const originalSubtitle = currentQuestion ? (currentQuestion.digital_human_video_subtitle || currentQuestion.question) : this.currentSubtitle;
|
|
|
+ const originalSubtitle = currentQuestion ? (currentQuestion.question || currentQuestion.question) : this.currentSubtitle;
|
|
|
|
|
|
// 清除现有字幕
|
|
|
this.currentSubtitle = '';
|
|
@@ -4168,7 +4550,7 @@ export default {
|
|
|
const followUpSubtitles = [{
|
|
|
startTime: 0,
|
|
|
endTime: 60, // 延长显示时间到60秒
|
|
|
- text: followUpQuestion.digital_human_video_subtitle || followUpQuestion.question
|
|
|
+ text: followUpQuestion.question || followUpQuestion.question
|
|
|
}];
|
|
|
|
|
|
const subtitleKey = `followUpSubtitles_${followUpQuestion.id}`;
|