29 lines
		
	
	
		
			831 B
		
	
	
	
		
			Plaintext
		
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			831 B
		
	
	
	
		
			Plaintext
		
	
	
| const OSS = require('ali-oss')
 | |
| import Vue from 'vue'
 | |
| const { GenerateSTS, GetObjectStoreToken } = require('../api/user.js')
 | |
| import { getToken } from '@/utils/auth'
 | |
| 
 | |
| Vue.prototype.OSSclientConfig = {
 | |
| }
 | |
| 
 | |
| 
 | |
| async function ossGenerateSTS() {
 | |
|   let res = await GetObjectStoreToken()
 | |
|   Vue.prototype.OSSclientConfig = { ...res.Result[res.Result.ObjectStoreUse] }
 | |
|   Vue.prototype.OSSclientConfig.basePath = Vue.prototype.OSSclientConfig.ViewEndpoint
 | |
|   switch (res.Result.ObjectStoreUse) {
 | |
|     case 'AliyunOSS':
 | |
|       Vue.prototype.OSSclientConfig.bucket = Vue.prototype.OSSclientConfig.bucketName
 | |
|       Vue.prototype.OSSclient = new OSS(Vue.prototype.OSSclientConfig)
 | |
|       break
 | |
|     case 'MinIO':
 | |
|       Vue.prototype.OSSclient = new OSS(Vue.prototype.OSSclientConfig)
 | |
|       break
 | |
|   }
 | |
|   return
 | |
| }
 | |
| 
 | |
| 
 | |
| 
 | |
| export const OSSclient = ossGenerateSTS
 |