diff --git a/src/layout/components/TagsView/ScrollPane.vue b/src/layout/components/TagsView/ScrollPane.vue index b9130c7d..e106f188 100644 --- a/src/layout/components/TagsView/ScrollPane.vue +++ b/src/layout/components/TagsView/ScrollPane.vue @@ -1,84 +1,97 @@ - - + \ No newline at end of file diff --git a/src/store/modules/tagsView.ts b/src/store/modules/tagsView.ts index 8e45852c..d6abd6ff 100644 --- a/src/store/modules/tagsView.ts +++ b/src/store/modules/tagsView.ts @@ -1,16 +1,15 @@ - -import { defineStore } from "pinia"; -import { store } from "@/store"; +import {defineStore} from "pinia"; +import {store} from "@/store"; import {TagsViewState} from "@store/interface"; -const tagsViewStore=defineStore({ - id:"tagsView", - state:():TagsViewState=>( { +const tagsViewStore = defineStore({ + id: "tagsView", + state: (): TagsViewState => ({ visitedViews: [], cachedViews: [] }), actions: { - addVisitedView ( view:any) { + addVisitedView(view: any) { if (this.visitedViews.some(v => v.path === view.path)) return this.visitedViews.push( Object.assign({}, view, { @@ -18,58 +17,58 @@ const tagsViewStore=defineStore({ }) ) }, - addCachedView(view:any) { + addCachedView(view: any) { if (this.cachedViews.includes(view.name)) return if (!view.meta.noCache) { this.cachedViews.push(view.name) } }, - delVisitedView( view:any) { - return new Promise(resolve => { - for (const [i, v] of this.visitedViews.entries()) { - if (v.path === view.path) { - this.visitedViews.splice(i, 1) - break - } - } - resolve([...this.visitedViews]) - }) + delVisitedView(view: any) { + return new Promise(resolve => { + for (const [i, v] of this.visitedViews.entries()) { + if (v.path === view.path) { + this.visitedViews.splice(i, 1) + break + } + } + resolve([...this.visitedViews]) + }) }, - delCachedView ( view:any) { - return new Promise(resolve => { - const index = this.cachedViews.indexOf(view.name) - index > -1 && this.cachedViews.splice(index, 1) - resolve([...this.cachedViews]) - }) + delCachedView(view: any) { + return new Promise(resolve => { + const index = this.cachedViews.indexOf(view.name) + index > -1 && this.cachedViews.splice(index, 1) + resolve([...this.cachedViews]) + }) }, - delOthersVisitedViews (view:any) { - return new Promise(resolve => { - this.visitedViews = this.visitedViews.filter(v => { - return v.meta?.affix || v.path === view.path - }) - resolve([...this.visitedViews]) - }) + delOthersVisitedViews(view: any) { + return new Promise(resolve => { + this.visitedViews = this.visitedViews.filter(v => { + return v.meta?.affix || v.path === view.path + }) + resolve([...this.visitedViews]) + }) }, - delOthersCachedViews( view:any) { - return new Promise(resolve => { - const index = this.cachedViews.indexOf(view.name) - if (index > -1) { - this.cachedViews = this.cachedViews.slice(index, index + 1) - } else { - // if index = -1, there is no cached tags - this.cachedViews = [] - } - resolve([...this.cachedViews]) - }) + delOthersCachedViews(view: any) { + return new Promise(resolve => { + const index = this.cachedViews.indexOf(view.name) + if (index > -1) { + this.cachedViews = this.cachedViews.slice(index, index + 1) + } else { + // if index = -1, there is no cached tags + this.cachedViews = [] + } + resolve([...this.cachedViews]) + }) }, - updateVisitedView (view:any) { + updateVisitedView(view: any) { for (let v of this.visitedViews) { if (v.path === view.path) { v = Object.assign(v, view) @@ -77,31 +76,42 @@ const tagsViewStore=defineStore({ } } }, - addView( view:any) { - this.addVisitedView( view) + addView(view: any) { + this.addVisitedView(view) this.addCachedView(view) }, - delView( view:any) { + delView(view: any) { return new Promise(resolve => { - this.delVisitedView(view) - this.delCachedView( view) + this.delVisitedView(view) + this.delCachedView(view) resolve({ visitedViews: [...this.visitedViews], cachedViews: [...this.cachedViews] }) }) }, - delOthersViews( view:any) { + delOthersViews(view: any) { return new Promise(resolve => { - this.delOthersVisitedViews(view) - this.delOthersCachedViews(view) + this.delOthersVisitedViews(view) + this.delOthersCachedViews(view) resolve({ visitedViews: [...this.visitedViews], cachedViews: [...this.cachedViews] }) }) }, - delAllViews( view:any) { + delLeftViews(view: any) { + const currIndex = this.visitedViews.findIndex(v => v.path === view.path) + if (currIndex === -1) { + return + } + this.visitedViews = this.visitedViews.filter((item, index) => { + if(index>=currIndex||(item.meta&&item.meta.affix)){ + return true + } + }) + }, + delAllViews(view: any) { return new Promise(resolve => { const affixTags = this.visitedViews.filter(tag => tag.meta?.affix) this.visitedViews = affixTags diff --git a/src/views/redirect/index.vue b/src/views/redirect/index.vue index 00df81ea..2363a22e 100644 --- a/src/views/redirect/index.vue +++ b/src/views/redirect/index.vue @@ -1,14 +1,15 @@ -