mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
try to fix memory leak
This commit is contained in:
parent
6e22dde22c
commit
8b5c59d39a
@ -2,27 +2,30 @@ import Vue from 'vue'
|
||||
|
||||
let lastRoute
|
||||
const keepAliveHook = {}
|
||||
keepAliveHook.install = Vue => {
|
||||
const keepAlivePages = process.env.keepAlivePages || []
|
||||
|
||||
Vue.mixin({
|
||||
// Save route if this instance is a page (has metaInfo)
|
||||
mounted() {
|
||||
if (this.$metaInfo) {
|
||||
lastRoute = this.$route.name
|
||||
if (!process.server) {
|
||||
keepAliveHook.install = Vue => {
|
||||
const keepAlivePages = process.env.keepAlivePages || []
|
||||
|
||||
Vue.mixin({
|
||||
// Save route if this instance is a page (has metaInfo)
|
||||
mounted() {
|
||||
if (this.$metaInfo) {
|
||||
lastRoute = this.$route.name
|
||||
}
|
||||
},
|
||||
activated() {
|
||||
if (this.$metaInfo) {
|
||||
lastRoute = this.$route.name
|
||||
}
|
||||
},
|
||||
deactivated() {
|
||||
// If this is a page and we don't want it to be kept alive
|
||||
if (this.$metaInfo && !keepAlivePages.includes(lastRoute)) {
|
||||
this.$destroy()
|
||||
}
|
||||
}
|
||||
},
|
||||
activated() {
|
||||
if (this.$metaInfo) {
|
||||
lastRoute = this.$route.name
|
||||
}
|
||||
},
|
||||
deactivated() {
|
||||
// If this is a page and we don't want it to be kept alive
|
||||
if (this.$metaInfo && !keepAlivePages.includes(lastRoute)) {
|
||||
this.$destroy()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
Vue.use(keepAliveHook)
|
||||
}
|
||||
Vue.use(keepAliveHook)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user