Files
FileHost/server/utils/image-query.ts
T
O96u ac65c1eb9d refactor: 重构设置、API、图库与存储页面前端结构。
将操作日志并入设置侧栏,补齐检查更新提示与版本接口刷新;拆分各模块组件并修复图库搜索分页变量。
2026-09-01 17:15:02 +08:00

29 lines
1015 B
TypeScript

import { getStorageBackendRow } from './storage-backends'
import { ALLOWED_MIME_TYPES } from './constants'
export function readBackendIdQuery(
query: Record<string, unknown>
): string | undefined | null {
const raw = typeof query.backendId === 'string' ? query.backendId.trim() : ''
if (!raw || raw === 'all') return undefined
return getStorageBackendRow(raw)?.id ?? null
}
export function readContentTypeQuery(
query: Record<string, unknown>
): string | undefined | null {
const raw = typeof query.contentType === 'string' ? query.contentType.trim() : ''
if (!raw || raw === 'all') return undefined
if (!(ALLOWED_MIME_TYPES as readonly string[]).includes(raw)) return null
return raw
}
export function readUploadSourceQuery(
query: Record<string, unknown>
): 'web' | 'api' | undefined | null {
const raw = typeof query.uploadSource === 'string' ? query.uploadSource.trim() : ''
if (!raw || raw === 'all') return undefined
if (raw === 'web' || raw === 'api') return raw
return null
}