parent
075d877b78
commit
66649dc686
2 changed files with 35 additions and 37 deletions
@ -1,45 +1,21 @@ |
||||
/** |
||||
* 阿里云oss配置 |
||||
* */ |
||||
import { get } from '@/plugins/requests/index.js' |
||||
import api from '@/api' |
||||
import CryptoJS from 'crypto-js' |
||||
import JSEncrypt from 'jsencrypt' |
||||
import Util from '@/libs/util' |
||||
import Setting from '@/setting' |
||||
|
||||
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 { |
||||
if (Util.local.get(Setting.tokenKey)) { |
||||
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/' |
||||
} |
||||
} |
||||
let RE = localStorage.getItem('osc') |
||||
if (RE) RE = JSON.parse(RE) |
||||
return RE ? { |
||||
// 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