task-28: 死代码清理

删除拆分后失去引用的 API 残留文件:
- src/shared/api/call.ts(已由 http.ts 取代)
- src/shared/api/download.ts(已由 download-url.ts 取代)
- src/shared/api/status.ts(页面内已有本地实现)
及其孤儿测试 tests/call.test.ts / call-abort.test.ts / download.test.ts / status.test.ts。
endpoints/url/user 仍被模块文件引用,保留。

新增 8 个验证测试(dead-code-cleanup.test.ts):无重复导出、
vue-tsc 零错误、全量测试绿、无调试日志、无残留函数体、
16+ HTML 入口存在、build 产物齐全、提交变更仅限 frontend-vue。
This commit is contained in:
2026-08-31 20:11:49 +08:00
parent 3fe8d5d05c
commit 71606e9fe5
8 changed files with 99 additions and 365 deletions
-35
View File
@@ -1,35 +0,0 @@
import { http, type RequestOptions } from './http.ts'
export interface JavaApiResponse<T> {
success: boolean
message: string
data: T | null
}
export interface LegacyApiSuccess<T> {
success: true
msg?: string
data?: T
}
export async function callJava<T = unknown, D = unknown>(
config: RequestOptions<D>,
): Promise<T> {
const body = await http.request<unknown, unknown, D>(config)
const data = (body as { data?: unknown }).data ?? body
if (
data &&
typeof data === 'object' &&
'success' in data &&
typeof (data as { success: unknown }).success === 'boolean'
) {
const wrapped = data as { success: boolean; message?: string; msg?: string; error?: string; data?: T }
if (!wrapped.success) {
throw new Error(wrapped.message || wrapped.msg || wrapped.error || '请求失败')
}
return wrapped.data as T
}
return data as T
}
-22
View File
@@ -1,22 +0,0 @@
export interface DownloadableItem {
freshDownloadUrl?: string | null
downloadUrl?: string | null
}
export function buildDownloadUrl(path: string, userId?: number): string {
if (userId === undefined || userId === null || Number.isNaN(userId)) {
return path
}
if (/[?&]user_id=/.test(path)) {
return path
}
const separator = path.includes('?') ? '&' : '?'
return `${path}${separator}user_id=${userId}`
}
export function resolveDownloadUrl(item: DownloadableItem | null | undefined): string {
if (!item) {
return ''
}
return item.freshDownloadUrl || item.downloadUrl || ''
}
-26
View File
@@ -1,26 +0,0 @@
export function normalizeStatus(raw: string | null | undefined): string {
if (typeof raw !== 'string') {
return ''
}
const trimmed = raw.trim()
if (!trimmed) {
return ''
}
return trimmed.toUpperCase().replace(/[\s-]+/g, '_')
}
export function isTerminalStatus(
status: string | null | undefined,
extras?: string[],
): boolean {
const normalized = normalizeStatus(status)
if (!normalized) {
return false
}
const terminalSet = new Set([
'SUCCESS',
'FAILED',
...(extras ?? []).map((extra) => normalizeStatus(extra)),
])
return terminalSet.has(normalized)
}