11<template >
22 <div class =" mavonEditor" >
3- <el-row type =" flex" justify =" end" >
3+ <el-row type =" flex" justify =" end" class = " title-btn " >
44 <el-button icon =" el-icon-edit" @click =" edit" v-if =" isCreator" >编辑</el-button >
55 <el-button icon =" el-icon-circle-check" @click =" finish" v-if =" isInToday" >完成</el-button >
66 <el-button icon =" el-icon-delete" @click =" removePlan" v-if =" isInPlan" >移出学习计划</el-button >
1818 style =" border : 0 "
1919 v-model =" content"
2020 />
21+
22+ <el-row type =" flex" justify =" end" class =" bottom-btn" >
23+ <el-button icon =" el-icon-arrow-left" @click =" pre" v-if =" JSON.stringify(preProblem)!=='{}'" >
24+ 上一题:{{ preProblem.name }}
25+ </el-button >
26+ <el-button @click =" next" v-if =" JSON.stringify(nextProblem)!=='{}'" >
27+ 下一题:{{ nextProblem.name }}
28+ <i class =" el-icon-arrow-right" />
29+ </el-button >
30+ </el-row >
31+
2132 </div >
2233</template >
2334
2435
2536<script >
26- import {addToProblemPlan , getProblemByID , finishProblem , removeFromProblemPlan } from ' @api'
37+ import {addToProblemPlan , finishProblem , getProblemByID , removeFromProblemPlan } from ' @api'
2738
2839export default {
2940 name: " info-problem" ,
@@ -33,6 +44,8 @@ export default {
3344 isInToday: false ,
3445 content: " " ,
3546 isCreator: false ,
47+ preProblem: {},
48+ nextProblem: {}
3649 };
3750 },
3851 computed: {
@@ -43,6 +56,16 @@ export default {
4356 mounted () {
4457 this .problemId = this .$store .state .curProblem .id
4558 this .isInToday = this .$store .state .curProblem .isInToday
59+ if (this .isInToday ) {
60+ let idx = this .$store .state .curProblem .idx
61+ let len = this .$store .state .curProblem .rawList .length
62+ if (idx - 1 >= 0 ) {
63+ this .preProblem = this .$store .state .curProblem .rawList [idx - 1 ]
64+ }
65+ if (idx + 1 < len) {
66+ this .nextProblem = this .$store .state .curProblem .rawList [idx + 1 ]
67+ }
68+ }
4669 getProblemByID ({problem_id: this .problemId }).then (data => {
4770 this .content = " ## " + data .name + " \n [OJ链接](" + data .link + " )\n\n " + data .content + " \n ### 解答\n " + data .result
4871 this .isCreator = (this .$store .state .user .ID === data .creator_id )
@@ -84,13 +107,39 @@ export default {
84107 })
85108 });
86109 },
87- addPlan : function (){
110+ addPlan : function () {
88111 addToProblemPlan ({problem_id: this .problemId }).then (() => {
89112 let cur = this .$store .state .curProblem
90113 cur .isInPlan = true
91114 this .$store .commit (' SET_CUR_PROBLEM' , cur)
92115 this .$messages (' success' , ' success' )
93116 })
117+ },
118+ pre : function () {
119+ let cur = this .$store .state .curProblem
120+ if (! cur .isInToday || ! cur .isInPlan ) {
121+ cur .rawList .splice (cur .idx , 1 )
122+ }
123+ cur .id = this .preProblem .ID
124+ cur .idx = (cur .idx - 1 ) % cur .rawList .length
125+ cur .isInPlan = true
126+ cur .isInToday = true
127+ this .$store .commit (' SET_CUR_PROBLEM' , cur)
128+ location .reload ()
129+ },
130+ next : function () {
131+ let cur = this .$store .state .curProblem
132+ if (! cur .isInToday || ! cur .isInPlan ) {
133+ cur .rawList .splice (cur .idx , 1 )
134+ cur .idx = cur .idx % cur .rawList .length
135+ } else {
136+ cur .idx = (cur .idx + 1 ) % cur .rawList .length
137+ }
138+ cur .id = this .nextProblem .ID
139+ cur .isInPlan = true
140+ cur .isInToday = true
141+ this .$store .commit (' SET_CUR_PROBLEM' , cur)
142+ location .reload ()
94143 }
95144 }
96145};
@@ -104,10 +153,25 @@ export default {
104153 border-radius : 6px ;
105154}
106155
107- .mavonEditor >>> .el-button {
156+ .title-btn >>> .el-button {
108157 width : auto ;
109158 height : 30px ;
110159 font-size : 12px ;
111160 padding : 6px 10px ;
112161}
162+
163+ .bottom-btn >>> .el-button {
164+ width : auto ;
165+ height : 40px ;
166+ font-size : 13px ;
167+ padding : 10px 10px ;
168+ margin-top : 20px ;;
169+ max-width : 500px ;
170+ text-overflow : ellipsis ;
171+ overflow : hidden ;
172+ white-space : nowrap ;
173+ display : block ;
174+ }
175+
176+
113177 </style >
0 commit comments