仅能打开一个python页面限制

master
yujialong 5 months ago
parent 93987d0e74
commit 9f37d8be0a
  1. 22
      src/App.vue
  2. 8
      src/components/TestPanel.vue
  3. 42
      src/util/index.js
  4. 41
      src/views/Home.vue

@ -5,6 +5,7 @@
</template>
<script>
import Util from '@/util'
export default {
name: "App",
created () {
@ -17,10 +18,26 @@ export default {
JSON.parse(sessionStorage.getItem("store"))
)
);
} //vuexsessionStorage
}
//vuexsessionStorage
window.addEventListener("beforeunload", () => {
console.log('beforeunload')
const opened = +localStorage.getItem('opened')
if (opened) {
localStorage.setItem('opened', opened - 1)
} else {
localStorage.removeItem('opened')
}
sessionStorage.setItem("store", JSON.stringify(this.$store.state));
});
//
if (!document.referrer) {
localStorage.setItem('opened', 2)
Util.exit()
}
}
};
</script>
@ -32,9 +49,8 @@ export default {
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
}
body {
margin: 0;
}
</style>

@ -164,7 +164,7 @@
<script>
import newmain from "../util/newMain";
import quill from "@/components/quill";
import util from '@/util'
import Util from '@/util'
import Config from '@/config'
import Cookie from 'js-cookie'
import 'quill/dist/quill.core.css';
@ -824,7 +824,7 @@ export default {
const date = await this.getNow()
const { entryTime } = this
const timeSum = Math.ceil((date - entryTime) / 60000) //
const submitTime = util.formatDate('yyyy-MM-dd hh:mm:ss', date)
const submitTime = Util.formatDate('yyyy-MM-dd hh:mm:ss', date)
const projectId = this.projectId
const pro = this.projectList.find(e => e.projectId == projectId)
const projectName = pro ? pro.projectName : '' //
@ -847,7 +847,7 @@ export default {
classId: this.classId ? this.classId : '',
className: this.className ? this.className : '',
curriculumId: this.courseId,
startTime: util.formatDate('yyyy-MM-dd hh:mm:ss', entryTime), //
startTime: Util.formatDate('yyyy-MM-dd hh:mm:ss', entryTime), //
endTime: this.projectPermissions ? this.endTime : submitTime, //
submitTime, // 3
timeSum,
@ -881,7 +881,7 @@ export default {
}
score += e.examScore //
})
this.grade = util.handleZero(score) // 0()
this.grade = Util.handleZero(score) // 0()
this.reportId = reportId
this.$store.commit('setReportId', reportId)
this.$store.commit('setTaskList', taskList)

@ -1,22 +1,7 @@
export default {
getCookie(cookie_name) {
//获取cookie中指定key的value
var allcookies = document.cookie; //索引长度,开始索引的位置
var cookie_pos = allcookies.indexOf(cookie_name); // 如果找到了索引,就代表cookie存在,否则不存在
if (cookie_pos != -1) {
// 把cookie_pos放在值的开始,只要给值加1即可
//计算取cookie值得开始索引,加的1为“=”
cookie_pos = cookie_pos + cookie_name.length + 1; //计算取cookie值得结束索引
var cookie_end = allcookies.indexOf(";", cookie_pos);
import Config from '@/config'
import Cookie from 'js-cookie'
if (cookie_end == -1) {
cookie_end = allcookies.length;
} //得到想要的cookie的值
var value = unescape(allcookies.substring(cookie_pos, cookie_end));
}
return value;
},
export default {
// 返回格式化时间,传参例如:"yyyy-MM-dd hh:mm:ss"
formatDate (fmt, date) {
var date = date ? date : new Date()
@ -114,5 +99,26 @@ export default {
// 小于0前面加上0
handleZero (num) {
return num < 10 ? '0' + num : num
},
// 退出实验
exit () {
let href = Config.isDev ?
`http://${location.hostname}:8082/#/` :
`${location.origin}${Cookie.get('admin-fromManager') ?
'/admin' :
(!Config.isTest) ?
'' :
'/student'}/#/`
// 考核
if (Cookie.get('admin-assessmentId')) {
href += `ass/list`
} else if (Cookie.get('admin-competitionId')) {
// 竞赛
href += `match/list`
} else {
// 练习
href += `station/preview?courseId=${Cookie.get('admin-courseId')}&curriculumName=${Cookie.get('admin-curriculumName') ? decodeURIComponent(Cookie.get('admin-curriculumName')) : 'python'}&mallId=${Cookie.get('admin-mallId')}`
}
location.href = href
}
}

@ -50,9 +50,10 @@
</template>
<script>
import newmain from "../util/newMain";
import testPanel from "../components/TestPanel";
import codemirror from "../components/codemirror";
import newmain from "../util/newMain"
import Util from '@/util'
import testPanel from "../components/TestPanel"
import codemirror from "../components/codemirror"
import Cookie from 'js-cookie'
import { Loading } from 'element-ui'
import Config from '@/config'
@ -95,16 +96,19 @@ export default {
testPanel
},
mounted () {
//
if (!document.referrer) {
const opened = +localStorage.getItem('opened')
if (opened) {
localStorage.setItem('opened', opened + 1)
this.notAllowed = 1
this.$alert('我们注意到您当前已尝试打开多个实验页面。为保证实验的公平性和诚信,系统仅允许单个实验页面处于活跃状态。', '提示', {
confirmButtonText: '退出当前页面',
showClose: false,
callback: action => {
this.back()
}
beforeClose: () => {
Util.exit()
},
})
} else {
localStorage.setItem('opened', 1)
}
document.onkeydown = function (event) {
@ -158,7 +162,7 @@ export default {
if ((new Date().getTime() - lastTime) > this.$config.autoLogoutTime) {
logout || this.$message.error('用户登录过期,请重新登录')
logout = true
setTimeout(this.back, 1500)
setTimeout(Util.exit, 1500)
}
}, 1000)
},
@ -177,24 +181,7 @@ export default {
},
// 退
back () {
let href = this.$config.isDev ?
`http://${location.hostname}:8082/#/` :
`${location.origin}${this.fromManager ?
'/admin' :
(!this.$config.isTest) ?
'' :
'/student'}/#/`
//
if (this.assessmentId) {
href += `ass/list`
} else if (this.competitionId) {
//
href += `match/list`
} else {
//
href += `station/preview?courseId=${this.courseId}&curriculumName=${this.curriculumName}&mallId=${this.mallId}`
}
location.href = href
Util.exit()
},
// id
setPoints (projectId, systemId, workbench) {

Loading…
Cancel
Save