feat:课程列表ai伴学模式修发布评论对接
This commit is contained in:
parent
7b993f0648
commit
177bdbc009
@ -29,6 +29,24 @@ export class CommentApi {
|
||||
return ApiRequest.get(`/lessons/${lessonId}/comments`, params)
|
||||
}
|
||||
|
||||
// 发送课程评论
|
||||
static async postCourseComment(courseId: string, data: {
|
||||
content: string
|
||||
imgs?: string
|
||||
}): Promise<ApiResponse<any>> {
|
||||
try {
|
||||
console.log('🚀 发送课程评论:', { courseId, data })
|
||||
|
||||
const response = await ApiRequest.post<any>(`/aiol/aiolComment/course/${courseId}/add`, data)
|
||||
console.log('✅ 发送课程评论成功:', response)
|
||||
|
||||
return response
|
||||
} catch (error) {
|
||||
console.error('❌ 发送课程评论失败:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// 添加课程评论
|
||||
static addCourseComment(courseId: number, data: {
|
||||
content: string
|
||||
|
@ -446,11 +446,30 @@
|
||||
|
||||
<!-- 左侧边栏 -->
|
||||
<div class="sidebar">
|
||||
<div class="sidebar-title">
|
||||
|
||||
|
||||
<!-- 学期选择器 -->
|
||||
<div class="semester-selector">
|
||||
<select class="semester-dropdown">
|
||||
<option value="2025-spring">2025年上学期</option>
|
||||
<option value="2025-fall">2025年下学期</option>
|
||||
<option value="2024-spring">2024年上学期</option>
|
||||
</select>
|
||||
<div class="dropdown-arrow">
|
||||
<svg width="12" height="8" viewBox="0 0 12 8" fill="none">
|
||||
<path d="M1 1L6 6L11 1" stroke="#0088D1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 开课时间 -->
|
||||
<div class="course-time-info">
|
||||
开课时间:2025.09.01-2026.01.14
|
||||
</div>
|
||||
<div class="sidebar-title">
|
||||
<h2>学习进度</h2>
|
||||
<img src="/images/aiCompanion/fold.png" alt="">
|
||||
</div>
|
||||
|
||||
<!-- 学习进度 -->
|
||||
<div class="progress-section">
|
||||
<div class="progress-header">
|
||||
@ -1029,6 +1048,7 @@ import { useMessage } from 'naive-ui'
|
||||
// import { useAuth } from '@/composables/useAuth'
|
||||
// import { useUserStore } from '@/stores/user'
|
||||
import { CourseApi } from '@/api/modules/course'
|
||||
import { CommentApi } from '@/api/modules/comment'
|
||||
import type { Course, CourseSection, CourseComment } from '@/api/types'
|
||||
import QuillEditor from '@/components/common/QuillEditor.vue'
|
||||
import DPlayerVideo from '@/components/course/DPlayerVideo.vue'
|
||||
@ -1391,14 +1411,36 @@ const loadCourseComments = async () => {
|
||||
}
|
||||
|
||||
// 提交评论函数
|
||||
const submitComment = () => {
|
||||
if (newComment.value.trim()) {
|
||||
// 这里可以调用API提交评论
|
||||
console.log('提交评论:', newComment.value)
|
||||
// 提交成功后重新加载评论列表
|
||||
// await CourseApi.submitComment(courseId.value, newComment.value)
|
||||
// loadCourseComments()
|
||||
newComment.value = ''
|
||||
const submitComment = async () => {
|
||||
if (!newComment.value.trim()) {
|
||||
message.warning('请输入评论内容')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
console.log('🚀 开始提交评论:', newComment.value)
|
||||
|
||||
// 调用评论API
|
||||
const response = await CommentApi.postCourseComment(courseId.value, {
|
||||
content: newComment.value.trim(),
|
||||
imgs: '' // 暂时不支持图片,可以后续扩展
|
||||
})
|
||||
|
||||
console.log('✅ 评论提交成功:', response)
|
||||
|
||||
// 检查响应数据结构
|
||||
if (response.data && response.data.code === 200 && response.data.success) {
|
||||
message.success('评论发布成功')
|
||||
newComment.value = ''
|
||||
|
||||
// 重新加载评论列表
|
||||
await loadCourseComments()
|
||||
} else {
|
||||
message.error(response.data?.message || '评论发布失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ 提交评论失败:', error)
|
||||
message.error('评论发布失败,请稍后重试')
|
||||
}
|
||||
}
|
||||
|
||||
@ -2357,6 +2399,68 @@ onActivated(() => {
|
||||
border: 1px solid white;
|
||||
}
|
||||
|
||||
/* 学期选择器 */
|
||||
.semester-selector {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 42px;
|
||||
margin: 20px 0 -3px 0;
|
||||
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.semester-dropdown {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #E2F5FF;
|
||||
border: 1px solid #0088D1;
|
||||
border-radius: 4px;
|
||||
padding: 0 40px 0 16px;
|
||||
font-family: PingFangSC, PingFang SC;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
color: #0088D1;
|
||||
appearance: none;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.semester-dropdown:focus {
|
||||
border-color: #0088D1;
|
||||
box-shadow: 0 0 0 2px rgba(0, 136, 209, 0.1);
|
||||
}
|
||||
|
||||
.dropdown-arrow {
|
||||
position: absolute;
|
||||
right: 16px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* 开课时间信息 */
|
||||
.course-time-info {
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
font-family: PingFangSC, PingFang SC;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
color: #666666;
|
||||
line-height: 20px;
|
||||
text-align: left;
|
||||
font-style: normal;
|
||||
margin: 0 0 20px 0;
|
||||
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 进度头部样式 */
|
||||
.progress-header {
|
||||
margin-bottom: 20px;
|
||||
@ -5715,6 +5819,7 @@ onActivated(() => {
|
||||
.banner-title-section {
|
||||
width: 100%;
|
||||
margin-bottom: 10px;
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.banner-content {
|
||||
@ -5722,6 +5827,7 @@ onActivated(() => {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
color: #000;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner-text {
|
||||
|
Loading…
x
Reference in New Issue
Block a user