feat: add ai-html

This commit is contained in:
2025-06-02 13:22:04 +08:00
parent a43cfb4b5f
commit a309faead0
46 changed files with 11067 additions and 416 deletions

View File

@@ -0,0 +1,30 @@
import { uploadChunkV2 } from '@/apps/draw/modules/upload';
import { toFile } from '@/apps/draw/modules/to-file';
import { toast } from 'react-toastify';
type UploadFileOpts = {
appKey: string;
version: string;
filename: string;
text: string;
};
const getFilenameExtension = (filename: string) => {
return filename.split('.').pop() || '';
};
const allowFilesName = ['js', 'css', 'json', 'html'];
export const uploadFile = async (uploadFileOpts: UploadFileOpts) => {
const { appKey, version, filename, text } = uploadFileOpts;
const extension = getFilenameExtension(filename);
if (!allowFilesName.includes(extension)) {
toast.error('文件类型不支持');
return;
}
const file = toFile(text, filename);
const res = await uploadChunkV2(file, {
appKey,
version,
filename,
noCheckAppFiles: false,
});
return res as any;
};