mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-03 15:06:36 +08:00
接口参数调整
This commit is contained in:
@@ -35,7 +35,7 @@ import {
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog"
|
||||
import {Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle,} from "@/components/ui/sheet"
|
||||
import {formatFileSize, UploadService} from "@/lib/services/upload/upload.service"
|
||||
import {formatFileSize, getFileUrl, UploadService} from "@/lib/services/upload/upload.service"
|
||||
import type {Upload as UploadRecord} from "@/lib/services/upload/types"
|
||||
|
||||
/* ─── 工具函数 ─────────────────────────────────────────── */
|
||||
@@ -310,7 +310,7 @@ export function FilesMain() {
|
||||
{file.mime_type.startsWith("image/") ? (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
src={`/f/${file.id}`}
|
||||
src={getFileUrl(file.id, "low") ?? undefined}
|
||||
alt={file.file_name}
|
||||
className="size-full object-cover"
|
||||
onError={(e) => {
|
||||
@@ -426,7 +426,7 @@ export function FilesMain() {
|
||||
{detailTarget.mime_type.startsWith("image/") ? (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
src={`/f/${detailTarget.id}`}
|
||||
src={getFileUrl(detailTarget.id, "low") ?? undefined}
|
||||
alt={detailTarget.file_name}
|
||||
className="max-h-full max-w-full object-contain rounded-lg shadow-sm"
|
||||
/>
|
||||
|
||||
@@ -2,14 +2,21 @@ import {BaseService} from '../core/base.service'
|
||||
import type {ListUploadsResponse, Upload, UploadImageResponse} from './types'
|
||||
import type {InternalAxiosRequestConfig} from 'axios'
|
||||
|
||||
export type ImageQuality = 'low' | 'medium' | 'high' | 'origin'
|
||||
|
||||
/**
|
||||
* 根据上传ID构造文件访问URL
|
||||
* @param id - 上传记录ID
|
||||
* @param quality - 图片质量
|
||||
* @returns 文件访问URL
|
||||
*/
|
||||
export function getFileUrl(id: string | number | null | undefined): string | null {
|
||||
export function getFileUrl(
|
||||
id: string | number | null | undefined,
|
||||
quality: ImageQuality = 'origin'
|
||||
): string | null {
|
||||
if (!id) return null
|
||||
return `/f/${id}`
|
||||
if (quality === 'origin') return `/f/${id}`
|
||||
return `/f/${id}?quality=${quality}`
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user