Skip to content

Commit

Permalink
更新上传文件api
Browse files Browse the repository at this point in the history
  • Loading branch information
more-strive committed Dec 3, 2023
1 parent d0a8ec3 commit dea4054
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/api/file/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import request from '@/utils/request'
import { AxiosPromise } from 'axios'
import { UploadResult } from './types'

/**
* 上传文件
*
* @param file
*/
export function uploadFile(file: File, type: string): AxiosPromise<UploadResult> {
const formData = new FormData()
formData.append('file', file)
formData.append('type', type)
return request({
url: '/api/upload/file',
method: 'post',
data: formData,
headers: {
'Content-Type': 'multipart/form-data',
},
})
}
27 changes: 27 additions & 0 deletions src/api/file/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Template } from "@/types/canvas"

export interface SVGInfo {
width: number
height: number
index: number
svg: string
}

export interface UploadResult {
code: number
msg: string
file: string
svg: SVGInfo[]
data: Template[]
}

/**
* 文件API类型声明
*/
export interface ImgData {
id: number
name: string
dateTime: string
imgPath: string
}

0 comments on commit dea4054

Please sign in to comment.