|
@@ -8,7 +8,7 @@ import routesFour from './routes/routes-file-four'
|
|
|
import routesFive from './routes/routes-file-five'
|
|
|
import routesSix from './routes/routes-file-six'
|
|
|
import routesSeven from './routes/routes-file-seven'
|
|
|
-import { Route, useKeepAlive } from '@/store/keepAlive'
|
|
|
+import { Route, useKeepAliveStore } from '@/store/keepAlive'
|
|
|
|
|
|
const routesPush = (arr, routes) => {
|
|
|
if (!Array.isArray(arr)) return '请传入数组格式路由表'
|
|
@@ -76,15 +76,19 @@ const router: Router = createRouter({
|
|
|
})
|
|
|
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
+ const keepAliveStore = useKeepAliveStore()
|
|
|
const {
|
|
|
savedRoutes,
|
|
|
- saveRoute,
|
|
|
// cachedViews,
|
|
|
- addCachedViewAll,
|
|
|
// delCachedView,
|
|
|
+ } = storeToRefs(keepAliveStore)
|
|
|
+ const {
|
|
|
+ saveRoute,
|
|
|
+ addCachedViewAll,
|
|
|
delCachedViewAll,
|
|
|
delCachedViewUntil,
|
|
|
- } = useKeepAlive()
|
|
|
+ } = keepAliveStore
|
|
|
+
|
|
|
if (from.matched?.[0]?.name === 'RealTime') {
|
|
|
if (to.matched[2].name !== from.matched[2].name) {
|
|
|
delCachedViewAll()
|
|
@@ -114,7 +118,7 @@ router.beforeEach(async (to, from, next) => {
|
|
|
(!to.query.flightNO || !to.query.flightDate)) ||
|
|
|
(to.name.includes('WaybillView') && !to.query.waybillNO))
|
|
|
) {
|
|
|
- const savedRoute = savedRoutes.find(
|
|
|
+ const savedRoute = savedRoutes.value.find(
|
|
|
savedRoute => savedRoute.name === to.name
|
|
|
)
|
|
|
if (savedRoute) {
|