修正公共课程列表样式,与课程直播间完全一致

- 更新PublicCourseList组件结构,完全复制CourseList的实现
- 使用course-list-wrapper统一容器样式(304px宽度,798px高度)
- 添加时间轴图标样式(time-line-dot-icon, time-line-clock-icon, time-line-lock-icon)
- 实现课程状态样式(finish, active, coming, not-started, pending)
- 添加选中状态和悬停效果
- 统一使用time-line-item样式类
- 保持与课程直播间完全一致的视觉效果

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
KQL
2025-09-06 16:52:08 +08:00
parent 94610142af
commit 6337cc4812
2 changed files with 339 additions and 181 deletions

View File

@@ -1,167 +1,307 @@
.public-course-list { .course-list-wrapper {
width: 100%; width: 304px;
height: 100%; height: 798px;
display: flex;
flex-direction: column;
background: #fff;
border-radius: 8px; border-radius: 8px;
overflow: hidden; background-color: #fff;
box-sizing: border-box;
padding: 20px 16px;
overflow-y: hidden;
} }
.course-list-header { .course-list-wrapper .course-list-title {
padding: 16px 20px; width: 100%;
border-bottom: 1px solid #e5e6eb; height: 30px;
background: #fafafa; position: relative;
} box-sizing: border-box;
font-size: 20px;
.course-list-header h3 { font-weight: 600;
margin: 0; line-height: 20px;
font-size: 16px;
font-weight: 500;
color: #1d2129; color: #1d2129;
padding-bottom: 10px;
border-bottom: 1px solid #e5e6eb;
margin-bottom: 10px;
} }
.course-list-collapse { .course-list-wrapper .course-list-title::before {
flex: 1; content: "";
position: absolute;
left: 20px;
bottom: 5px;
width: 31px;
height: 3px;
background-image: url("@/assets/images/Common/title_icon.png");
background-size: 100% 100%;
}
.course-list-wrapper .course-list-content {
width: 100%;
height: 700px;
overflow-y: auto; overflow-y: auto;
padding: 12px;
} }
.course-list-collapse .arco-collapse-item { .course-list-wrapper .course-list-content .course-list {
margin-bottom: 8px;
border: 1px solid #e5e6eb;
border-radius: 4px;
overflow: hidden;
}
.course-list-collapse .arco-collapse-item-header {
background: #f7f8fa;
padding: 12px 16px;
}
.unit-header {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%; width: 100%;
} }
.unit-name { /* 自定义折叠面板元素 */
.course-list-wrapper .course-list-content .course-list .course-list-item {
width: 272px;
margin-bottom: 10px;
box-sizing: border-box;
padding: 3px 0;
color: #4e5969;
font-size: 14px; font-size: 14px;
font-weight: 500; font-weight: 400;
color: #1d2129; line-height: 21px;
border: none;
} }
.unit-course-count { .course-list-item .arco-collapse-item-header {
font-size: 12px; border-radius: 8px;
color: #86909c; background-color: #f2f3f5;
margin-right: 20px;
} }
.course-timeline { .course-list-item .arco-timeline-item {
padding: 16px 0; margin-bottom: 10px;
padding-left: 0;
} }
.timeline-dot { .course-list-item .arco-collapse-item-content-expanded {
width: 8px; background-color: #fff;
height: 8px; }
.course-list-item .arco-collapse-item-content-box {
margin-top: 10px;
padding: 0 0 0 5px;
box-sizing: border-box;
}
/* 自定义时间轴元素 - 统一使用CSS样式 */
.course-list-item .time-line-dot-icon {
width: 12px;
height: 12px;
background-color: #10b981;
border-radius: 50%; border-radius: 50%;
background: #e5e6eb; position: relative;
} }
.timeline-dot.completed { .course-list-item .time-line-dot-icon::before {
background: #00b42a; content: "";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 6px;
height: 6px;
background-color: #fff;
border-radius: 50%;
} }
.timeline-dot.current { .course-list-item .time-line-clock-icon {
background: #ff7d00; width: 12px;
box-shadow: 0 0 0 4px rgba(255, 125, 0, 0.2); height: 12px;
background-color: #3b82f6;
border-radius: 50%;
position: relative;
} }
.timeline-dot.upcoming { .course-list-item .time-line-clock-icon::before {
background: #165dff; content: "";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 6px;
height: 6px;
background-color: #fff;
border-radius: 50%;
} }
.course-item { .course-list-item .time-line-lock-icon {
padding: 12px; width: 12px;
background: #f7f8fa; height: 12px;
border-radius: 4px; background-color: #c9cdd4;
border-radius: 50%;
position: relative;
opacity: 0.6;
}
.course-list-item .time-line-lock-icon::before {
content: "";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 6px;
height: 6px;
background-color: #fff;
border-radius: 50%;
}
.course-list-item .time-line-item {
width: 248px;
min-height: 74px !important;
height: auto !important;
background-color: #f2f3f5;
border-radius: 8px;
position: relative;
box-sizing: border-box;
padding: 10px;
cursor: pointer; cursor: pointer;
transition: all 0.3s; transition: all 0.3s;
}
.course-list-item .time-line-item:hover {
background-color: #e8f3ff;
transform: translateX(2px);
}
.course-list-item .time-line-item > p {
width: calc(100% - 70px) !important;
min-height: 22px !important;
height: auto !important;
font-size: 14px;
font-weight: 600;
line-height: 22px;
color: #1d2129;
word-wrap: break-word !important;
word-break: break-word !important;
white-space: normal !important;
overflow-wrap: break-word !important;
display: block !important;
text-overflow: unset !important;
overflow: visible !important;
max-width: none !important;
-webkit-line-clamp: unset !important;
-webkit-box-orient: unset !important;
text-rendering: auto !important;
}
.course-list-item .time-line-item > .time-line-item-info {
margin-top: 10px;
width: 100%;
min-height: 20px;
font-size: 12px;
font-weight: 400;
line-height: 20px;
color: #4e5969;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: flex-start;
flex-wrap: wrap;
gap: 5px;
} }
.course-item:hover { .course-list-item .finish::before {
background: #e8f3ff; content: "已结束";
transform: translateX(4px); position: absolute;
} right: 10px;
top: 10px;
.course-item.selected { width: 48px;
background: #e8f3ff; height: 20px;
border-left: 3px solid #165dff; line-height: 18px;
} text-align: center;
border-radius: 12px;
.course-item.completed { background-color: #c9cdd4;
opacity: 0.7; color: #86909c;
}
.course-info {
flex: 1;
}
.course-name {
font-size: 14px;
font-weight: 500;
color: #1d2129;
margin-bottom: 4px;
}
.course-meta {
display: flex;
gap: 16px;
font-size: 12px; font-size: 12px;
font-weight: 600;
box-sizing: border-box;
border: 1px solid #c9cdd4;
}
.course-list-item .not-started::before {
content: "未开始";
position: absolute;
right: 10px;
top: 10px;
width: 48px;
height: 20px;
line-height: 18px;
text-align: center;
border-radius: 12px;
background-color: #e8e8e8;
color: #86909c;
font-size: 12px;
font-weight: 600;
box-sizing: border-box;
border: 1px solid #e8e8e8;
}
.course-list-item .active {
border: 1px solid #0275f2;
}
.course-list-item .active::before {
content: "";
position: absolute;
right: 10px;
top: 10px;
width: 60px;
height: 20px;
background-image: url("@/assets/images/CoursesVideoPlayer/living_icon.png");
background-size: 100% 100%;
}
.course-list-item .selected {
background-color: #f2f8ff;
border: 1px solid #4080ff !important;
box-shadow: 0 2px 8px rgba(64, 128, 255, 0.15);
}
.course-list-item .selected p {
color: #1d2129;
font-weight: 500;
}
.course-list-item .pending {
opacity: 0.6;
cursor: not-allowed;
}
.course-list-item .pending > p {
color: #86909c; color: #86909c;
} }
.course-status { .course-list-item .pending .time-line-item-info {
padding: 2px 8px; color: #86909c;
}
.course-list-item .coming::before {
content: "即将开始";
position: absolute;
right: 10px;
top: 10px;
width: 60px;
height: 20px;
line-height: 18px;
text-align: center;
border-radius: 12px; border-radius: 12px;
font-size: 12px; background-color: #f2f3f5;
white-space: nowrap;
}
.course-status.completed {
background: #e8ffea;
color: #00b42a;
}
.course-status.current {
background: #fff7e8;
color: #ff7d00; color: #ff7d00;
font-size: 12px;
font-weight: 600;
box-sizing: border-box;
border: 1px solid #ff7d00;
} }
.course-status.upcoming { /* 强制覆盖Arco Timeline文本省略 */
background: #e8f3ff; .course-list .arco-timeline-item-content p {
color: #165dff; text-overflow: unset !important;
overflow: visible !important;
white-space: normal !important;
display: block !important;
-webkit-line-clamp: unset !important;
-webkit-box-orient: unset !important;
word-break: break-word !important;
max-width: calc(100% - 70px) !important;
} }
/* 自定义滚动条 */ .course-list .time-line-item p {
.course-list-collapse::-webkit-scrollbar { text-overflow: unset !important;
width: 6px; overflow: visible !important;
} white-space: normal !important;
display: block !important;
.course-list-collapse::-webkit-scrollbar-track { -webkit-line-clamp: unset !important;
background: #f2f3f5; -webkit-box-orient: unset !important;
border-radius: 3px;
}
.course-list-collapse::-webkit-scrollbar-thumb {
background: #c9cdd4;
border-radius: 3px;
}
.course-list-collapse::-webkit-scrollbar-thumb:hover {
background: #86909c;
} }

