mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-16 14:26:43 +08:00
fix:等待finish接口调用完成
This commit is contained in:
@@ -167,6 +167,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="resType == 50" style="min-height: 500px">
|
<div v-if="resType == 50" style="min-height: 500px">
|
||||||
<iframe
|
<iframe
|
||||||
|
id="iframeId"
|
||||||
v-if="scormUrl"
|
v-if="scormUrl"
|
||||||
:src="scormUrl"
|
:src="scormUrl"
|
||||||
frameborder="0"
|
frameborder="0"
|
||||||
@@ -944,6 +945,10 @@ export default {
|
|||||||
warn: "测试内容",
|
warn: "测试内容",
|
||||||
warnTitle: "测试标题",
|
warnTitle: "测试标题",
|
||||||
isFinishingStudyItem: false, // 防止重复调用完成状态更新接口
|
isFinishingStudyItem: false, // 防止重复调用完成状态更新接口
|
||||||
|
// // 全局状态:是否正在等待接口完成
|
||||||
|
// isWaitingForApis: false,
|
||||||
|
// // 待执行的切换操作(存储点击的目标课程)
|
||||||
|
// pendingSwitchAction: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -958,6 +963,8 @@ export default {
|
|||||||
this.stopStudyTime(); //先关闭
|
this.stopStudyTime(); //先关闭
|
||||||
this.cleanAppendTime(); //
|
this.cleanAppendTime(); //
|
||||||
this.loadData();
|
this.loadData();
|
||||||
|
// // 监听iframe接口
|
||||||
|
// this.checkAllApisCompleted();
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(["userInfo"]),
|
...mapGetters(["userInfo"]),
|
||||||
@@ -996,6 +1003,61 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
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) {
|
handleOpen(key, path) {
|
||||||
if (this.isFalse) {
|
if (this.isFalse) {
|
||||||
this.defaultOpeneds = [key];
|
this.defaultOpeneds = [key];
|
||||||
@@ -1326,6 +1388,8 @@ export default {
|
|||||||
this.contentData.status = 2;
|
this.contentData.status = 2;
|
||||||
},
|
},
|
||||||
showRes(r, i, index, item) {
|
showRes(r, i, index, item) {
|
||||||
|
console.log("showRes");
|
||||||
|
|
||||||
//i:子节下标,index:章下标
|
//i:子节下标,index:章下标
|
||||||
// 无权限查看不能点击
|
// 无权限查看不能点击
|
||||||
if (!this.isCrowd) {
|
if (!this.isCrowd) {
|
||||||
@@ -1374,7 +1438,9 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setTimeout(() => {
|
||||||
this.changePlayRes(r, item);
|
this.changePlayRes(r, item);
|
||||||
|
}, 10000);
|
||||||
},
|
},
|
||||||
loadScorePraiseAndTrample() {
|
loadScorePraiseAndTrample() {
|
||||||
//加载是否请过分
|
//加载是否请过分
|
||||||
|
|||||||
Reference in New Issue
Block a user