Skip to content

Commit d8471f7

Browse files
committed
fixed: Cachable Route
1 parent bba0d88 commit d8471f7

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/store/modules/visited-routes.ts

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { defineStore } from 'pinia'
22
import { RouteLocationNormalized } from 'vue-router'
33
import pinia from '../pinia'
4-
import useCachedRouteStore from '@/store/modules/cached-routes'
5-
import { findCachedRoutes } from '../help'
4+
// import useCachedRouteStore from '@/store/modules/cached-routes'
5+
// import { findCachedRoutes } from '../help'
66

77
const visitedRoutes = JSON.parse(localStorage.getItem('visited-routes') || '[]')
88

@@ -30,12 +30,12 @@ const useVisitedRouteStore = defineStore('visited-routes', {
3030
addVisitedRoute(route: RouteLocationNormalized) {
3131
return new Promise((resolve) => {
3232
if (!this.visitedRoutes.find((it) => it.fullPath === route.fullPath)) {
33-
if (route.name) {
34-
const cachedRoutesStore = useCachedRouteStore()
35-
if (!cachedRoutesStore.cachedRoutes.includes(route.name as string)) {
36-
cachedRoutesStore.cachedRoutes.push(route.name as string)
37-
}
38-
}
33+
// if (route.name) {
34+
// const cachedRoutesStore = useCachedRouteStore()
35+
// if (!cachedRoutesStore.cachedRoutes.includes(route.name as string)) {
36+
// cachedRoutesStore.cachedRoutes.push(route.name as string)
37+
// }
38+
// }
3939
this.visitedRoutes.push(route)
4040

4141
this.persistentVisitedView()
@@ -46,15 +46,15 @@ const useVisitedRouteStore = defineStore('visited-routes', {
4646
removeVisitedRoute(route: RouteLocationNormalized) {
4747
return new Promise<string>((resolve) => {
4848
this.visitedRoutes.splice(this.visitedRoutes.indexOf(route), 1)
49-
if (route.name) {
50-
const cachedRoutesStore = useCachedRouteStore()
51-
if (cachedRoutesStore.cachedRoutes.includes(route.name as string)) {
52-
cachedRoutesStore.cachedRoutes.splice(
53-
cachedRoutesStore.cachedRoutes.indexOf(route.name as string),
54-
1
55-
)
56-
}
57-
}
49+
// if (route.name) {
50+
// const cachedRoutesStore = useCachedRouteStore()
51+
// if (cachedRoutesStore.cachedRoutes.includes(route.name as string)) {
52+
// cachedRoutesStore.cachedRoutes.splice(
53+
// cachedRoutesStore.cachedRoutes.indexOf(route.name as string),
54+
// 1
55+
// )
56+
// }
57+
// }
5858
this.persistentVisitedView()
5959
resolve(this.findLastRoutePath())
6060
})
@@ -71,8 +71,8 @@ const useVisitedRouteStore = defineStore('visited-routes', {
7171
this.visitedRoutes = this.visitedRoutes.filter((it, index) => {
7272
return (it.meta && it.meta.affix) || index >= selectIndex
7373
})
74-
const cachedRoutesStore = useCachedRouteStore()
75-
cachedRoutesStore.setCachedRoutes(findCachedRoutes(this.visitedRoutes))
74+
// const cachedRoutesStore = useCachedRouteStore()
75+
// cachedRoutesStore.setCachedRoutes(findCachedRoutes(this.visitedRoutes))
7676
this.persistentVisitedView()
7777
}
7878
resolve(selectRoute)
@@ -85,8 +85,8 @@ const useVisitedRouteStore = defineStore('visited-routes', {
8585
this.visitedRoutes = this.visitedRoutes.filter((it, index) => {
8686
return (it.meta && it.meta.affix) || index <= selectIndex
8787
})
88-
const cachedRoutesStore = useCachedRouteStore()
89-
cachedRoutesStore.setCachedRoutes(findCachedRoutes(this.visitedRoutes))
88+
// const cachedRoutesStore = useCachedRouteStore()
89+
// cachedRoutesStore.setCachedRoutes(findCachedRoutes(this.visitedRoutes))
9090
this.persistentVisitedView()
9191
}
9292
resolve(selectRoute)
@@ -97,8 +97,8 @@ const useVisitedRouteStore = defineStore('visited-routes', {
9797
this.visitedRoutes = this.visitedRoutes.filter((it) => {
9898
return it.meta && it.meta.affix
9999
})
100-
const cachedRoutesStore = useCachedRouteStore()
101-
cachedRoutesStore.setCachedRoutes(findCachedRoutes(this.visitedRoutes))
100+
// const cachedRoutesStore = useCachedRouteStore()
101+
// cachedRoutesStore.setCachedRoutes(findCachedRoutes(this.visitedRoutes))
102102
this.persistentVisitedView()
103103
resolve()
104104
})

0 commit comments

Comments
 (0)