diff --git a/package-lock.json b/package-lock.json index 5c688d7..3acfa1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3871,6 +3871,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", @@ -9509,6 +9514,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 c9e0195..a780203 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "babel-polyfill": "^6.26.0", "blueimp-md5": "^2.19.0", "clipboard": "^2.0.11", + "crypto-js": "^4.2.0", "decimal.js": "^10.4.3", "echarts": "^5.4.1", "element-theme": "^2.0.1", @@ -22,6 +23,7 @@ "image-conversion": "^2.1.1", "image-webpack-loader": "^8.1.0", "js-cookie": "^3.0.1", + "jsencrypt": "^3.3.2", "jszip": "^3.10.1", "lodash": "^4.17.21", "mavon-editor": "^2.10.4", diff --git a/src/App.vue b/src/App.vue index d6ff496..c12e90f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -16,7 +16,7 @@ export default { data () { return { Setting, - ip: localStorage.getItem('nakadaiIp') ? +localStorage.getItem('nakadaiIp') : 0, + ip: localStorage.getItem('ip') ? +localStorage.getItem('ip') : 0, }; }, created () { @@ -32,7 +32,7 @@ export default { }, methods: { ipChange (val) { - localStorage.setItem('nakadaiIp', val) + localStorage.setItem('ip', val) location.reload() }, } diff --git a/src/components/upload/config.js b/src/components/upload/config.js index f8a1254..326e680 100644 --- a/src/components/upload/config.js +++ b/src/components/upload/config.js @@ -1,15 +1,41 @@ /** * 阿里云oss配置 * */ +import { get } from '@/utils/http' +import api from '@/utils/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 @@