parent
a7a04ff314
commit
1c3297c0c0
8 changed files with 91 additions and 50 deletions
@ -1,15 +1,41 @@ |
|||||||
/** |
/** |
||||||
* 阿里云oss配置 |
* 阿里云oss配置 |
||||||
* */ |
* */ |
||||||
|
import { get } from '@/api/http' |
||||||
|
import api from '@/api' |
||||||
|
import CryptoJS from 'crypto-js' |
||||||
|
import JSEncrypt from 'jsencrypt' |
||||||
|
|
||||||
export default { |
const A = (key, encryptedData) => { |
||||||
// oss账号信息
|
const keyHex = CryptoJS.enc.Base64.parse(key) |
||||||
config: { |
const decrypted = CryptoJS.AES.decrypt(encryptedData, keyHex, { |
||||||
region: 'oss-cn-shenzhen', |
mode: CryptoJS.mode.ECB, |
||||||
accessKeyId: 'LTAI4FzqQHnk4rozqLZ8jCNj', |
padding: CryptoJS.pad.Pkcs7 |
||||||
accessKeySecret: 'mveW7B1OyFoKUkHm8WsxmrjHmkJWHq', |
}) |
||||||
bucket: 'huoran' |
return decrypted.toString(CryptoJS.enc.Utf8) |
||||||
}, |
} |
||||||
// 上传成功url前置部分(成功回调没有返回url)
|
|
||||||
preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/' |
const R = (encryptedKey, privateKey) => { |
||||||
|
const decrypt = new JSEncrypt() |
||||||
|
decrypt.setPrivateKey(privateKey) |
||||||
|
const decryptedKey = decrypt.decrypt(encryptedKey) |
||||||
|
return decryptedKey |
||||||
|
} |
||||||
|
|
||||||
|
export default async function () { |
||||||
|
try { |
||||||
|
const res = await get(api.encrypt) |
||||||
|
const RE = A(R(res.encryptedKey, res.privateKey), res.encryptedData).split('/') |
||||||
|
return { |
||||||
|
// oss账号信息
|
||||||
|
config: { |
||||||
|
region: 'oss-cn-shenzhen', |
||||||
|
accessKeyId: RE[0], |
||||||
|
accessKeySecret: RE[1], |
||||||
|
bucket: 'huoran' |
||||||
|
}, |
||||||
|
// 上传成功url前置部分(成功回调没有返回url)
|
||||||
|
preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/' |
||||||
|
} |
||||||
|
} catch (e) { } |
||||||
} |
} |
Loading…
Reference in new issue