我的数据添加面包屑,返回首页时要恢复项目

dev_2022-04-07
yujialong 3 years ago
parent 90eb8bb227
commit cfe26b3250
  1. 5
      package-lock.json
  2. 1
      package.json
  3. 9
      src/api/http.js
  4. 144
      src/components/TestPanel.vue
  5. 71
      src/components/breadcrumb/index.vue
  6. 7
      src/components/codemirror.vue
  7. 2
      src/config/index.js
  8. 10
      src/views/Data.vue
  9. 52
      src/views/Home.vue

5
package-lock.json generated

@ -6917,6 +6917,11 @@
"resolved": "https://registry.npm.taobao.org/js-base64/download/js-base64-2.5.2.tgz",
"integrity": "sha1-MTtidN2nGPcU0AszMLuubjjpAgk="
},
"js-cookie": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.1.tgz",
"integrity": "sha512-+0rgsUXZu4ncpPxRL+lNEptWMOWl9etvPHc/koSRp6MPwpRYAhmk0dUG00J4bxVV3r9uUzfo24wW0knS07SKSw=="
},
"js-message": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/js-message/-/js-message-1.0.7.tgz",

@ -13,6 +13,7 @@
"core-js": "^3.19.3",
"element-ui": "^2.15.6",
"jquery": "^3.6.0",
"js-cookie": "^3.0.1",
"lib-flexible": "^0.3.2",
"postcss-px2rem": "^0.3.0",
"postcss-pxtorem": "^5.1.1",

