diff --git a/package-lock.json b/package-lock.json index 38107cc..ba2db71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3823,6 +3823,11 @@ "randomfill": "^1.0.3" } }, + "crypto-js": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", + "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==" + }, "css": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz", @@ -9345,6 +9350,11 @@ "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" }, + "jsencrypt": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/jsencrypt/-/jsencrypt-3.3.2.tgz", + "integrity": "sha512-arQR1R1ESGdAxY7ZheWr12wCaF2yF47v5qpB76TtV64H1pyGudk9Hvw8Y9tb/FiTIaaTRUyaSnm5T/Y53Ghm/A==" + }, "jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", diff --git a/package.json b/package.json index bbdbdee..500f681 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "ali-oss": "^6.18.1", "axios": "^0.18.0", "babel-polyfill": "^6.26.0", + "crypto-js": "^4.2.0", "decimal.js": "^10.4.3", "echarts": "^4.8.0", "element-theme": "^2.0.1", @@ -19,6 +20,7 @@ "file-saver": "^2.0.5", "image-webpack-loader": "^8.1.0", "js-cookie": "^2.2.1", + "jsencrypt": "^3.3.2", "jszip": "^3.10.1", "mavon-editor": "^2.10.4", "postcss-px2rem": "^0.3.0", diff --git a/src/api/index.js b/src/api/index.js index 120a354..48e9dc6 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -13,6 +13,7 @@ export default { refreshPageNotification: `nakadai/message/refreshPageNotification`, getCurrentTime: `competition/competition/management/getCurrentTime`, heartbeatDetection: `nakadai/message/heartbeatDetection`, + encrypt: `nakadai/data/encrypt`, getPlayAuth: `oss/manage/getPlayAuth`, // 获取播放凭证 diff --git a/src/components/upload/config.js b/src/components/upload/config.js index f8a1254..04818ef 100644 --- a/src/components/upload/config.js +++ b/src/components/upload/config.js @@ -1,15 +1,41 @@ /** * 阿里云oss配置 * */ +import { get } from '@/plugins/requests/index.js' +import api from '@/api' +import CryptoJS from 'crypto-js' +import JSEncrypt from 'jsencrypt' - export default { - // oss账号信息 - config: { - region: 'oss-cn-shenzhen', - accessKeyId: 'LTAI4FzqQHnk4rozqLZ8jCNj', - accessKeySecret: 'mveW7B1OyFoKUkHm8WsxmrjHmkJWHq', - bucket: 'huoran' - }, - // 上传成功url前置部分(成功回调没有返回url) - preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/' +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账号信息 + 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) { } } \ No newline at end of file diff --git a/src/components/upload/index.vue b/src/components/upload/index.vue index 313635f..88c4f34 100644 --- a/src/components/upload/index.vue +++ b/src/components/upload/index.vue @@ -1,25 +1,13 @@