Browse Source

代码整理

cxmo 1 year ago
parent
commit
e75c9a6bfe
2 changed files with 1 additions and 19 deletions
  1. 1 18
      src/hooks/useUploadFileToOSS.js
  2. 0 1
      src/store/modules/publicSetting.js

+ 1 - 18
src/hooks/useUploadFileToOSS.js

@@ -68,18 +68,6 @@ export async function useUploadFileToOSS(data,fileName,isMultipart=false){
     return resUrl
 }
 
-//vite 不支持Buffer 代替Buffer.form方法
-const toBinary = (data)=>{
-    const length = data.length
-    let buf = new ArrayBuffer(length)
-    let view  = new Uint8Array(buf)
-    for(let i=0;i<length;++i){
-        view[i] = data[i]
-    }
-    let blob = new Blob([buf],{type:'application/x-tra'})
-    const url = URL.createObjectURL(blob)
-    return url
-}
 //上传到minio
 // minio sdk 文档 https://min.io/docs/minio/linux/developers/javascript/API.html
 export async function useUploadToMinIO (file, fileName, options = {}){
@@ -125,9 +113,6 @@ export async function useUploadToMinIO (file, fileName, options = {}){
                         let bufferStream = new stream.PassThrough();
                         // 转化成数据流  minio接受数据流格式
                         bufferStream.end(Buffer.from(dataurl))
-                        //bufferStream.end(toBinary(dataurl))
-                        // console.log(bufferStream);
-                        const bufferUrl = toBinary(dataurl)
                         minioClient.putObject(res.Data.Bucketname, fileName, bufferStream, file.size, metaData, function (err, etag) {
                             if (err) {
                                 return console.log("上传到minio失败:" + err)
@@ -147,15 +132,13 @@ export async function useUploadToMinIO (file, fileName, options = {}){
                     const dataurl = e.target.result;
                     let bufferStream = new stream.PassThrough();
                     bufferStream.end(Buffer.from(dataurl))
-                    //bufferStream.end(toBinary(dataurl))
-                    const bufferUrl = toBinary(dataurl)
                     minioClient.putObject(res.Data.Bucketname, fileName, bufferStream, metaData, function (err, etag) {
                         if (err) {
                             console.log("上传到minio失败:" + err)
                             return 
                         }
                         let fileUrl = fileName.startsWith('/') ? res.Data.ImgHost + fileName : res.Data.ImgHost + "/" + fileName
-                        console.log('test',fileUrl)
+                        //console.log('test',fileUrl)
                         return fileUrl
                     })
                 }

+ 0 - 1
src/store/modules/publicSetting.js

@@ -21,7 +21,6 @@ export const usePublicSettingStore = defineStore('publicSetting',{
         }
       })
       this.publicSetting = filterObj
-      console.log('a')
     }
   }
 })