仅能打开一个python页面限制

master
yujialong 5 months ago
parent 05fd504802
commit d90fcd1df0
  1. 26
      src/api/http.js
  2. 10
      src/components/TestPanel.vue
  3. 4
      src/config/index.js
  4. 36
      src/views/Home.vue

@ -20,11 +20,11 @@ service.interceptors.request.use(config => {
config.headers.token = token
}
return config;
}, err => {
}, err => {
Message.error({
message: '退出登陆',
onClose: function () {
router.push({name: 'login'});
router.push({ name: 'login' });
}
})
return Promise.reject(err);
@ -36,9 +36,18 @@ service.interceptors.response.use(
response => {
const res = response.data;
if (res.status == 200 || res.status == 10000 || res.status == 30001) {
return Promise.resolve(res).catch(e => {});
return Promise.resolve(res).catch(e => { });
} else if (res.code === 401) {
// 账号互踢
if (!logouted) {
Message.error(res.msg.includes('顶') ? '您的账号已在其他设备登录,您已被迫下线!' : '登录过期,请重新登录!')
setTimeout(() => {
history.back()
}, 1500)
logouted = 1
}
} else if (!res.status) {
return Promise.resolve(res).catch(e => {});
return Promise.resolve(res).catch(e => { });
} else {
Message.error(res.message)
return Promise.reject(res)
@ -59,7 +68,6 @@ service.interceptors.response.use(
}
break;
default:
// Message.error(error.response.data.message)
Promise.reject(error.response);
}
return Promise.reject(error.response);
@ -67,7 +75,7 @@ service.interceptors.response.use(
}
);
function get(url, params) {
function get (url, params) {
return new Promise((resolve, reject) => {
service.get(url, { params: params }).then(res => {
resolve(res);
@ -77,7 +85,7 @@ function get(url, params) {
});
}
function post(url, params) {
function post (url, params) {
return new Promise((resolve, reject) => {
service.post(url, params).then(res => {
resolve(res);
@ -87,7 +95,7 @@ function post(url, params) {
});
}
function del(url, params) {
function del (url, params) {
return new Promise((resolve, reject) => {
service.delete(url, {
params
@ -99,7 +107,7 @@ function del(url, params) {
});
}
function put(url, params) {
function put (url, params) {
return new Promise((resolve, reject) => {
service.put(url, params).then(res => {
resolve(res);

@ -214,8 +214,10 @@ import "codemirror/theme/base16-light.css";
import { mavonEditor } from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
import Stomp from 'stompjs'
export const MQTT_USERNAME = 'huoran' // , todo: read from database
export const MQTT_PASSWORD = 'huoran2024' // , todo: read from database
// export const MQTT_USERNAME = 'huoran' // , todo: read from database
// export const MQTT_PASSWORD = 'huoran2024' // , todo: read from database
export const MQTT_USERNAME = 'huorantest' // , todo: read from database
export const MQTT_PASSWORD = 'huorantest2024' // , todo: read from database
export default {
data () {
@ -1090,8 +1092,8 @@ export default {
//
connect () {
// let ws = new WebSocket(`ws://124.71.74.9:15674/ws`);
let ws = new WebSocket(`wss://python.occupationlab.com/ws`);
let ws = new WebSocket(`ws://139.159.153.48:15674/ws`);
// let ws = new WebSocket(`wss://python.occupationlab.com/ws`);
this.client = Stomp.over(ws);
this.client.heartbeat.outgoing = 0
this.client.heartbeat.incoming = 0

@ -13,8 +13,8 @@ let host = location.origin + '/'
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://192.168.31.51:9000/'
// host = 'http://121.37.12.51:9000/'
// host = 'https://occupationlab.com/'
bankPath = `http://${location.hostname}:8093`
} else if (isPro) {

@ -5,6 +5,7 @@
<p v-else>{{ curriculumName }}</p>
<el-button class="back btn" type="primary" @click="back">退出实验</el-button>
</div>
<template v-if="!notAllowed">
<div class="top">
<div class="language">
<p v-if="$config.isHh" style="font-size: 18px">{{ $config.title }}</p>
@ -26,7 +27,8 @@
<div class="tab">
<el-tabs v-model="curTab" type="card" @tab-click="judChange">
<el-tab-pane v-for="(item, i) in workbench" :key="item.judgmentId" :label="item.name" :value="item.judgmentId">
<el-tab-pane v-for="(item, i) in workbench" :key="item.judgmentId" :label="item.name"
:value="item.judgmentId">
<codemirror v-if="!language" :ref="'code' + i" :key="codeKey" :projectId.sync="projectId"
:systemId.sync="systemId" :code.sync="item.code" :finalCode.sync="item.finalCode"
:judgmentId="item.judgmentId" :codeId.sync="item.codeId" :answer.sync="item.answer"
@ -38,10 +40,12 @@
</div>
<div class="menu">
<testPanel @tell="setPoints" @recoveryCode="recoveryCode" ref="mainindex" :workbench.sync="workbench"></testPanel>
<testPanel @tell="setPoints" @recoveryCode="recoveryCode" ref="mainindex" :workbench.sync="workbench">
</testPanel>
</div>
<div v-if="isSubmit" class="mask"></div>
</template>
</div>
</template>
@ -82,7 +86,8 @@ export default {
],
curTab: '', //
workbench: [], //
codeKey: 1 //
codeKey: 1, //
notAllowed: 0,
};
},
components: {
@ -90,22 +95,32 @@ export default {
testPanel
},
mounted () {
const opened = localStorage.getItem('opened')
if (opened || opened === '0') {
localStorage.setItem('opened', +opened + 1)
//
const opened = +localStorage.getItem('opened')
if (opened) {
localStorage.setItem('opened', opened + 1)
this.notAllowed = 1
this.$alert('我们注意到您当前已尝试打开多个实验页面。为保证实验的公平性和诚信,系统仅允许单个实验页面处于活跃状态。', '提示', {
confirmButtonText: '退出当前页面',
showClose: false,
callback: action => {
this.back()
}
})
} else {
localStorage.setItem('opened', 1)
}
//
window.addEventListener('unload', function () {
const opened = localStorage.getItem('opened')
const opened = +localStorage.getItem('opened')
if (opened) {
localStorage.setItem('opened', +opened - 1)
localStorage.setItem('opened', opened - 1)
} else {
localStorage.removeItem('opened')
}
});
})
console.log(11, localStorage.getItem('opened'))
document.onkeydown = function (event) {
var e = event || window.event || arguments.callee.caller.arguments[0];
@ -142,7 +157,6 @@ export default {
},
//
toData () {
return console.log(11, localStorage.getItem('opened'))
this.$router.push('/data')
},
// 退

Loading…
Cancel
Save