fix: remove remaining list truncation gaps

This commit is contained in:
biss committed 2026-10-25 21:29:06 +08:00
1 parent 1ddfecbecc
commit 64b86d2a68
8 files changed
+153 -40

No files matched your search

+13 -3
View File
@@ -4,9 +4,10 @@ import { Delete, Refresh } from '@element-plus/icons-vue'
import http, { apiErrorMessage } from '../api/http'
type Reply = { id: string; content: string; isAnonymous: boolean; authorName: string; createdAt: string; canDelete: boolean }
type ReplyCursor = { createdAt: string; id: string }
type ReactionName = 'Like' | 'Insightful' | 'Agree' | 'Hooray' | 'Heart' | 'Rocket' | 'Eyes' | 'Laugh'
type ReactionOption = { type: ReactionName; emoji: string; label: string; countKey: string; activeKey: string }
type Comment = Reply & { replyCount: number; replies?: Reply[]; [key: string]: string | number | boolean | Reply[] | undefined }
type Comment = Reply & { replyCount: number; replies?: Reply[]; repliesHasMore?: boolean; repliesNextCursor?: ReplyCursor; [key: string]: string | number | boolean | Reply[] | ReplyCursor | undefined }
const reactionOptions: ReactionOption[] = [
{ type: 'Like', emoji: '👍', label: '赞', countKey: 'likeCount', activeKey: 'hasLiked' },
{ type: 'Insightful', emoji: '💡', label: '有启发', countKey: 'insightfulCount', activeKey: 'hasInsightful' },
@@ -44,8 +45,17 @@ function reacted(comment: Comment, option: ReactionOption) { return comment[opti
async function react(comment: Comment, type: ReactionName) { try { await http.post(`${base()}/comments/${comment.id}/reactions/${type}`); await load(true) } catch (error) { ElMessage.error(apiErrorMessage(error)) } }
async function toggleReplies(comment: Comment) {
replyOpen[comment.id] = !replyOpen[comment.id]; if (!replyOpen[comment.id] || comment.replies) return
await loadReplies(comment, true)
}
async function loadReplies(comment: Comment, reset = false) {
replyLoading[comment.id] = true
try { comment.replies = (await http.get(`${base()}/comments/${comment.id}/replies`)).data.items } catch (error) { ElMessage.error(apiErrorMessage(error)) } finally { replyLoading[comment.id] = false }
try {
const cursor = reset ? undefined : comment.repliesNextCursor
const data = (await http.get(`${base()}/comments/${comment.id}/replies`, { params: cursor ? { afterCreatedAt: cursor.createdAt, afterId: cursor.id } : undefined })).data
comment.replies = reset ? data.items : [...(comment.replies ?? []), ...data.items]
comment.repliesHasMore = data.hasMore
comment.repliesNextCursor = data.nextCursor ?? undefined
} catch (error) { ElMessage.error(apiErrorMessage(error)) } finally { replyLoading[comment.id] = false }
}
async function reply(comment: Comment) {
const text = drafts[comment.id]?.trim(); if (!text) return
@@ -64,7 +74,7 @@ watch(() => props.sheetId, () => load(true), { immediate: true })
<el-input v-model="content" type="textarea" :rows="3" maxlength="1000" show-word-limit placeholder="分享对这门课程成绩、学习收获或教学改进的看法" />
<div class="compose"><el-checkbox v-model="anonymous">匿名发布</el-checkbox><el-button type="primary" :loading="submitting" @click="submit">发布评论</el-button></div>
<el-empty v-if="!loading && !comments.length" :image-size="64" description="还没有评论,来说说你的看法吧" />
<ol v-else class="comments"><li v-for="comment in comments" :key="comment.id"><div class="meta"><strong>{{ comment.authorName || '未命名用户' }}</strong><span v-if="comment.isAnonymous">匿名</span><time>{{ new Date(comment.createdAt).toLocaleString('zh-CN') }}</time></div><p>{{ comment.content }}</p><div class="actions"><div class="reaction-bar"><button v-for="option in reactionOptions.filter(item => reactionCount(comment, item))" :key="option.type" type="button" class="reaction-chip" :class="{ active: reacted(comment, option) }" :aria-label="`${option.label} ${reactionCount(comment, option)}`" @click="react(comment, option.type)">{{ option.emoji }} <span>{{ reactionCount(comment, option) }}</span></button><el-popover placement="top-start" :width="260" trigger="click"><template #reference><el-button class="reaction-add" text size="small" aria-label="添加表情反应">😊</el-button></template><div class="reaction-picker" aria-label="选择表情反应"><button v-for="option in reactionOptions" :key="option.type" type="button" :class="{ active: reacted(comment, option) }" :aria-label="option.label" @click="react(comment, option.type)"><span>{{ option.emoji }}</span><small>{{ option.label }}</small></button></div></el-popover></div><el-button text size="small" @click="toggleReplies(comment)">回复{{ comment.replyCount ? ` (${comment.replyCount})` : '' }}</el-button><el-button v-if="comment.canDelete" text type="danger" size="small" :icon="Delete" @click="remove(comment)">删除</el-button></div><div v-if="replyOpen[comment.id]" class="replies" v-loading="replyLoading[comment.id]"><ol v-if="comment.replies?.length"><li v-for="item in comment.replies" :key="item.id"><div class="meta"><strong>{{ item.authorName }}</strong><span v-if="item.isAnonymous">匿名</span><time>{{ new Date(item.createdAt).toLocaleString('zh-CN') }}</time></div><p>{{ item.content }}</p><el-button v-if="item.canDelete" text type="danger" size="small" @click="remove(item)">删除</el-button></li></ol><el-input v-model="drafts[comment.id]" type="textarea" :rows="2" maxlength="1000" show-word-limit placeholder="回复这条评论" /><div class="compose"><el-checkbox v-model="replyAnonymous[comment.id]">匿名回复</el-checkbox><el-button type="primary" size="small" @click="reply(comment)">回复</el-button></div></div></li></ol>
<ol v-else class="comments"><li v-for="comment in comments" :key="comment.id"><div class="meta"><strong>{{ comment.authorName || '未命名用户' }}</strong><span v-if="comment.isAnonymous">匿名</span><time>{{ new Date(comment.createdAt).toLocaleString('zh-CN') }}</time></div><p>{{ comment.content }}</p><div class="actions"><div class="reaction-bar"><button v-for="option in reactionOptions.filter(item => reactionCount(comment, item))" :key="option.type" type="button" class="reaction-chip" :class="{ active: reacted(comment, option) }" :aria-label="`${option.label} ${reactionCount(comment, option)}`" @click="react(comment, option.type)">{{ option.emoji }} <span>{{ reactionCount(comment, option) }}</span></button><el-popover placement="top-start" :width="260" trigger="click"><template #reference><el-button class="reaction-add" text size="small" aria-label="添加表情反应">😊</el-button></template><div class="reaction-picker" aria-label="选择表情反应"><button v-for="option in reactionOptions" :key="option.type" type="button" :class="{ active: reacted(comment, option) }" :aria-label="option.label" @click="react(comment, option.type)"><span>{{ option.emoji }}</span><small>{{ option.label }}</small></button></div></el-popover></div><el-button text size="small" @click="toggleReplies(comment)">回复{{ comment.replyCount ? ` (${comment.replyCount})` : '' }}</el-button><el-button v-if="comment.canDelete" text type="danger" size="small" :icon="Delete" @click="remove(comment)">删除</el-button></div><div v-if="replyOpen[comment.id]" class="replies" v-loading="replyLoading[comment.id]"><ol v-if="comment.replies?.length"><li v-for="item in comment.replies" :key="item.id"><div class="meta"><strong>{{ item.authorName }}</strong><span v-if="item.isAnonymous">匿名</span><time>{{ new Date(item.createdAt).toLocaleString('zh-CN') }}</time></div><p>{{ item.content }}</p><el-button v-if="item.canDelete" text type="danger" size="small" @click="remove(item)">删除</el-button></li></ol><div v-if="comment.repliesHasMore" class="more"><el-button size="small" :loading="replyLoading[comment.id]" @click="loadReplies(comment)">加载更多回复</el-button></div><el-input v-model="drafts[comment.id]" type="textarea" :rows="2" maxlength="1000" show-word-limit placeholder="回复这条评论" /><div class="compose"><el-checkbox v-model="replyAnonymous[comment.id]">匿名回复</el-checkbox><el-button type="primary" size="small" @click="reply(comment)">回复</el-button></div></div></li></ol>
<div v-if="hasMore" class="more"><el-button :loading="loading" @click="load()">加载更多评论</el-button></div>
</section>
</template>
+24 -6
View File
@@ -27,6 +27,10 @@ const options = reactive({
classrooms: [] as any[],
teachers: [] as any[],
periods: [] as any[],
taskTotal: 0,
tasksTruncated: false,
scheduleEntryTotal: 0,
scheduleEntriesTruncated: false,
})
const modeFilter = ref('')
const statusFilter = ref('')
@@ -83,6 +87,9 @@ const proxyBookingStudents = ref<any[]>([])
const proxyBookingLoading = ref(false)
const proxyBookingKeyword = ref('')
const proxyBookingStudentIds = ref<string[]>([])
const proxyBookingPage = ref(1)
const proxyBookingPageSize = 20
const proxyBookingTotal = ref(0)
const selectedTask = computed(() =>
options.tasks.find((task) => task.id === projectForm.teachingTaskIds[0]),
@@ -618,14 +625,18 @@ async function showParticipants(project: any, session: any) {
}
}
async function loadProxyBookingStudents() {
async function loadProxyBookingStudents(page = proxyBookingPage.value) {
if (!participantSession.value) return
proxyBookingPage.value = page
proxyBookingStudentIds.value = []
proxyBookingLoading.value = true
try {
proxyBookingStudents.value = (await http.get(
const { data } = await http.get(
`/experiments/sessions/${participantSession.value.id}/eligible-students`,
{ params: { keyword: proxyBookingKeyword.value || undefined } },
)).data
{ params: { keyword: proxyBookingKeyword.value || undefined, page, pageSize: proxyBookingPageSize } },
)
proxyBookingStudents.value = data.items
proxyBookingTotal.value = data.total
} catch (error) {
proxyBookingStudents.value = []
ElMessage.error(apiErrorMessage(error))
@@ -637,6 +648,7 @@ async function loadProxyBookingStudents() {
async function openProxyBooking() {
proxyBookingStudentIds.value = []
proxyBookingKeyword.value = ''
proxyBookingPage.value = 1
proxyBookingDialog.value = true
await loadProxyBookingStudents()
}
@@ -719,8 +731,12 @@ async function loadOptions() {
},
})
options.tasks = data.tasks
options.taskTotal = data.taskTotal
options.tasksTruncated = data.tasksTruncated
options.colleges = data.colleges
options.scheduleEntries = data.scheduleEntries
options.scheduleEntryTotal = data.scheduleEntryTotal
options.scheduleEntriesTruncated = data.scheduleEntriesTruncated
options.classrooms = data.classrooms
options.teachers = data.teachers
options.periods = data.periods
@@ -1117,6 +1133,7 @@ onMounted(async () => {
/>
<div class="form-section">
<header><span>PROJECT</span><b>规定实验项目</b></header>
<el-alert v-if="options.tasksTruncated || options.scheduleEntriesTruncated" type="warning" :closable="false" show-icon title="匹配结果较多,请使用开课学院和课程名称/代码缩小范围后再选择;系统不会把截断后的列表当作完整数据。" />
<el-form-item v-if="editingProjectId && projectForm.arrangementMode === 'Centralized'" label="已发布课表中的实验课" required>
<el-select v-model="projectForm.scheduleEntryId" filterable :disabled="!!editingProjectId" placeholder="选择已安排实验室的实验课" @change="onScheduleEntryChange">
<el-option
@@ -1515,8 +1532,8 @@ onMounted(async () => {
show-icon
/>
<div class="proxy-booking-search">
<el-input v-model="proxyBookingKeyword" clearable placeholder="输入学号、姓名或行政班" @keyup.enter="loadProxyBookingStudents" />
<el-button @click="loadProxyBookingStudents">查询</el-button>
<el-input v-model="proxyBookingKeyword" clearable placeholder="输入学号、姓名或行政班" @keyup.enter="loadProxyBookingStudents(1)" />
<el-button @click="loadProxyBookingStudents(1)">查询</el-button>
</div>
<el-table
v-loading="proxyBookingLoading"
@@ -1529,6 +1546,7 @@ onMounted(async () => {
<el-table-column prop="name" label="姓名" min-width="100" />
<el-table-column prop="className" label="行政班" min-width="180" />
</el-table>
<el-pagination v-if="proxyBookingTotal > proxyBookingPageSize" background :current-page="proxyBookingPage" :page-size="proxyBookingPageSize" :total="proxyBookingTotal" layout="total, prev, pager, next" @current-change="loadProxyBookingStudents" />
<el-empty v-if="!proxyBookingLoading && !proxyBookingStudents.length" description="没有可代选的学生" />
<template #footer>
<el-button @click="proxyBookingDialog = false">取消</el-button>
+14 -1
View File
@@ -72,6 +72,8 @@ interface GradeAnalyticsComment {
hasInsightful: boolean
hasAgreed: boolean
replies?: GradeAnalyticsComment[]
repliesHasMore?: boolean
repliesNextCursor?: { createdAt: string; id: string }
}
const terms = ref<any[]>([])
@@ -438,10 +440,20 @@ async function toggleReaction(comment: GradeAnalyticsComment, type: 'Like' | 'In
async function toggleReplies(comment: GradeAnalyticsComment) {
replyOpen[comment.id] = !replyOpen[comment.id]
if (!replyOpen[comment.id] || comment.replies) return
await loadReplies(comment, true)
}
async function loadReplies(comment: GradeAnalyticsComment, reset = false) {
const courseId = commentCourseId.value
if (!courseId) return
replyLoading[comment.id] = true
try { comment.replies = (await http.get(`/grade-analytics/courses/${courseId}/comments/${comment.id}/replies`)).data.items }
try {
const cursor = reset ? undefined : comment.repliesNextCursor
const data = (await http.get(`/grade-analytics/courses/${courseId}/comments/${comment.id}/replies`, { params: cursor ? { afterCreatedAt: cursor.createdAt, afterId: cursor.id } : undefined })).data
comment.replies = reset ? data.items : [...(comment.replies ?? []), ...data.items]
comment.repliesHasMore = data.hasMore
comment.repliesNextCursor = data.nextCursor ?? undefined
}
catch (error) { ElMessage.error(apiErrorMessage(error)) }
finally { replyLoading[comment.id] = false }
}
@@ -880,6 +892,7 @@ onBeforeUnmount(() => {
</div>
<div v-if="replyOpen[comment.id]" class="reply-panel" v-loading="replyLoading[comment.id]">
<ol v-if="comment.replies?.length" class="reply-list"><li v-for="reply in comment.replies" :key="reply.id"><div class="comment-meta"><strong>{{ reply.authorName }}</strong><span v-if="reply.isAnonymous">匿名</span><time>{{ new Date(reply.createdAt).toLocaleString('zh-CN') }}</time></div><p>{{ reply.content }}</p><el-button v-if="reply.canDelete" text type="danger" size="small" @click="deleteComment(reply)">删除</el-button></li></ol>
<el-button v-if="comment.repliesHasMore" text size="small" :loading="replyLoading[comment.id]" @click="loadReplies(comment)">加载更多回复</el-button>
<el-input v-model="replyDrafts[comment.id]" type="textarea" :rows="2" maxlength="1000" show-word-limit placeholder="回复这条评论" />
<div class="reply-compose"><el-checkbox v-model="replyAnonymous[comment.id]">匿名回复</el-checkbox><el-button type="primary" size="small" @click="submitReply(comment)">回复</el-button></div>
</div>
Loaded 3 of 8 files, more files were not shown because too many files have changed in this diff. Show more