add
yj
2024-12-05 b9900893177c78fc559223521fe839aa21000017
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { uploadService } from '@/utils/request'
const uploadPath = process.env.HOST + '/upload/admin'
const uploadLocalPath = process.env.HOST + '/upload/local'
export { uploadPath, uploadLocalPath }
 
export function createStorage(data) {
  return uploadService({
    url: uploadPath,
    method: 'post',
    data
  })
}
 
export function beforeFileUplod(file) {
  const isIMAGE = file.type === 'image/jpeg' || 'image/gif' || 'image/png' || 'image/jpg'
  const isLt1M = file.size / 1024 / 1024 < 1
  if (!isIMAGE) {
    this.$message.error('上传文件只能是图片格式!')
  }
  if (!isLt1M) {
    this.$message.error('上传文件大小不能超过 1MB!')
  }
  return isIMAGE && isLt1M
}