mirror of
https://github.com/dataease/dataease.git
synced 2026-05-18 17:58:11 +08:00
refactor: 背景图片直接存储在服务器
refactor: 背景图片直接存储在服务器
This commit is contained in:
26
frontend/src/api/staticResource/staticResource.js
Normal file
26
frontend/src/api/staticResource/staticResource.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import request from '@/utils/request'
|
||||
import { uuid } from 'vue-uuid'
|
||||
import store from '@/store'
|
||||
|
||||
export function uploadFile(fileId, file) {
|
||||
const param = new FormData()
|
||||
param.append('file', file.file)
|
||||
return request({
|
||||
url: '/static/resource/upload/' + fileId,
|
||||
method: 'post',
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
data: param,
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
|
||||
export function uploadFileResult(file, callback) {
|
||||
const fileId = uuid.v1()
|
||||
const fileName = file.file.name
|
||||
const newFileName = fileId + fileName.substr(fileName.lastIndexOf('.'), fileName.length)
|
||||
const fileUrl = store.state.staticResourcePath + newFileName
|
||||
uploadFile(fileId, file).then(() => {
|
||||
callback(fileUrl)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user