|
|
@@ -174,16 +174,7 @@ export default {
|
|
|
this.onStartRecordWithMicrosoft();
|
|
|
},
|
|
|
toggleRecording() {
|
|
|
- navigator.permissions && navigator.permissions.query({ name: 'microphone' }).then(permissionStatus => {
|
|
|
- if (permissionStatus.state !== "granted") {
|
|
|
- // 没有开启录音权限,直接确定停止录音
|
|
|
- this.recordedForm.status = "0";
|
|
|
- let iframe = this.$refs["iiframe"];
|
|
|
- iframe.contentWindow.onSessionStopped = null;
|
|
|
- iframe.contentWindow.window.onRecognizedResult = null;
|
|
|
- this.$message.success(this.lang.ssNoPermStop);
|
|
|
- return;
|
|
|
- }
|
|
|
+
|
|
|
if (this.recordedForm.status == 1) {
|
|
|
// 检查录音时间是否至少为5秒
|
|
|
const now = new Date();
|
|
|
@@ -218,7 +209,7 @@ export default {
|
|
|
}
|
|
|
this.onStartRecordWithMicrosoft();
|
|
|
}
|
|
|
- })
|
|
|
+ // })
|
|
|
},
|
|
|
// ============ start 微软录音转译
|
|
|
onStartRecordWithMicrosoft() {
|
|
|
@@ -283,36 +274,32 @@ export default {
|
|
|
};
|
|
|
|
|
|
iiframe.contentWindow.ConversationTranscriber();
|
|
|
- // 优化录音权限检测和处理流程,防止多次触发和潜在异常
|
|
|
- setTimeout(async () => {
|
|
|
- try {
|
|
|
- if (navigator.permissions) {
|
|
|
- const permissionStatus = await navigator.permissions.query({ name: 'microphone' });
|
|
|
- if (permissionStatus.state !== "granted") {
|
|
|
- // 没有开启录音权限,直接确定停止录音
|
|
|
- this.recordedForm.status = "0";
|
|
|
- const iframe = this.$refs["iiframe"];
|
|
|
- if (iframe && iframe.contentWindow) {
|
|
|
- if (typeof iframe.contentWindow.onSessionStopped !== "undefined") {
|
|
|
- iframe.contentWindow.onSessionStopped = null;
|
|
|
- }
|
|
|
- if (iframe.contentWindow.window && typeof iframe.contentWindow.window.onRecognizedResult !== "undefined") {
|
|
|
- iframe.contentWindow.window.onRecognizedResult = null;
|
|
|
- }
|
|
|
- }
|
|
|
- if (this.$message && this.lang && this.lang.ssNoPermStop) {
|
|
|
- this.$message.success(this.lang.ssNoPermStop);
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('麦克风权限检测异常:', error);
|
|
|
+ setTimeout(()=>{
|
|
|
+ navigator.permissions && navigator.permissions.query({ name: 'microphone' }).then(permissionStatus => {
|
|
|
+ if (permissionStatus.state !== "granted") {
|
|
|
+ // 没有开启录音权限,直接确定停止录音
|
|
|
+ this.recordedForm.status = "0";
|
|
|
+ let iframe = this.$refs["iiframe"];
|
|
|
+ iframe.contentWindow.onSessionStopped = null;
|
|
|
+ iframe.contentWindow.window.onRecognizedResult = null;
|
|
|
+ this.$message.success(this.lang.ssNoPermStop);
|
|
|
+ return;
|
|
|
}
|
|
|
- }, 10000);
|
|
|
+ })
|
|
|
+ },10000)
|
|
|
|
|
|
},
|
|
|
async onFinishRecordWithMicrosoft() {
|
|
|
+ navigator.permissions && navigator.permissions.query({ name: 'microphone' }).then(async permissionStatus => {
|
|
|
+ if (permissionStatus.state !== "granted") {
|
|
|
+ // 没有开启录音权限,直接确定停止录音
|
|
|
+ this.recordedForm.status = "0";
|
|
|
+ let iframe = this.$refs["iiframe"];
|
|
|
+ iframe.contentWindow.onSessionStopped = null;
|
|
|
+ iframe.contentWindow.window.onRecognizedResult = null;
|
|
|
+ this.$message.success(this.lang.ssNoPermStop);
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (this.recordedForm.status == 1) {
|
|
|
//正在录音时
|
|
|
let iiframe = this.$refs["iiframe"];
|
|
|
@@ -366,6 +353,7 @@ export default {
|
|
|
// 调用 addPPTClass 接口
|
|
|
this.addPPTClass(file);
|
|
|
}
|
|
|
+ })
|
|
|
},
|
|
|
storeRecordingData(file) {
|
|
|
// 配置全局 window 对象存储录音数据
|