后台八个列表(题目、比赛、用户、公告、题单、AI 报告、从题库加题、标签下的题)原来是 `const res = await getXxx(); rows.value = res.results`:接口 500 或断网时什么都不提示, 表格停在旧数据上;关键词防抖和翻页一交错,先发的晚回来会把新结果盖掉。 shared/composables/listLoader.ts 的 track() 把请求包一层:带请求序号、出错按后端文案提示 (登录过期、没权限这几种全局拦截器已经提示过,不弹第二遍)、表格挂 loading。 实跑:六个列表各 10 行正常;拦掉题目列表的接口再翻页,弹「网络异常,请检查网络后重试」 (原来没有任何反应)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4dfd14f95b
commit
d4aadc7722
10 files changed
+122
-27
No files matched your search
@@ -18,6 +18,7 @@ import { downloadAccountsCsv } from "./accountsCsv"
|
||||
import { classLabel, groupClassOptions } from "utils/classes"
|
||||
import { useConfigStore } from "shared/store/config"
|
||||
import { useBreakpoints } from "shared/composables/breakpoints"
|
||||
import { useListLoader } from "shared/composables/listLoader"
|
||||
|
||||
/**
|
||||
* 后台用户列表(设计稿「后台用户与批量建号」UsList)。老师进来多半是三件事:学生忘了密码、
|
||||
@@ -203,17 +204,14 @@ const problemPermissionOptions: SelectOption[] = [
|
||||
// 老师不给「无权限」:比赛题的接口要出题权限,设了就是比赛题目页全报权限不足,后端也会兜成「仅自己」
|
||||
const teacherPermissionOptions = problemPermissionOptions.slice(1)
|
||||
|
||||
const { loading, track } = useListLoader()
|
||||
async function listUsers() {
|
||||
if (query.page < 1) query.page = 1
|
||||
const offset = (query.page - 1) * query.limit
|
||||
const res = await getUserList(
|
||||
offset,
|
||||
query.limit,
|
||||
query.type,
|
||||
query.keyword,
|
||||
query.orderBy,
|
||||
query.className,
|
||||
const res = await track(
|
||||
getUserList(offset, query.limit, query.type, query.keyword, query.orderBy, query.className),
|
||||
)
|
||||
if (!res) return
|
||||
total.value = res.total
|
||||
neverLoggedIn.value = res.neverLoggedIn
|
||||
users.value = res.results
|
||||
@@ -427,6 +425,7 @@ watch(() => [query.page, query.limit, query.type, query.orderBy, query.className
|
||||
</template>
|
||||
</PageHeader>
|
||||
<n-data-table
|
||||
:loading="loading"
|
||||
striped
|
||||
class="user-table"
|
||||
:data="users"
|
||||
|
||||
Reference in new issue
Block a user