fix: 修复课程库加载 - 后端限制每页最多100条
All checks were successful
continuous-integration/drone/push Build is passing

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yuliang_guo
2026-02-03 15:12:34 +08:00
parent 344d8c1770
commit 7555de2275

View File

@@ -662,8 +662,27 @@ const loadPositions = async () => {
const loadCourses = async () => { const loadCourses = async () => {
coursesLoading.value = true coursesLoading.value = true
try { try {
const res = await getManagerCourses({ page: 1, size: 500 }) // 后端限制每页最多100条需要分页获取所有课程
courses.value = res.data?.items || res.items || [] let allCourses: Course[] = []
let page = 1
const pageSize = 100
let hasMore = true
while (hasMore) {
const res = await getManagerCourses({ page, size: pageSize })
const items = res.data?.items || res.items || []
allCourses = [...allCourses, ...items]
// 检查是否还有更多数据
const total = res.data?.total || res.total || 0
hasMore = allCourses.length < total && items.length === pageSize
page++
// 安全限制最多获取10页1000门课程
if (page > 10) break
}
courses.value = allCourses
} catch (error) { } catch (error) {
console.error('加载课程失败:', error) console.error('加载课程失败:', error)
} finally { } finally {