fix: 网页版增加对话图片支持

This commit is contained in:
Gsh
2025-12-13 18:09:12 +08:00
parent d2981100fa
commit c073868989
11 changed files with 300 additions and 29 deletions

View File

@@ -0,0 +1,34 @@
import type { UploadFileResponse } from './types';
/**
* 上传文件
* @param file 文件对象
* @returns 返回文件ID数组
*/
export async function uploadFile(file: File): Promise<UploadFileResponse[]> {
const formData = new FormData();
formData.append('file', file);
const uploadApiUrl = import.meta.env.VITE_FILE_UPLOAD_API;
const response = await fetch(`${uploadApiUrl}/prod-api/file`, {
method: 'POST',
body: formData,
});
if (!response.ok) {
throw new Error('文件上传失败');
}
const result = await response.json();
return result;
}
/**
* 生成文件URL
* @param fileId 文件ID
* @returns 文件访问URL
*/
export function getFileUrl(fileId: string): string {
return `https://ccnetcore.com/prod-api/file/${fileId}/true`;
}

View File

@@ -0,0 +1,3 @@
export interface UploadFileResponse {
id: string;
}

View File

@@ -1,6 +1,7 @@
export * from './announcement'
export * from './auth';
export * from './chat';
export * from './file';
export * from './model';
export * from './pay';
export * from './session';