添加页面大纲功能

This commit is contained in:
wux_labs
2025-02-18 22:31:06 +08:00
parent 8d513d1191
commit 95a374fb03
14 changed files with 663 additions and 5 deletions
+24
View File
@@ -0,0 +1,24 @@
// Copyright (c) 2024-present AI-Labs
/**
* 定义文件上传类
*/
export type Uploader = (file: File, uploadUrl?: string, headers?: Record<string, any>, formName?: string) => Promise<Record<string, any>>;
/**
* 默认的Base64文件处理
* @param file
* @param _uploadUrl
* @param _headers
* @param _formName
* @returns
*/
export const Base64Uploader: Uploader = (file: File, _uploadUrl?: string, _headers?: Record<string, any>, _formName?: string): Promise<Record<string, any>> => {
let reader = new FileReader;
return new Promise((accept, fail) => {
reader.onload = () => accept({ code: 200, data: { src: reader.result, href: file.name } });
reader.onerror = () => fail(reader.error);
setTimeout(() => reader.readAsDataURL(file), 1000);
})
}