web-学习
This commit is contained in:
@@ -17,7 +17,7 @@ export const learningRecordApi = {
|
|||||||
* @returns Promise<ResultDomain<LearningRecord>>
|
* @returns Promise<ResultDomain<LearningRecord>>
|
||||||
*/
|
*/
|
||||||
async getRecordList(filter?: Partial<LearningRecord>): Promise<ResultDomain<LearningRecord>> {
|
async getRecordList(filter?: Partial<LearningRecord>): Promise<ResultDomain<LearningRecord>> {
|
||||||
const response = await api.get<LearningRecord>('/study/learning-record/list', filter);
|
const response = await api.post<LearningRecord>('/study/records/list', filter);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -27,45 +27,51 @@ export const learningRecordApi = {
|
|||||||
* @returns Promise<ResultDomain<LearningRecord>>
|
* @returns Promise<ResultDomain<LearningRecord>>
|
||||||
*/
|
*/
|
||||||
async createRecord(record: LearningRecord): Promise<ResultDomain<LearningRecord>> {
|
async createRecord(record: LearningRecord): Promise<ResultDomain<LearningRecord>> {
|
||||||
const response = await api.post<LearningRecord>('/study/learning-record/create', record);
|
const response = await api.post<LearningRecord>('/study/records/record', record);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新学习记录
|
* 更新学习记录(禁用 loading 动画,避免影响视频播放)
|
||||||
* @param record 记录数据
|
* @param record 记录数据
|
||||||
* @returns Promise<ResultDomain<LearningRecord>>
|
* @returns Promise<ResultDomain<LearningRecord>>
|
||||||
*/
|
*/
|
||||||
async updateRecord(record: LearningRecord): Promise<ResultDomain<LearningRecord>> {
|
async updateRecord(record: Partial<LearningRecord>): Promise<ResultDomain<LearningRecord>> {
|
||||||
const response = await api.put<LearningRecord>('/study/learning-record/update', record);
|
const response = await api.put<LearningRecord>('/study/records/record', record, {
|
||||||
|
showLoading: false // 禁用 loading 动画
|
||||||
|
} as any);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户学习统计
|
* 删除学习记录
|
||||||
* @param userID 用户ID
|
* @param recordId 记录ID
|
||||||
* @param timeRange 时间范围
|
* @returns Promise<ResultDomain<boolean>>
|
||||||
* @returns Promise<ResultDomain<LearningRecordStatistics>>
|
|
||||||
*/
|
*/
|
||||||
async getUserLearningStatistics(userID: string, timeRange?: string): Promise<ResultDomain<LearningRecordStatistics>> {
|
async deleteRecord(recordId: string): Promise<ResultDomain<boolean>> {
|
||||||
const response = await api.get<LearningRecordStatistics>('/study/learning-record/statistics', {
|
const response = await api.delete<boolean>('/study/records/record', { ID: recordId });
|
||||||
userID,
|
|
||||||
timeRange
|
|
||||||
});
|
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取学习时长图表数据
|
* 标记学习完成(禁用 loading 动画,避免影响视频播放)
|
||||||
* @param userID 用户ID
|
* @param record 记录数据
|
||||||
* @param timeRange 时间范围
|
* @returns Promise<ResultDomain<LearningRecord>>
|
||||||
* @returns Promise<ResultDomain<LearningRecordStatistics>>
|
|
||||||
*/
|
*/
|
||||||
async getLearningDurationChart(userID: string, timeRange?: string): Promise<ResultDomain<LearningRecordStatistics>> {
|
async markComplete(record: Partial<LearningRecord>): Promise<ResultDomain<LearningRecord>> {
|
||||||
const response = await api.get<LearningRecordStatistics>('/study/learning-record/duration-chart', {
|
const response = await api.put<LearningRecord>('/study/records/complete', record, {
|
||||||
userID,
|
showLoading: false // 禁用 loading 动画
|
||||||
timeRange
|
} as any);
|
||||||
});
|
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户课程的学习记录
|
||||||
|
* @param filter 过滤条件(包含 userID 和 resourceID)
|
||||||
|
* @returns Promise<ResultDomain<LearningRecord>>
|
||||||
|
*/
|
||||||
|
async getCourseLearningRecord(filter: Partial<LearningRecord>): Promise<ResultDomain<LearningRecord>> {
|
||||||
|
const response = await api.post<LearningRecord>('/study/records/course/records', filter);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,6 +32,16 @@ export const learningTaskApi = {
|
|||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID获取用户任务详情
|
||||||
|
* @param taskID 任务ID
|
||||||
|
* @returns Promise<ResultDomain<TaskVO>>
|
||||||
|
*/
|
||||||
|
async getUserTask(taskID: string): Promise<ResultDomain<TaskVO>> {
|
||||||
|
const response = await api.get<TaskVO>(`${this.learningTaskPrefix}/${taskID}/user`);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取任务分页列表
|
* 获取任务分页列表
|
||||||
* @param pageParam 分页参数
|
* @param pageParam 分页参数
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import type { UserCollection, ResultDomain } from '@/types';
|
|||||||
* 用户收藏API服务
|
* 用户收藏API服务
|
||||||
*/
|
*/
|
||||||
export const userCollectionApi = {
|
export const userCollectionApi = {
|
||||||
|
baseUrl: '/usercenter/collections',
|
||||||
/**
|
/**
|
||||||
* 获取用户收藏列表
|
* 获取用户收藏列表
|
||||||
* @param userID 用户ID
|
* @param userID 用户ID
|
||||||
@@ -18,7 +19,7 @@ export const userCollectionApi = {
|
|||||||
* @returns Promise<ResultDomain<UserCollection>>
|
* @returns Promise<ResultDomain<UserCollection>>
|
||||||
*/
|
*/
|
||||||
async getUserCollections(userID: string, collectionType?: number): Promise<ResultDomain<UserCollection>> {
|
async getUserCollections(userID: string, collectionType?: number): Promise<ResultDomain<UserCollection>> {
|
||||||
const response = await api.get<UserCollection>('/usercenter/collection/list', {
|
const response = await api.get<UserCollection>(`${this.baseUrl}/list`, {
|
||||||
userID,
|
userID,
|
||||||
collectionType
|
collectionType
|
||||||
});
|
});
|
||||||
@@ -31,7 +32,7 @@ export const userCollectionApi = {
|
|||||||
* @returns Promise<ResultDomain<UserCollection>>
|
* @returns Promise<ResultDomain<UserCollection>>
|
||||||
*/
|
*/
|
||||||
async addCollection(collection: UserCollection): Promise<ResultDomain<UserCollection>> {
|
async addCollection(collection: UserCollection): Promise<ResultDomain<UserCollection>> {
|
||||||
const response = await api.post<UserCollection>('/usercenter/collection/add', collection);
|
const response = await api.post<UserCollection>(`${this.baseUrl}/collect`, collection);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ export const userCollectionApi = {
|
|||||||
* @returns Promise<ResultDomain<boolean>>
|
* @returns Promise<ResultDomain<boolean>>
|
||||||
*/
|
*/
|
||||||
async removeCollection(userID: string, collectionType: number, collectionID: string): Promise<ResultDomain<boolean>> {
|
async removeCollection(userID: string, collectionType: number, collectionID: string): Promise<ResultDomain<boolean>> {
|
||||||
const response = await api.delete<boolean>('/usercenter/collection/remove', {
|
const response = await api.delete<boolean>(`${this.baseUrl}/collect`, {
|
||||||
userID,
|
userID,
|
||||||
collectionType,
|
collectionType,
|
||||||
collectionID
|
collectionID
|
||||||
@@ -58,9 +59,8 @@ export const userCollectionApi = {
|
|||||||
* @param collectionID 收藏对象ID
|
* @param collectionID 收藏对象ID
|
||||||
* @returns Promise<ResultDomain<boolean>>
|
* @returns Promise<ResultDomain<boolean>>
|
||||||
*/
|
*/
|
||||||
async isCollected(userID: string, collectionType: number, collectionID: string): Promise<ResultDomain<boolean>> {
|
async isCollected(collectionType: number, collectionID: string): Promise<ResultDomain<boolean>> {
|
||||||
const response = await api.get<boolean>('/usercenter/collection/check', {
|
const response = await api.get<boolean>(`${this.baseUrl}/check`, {
|
||||||
userID,
|
|
||||||
collectionType,
|
collectionType,
|
||||||
collectionID
|
collectionID
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -146,7 +146,6 @@ watch(
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.navigation-layout {
|
.navigation-layout {
|
||||||
min-height: 100vh;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background: #f0f2f5;
|
background: #f0f2f5;
|
||||||
@@ -156,6 +155,8 @@ watch(
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
max-height: calc(100vh - 76px);
|
||||||
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.breadcrumb-wrapper {
|
.breadcrumb-wrapper {
|
||||||
|
|||||||
@@ -122,6 +122,18 @@ export enum CollectionType {
|
|||||||
COURSE = 2
|
COURSE = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章状态枚举
|
||||||
|
*/
|
||||||
|
export enum ArticleStatus {
|
||||||
|
/** 草稿 */
|
||||||
|
DRAFT = 0,
|
||||||
|
/** 已发布 */
|
||||||
|
PUBLISHED = 1,
|
||||||
|
/** 下架 */
|
||||||
|
OFFLINE = 2
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 资源类型枚举
|
* 资源类型枚举
|
||||||
*/
|
*/
|
||||||
@@ -189,4 +201,12 @@ export enum CollectionStatus {
|
|||||||
/** 成功 */
|
/** 成功 */
|
||||||
SUCCESS = 1
|
SUCCESS = 1
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 任务项类型枚举
|
||||||
|
*/
|
||||||
|
export enum TaskItemType {
|
||||||
|
/** 资源类型 */
|
||||||
|
RESOURCE = 1,
|
||||||
|
/** 课程类型 */
|
||||||
|
COURSE = 2
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
* @since 2025-10-15
|
* @since 2025-10-15
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { BaseDTO, SysUser, Resource } from '@/types';
|
import type { BaseDTO } from '@/types';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 课程实体
|
* 课程实体
|
||||||
@@ -149,12 +150,18 @@ export interface LearningTask extends BaseDTO {
|
|||||||
export interface LearningRecord extends BaseDTO {
|
export interface LearningRecord extends BaseDTO {
|
||||||
/** 用户ID */
|
/** 用户ID */
|
||||||
userID?: string;
|
userID?: string;
|
||||||
|
/** 任务ID */
|
||||||
|
taskID?: string;
|
||||||
/** 资源类型(1资源 2课程 3章节) */
|
/** 资源类型(1资源 2课程 3章节) */
|
||||||
resourceType?: number;
|
resourceType?: number;
|
||||||
/** 资源ID */
|
/** 资源ID */
|
||||||
resourceID?: string;
|
resourceID?: string;
|
||||||
/** 任务ID */
|
/** 课程ID */
|
||||||
taskID?: string;
|
courseID?: string;
|
||||||
|
/** 章节ID */
|
||||||
|
chapterID?: string;
|
||||||
|
/** 节点ID */
|
||||||
|
nodeID?: string;
|
||||||
/** 学习时长(秒) */
|
/** 学习时长(秒) */
|
||||||
duration?: number;
|
duration?: number;
|
||||||
/** 学习进度(0-100) */
|
/** 学习进度(0-100) */
|
||||||
@@ -195,58 +202,84 @@ export interface TaskUser extends BaseDTO {
|
|||||||
userID?: string;
|
userID?: string;
|
||||||
/** 完成状态(0未完成 1已完成) */
|
/** 完成状态(0未完成 1已完成) */
|
||||||
status?: number;
|
status?: number;
|
||||||
|
/** 学习进度 */
|
||||||
|
progress?: number;
|
||||||
/** 完成时间 */
|
/** 完成时间 */
|
||||||
completeTime?: string;
|
completeTime?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务资源关联实体
|
* 任务项实体(统一管理资源和课程)
|
||||||
*/
|
*/
|
||||||
export interface TaskResource extends BaseDTO {
|
export interface TaskItem extends BaseDTO {
|
||||||
/** 任务ID */
|
/** 任务ID */
|
||||||
taskID?: string;
|
taskID?: string;
|
||||||
/** 资源ID */
|
/** 项类型(1资源 2课程) */
|
||||||
resourceID?: string;
|
itemType?: number;
|
||||||
/** 资源类型(1资源 2课程) */
|
/** 项ID(资源ID或课程ID) */
|
||||||
resourceType?: number;
|
itemID?: string;
|
||||||
|
/** 是否必须完成 */
|
||||||
|
required?: boolean;
|
||||||
/** 排序号 */
|
/** 排序号 */
|
||||||
orderNum?: number;
|
orderNum?: number;
|
||||||
|
/** 创建者 */
|
||||||
|
creator?: string;
|
||||||
|
/** 更新者 */
|
||||||
|
updater?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TaskItemVO extends LearningTask {
|
|
||||||
courseID?: string;
|
|
||||||
courseName?: string;
|
|
||||||
resourceID?: string;
|
|
||||||
resourceName?: string;
|
|
||||||
userID?: string;
|
|
||||||
username?: string;
|
|
||||||
required?: boolean;
|
|
||||||
orderNum?: number;
|
|
||||||
status?: number;
|
|
||||||
progress?: boolean;
|
|
||||||
completeTime?: string;
|
|
||||||
}
|
|
||||||
export interface TaskVO extends BaseDTO {
|
|
||||||
learningTask: LearningTask;
|
|
||||||
taskCourses: TaskItemVO[];
|
|
||||||
taskResources: TaskItemVO[];
|
|
||||||
taskUsers: TaskItemVO[];
|
|
||||||
totalTaskNum?: number;
|
|
||||||
completedTaskNum?: number;
|
|
||||||
learningTaskNum?: number;
|
|
||||||
notStartTaskNum?: number;
|
|
||||||
taskStatus?: number;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 任务课程关联实体
|
* 任务项视图对象(扩展了任务基本信息)
|
||||||
*/
|
*/
|
||||||
export interface TaskCourse extends BaseDTO {
|
export interface TaskItemVO extends LearningTask {
|
||||||
/** 任务ID */
|
/** 项类型(1资源 2课程) */
|
||||||
taskID?: string;
|
itemType?: number;
|
||||||
/** 课程ID */
|
/** 课程ID */
|
||||||
courseID?: string;
|
courseID?: string;
|
||||||
|
/** 课程名称 */
|
||||||
|
courseName?: string;
|
||||||
|
/** 资源ID */
|
||||||
|
resourceID?: string;
|
||||||
|
/** 资源名称 */
|
||||||
|
resourceName?: string;
|
||||||
|
/** 用户ID */
|
||||||
|
userID?: string;
|
||||||
|
/** 用户名 */
|
||||||
|
username?: string;
|
||||||
|
/** 是否必修 */
|
||||||
|
required?: boolean;
|
||||||
/** 排序号 */
|
/** 排序号 */
|
||||||
orderNum?: number;
|
orderNum?: number;
|
||||||
|
/** 任务状态 */
|
||||||
|
status?: number;
|
||||||
|
/** 学习进度(0-100) */
|
||||||
|
progress?: number;
|
||||||
|
/** 完成时间 */
|
||||||
|
completeTime?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务视图对象(包含任务及关联的课程、资源、用户)
|
||||||
|
*/
|
||||||
|
export interface TaskVO extends BaseDTO {
|
||||||
|
/** 学习任务基本信息 */
|
||||||
|
learningTask: LearningTask;
|
||||||
|
/** 任务关联的课程列表 */
|
||||||
|
taskCourses: TaskItemVO[];
|
||||||
|
/** 任务关联的资源列表 */
|
||||||
|
taskResources: TaskItemVO[];
|
||||||
|
/** 任务关联的用户列表 */
|
||||||
|
taskUsers: TaskItemVO[];
|
||||||
|
/** 总任务数 */
|
||||||
|
totalTaskNum?: number;
|
||||||
|
/** 已完成任务数 */
|
||||||
|
completedTaskNum?: number;
|
||||||
|
/** 学习中任务数 */
|
||||||
|
learningTaskNum?: number;
|
||||||
|
/** 未开始任务数 */
|
||||||
|
notStartTaskNum?: number;
|
||||||
|
/** 任务状态 */
|
||||||
|
taskStatus?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,9 +24,16 @@
|
|||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="200" fixed="right">
|
<el-table-column label="操作" width="250" fixed="right">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-button size="small" @click="viewArticle(row)">查看</el-button>
|
<el-button size="small" @click="viewArticle(row)">查看</el-button>
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
:type="getActionButtonType(row.status)"
|
||||||
|
@click="changeArticleStatus(row)"
|
||||||
|
>
|
||||||
|
{{ getActionButtonText(row.status) }}
|
||||||
|
</el-button>
|
||||||
<el-button size="small" @click="editArticle(row)">编辑</el-button>
|
<el-button size="small" @click="editArticle(row)">编辑</el-button>
|
||||||
<el-button size="small" type="danger" @click="deleteArticle()">删除</el-button>
|
<el-button size="small" type="danger" @click="deleteArticle()">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
@@ -64,6 +71,7 @@ import { useRouter } from 'vue-router';
|
|||||||
import { resourceApi, resourceCategoryApi } from '@/apis/resource'
|
import { resourceApi, resourceCategoryApi } from '@/apis/resource'
|
||||||
import type { PageParam, ResourceSearchParams, Resource, ResourceCategory } from '@/types';
|
import type { PageParam, ResourceSearchParams, Resource, ResourceCategory } from '@/types';
|
||||||
import { ArticleShowView } from '@/views/article';
|
import { ArticleShowView } from '@/views/article';
|
||||||
|
import { ArticleStatus } from '@/types/enums';
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchKeyword = ref('');
|
const searchKeyword = ref('');
|
||||||
@@ -100,7 +108,7 @@ async function loadArticles() {
|
|||||||
const res = await resourceApi.getResourcePage(pageParam.value, filter.value);
|
const res = await resourceApi.getResourcePage(pageParam.value, filter.value);
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
articles.value = res.pageDomain?.dataList || [];
|
articles.value = res.pageDomain?.dataList || [];
|
||||||
total.value = res.pageDomain?.total || 0;
|
total.value = res.pageDomain?.pageParam.totalElements || 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,6 +153,34 @@ function editArticle(row: any) {
|
|||||||
router.push('/article/add?id=' + row.resourceID);
|
router.push('/article/add?id=' + row.resourceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function changeArticleStatus(row: Resource) {
|
||||||
|
try {
|
||||||
|
// status: 0-草稿, 1-已发布, 2-已下架
|
||||||
|
if (row.status === ArticleStatus.DRAFT || row.status === ArticleStatus.OFFLINE) {
|
||||||
|
// 草稿或下架状态 -> 发布
|
||||||
|
const res = await resourceApi.publishResource(row.resourceID!);
|
||||||
|
if (res.success) {
|
||||||
|
ElMessage.success('发布成功');
|
||||||
|
loadArticles();
|
||||||
|
} else {
|
||||||
|
ElMessage.error('发布失败');
|
||||||
|
}
|
||||||
|
} else if (row.status === ArticleStatus.PUBLISHED) {
|
||||||
|
// 已发布状态 -> 下架
|
||||||
|
const res = await resourceApi.unpublishResource(row.resourceID!);
|
||||||
|
if (res.success) {
|
||||||
|
ElMessage.success('下架成功');
|
||||||
|
loadArticles();
|
||||||
|
} else {
|
||||||
|
ElMessage.error('下架失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('操作失败:', error);
|
||||||
|
ElMessage.error('操作失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleEditFromView() {
|
function handleEditFromView() {
|
||||||
if (currentArticle.value?.resourceID) {
|
if (currentArticle.value?.resourceID) {
|
||||||
showViewDialog.value = false;
|
showViewDialog.value = false;
|
||||||
@@ -157,22 +193,42 @@ function deleteArticle() {
|
|||||||
ElMessage.info('删除功能开发中');
|
ElMessage.info('删除功能开发中');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatusType(status: string) {
|
function getStatusType(status: number) {
|
||||||
const typeMap: Record<string, any> = {
|
const typeMap: Record<number, any> = {
|
||||||
'published': 'success',
|
[ArticleStatus.DRAFT]: 'info',
|
||||||
'draft': 'info',
|
[ArticleStatus.PUBLISHED]: 'success',
|
||||||
'pending': 'warning'
|
[ArticleStatus.OFFLINE]: 'warning'
|
||||||
};
|
};
|
||||||
return typeMap[status] || 'info';
|
return typeMap[status] || 'info';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatusText(status: string) {
|
function getStatusText(status: number) {
|
||||||
const textMap: Record<string, string> = {
|
const textMap: Record<number, string> = {
|
||||||
'published': '已发布',
|
[ArticleStatus.DRAFT]: '草稿',
|
||||||
'draft': '草稿',
|
[ArticleStatus.PUBLISHED]: '已发布',
|
||||||
'pending': '待审核'
|
[ArticleStatus.OFFLINE]: '已下架'
|
||||||
};
|
};
|
||||||
return textMap[status] || status;
|
return textMap[status] || '未知';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getActionButtonType(status: number) {
|
||||||
|
// 草稿或下架状态显示主要按钮(发布), 已发布状态显示警告按钮(下架)
|
||||||
|
if (status === ArticleStatus.DRAFT || status === ArticleStatus.OFFLINE) {
|
||||||
|
return 'primary';
|
||||||
|
} else if (status === ArticleStatus.PUBLISHED) {
|
||||||
|
return 'warning';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getActionButtonText(status: number) {
|
||||||
|
// 草稿或下架状态显示"发布", 已发布状态显示"下架"
|
||||||
|
if (status === ArticleStatus.DRAFT || status === ArticleStatus.OFFLINE) {
|
||||||
|
return '发布';
|
||||||
|
} else if (status === ArticleStatus.PUBLISHED) {
|
||||||
|
return '下架';
|
||||||
|
}
|
||||||
|
return '操作';
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSizeChange(val: number) {
|
function handleSizeChange(val: number) {
|
||||||
|
|||||||
@@ -9,18 +9,23 @@
|
|||||||
@close="handleClose"
|
@close="handleClose"
|
||||||
>
|
>
|
||||||
<div class="article-show-container">
|
<div class="article-show-container">
|
||||||
|
<div v-if="loading" class="loading-state">
|
||||||
|
<el-skeleton :rows="8" animated />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else-if="currentArticleData">
|
||||||
<!-- 文章头部信息 -->
|
<!-- 文章头部信息 -->
|
||||||
<div class="article-header">
|
<div class="article-header">
|
||||||
<h1 class="article-title">{{ articleData.title }}</h1>
|
<h1 class="article-title">{{ currentArticleData.title }}</h1>
|
||||||
<div class="article-meta-info">
|
<div class="article-meta-info">
|
||||||
<div class="meta-item" v-if="articleData.publishTime || articleData.createTime">
|
<div class="meta-item" v-if="currentArticleData.publishTime || currentArticleData.createTime">
|
||||||
发布时间:{{ formatDateSimple(articleData.publishTime || articleData.createTime || '') }}
|
发布时间:{{ formatDateSimple(currentArticleData.publishTime || currentArticleData.createTime || '') }}
|
||||||
</div>
|
</div>
|
||||||
<div class="meta-item" v-if="articleData.viewCount !== undefined">
|
<div class="meta-item" v-if="currentArticleData.viewCount !== undefined">
|
||||||
浏览次数:{{ articleData.viewCount }}
|
浏览次数:{{ currentArticleData.viewCount }}
|
||||||
</div>
|
</div>
|
||||||
<div class="meta-item" v-if="articleData.source">
|
<div class="meta-item" v-if="currentArticleData.source">
|
||||||
来源:{{ articleData.source }}
|
来源:{{ currentArticleData.source }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -29,7 +34,10 @@
|
|||||||
<div class="separator"></div>
|
<div class="separator"></div>
|
||||||
|
|
||||||
<!-- 文章内容 -->
|
<!-- 文章内容 -->
|
||||||
<div class="article-content ql-editor" v-html="articleData.content"></div>
|
<div class="article-content ql-editor" v-html="currentArticleData.content"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-empty v-else description="加载文章失败" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@@ -38,20 +46,33 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 非 Dialog 模式 -->
|
<!-- 路由页面模式 -->
|
||||||
<div v-else class="article-show-container">
|
<div v-else class="article-page-view">
|
||||||
|
<!-- 返回按钮 -->
|
||||||
|
<div v-if="showBackButton" class="back-header">
|
||||||
|
<el-button @click="handleBack" :icon="ArrowLeft">{{ backButtonText }}</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 加载中 -->
|
||||||
|
<div v-if="loading" class="loading-container">
|
||||||
|
<el-skeleton :rows="10" animated />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 文章内容 -->
|
||||||
|
<div v-else-if="currentArticleData" class="article-wrapper">
|
||||||
|
<div class="article-show-container">
|
||||||
<!-- 文章头部信息 -->
|
<!-- 文章头部信息 -->
|
||||||
<div class="article-header">
|
<div class="article-header">
|
||||||
<h1 class="article-title">{{ articleData.title }}</h1>
|
<h1 class="article-title">{{ currentArticleData.title }}</h1>
|
||||||
<div class="article-meta-info">
|
<div class="article-meta-info">
|
||||||
<div class="meta-item" v-if="articleData.publishTime || articleData.createTime">
|
<div class="meta-item" v-if="currentArticleData.publishTime || currentArticleData.createTime">
|
||||||
发布时间:{{ formatDateSimple(articleData.publishTime || articleData.createTime || '') }}
|
发布时间:{{ formatDateSimple(currentArticleData.publishTime || currentArticleData.createTime || '') }}
|
||||||
</div>
|
</div>
|
||||||
<div class="meta-item" v-if="articleData.viewCount !== undefined">
|
<div class="meta-item" v-if="currentArticleData.viewCount !== undefined">
|
||||||
浏览次数:{{ articleData.viewCount }}
|
浏览次数:{{ currentArticleData.viewCount }}
|
||||||
</div>
|
</div>
|
||||||
<div class="meta-item" v-if="articleData.source">
|
<div class="meta-item" v-if="currentArticleData.source">
|
||||||
来源:{{ articleData.source }}
|
来源:{{ currentArticleData.source }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -60,48 +81,396 @@
|
|||||||
<div class="separator"></div>
|
<div class="separator"></div>
|
||||||
|
|
||||||
<!-- 文章内容 -->
|
<!-- 文章内容 -->
|
||||||
<div class="article-content ql-editor" v-html="articleData.content"></div>
|
<div class="article-content ql-editor" v-html="currentArticleData.content"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 加载失败 -->
|
||||||
|
<div v-else class="error-container">
|
||||||
|
<el-empty description="加载文章失败" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue';
|
import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue';
|
||||||
import { ElDialog, ElButton } from 'element-plus';
|
import { useRouter, useRoute } from 'vue-router';
|
||||||
import { ResourceCategory, Resource, Tag } from '@/types';
|
import { ElMessage } from 'element-plus';
|
||||||
|
import { ArrowLeft } from '@element-plus/icons-vue';
|
||||||
|
import { resourceApi } from '@/apis/resource';
|
||||||
|
import { learningRecordApi } from '@/apis/study';
|
||||||
|
import { useStore } from 'vuex';
|
||||||
|
import type { ResourceCategory, Resource, ResourceVO, LearningRecord } from '@/types';
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'ArticleShowView'
|
||||||
|
});
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
modelValue?: boolean; // Dialog 模式下的显示状态
|
modelValue?: boolean; // Dialog 模式下的显示状态
|
||||||
asDialog?: boolean; // 是否作为 Dialog 使用
|
asDialog?: boolean; // 是否作为 Dialog 使用
|
||||||
title?: string; // Dialog 标题
|
title?: string; // Dialog 标题
|
||||||
width?: string; // Dialog 宽度
|
width?: string; // Dialog 宽度
|
||||||
articleData?: Resource; // 文章数据
|
articleData?: Resource; // 文章数据(Dialog 模式使用)
|
||||||
|
resourceID?: string; // 资源ID(路由模式使用)
|
||||||
categoryList?: Array<ResourceCategory>; // 分类列表
|
categoryList?: Array<ResourceCategory>; // 分类列表
|
||||||
showEditButton?: boolean; // 是否显示编辑按钮
|
showEditButton?: boolean; // 是否显示编辑按钮
|
||||||
|
showBackButton?: boolean; // 是否显示返回按钮(路由模式)
|
||||||
|
backButtonText?: string; // 返回按钮文本
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
modelValue: false,
|
modelValue: false,
|
||||||
asDialog: true,
|
asDialog: false, // 默认作为路由页面使用
|
||||||
title: '文章预览',
|
title: '文章预览',
|
||||||
width: '900px',
|
width: '900px',
|
||||||
articleData: () => ({}),
|
articleData: () => ({}),
|
||||||
categoryList: () => [],
|
categoryList: () => [],
|
||||||
showEditButton: false
|
showEditButton: false,
|
||||||
|
showBackButton: true,
|
||||||
|
backButtonText: '返回'
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
'update:modelValue': [value: boolean];
|
'update:modelValue': [value: boolean];
|
||||||
'close': [];
|
'close': [];
|
||||||
'edit': [];
|
'edit': [];
|
||||||
|
'back': [];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const route = useRoute();
|
||||||
|
const store = useStore();
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
const loadedArticleData = ref<Resource | null>(null);
|
||||||
|
|
||||||
|
// 学习记录相关
|
||||||
|
const learningRecord = ref<LearningRecord | null>(null);
|
||||||
|
const learningStartTime = ref(0);
|
||||||
|
const learningTimer = ref<number | null>(null);
|
||||||
|
const hasVideoCompleted = ref(false);
|
||||||
|
const totalVideos = ref(0); // 视频总数
|
||||||
|
const completedVideos = ref<Set<number>>(new Set()); // 已完成的视频索引
|
||||||
|
const userInfo = computed(() => store.getters['auth/user']);
|
||||||
|
|
||||||
|
// 当前显示的文章数据
|
||||||
|
const currentArticleData = computed(() => {
|
||||||
|
// Dialog 模式使用传入的 articleData
|
||||||
|
if (props.asDialog) {
|
||||||
|
return props.articleData;
|
||||||
|
}
|
||||||
|
// 路由模式:优先使用传入的 articleData,否则使用加载的数据
|
||||||
|
if (props.articleData && Object.keys(props.articleData).length > 0) {
|
||||||
|
return props.articleData;
|
||||||
|
}
|
||||||
|
return loadedArticleData.value;
|
||||||
|
});
|
||||||
|
|
||||||
// Dialog 显示状态
|
// Dialog 显示状态
|
||||||
const visible = computed({
|
const visible = computed({
|
||||||
get: () => props.asDialog ? props.modelValue : false,
|
get: () => props.asDialog ? props.modelValue : false,
|
||||||
set: (val) => props.asDialog ? emit('update:modelValue', val) : undefined
|
set: (val) => props.asDialog ? emit('update:modelValue', val) : undefined
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// 路由模式下,从路由参数加载文章
|
||||||
|
if (!props.asDialog) {
|
||||||
|
const articleId = route.query.articleId as string;
|
||||||
|
const taskId = route.query.taskId as string;
|
||||||
|
|
||||||
|
// 如果传入了 articleData,则不需要从路由加载
|
||||||
|
if (props.articleData && Object.keys(props.articleData).length > 0) {
|
||||||
|
loadedArticleData.value = props.articleData;
|
||||||
|
// 即使传入了数据,也要监听视频(如果有taskId)
|
||||||
|
if (taskId || route.query.taskId) {
|
||||||
|
const resourceID = props.articleData.resourceID;
|
||||||
|
if (resourceID) {
|
||||||
|
loadLearningRecord(resourceID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 初始化视频监听
|
||||||
|
nextTick().then(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
initVideoListeners();
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
} else if (articleId) {
|
||||||
|
// 从路由参数加载
|
||||||
|
loadArticle(articleId);
|
||||||
|
// 如果有 taskId,表示是任务学习,需要创建/加载学习记录
|
||||||
|
if (taskId) {
|
||||||
|
loadLearningRecord(articleId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 既没有传入数据,也没有路由参数,显示错误
|
||||||
|
ElMessage.error('文章ID不存在');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
// 组件销毁前保存学习进度
|
||||||
|
if (learningRecord.value && !learningRecord.value.isComplete) {
|
||||||
|
saveLearningProgress();
|
||||||
|
}
|
||||||
|
stopLearningTimer();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 监听 articleData 变化(用于 ResourceArticle 切换文章)
|
||||||
|
watch(() => props.articleData, (newData) => {
|
||||||
|
if (!props.asDialog && newData && Object.keys(newData).length > 0) {
|
||||||
|
loadedArticleData.value = newData;
|
||||||
|
// 重新初始化视频监听
|
||||||
|
nextTick().then(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
initVideoListeners();
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 加载文章数据
|
||||||
|
async function loadArticle(resourceID: string) {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const res = await resourceApi.getResourceById(resourceID);
|
||||||
|
if (res.success && res.data) {
|
||||||
|
// ResourceVO 包含 resource 对象
|
||||||
|
const resourceVO = res.data as ResourceVO;
|
||||||
|
loadedArticleData.value = resourceVO.resource || res.data as Resource;
|
||||||
|
|
||||||
|
// 增加浏览次数
|
||||||
|
await resourceApi.incrementViewCount(resourceID);
|
||||||
|
|
||||||
|
// 等待 DOM 更新后监听视频(增加延迟确保 DOM 完全渲染)
|
||||||
|
await nextTick();
|
||||||
|
setTimeout(() => {
|
||||||
|
initVideoListeners();
|
||||||
|
}, 300); // 延迟 300ms 确保 DOM 完全渲染
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.message || '加载文章失败');
|
||||||
|
loadedArticleData.value = null;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载文章失败:', error);
|
||||||
|
ElMessage.error('加载文章失败');
|
||||||
|
loadedArticleData.value = null;
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载学习记录
|
||||||
|
async function loadLearningRecord(resourceID: string) {
|
||||||
|
if (!userInfo.value?.id) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await learningRecordApi.getRecordList({
|
||||||
|
userID: userInfo.value.id,
|
||||||
|
resourceType: 1, // 资源类型:文章
|
||||||
|
resourceID: resourceID
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.success && res.dataList && res.dataList.length > 0) {
|
||||||
|
learningRecord.value = res.dataList[0];
|
||||||
|
|
||||||
|
// 如果已完成,不需要启动计时器
|
||||||
|
if (learningRecord.value.isComplete) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 没有记录,创建新的
|
||||||
|
await createLearningRecord(resourceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始学习计时
|
||||||
|
startLearningTimer();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载学习记录失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建学习记录
|
||||||
|
async function createLearningRecord(resourceID: string) {
|
||||||
|
if (!userInfo.value?.id) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const taskId = route.query.taskId as string;
|
||||||
|
const res = await learningRecordApi.createRecord({
|
||||||
|
userID: userInfo.value.id,
|
||||||
|
resourceType: 1, // 资源类型:文章
|
||||||
|
resourceID: resourceID,
|
||||||
|
taskID: taskId || undefined,
|
||||||
|
duration: 0,
|
||||||
|
progress: 0,
|
||||||
|
isComplete: false
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.success && res.data) {
|
||||||
|
learningRecord.value = res.data;
|
||||||
|
ElMessage.success('开始学习');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('创建学习记录失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始学习计时
|
||||||
|
function startLearningTimer() {
|
||||||
|
learningStartTime.value = Date.now();
|
||||||
|
|
||||||
|
// 每10秒保存一次学习进度
|
||||||
|
learningTimer.value = window.setInterval(() => {
|
||||||
|
// 如果文章已完成,停止定时器
|
||||||
|
if (learningRecord.value?.isComplete) {
|
||||||
|
stopLearningTimer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
saveLearningProgress();
|
||||||
|
}, 10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 停止学习计时
|
||||||
|
function stopLearningTimer() {
|
||||||
|
if (learningTimer.value) {
|
||||||
|
clearInterval(learningTimer.value);
|
||||||
|
learningTimer.value = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存学习进度
|
||||||
|
async function saveLearningProgress() {
|
||||||
|
if (!userInfo.value?.id || !learningRecord.value) return;
|
||||||
|
|
||||||
|
// 如果文章已完成,不再保存进度
|
||||||
|
if (learningRecord.value.isComplete) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentTime = Date.now();
|
||||||
|
const duration = Math.floor((currentTime - learningStartTime.value) / 1000);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const updatedRecord = {
|
||||||
|
id: learningRecord.value.id,
|
||||||
|
userID: userInfo.value.id,
|
||||||
|
resourceType: 1,
|
||||||
|
resourceID: route.query.articleId as string,
|
||||||
|
duration: (learningRecord.value.duration || 0) + duration,
|
||||||
|
progress: hasVideoCompleted.value ? 100 : 50, // 如果视频播放完成,进度100%
|
||||||
|
isComplete: hasVideoCompleted.value
|
||||||
|
};
|
||||||
|
|
||||||
|
await learningRecordApi.updateRecord(updatedRecord);
|
||||||
|
|
||||||
|
// 更新本地记录
|
||||||
|
learningRecord.value.duration = updatedRecord.duration;
|
||||||
|
learningRecord.value.progress = updatedRecord.progress;
|
||||||
|
learningRecord.value.isComplete = updatedRecord.isComplete;
|
||||||
|
|
||||||
|
// 重置开始时间
|
||||||
|
learningStartTime.value = currentTime;
|
||||||
|
|
||||||
|
// 如果已完成,标记完成
|
||||||
|
if (hasVideoCompleted.value) {
|
||||||
|
await markArticleComplete();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('保存学习进度失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 标记文章完成
|
||||||
|
async function markArticleComplete() {
|
||||||
|
if (!userInfo.value?.id || !learningRecord.value) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await learningRecordApi.markComplete({
|
||||||
|
id: learningRecord.value.id,
|
||||||
|
taskID: route.query.taskId as string,
|
||||||
|
userID: userInfo.value.id,
|
||||||
|
resourceType: 1,
|
||||||
|
resourceID: route.query.articleId as string,
|
||||||
|
isComplete: true
|
||||||
|
});
|
||||||
|
|
||||||
|
ElMessage.success('文章学习完成!');
|
||||||
|
stopLearningTimer();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('标记完成失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化视频监听器
|
||||||
|
function initVideoListeners() {
|
||||||
|
|
||||||
|
// 尝试多种选择器查找文章内容区域
|
||||||
|
const selectors = [
|
||||||
|
'.article-show-container .article-content.ql-editor',
|
||||||
|
'.article-wrapper .article-content.ql-editor',
|
||||||
|
'.article-content.ql-editor',
|
||||||
|
'.article-show-container .article-content',
|
||||||
|
'.article-wrapper .article-content',
|
||||||
|
'.article-content'
|
||||||
|
];
|
||||||
|
|
||||||
|
let articleContent: Element | null = null;
|
||||||
|
|
||||||
|
for (const selector of selectors) {
|
||||||
|
articleContent = document.querySelector(selector);
|
||||||
|
if (articleContent) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!articleContent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const videos = articleContent.querySelectorAll('video');
|
||||||
|
|
||||||
|
if (videos.length === 0) {
|
||||||
|
// 没有视频,默认阅读即完成
|
||||||
|
hasVideoCompleted.value = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化视频数量和完成状态
|
||||||
|
totalVideos.value = videos.length;
|
||||||
|
completedVideos.value.clear();
|
||||||
|
|
||||||
|
// 监听所有视频的播放结束事件
|
||||||
|
videos.forEach((video, index) => {
|
||||||
|
const videoElement = video as HTMLVideoElement;
|
||||||
|
|
||||||
|
// 移除旧的监听器
|
||||||
|
videoElement.removeEventListener('ended', () => handleVideoEnded(index));
|
||||||
|
// 添加新的监听器,传递视频索引
|
||||||
|
videoElement.addEventListener('ended', () => handleVideoEnded(index));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理视频播放结束
|
||||||
|
function handleVideoEnded(videoIndex: number) {
|
||||||
|
// 标记该视频已完成
|
||||||
|
completedVideos.value.add(videoIndex);
|
||||||
|
|
||||||
|
const completedCount = completedVideos.value.size;
|
||||||
|
console.log(`✅ 视频 ${videoIndex + 1} 播放完成 (${completedCount}/${totalVideos.value})`);
|
||||||
|
|
||||||
|
// 检查是否所有视频都已完成
|
||||||
|
if (completedCount >= totalVideos.value) {
|
||||||
|
if (!hasVideoCompleted.value) {
|
||||||
|
hasVideoCompleted.value = true;
|
||||||
|
ElMessage.success(`所有视频播放完成 (${totalVideos.value}/${totalVideos.value})`);
|
||||||
|
// 立即保存学习进度并标记完成
|
||||||
|
saveLearningProgress();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ElMessage.info(`视频 ${videoIndex + 1} 播放完成 (${completedCount}/${totalVideos.value})`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 格式化日期(简单格式:YYYY-MM-DD)
|
// 格式化日期(简单格式:YYYY-MM-DD)
|
||||||
function formatDateSimple(date: string | Date): string {
|
function formatDateSimple(date: string | Date): string {
|
||||||
@@ -128,6 +497,26 @@ function handleEdit() {
|
|||||||
emit('edit');
|
emit('edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 返回处理
|
||||||
|
function handleBack() {
|
||||||
|
// 返回前保存学习进度
|
||||||
|
if (learningRecord.value && !learningRecord.value.isComplete) {
|
||||||
|
saveLearningProgress();
|
||||||
|
}
|
||||||
|
stopLearningTimer();
|
||||||
|
|
||||||
|
const taskId = route.query.taskId as string;
|
||||||
|
// 如果有 taskId,返回任务详情
|
||||||
|
if (taskId) {
|
||||||
|
router.push({
|
||||||
|
path: '/study-plan/task-detail',
|
||||||
|
query: { taskId }
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
emit('back');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 暴露方法
|
// 暴露方法
|
||||||
defineExpose({
|
defineExpose({
|
||||||
open: () => {
|
open: () => {
|
||||||
@@ -140,6 +529,51 @@ defineExpose({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
// 路由页面模式样式
|
||||||
|
.article-page-view {
|
||||||
|
min-height: 100vh;
|
||||||
|
background: #f5f7fa;
|
||||||
|
padding-bottom: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back-header {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 100;
|
||||||
|
padding: 16px 24px;
|
||||||
|
background: #fff;
|
||||||
|
border-bottom: 1px solid #e4e7ed;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-container {
|
||||||
|
max-width: 900px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 40px 24px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-wrapper {
|
||||||
|
max-width: 900px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 40px 24px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-container {
|
||||||
|
padding: 80px 24px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-state {
|
||||||
|
padding: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dialog 和路由模式共用的文章内容样式
|
||||||
.article-show-container {
|
.article-show-container {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
|||||||
@@ -64,6 +64,7 @@
|
|||||||
size="large"
|
size="large"
|
||||||
:icon="isCollected ? StarFilled : Star"
|
:icon="isCollected ? StarFilled : Star"
|
||||||
@click="handleCollect"
|
@click="handleCollect"
|
||||||
|
:type="isCollected ? 'success' : 'default'"
|
||||||
>
|
>
|
||||||
{{ isCollected ? '已收藏' : '收藏课程' }}
|
{{ isCollected ? '已收藏' : '收藏课程' }}
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -293,7 +294,6 @@ async function checkCollectionStatus() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await userCollectionApi.isCollected(
|
const res = await userCollectionApi.isCollected(
|
||||||
userInfo.value.id,
|
|
||||||
CollectionType.COURSE,
|
CollectionType.COURSE,
|
||||||
props.courseId
|
props.courseId
|
||||||
);
|
);
|
||||||
@@ -310,10 +310,10 @@ async function loadLearningProgress() {
|
|||||||
if (!userInfo.value?.id) return;
|
if (!userInfo.value?.id) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await learningRecordApi.getRecordList({
|
const res = await learningRecordApi.getCourseLearningRecord({
|
||||||
userID: userInfo.value.id,
|
userID: userInfo.value.id,
|
||||||
resourceType: 2, // 课程类型
|
resourceType: 2, // 课程
|
||||||
resourceID: props.courseId
|
courseID: props.courseId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.success && res.dataList && res.dataList.length > 0) {
|
if (res.success && res.dataList && res.dataList.length > 0) {
|
||||||
@@ -440,10 +440,14 @@ function formatDuration(minutes?: number): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.back-header {
|
.back-header {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 100;
|
||||||
padding: 16px 24px;
|
padding: 16px 24px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-bottom: 1px solid #e4e7ed;
|
border-bottom: 1px solid #e4e7ed;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading {
|
.loading {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<div class="learning-header">
|
<div class="learning-header">
|
||||||
<div class="header-left">
|
<div class="header-left">
|
||||||
<el-button @click="handleBack" :icon="ArrowLeft" text>
|
<el-button @click="handleBack" :icon="ArrowLeft" text>
|
||||||
返回课程详情
|
{{ backButtonText }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<span class="course-name">{{ courseVO?.course.name }}</span>
|
<span class="course-name">{{ courseVO?.course.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -17,13 +17,18 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="learning-container">
|
<div class="learning-container">
|
||||||
|
<!-- 浮动展开按钮(侧边栏收起时显示) -->
|
||||||
|
<div v-if="sidebarCollapsed" class="float-expand-btn" @click="toggleSidebar">
|
||||||
|
<el-button circle :icon="Expand" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- 左侧:章节目录 -->
|
<!-- 左侧:章节目录 -->
|
||||||
<div class="chapter-sidebar" :class="{ collapsed: sidebarCollapsed }">
|
<div class="chapter-sidebar" :class="{ collapsed: sidebarCollapsed }">
|
||||||
<div class="sidebar-header">
|
<div class="sidebar-header">
|
||||||
<span class="sidebar-title">课程目录</span>
|
<span class="sidebar-title">课程目录</span>
|
||||||
<el-button
|
<el-button
|
||||||
text
|
text
|
||||||
:icon="sidebarCollapsed ? Expand : Fold"
|
:icon="Fold"
|
||||||
@click="toggleSidebar"
|
@click="toggleSidebar"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -85,7 +90,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 右侧:学习内容区 -->
|
<!-- 右侧:学习内容区 -->
|
||||||
<div class="content-area" :class="{ expanded: sidebarCollapsed }">
|
<div
|
||||||
|
ref="contentAreaRef"
|
||||||
|
class="content-area"
|
||||||
|
:class="{ expanded: sidebarCollapsed }"
|
||||||
|
@scroll="handleContentScroll"
|
||||||
|
>
|
||||||
<!-- 加载中 -->
|
<!-- 加载中 -->
|
||||||
<div v-if="loading" class="loading-container">
|
<div v-if="loading" class="loading-container">
|
||||||
<el-skeleton :rows="8" animated />
|
<el-skeleton :rows="8" animated />
|
||||||
@@ -194,7 +204,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch, onMounted, onBeforeUnmount } from 'vue';
|
import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
import {
|
import {
|
||||||
ArrowLeft,
|
ArrowLeft,
|
||||||
@@ -220,11 +231,13 @@ interface Props {
|
|||||||
courseId: string;
|
courseId: string;
|
||||||
chapterIndex?: number;
|
chapterIndex?: number;
|
||||||
nodeIndex?: number;
|
nodeIndex?: number;
|
||||||
|
backButtonText?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
chapterIndex: 0,
|
chapterIndex: 0,
|
||||||
nodeIndex: 0
|
nodeIndex: 0,
|
||||||
|
backButtonText: '返回课程详情'
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -232,7 +245,8 @@ const emit = defineEmits<{
|
|||||||
}>();
|
}>();
|
||||||
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const authStore = computed(() => store.state.auth);
|
const userInfo = computed(() => store.getters['auth/user']);
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const courseVO = ref<CourseVO | null>(null);
|
const courseVO = ref<CourseVO | null>(null);
|
||||||
@@ -241,12 +255,19 @@ const currentNodeIndex = ref(0);
|
|||||||
const sidebarCollapsed = ref(false);
|
const sidebarCollapsed = ref(false);
|
||||||
const activeChapters = ref<number[]>([0]);
|
const activeChapters = ref<number[]>([0]);
|
||||||
const articleData = ref<any>(null);
|
const articleData = ref<any>(null);
|
||||||
|
const contentAreaRef = ref<HTMLElement | null>(null);
|
||||||
|
|
||||||
// 学习记录
|
// 学习记录
|
||||||
const learningRecord = ref<LearningRecord | null>(null);
|
const learningRecord = ref<LearningRecord | null>(null);
|
||||||
const completedNodes = ref<Set<string>>(new Set());
|
const completedNodes = ref<Set<string>>(new Set());
|
||||||
const learningStartTime = ref<number>(0);
|
const learningStartTime = ref<number>(0);
|
||||||
const learningTimer = ref<number | null>(null);
|
const learningTimer = ref<number | null>(null);
|
||||||
|
const hasScrolledToBottom = ref(false);
|
||||||
|
const previousNodeKey = ref<string | null>(null);
|
||||||
|
|
||||||
|
// 富文本视频跟踪
|
||||||
|
const totalRichTextVideos = ref(0);
|
||||||
|
const completedRichTextVideos = ref<Set<number>>(new Set());
|
||||||
|
|
||||||
// 当前节点
|
// 当前节点
|
||||||
const currentNode = computed(() => {
|
const currentNode = computed(() => {
|
||||||
@@ -371,30 +392,55 @@ async function loadCourse() {
|
|||||||
|
|
||||||
// 加载学习记录
|
// 加载学习记录
|
||||||
async function loadLearningRecord() {
|
async function loadLearningRecord() {
|
||||||
if (!authStore.value.userInfo?.userID) return;
|
if (!userInfo.value?.id) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await learningRecordApi.getRecordList({
|
const res = await learningRecordApi.getCourseLearningRecord({
|
||||||
userID: authStore.value.userInfo.userID,
|
userID: userInfo.value.id,
|
||||||
resourceType: 2, // 课程
|
resourceType: 2, // 课程
|
||||||
resourceID: props.courseId
|
courseID: props.courseId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.success && res.dataList && res.dataList.length > 0) {
|
if (res.success && res.dataList && res.dataList.length > 0) {
|
||||||
learningRecord.value = res.dataList[0];
|
learningRecord.value = res.dataList[0];
|
||||||
|
|
||||||
// TODO: 从后端获取已完成的节点列表
|
// 从本地存储加载已完成的节点列表
|
||||||
// 这里暂时用本地存储模拟
|
|
||||||
const savedProgress = localStorage.getItem(`course_${props.courseId}_nodes`);
|
const savedProgress = localStorage.getItem(`course_${props.courseId}_nodes`);
|
||||||
if (savedProgress) {
|
if (savedProgress) {
|
||||||
completedNodes.value = new Set(JSON.parse(savedProgress));
|
completedNodes.value = new Set(JSON.parse(savedProgress));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 没有学习记录,创建新的
|
||||||
|
await createLearningRecord();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('加载学习记录失败:', error);
|
console.error('加载学习记录失败:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 创建学习记录
|
||||||
|
async function createLearningRecord() {
|
||||||
|
if (!userInfo.value?.id) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await learningRecordApi.createRecord({
|
||||||
|
userID: userInfo.value.id,
|
||||||
|
resourceType: 2, // 课程
|
||||||
|
courseID: props.courseId,
|
||||||
|
chapterID: courseVO.value?.courseChapters[currentChapterIndex.value].chapter.chapterID,
|
||||||
|
nodeID: courseVO.value?.courseChapters[currentChapterIndex.value].nodes[currentNodeIndex.value].nodeID,
|
||||||
|
taskID: route.query.taskId as string
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.success && res.data) {
|
||||||
|
learningRecord.value = res.data;
|
||||||
|
console.log('学习记录创建成功');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('创建学习记录失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 加载节点内容
|
// 加载节点内容
|
||||||
async function loadNodeContent() {
|
async function loadNodeContent() {
|
||||||
if (!currentNode.value) return;
|
if (!currentNode.value) return;
|
||||||
@@ -423,9 +469,28 @@ async function loadNodeContent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 选择节点
|
// 选择节点
|
||||||
function selectNode(chapterIndex: number, nodeIndex: number) {
|
async function selectNode(chapterIndex: number, nodeIndex: number) {
|
||||||
|
// 检查前一个节点是否需要标记完成
|
||||||
|
if (previousNodeKey.value && (hasScrolledToBottom.value || !hasScrollbar())) {
|
||||||
|
await markNodeComplete(previousNodeKey.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 切换到新节点
|
||||||
currentChapterIndex.value = chapterIndex;
|
currentChapterIndex.value = chapterIndex;
|
||||||
currentNodeIndex.value = nodeIndex;
|
currentNodeIndex.value = nodeIndex;
|
||||||
|
|
||||||
|
// 重置滚动状态
|
||||||
|
hasScrolledToBottom.value = false;
|
||||||
|
previousNodeKey.value = `${chapterIndex}-${nodeIndex}`;
|
||||||
|
|
||||||
|
// 滚动到顶部
|
||||||
|
if (contentAreaRef.value) {
|
||||||
|
contentAreaRef.value.scrollTop = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 等待 DOM 更新后初始化视频监听
|
||||||
|
await nextTick();
|
||||||
|
initRichTextVideoListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上一节
|
// 上一节
|
||||||
@@ -458,17 +523,11 @@ function gotoNext() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 标记为完成
|
// 标记为完成
|
||||||
function markAsComplete() {
|
async function markAsComplete() {
|
||||||
if (!currentNode.value) return;
|
if (!currentNode.value) return;
|
||||||
|
|
||||||
const nodeKey = `${currentChapterIndex.value}-${currentNodeIndex.value}`;
|
const nodeKey = `${currentChapterIndex.value}-${currentNodeIndex.value}`;
|
||||||
completedNodes.value.add(nodeKey);
|
await markNodeComplete(nodeKey);
|
||||||
|
|
||||||
// 保存到本地存储
|
|
||||||
localStorage.setItem(
|
|
||||||
`course_${props.courseId}_nodes`,
|
|
||||||
JSON.stringify(Array.from(completedNodes.value))
|
|
||||||
);
|
|
||||||
|
|
||||||
ElMessage.success('已标记为完成');
|
ElMessage.success('已标记为完成');
|
||||||
|
|
||||||
@@ -477,13 +536,7 @@ function markAsComplete() {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
gotoNext();
|
gotoNext();
|
||||||
}, 500);
|
}, 500);
|
||||||
} else {
|
|
||||||
// 课程全部完成
|
|
||||||
ElMessage.success('恭喜你完成了整个课程!');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新学习进度
|
|
||||||
saveLearningProgress();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断节点是否完成
|
// 判断节点是否完成
|
||||||
@@ -496,10 +549,15 @@ function isNodeCompleted(chapterIndex: number, nodeIndex: number): boolean {
|
|||||||
function startLearningTimer() {
|
function startLearningTimer() {
|
||||||
learningStartTime.value = Date.now();
|
learningStartTime.value = Date.now();
|
||||||
|
|
||||||
// 每分钟保存一次学习进度
|
// 每10秒保存一次学习进度(如果未完成)
|
||||||
learningTimer.value = window.setInterval(() => {
|
learningTimer.value = window.setInterval(() => {
|
||||||
|
// 如果课程已完成,停止定时器
|
||||||
|
if (learningRecord.value?.isComplete) {
|
||||||
|
stopLearningTimer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
saveLearningProgress();
|
saveLearningProgress();
|
||||||
}, 60000); // 60秒
|
}, 10000); // 10秒
|
||||||
}
|
}
|
||||||
|
|
||||||
// 停止学习计时
|
// 停止学习计时
|
||||||
@@ -512,19 +570,34 @@ function stopLearningTimer() {
|
|||||||
|
|
||||||
// 保存学习进度
|
// 保存学习进度
|
||||||
async function saveLearningProgress() {
|
async function saveLearningProgress() {
|
||||||
if (!authStore.value.userInfo?.userID || !learningRecord.value) return;
|
if (!userInfo.value?.id || !learningRecord.value) return;
|
||||||
|
|
||||||
|
// 如果课程已完成,不再保存进度
|
||||||
|
if (learningRecord.value.isComplete) {
|
||||||
|
console.log('课程已完成,跳过进度保存');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const currentTime = Date.now();
|
const currentTime = Date.now();
|
||||||
const duration = Math.floor((currentTime - learningStartTime.value) / 1000); // 秒
|
const duration = Math.floor((currentTime - learningStartTime.value) / 1000); // 秒
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await learningRecordApi.updateRecord({
|
const updatedRecord = {
|
||||||
...learningRecord.value,
|
id: learningRecord.value.id,
|
||||||
|
userID: userInfo.value.id,
|
||||||
|
resourceType: 2,
|
||||||
|
resourceID: props.courseId,
|
||||||
duration: (learningRecord.value.duration || 0) + duration,
|
duration: (learningRecord.value.duration || 0) + duration,
|
||||||
progress: currentProgress.value,
|
progress: currentProgress.value,
|
||||||
isComplete: currentProgress.value === 100,
|
isComplete: currentProgress.value === 100
|
||||||
lastLearnTime: new Date().toISOString()
|
};
|
||||||
});
|
|
||||||
|
await learningRecordApi.updateRecord(updatedRecord);
|
||||||
|
|
||||||
|
// 更新本地记录
|
||||||
|
learningRecord.value.duration = updatedRecord.duration;
|
||||||
|
learningRecord.value.progress = updatedRecord.progress;
|
||||||
|
learningRecord.value.isComplete = updatedRecord.isComplete;
|
||||||
|
|
||||||
// 重置开始时间
|
// 重置开始时间
|
||||||
learningStartTime.value = currentTime;
|
learningStartTime.value = currentTime;
|
||||||
@@ -533,6 +606,78 @@ async function saveLearningProgress() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 标记节点完成
|
||||||
|
async function markNodeComplete(nodeKey: string) {
|
||||||
|
if (completedNodes.value.has(nodeKey)) return;
|
||||||
|
|
||||||
|
// 如果课程已完成,不再标记节点
|
||||||
|
if (learningRecord.value?.isComplete) {
|
||||||
|
console.log('课程已完成,跳过节点标记');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
completedNodes.value.add(nodeKey);
|
||||||
|
|
||||||
|
// 保存到本地存储
|
||||||
|
localStorage.setItem(
|
||||||
|
`course_${props.courseId}_nodes`,
|
||||||
|
JSON.stringify(Array.from(completedNodes.value))
|
||||||
|
);
|
||||||
|
|
||||||
|
// 更新学习进度
|
||||||
|
await saveLearningProgress();
|
||||||
|
|
||||||
|
// 如果全部完成,标记课程为完成
|
||||||
|
if (currentProgress.value === 100) {
|
||||||
|
await markCourseComplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 标记课程完成
|
||||||
|
async function markCourseComplete() {
|
||||||
|
if (!userInfo.value?.id || !learningRecord.value) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await learningRecordApi.markComplete({
|
||||||
|
id: learningRecord.value.id,
|
||||||
|
userID: userInfo.value.id,
|
||||||
|
resourceType: 2,
|
||||||
|
resourceID: props.courseId,
|
||||||
|
taskID: route.query.taskId as string,
|
||||||
|
progress: 100,
|
||||||
|
isComplete: true
|
||||||
|
});
|
||||||
|
|
||||||
|
ElMessage.success('恭喜你完成了整个课程!');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('标记课程完成失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否有滚动条
|
||||||
|
function hasScrollbar(): boolean {
|
||||||
|
if (!contentAreaRef.value) return false;
|
||||||
|
return contentAreaRef.value.scrollHeight > contentAreaRef.value.clientHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理内容区域滚动
|
||||||
|
function handleContentScroll(event: Event) {
|
||||||
|
const target = event.target as HTMLElement;
|
||||||
|
const scrollTop = target.scrollTop;
|
||||||
|
const scrollHeight = target.scrollHeight;
|
||||||
|
const clientHeight = target.clientHeight;
|
||||||
|
|
||||||
|
// 判断是否滚动到底部(留10px容差)
|
||||||
|
if (scrollHeight - scrollTop - clientHeight < 10) {
|
||||||
|
if (!hasScrolledToBottom.value) {
|
||||||
|
hasScrolledToBottom.value = true;
|
||||||
|
// 滚动到底部,标记当前节点完成
|
||||||
|
const nodeKey = `${currentChapterIndex.value}-${currentNodeIndex.value}`;
|
||||||
|
markNodeComplete(nodeKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 处理视频进度
|
// 处理视频进度
|
||||||
function handleVideoProgress(event: Event) {
|
function handleVideoProgress(event: Event) {
|
||||||
// 可以在这里记录视频播放进度
|
// 可以在这里记录视频播放进度
|
||||||
@@ -552,6 +697,67 @@ function handleVideoEnded() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化富文本中的视频监听器
|
||||||
|
function initRichTextVideoListeners() {
|
||||||
|
// 使用 setTimeout 确保 DOM 完全渲染
|
||||||
|
setTimeout(() => {
|
||||||
|
// 尝试多种选择器查找富文本内容区域
|
||||||
|
const selectors = [
|
||||||
|
'.node-content .rich-text-content',
|
||||||
|
'.content-area .rich-text-content',
|
||||||
|
'.rich-text-content'
|
||||||
|
];
|
||||||
|
|
||||||
|
let richTextContent: Element | null = null;
|
||||||
|
|
||||||
|
for (const selector of selectors) {
|
||||||
|
richTextContent = document.querySelector(selector);
|
||||||
|
if (richTextContent) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!richTextContent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const videos = richTextContent.querySelectorAll('video');
|
||||||
|
|
||||||
|
if (videos.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化视频数量和完成状态
|
||||||
|
totalRichTextVideos.value = videos.length;
|
||||||
|
completedRichTextVideos.value.clear();
|
||||||
|
|
||||||
|
// 监听所有视频的播放结束事件
|
||||||
|
videos.forEach((video, index) => {
|
||||||
|
const videoElement = video as HTMLVideoElement;
|
||||||
|
// 移除旧的监听器,避免重复添加
|
||||||
|
videoElement.removeEventListener('ended', () => handleRichTextVideoEnded(index));
|
||||||
|
// 添加新的监听器,传递视频索引
|
||||||
|
videoElement.addEventListener('ended', () => handleRichTextVideoEnded(index));
|
||||||
|
});
|
||||||
|
}, 300); // 延迟 300ms 确保 DOM 完全渲染
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理富文本视频播放结束
|
||||||
|
function handleRichTextVideoEnded(videoIndex: number) {
|
||||||
|
// 标记该视频已完成
|
||||||
|
completedRichTextVideos.value.add(videoIndex);
|
||||||
|
|
||||||
|
const completedCount = completedRichTextVideos.value.size;
|
||||||
|
|
||||||
|
// 检查是否所有视频都已完成
|
||||||
|
if (completedCount >= totalRichTextVideos.value) {
|
||||||
|
if (!isCurrentNodeCompleted.value) {
|
||||||
|
ElMessage.success(`所有视频播放完成 (${totalRichTextVideos.value}/${totalRichTextVideos.value})`);
|
||||||
|
markAsComplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 处理音频进度
|
// 处理音频进度
|
||||||
function handleAudioProgress(event: Event) {
|
function handleAudioProgress(event: Event) {
|
||||||
const audio = event.target as HTMLAudioElement;
|
const audio = event.target as HTMLAudioElement;
|
||||||
@@ -626,6 +832,7 @@ function handleBack() {
|
|||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||||
|
|
||||||
.header-left {
|
.header-left {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -651,6 +858,18 @@ function handleBack() {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
height: calc(100vh - 61px);
|
height: calc(100vh - 61px);
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.float-expand-btn {
|
||||||
|
position: absolute;
|
||||||
|
left: 16px;
|
||||||
|
top: 16px;
|
||||||
|
z-index: 10;
|
||||||
|
|
||||||
|
:deep(.el-button) {
|
||||||
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.chapter-sidebar {
|
.chapter-sidebar {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="resource-article">
|
<div class="resource-article">
|
||||||
<div class="page-header">
|
|
||||||
<el-button @click="handleBack" :icon="ArrowLeft">返回</el-button>
|
|
||||||
</div>
|
|
||||||
<ArticleShowView
|
<ArticleShowView
|
||||||
v-if="articleData"
|
v-if="articleData"
|
||||||
:as-dialog="false"
|
:as-dialog="false"
|
||||||
:article-data="articleData"
|
:article-data="articleData"
|
||||||
:category-list="[]"
|
:category-list="[]"
|
||||||
|
:show-back-button="true"
|
||||||
|
back-button-text="返回列表"
|
||||||
|
@back="handleBack"
|
||||||
/>
|
/>
|
||||||
<div v-else class="loading">加载中...</div>
|
<div v-else class="loading">加载中...</div>
|
||||||
<ResouceCollect
|
<ResouceCollect
|
||||||
@@ -29,7 +29,6 @@ import { ResouceCollect, ResouceBottom } from '@/views/resource-center/component
|
|||||||
import { resourceApi } from '@/apis/resource';
|
import { resourceApi } from '@/apis/resource';
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
import type { Resource } from '@/types/resource';
|
import type { Resource } from '@/types/resource';
|
||||||
import { ArrowLeft } from '@element-plus/icons-vue';
|
|
||||||
import { CollectionType, type UserCollection } from '@/types';
|
import { CollectionType, type UserCollection } from '@/types';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -145,24 +144,17 @@ function handleBack() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
||||||
.page-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 16px;
|
|
||||||
margin-bottom: 24px;
|
|
||||||
|
|
||||||
.page-title {
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #303133;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.resource-article {
|
.resource-article {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
padding: 40px 60px;
|
padding: 40px 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.loading {
|
||||||
|
text-align: center;
|
||||||
|
padding: 40px;
|
||||||
|
color: #909399;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
:course-id="courseId"
|
:course-id="courseId"
|
||||||
:chapter-index="chapterIndex"
|
:chapter-index="chapterIndex"
|
||||||
:node-index="nodeIndex"
|
:node-index="nodeIndex"
|
||||||
|
:back-button-text="taskId ? '返回任务详情' : '返回课程详情'"
|
||||||
@back="handleBack"
|
@back="handleBack"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@@ -24,15 +25,27 @@ const route = useRoute();
|
|||||||
const courseId = computed(() => route.query.courseId as string || '');
|
const courseId = computed(() => route.query.courseId as string || '');
|
||||||
const chapterIndex = computed(() => parseInt(route.query.chapterIndex as string) || 0);
|
const chapterIndex = computed(() => parseInt(route.query.chapterIndex as string) || 0);
|
||||||
const nodeIndex = computed(() => parseInt(route.query.nodeIndex as string) || 0);
|
const nodeIndex = computed(() => parseInt(route.query.nodeIndex as string) || 0);
|
||||||
|
const taskId = computed(() => route.query.taskId as string || '');
|
||||||
|
|
||||||
// 返回到课程详情页
|
// 返回到上一页
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
|
// 如果有 taskId,返回任务详情页
|
||||||
|
if (taskId.value) {
|
||||||
|
router.push({
|
||||||
|
path: '/study-plan/task-detail',
|
||||||
|
query: {
|
||||||
|
taskId: taskId.value
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 否则返回课程详情页
|
||||||
router.push({
|
router.push({
|
||||||
path: '/study-plan/course-detail',
|
path: '/study-plan/course-detail',
|
||||||
query: {
|
query: {
|
||||||
courseId: courseId.value
|
courseId: courseId.value
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const taskId = computed(() => route.query.taskId as string || '');
|
|||||||
|
|
||||||
// 返回任务列表
|
// 返回任务列表
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
router.back();
|
router.push('/study-plan/tasks');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -138,8 +138,8 @@ const progressPercent = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadUserProgress();
|
|
||||||
loadTaskList();
|
loadTaskList();
|
||||||
|
loadUserProgress();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 获取当前用户ID
|
// 获取当前用户ID
|
||||||
@@ -199,6 +199,7 @@ async function loadUserProgress() {
|
|||||||
const pending = (progressData.notStartTaskNum || 0) + (progressData.learningTaskNum || 0);
|
const pending = (progressData.notStartTaskNum || 0) + (progressData.learningTaskNum || 0);
|
||||||
// 设置统计数据
|
// 设置统计数据
|
||||||
totalCount.value = progressData.totalTaskNum || 0;
|
totalCount.value = progressData.totalTaskNum || 0;
|
||||||
|
completedCount.value = progressData.completedTaskNum || 0;
|
||||||
pendingCount.value = pending;
|
pendingCount.value = pending;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -244,7 +245,7 @@ function getDeadlineStatus(task: LearningTask): { show: boolean; text: string; t
|
|||||||
|
|
||||||
if (task.status === 2) {
|
if (task.status === 2) {
|
||||||
// 已完成
|
// 已完成
|
||||||
return { show: true, text: '已截止', type: 'success' };
|
return { show: true, text: '已完成', type: 'success' };
|
||||||
} else if (diffDays < 0) {
|
} else if (diffDays < 0) {
|
||||||
// 已过期
|
// 已过期
|
||||||
return { show: true, text: '已截止', type: 'info' };
|
return { show: true, text: '已截止', type: 'info' };
|
||||||
|
|||||||
@@ -156,26 +156,31 @@
|
|||||||
</el-tag>
|
</el-tag>
|
||||||
</div>
|
</div>
|
||||||
<div class="course-meta">
|
<div class="course-meta">
|
||||||
<span v-if="course.completeTime" class="complete-time">
|
<div class="status-info">
|
||||||
<el-icon><CircleCheck /></el-icon>
|
|
||||||
完成于 {{ formatDateTime(course.completeTime) }}
|
|
||||||
</span>
|
|
||||||
<el-tag
|
<el-tag
|
||||||
v-else
|
:type="getItemStatusType(course.status)"
|
||||||
:type="getCourseStatusType(course.progress)"
|
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
{{ course.progress ? '学习中' : '未开始' }}
|
{{ getItemStatusText(course.status) }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
|
<span v-if="course.status === 2 && course.completeTime" class="complete-time">
|
||||||
|
<el-icon><CircleCheck /></el-icon>
|
||||||
|
{{ formatDateTime(course.completeTime) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="course.progress !== null && course.progress !== undefined" class="progress-info">
|
||||||
|
<span class="progress-text">{{ course.progress }}%</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="course-action">
|
<div class="course-action">
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
:icon="course.progress ? VideoPlay : Reading"
|
:icon="course.status === 2 ? CircleCheck : (course.status === 1 ? VideoPlay : Reading)"
|
||||||
|
:disabled="course.status === 2"
|
||||||
@click.stop="handleCourseClick(course)"
|
@click.stop="handleCourseClick(course)"
|
||||||
>
|
>
|
||||||
{{ course.progress ? '继续学习' : '开始学习' }}
|
{{ course.status === 2 ? '已完成' : (course.status === 1 ? '继续学习' : '开始学习') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -215,26 +220,31 @@
|
|||||||
</el-tag>
|
</el-tag>
|
||||||
</div>
|
</div>
|
||||||
<div class="resource-meta">
|
<div class="resource-meta">
|
||||||
<span v-if="resource.completeTime" class="complete-time">
|
<div class="status-info">
|
||||||
<el-icon><CircleCheck /></el-icon>
|
|
||||||
完成于 {{ formatDateTime(resource.completeTime) }}
|
|
||||||
</span>
|
|
||||||
<el-tag
|
<el-tag
|
||||||
v-else
|
:type="getItemStatusType(resource.status)"
|
||||||
:type="getResourceStatusType(resource.progress)"
|
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
{{ resource.progress ? '阅读中' : '未开始' }}
|
{{ getItemStatusText(resource.status) }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
|
<span v-if="resource.status === 2 && resource.completeTime" class="complete-time">
|
||||||
|
<el-icon><CircleCheck /></el-icon>
|
||||||
|
{{ formatDateTime(resource.completeTime) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="resource.progress !== null && resource.progress !== undefined" class="progress-info">
|
||||||
|
<span class="progress-text">{{ resource.progress }}%</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="resource-action">
|
<div class="resource-action">
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
:icon="resource.progress ? Reading : View"
|
:icon="resource.status === 2 ? CircleCheck : (resource.status === 1 ? Reading : View)"
|
||||||
|
:disabled="resource.status === 2"
|
||||||
@click.stop="handleResourceClick(resource)"
|
@click.stop="handleResourceClick(resource)"
|
||||||
>
|
>
|
||||||
{{ resource.progress ? '继续阅读' : '开始阅读' }}
|
{{ resource.status === 2 ? '已完成' : (resource.status === 1 ? '继续阅读' : '开始阅读') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -336,7 +346,7 @@ async function loadTaskDetail() {
|
|||||||
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const res = await learningTaskApi.getTaskById(currentTaskId.value);
|
const res = await learningTaskApi.getUserTask(currentTaskId.value);
|
||||||
if (res.success && res.data) {
|
if (res.success && res.data) {
|
||||||
taskVO.value = res.data;
|
taskVO.value = res.data;
|
||||||
|
|
||||||
@@ -392,7 +402,7 @@ function handleResourceClick(resource: TaskItemVO) {
|
|||||||
path: '/article/show',
|
path: '/article/show',
|
||||||
query: {
|
query: {
|
||||||
articleId: resource.resourceID,
|
articleId: resource.resourceID,
|
||||||
taskId: currentTaskId.value
|
taskId: currentTaskId.value // 传递 taskId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -444,14 +454,32 @@ function getTaskStatusType(status?: number): 'info' | 'success' | 'warning' | 'd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取课程状态类型
|
// 获取学习项状态文本(课程/资源通用)
|
||||||
function getCourseStatusType(progress?: boolean): 'success' | 'info' {
|
function getItemStatusText(status?: number): string {
|
||||||
return progress ? 'success' : 'info';
|
switch (status) {
|
||||||
|
case 0:
|
||||||
|
return '未开始';
|
||||||
|
case 1:
|
||||||
|
return '学习中';
|
||||||
|
case 2:
|
||||||
|
return '已完成';
|
||||||
|
default:
|
||||||
|
return '未知';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取资源状态类型
|
// 获取学习项状态类型(课程/资源通用)
|
||||||
function getResourceStatusType(progress?: boolean): 'success' | 'info' {
|
function getItemStatusType(status?: number): 'info' | 'warning' | 'success' {
|
||||||
return progress ? 'success' : 'info';
|
switch (status) {
|
||||||
|
case 0:
|
||||||
|
return 'info';
|
||||||
|
case 1:
|
||||||
|
return 'warning';
|
||||||
|
case 2:
|
||||||
|
return 'success';
|
||||||
|
default:
|
||||||
|
return 'info';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -463,10 +491,14 @@ function getResourceStatusType(progress?: boolean): 'success' | 'info' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.back-header {
|
.back-header {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 100;
|
||||||
padding: 16px 24px;
|
padding: 16px 24px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-bottom: 1px solid #e4e7ed;
|
border-bottom: 1px solid #e4e7ed;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading {
|
.loading {
|
||||||
@@ -755,8 +787,14 @@ function getResourceStatusType(progress?: boolean): 'success' | 'info' {
|
|||||||
.course-meta {
|
.course-meta {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
|
|
||||||
|
.status-info {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
.complete-time {
|
.complete-time {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -769,6 +807,15 @@ function getResourceStatusType(progress?: boolean): 'success' | 'info' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.progress-info {
|
||||||
|
.progress-text {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #409eff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.course-action {
|
.course-action {
|
||||||
@@ -843,8 +890,14 @@ function getResourceStatusType(progress?: boolean): 'success' | 'info' {
|
|||||||
.resource-meta {
|
.resource-meta {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
|
|
||||||
|
.status-info {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
.complete-time {
|
.complete-time {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -857,6 +910,15 @@ function getResourceStatusType(progress?: boolean): 'success' | 'info' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.progress-info {
|
||||||
|
.progress-text {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #409eff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.resource-action {
|
.resource-action {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export default defineConfig({
|
|||||||
build: {
|
build: {
|
||||||
outDir: 'dist',
|
outDir: 'dist',
|
||||||
assetsDir: 'static',
|
assetsDir: 'static',
|
||||||
sourcemap: false,
|
sourcemap: true, // 开启 source map 用于调试
|
||||||
chunkSizeWarningLimit: 1500,
|
chunkSizeWarningLimit: 1500,
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
Reference in New Issue
Block a user