|
68 | 68 | <div class="guide-box-title">常见问题</div> |
69 | 69 | <ul class="guide-questions"> |
70 | 70 | <li v-for="q in guide.questions" :key="q.title"> |
71 | | - <a @click="changeToLibraryDetail(q)">{{ q.title }}</a> |
| 71 | + <a @click="changeQuestionToLibraryDetail(q)">{{ q.title }}</a> |
72 | 72 | </li> |
73 | 73 | </ul> |
74 | 74 | </div> |
@@ -232,32 +232,40 @@ export default { |
232 | 232 | }, |
233 | 233 | changeToLibraryHome() { |
234 | 234 | this.currentMode = "home"; |
235 | | - // 当前元素不等于history最后一个元素,就可以进入队列 |
236 | | - if (this.lastHistory.mode !== "home") { |
237 | | - // history队列a b c d e, 如果当前在c,此时有元素进入队列,那么d e会被remove |
238 | | - this.history = this.history.slice(0, this.currentIndex + 1).concat({ mode: "home", data: {} }); |
239 | | - this.currentIndex = this.currentIndex + 1; |
240 | | - } |
| 235 | + // history队列a b c d e, 如果当前在c,此时有元素进入队列,那么d e会被remove |
| 236 | + this.history = this.history.slice(0, this.currentIndex + 1).concat({ mode: "home", data: {} }); |
| 237 | + this.currentIndex = this.currentIndex + 1; |
241 | 238 | }, |
242 | | - changeToLibraryDetail(chapter) { |
| 239 | + changeQuestionToLibraryDetail(chapter) { |
243 | 240 | this.currentTab = "library"; |
244 | 241 | this.currentMode = "detail"; |
245 | 242 | this.currentDoc = chapter; |
246 | | - // 当前元素不等于history最后一个元素,就可以进入队列 |
247 | | - if (this.lastHistory.data.id !== chapter.id) { |
| 243 | + // 点击学习tab的问题跳到知识库,然后再次点击同一问题,history不变,currentIndex不变; |
| 244 | + if (this.lastHistory.data.id == chapter.id && this.isLast && !this.isFirst) { |
| 245 | + // 内容相同且currentIndex是最后一个且不是第一个,无须重复展示 |
| 246 | + } else { |
248 | 247 | // history队列a b c d e, 如果当前在c,此时有元素进入队列,那么d e会被remove |
249 | 248 | this.history = this.history.slice(0, this.currentIndex + 1).concat({ mode: "detail", data: chapter }); |
250 | 249 | this.currentIndex = this.currentIndex + 1; |
251 | 250 | } |
252 | 251 | }, |
| 252 | + changeToLibraryDetail(chapter) { |
| 253 | + this.currentTab = "library"; |
| 254 | + this.currentMode = "detail"; |
| 255 | + this.currentDoc = chapter; |
| 256 | + // 点击某一文档内置链接,然后点返回,再次点击同一链接,此时currentIndex应该变化,history也最好更新; |
| 257 | + // history队列a b c d e, 如果当前在c,此时有元素进入队列,那么d e会被remove |
| 258 | + this.history = this.history.slice(0, this.currentIndex + 1).concat({ mode: "detail", data: chapter }); |
| 259 | + this.currentIndex = this.currentIndex + 1; |
| 260 | + }, |
253 | 261 | changeToLibrarySearch() { |
254 | 262 | if (!this.keyword || !this.keyword.trim()) { |
255 | 263 | return; |
256 | 264 | } |
257 | | - this.currentMode = "search"; |
258 | 265 | if (this.lastHistory.mode == "search" && this.lastHistory.data.keyword == this.keyword.trim()) { |
259 | 266 | // 最后一条历史记录是search且keyword没有变化,不处理 |
260 | 267 | } else { |
| 268 | + this.currentMode = "search"; |
261 | 269 | // history队列a b c d e, 如果当前在c,此时有元素进入队列,那么d e会被remove |
262 | 270 | this.history = this.history.slice(0, this.currentIndex + 1).concat({ mode: "search", data: { keyword: this.keyword } }); |
263 | 271 | this.currentIndex = this.currentIndex + 1; |
@@ -304,12 +312,13 @@ export default { |
304 | 312 | }; |
305 | 313 | }, |
306 | 314 | changeDocument(type) { |
307 | | - if (type == "prev" && this.currentIndex == 0) { |
| 315 | + if (type == "prev" && this.isFirst) { |
308 | 316 | return; |
309 | 317 | } |
310 | | - if (type == "next" && this.currentIndex == this.history.length - 1) { |
| 318 | + if (type == "next" && this.isLast) { |
311 | 319 | return; |
312 | 320 | } |
| 321 | + this.loading = false; |
313 | 322 | if (type == "prev") { |
314 | 323 | this.currentIndex = this.currentIndex - 1; |
315 | 324 | } else if (type == "next") { |
|
0 commit comments