第一次提交

This commit is contained in:
gxwebsoft
2023-08-04 13:14:48 +08:00
commit 1b923e5cff
1030 changed files with 128016 additions and 0 deletions

56
api/upload.js Normal file
View File

@@ -0,0 +1,56 @@
import http from './index.js';
import {
fileUrl
} from '@/config.js';
import storage from '@/utils/storage'
import dayjs from "dayjs"
import appConfig from '@/config.js'
// 文件服务器
// export const uploadFile = (file) => http.upload(fileUrl + '/api/file/upload', file)
// 阿里云OSS
export const uploadFile = (file) => http.upload('/oss/upload', file)
// export const uploadFile = async ({filePath}) => {
// // 获取临时凭证
// let sts = storage.get('sts');
// if(!sts){
// const stsRes = await http.get('/oss/getPostForm')
// sts = stsRes.data
// storage.set('sts', sts, 60)
// }
// const {polocyBase64,signature} = sts;
// var suffix = filePath.substring(filePath.lastIndexOf(".")); //.txt
// const fileName = dayjs().format('YYYYMMDD') + '/'+ uni.$u.guid() + suffix;
// return new Promise((reso, rej) => {
// uni.uploadFile({
// url: appConfig.fileUrl, // 开发者服务器的URL。
// filePath: filePath,
// name: 'file', // 必须填file。
// formData: {
// key: fileName,
// 'policy': polocyBase64,
// 'OSSAccessKeyId': 'LTAI5t8UTh8CTXEi2dYxobhj',
// 'success_action_status': '200', //让服务端返回200,不然默认会返回204
// 'signature': signature,
// // 'x-oss-security-token': this.stsToken,
// },
// success: (res) => {
// const webUrl = appConfig.fileUrl + '/' + fileName;
// reso({data: {url: webUrl,thumb: webUrl}})
// },
// fail: err => {
// rej(err)
// }
// });
// })
// }
export const getTempOssToken = () => http.get('/oss/getTempToken')
export default {
uploadFile,
getTempOssToken
}