diff --git a/package-lock.json b/package-lock.json index 41bcf6b..4c546de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4666,6 +4666,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.npm.taobao.org/css/download/css-2.2.4.tgz", @@ -8912,6 +8917,11 @@ "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "dev": true }, + "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 37e1ccc..46fe382 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,14 @@ "axios": "^0.19.2", "clipboard": "^2.0.10", "core-js": "^3.19.3", + "crypto-js": "^4.2.0", "element-ui": "^2.15.6", "file-saver": "^2.0.5", "html2canvas": "^1.4.1", "image-webpack-loader": "^8.1.0", "jquery": "^3.6.0", "js-cookie": "^3.0.1", + "jsencrypt": "^3.3.2", "jspdf": "^2.5.1", "lib-flexible": "^0.3.2", "mavon-editor": "^2.10.4", diff --git a/src/App.vue b/src/App.vue index 5e93162..4675eda 100644 --- a/src/App.vue +++ b/src/App.vue @@ -19,23 +19,19 @@ export default { ) ); } + // 保证同一个浏览器只有一个当前系统能打开 + if (!document.referrer) { + Util.exit() + return false + } + //在页面刷新时将vuex里的信息保存到sessionStorage里 window.addEventListener("beforeunload", () => { - const opened = +localStorage.getItem('opened') - if (opened) { - localStorage.setItem('opened', opened - 1) - } else { - localStorage.removeItem('opened') - } + localStorage.removeItem('opened') sessionStorage.setItem("store", JSON.stringify(this.$store.state)); }); - // 保证同一个浏览器只有一个当前系统能打开 - if (!document.referrer) { - localStorage.setItem('opened', 2) - Util.exit() - } } }; diff --git a/src/api/index.js b/src/api/index.js index adfc99a..3591986 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -1,5 +1,6 @@ import config from '@/config' export default { + encrypt: `nakadai/data/encrypt`, getCurrentTime: `competition/competition/management/getCurrentTime`, getProjectDetail: 'occupationlab/occupationlab/projectManage/getProjectDetail', submit: 'python/python/submit', diff --git a/src/components/upload/config.js b/src/components/upload/config.js index f8a1254..2681199 100644 --- a/src/components/upload/config.js +++ b/src/components/upload/config.js @@ -1,15 +1,41 @@ /** * 阿里云oss配置 * */ +import { get } from '@/api/http' +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/upload.js b/src/components/upload/upload.js index e485aa8..e88158d 100644 --- a/src/components/upload/upload.js +++ b/src/components/upload/upload.js @@ -5,33 +5,36 @@ import OssConfig from './config' import Util from '@/util' let client = null +let Oss // 初始化oss -const initOss = () => { - if (!client) client = new OSS(OssConfig.config) +const initOss = async () => { + Oss = await OssConfig() + if (!client) client = new OSS(Oss.config) } +initOss() export default { - // 上传文件 - upload(file) { - initOss() - return new Promise(async (resolve, reject) => { - try { - // 上传到阿里云oss - const res = await client.multipartUpload(Date.now() + '.' + Util.getFileExt(file.name), file); - resolve({ - format: Util.getFileExt(file.name), + // 上传文件 + upload (file) { + initOss() + return new Promise(async (resolve, reject) => { + try { + // 上传到阿里云oss + const res = await client.multipartUpload(Date.now() + '.' + Util.getFileExt(file.name), file); + resolve({ + format: Util.getFileExt(file.name), name: file.name, - url: OssConfig.preUrl + res.name, + url: Oss.preUrl + res.name, size: file.size, - }) - } catch (error) { - reject() - } - }) - }, - // 删除文件(传完整url,不是没有https的name,因为很多接口没有存name,只存url,所以统一使用url) - async del(url) { - initOss() - await client.delete(url.replace(OssConfig.preUrl, '')); - } + }) + } catch (error) { + reject() + } + }) + }, + // 删除文件(传完整url,不是没有https的name,因为很多接口没有存name,只存url,所以统一使用url) + async del (url) { + initOss() + await client.delete(url.replace(Oss.preUrl, '')); + } } diff --git a/src/config/index.js b/src/config/index.js index ebc465e..b174c5d 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -14,7 +14,7 @@ let bankPath = `${location.origin}/banksystem` // 银行系统 // 121.37.12.51 | 192.168.31.151 if (isDev) { host = 'http://192.168.31.217:9000/' - host = 'http://121.37.12.51:9000/' + host = 'http://121.37.12.217:9000/' // host = 'https://occupationlab.com/' bankPath = `http://${location.hostname}:8093` } else if (isPro) { diff --git a/src/views/Home.vue b/src/views/Home.vue index ecc9d60..ac06632 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -3,11 +3,11 @@

{{ curriculumName }}

-

账号:{{ account }};密码:112233aa

+

账号:{{ account }};密码:112233aa

退出实验