oss上传秘钥加密及低代码平台嵌入

master V3.0.0
yujialong 4 months ago
parent a7a04ff314
commit 1c3297c0c0
  1. 10
      package-lock.json
  2. 2
      package.json
  3. 16
      src/App.vue
  4. 1
      src/api/index.js
  5. 32
      src/components/upload/config.js
  6. 11
      src/components/upload/upload.js
  7. 2
      src/config/index.js
  8. 13
      src/views/Home.vue

10
package-lock.json generated

@ -4666,6 +4666,11 @@
"randomfill": "^1.0.3" "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": { "css": {
"version": "2.2.4", "version": "2.2.4",
"resolved": "https://registry.npm.taobao.org/css/download/css-2.2.4.tgz", "resolved": "https://registry.npm.taobao.org/css/download/css-2.2.4.tgz",
@ -8912,6 +8917,11 @@
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
"dev": true "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": { "jsesc": {
"version": "2.5.2", "version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",

@ -13,12 +13,14 @@
"axios": "^0.19.2", "axios": "^0.19.2",
"clipboard": "^2.0.10", "clipboard": "^2.0.10",
"core-js": "^3.19.3", "core-js": "^3.19.3",
"crypto-js": "^4.2.0",
"element-ui": "^2.15.6", "element-ui": "^2.15.6",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"html2canvas": "^1.4.1", "html2canvas": "^1.4.1",
"image-webpack-loader": "^8.1.0", "image-webpack-loader": "^8.1.0",
"jquery": "^3.6.0", "jquery": "^3.6.0",
"js-cookie": "^3.0.1", "js-cookie": "^3.0.1",
"jsencrypt": "^3.3.2",
"jspdf": "^2.5.1", "jspdf": "^2.5.1",
"lib-flexible": "^0.3.2", "lib-flexible": "^0.3.2",
"mavon-editor": "^2.10.4", "mavon-editor": "^2.10.4",

@ -19,23 +19,19 @@ export default {
) )
); );
} }
//
if (!document.referrer) {
Util.exit()
return false
}
//vuexsessionStorage //vuexsessionStorage
window.addEventListener("beforeunload", () => { 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)); sessionStorage.setItem("store", JSON.stringify(this.$store.state));
}); });
//
if (!document.referrer) {
localStorage.setItem('opened', 2)
Util.exit()
}
} }
}; };
</script> </script>

@ -1,5 +1,6 @@
import config from '@/config' import config from '@/config'
export default { export default {
encrypt: `nakadai/data/encrypt`,
getCurrentTime: `competition/competition/management/getCurrentTime`, getCurrentTime: `competition/competition/management/getCurrentTime`,
getProjectDetail: 'occupationlab/occupationlab/projectManage/getProjectDetail', getProjectDetail: 'occupationlab/occupationlab/projectManage/getProjectDetail',
submit: 'python/python/submit', submit: 'python/python/submit',

@ -1,15 +1,41 @@
/** /**
* 阿里云oss配置 * 阿里云oss配置
* */ * */
import { get } from '@/api/http'
import api from '@/api'
import CryptoJS from 'crypto-js'
import JSEncrypt from 'jsencrypt'
export default { 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账号信息 // oss账号信息
config: { config: {
region: 'oss-cn-shenzhen', region: 'oss-cn-shenzhen',
accessKeyId: 'LTAI4FzqQHnk4rozqLZ8jCNj', accessKeyId: RE[0],
accessKeySecret: 'mveW7B1OyFoKUkHm8WsxmrjHmkJWHq', accessKeySecret: RE[1],
bucket: 'huoran' bucket: 'huoran'
}, },
// 上传成功url前置部分(成功回调没有返回url) // 上传成功url前置部分(成功回调没有返回url)
preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/' preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/'
} }
} catch (e) { }
}

