|
|
@@ -85,21 +85,13 @@
|
|
|
<div class="d-flex justify-center">
|
|
|
<video ref="videos" v-show="true" width="150" height="120"></video>
|
|
|
<video ref="video" v-show="false" width="640" height="480"></video>
|
|
|
- <el-upload
|
|
|
- class="avatar-uploader"
|
|
|
- action
|
|
|
- :show-file-list="false"
|
|
|
- :with-credentials="false"
|
|
|
- :http-request="selectPicUpload"
|
|
|
- >
|
|
|
- <canvas
|
|
|
- name="file"
|
|
|
- v-show="false"
|
|
|
- width="640"
|
|
|
- height="480"
|
|
|
- ref="canvas"
|
|
|
- ></canvas>
|
|
|
- </el-upload>
|
|
|
+ <canvas
|
|
|
+ name="file"
|
|
|
+ v-show="false"
|
|
|
+ width="640"
|
|
|
+ height="480"
|
|
|
+ ref="canvas"
|
|
|
+ ></canvas>
|
|
|
<!-- 预留给反作弊-->
|
|
|
</div>
|
|
|
<div class="flex-shrink-0">
|
|
|
@@ -374,7 +366,7 @@ import { getQuestionStem } from '@/api/question'
|
|
|
import { objectiveJudge } from '@/api/judge'
|
|
|
import dayjs from 'dayjs'
|
|
|
import { TIME_FORMAT } from '@/utils/common'
|
|
|
-import InputFocus from '@/views/exam/components/InputFocus.vue'
|
|
|
+import { InputFocus } from '@/views/exam/components/InputFocus.ts'
|
|
|
import axios from 'axios'
|
|
|
import qs from 'qs'
|
|
|
|
|
|
@@ -415,9 +407,13 @@ export default Vue.extend({
|
|
|
codeQuestionsReady: false,
|
|
|
endTimeChanged: false,
|
|
|
|
|
|
+ mediaTracks: [] as MediaStreamTrack[],
|
|
|
time: 0,
|
|
|
allowNum: 3,
|
|
|
- interval: 0,
|
|
|
+ videoInterval: 0,
|
|
|
+ focusAutoInterval: 0,
|
|
|
+ timeCountInterval: 0,
|
|
|
+ ipInterval: 0,
|
|
|
flag: 1,
|
|
|
vCardFlag: 1,
|
|
|
visible: false,
|
|
|
@@ -441,10 +437,6 @@ export default Vue.extend({
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- test() {
|
|
|
- alert(this.allowNum)
|
|
|
- },
|
|
|
-
|
|
|
getUserIp() {
|
|
|
let ip = localStorage.getItem('Ip')
|
|
|
let id = this.$store.getters.getId
|
|
|
@@ -494,7 +486,7 @@ export default Vue.extend({
|
|
|
},
|
|
|
|
|
|
getUserIpAuto() {
|
|
|
- let i = setInterval(this.getUserIp, 1000)
|
|
|
+ this.ipInterval = setInterval(this.getUserIp, 1000)
|
|
|
},
|
|
|
|
|
|
preventBlur(event: any) {
|
|
|
@@ -523,7 +515,7 @@ export default Vue.extend({
|
|
|
this.monitor()
|
|
|
}
|
|
|
const fo = this.$refs.focusOn
|
|
|
- let intval = setInterval(function() {
|
|
|
+ this.focusAutoInterval = setInterval(function() {
|
|
|
if (
|
|
|
(InputFocus as any).InputFlag == 1 &&
|
|
|
(InputFocus as any).codeFlag == 1
|
|
|
@@ -542,17 +534,17 @@ export default Vue.extend({
|
|
|
this.time++
|
|
|
if (this.time > 10) {
|
|
|
this.time = 0
|
|
|
- clearInterval(this.interval)
|
|
|
+ clearInterval(this.timeCountInterval)
|
|
|
this.visible1 = true
|
|
|
}
|
|
|
},
|
|
|
|
|
|
timeCount() {
|
|
|
- this.interval = setInterval(this.timeWatch, 1000)
|
|
|
+ this.timeCountInterval = setInterval(this.timeWatch, 1000)
|
|
|
},
|
|
|
|
|
|
stopTimeCount() {
|
|
|
- clearInterval(this.interval)
|
|
|
+ clearInterval(this.timeCountInterval)
|
|
|
this.time = 0
|
|
|
this.focusAuto()
|
|
|
;(InputFocus as any).ExamFlag = 1
|
|
|
@@ -618,6 +610,7 @@ export default Vue.extend({
|
|
|
})
|
|
|
.then((success) => {
|
|
|
var videoTracks = success.getVideoTracks()
|
|
|
+ this.mediaTracks = success.getTracks()
|
|
|
console.log(success)
|
|
|
console.log(videoTracks)
|
|
|
// 摄像头开启成功
|
|
|
@@ -627,7 +620,7 @@ export default Vue.extend({
|
|
|
// 实时拍照效果
|
|
|
;(this.$refs['video'] as any).play()
|
|
|
;(this.$refs['videos'] as any).play()
|
|
|
- this.interval = setInterval(this.photoCount, 1000)
|
|
|
+ this.videoInterval = setInterval(this.photoCount, 1000)
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
console.error('摄像头开启失败,请检查摄像头是否可用!')
|
|
|
@@ -833,6 +826,7 @@ export default Vue.extend({
|
|
|
|
|
|
getExamById(this.examId).then(({ data }) => {
|
|
|
this.examInfo = data.result
|
|
|
+ this.initMonitor() // 根据考试信息进行是否监考初始化
|
|
|
this.endTime = dayjs(this.examInfo.endTime, TIME_FORMAT).valueOf()
|
|
|
this.currentTime = dayjs().valueOf()
|
|
|
const startTime = dayjs(this.examInfo.startTime, TIME_FORMAT).valueOf()
|
|
|
@@ -875,19 +869,32 @@ export default Vue.extend({
|
|
|
this.objectiveAnswers = new Map<ID, Record>()
|
|
|
})
|
|
|
})
|
|
|
+ },
|
|
|
+ initMonitor() {
|
|
|
+ if (this.examInfo.antiCheating) {
|
|
|
+ ;(this.$refs.focusOn as any).focus()
|
|
|
+ this.getUserIp()
|
|
|
+ this.isFullScreen()
|
|
|
+ this.getMedia()
|
|
|
+ this.saveIP()
|
|
|
+ this.getUserIpAuto()
|
|
|
+ window.onresize = () => {
|
|
|
+ this.isFullScreen()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
this.fetchData()
|
|
|
- ;(this.$refs.focusOn as any).focus()
|
|
|
- this.getUserIp()
|
|
|
- this.isFullScreen()
|
|
|
- this.getMedia()
|
|
|
- this.saveIP()
|
|
|
- this.getUserIpAuto()
|
|
|
- window.onresize = () => {
|
|
|
- this.isFullScreen()
|
|
|
- }
|
|
|
+ },
|
|
|
+ beforeDestroy() {
|
|
|
+ clearInterval(this.videoInterval)
|
|
|
+ clearInterval(this.timeCountInterval)
|
|
|
+ clearInterval(this.focusAutoInterval)
|
|
|
+ clearInterval(this.ipInterval)
|
|
|
+ this.mediaTracks.forEach((val) => {
|
|
|
+ val.stop()
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
</script>
|