fix:延迟iframe卸载

This commit is contained in:
zxj
2025-12-12 15:18:43 +08:00
parent 649a0ea0b9
commit 77b5af0f47

View File

@@ -165,10 +165,12 @@
<div v-if="resType == 41">
<div style="padding: 20px" v-html="contentData.content"></div>
</div>
<div v-if="resType == 50" style="min-height: 500px">
<div
v-if="resType == 50 || isLoadIframe"
style="min-height: 500px"
>
<iframe
id="iframeId"
v-if="scormUrl"
v-if="scormUrl || isLoadIframe"
:src="scormUrl"
frameborder="0"
border="0px"
@@ -946,7 +948,7 @@ export default {
warnTitle: "测试标题",
isFinishingStudyItem: false, // 防止重复调用完成状态更新接口
// // 全局状态:是否正在等待接口完成
// isWaitingForApis: false,
isLoadIframe: false,
// // 待执行的切换操作(存储点击的目标课程)
// pendingSwitchAction: null,
};
@@ -963,8 +965,6 @@ export default {
this.stopStudyTime(); //先关闭
this.cleanAppendTime(); //
this.loadData();
// // 监听iframe接口
// this.checkAllApisCompleted();
},
computed: {
...mapGetters(["userInfo"]),
@@ -1003,61 +1003,6 @@ export default {
},
},
methods: {
// 延迟执行课程切换操作
// delaySwitchCourse() {
// if (!pendingSwitchAction) return;
// // 轮询检查接口是否完成
// const pollTimer = setInterval(() => {
// const allApisDone = checkAllApisCompleted();
// if (allApisDone) {
// clearInterval(pollTimer);
// clearTimeout(timeoutTimer);
// isWaitingForApis = false;
// // 执行真正的课程切换
// executeCourseSwitch(pendingSwitchAction);
// pendingSwitchAction = null;
// }
// }, CONFIG.pollInterval);
// // 超时兜底:超过最大等待时间强制切换
// const timeoutTimer = setTimeout(() => {
// clearInterval(pollTimer);
// isWaitingForApis = false;
// console.warn("接口请求超时,强制切换课程");
// executeCourseSwitch(pendingSwitchAction);
// pendingSwitchAction = null;
// }, CONFIG.maxWaitTime);
// },
// checkAllApisCompleted() {
// const CONFIG = {
// // 需要等待完成的两个接口(支持模糊匹配)
// targetApis: ["/finish", "/update"],
// // iframe 元素ID
// iframeId: "iframeID",
// // 课程切换触发的元素选择器(比如课程列表的点击项)
// courseItemSelector: ".units-info",
// // 最大等待时间(防止接口卡住,单位:毫秒)
// maxWaitTime: 10000,
// // 轮询检查接口的间隔
// pollInterval: 200,
// };
// // 获取所有网络请求的性能数据
// const performanceEntries = performance.getEntriesByType("resource");
// // 筛选已完成的目标接口需同时满足URL匹配 + 有数据传输/完成)
// const completedApis = CONFIG.targetApis.filter((api) => {
// const entry = performanceEntries.find(
// (item) =>
// item.name.includes(api) &&
// item.transferSize > 0 && // 确保请求有数据传输(完成)
// item.responseEnd > 0 // 确认响应已结束
// );
// return !!entry;
// });
// // 两个接口都完成时返回true
// return completedApis.length === CONFIG.targetApis.length;
// },
handleOpen(key, path) {
if (this.isFalse) {
this.defaultOpeneds = [key];
@@ -1202,6 +1147,13 @@ export default {
this.$refs.mynote.showVideoTimeBtn(false);
let $this = this;
this.resType = r.contentType;
if (this.resType == 50) {
this.isLoadIframe = true;
} else {
setTimeout(() => {
this.isLoadIframe = false;
}, 10000);
}
this.contentData = r;
this.activeId = this.contentData.id;
if (item) {
@@ -1438,9 +1390,7 @@ export default {
}
}
}
setTimeout(() => {
this.changePlayRes(r, item);
}, 10000);
this.changePlayRes(r, item);
},
loadScorePraiseAndTrample() {
//加载是否请过分