fix(phase-5.2): 消项 CR 第二轮 P1/P2/P3(通道/证据链/交付时序/后管证据页)
This commit is contained in:
@@ -1,38 +1,172 @@
|
||||
import { http, unwrap } from '@/api/http'
|
||||
|
||||
/** 大档分片阈值(AC-11):8MB 以上不再一次 PUT 直传,断点续传由服务端 chunk 通道承担。 */
|
||||
export const CHUNK_UPLOAD_THRESHOLD = 8 * 1024 * 1024
|
||||
/**
|
||||
* 大档分片阈值与片大小(AC-11):后管这一侧只有这一个出口,阈值由片大小派生。
|
||||
*
|
||||
* ⚠ 同族的 8MB 数还另有两处:用户端上传出口一处、桌面客户端分片入口一处。两边是各自
|
||||
* 独立的构建根(各自的 `@` 别名与 tsconfig include),客户端是 Python 打包物 ⇒
|
||||
* 没有共享包就合不成同一个字面量(P3-5 的边界,已登记)。
|
||||
*/
|
||||
export const CHUNK_UPLOAD_PART_SIZE = 8 * 1024 * 1024
|
||||
export const CHUNK_UPLOAD_THRESHOLD = CHUNK_UPLOAD_PART_SIZE
|
||||
|
||||
/** 每片重试次数(不含首次):单片 502/超时不该让 512MB 从 0 再来。 */
|
||||
const PART_RETRY_LIMIT = 2
|
||||
|
||||
/**
|
||||
* 逐片超时(P2-8):预算只看**这一片**有多大——60s 保底 + 每 MB 30s(8MB 片=300s)。
|
||||
* 过去按整包体积算(120s + MB×15s),512MB 包里的一个 8MB 片能拿到 128 分钟,
|
||||
* 慢链路真卡死时没人知道,进度条还会一直爬。
|
||||
*/
|
||||
export function partTimeoutOf(partBytes: number): number {
|
||||
return 60_000 + Math.ceil(partBytes / (1024 * 1024)) * 30_000
|
||||
}
|
||||
|
||||
/** 会话登记/查询只发元数据,固定预算即可;失败要快快回来,别陪整包一起放大。 */
|
||||
const REQUEST_TIMEOUT_MS = 60_000
|
||||
/** 只有拼装这一步真随整包体积走:服务端要读全部分片、复算 sha256。 */
|
||||
const COMPLETE_TIMEOUT_MS = 600_000
|
||||
|
||||
function partUrl(uploadId: string, index: number): string {
|
||||
return `/api/files/chunk/${encodeURIComponent(uploadId)}/part/${index}`
|
||||
}
|
||||
|
||||
/** 后管大档上传(版本包/教程包共用):init → GET 已达片号 → 逐片 POST → complete。 */
|
||||
/** 分片会话跨尝试/刷新续用:同一文件身份复用 upload_id,服务端没回收就从已达片号继续(P2-7)。 */
|
||||
interface StoredChunkSession {
|
||||
uploadId: string;
|
||||
size: number;
|
||||
lastModified: number;
|
||||
}
|
||||
|
||||
const CHUNK_SESSION_PREFIX = 'shufu:admin:chunk:'
|
||||
|
||||
function lastModifiedOf(file: Blob): number {
|
||||
const value = (file as File).lastModified
|
||||
return typeof value === 'number' && Number.isFinite(value) ? value : 0
|
||||
}
|
||||
|
||||
/** 会话键:文件名+体积+修改时间,三者同一条上传才算同一个件。 */
|
||||
export function chunkSessionKeyOf(fileName: string, file: Blob): string {
|
||||
return `${CHUNK_SESSION_PREFIX}${fileName}:${file.size}:${lastModifiedOf(file)}`
|
||||
}
|
||||
|
||||
function readStoredSession(key: string, file: Blob): string {
|
||||
if (typeof localStorage === 'undefined') return ''
|
||||
try {
|
||||
const raw = localStorage.getItem(key)
|
||||
if (!raw) return ''
|
||||
const parsed = JSON.parse(raw) as StoredChunkSession
|
||||
return parsed.size === file.size && parsed.lastModified === lastModifiedOf(file) ? parsed.uploadId : ''
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function writeStoredSession(key: string, file: Blob, uploadId: string): void {
|
||||
if (typeof localStorage === 'undefined') return
|
||||
try {
|
||||
localStorage.setItem(key, JSON.stringify({
|
||||
uploadId, size: file.size, lastModified: lastModifiedOf(file),
|
||||
} satisfies StoredChunkSession))
|
||||
} catch {
|
||||
// 存储不可用(隐私模式/配额满)只影响跨刷新续传,不影响本次上传
|
||||
}
|
||||
}
|
||||
|
||||
function clearStoredSession(key: string): void {
|
||||
if (typeof localStorage === 'undefined') return
|
||||
try {
|
||||
localStorage.removeItem(key)
|
||||
} catch {
|
||||
// 同上:清不掉只会让下次多问一次 status
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务端对「这个会话还在不在」的三种答复:还在(附带已到片号)/确实没了/问不出来。
|
||||
* 第三态是 P2-7 与 P1-11 的共同判据——过去它被当成"没会话",瞬态抖动=整包作废。
|
||||
*/
|
||||
type ProbeOutcome
|
||||
= { state: 'ok'; parts: number[] }
|
||||
| { state: 'gone' }
|
||||
| { state: 'transient' }
|
||||
|
||||
/** 后端回收会话的原文案(ChunkedUploadService.readMeta);BusinessException 不带 code ⇒ HTTP 200 出。 */
|
||||
function messageSaysSessionGone(text: unknown): boolean {
|
||||
const message = typeof text === 'string' ? text : ''
|
||||
return ['不存在', '过期'].some((marker) => message.includes(marker))
|
||||
}
|
||||
|
||||
function classifyProbe(response: unknown): ProbeOutcome {
|
||||
const status = Number((response as { status?: unknown } | null | undefined)?.status)
|
||||
if (status === 404) return { state: 'gone' }
|
||||
if (status >= 500 || status === 408 || status === 429) return { state: 'transient' }
|
||||
const body = (response as { data?: unknown } | null | undefined)?.data
|
||||
if (body && typeof body === 'object' && (body as { success?: unknown }).success === false) {
|
||||
return messageSaysSessionGone((body as { message?: unknown }).message)
|
||||
? { state: 'gone' }
|
||||
: { state: 'transient' }
|
||||
}
|
||||
const core = (unwrap<Record<string, unknown>>(body) ?? {}) as Record<string, unknown>
|
||||
const arrived = core.uploaded_parts
|
||||
return { state: 'ok', parts: Array.isArray(arrived) ? arrived.map((value) => Number(value)) : [] }
|
||||
}
|
||||
|
||||
/**
|
||||
* 探测已达片号(P2-7/与用户端 upload.ts 同一口径)。
|
||||
* validateStatus 恒真:状态码要自己判——真 404/5xx 一旦被拦截器折成 Error 就分不出原因了;
|
||||
* 能走到 catch 的就只剩网络层失败与超时,铁定瞬态。
|
||||
*/
|
||||
async function probeUploadedParts(uploadId: string): Promise<ProbeOutcome> {
|
||||
try {
|
||||
const response = await http.get(
|
||||
`/api/files/chunk/${encodeURIComponent(uploadId)}`,
|
||||
{ validateStatus: () => true },
|
||||
)
|
||||
return classifyProbe(response)
|
||||
} catch (error) {
|
||||
const status = (error as { response?: { status?: unknown } } | null | undefined)?.response?.status
|
||||
if (status === 404) return { state: 'gone' }
|
||||
if (messageSaysSessionGone((error as { message?: unknown } | null | undefined)?.message)) {
|
||||
return { state: 'gone' }
|
||||
}
|
||||
return { state: 'transient' }
|
||||
}
|
||||
}
|
||||
|
||||
/** 后管大档上传(版本包/教程包共用):会话续用 → GET 已达片号 → 逐片 POST → complete。 */
|
||||
export async function uploadFileInChunks(
|
||||
file: Blob,
|
||||
fileName: string,
|
||||
onProgress?: (percent: number) => void,
|
||||
): Promise<Record<string, unknown>> {
|
||||
const totalParts = Math.max(1, Math.ceil(file.size / CHUNK_UPLOAD_PART_SIZE))
|
||||
const initResponse = await http.post('/api/files/chunk/init', null, {
|
||||
params: { fileName, totalParts, totalBytes: file.size },
|
||||
timeout: 120_000 + Math.ceil(file.size / (1024 * 1024)) * 15_000,
|
||||
})
|
||||
const init = (unwrap(initResponse.data) ?? {}) as Record<string, unknown>
|
||||
const uploadId = String(init.upload_id ?? '')
|
||||
if (!uploadId) {
|
||||
throw new Error('后端未返回分片会话,请重试')
|
||||
const sessionKey = chunkSessionKeyOf(fileName, file)
|
||||
let uploadId = readStoredSession(sessionKey, file)
|
||||
const arrived = new Set<number>()
|
||||
if (uploadId) {
|
||||
const probed = await probeUploadedParts(uploadId)
|
||||
if (probed.state === 'gone') {
|
||||
// 服务端确实说会话没了(404/「不存在或已过期」):清掉重开,否则这个件每次都在同一个死会话上失败。
|
||||
clearStoredSession(sessionKey)
|
||||
uploadId = ''
|
||||
} else if (probed.state === 'ok') {
|
||||
probed.parts.forEach((index) => arrived.add(index))
|
||||
}
|
||||
// transient:片号未知但会话还在 ⇒ 照原会话逐片重传(后端同片覆盖,幂等),不重开 init。
|
||||
}
|
||||
if (!uploadId) {
|
||||
const initResponse = await http.post('/api/files/chunk/init', null, {
|
||||
params: { fileName, totalParts, totalBytes: file.size },
|
||||
timeout: REQUEST_TIMEOUT_MS,
|
||||
})
|
||||
const init = (unwrap(initResponse.data) ?? {}) as Record<string, unknown>
|
||||
uploadId = String(init.upload_id ?? '')
|
||||
if (!uploadId) {
|
||||
throw new Error('后端未返回分片会话,请重试')
|
||||
}
|
||||
writeStoredSession(sessionKey, file, uploadId)
|
||||
}
|
||||
|
||||
const statusResponse = await http.get(`/api/files/chunk/${encodeURIComponent(uploadId)}`)
|
||||
const status = (unwrap(statusResponse.data) ?? {}) as Record<string, unknown>
|
||||
const arrived = new Set<number>(
|
||||
Array.isArray(status.uploaded_parts) ? status.uploaded_parts.map((value) => Number(value)) : [],
|
||||
)
|
||||
|
||||
for (let index = 0; index < totalParts; index += 1) {
|
||||
if (arrived.has(index)) {
|
||||
@@ -47,7 +181,7 @@ export async function uploadFileInChunks(
|
||||
try {
|
||||
const partResponse = await http.post(partUrl(uploadId, index), form, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
timeout: 120_000 + Math.ceil(file.size / (1024 * 1024)) * 15_000,
|
||||
timeout: partTimeoutOf(blob.size),
|
||||
onUploadProgress: (event) => {
|
||||
if (!onProgress) return
|
||||
const perPart = Math.round(((index + (event.loaded || 0) / Math.max(blob.size, 1)) / totalParts) * 100)
|
||||
@@ -63,14 +197,15 @@ export async function uploadFileInChunks(
|
||||
}
|
||||
}
|
||||
if (lastError) {
|
||||
// 后管上传是一次性的:放弃时把会话连同临时片一起清掉,不留 24h 残盘。
|
||||
await http.delete(`/api/files/chunk/${encodeURIComponent(uploadId)}`).catch(() => undefined)
|
||||
// 不 DELETE(P2-7):会话连同已达片号留在服务端(后端 24h 过期回收兜底),
|
||||
// 下一次点开同一个文件就从断点接着传——这才是"续传"两个字的本义。
|
||||
throw lastError instanceof Error ? lastError : new Error('分片上传失败')
|
||||
}
|
||||
}
|
||||
|
||||
const completeResponse = await http.post(
|
||||
`/api/files/chunk/${encodeURIComponent(uploadId)}/complete`, null, { timeout: 600_000 })
|
||||
`/api/files/chunk/${encodeURIComponent(uploadId)}/complete`, null, { timeout: COMPLETE_TIMEOUT_MS })
|
||||
clearStoredSession(sessionKey)
|
||||
if (onProgress) onProgress(100)
|
||||
return (unwrap(completeResponse.data) ?? {}) as Record<string, unknown>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import { http } from './http'
|
||||
import { unwrap } from './envelope'
|
||||
|
||||
/** 任务证据件列表行(AC-13:后管只读面,仅超级管理员)。 */
|
||||
export interface TaskEvidenceRow {
|
||||
id: number
|
||||
taskId: string
|
||||
uid: number | null
|
||||
evidenceType: string
|
||||
source: string
|
||||
objectKey: string
|
||||
byteSize: number
|
||||
contentType: string
|
||||
sha256: string
|
||||
createdAt: string | null
|
||||
}
|
||||
|
||||
export interface TaskEvidencePage {
|
||||
items: TaskEvidenceRow[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
export interface TaskEvidenceQuery {
|
||||
taskId?: string
|
||||
uid?: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
export interface TaskEvidenceContent {
|
||||
id: number
|
||||
taskId: string
|
||||
contentType: string
|
||||
binary: boolean
|
||||
content: string
|
||||
}
|
||||
|
||||
export async function fetchTaskEvidenceFiles(params: TaskEvidenceQuery): Promise<TaskEvidencePage> {
|
||||
const query: Record<string, string | number> = { page: params.page, pageSize: params.pageSize }
|
||||
if (params.taskId) query.taskId = params.taskId
|
||||
if (params.uid) query.uid = params.uid
|
||||
const { data } = await http.get('/api/admin/task-evidence/files', { params: query })
|
||||
return unwrap<TaskEvidencePage>(data)
|
||||
}
|
||||
|
||||
export async function fetchTaskEvidenceContent(fileId: number): Promise<TaskEvidenceContent> {
|
||||
const { data } = await http.get('/api/admin/task-evidence/content', { params: { fileId } })
|
||||
return unwrap<TaskEvidenceContent>(data)
|
||||
}
|
||||
|
||||
/** 下载走服务端流,不把对象直链/预签名 URL 交给浏览器(AC-13 的不入日志口径)。 */
|
||||
export function taskEvidenceDownloadUrl(fileId: number): string {
|
||||
return `/api/admin/task-evidence/download?fileId=${fileId}`
|
||||
}
|
||||
|
||||
export async function deleteTaskEvidence(ids: number[]): Promise<number> {
|
||||
const { data } = await http.post('/api/admin/task-evidence/delete', ids)
|
||||
return unwrap<{ deleted: number }>(data).deleted
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
* 而护栏用例要从这里反过来读注册表,放在一起会成环。 */
|
||||
|
||||
/** 角色内在闸门:只有超管可见可读写,与 user_column_permission 无关。 */
|
||||
export const SUPER_ADMIN_ONLY_MENU_KEYS: readonly string[] = ['admin_companies']
|
||||
export const SUPER_ADMIN_ONLY_MENU_KEYS: readonly string[] = ['admin_companies', 'admin_task_evidence']
|
||||
|
||||
export interface CompanyScopedPage {
|
||||
/** 与 routes.ts 的 menuKey 逐字一致。 */
|
||||
|
||||
@@ -109,6 +109,10 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
||||
text: '桌面客户端与麦象采集机上报的日志按来源、日期和关键字筛选;可查看日志尾部、下载完整文件或删除云端记录,云端日志按保留期自动清理。',
|
||||
steps: ['选择来源与日期', '查看或下载日志', '必要时删除'],
|
||||
},
|
||||
admin_task_evidence: {
|
||||
text: '任务异常现场件与窗口图按任务号关联;只有超级管理员能读取与下载,对象直链不出服务端,证据件按保留期自动清理。',
|
||||
steps: ['按任务号或 uid 查询', '查看现场件或窗口图', '下载或清理过期证据'],
|
||||
},
|
||||
admin_user_secret_usage: {
|
||||
text: '按日期范围统计各用户的密钥调用次数(货源查询与外观专利按 LLM 请求次数、代理按提取次数),用于评估用户资源损耗。',
|
||||
steps: ['选择日期范围', '筛选用户或分组', '核对各模块次数'],
|
||||
|
||||
@@ -9,6 +9,7 @@ import { fetchSoftwareVersions, uploadSoftwareVersion, deleteSoftwareVersions }
|
||||
import type { SoftwareVersionItem } from './version-dto.ts'
|
||||
import { isNonEmptyVersion } from './version-dto.ts'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { loadFailureMessage } from '@/components/load-failure-model'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
@@ -62,7 +63,7 @@ async function removeSelected() {
|
||||
selectedIds.value = new Set()
|
||||
await load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
showAdminFeedback(loadFailureMessage(error, '删除失败'), 'error')
|
||||
}
|
||||
}
|
||||
async function removeOne(row: SoftwareVersionItem) {
|
||||
@@ -73,7 +74,7 @@ async function removeOne(row: SoftwareVersionItem) {
|
||||
selectedIds.value = new Set([...selectedIds.value].filter((id) => id !== row.id))
|
||||
await load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
showAdminFeedback(loadFailureMessage(error, '删除失败'), 'error')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +93,7 @@ async function load() {
|
||||
try {
|
||||
items.value = (await fetchSoftwareVersions()).items
|
||||
} catch (error) {
|
||||
loadFailure.value = error instanceof Error ? error.message : '版本列表加载失败'
|
||||
loadFailure.value = loadFailureMessage(error, '版本列表加载失败')
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -146,7 +147,8 @@ async function submitUpload() {
|
||||
uploadPercent.value = 0
|
||||
load()
|
||||
} catch (error) {
|
||||
uploadMsg.value = error instanceof Error ? error.message : '上传失败'
|
||||
// P2-10:api/http 拦截器不 sanitize,error.message 可能是英文异常原文——界面只吃中文出口,原文进 console。
|
||||
uploadMsg.value = loadFailureMessage(error, '上传失败')
|
||||
} finally {
|
||||
uploading.value = false
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { fetchTutorialPackages, uploadTutorialPackage, deleteTutorialPackages }
|
||||
import { formatFileSize } from './tutorial-model.ts'
|
||||
import type { TutorialPackageItem } from './tutorial-dto.ts'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { loadFailureMessage } from '@/components/load-failure-model'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
@@ -119,7 +120,7 @@ async function removeSelected() {
|
||||
selectedIds.value = new Set()
|
||||
await load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
showAdminFeedback(loadFailureMessage(error, '删除失败'), 'error')
|
||||
}
|
||||
}
|
||||
async function removeOne(row: TutorialPackageItem) {
|
||||
@@ -130,7 +131,7 @@ async function removeOne(row: TutorialPackageItem) {
|
||||
selectedIds.value = new Set([...selectedIds.value].filter((id) => id !== row.id))
|
||||
await load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
showAdminFeedback(loadFailureMessage(error, '删除失败'), 'error')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +150,7 @@ async function load() {
|
||||
try {
|
||||
items.value = (await fetchTutorialPackages()).items
|
||||
} catch (error) {
|
||||
loadFailure.value = error instanceof Error ? error.message : '教程包列表加载失败'
|
||||
loadFailure.value = loadFailureMessage(error, '教程包列表加载失败')
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -198,7 +199,8 @@ async function submitUpload() {
|
||||
uploadPercent.value = 0
|
||||
load()
|
||||
} catch (error) {
|
||||
uploadMsg.value = error instanceof Error ? error.message : '上传失败'
|
||||
// P2-10:api/http 拦截器不 sanitize,error.message 可能是英文异常原文——界面只吃中文出口,原文进 console。
|
||||
uploadMsg.value = loadFailureMessage(error, '上传失败')
|
||||
} finally {
|
||||
uploading.value = false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 任务证据件(R3「后管可视」):按 taskId / uid 关联查看异常现场件与窗口图。
|
||||
* 读取面在服务端逐个方法走 requireSuperAdmin;本页只消费服务端流,不接触对象直链。
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import {
|
||||
deleteTaskEvidence,
|
||||
fetchTaskEvidenceContent,
|
||||
fetchTaskEvidenceFiles,
|
||||
taskEvidenceDownloadUrl,
|
||||
} from '@/api/task-evidence'
|
||||
import type { TaskEvidenceRow } from '@/api/task-evidence'
|
||||
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const items = ref<TaskEvidenceRow[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(20)
|
||||
const taskIdFilter = ref('')
|
||||
const uidFilter = ref('')
|
||||
const selectedIds = ref<Set<number>>(new Set())
|
||||
const selectedCount = computed(() => selectedIds.value.size)
|
||||
|
||||
const previewVisible = ref(false)
|
||||
const previewLoading = ref(false)
|
||||
const previewRow = ref<TaskEvidenceRow | null>(null)
|
||||
const previewText = ref('')
|
||||
const previewImage = ref('')
|
||||
|
||||
function imageOf(row: TaskEvidenceRow, content: string): string {
|
||||
return `data:${row.contentType || 'image/png'};base64,${content}`
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
loadFailure.value = ''
|
||||
try {
|
||||
const uid = uidFilter.value.trim() ? Number(uidFilter.value.trim()) : undefined
|
||||
const data = await fetchTaskEvidenceFiles({
|
||||
taskId: taskIdFilter.value.trim() || undefined,
|
||||
uid: Number.isFinite(uid) && (uid || 0) > 0 ? uid : undefined,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
})
|
||||
items.value = data.items
|
||||
total.value = data.total
|
||||
} catch (error) {
|
||||
loadFailure.value = error instanceof Error ? error.message : '任务证据件加载失败'
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function search() {
|
||||
page.value = 1
|
||||
selectedIds.value = new Set()
|
||||
load()
|
||||
}
|
||||
|
||||
function changePage(next: number) {
|
||||
page.value = next
|
||||
load()
|
||||
}
|
||||
|
||||
function changeSize(size: number) {
|
||||
pageSize.value = size
|
||||
page.value = 1
|
||||
load()
|
||||
}
|
||||
|
||||
function toggleSelect(id: number) {
|
||||
const next = new Set(selectedIds.value)
|
||||
if (next.has(id)) next.delete(id)
|
||||
else next.add(id)
|
||||
selectedIds.value = next
|
||||
}
|
||||
|
||||
function toggleSelectAllPage() {
|
||||
const allOn = items.value.length > 0 && items.value.every((row) => selectedIds.value.has(row.id))
|
||||
const next = new Set(selectedIds.value)
|
||||
if (allOn) items.value.forEach((row) => next.delete(row.id))
|
||||
else items.value.forEach((row) => next.add(row.id))
|
||||
selectedIds.value = next
|
||||
}
|
||||
|
||||
async function removeSelected() {
|
||||
if (!selectedCount.value) return
|
||||
try {
|
||||
const deleted = await deleteTaskEvidence(Array.from(selectedIds.value))
|
||||
showAdminFeedback(`已删除 ${deleted} 份证据件`, 'success')
|
||||
selectedIds.value = new Set()
|
||||
await load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除证据件失败', 'error')
|
||||
}
|
||||
}
|
||||
|
||||
async function openPreview(row: TaskEvidenceRow) {
|
||||
previewRow.value = row
|
||||
previewVisible.value = true
|
||||
previewLoading.value = true
|
||||
previewText.value = ''
|
||||
previewImage.value = ''
|
||||
try {
|
||||
const content = await fetchTaskEvidenceContent(row.id)
|
||||
if (content.binary) previewImage.value = imageOf(row, content.content)
|
||||
else previewText.value = content.content
|
||||
} catch (error) {
|
||||
previewText.value = error instanceof Error ? error.message : '证据件读取失败'
|
||||
} finally {
|
||||
previewLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function closePreview() {
|
||||
previewVisible.value = false
|
||||
previewRow.value = null
|
||||
previewText.value = ''
|
||||
previewImage.value = ''
|
||||
}
|
||||
|
||||
function kindLabel(row: TaskEvidenceRow): string {
|
||||
if (row.contentType?.startsWith('image/')) return '窗口/页面图'
|
||||
return row.evidenceType || '证据件'
|
||||
}
|
||||
|
||||
watch([taskIdFilter, uidFilter], () => {
|
||||
// 过滤条件改了不自动打请求,避免一次输入打满接口;按「查询」或回车再取。
|
||||
})
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="evidence-view">
|
||||
<section class="panel-box">
|
||||
<div class="evidence-head">
|
||||
<h3>任务证据件</h3>
|
||||
<div class="evidence-tools">
|
||||
<input
|
||||
v-model="taskIdFilter"
|
||||
type="text"
|
||||
class="evidence-input"
|
||||
placeholder="按任务号筛选"
|
||||
@keyup.enter="search"
|
||||
/>
|
||||
<input
|
||||
v-model="uidFilter"
|
||||
type="text"
|
||||
class="evidence-input evidence-uid"
|
||||
placeholder="按 uid 筛选"
|
||||
@keyup.enter="search"
|
||||
/>
|
||||
<button class="btn" type="button" @click="search">查询</button>
|
||||
<button class="btn btn-danger" type="button" :disabled="!selectedCount" @click="removeSelected">
|
||||
删除{{ selectedCount ? `(${selectedCount})` : '' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="page-hint">
|
||||
异常现场件与窗口图按任务号关联;读取与下载仅超级管理员可用,对象直链不出服务端。
|
||||
</p>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<div class="table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 40px">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="items.length > 0 && items.every((row) => selectedIds.has(row.id))"
|
||||
:disabled="!items.length"
|
||||
@change="toggleSelectAllPage"
|
||||
/>
|
||||
</th>
|
||||
<th style="width: 90px">ID</th>
|
||||
<th style="width: 150px">任务号</th>
|
||||
<th style="width: 90px">UID</th>
|
||||
<th style="width: 130px">类型</th>
|
||||
<th style="width: 130px">来源</th>
|
||||
<th style="width: 110px">体积</th>
|
||||
<th style="width: 160px">生成时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-if="items.length">
|
||||
<tr v-for="row in items" :key="row.id">
|
||||
<td>
|
||||
<input type="checkbox" :checked="selectedIds.has(row.id)" @change="toggleSelect(row.id)" />
|
||||
</td>
|
||||
<td>{{ row.id }}</td>
|
||||
<td>{{ row.taskId || '-' }}</td>
|
||||
<td>{{ row.uid ?? '-' }}</td>
|
||||
<td>{{ kindLabel(row) }}</td>
|
||||
<td>{{ row.source || '-' }}</td>
|
||||
<td>{{ row.byteSize }} B</td>
|
||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||||
<td class="evidence-actions">
|
||||
<button class="link-like" type="button" @click="openPreview(row)">查看</button>
|
||||
<a class="link-cell" :href="taskEvidenceDownloadUrl(row.id)" target="_blank" rel="noopener">下载</a>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td colspan="9" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td colspan="9" class="empty-tip">暂无证据件</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<OldPagination :total="total" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
|
||||
</section>
|
||||
|
||||
<div v-if="previewVisible" class="modal-mask" @click.self="closePreview">
|
||||
<div class="modal evidence-modal">
|
||||
<div class="modal-head">
|
||||
<h3 v-if="previewRow">证据件 #{{ previewRow.id }} · {{ previewRow.taskId || '-' }}</h3>
|
||||
<button class="modal-close" type="button" aria-label="关闭" @click="closePreview">×</button>
|
||||
</div>
|
||||
<div v-if="previewLoading" class="modal-empty">读取中...</div>
|
||||
<div v-else-if="previewImage" class="preview-grid">
|
||||
<img :src="previewImage" alt="任务证据图" />
|
||||
</div>
|
||||
<pre v-else class="evidence-text">{{ previewText || '(空)' }}</pre>
|
||||
<div class="modal-foot">
|
||||
<button class="btn btn-secondary" type="button" @click="closePreview">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.evidence-view {
|
||||
font-family: inherit;
|
||||
color: var(--c-text, #24384d);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
.evidence-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.evidence-tools {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.evidence-input {
|
||||
width: 180px;
|
||||
height: 32px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #cdd8e3;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.evidence-uid {
|
||||
width: 120px;
|
||||
}
|
||||
.evidence-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.link-like {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #2563eb;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
.evidence-modal {
|
||||
width: min(960px, 92vw);
|
||||
max-height: 86vh;
|
||||
}
|
||||
.evidence-text {
|
||||
max-height: 60vh;
|
||||
overflow: auto;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
background: #f6f8fa;
|
||||
padding: 12px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.preview-grid img {
|
||||
max-width: 100%;
|
||||
max-height: 60vh;
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
@@ -10,8 +10,6 @@ export const TUTORIAL_UPLOAD_ENDPOINT = '/api/admin/tutorial'
|
||||
export const TUTORIAL_PRESIGN_ENDPOINT = `${TUTORIAL_UPLOAD_ENDPOINT}/presign`
|
||||
export const TUTORIAL_CONFIRM_ENDPOINT = `${TUTORIAL_UPLOAD_ENDPOINT}/confirm`
|
||||
export const TUTORIAL_DELETE_ENDPOINT = `${TUTORIAL_UPLOAD_ENDPOINT}/delete`
|
||||
/** 大档分片通道(AC-11):>8MB 的教程包走这里,不再一次性 presign PUT。 */
|
||||
export const TUTORIAL_CHUNK_ENDPOINT = '/api/files/chunk'
|
||||
|
||||
/** MinIO 直传专用实例:不带 cookie、不挂 401 跳登录拦截器(预签名过期/签名失败不能误判会话过期);大 zip 给足超时。 */
|
||||
const directPut = axios.create({ timeout: 600_000, withCredentials: false })
|
||||
|
||||
@@ -10,8 +10,6 @@ export const SOFTWARE_VERSION_UPLOAD_ENDPOINT = '/api/admin/version'
|
||||
export const SOFTWARE_VERSION_PRESIGN_ENDPOINT = `${SOFTWARE_VERSION_UPLOAD_ENDPOINT}/presign`
|
||||
export const SOFTWARE_VERSION_CONFIRM_ENDPOINT = `${SOFTWARE_VERSION_UPLOAD_ENDPOINT}/confirm`
|
||||
export const SOFTWARE_VERSION_DELETE_ENDPOINT = `${SOFTWARE_VERSION_UPLOAD_ENDPOINT}/delete`
|
||||
/** 大档分片通道(AC-11):>8MB 的安装包走这里,不再一次性 presign PUT。 */
|
||||
export const SOFTWARE_VERSION_CHUNK_ENDPOINT = '/api/files/chunk'
|
||||
|
||||
/** MinIO 直传专用实例:不带 cookie、不挂 401 跳登录拦截器(预签名过期/签名失败不能误判会话过期);大 zip 给足超时。 */
|
||||
const directPut = axios.create({ timeout: 600_000, withCredentials: false })
|
||||
|
||||
@@ -34,6 +34,7 @@ export const adminPages: AdminPageDef[] = [
|
||||
{ path: 'records/tutorial', menuKey: 'admin_tutorial', title: '教程管理', companyScoped: false, load: () => import('@/pages/records/RecordsTutorialPage.vue') },
|
||||
{ path: 'records/workbench-client-package', menuKey: 'admin_workbench_client_package', title: '数富AI工作台客户端包管理', companyScoped: false, load: () => import('@/pages/records/WorkbenchClientPackagePage.vue') },
|
||||
{ path: 'records/device-logs', menuKey: 'admin_device_logs', title: '日志管理', companyScoped: true, load: () => import('@/pages/records/DeviceLogsPage.vue') },
|
||||
{ path: 'records/task-evidence', menuKey: 'admin_task_evidence', title: '任务证据', superAdminOnly: true, companyScoped: false, load: () => import('@/pages/records/TaskEvidencePage.vue') },
|
||||
{ path: 'task-center/board', menuKey: 'admin_task_center', title: '客户端任务管理', companyScoped: true, load: () => import('@/pages/task-center/TaskCenterBoardPage.vue') },
|
||||
{ path: 'records/digital-human-version', menuKey: 'digital_human_version', title: '数字人版本管理', load: () => import('@/pages/records/RecordsDigitalHumanVersionPage.vue') },
|
||||
{ path: 'records/image-video-tasks', menuKey: 'admin_image_video_tasks', title: '视频任务记录', companyScoped: true, load: () => import('@/pages/tasks/ImageVideoTasksPage.vue') },
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"note": "readSource 钉子逐文件基线。两把尺子:pins=落在用例体内的读盘,reads=全文读点总数(含模块级夹具与 helper)。都只许减;pins 下降而 reads 没同步下降=把读盘挪出体内,不算改进。由 tests/source-pin-ratchet.test.ts 生成。",
|
||||
"totals": {
|
||||
"files": 251,
|
||||
"cases": 1750,
|
||||
"pins": 453,
|
||||
"reads": 646
|
||||
"files": 252,
|
||||
"cases": 1753,
|
||||
"pins": 456,
|
||||
"reads": 651
|
||||
},
|
||||
"files": {
|
||||
"admin-scaffold.test.ts": {
|
||||
@@ -1247,6 +1247,11 @@
|
||||
"pins": 3,
|
||||
"reads": 5
|
||||
},
|
||||
"task-evidence-page.test.ts": {
|
||||
"cases": 3,
|
||||
"pins": 3,
|
||||
"reads": 5
|
||||
},
|
||||
"timer-cleanup-pairing.test.ts": {
|
||||
"cases": 5,
|
||||
"pins": 3,
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
// P2-10(后管 AC/user-notice「只把中文给用户看」口径)。
|
||||
//
|
||||
// 评审实录:`RecordsSoftwareVersionPage.vue`/`RecordsTutorialPage.vue` 的 catch 直接写
|
||||
// `error instanceof Error ? error.message : '上传失败'`,而 `src/api/http.ts` 的响应拦截器
|
||||
// **不做 sanitize**(只挑 401/403/4011)⇒ `Broken pipe`、`Request failed with status code 403`
|
||||
// 这类英文异常原文整段上屏。收口方式沿用本仓既有出口 `components/load-failure-model`
|
||||
// 的 `loadFailureMessage(error, 本页兜底句)`(去重页四条写路径同一写法)。
|
||||
//
|
||||
// 跑法:npm run test:mount(tests/mount/**,vitest+jsdom)。
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import RecordsSoftwareVersionPage from '@/pages/records/RecordsSoftwareVersionPage.vue'
|
||||
import RecordsTutorialPage from '@/pages/records/RecordsTutorialPage.vue'
|
||||
import { loadFailureMessage } from '@/components/load-failure-model'
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url))
|
||||
const root = resolve(here, '../..')
|
||||
|
||||
const versionApi = vi.hoisted(() => ({
|
||||
fetchSoftwareVersions: vi.fn(),
|
||||
uploadSoftwareVersion: vi.fn(),
|
||||
deleteSoftwareVersions: vi.fn(),
|
||||
}))
|
||||
const tutorialApi = vi.hoisted(() => ({
|
||||
fetchTutorialPackages: vi.fn(),
|
||||
uploadTutorialPackage: vi.fn(),
|
||||
deleteTutorialPackages: vi.fn(),
|
||||
}))
|
||||
const confirmMock = vi.hoisted(() => vi.fn())
|
||||
const feedbackMock = vi.hoisted(() => vi.fn())
|
||||
const messageMock = vi.hoisted(() => ({ success: vi.fn() }))
|
||||
|
||||
vi.mock('@/pages/records/version-api.ts', () => versionApi)
|
||||
vi.mock('@/pages/records/tutorial-api.ts', () => tutorialApi)
|
||||
vi.mock('@/components/admin-confirm', () => ({ openAdminConfirm: confirmMock }))
|
||||
vi.mock('@/components/admin-feedback-ui', () => ({ showAdminFeedback: feedbackMock }))
|
||||
vi.mock('element-plus', () => ({ ElMessage: messageMock }))
|
||||
|
||||
/** el-upload 的桩:把页面传进来的 on-change 回调顶出来,等价于用户选了一个 .zip。 */
|
||||
const uploadStub = {
|
||||
props: ['onChange'],
|
||||
template: '<button class="pick-zip" @click="onChange({ raw: fake })">选择文件</button>',
|
||||
data: () => ({ fake: new File([new Uint8Array(16)], 'pkg.zip', { type: 'application/zip' }) }),
|
||||
}
|
||||
|
||||
const stubs = {
|
||||
'el-dialog': { template: '<div><slot /><slot name="footer" /></div>' },
|
||||
'el-form': { template: '<form><slot /></form>' },
|
||||
'el-form-item': { template: '<div><slot /></div>' },
|
||||
'el-input': {
|
||||
props: ['modelValue'],
|
||||
emits: ['update:modelValue'],
|
||||
template: '<input :value="modelValue" @input="$emit(\'update:modelValue\', $event.target.value)" />',
|
||||
},
|
||||
'el-upload': uploadStub,
|
||||
'el-button': { template: '<button><slot /></button>' },
|
||||
'el-progress': true,
|
||||
'el-alert': { props: ['title'], template: '<div class="upload-msg">{{ title }}</div>' },
|
||||
}
|
||||
|
||||
/** 后端/驱动层原文:一句中文都没有,正是过去直接上屏的那种。 */
|
||||
const RAW_ENGLISH = 'Broken pipe: java.io.IOException at sun.nio.ch.FileDispatcherImpl.write0'
|
||||
|
||||
function clickButtonByText(wrapper: ReturnType<typeof mount>, text: string, last = false) {
|
||||
const matches = wrapper.findAll('button').filter((node) => node.text().trim() === text)
|
||||
const button = last ? matches[matches.length - 1] : matches[0]
|
||||
if (!button) throw new Error(`找不到文案为「${text}」的按钮`)
|
||||
return button
|
||||
}
|
||||
|
||||
async function submitZipUpload(component: typeof RecordsSoftwareVersionPage, versionPlaceholder: string, submitText: string, openText = '上传新版本') {
|
||||
const wrapper = mount(component, { global: { stubs } })
|
||||
await flushPromises()
|
||||
|
||||
clickButtonByText(wrapper, openText)
|
||||
const versionInput = wrapper.find(`input[placeholder="${versionPlaceholder}"]`)
|
||||
if (versionInput.exists()) await versionInput.setValue('9.9.9')
|
||||
await wrapper.get('.pick-zip').trigger('click')
|
||||
await clickButtonByText(wrapper, submitText, true).trigger('click')
|
||||
await flushPromises()
|
||||
return wrapper
|
||||
}
|
||||
|
||||
describe('P2-10 后管上传/加载失败只把中文交给界面', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
versionApi.fetchSoftwareVersions.mockResolvedValue({ items: [] })
|
||||
tutorialApi.fetchTutorialPackages.mockResolvedValue({ items: [] })
|
||||
confirmMock.mockResolvedValue(true)
|
||||
})
|
||||
|
||||
it('真实出口对照:英文原文一律被换成中文,原因段不拼半截句', () => {
|
||||
expect(loadFailureMessage(new Error(RAW_ENGLISH), '上传失败')).toBe('上传失败')
|
||||
expect(loadFailureMessage(new Error('分片会话不存在或已过期'), '上传失败'))
|
||||
.toBe('上传失败:分片会话不存在或已过期')
|
||||
})
|
||||
|
||||
it('安装包上传失败:界面文案不含英文原文,原文只进 console', async () => {
|
||||
const warned = vi.spyOn(console, 'warn').mockImplementation(() => undefined)
|
||||
versionApi.uploadSoftwareVersion.mockRejectedValue(new Error(RAW_ENGLISH))
|
||||
|
||||
const wrapper = await submitZipUpload(RecordsSoftwareVersionPage, '例如:1.0.0', '上传软件版本')
|
||||
|
||||
const shown = wrapper.get('.upload-msg').text()
|
||||
expect(shown, '英文异常原文仍在上屏').not.toContain('Broken pipe')
|
||||
expect(shown).toContain('上传失败')
|
||||
expect(
|
||||
warned.mock.calls.some((call) => String(call.join(' ')).includes(RAW_ENGLISH)),
|
||||
'原文要留在 console,否则支持同学对着后端日志无从核对',
|
||||
).toBe(true)
|
||||
warned.mockRestore()
|
||||
})
|
||||
|
||||
it('教程包上传失败:同一条中文出口,不得再直落 error.message', async () => {
|
||||
vi.spyOn(console, 'warn').mockImplementation(() => undefined)
|
||||
tutorialApi.uploadTutorialPackage.mockRejectedValue(new Error(RAW_ENGLISH))
|
||||
|
||||
const wrapper = await submitZipUpload(RecordsTutorialPage, '例如:v2026.09 或留空', '上传教程包', '上传教程包')
|
||||
|
||||
const shown = wrapper.get('.upload-msg').text()
|
||||
expect(shown, '英文异常原文仍在上屏').not.toContain('Broken pipe')
|
||||
expect(shown).toContain('上传失败')
|
||||
})
|
||||
|
||||
it('列表加载失败:LoadFailureBar 的文案也是中文', async () => {
|
||||
vi.spyOn(console, 'warn').mockImplementation(() => undefined)
|
||||
versionApi.fetchSoftwareVersions.mockRejectedValue(new Error('Internal Server Error'))
|
||||
|
||||
const wrapper = mount(RecordsSoftwareVersionPage, { global: { stubs } })
|
||||
await flushPromises()
|
||||
|
||||
const shown = wrapper.text()
|
||||
expect(shown).not.toContain('Internal Server Error')
|
||||
expect(shown).toContain('版本列表加载失败')
|
||||
expect(feedbackMock).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
// 写法收口的台账:两页四条 catch(列表/删除×2/上传)都必须把错误交给同一个出口。
|
||||
it('两页不得再留 error instanceof Error ? error.message 那套写法', () => {
|
||||
for (const file of [
|
||||
'src/pages/records/RecordsSoftwareVersionPage.vue',
|
||||
'src/pages/records/RecordsTutorialPage.vue',
|
||||
]) {
|
||||
const source = readFileSync(resolve(root, file), 'utf-8')
|
||||
expect(source, `${file} 仍直落 error.message`).not.toMatch(/error instanceof Error \? error\.message/)
|
||||
expect(source.match(/loadFailureMessage\(error,/g)?.length ?? 0, `${file} 的失败出口没接上`)
|
||||
.toBeGreaterThanOrEqual(4)
|
||||
expect(source).toMatch(/import \{ loadFailureMessage \} from '@\/components\/load-failure-model'/)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1,8 +1,13 @@
|
||||
// AC-11(R4):后管版本/教程大档上传接线的「源码尺子」那一半。
|
||||
//
|
||||
// Pending Phase 4 激活。今天 `src/pages/records/version-api.ts` 与 `tutorial-api.ts`
|
||||
// 都是 presign → 一次 PUT 直传(512MB 级也一样,蓝图 §1.2 R4 实读);本文件要求两条
|
||||
// 路径接上既有 `/api/files/chunk/**` 分片通道(断点续传/按片重试)。
|
||||
// Pending Phase 4 激活。本尺子的前身只断言 `files/chunk` 出现在非注释行,而那一句匹配来自
|
||||
// `version-api.ts`/`tutorial-api.ts` 里一对**全仓零引用的死常量**(SOFTWARE_VERSION_CHUNK_ENDPOINT/
|
||||
// TUTORIAL_CHUNK_ENDPOINT)——把真调用 `uploadFileInChunks(…)` 删掉,尺子照样绿(评审 P2-6 假绿形状)。
|
||||
// 现在判据钉在**真调用点**上:被接线的那个函数体里必须出现 `uploadFileInChunks(`,
|
||||
// 且死常量不许回来(`CHUNK_ENDPOINT =` 一出现即红)。删调用必判红,加死常量也判红。
|
||||
//
|
||||
// 行为口径在 tests/pure/pending-phase4-大档上传接线.test.ts(vitest 真调 uploadSoftwareVersion/
|
||||
// uploadTutorialPackage,删掉调用同一刻那一边也红);本文件只补"接线没被搬空"这一层。
|
||||
//
|
||||
// 跑法:npm test(node --test tests/*.test.ts)。
|
||||
import { test } from 'node:test'
|
||||
@@ -14,29 +19,75 @@ import { fileURLToPath } from 'node:url'
|
||||
const here = dirname(fileURLToPath(import.meta.url))
|
||||
const root = resolve(here, '..')
|
||||
|
||||
const LARGE_UPLOAD_FILES = [
|
||||
'src/pages/records/version-api.ts',
|
||||
'src/pages/records/tutorial-api.ts',
|
||||
]
|
||||
/** 把注释整段涂白(保行数):接线只写在注释里不算数。 */
|
||||
function blankComments(source: string): string {
|
||||
return source
|
||||
.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '))
|
||||
.replace(/\/\/[^\n]*/g, (line) => ' '.repeat(line.length))
|
||||
}
|
||||
|
||||
test('后管版本/教程大档必须接分片通道', () => {
|
||||
for (const file of LARGE_UPLOAD_FILES) {
|
||||
const source = readFileSync(resolve(root, file), 'utf-8')
|
||||
assert.match(
|
||||
source,
|
||||
/files\/chunk/,
|
||||
`AC-11:${file} 仍是 presign 直传(512MB 断网从 0 重来,没有分片续传)`,
|
||||
)
|
||||
/** 取 `function <name>(…) {…}` 的函数体:大括号配对,跳过字符串与模板串里的括号。 */
|
||||
function functionBodyOf(source: string, name: string): string {
|
||||
const code = blankComments(source)
|
||||
const head = code.indexOf(`function ${name}(`)
|
||||
assert.notEqual(head, -1, `找不到函数 ${name}()——接线被删了还是改名了?`)
|
||||
const open = code.indexOf('{', head)
|
||||
assert.notEqual(open, -1, `${name}() 没有函数体`)
|
||||
let depth = 0
|
||||
let index = open
|
||||
let quote = ''
|
||||
for (; index < code.length; index += 1) {
|
||||
const char = code[index]
|
||||
if (quote) {
|
||||
if (char === '\\') index += 1
|
||||
else if (char === quote) quote = ''
|
||||
continue
|
||||
}
|
||||
if (char === '"' || char === "'" || char === '`') { quote = char; continue }
|
||||
if (char === '{') depth += 1
|
||||
else if (char === '}') {
|
||||
depth -= 1
|
||||
if (depth === 0) return code.slice(open + 1, index)
|
||||
}
|
||||
}
|
||||
return code.slice(open + 1)
|
||||
}
|
||||
|
||||
/**
|
||||
* 两格共同判据(读盘点留在用例体内:把 readFileSync 挪进 helper 是本仓 source-pin 棘轮点名的"搬家不算改进"):
|
||||
* ① 从 @/api/chunk-upload 把分片函数引进来;② 被接线的函数体里真的调它;
|
||||
* ③ 阈值同源;④ 死常量不得回来。
|
||||
*/
|
||||
function assertChunkedWiring(source: string, file: string, wiredFunction: string): void {
|
||||
assert.match(
|
||||
source,
|
||||
/import\s*\{[^}]*uploadFileInChunks[^}]*\}\s*from\s*'@\/api\/chunk-upload'/,
|
||||
`AC-11:${file} 没有从 @/api/chunk-upload 引入分片函数`,
|
||||
)
|
||||
const body = functionBodyOf(source, wiredFunction)
|
||||
assert.match(
|
||||
body,
|
||||
/uploadFileInChunks\s*\(/,
|
||||
`AC-11:${file}::${wiredFunction}() 里没有真调用 uploadFileInChunks(…)(大档仍走一次 PUT 直传,512MB 断网从 0 重来)`,
|
||||
)
|
||||
assert.match(
|
||||
body,
|
||||
/CHUNK_UPLOAD_THRESHOLD/,
|
||||
`AC-11:${wiredFunction}() 的选路阈值必须与 chunk-upload 同源,不得各自写死 8MB`,
|
||||
)
|
||||
assert.doesNotMatch(
|
||||
source,
|
||||
/CHUNK_ENDPOINT\s*=/,
|
||||
`AC-11:${file} 又立了一个没人引用的 CHUNK_ENDPOINT 常量——它会顶掉本尺子的匹配来源,正是 P2-6 的假绿形状`,
|
||||
)
|
||||
}
|
||||
|
||||
test('后管安装包上传必须真的调分片通道', () => {
|
||||
const file = 'src/pages/records/version-api.ts'
|
||||
assertChunkedWiring(readFileSync(resolve(root, file), 'utf-8'), file, 'uploadSoftwareVersion')
|
||||
})
|
||||
|
||||
test('分片接线不得只落注释', () => {
|
||||
for (const file of LARGE_UPLOAD_FILES) {
|
||||
const source = readFileSync(resolve(root, file), 'utf-8')
|
||||
const codeLines = source
|
||||
.split('\n')
|
||||
.filter((line) => !line.trim().startsWith('//') && !line.trim().startsWith('*'))
|
||||
.join('\n')
|
||||
assert.match(codeLines, /files\/chunk/, `AC-11:${file} 的分片引用只出现在注释里`)
|
||||
}
|
||||
test('后管教程包上传必须真的调分片通道', () => {
|
||||
const file = 'src/pages/records/tutorial-api.ts'
|
||||
assertChunkedWiring(readFileSync(resolve(root, file), 'utf-8'), file, 'uploadTutorialPackage')
|
||||
})
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
// P2-7/P2-8/P3-5(后管分片通道 AC-9/AC-11 精神)。
|
||||
//
|
||||
// 评审实录:`src/api/chunk-upload.ts` 每次调用都新 init 一个 upload_id ⇒ 紧随的 GET 必空、
|
||||
// 放弃时又把会话 DELETE 掉,**等于根本没有续传**;逐片超时还按整包体积算(120s + MB×15s),
|
||||
// 8MB 的片能拿到约 130 分钟。本文件按用户端 `shared/api/upload.ts` 的同一口径钉四件事:
|
||||
// ① 同一文件身份复用 upload_id(不重新 init);② 瞬态失败不 DELETE、会话留在本地供下次续传;
|
||||
// ③ 只有服务端确实说会话没了(404/「不存在或已过期」)才重开;④ 逐片超时按本片体积给。
|
||||
//
|
||||
// 跑法:npm run test:mount(tests/pure/** 与 tests/mount/** 同走 vitest)。
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
post: vi.fn(),
|
||||
get: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
}))
|
||||
|
||||
// 只顶掉 http 实例,unwrap 用真的:会话回收在后端是 HTTP 200+success:false,
|
||||
// 判因逻辑要吃真实解包语义(含中文文案把关),换桩会把这一半形状测漏。
|
||||
vi.mock('@/api/http', async (importOriginal) => {
|
||||
const actual = await importOriginal<{ unwrap: <T>(payload: unknown) => T }>()
|
||||
return {
|
||||
...actual,
|
||||
http: { post: mocks.post, get: mocks.get, delete: mocks.delete },
|
||||
}
|
||||
})
|
||||
|
||||
import {
|
||||
CHUNK_UPLOAD_PART_SIZE,
|
||||
CHUNK_UPLOAD_THRESHOLD,
|
||||
chunkSessionKeyOf,
|
||||
partTimeoutOf,
|
||||
uploadFileInChunks,
|
||||
} from '@/api/chunk-upload'
|
||||
|
||||
const RESUMED_ID = 'r'.repeat(32)
|
||||
const FRESH_ID = 'n'.repeat(32)
|
||||
|
||||
function axiosResponse(status: number, body: unknown) {
|
||||
return { status, data: body }
|
||||
}
|
||||
|
||||
function javaOk(body: unknown) {
|
||||
return axiosResponse(200, { success: true, message: '', data: body })
|
||||
}
|
||||
|
||||
function makeFile(name: string, bytes: number): File {
|
||||
return new File([new Uint8Array(bytes)], name, { type: 'application/octet-stream' })
|
||||
}
|
||||
|
||||
function seedSession(file: File, uploadId: string): void {
|
||||
localStorage.setItem(chunkSessionKeyOf(file.name, file), JSON.stringify({
|
||||
uploadId,
|
||||
size: file.size,
|
||||
lastModified: file.lastModified,
|
||||
}))
|
||||
}
|
||||
|
||||
function storedUploadId(file: File): string {
|
||||
const raw = localStorage.getItem(chunkSessionKeyOf(file.name, file))
|
||||
if (!raw) return ''
|
||||
return String((JSON.parse(raw) as { uploadId?: unknown }).uploadId ?? '')
|
||||
}
|
||||
|
||||
function postedUrls(): string[] {
|
||||
return mocks.post.mock.calls.map(([url]) => String(url))
|
||||
}
|
||||
|
||||
function partPosts(): Array<{ url: string; timeout: number }> {
|
||||
return mocks.post.mock.calls
|
||||
.filter(([url]) => /\/part\/\d+$/.test(String(url)))
|
||||
.map(([url, , config]) => ({
|
||||
url: String(url),
|
||||
timeout: Number((config as { timeout?: unknown } | undefined)?.timeout ?? -1),
|
||||
}))
|
||||
}
|
||||
|
||||
function initCount(): number {
|
||||
return postedUrls().filter((url) => url.includes('/chunk/init')).length
|
||||
}
|
||||
|
||||
/** init/逐片/complete 一律成功;complete 返回拼装后的 fileKey。 */
|
||||
function routePosts(uploadId: string) {
|
||||
mocks.post.mockImplementation((url: string) => Promise.resolve(
|
||||
String(url).includes('/chunk/init')
|
||||
? javaOk({ upload_id: uploadId, total_parts: 2 })
|
||||
: String(url).includes('/complete')
|
||||
? javaOk({ fileKey: 'tmp/pkg.zip', originalFilename: 'pkg.zip', size: 1 })
|
||||
: javaOk({ upload_id: String(url).split('/')[5], received_parts: 1 }),
|
||||
))
|
||||
}
|
||||
|
||||
describe('P2-7 后管分片必须真的续传', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
localStorage.clear()
|
||||
routePosts(FRESH_ID)
|
||||
})
|
||||
|
||||
it('同一文件身份复用 upload_id:探测成功就一条 init 都不许发', async () => {
|
||||
const file = makeFile('pkg.zip', CHUNK_UPLOAD_PART_SIZE * 2)
|
||||
seedSession(file, RESUMED_ID)
|
||||
mocks.get.mockResolvedValue(javaOk({ upload_id: RESUMED_ID, uploaded_parts: [0] }))
|
||||
|
||||
await uploadFileInChunks(file, file.name)
|
||||
|
||||
expect(initCount(), '会话还在服务端,重开 init 就是作废已传片').toBe(0)
|
||||
expect(
|
||||
partPosts().map((part) => part.url),
|
||||
'第 0 片服务端已有,只补第 1 片',
|
||||
).toEqual([`/api/files/chunk/${RESUMED_ID}/part/1`])
|
||||
})
|
||||
|
||||
it('瞬态失败(分片打不出去):不 DELETE 会话,且本地仍留着 upload_id', async () => {
|
||||
const file = makeFile('pkg.zip', CHUNK_UPLOAD_PART_SIZE * 2)
|
||||
seedSession(file, RESUMED_ID)
|
||||
mocks.get.mockResolvedValue(javaOk({ upload_id: RESUMED_ID, uploaded_parts: [] }))
|
||||
mocks.post.mockRejectedValue(new Error('Network Error'))
|
||||
|
||||
await expect(uploadFileInChunks(file, file.name)).rejects.toThrow(/Network Error/)
|
||||
|
||||
expect(mocks.delete.mock.calls, 'DELETE 会把已达片号一起清掉,下次只能从 0').length(0)
|
||||
expect(storedUploadId(file), '会话要留给下一次(含刷新后)续传').toBe(RESUMED_ID)
|
||||
})
|
||||
|
||||
it('探测 503:瞬态 ⇒ 保留原会话,不重开', async () => {
|
||||
const file = makeFile('pkg.zip', CHUNK_UPLOAD_PART_SIZE * 2)
|
||||
seedSession(file, RESUMED_ID)
|
||||
mocks.get.mockResolvedValue(axiosResponse(503, '<html>Bad Gateway</html>'))
|
||||
|
||||
await uploadFileInChunks(file, file.name)
|
||||
|
||||
expect(initCount()).toBe(0)
|
||||
expect(partPosts().every((part) => part.url.includes(RESUMED_ID))).toBe(true)
|
||||
})
|
||||
|
||||
it('探测超时(网络层错误):瞬态 ⇒ 同样保留原会话', async () => {
|
||||
const file = makeFile('pkg.zip', CHUNK_UPLOAD_PART_SIZE * 2)
|
||||
seedSession(file, RESUMED_ID)
|
||||
mocks.get.mockRejectedValue(new Error('timeout of 30000ms exceeded'))
|
||||
|
||||
await uploadFileInChunks(file, file.name)
|
||||
|
||||
expect(initCount()).toBe(0)
|
||||
expect(partPosts().every((part) => part.url.includes(RESUMED_ID))).toBe(true)
|
||||
})
|
||||
|
||||
it('HTTP 404:会话确实没了 ⇒ 清状态重开', async () => {
|
||||
const file = makeFile('pkg.zip', CHUNK_UPLOAD_PART_SIZE * 2)
|
||||
seedSession(file, RESUMED_ID)
|
||||
mocks.get.mockResolvedValue(axiosResponse(404, { success: false, message: 'Not Found', data: null }))
|
||||
|
||||
await uploadFileInChunks(file, file.name)
|
||||
|
||||
expect(initCount(), '会话已回收,不重建就永远卡在同一个死会话上').toBe(1)
|
||||
expect(partPosts().every((part) => part.url.includes(FRESH_ID))).toBe(true)
|
||||
})
|
||||
|
||||
it('后端 HTTP 200+「分片会话不存在或已过期」(现网形状)⇒ 同样重开', async () => {
|
||||
const file = makeFile('pkg.zip', CHUNK_UPLOAD_PART_SIZE * 2)
|
||||
seedSession(file, RESUMED_ID)
|
||||
mocks.get.mockResolvedValue(axiosResponse(
|
||||
200,
|
||||
{ success: false, message: '分片会话不存在或已过期', data: null },
|
||||
))
|
||||
|
||||
await uploadFileInChunks(file, file.name)
|
||||
|
||||
expect(initCount()).toBe(1)
|
||||
expect(partPosts().every((part) => part.url.includes(FRESH_ID))).toBe(true)
|
||||
})
|
||||
|
||||
it('拼装成功 ⇒ 本地会话清掉(同一文件再传要开新会话)', async () => {
|
||||
const file = makeFile('pkg.zip', CHUNK_UPLOAD_PART_SIZE * 2)
|
||||
seedSession(file, RESUMED_ID)
|
||||
mocks.get.mockResolvedValue(javaOk({ upload_id: RESUMED_ID, uploaded_parts: [] }))
|
||||
|
||||
await uploadFileInChunks(file, file.name)
|
||||
|
||||
expect(storedUploadId(file), '完成后会话已拼装落库,本地不该留残号').toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
describe('P2-8 逐片超时按本片体积', () => {
|
||||
it('每片预算只看这一片有多大,不得按整包体积放大', async () => {
|
||||
const file = makeFile('big.zip', CHUNK_UPLOAD_PART_SIZE * 5)
|
||||
mocks.get.mockResolvedValue(javaOk({ upload_id: FRESH_ID, uploaded_parts: [] }))
|
||||
routePosts(FRESH_ID)
|
||||
|
||||
await uploadFileInChunks(file, file.name)
|
||||
|
||||
const parts = partPosts()
|
||||
expect(parts.length, '40MB=5 片').toBe(5)
|
||||
// 整包口径会给出 120s + 40×15s = 720s;按片口径 8MB 片=300s。判红要留出余量差。
|
||||
for (const part of parts) {
|
||||
expect(part.timeout, `片 ${part.url} 的超时没有按本片体积算`).toBeGreaterThan(0)
|
||||
expect(
|
||||
part.timeout,
|
||||
`片 ${part.url} 的超时 ${part.timeout}ms 是按整包体积算的(P2-8)`,
|
||||
).toBeLessThanOrEqual(partTimeoutOf(CHUNK_UPLOAD_PART_SIZE))
|
||||
}
|
||||
expect(partTimeoutOf(CHUNK_UPLOAD_PART_SIZE), '8MB 片的预算不该超过 10 分钟')
|
||||
.toBeLessThanOrEqual(600_000)
|
||||
expect(partTimeoutOf(1), '再小的片也要有保底,不能给 0').toBeGreaterThanOrEqual(60_000)
|
||||
})
|
||||
|
||||
it('init 与 complete 的预算不再随整包体积线性放大', async () => {
|
||||
const file = makeFile('big.zip', CHUNK_UPLOAD_PART_SIZE * 5)
|
||||
mocks.get.mockResolvedValue(javaOk({ upload_id: FRESH_ID, uploaded_parts: [] }))
|
||||
routePosts(FRESH_ID)
|
||||
|
||||
await uploadFileInChunks(file, file.name)
|
||||
|
||||
const initCall = mocks.post.mock.calls.find(([url]) => String(url).includes('/chunk/init'))
|
||||
const initTimeout = Number((initCall?.[2] as { timeout?: unknown } | undefined)?.timeout ?? -1)
|
||||
expect(initTimeout, 'init 只发一条登记请求,按整包体积给 720s 是把失败拖到天荒地老').toBeLessThan(300_000)
|
||||
})
|
||||
})
|
||||
|
||||
describe('P3-5 阈值单点', () => {
|
||||
it('后管这一侧的 8MB 只有一个出口:阈值由片大小派生', () => {
|
||||
expect(CHUNK_UPLOAD_THRESHOLD, '阈值必须与片大小同源(P3-5 三处各写一遍的收口)')
|
||||
.toBe(CHUNK_UPLOAD_PART_SIZE)
|
||||
expect(CHUNK_UPLOAD_PART_SIZE).toBe(8 * 1024 * 1024)
|
||||
})
|
||||
})
|
||||
@@ -3,7 +3,7 @@
|
||||
// Pending Phase 4 激活。9MB 安装包(跨分片阈值)调 uploadSoftwareVersion,
|
||||
// 必须出现 POST /files/chunk/init;今天它走 presign → 一次 PUT 直传,
|
||||
// 512MB 断网只能从 0 重来。本文件不出网,mock 掉 http 与 axios 直传实例。
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { beforeEach, describe, it, expect, vi } from 'vitest'
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
post: vi.fn(),
|
||||
@@ -34,9 +34,16 @@ vi.mock('@/api/http', () => ({
|
||||
}))
|
||||
|
||||
import { uploadSoftwareVersion } from '@/pages/records/version-api.ts'
|
||||
import { uploadTutorialPackage } from '@/pages/records/tutorial-api.ts'
|
||||
|
||||
|
||||
describe('AC-11 后管大档上传', () => {
|
||||
// 会话跨尝试复用后,两格之间必须清态:残留的 upload_id 会让第二格跳过本该发生的 init。
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
localStorage.clear()
|
||||
})
|
||||
|
||||
it('9MB 安装包必须走分片 init', async () => {
|
||||
// 预签名与分片两套响应揉成一个超集:哪条实现路径先走都能拿到自己要的字段。
|
||||
mocks.post.mockResolvedValue({
|
||||
@@ -68,5 +75,48 @@ describe('AC-11 后管大档上传', () => {
|
||||
urls.some((url) => url.includes('/files/chunk/init')),
|
||||
`AC-11:9MB 安装包仍走 presign 直传,实际出口:${urls.join(', ')}`,
|
||||
).toBe(true)
|
||||
// P2-6:删掉 uploadFileInChunks(…) 真调用后,这一格必须跟着红——所以还要核对分片片确实发出去了。
|
||||
expect(
|
||||
mocks.post.mock.calls.filter(([url]) => /\/files\/chunk\/[^/]+\/part\/\d+$/.test(String(url))).length,
|
||||
'AC-11:走分片就要真把片 POST 出去',
|
||||
).toBe(2)
|
||||
})
|
||||
|
||||
// P2-6:教程包那条道过去只有源码尺子覆盖(而尺子当时吃的是死常量),删掉真调用没人判红。
|
||||
it('9MB 教程包必须走分片 init', async () => {
|
||||
localStorage.clear()
|
||||
mocks.post.mockResolvedValue({
|
||||
data: {
|
||||
success: true,
|
||||
data: {
|
||||
upload_url: 'https://oss.example/put',
|
||||
file_url: 'https://oss.example/tutorial.zip',
|
||||
version: '9.9.9',
|
||||
object_key: 'client/tutorials/tutorial.zip',
|
||||
upload_id: 'b'.repeat(32),
|
||||
uploaded_parts: [],
|
||||
item: null,
|
||||
},
|
||||
},
|
||||
})
|
||||
mocks.get.mockResolvedValue({
|
||||
data: { success: true, data: { upload_id: 'b'.repeat(32), uploaded_parts: [] } },
|
||||
})
|
||||
mocks.directPut.mockResolvedValue({})
|
||||
|
||||
const file = new Blob([new Uint8Array(9 * 1024 * 1024)], {
|
||||
type: 'application/octet-stream',
|
||||
})
|
||||
await uploadTutorialPackage(file, 'tutorial.zip', '9.9.9')
|
||||
|
||||
const urls = mocks.post.mock.calls.map(([url]) => String(url))
|
||||
expect(
|
||||
urls.some((url) => url.includes('/files/chunk/init')),
|
||||
`AC-11:9MB 教程包仍走 presign 直传,实际出口:${urls.join(', ')}`,
|
||||
).toBe(true)
|
||||
expect(
|
||||
mocks.directPut.mock.calls.length,
|
||||
'AC-11:大档不该再走一次 PUT 直传',
|
||||
).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readSource } from './helpers.ts'
|
||||
|
||||
/** P1-9:任务证据读取面的后台入口必须存在,且只给超级管理员。 */
|
||||
|
||||
test('task evidence menu is super-admin only', () => {
|
||||
const routes = readSource('src/router/routes.ts')
|
||||
assert.match(routes, /path: 'records\/task-evidence'[\s\S]*?menuKey: 'admin_task_evidence'[\s\S]*?superAdminOnly: true/,
|
||||
'任务证据路由必须带 superAdminOnly')
|
||||
|
||||
const scope = readSource('src/config/company-scope.ts')
|
||||
assert.match(scope, /SUPER_ADMIN_ONLY_MENU_KEYS[^\n]*admin_task_evidence/,
|
||||
'菜单 key 必须在超级管理员可见清单里')
|
||||
|
||||
const guide = readSource('src/layout/operation-guides.ts')
|
||||
assert.match(guide, /admin_task_evidence:\s*\{/, '菜单必须配操作指引')
|
||||
})
|
||||
|
||||
test('task evidence page never renders object keys', () => {
|
||||
const page = readSource('src/pages/records/TaskEvidencePage.vue')
|
||||
assert.doesNotMatch(page, /objectKey|object_key|presign/i, '页面不得展示或持有对象直链')
|
||||
assert.match(page, /taskEvidenceDownloadUrl/, '下载必须走鉴权接口')
|
||||
assert.match(page, /deleteTaskEvidence/, '删除必须走鉴权接口')
|
||||
})
|
||||
|
||||
test('task evidence api is wired to admin endpoints', () => {
|
||||
const api = readSource('src/api/task-evidence.ts')
|
||||
assert.match(api, /\/admin\/task-evidence\/files/)
|
||||
assert.match(api, /\/admin\/task-evidence\/download\?fileId=/)
|
||||
assert.match(api, /\/admin\/task-evidence\/delete/)
|
||||
})
|
||||
Reference in New Issue
Block a user