|
|
@@ -365,21 +365,21 @@ export default {
|
|
|
window.recordingData.text = this.transcriptionData.content;
|
|
|
window.recordingData.textList = this.recordedForm.textList;
|
|
|
// 将录音文件转为base64并存入localStorage
|
|
|
- const reader = new FileReader();
|
|
|
- reader.onload = function(e) {
|
|
|
- const base64data = e.target.result;
|
|
|
- try {
|
|
|
- localStorage.setItem("recordedFileBase64", base64data);
|
|
|
- localStorage.setItem('recordedFileName', file.name);
|
|
|
- localStorage.setItem('recordedFileType', file.type);
|
|
|
- resolve(true)
|
|
|
- console.log("录音数据已存储到全局对象:", window.recordingData);
|
|
|
- } catch (err) {
|
|
|
- resolve(false)
|
|
|
- console.error("localStorage存储base64文件失败:", err);
|
|
|
- }
|
|
|
- };
|
|
|
- reader.readAsDataURL(file);
|
|
|
+ // const reader = new FileReader();
|
|
|
+ // reader.onload = function(e) {
|
|
|
+ // const base64data = e.target.result;
|
|
|
+ // try {
|
|
|
+ // localStorage.setItem("recordedFileBase64", base64data);
|
|
|
+ // localStorage.setItem('recordedFileName', file.name);
|
|
|
+ // localStorage.setItem('recordedFileType', file.type);
|
|
|
+ // resolve(true)
|
|
|
+ // console.log("录音数据已存储到全局对象:", window.recordingData);
|
|
|
+ // } catch (err) {
|
|
|
+ // resolve(false)
|
|
|
+ // console.error("localStorage存储base64文件失败:", err);
|
|
|
+ // }
|
|
|
+ // };
|
|
|
+ // reader.readAsDataURL(file);
|
|
|
})
|
|
|
},
|
|
|
openObserveDialog(pptid,file) {
|
|
|
@@ -388,45 +388,43 @@ export default {
|
|
|
|
|
|
const url = `https://observe.cocorobo.cn/#/newClassroom?userid=${this.userid}&oid=${this.oid}&org=${this.org}&pptid=${pptid}`;
|
|
|
const _pageWindow = window.open(url, '_blank');
|
|
|
- // 优化:等待新窗口加载完成后再传递消息,避免部分浏览器下页面未初始化无法接收消息的问题
|
|
|
+
|
|
|
+ // 优化:仅通过轮询方式检查窗口是否加载完成并发送消息,被打开页面无需做任何处理
|
|
|
const sendFileData = () => {
|
|
|
- if (!_pageWindow) {
|
|
|
- console.error("新窗口未成功打开!");
|
|
|
- return;
|
|
|
+ if (_pageWindow && !_pageWindow.closed) {
|
|
|
+ _pageWindow.postMessage(
|
|
|
+ {
|
|
|
+ type: 'fileData',
|
|
|
+ file,
|
|
|
+ },
|
|
|
+ '*'
|
|
|
+ );
|
|
|
}
|
|
|
- _pageWindow.postMessage(
|
|
|
- {
|
|
|
- type: 'fileData',
|
|
|
- file,
|
|
|
- },
|
|
|
- '*'
|
|
|
- );
|
|
|
};
|
|
|
|
|
|
- // 轮询检测新窗口加载完成(避免跨域无法onload的情况)
|
|
|
let checkCount = 0;
|
|
|
const checkLoadedInterval = setInterval(() => {
|
|
|
- if (_pageWindow.closed) {
|
|
|
+ if (!_pageWindow || _pageWindow.closed) {
|
|
|
clearInterval(checkLoadedInterval);
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
- // 有的情况下,如果页面已加载会有document.body等属性
|
|
|
if (_pageWindow.document && _pageWindow.document.readyState === 'complete') {
|
|
|
clearInterval(checkLoadedInterval);
|
|
|
sendFileData();
|
|
|
}
|
|
|
} catch (err) {
|
|
|
- // 跨域时会报错,直接尝试发送
|
|
|
+ // 跨域下直接尝试发送
|
|
|
clearInterval(checkLoadedInterval);
|
|
|
sendFileData();
|
|
|
}
|
|
|
- // 最多检测2秒(20次),防止死循环
|
|
|
if (++checkCount > 20) {
|
|
|
+ // 最多检测2秒(20次)
|
|
|
clearInterval(checkLoadedInterval);
|
|
|
sendFileData();
|
|
|
}
|
|
|
}, 100);
|
|
|
+
|
|
|
setTimeout(()=>{
|
|
|
window.focus()
|
|
|
},100)
|