新增本周直接查询按钮,所选范围自动分批读取并校验总数、重复与游标完整性;删除手动加载更多,固定展示完整字段,空列不隐藏,不伪造译文或评估。 验证:全量、固定列及本周入口回归先红后绿;完整make verify通过,前端273通过;真实只读源浏览器默认及快捷查询均639条全部唯一展示,14必需字段按序,右侧字段可达、手机无外溢、JS异常0。无新增迁移或源库写入。
This commit is contained in:
+34
-1
@@ -259,6 +259,35 @@ export async function fetchQARecords(query: QAQuery, signal?: AbortSignal): Prom
|
||||
})
|
||||
return parseQARecordPage(await getPayload(`/api/v1/qa-ops/records?${parameters}`, signal))
|
||||
}
|
||||
export async function fetchAllQARecords(
|
||||
query: QAQuery,
|
||||
signal?: AbortSignal,
|
||||
onProgress?: (loaded: number, total: number) => void
|
||||
): Promise<QARecordPage> {
|
||||
if (signal?.aborted) throw new DOMException('读取已取消', 'AbortError')
|
||||
let page = await fetchQARecords({ ...query, cursor: '', limit: 100 }, signal)
|
||||
const total = page.total
|
||||
const ids = new Set(page.items.map((item) => item.id))
|
||||
const cursors = new Set<string>()
|
||||
onProgress?.(ids.size, total)
|
||||
while (page.has_more) {
|
||||
if (signal?.aborted) throw new DOMException('读取已取消', 'AbortError')
|
||||
const cursor = page.next_cursor
|
||||
if (cursors.has(cursor) || ids.size >= total) throw new Error('全量读取游标异常,请重新查询')
|
||||
cursors.add(cursor)
|
||||
const next = await fetchQARecords({ ...query, cursor, limit: 100 }, signal)
|
||||
if (next.total !== total) throw new Error('查询总数已变化,请重新查询,未将部分记录当作全部结果')
|
||||
for (const item of next.items) {
|
||||
if (ids.has(item.id)) throw new Error('全量读取出现重复记录,请重新查询')
|
||||
ids.add(item.id)
|
||||
}
|
||||
page = mergeQAPages(page, next)
|
||||
onProgress?.(ids.size, total)
|
||||
}
|
||||
if (ids.size !== total) throw new Error('全量读取数量不完整,请重试,未将部分记录当作全部结果')
|
||||
return page
|
||||
}
|
||||
|
||||
export async function fetchQARecord(id: string, signal?: AbortSignal): Promise<QARecord> {
|
||||
return parseQARecord(await getPayload(`/api/v1/qa-ops/records/${encodeURIComponent(id)}`, signal))
|
||||
}
|
||||
@@ -283,6 +312,9 @@ export async function fetchQAStatus(signal?: AbortSignal): Promise<QAStatus> {
|
||||
}
|
||||
|
||||
export function qaCellValue(item: QARecord, column: QAColumn): string | null {
|
||||
if (column === 'question_chinese')
|
||||
return item.question_chinese || (/\p{Script=Han}/u.test(item.question) ? item.question : '待翻译')
|
||||
if (column === 'language') return item.language || '未识别'
|
||||
const f = item.quality?.effective
|
||||
if (f) {
|
||||
if (column === 'coverage')
|
||||
@@ -309,6 +341,7 @@ export function qaCellValue(item: QARecord, column: QAColumn): string | null {
|
||||
if (item.feedback.up || item.feedback.down) return `其他人:赞 ${item.feedback.up} / 踩 ${item.feedback.down}`
|
||||
return null
|
||||
}
|
||||
if (column === 'asked_at') return new Date(item.asked_at).toLocaleString('zh-CN', { hour12: false })
|
||||
if (column === 'asked_at')
|
||||
return new Date(item.asked_at).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai', hour12: false })
|
||||
return item[column] || null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user