@ -5,10 +5,13 @@ import OssConfig from './config'
import Util from '@/util' import Util from '@/util'
let client = null let client = null
let Oss
// 初始化oss // 初始化oss
const initOss = () => { const initOss = async () => {
if (!client) client = new OSS(OssConfig.config) Oss = await OssConfig()
if (!client) client = new OSS(Oss.config)
} }
initOss()
export default { export default {
// 上传文件 // 上传文件
@ -21,7 +24,7 @@ export default {
resolve({ resolve({
format: Util.getFileExt(file.name), format: Util.getFileExt(file.name),
name: file.name, name: file.name,
url: OssConfig.preUrl + res.name, url: Oss.preUrl + res.name,
size: file.size, size: file.size,
}) })
} catch (error) { } catch (error) {
@ -32,6 +35,6 @@ export default {
// 删除文件(传完整url,不是没有https的name,因为很多接口没有存name,只存url,所以统一使用url) // 删除文件(传完整url,不是没有https的name,因为很多接口没有存name,只存url,所以统一使用url)
async del (url) { async del (url) {
initOss() initOss()
await client.delete(url.replace(OssConfig.preUrl, '')); await client.delete(url.replace(Oss.preUrl, ''));
} }
} }

@ -14,7 +14,7 @@ let bankPath = `${location.origin}/banksystem` // 银行系统
// 121.37.12.51 | 192.168.31.151 // 121.37.12.51 | 192.168.31.151
if (isDev) { if (isDev) {
host = 'http://192.168.31.217:9000/' 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/' // host = 'https://occupationlab.com/'
bankPath = `http://${location.hostname}:8093` bankPath = `http://${location.hostname}:8093`
} else if (isPro) { } else if (isPro) {

@ -3,11 +3,11 @@
<div class="header" :class="{ hh: $config.isHh }"> <div class="header" :class="{ hh: $config.isHh }">
<img v-if="$config.isHh" src="@/assets/images/logo-hh.png" alt="" class="logo"> <img v-if="$config.isHh" src="@/assets/images/logo-hh.png" alt="" class="logo">
<p v-else>{{ curriculumName }}</p> <p v-else>{{ curriculumName }}</p>
<p v-if="isAI">账号{{ account }}密码112233aa</p> <p v-if="third === 'ai'">账号{{ account }}密码112233aa</p>
<el-button class="back btn" type="primary" @click="back">退出实验</el-button> <el-button class="back btn" type="primary" @click="back">退出实验</el-button>
</div> </div>
<template v-if="!notAllowed"> <template v-if="!notAllowed">
<iframe v-if="isAI" class="AI" src="https://ai.huorantech.cn/" frameborder="0" width="100%"></iframe> <iframe v-if="third" class="AI" :src="iframeSrc" frameborder="0" width="100%"></iframe>
<template v-else> <template v-else>
<div class="top"> <div class="top">
<div class="language"> <div class="language">
@ -65,7 +65,8 @@ export default {
data () { data () {
return { return {
Config, Config,
isAI: Cookie.get('admin-isAI') == 'true' ? true : false, third: Cookie.get('admin-third'), // iframe
iframeSrc: '',
isSubmit: Cookie.get('admin-isSubmit') == 'true' ? true : false, // isSubmit: Cookie.get('admin-isSubmit') == 'true' ? true : false, //
loaded: false, // loaded: false, //
loadIns: null, // loading loadIns: null, // loading
@ -109,13 +110,15 @@ export default {
testPanel testPanel
}, },
mounted () { mounted () {
if (this.isAI) { if (this.third) {
this.language = 'vscode' this.language = 'vscode'
this.handleAI() this.third === 'ai' && this.handleAI()
this.iframeSrc = this.third === 'ai' ? 'https://ai.huorantech.cn/' : 'https://lowcode.izhixinyun.com/'
document.body.style.overflow = 'hidden' document.body.style.overflow = 'hidden'
this.loaded = true this.loaded = true
} else { } else {
Cookie.set('admin-language', 'python3.7.9') Cookie.set('admin-language', 'python3.7.9')
// const opened = +localStorage.getItem('opened') // const opened = +localStorage.getItem('opened')
// if (opened) { // if (opened) {
// localStorage.setItem('opened', opened + 1) // localStorage.setItem('opened', opened + 1)

Loading…
Cancel
Save