View File

@@ -67,88 +67,106 @@ const PublicCourseList = ({ className = "", onCourseClick }) => {
} }
}; };
const handleCourseClick = (course, unitName) => { const getCourseStatus = (course) => {
setSelectedCourseId(course.courseId); if (course.completed) return "finish";
if (onCourseClick) { if (course.current) return "active";
onCourseClick({
...course, // 判断未来课程的具体状态
unitName: unitName if (course.upcoming) {
}); const courseDate = new Date(course.date);
const today = new Date();
// 重置时间部分只比较日期
courseDate.setHours(0, 0, 0, 0);
today.setHours(0, 0, 0, 0);
const timeDiff = courseDate - today;
const daysDiff = Math.floor(timeDiff / (24 * 60 * 60 * 1000));
// 未来7天内的课程显示为"即将开始"
if (daysDiff > 0 && daysDiff <= 7) {
return "coming";
} }
// 7天后的课程显示为"未开始"
return "not-started";
}
// 默认状态
return "pending";
}; };
const renderCourseStatus = (course) => { // 获取图标类型
if (course.completed) { const getDotIcon = (course) => {
return <span className="course-status completed">已完成</span>; if (course.completed) return <div className="time-line-dot-icon" />;
} else if (course.current) { if (course.current) return <div className="time-line-clock-icon" />;
return <span className="course-status current">正在进行</span>; return <div className="time-line-lock-icon" />;
} else if (course.upcoming) {
return <span className="course-status upcoming">即将开始</span>;
}
return null;
}; };
if (loading) {
return (
<div className={`${className} course-list-wrapper`}>
<p className="course-list-title">公共课程列表</p>
<div className="course-list-content">
<Spin />
</div>
</div>
);
}
return ( return (
<div className={`public-course-list ${className}`}> <div className={`${className} course-list-wrapper`}>
<div className="course-list-header"> <p className="course-list-title">公共课程列表</p>
<h3>公共课程列表</h3> <div className="course-list-content">
</div>
<Spin loading={loading} style={{ width: '100%' }}>
<Collapse <Collapse
defaultActiveKey={courseLiveList.map(unit => unit.unitId)} lazyload
className="course-list-collapse" className="course-list"
bordered={false}
expandIconPosition="right"
defaultActiveKey={["1", "2", "3"]}
> >
{courseLiveList.map((unit) => ( {courseLiveList.map((unit, index) => (
<CollapseItem <CollapseItem
key={unit.unitId} key={unit.unitId}
header={ header={unit.unitName}
<div className="unit-header"> name={String(index + 1)}
<span className="unit-name">{unit.unitName}</span> className="course-list-item"
<span className="unit-course-count">
{unit.courses.filter(c => c.completed).length}/{unit.courses.length} 已完成
</span>
</div>
}
name={unit.unitId}
> >
<Timeline className="course-timeline"> <Timeline>
{unit.courses.map((course) => ( {unit.courses.map((course) => (
<TimelineItem <TimelineItem
key={course.courseId} key={course.courseId}
dot={ dot={getDotIcon(course)}
<div lineType="dashed"
className={`timeline-dot ${
course.completed ? 'completed' :
course.current ? 'current' :
course.upcoming ? 'upcoming' : ''
}`}
/>
}
label={course.date}
> >
<div <div
className={`course-item ${ className={`time-line-item ${getCourseStatus(course)} ${selectedCourseId === course.courseId ? 'selected' : ''}`}
selectedCourseId === course.courseId ? 'selected' : '' onClick={() => {
} ${course.completed ? 'completed' : ''}`} setSelectedCourseId(course.courseId);
onClick={() => handleCourseClick(course, unit.unitName)} onCourseClick && onCourseClick({ ...course, unitName: unit.unitName });
}}
style={{ cursor: 'pointer' }}
> >
<div className="course-info"> <p style={{
<div className="course-name">{course.courseName}</div> overflow: 'visible',
<div className="course-meta"> textOverflow: 'unset',
<span className="course-teacher">讲师{course.teacherName}</span> whiteSpace: 'normal',
{course.time && <span className="course-time">时间{course.time}</span>} wordBreak: 'break-word'
}}>
{course.courseName}
</p>
<div className="time-line-item-info">
<span>讲师{course.teacherName}</span>
{course.date && <span>{course.date}</span>}
{course.time && <span>{course.time}</span>}
</div> </div>
</div> </div>
{renderCourseStatus(course)}
</div>
</TimelineItem> </TimelineItem>
))} ))}
</Timeline> </Timeline>
</CollapseItem> </CollapseItem>
))} ))}
</Collapse> </Collapse>
</Spin> </div>
</div> </div>
); );
}; };