yujialong 2 weeks ago
parent 9811ac3bbd
commit d6babd4c52
  1. 28
      src/components/upload/config.js
  2. 32
      src/pages/account/redirect/index.vue

@ -1,32 +1,12 @@
/**
* 阿里云oss配置
* */
import { get } from '@/plugins/requests/index.js'
import api from '@/api'
import CryptoJS from 'crypto-js'
import JSEncrypt from 'jsencrypt'
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 {
let RE = localStorage.getItem('osc')
if (RE) RE = JSON.parse(RE)
return RE ? {
// oss账号信息
config: {
region: 'oss-cn-shenzhen',
@ -36,6 +16,6 @@ export default async function () {
},
// 上传成功url前置部分(成功回调没有返回url)
preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/'
}
} : {}
} catch (e) { }
}

@ -1,9 +1,11 @@
<template></template>
<script>
import { mapActions, mapMutations } from "vuex";
import { mapActions, mapMutations } from 'vuex'
import Util from '@/libs/util'
import Setting from "@/setting";
import Setting from '@/setting'
import CryptoJS from 'crypto-js'
import JSEncrypt from 'jsencrypt'
export default {
data: function () {
return {
@ -12,6 +14,8 @@ export default {
},
mounted () {
localStorage.removeItem('opened')
localStorage.removeItem('review_token')
localStorage.removeItem('reviewPath')
this.token ? this.setLogin() : this.$router.replace('/login')
},
methods: {
@ -22,10 +26,9 @@ export default {
"setCustomerName"
]),
setLogin () {
localStorage.removeItem('review_token')
localStorage.removeItem('reviewPath')
this.SET_FROM(true)
Util.local.set(Setting.tokenKey, window.atob(decodeURI(this.token)), Setting.tokenExpires);
this.getOss()
this.getRole()
this.queryCustomer()
},
@ -43,7 +46,28 @@ export default {
const list = res.permissionMenu[0].children
this.$router.push(list.find(e => e.path === path) ? path : list[0].path)
}).catch(err => { })
},
async getOss () {
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
}
const res = await this.$get(this.api.encrypt)
const RE = A(R(res.encryptedKey, res.privateKey), res.encryptedData).split('/')
localStorage.setItem('osc', JSON.stringify(RE))
},
}
};
</script>

Loading…
Cancel
Save