@ -3,7 +3,7 @@ import {
Message
} from 'element-ui'
import router from '../router/index'
import util from '@/util'
import Cookie from 'js-cookie'
import config from '@/config'
const service = axios.create({
@ -15,7 +15,7 @@ const service = axios.create({
service.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8';
// 请求拦截器
service.interceptors.request.use(config => {
const token = util.getCookie('token')
const token = Cookie.get('admin-token')
if (token) {
config.headers.token = token
}
@ -49,7 +49,10 @@ service.interceptors.response.use(
switch (error.response.status) {
// 401: 未登录
case 401:
history.back()
Message.error('登录过期,请重新登录')
setTimeout(() => {
history.back()
}, 1500)
break;
default:
// Message.error(error.response.data.message)

@ -127,21 +127,22 @@
<script>
import newmain from "../util/newMain";
import util from '@/util'
import Cookie from 'js-cookie'
export default {
data() {
return {
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'),
systemId: Cookie.get('admin-systemId') || 1,
classId: Cookie.get('admin-classId'),
className: Cookie.get('admin-className') ? decodeURI(Cookie.get('admin-className')) : '',
courseId: Cookie.get('admin-courseId'),
projectId: Cookie.get('admin-projectId') ? Number(Cookie.get('admin-projectId')) : '',
assessmentId: Cookie.get('admin-assessmentId'),
curSystemId: 1,
projectPermissions: 0, // (0 1 2)
isSubmit: false, //
entryTime: new Date(),
startTime: util.getCookie('startTime'),
endTime: util.getCookie('stopTime'),
startTime: Cookie.get('admin-startTime'),
endTime: Cookie.get('admin-stopTime'),
pannelVisible: true, //
grade: '00', //
text: '', //
@ -310,74 +311,81 @@ export default {
//
points = JSON.parse(JSON.stringify(this.points))
}
let newJudgmentId = '' //
const promiseList = [] // promise
let hasCache = 0 //
points.map((e, i) => {
const judgmentId = e.judgmentId
promiseList.push(new Promise((resolve,reject) => {
this.$post(this.api.getLastCache, {
assessmentId: assessmentId ? Number(assessmentId) : '',
bcId: judgmentId,
projectId, // id
cid // id
}).then(res => {
this.closeLoad()
const code = res.getLastCache
//
if (code) {
hasCache = 1
if (newJudgmentId === '') newJudgmentId = i
e.code = code
}
resolve()
}).catch(res => {
reject()
this.closeLoad()
})
}))
})
//
Promise.all(promiseList).then(_ => {
hasCache && this.$confirm('是否要继续上次的实验?', '提示', {
confirmButtonText: '是',
cancelButtonText: '否',
type: 'success'
}).then(() => {
localStorage.removeItem('codeCache') //
this.projectId = projectId
// id
if (pId) {
this.getProDetail().then(() => {
//
if (cache.empty) {
this.projectId = projectId
this.closeLoad()
localStorage.removeItem('codeCache')
} else {
let newJudgmentId = '' //
const promiseList = [] // promise
let hasCache = 0 //
points.map((e, i) => {
const judgmentId = e.judgmentId
promiseList.push(new Promise((resolve,reject) => {
this.$post(this.api.getLastCache, {
assessmentId: assessmentId ? Number(assessmentId) : '',
bcId: judgmentId,
projectId, // id
cid // id
}).then(res => {
this.closeLoad()
const code = res.getLastCache
//
if (code) {
hasCache = 1
if (newJudgmentId === '') newJudgmentId = i
e.code = code
}
resolve()
}).catch(res => {
reject()
this.closeLoad()
})
}))
})
//
Promise.all(promiseList).then(_ => {
hasCache && this.$confirm('是否要继续上次的实验?', '提示', {
confirmButtonText: '是',
cancelButtonText: '否',
type: 'success'
}).then(() => {
localStorage.removeItem('codeCache') //
this.projectId = projectId
// id
if (pId) {
this.getProDetail().then(() => {
this.points.map(e => {
const item = points.find(n => n.judgmentId === e.judgmentId)
if (item && item.code) this.$set(e, 'code', item.code)
})
this.$emit('tell', projectId, this.curSystemId, this.points)
this.$emit('recoveryCode', newJudgmentId + '') // tab
}).catch(res => {})
} else {
this.points.map(e => {
const item = points.find(n => n.judgmentId === e.judgmentId)
if (item && item.code) this.$set(e, 'code', item.code)
})
this.$emit('tell', projectId, this.curSystemId, this.points)
this.$emit('recoveryCode', newJudgmentId + '') // tab
}).catch(res => {})
} else {
this.points.map(e => {
const item = points.find(n => n.judgmentId === e.judgmentId)
if (item && item.code) this.$set(e, 'code', item.code)
this.$emit('recoveryCode')
}
}).catch(() => {
//
localStorage.removeItem('codeCache')
//
points.map(e => {
e.code && this.$post(this.api.delCache, {
assessmentId,
bcId: e.judgmentId,
projectId,
cid
}).then(res => {}).catch(() => {})
})
this.$emit('tell', projectId, this.curSystemId, this.points)
this.$emit('recoveryCode')
}
}).catch(() => {
//
localStorage.removeItem('codeCache')
//
points.map(e => {
e.code && this.$post(`${this.api.delCache}`, {
assessmentId,
bcId: e.judgmentId,
projectId,
cid
}).then(res => {}).catch(() => {})
})
})
})
}
},
//
getStatus() {

@ -0,0 +1,71 @@
<template>
<!-- 面包屑 -->
<div class="breadcrumb">
<el-breadcrumb separator=">">
<template v-for="(item, index) in pages">
<el-breadcrumb-item
v-if="index != pages.length - 1"
:key="index"
>
<span @click="toPath">{{item}}</span>
</el-breadcrumb-item>
<el-breadcrumb-item
v-else
:key="index">
{{item}}
</el-breadcrumb-item>
</template>
</el-breadcrumb>
</div>
</template>
<script>
export default {
props: {
data: {
type: String,
required: true
},
route: {
type: String,
default: '/'
},
query: {
type: Object
}
},
data() {
return {
pages: this.data.split('/')
};
},
methods: {
update(data){
this.pages = data.split('/')
},
toPath() {
console.log(33)
this.$router.back()
}
}
};
</script>
<style lang="scss" scoped>
.breadcrumb {
margin: 4px 0 16px;
/deep/.el-breadcrumb__item {
&:first-child {
span {
font-weight: 400;
color: #007eff;
cursor: pointer;
}
}
&:last-child {
.is-link {
color: #0B1D30;
}
}
}
}
</style>

@ -82,6 +82,7 @@
</template>
<script>
import Cookie from 'js-cookie'
import newmain from "../util/newMain";
import { codemirror } from "vue-codemirror";
import "codemirror/theme/ambiance.css"; //
@ -132,9 +133,9 @@ export default {
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
token: Cookie.get('admin-token'),
assessmentId: Cookie.get('admin-assessmentId'), // id
courseId: Cookie.get('admin-courseId'), // id
showTips: false, //
answer: '', //
codeVal: this.code,

@ -5,7 +5,7 @@ const isBeta = process.env.NODE_ENV === 'development' || location.host.includes(
let host = location.origin + ':9000/'
// 39.108.250.202 | 192.168.31.151
if (process.env.NODE_ENV === 'development') host = 'http://192.168.31.151:9000/'
if (process.env.NODE_ENV === 'development') host = 'http://39.108.250.202:9000/'
const systemId = util.getCookie('systemId')
/**
* python8个系统的id和名称

@ -1,7 +1,7 @@
<template>
<div class="wrap" v-loading="loading">
<div class="inner">
<el-page-header @back="$router.back()" content="我的数据"></el-page-header>
<breadcrumb data="首页/我的数据"></breadcrumb>
<div class="tool">
<el-input style="width: 250px" placeholder="请输入文件名称" v-model="keyword" suffix-icon="el-icon-search" clearable size="small"></el-input>
<div class="action">
@ -44,12 +44,14 @@
</div>
</template>
<script>
import Cookie from 'js-cookie'
import util from '@/util'
import clipboard from '@/util/clipboard'
import breadcrumb from '@/components/breadcrumb'
export default {
data() {
return {
token: util.getCookie('token'),
token: Cookie.get('admin-token'),
loading: false,
list: [],
multipleSelection: [],
@ -59,6 +61,9 @@ export default {
total: 0
};
},
components: {
breadcrumb
},
watch: {
keyword: function(val) {
clearTimeout(this.searchTimer)
@ -178,6 +183,7 @@ export default {
</script>
<style lang="scss" scoped>
.wrap {
min-height: 100vh;
padding: 20px;
background-color: #f3f6fa;
.inner {

@ -12,7 +12,7 @@
<p>编程语言</p>
<el-input placeholder="请输入内容" v-model="language" :disabled="true"></el-input>
</div>
<el-button type="primary" size="small" @click="toData">我的数据</el-button>
<el-button type="primary" size="small" icon="el-icon-document" @click="toData">我的数据</el-button>
</div>
<div class="tab">
@ -54,16 +54,16 @@
<script>
import testPanel from "../components/TestPanel";
import codemirror from "../components/codemirror";
import util from '@/util'
import Cookie from 'js-cookie'
import { Loading } from 'element-ui'
export default {
data() {
return {
loaded: false, //
loadIns: null, // loading
courseId: util.getCookie('courseId'), // id
curriculumName: util.getCookie('curriculumName') ? unescape(util.getCookie('curriculumName')) : 'python', //
assessmentId: util.getCookie('assessmentId'), // id
courseId: Cookie.get('admin-courseId'), // id
curriculumName: Cookie.get('admin-curriculumName') ? unescape(Cookie.get('admin-curriculumName')) : 'python', //
assessmentId: Cookie.get('admin-assessmentId'), // id
projectId: '',
systemId: '',
modelIsShow: false, //
@ -88,28 +88,38 @@ export default {
this.leavePage()
}
},
beforeRouteLeave(to, from, next) {
next(this.leavePage())
},
methods: {
//
leavePage(){
leavePage() {
const list = this.workbench
if(!this.$refs.mainindex.isSubmit && list.length && list.some(e => e.code)){
console.log("🚀 ~ file: Home.vue ~ line 95 ~ leavePage ~ this.workbench", this.workbench)
//
if (!this.$refs.mainindex.isSubmit && list.length) {
const cache = {
projectId: Number(this.projectId),
judgmentIdList: this.workbench.map(e => e.judgmentId)
}
localStorage.setItem('codeCache', JSON.stringify(cache)) // ididid
list.map(e => {
if (e.code) {
let data = {
assessmentId: this.assessmentId,
code: e.code,
bcId: e.judgmentId,
cid: this.courseId,
projectId: this.projectId
//
if (list.some(e => e.code)) {
list.map(e => {
if (e.code) {
let data = {
assessmentId: this.assessmentId,
code: e.code,
bcId: e.judgmentId,
cid: this.courseId,
projectId: this.projectId
}
this.$post(this.api.saveCache,data).then(res => {}).catch(e => {})
}
this.$post(this.api.saveCache,data).then(res => {}).catch(e => {})
}
})
})
} else {
cache.empty = true //
}
localStorage.setItem('codeCache', JSON.stringify(cache)) // ididid
}
},
//
@ -123,7 +133,7 @@ export default {
this.$router.push('/data')
},
// 退
autoLogout(){
autoLogout() {
let lastTime = new Date().getTime()
let logout = false
//
@ -148,7 +158,7 @@ export default {
})
},
//
recoveryCode(curTab = '0'){
recoveryCode(curTab = '0') {
this.curTab = curTab
this.codeKey++
},

Loading…
Cancel
Save