feat: add drawer and add upload feat
This commit is contained in:
@@ -8,13 +8,18 @@ type ConvertOpts = {
|
||||
appKey?: string;
|
||||
version?: string;
|
||||
username?: string;
|
||||
directory?: string;
|
||||
};
|
||||
export const uploadFiles = async (files: File[], opts: ConvertOpts) => {
|
||||
const { directory } = opts;
|
||||
return new Promise((resolve, reject) => {
|
||||
const formData = new FormData();
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
formData.append('file', files[i], files[i].name);
|
||||
}
|
||||
if (directory) {
|
||||
formData.append('directory', directory);
|
||||
}
|
||||
const token = localStorage.getItem('token');
|
||||
if (!token) {
|
||||
toastLogin();
|
||||
@@ -23,8 +28,8 @@ export const uploadFiles = async (files: File[], opts: ConvertOpts) => {
|
||||
const taskId = nanoid();
|
||||
// 49.232.155.236:11015
|
||||
// const eventSource = new EventSource('https://kevisual.silkyai.cn/api/s1/events?taskId=' + taskId);
|
||||
// const eventSource = new EventSource('/api/s1/events?taskId=' + taskId);
|
||||
const eventSource = new EventSource('http://49.232.155.236:11015/api/s1/events?taskId=' + taskId);
|
||||
const eventSource = new EventSource('/api/s1/events?taskId=' + taskId);
|
||||
// const eventSource = new EventSource('http://49.232.155.236:11015/api/s1/events?taskId=' + taskId);
|
||||
const load = toast.loading('上传中...');
|
||||
NProgress.start();
|
||||
eventSource.onopen = async function (event) {
|
||||
@@ -63,7 +68,6 @@ export const uploadFiles = async (files: File[], opts: ConvertOpts) => {
|
||||
if (progress) {
|
||||
NProgress.set(progress);
|
||||
}
|
||||
|
||||
};
|
||||
eventSource.onerror = function (event) {
|
||||
console.log('eventSource.onerror', event);
|
||||
|
||||
Reference in New Issue
Block a user