提交 dbc801a2 authored 作者: 王鹏飞's avatar 王鹏飞

refactor: update app configuration and live monitor for improved user experience and functionality

上级 8b6f8dd9
...@@ -14,7 +14,7 @@ const appConfigList = [ ...@@ -14,7 +14,7 @@ const appConfigList = [
}, },
{ {
system: 'x', system: 'x',
title: '1+X实训平台', // title: '1+X实训平台',
logo: 'https://webapp-pub.ezijing.com/website/base/logo.svg', logo: 'https://webapp-pub.ezijing.com/website/base/logo.svg',
hosts: ['saas-x'], hosts: ['saas-x'],
studentMenus: [ studentMenus: [
......
...@@ -3,7 +3,7 @@ import { useLive, readBlobAsBase64 } from '@/composables/useLive' ...@@ -3,7 +3,7 @@ import { useLive, readBlobAsBase64 } from '@/composables/useLive'
import { useSocket } from '@/composables/useSocket' import { useSocket } from '@/composables/useSocket'
import md5 from 'blueimp-md5' import md5 from 'blueimp-md5'
import { ElMessageBox } from 'element-plus' import { ElMessageBox } from 'element-plus'
import { usePermission } from '@vueuse/core' import { usePermission, useIntervalFn } from '@vueuse/core'
export function useLiveMonitor({ autoStart = false }: { autoStart?: boolean } = {}) { export function useLiveMonitor({ autoStart = false }: { autoStart?: boolean } = {}) {
const userStore = useUserStore() const userStore = useUserStore()
...@@ -25,7 +25,7 @@ export function useLiveMonitor({ autoStart = false }: { autoStart?: boolean } = ...@@ -25,7 +25,7 @@ export function useLiveMonitor({ autoStart = false }: { autoStart?: boolean } =
}, },
}) })
const { stream, startTime, start, stop, restart } = useLive({ const { startTime, start, stop, restart } = useLive({
enabledUserMedia: autoStart, enabledUserMedia: autoStart,
onRecord: async (blob) => { onRecord: async (blob) => {
const base64Data = await readBlobAsBase64(blob) const base64Data = await readBlobAsBase64(blob)
...@@ -40,23 +40,27 @@ export function useLiveMonitor({ autoStart = false }: { autoStart?: boolean } = ...@@ -40,23 +40,27 @@ export function useLiveMonitor({ autoStart = false }: { autoStart?: boolean } =
const cameraPermission = usePermission('camera') const cameraPermission = usePermission('camera')
const hasMessageBox = ref(false)
const showMessageBox = () => { const showMessageBox = () => {
if (hasMessageBox.value) return
hasMessageBox.value = true
ElMessageBox.alert('本次考试要求全程开启摄像头,请点击‘确定’允许摄像头访问,以便正常参加考试。', '温馨提示', { ElMessageBox.alert('本次考试要求全程开启摄像头,请点击‘确定’允许摄像头访问,以便正常参加考试。', '温馨提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
beforeClose: (action, instance, done) => { // beforeClose: (action, instance, done) => {
console.log('stream', stream.value) // console.log('stream', stream.value)
console.log('cameraPermission', cameraPermission.value) // console.log('cameraPermission', cameraPermission.value)
if (stream.value && cameraPermission.value === 'granted') done() // if (stream.value && cameraPermission.value === 'granted') done()
}, // },
callback: () => { callback: () => {
hasMessageBox.value = false
restart() restart()
}, },
}) })
} }
watchEffect(() => { useIntervalFn(() => {
if (cameraPermission.value === 'denied') showMessageBox() if (cameraPermission.value === 'denied') showMessageBox()
}) }, 1000 * 10)
onMounted(() => { onMounted(() => {
if (autoStart) showMessageBox() if (autoStart) showMessageBox()
......
...@@ -323,8 +323,8 @@ function handleGoToFunction(path: string) { ...@@ -323,8 +323,8 @@ function handleGoToFunction(path: string) {
<template #right> <template #right>
<AppCard> <AppCard>
<div class="exam-status" v-if="appConfig.system === 'x' && experimentInfo?.exam_status === 1"> <div class="exam-status" v-if="appConfig.system === 'x' && experimentInfo?.exam_status === 1">
<el-button type="primary" @click="tabActive = 'qa'">实操系统</el-button>
<el-button type="primary" @click="tabActive = 'exam'">理论试题</el-button> <el-button type="primary" @click="tabActive = 'exam'">理论试题</el-button>
<el-button type="primary" @click="tabActive = 'qa'">实操环境</el-button>
</div> </div>
<el-row justify="space-between" v-else> <el-row justify="space-between" v-else>
<div> <div>
......
...@@ -3,7 +3,7 @@ import { useUserStore } from '@/stores/user' ...@@ -3,7 +3,7 @@ import { useUserStore } from '@/stores/user'
const router = createRouter({ const router = createRouter({
history: createWebHistory(), history: createWebHistory(),
routes: [{ path: '/:pathMatch(.*)*', redirect: '/' }] routes: [{ path: '/:pathMatch(.*)*', redirect: '/' }],
}) })
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from, next) => {
...@@ -18,7 +18,13 @@ router.beforeEach(async (to, from, next) => { ...@@ -18,7 +18,13 @@ router.beforeEach(async (to, from, next) => {
} catch (e) { } catch (e) {
console.error(e) console.error(e)
} }
user.isLogin ? next() : next('/401') if (!user.isLogin) {
next('/401')
return
}
}
if (to.path === '/' && user.role?.id === 1) {
next('/student/lab')
return return
} }
next() next()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论