This commit is contained in:
ryan
2026-07-13 15:08:40 +08:00
parent 08e8eea932
commit 1eff7878a1
441 changed files with 26491 additions and 18405 deletions
@@ -13,7 +13,10 @@ export class AdminUploadService extends BaseService {
type?: string,
extension?: string,
): Promise<ListUploadsResponse> {
const params: Record<string, string | number> = { page, page_size: pageSize };
const params: Record<string, string | number> = {
page,
page_size: pageSize,
};
if (keyword) params.keyword = keyword;
if (type) params.type = type;
if (extension) params.extension = extension;
@@ -37,4 +40,4 @@ export class AdminUploadService extends BaseService {
responseType: 'blob',
} as InternalAxiosRequestConfig);
}
}
}
+6 -1
View File
@@ -2,4 +2,9 @@ export { UploadService } from './upload.service';
export { AdminUploadService } from './admin-upload.service';
export { formatFileSize, getFileUrl } from './utils';
export type { ImageQuality } from './utils';
export type { UploadImageResponse, Upload, ListUploadsResponse, FileStatsResponse } from './types';
export type {
UploadImageResponse,
Upload,
ListUploadsResponse,
FileStatsResponse,
} from './types';
+44 -44
View File
@@ -2,34 +2,34 @@
* 文件上传元数据
*/
export interface UploadMetadata {
width?: number
height?: number
duration?: number
original_mime?: string
user_agent?: string
client_ip?: string
bucket?: string
extra?: Record<string, unknown>
width?: number;
height?: number;
duration?: number;
original_mime?: string;
user_agent?: string;
client_ip?: string;
bucket?: string;
extra?: Record<string, unknown>;
}
/**
* 上传记录
*/
export interface Upload {
id: string
user_id: string
file_name: string
file_path: string
file_size: number
mime_type: string
extension: string
hash: string
type: string
status: string
access_mode: number
metadata: UploadMetadata
created_at: string
updated_at: string
id: string;
user_id: string;
file_name: string;
file_path: string;
file_size: number;
mime_type: string;
extension: string;
hash: string;
type: string;
status: string;
access_mode: number;
metadata: UploadMetadata;
created_at: string;
updated_at: string;
}
/**
@@ -37,55 +37,55 @@ export interface Upload {
*/
export interface UploadImageResponse {
/** 上传记录 ID */
id: string
id: string;
}
/**
* 文件列表查询参数
*/
export interface ListUploadsQuery {
page?: number
page_size?: number
type?: string
extension?: string
keyword?: string
page?: number;
page_size?: number;
type?: string;
extension?: string;
keyword?: string;
}
/**
* 文件列表分页响应
*/
export interface ListUploadsResponse {
total: number
page: number
page_size: number
items: Upload[]
total: number;
page: number;
page_size: number;
items: Upload[];
}
/**
* 近 7 天新增文件趋势项
*/
export interface TrendItem {
date: string
count: number
size: number
date: string;
count: number;
size: number;
}
/**
* 文件分类/类型统计项
*/
export interface DistributionItem {
name: string
count: number
size: number
name: string;
count: number;
size: number;
}
/**
* 文件统计信息响应
*/
export interface FileStatsResponse {
total_count: number
total_size: number
trend: TrendItem[]
categories: DistributionItem[]
types: DistributionItem[]
}
total_count: number;
total_size: number;
trend: TrendItem[];
categories: DistributionItem[];
types: DistributionItem[];
}
+14 -7
View File
@@ -1,8 +1,8 @@
import type {InternalAxiosRequestConfig} from 'axios';
import type { InternalAxiosRequestConfig } from 'axios';
import {apiConfig} from '../core/config';
import {BaseService} from '../core/base.service';
import type {ListUploadsResponse, Upload, UploadImageResponse} from './types';
import { apiConfig } from '../core/config';
import { BaseService } from '../core/base.service';
import type { ListUploadsResponse, Upload, UploadImageResponse } from './types';
export class UploadService extends BaseService {
protected static readonly basePath = '/api/v1/upload';
@@ -50,7 +50,10 @@ export class UploadService extends BaseService {
type?: string,
extension?: string,
): Promise<ListUploadsResponse> {
const params: Record<string, string | number> = { page, page_size: pageSize };
const params: Record<string, string | number> = {
page,
page_size: pageSize,
};
if (keyword) params.keyword = keyword;
if (type) params.type = type;
if (extension) params.extension = extension;
@@ -61,7 +64,11 @@ export class UploadService extends BaseService {
return this.delete<void>(`/${id}`);
}
static async updateMyFile(id: string, fileName: string, accessMode?: number): Promise<Upload> {
static async updateMyFile(
id: string,
fileName: string,
accessMode?: number,
): Promise<Upload> {
return this.put<Upload>(`/${id}`, {
file_name: fileName,
access_mode: accessMode,
@@ -77,4 +84,4 @@ export class UploadService extends BaseService {
static getDownloadUrl(id: string): string {
return `${this.basePath}/download/${id}`;
}
}
}
+1 -1
View File
@@ -15,4 +15,4 @@ export function formatFileSize(bytes: number): string {
const sizes = ['B', 'KB', 'MB', 'GB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`;
}
}