From 8e8097923b0b4eb6f4b8d6f73ec750f4cdf49ded Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Fri, 1 Apr 2022 16:08:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A2=98=E5=8F=AA=E7=94=A8=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F7=E7=9A=84=EF=BC=8C=E4=BB=A5=E5=8F=8A=E4=BB=8E?= =?UTF-8?q?=E8=81=8C=E7=AB=99=E8=8E=B7=E5=8F=96systemIds=EF=BC=8C=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=A4=9A=E4=B8=AA=E7=B3=BB=E7=BB=9F=E7=9A=84=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TestPanel.vue | 20 ++++++++++++-------- src/components/codemirror.vue | 21 +++++++++++++++------ src/config/index.js | 7 ++----- src/main.js | 21 +++------------------ src/views/Home.vue | 19 +++++++++++-------- 5 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/components/TestPanel.vue b/src/components/TestPanel.vue index 02103ef..917a2e8 100644 --- a/src/components/TestPanel.vue +++ b/src/components/TestPanel.vue @@ -117,8 +117,8 @@
- - + +
@@ -130,12 +130,13 @@ import util from '@/util' export default { data() { return { - systemId: Number(util.getCookie('systemId') || 1), + systemId: util.getCookie('systemId') || 1, classId: util.getCookie('classId'), className: util.getCookie('className') ? decodeURI(util.getCookie('className')) : '', courseId: util.getCookie('courseId'), projectId: util.getCookie('projectId') ? Number(util.getCookie('projectId')) : '', assessmentId: util.getCookie('assessmentId'), + curSystemId: 1, projectPermissions: 0, // 项目权限(0、练习 1、考核 2、竞赛) isSubmit: false, // 是否提交的标识 entryTime: new Date(), @@ -232,6 +233,9 @@ export default { projectName: project.projectName }] } + const { systemId } = project + this.curSystemId = systemId + this.$parent.getModelStatus(systemId) this.curReq = curReq // 实验要求默认全部展开,通过judgmentId来选中item this.points = points this.taskList = points // 实验任务 @@ -240,7 +244,7 @@ export default { this.experimentDescription = project.experimentDescription this.experimentHint = project.experimentHint this.hintOpen = !res.projectManage.hintOpen // 0显示,1不显示 - this.$emit('tell', projectId, this.points) + this.$emit('tell', projectId, systemId, this.points) const isAss = this.projectPermissions == 1 // 是否是考核 this.text = isAss ? '剩余' : '已用' this.countVal = isAss ? (new Date(this.endTime).getTime() - Date.now()) / 1000 : 0 // 如果是考核,取考核的结束时间减去当前时间去做倒计时,练习则直接给0做计时 @@ -349,7 +353,7 @@ export default { const item = points.find(n => n.judgmentId === e.judgmentId) if (item && item.code) this.$set(e, 'code', item.code) }) - this.$emit('tell', projectId, this.points) + this.$emit('tell', projectId, this.curSystemId, this.points) this.$emit('recoveryCode', newJudgmentId + '') // 切换为缓存的判分点,tab索引值要为字符串 }).catch(res => {}) } else { @@ -357,7 +361,7 @@ export default { const item = points.find(n => n.judgmentId === e.judgmentId) if (item && item.code) this.$set(e, 'code', item.code) }) - this.$emit('tell', projectId, this.points) + this.$emit('tell', projectId, this.curSystemId, this.points) this.$emit('recoveryCode') } }).catch(() => { @@ -419,7 +423,7 @@ export default { e.answer = '' e.retResult = '' }) - this.$emit('tell', this.projectId, points) + this.$emit('tell', this.projectId, this.curSystemId, points) this.$emit('recoveryCode') this.startCount() }, @@ -471,7 +475,7 @@ export default { projectName, assessmentId: this.assessmentId ? this.assessmentId : '', totalScore: 100, // 判分点总分固定为100 - systemId: this.systemId, + systemId: this.curSystemId, purpose: this.experimentTarget, // 实验目的 attributesReqList } diff --git a/src/components/codemirror.vue b/src/components/codemirror.vue index c154184..f90d49e 100644 --- a/src/components/codemirror.vue +++ b/src/components/codemirror.vue @@ -42,7 +42,7 @@
- 运行成功 + 运行成功
@@ -61,7 +61,7 @@
- + :props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}" + v-loading="modelLoading">
@@ -128,13 +129,12 @@ import util from '@/util' import config from '@/config' const CANCEL_TOKEN = axios.CancelToken // 用于input中中断请求 export default { - props: ['judgmentId', 'code', 'codeId', 'projectId', 'retResult', 'modelIsShow'], + props: ['judgmentId', 'code', 'codeId', 'projectId', 'systemId', 'retResult', 'modelIsShow'], data() { return { token: util.getCookie('admin-token'), assessmentId: util.getCookie('assessmentId'), // 考核id courseId: util.getCookie('courseId'), // 课程id - systemId: util.getCookie('systemId'), showTips: false, // 显示隐藏提示按钮 answer: '', // 正确答案 codeVal: this.code, @@ -176,6 +176,8 @@ export default { sourceCode: '', // 把input替换成exit函数后的代码 requestTimer: null, // 用于中断请求的定时器 modelVisible: false, + modelLoading: false, + modelImporting: false, modelData: [] }; }, @@ -216,6 +218,7 @@ export default { }, // 导入模型 importModel() { + this.modelLoading = true this.modelVisible = true // 查询源模型分类 this.$post(`${this.api.modelClassList}?systemId=${this.systemId}`).then(res => { @@ -248,6 +251,7 @@ export default { addType(data) Promise.all(promises).then(_ => { this.modelData = data + this.modelLoading = false }).catch(res => {}) }).catch(res => {}) }, @@ -262,15 +266,20 @@ export default { }, // 导入模型提交 submit() { + if (this.modelImporting) return false const id = this.$refs.tree.getCheckedKeys() if (!id.length) return this.$message.error('请选择模型!') + this.modelImporting = true this.$post(`${this.api.referenceFindById}?id=${id[0]}`).then(res => { - this.codeVal += '\n\n' + res.data.modelDemo // 空两行插入 + this.codeVal += (this.codeVal ? '\n\n' : '') + res.data.modelDemo // 空两行插入 this.modelVisible = false this.$nextTick(() => { const codemirror = this.$refs.codemirror.codemirror codemirror.focus() codemirror.setCursor(codemirror.lineCount(), 0) + setTimeout(() => { + this.modelImporting = false + }, 2000) }) }).catch(res => {}) }, diff --git a/src/config/index.js b/src/config/index.js index 1c24bd4..60eeeca 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -9,7 +9,6 @@ if (process.env.NODE_ENV === 'development') host = 'http://192.168.31.151:9000' * python8个系统的id和名称 * id即systemId,从cookie里取 */ -const systemId = util.getCookie('systemId') const pythonList = [ { id: 1, @@ -44,8 +43,6 @@ const pythonList = [ name: 'Python数据采集(爬虫)教学实验系统' } ] -const systemItem = pythonList.find(e => e.id == systemId) -const title = systemItem ? systemItem.name : 'Python程序设计教学系统' // 如果有匹配的python系统,则取匹配到的python,否则,默认显示python程序设计,其他地方同理 export default { /** * @description 域名 @@ -60,9 +57,9 @@ export default { */ isBeta, /** - * @description 配置显示在浏览器标签的title + * @description 系统主题色 */ - title, + defaultSystem: 7, /** * python子系统 **/ diff --git a/src/main.js b/src/main.js index af37b04..8345754 100644 --- a/src/main.js +++ b/src/main.js @@ -6,23 +6,7 @@ import ElementUI from 'element-ui' import util from '@/util' import '@/styles/index.scss'; const systemId = util.getCookie('systemId') -if (systemId == 1) { - import('@/styles/theme/theme1.scss') -} else if (systemId == 4) { - import('@/styles/theme/theme4.scss') -} else if (systemId == 5) { - import('@/styles/theme/theme5.scss') -} else if (systemId == 6) { - import('@/styles/theme/theme6.scss') -} else if (systemId == 7) { - import('@/styles/theme/theme7.scss') -} else if (systemId == 8) { - import('@/styles/theme/theme8.scss') -} else if (systemId == 9) { - import('@/styles/theme/theme9.scss') -} else if (systemId == 10) { - import('@/styles/theme/theme10.scss') -} +import('@/styles/theme/theme7.scss') import api from './api'; import { post, @@ -53,7 +37,8 @@ Vue.prototype.$put = put; Vue.prototype.$config = config Vue.config.productionTip = false; -document.title = config.title +const curriculumName = util.getCookie('curriculumName') +document.title = curriculumName ? unescape(curriculumName) : 'python' router.beforeEach((to, from, next) => { next() }) diff --git a/src/views/Home.vue b/src/views/Home.vue index 7fcb3d6..34ded0d 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -2,7 +2,7 @@
-

{{$config.title}}

+

{{curriculumName}}

退出实验
@@ -24,6 +24,7 @@ :ref="'code' + i" :key="codeKey" :projectId.sync="projectId" + :systemId.sync="systemId" :code.sync="item.code" :judgmentId="item.judgmentId" :codeId.sync="item.codeId" @@ -57,9 +58,11 @@ export default { return { loaded: false, // 页面是否加载完的标识,页面默认隐藏,一进来先显示加载条,接口加载完后再显示页面,不然一开始会一闪而过没有样式的页面 loadIns: null, // loading实例 - courseId: util.getCookie("courseId"), // 课程id - assessmentId: util.getCookie("assessmentId"), // 考核id - systemId: util.getCookie('systemId'), + courseId: util.getCookie('courseId'), // 课程id + curriculumName: util.getCookie('curriculumName') ? unescape(util.getCookie('curriculumName')) : 'python', // 课程名称 + assessmentId: util.getCookie('assessmentId'), // 考核id + projectId: '', + systemId: '', modelIsShow: false, // 导入模型按钮是否显示 projectPermissions: 0, // 项目权限(0、练习 1、考核 2、竞赛) language: 'Python', // 编程语言 @@ -76,7 +79,6 @@ export default { this.loadIns = Loading.service({ background: 'rgba(255, 255, 255, .1)' }) - this.getModelStatus() this.autoLogout() // 绑定页面离开监听 window.onbeforeunload = () => { @@ -108,8 +110,8 @@ export default { } }, // 获取导入模型按钮展示状态 - getModelStatus() { - this.$post(`${this.api.checkIsShowBySystemId}?systemId=${this.systemId}`).then(res => { + getModelStatus(systemId) { + this.$post(`${this.api.checkIsShowBySystemId}?systemId=${systemId}`).then(res => { this.modelIsShow = !res.isShow // 0为展示 1为不展示 }).catch(res => {}) }, @@ -148,8 +150,9 @@ export default { history.back() }, // 赋值项目id、项目列表 - setPoints(projectId, workbench) { + setPoints(projectId, systemId, workbench) { this.projectId = projectId + this.systemId = systemId this.workbench = workbench }, }