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

dev_2022-04-07
yujialong 3 years ago
parent 90eb8bb227
commit cfe26b3250
  1. 5
      package-lock.json
  2. 1
      package.json
  3. 7
      src/api/http.js
  4. 26
      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. 24
      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", "resolved": "https://registry.npm.taobao.org/js-base64/download/js-base64-2.5.2.tgz",
"integrity": "sha1-MTtidN2nGPcU0AszMLuubjjpAgk=" "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": { "js-message": {
"version": "1.0.7", "version": "1.0.7",
"resolved": "https://registry.npmjs.org/js-message/-/js-message-1.0.7.tgz", "resolved": "https://registry.npmjs.org/js-message/-/js-message-1.0.7.tgz",

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

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

@ -127,21 +127,22 @@
<script> <script>
import newmain from "../util/newMain"; import newmain from "../util/newMain";
import util from '@/util' import util from '@/util'
import Cookie from 'js-cookie'
export default { export default {
data() { data() {
return { return {
systemId: util.getCookie('systemId') || 1, systemId: Cookie.get('admin-systemId') || 1,
classId: util.getCookie('classId'), classId: Cookie.get('admin-classId'),
className: util.getCookie('className') ? decodeURI(util.getCookie('className')) : '', className: Cookie.get('admin-className') ? decodeURI(Cookie.get('admin-className')) : '',
courseId: util.getCookie('courseId'), courseId: Cookie.get('admin-courseId'),
projectId: util.getCookie('projectId') ? Number(util.getCookie('projectId')) : '', projectId: Cookie.get('admin-projectId') ? Number(Cookie.get('admin-projectId')) : '',
assessmentId: util.getCookie('assessmentId'), assessmentId: Cookie.get('admin-assessmentId'),
curSystemId: 1, curSystemId: 1,
projectPermissions: 0, // (0 1 2) projectPermissions: 0, // (0 1 2)
isSubmit: false, // isSubmit: false, //
entryTime: new Date(), entryTime: new Date(),
startTime: util.getCookie('startTime'), startTime: Cookie.get('admin-startTime'),
endTime: util.getCookie('stopTime'), endTime: Cookie.get('admin-stopTime'),
pannelVisible: true, // pannelVisible: true, //
grade: '00', // grade: '00', //
text: '', // text: '', //
@ -310,6 +311,12 @@ export default {
// //
points = JSON.parse(JSON.stringify(this.points)) points = JSON.parse(JSON.stringify(this.points))
} }
//
if (cache.empty) {
this.projectId = projectId
this.closeLoad()
localStorage.removeItem('codeCache')
} else {
let newJudgmentId = '' // let newJudgmentId = '' //
const promiseList = [] // promise const promiseList = [] // promise
let hasCache = 0 // let hasCache = 0 //
@ -369,7 +376,7 @@ export default {
localStorage.removeItem('codeCache') localStorage.removeItem('codeCache')
// //
points.map(e => { points.map(e => {
e.code && this.$post(`${this.api.delCache}`, { e.code && this.$post(this.api.delCache, {
assessmentId, assessmentId,
bcId: e.judgmentId, bcId: e.judgmentId,
projectId, projectId,
@ -378,6 +385,7 @@ export default {
}) })
}) })
}) })
}
}, },
// //
getStatus() { 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> </template>
<script> <script>
import Cookie from 'js-cookie'
import newmain from "../util/newMain"; import newmain from "../util/newMain";
import { codemirror } from "vue-codemirror"; import { codemirror } from "vue-codemirror";
import "codemirror/theme/ambiance.css"; // import "codemirror/theme/ambiance.css"; //
@ -132,9 +133,9 @@ export default {
props: ['judgmentId', 'code', 'codeId', 'projectId', 'systemId', 'retResult', 'modelIsShow'], props: ['judgmentId', 'code', 'codeId', 'projectId', 'systemId', 'retResult', 'modelIsShow'],
data() { data() {
return { return {
token: util.getCookie('admin-token'), token: Cookie.get('admin-token'),
assessmentId: util.getCookie('assessmentId'), // id assessmentId: Cookie.get('admin-assessmentId'), // id
courseId: util.getCookie('courseId'), // id courseId: Cookie.get('admin-courseId'), // id
showTips: false, // showTips: false, //
answer: '', // answer: '', //
codeVal: this.code, codeVal: this.code,

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

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

@ -12,7 +12,7 @@
<p>编程语言</p> <p>编程语言</p>
<el-input placeholder="请输入内容" v-model="language" :disabled="true"></el-input> <el-input placeholder="请输入内容" v-model="language" :disabled="true"></el-input>
</div> </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>
<div class="tab"> <div class="tab">
@ -54,16 +54,16 @@
<script> <script>
import testPanel from "../components/TestPanel"; import testPanel from "../components/TestPanel";
import codemirror from "../components/codemirror"; import codemirror from "../components/codemirror";
import util from '@/util' import Cookie from 'js-cookie'
import { Loading } from 'element-ui' import { Loading } from 'element-ui'
export default { export default {
data() { data() {
return { return {
loaded: false, // loaded: false, //
loadIns: null, // loading loadIns: null, // loading
courseId: util.getCookie('courseId'), // id courseId: Cookie.get('admin-courseId'), // id
curriculumName: util.getCookie('curriculumName') ? unescape(util.getCookie('curriculumName')) : 'python', // curriculumName: Cookie.get('admin-curriculumName') ? unescape(Cookie.get('admin-curriculumName')) : 'python', //
assessmentId: util.getCookie('assessmentId'), // id assessmentId: Cookie.get('admin-assessmentId'), // id
projectId: '', projectId: '',
systemId: '', systemId: '',
modelIsShow: false, // modelIsShow: false, //
@ -88,16 +88,22 @@ export default {
this.leavePage() this.leavePage()
} }
}, },
beforeRouteLeave(to, from, next) {
next(this.leavePage())
},
methods: { methods: {
// //
leavePage() { leavePage() {
const list = this.workbench 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 = { const cache = {
projectId: Number(this.projectId), projectId: Number(this.projectId),
judgmentIdList: this.workbench.map(e => e.judgmentId) judgmentIdList: this.workbench.map(e => e.judgmentId)
} }
localStorage.setItem('codeCache', JSON.stringify(cache)) // ididid //
if (list.some(e => e.code)) {
list.map(e => { list.map(e => {
if (e.code) { if (e.code) {
let data = { let data = {
@ -110,6 +116,10 @@ export default {
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
} }
}, },
// //

Loading…
Cancel
Save