diff --git a/src/components/upload/config.js b/src/components/upload/config.js index 326e680..77a573c 100644 --- a/src/components/upload/config.js +++ b/src/components/upload/config.js @@ -1,32 +1,11 @@ /** * 阿里云oss配置 * */ -import { get } from '@/utils/http' -import api from '@/utils/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 { + const RE = localStorage.getItem('osc') + return RE ? { // oss账号信息 config: { region: 'oss-cn-shenzhen', @@ -36,6 +15,6 @@ export default async function () { }, // 上传成功url前置部分(成功回调没有返回url) preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/' - } + } : {} } catch (e) { } } \ No newline at end of file diff --git a/src/views/Login.vue b/src/views/Login.vue index 1f4404e..c0c339d 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -103,6 +103,8 @@ import vFooter from '../components/Footer' import Setting from '@/setting' import addRoutes from '@/libs/route/addRoutes' +import CryptoJS from 'crypto-js' +import JSEncrypt from 'jsencrypt' export default { data: function () { var regPhoneOrEmail = (rule, value, callback) => {// 验证手机或邮箱 @@ -201,6 +203,7 @@ export default { this.$post(this.api.logins, param).then(({ status, data, message }) => { localStorage.removeItem('examPath') localStorage.removeItem('reviewPath') + this.getOss() if (status == 200) { const accounts = data.userAccounts // 如果返回的是数组,则弹框给用户选择登录哪个用户,否则,直接登录 @@ -229,6 +232,28 @@ export default { } }); }, + // 获取oss信息 + 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)) + }, // 选择用户回调 chooseUser (user) { user.isEnable && this.$post(`${this.api.getToken}?id=${user.id}`).then(({ data }) => { diff --git a/src/views/serve/projectAdd.vue b/src/views/serve/projectAdd.vue index 8901c66..71f4832 100644 --- a/src/views/serve/projectAdd.vue +++ b/src/views/serve/projectAdd.vue @@ -1,28 +1,20 @@