Skip to content

Commit 0577552

Browse files
committed
feat(Manager): 增加了本地缓存资源管理中心
1 parent fbd7d07 commit 0577552

File tree

2 files changed

+92
-1
lines changed

2 files changed

+92
-1
lines changed

src/components/Home.vue

+10-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
比赛题面
4040
</span>
4141
</el-menu-item>
42+
<el-menu-item index="7">
43+
<span slot="title">
44+
<i class="el-icon-folder"></i>
45+
本地缓存
46+
</span>
47+
</el-menu-item>
4248
</el-menu>
4349
</el-aside>
4450
<el-main>
@@ -50,6 +56,7 @@
5056
<Contest v-if="status===5" :contestId="contestId" v-on:enterProblem="enterProblem"></Contest>
5157
<Problem v-if="status===6" :contestId="contestId" :problemId="problemId"
5258
v-on:submitProblem="submitProblem" v-on:loadProblem="loadProblem"></Problem>
59+
<LocalManager v-if="status===7"></LocalManager>
5360
</el-main>
5461
</el-container>
5562
</el-container>
@@ -62,6 +69,7 @@ import Status from "@/components/Status";
6269
import ContestList from "@/components/ContestList";
6370
import Contest from "@/components/Contest";
6471
import Problem from "@/components/Problem";
72+
import LocalManager from "@/components/LocalManager";
6573
6674
export default {
6775
name: "Home",
@@ -82,7 +90,8 @@ export default {
8290
Status,
8391
ContestList,
8492
Contest,
85-
Problem
93+
Problem,
94+
LocalManager
8695
},
8796
8897
methods: {

src/components/LocalManager.vue

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<template>
2+
<div class="main">
3+
<el-button type="primary" :disabled="!account"
4+
v-on:click="removeUser">
5+
删除账号信息
6+
</el-button>
7+
<el-table :data="problems"
8+
style="width: 100%">
9+
<el-table-column
10+
prop="id"
11+
label="问题编号"
12+
align="center"
13+
min-width="100">
14+
</el-table-column>
15+
<el-table-column
16+
prop="memory"
17+
label="占用内存"
18+
align="center"
19+
min-width="100">
20+
</el-table-column>
21+
<el-table-column
22+
label="操作"
23+
align="center"
24+
min-width="50">
25+
<template scope="scope">
26+
<el-button type="primary"
27+
v-on:click="remove(scope.$index)">
28+
删除缓存
29+
</el-button>
30+
</template>
31+
</el-table-column>
32+
</el-table>
33+
</div>
34+
</template>
35+
36+
<script>
37+
export default {
38+
name: "LocalManager",
39+
40+
data() {
41+
return {
42+
account: false,
43+
problems: []
44+
}
45+
},
46+
47+
created() {
48+
if (window.localStorage.getItem('email') != null)
49+
this.account = true
50+
if (window.localStorage.savedProblem != null) {
51+
let problemList = window.localStorage.savedProblem
52+
problemList = problemList.split(';')
53+
for (let i = 0; i < problemList.length - 1; ++i) {
54+
let pro = {
55+
id: problemList[i],
56+
memory: window.localStorage.getItem(problemList[i]).length / 1024 + 'KB'
57+
}
58+
this.problems.push(pro)
59+
}
60+
}
61+
},
62+
63+
methods: {
64+
remove(index) {
65+
window.localStorage.removeItem(this.problems[index].id)
66+
window.localStorage.savedProblem = window.localStorage.savedProblem.replace(this.problems[index].id + ';', '')
67+
this.useLocalStorage = false
68+
this.problems.splice(index, 1)
69+
},
70+
71+
removeUser() {
72+
window.localStorage.removeItem('email');
73+
window.localStorage.removeItem('password');
74+
this.account = false
75+
}
76+
}
77+
}
78+
</script>
79+
80+
<style scoped>
81+
82+
</style>

0 commit comments

Comments
 (0)