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) => { |
||||||
|
const keyHex = CryptoJS.enc.Base64.parse(key) |
||||||
|
const decrypted = CryptoJS.AES.decrypt(encryptedData, keyHex, { |
||||||
|
mode: CryptoJS.mode.ECB, |
||||||
|
padding: CryptoJS.pad.Pkcs7 |
||||||
|
}) |
||||||
|
return decrypted.toString(CryptoJS.enc.Utf8) |
||||||
|
} |
||||||
|
|
||||||
|
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账号信息
|
// oss账号信息
|
||||||
config: { |
config: { |
||||||
region: 'oss-cn-shenzhen', |
region: 'oss-cn-shenzhen', |
||||||
accessKeyId: 'LTAI4FzqQHnk4rozqLZ8jCNj', |
accessKeyId: RE[0], |
||||||
accessKeySecret: 'mveW7B1OyFoKUkHm8WsxmrjHmkJWHq', |
accessKeySecret: RE[1], |
||||||
bucket: 'huoran' |
bucket: 'huoran' |
||||||
}, |
}, |
||||||
// 上传成功url前置部分(成功回调没有返回url)
|
// 上传成功url前置部分(成功回调没有返回url)
|
||||||
preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/' |
preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/' |
||||||
} |
} |
||||||
|
} catch (e) { } |
||||||
|
} |
Loading…
Reference in new issue