fix: 优化布局和显示

1. 修复教师名称显示问题,现在显示正确的教师名称
2. 固定进度条宽度
3. 优化整体布局结构
This commit is contained in:
huertian
2025-01-02 16:44:19 +08:00
parent dc25135dd2
commit 8452965556
4 changed files with 40 additions and 28 deletions

View File

@ -364,8 +364,7 @@
{ {
"courseName": "测试课程", "courseName": "测试课程",
"microLessonName": "测试微课", "microLessonName": "测试微课",
"userId": 1, "userId": 1
"advise": "任务说明"
} }
``` ```
- **成功响应** - **成功响应**
@ -385,7 +384,7 @@
"videoCreateTime": null, "videoCreateTime": null,
"videoConfirmTime": null, "videoConfirmTime": null,
"finishTime": null, "finishTime": null,
"advise": "任务说明", "advise": null,
"createdAt": 1735003870, "createdAt": 1735003870,
"updatedAt": 1735003870 "updatedAt": 1735003870
} }

View File

@ -142,7 +142,13 @@ const getUsernameById = (userId: number) => {
const refresh = async () => { const refresh = async () => {
try { try {
const startTime = Date.now()
await loadLessons() await loadLessons()
const endTime = Date.now()
const duration = endTime - startTime
if (duration < 500) {
await new Promise(resolve => setTimeout(resolve, 500 - duration))
}
} catch (err) { } catch (err) {
} finally { } finally {
uni.stopPullDownRefresh() uni.stopPullDownRefresh()
@ -175,12 +181,6 @@ onLoad(() => {
<div class="flex flex-col gap-1"> <div class="flex flex-col gap-1">
<p class="pt-1"> <p class="pt-1">
{{ courseName || '无标题课程' }} {{ courseName || '无标题课程' }}
<wd-badge hidden is-dot :top="-10">
<span v-if="!user.hasRole('teacher') && getUsernameById(courses[0]?.userId)"
class=" text-xs text-gray-400 ml-2">
<!-- {{ getUsernameById(courses[0]?.userId) }} -->
</span>
</wd-badge>
</p> </p>
<div class="flex items-center gap-1"> <div class="flex items-center gap-1">
<wd-tag v-if="(() => { <wd-tag v-if="(() => {
@ -238,9 +238,9 @@ onLoad(() => {
</template> </template>
<div class="w-full"> <div class="w-full">
<wd-status-tip v-if="courses.length === 0" image="content" tip="没有课程小节" /> <wd-status-tip v-if="courses.length === 0" image="content" tip="没有课程小节" />
<div v-else v-for="(lesson, i) in courses" :key="i" @click="openLessonDetail(lesson.id)" class="w-full py-2 flex justify-between items-center gap-20 border-b border-b-solid border-neutral-100 <div v-else v-for="(lesson, i) in courses" :key="i" @click="openLessonDetail(lesson.id)"
last:border-b-0 first:pt-0 last:pb-0"> class="w-full py-2 gap-12 flex justify-between items-center border-b border-b-solid border-neutral-100 last:border-b-0 first:pt-0 last:pb-0">
<div class="flex items-center gap-1"> <div class="flex items-center gap-1 self-center">
<wd-badge is-dot hidden> <wd-badge is-dot hidden>
<div is-dot> <div is-dot>
<div v-if="calcLessonProgress(lesson) === 100" class="i-tabler-circle-check"></div> <div v-if="calcLessonProgress(lesson) === 100" class="i-tabler-circle-check"></div>
@ -249,16 +249,18 @@ onLoad(() => {
</div> </div>
</wd-badge> </wd-badge>
<span>{{ lesson.microLessonName || '无标题微课' }}</span> <span>{{ lesson.microLessonName || '无标题微课' }}</span>
</div>
<div class="flex items-center gap-3 shrink-0">
<wd-badge hidden is-dot :top="-10"> <wd-badge hidden is-dot :top="-10">
<span v-if="!user.hasRole('teacher') && getUsernameById(courses[0]?.userId)" <span v-if="!user.hasRole('teacher') && getUsernameById(lesson.userId)"
class=" text-xs text-gray-400 ml-2"> class="text-xs text-gray-400 ml-2 whitespace-nowrap">
{{ getUsernameById(courses[0]?.userId) }} {{ getUsernameById(lesson.userId) }}
</span> </span>
</wd-badge> </wd-badge>
</div> <div class="w-16">
<div class="w-24 flex items-center gap-3">
<wd-progress :percentage="calcLessonProgress(lesson)" <wd-progress :percentage="calcLessonProgress(lesson)"
:color="calcLessonProgress(lesson) === 100 ? '#34d399' : '#60a5fa'" hide-text /> :color="calcLessonProgress(lesson) === 100 ? '#34d399' : '#60a5fa'" hide-text />
</div>
<div class="i-tabler-dots text-neutral-400 text-xl"></div> <div class="i-tabler-dots text-neutral-400 text-xl"></div>
</div> </div>
</div> </div>

View File

@ -57,7 +57,13 @@ onMounted(() => {
const refresh = async () => { const refresh = async () => {
try { try {
const startTime = Date.now()
await loadLesson() await loadLesson()
const endTime = Date.now()
const duration = endTime - startTime
if (duration < 500) {
await new Promise(resolve => setTimeout(resolve, 500 - duration))
}
} catch (err) { } catch (err) {
} finally { } finally {
uni.stopPullDownRefresh() uni.stopPullDownRefresh()

View File

@ -325,13 +325,18 @@ onMounted(() => {
const refresh = async () => { const refresh = async () => {
try { try {
const startTime = Date.now()
await updateLessons() await updateLessons()
const endTime = Date.now()
const duration = endTime - startTime
if (duration < 500) {
await new Promise(resolve => setTimeout(resolve, 500 - duration))
}
} catch (err) { } catch (err) {
} finally { } finally {
uni.stopPullDownRefresh() uni.stopPullDownRefresh()
} }
} }
// 添加下拉刷新处理函数
onPullDownRefresh(() => { onPullDownRefresh(() => {
refresh() refresh()
}) })