学习课程记录
This commit is contained in:
@@ -98,10 +98,10 @@
|
||||
|
||||
<!-- 文章资源 -->
|
||||
<div v-if="currentNode.nodeType === 0 && articleData" class="article-content">
|
||||
<ArticleShowView
|
||||
<ArticleShow
|
||||
:as-dialog="false"
|
||||
:article-data="articleData"
|
||||
:category-list="[]"
|
||||
:article-data="articleData"
|
||||
:show-back-button="false"
|
||||
@videos-completed="handleArticleVideosCompleted"
|
||||
/>
|
||||
</div>
|
||||
@@ -195,7 +195,7 @@ import {
|
||||
Download,
|
||||
InfoFilled
|
||||
} from '@element-plus/icons-vue';
|
||||
import { ArticleShowView } from '@/views/public/article';
|
||||
import { ArticleShow } from '@/views/public/article';
|
||||
import { courseApi } from '@/apis/study';
|
||||
import { learningRecordApi, learningHistoryApi } from '@/apis/study';
|
||||
import { resourceApi } from '@/apis/resource';
|
||||
@@ -516,6 +516,12 @@ async function loadNodeContent() {
|
||||
if (!activeChapters.value.includes(currentChapterIndex.value)) {
|
||||
activeChapters.value.push(currentChapterIndex.value);
|
||||
}
|
||||
|
||||
// 等待DOM更新后,检查是否需要自动标记完成(针对内容太短没有滚动条的情况)
|
||||
await nextTick();
|
||||
setTimeout(() => {
|
||||
checkAutoComplete();
|
||||
}, 500); // 延迟500ms,等待ArticleShow初始化完成
|
||||
}
|
||||
|
||||
// 选择节点
|
||||
@@ -706,6 +712,48 @@ function hasScrollbar(): boolean {
|
||||
return contentAreaRef.value.scrollHeight > contentAreaRef.value.clientHeight;
|
||||
}
|
||||
|
||||
// 检查是否需要自动标记完成(针对内容太短没有滚动条的情况)
|
||||
async function checkAutoComplete() {
|
||||
// 如果当前节点已完成,跳过
|
||||
if (isCurrentNodeCompleted.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!currentNode.value) return;
|
||||
|
||||
// 对富文本类型(nodeType === 1)立即检查
|
||||
if (currentNode.value.nodeType === 1) {
|
||||
if (!hasScrollbar()) {
|
||||
console.log('📄 富文本内容较短无需滚动,自动标记为完成');
|
||||
const nodeKey = `${currentChapterIndex.value}-${currentNodeIndex.value}`;
|
||||
await markNodeComplete(nodeKey);
|
||||
}
|
||||
}
|
||||
|
||||
// 对文章类型(nodeType === 0),延迟检查(等待ArticleShow初始化视频监听器)
|
||||
// 如果文章有视频,会在视频播放完成时emit事件,不会走到这里
|
||||
// 如果文章没有视频且没有滚动条,需要自动标记完成
|
||||
if (currentNode.value.nodeType === 0) {
|
||||
// 保存当前节点信息,避免延迟后节点已改变
|
||||
const chapterIdx = currentChapterIndex.value;
|
||||
const nodeIdx = currentNodeIndex.value;
|
||||
const nodeKey = `${chapterIdx}-${nodeIdx}`;
|
||||
|
||||
// 延迟1秒再检查,给ArticleShow足够时间初始化
|
||||
setTimeout(async () => {
|
||||
// 再次检查是否已完成(可能已通过视频完成事件标记)
|
||||
// 且确认当前还在同一个节点
|
||||
if (!completedNodes.value.has(nodeKey) &&
|
||||
currentChapterIndex.value === chapterIdx &&
|
||||
currentNodeIndex.value === nodeIdx &&
|
||||
!hasScrollbar()) {
|
||||
console.log('📄 文章内容较短无需滚动且无视频,自动标记为完成');
|
||||
await markNodeComplete(nodeKey);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理内容区域滚动
|
||||
function handleContentScroll(event: Event) {
|
||||
const target = event.target as HTMLElement;
|
||||
|
||||
Reference in New Issue
Block a user