Files
aigc-frontend/src/App.vue
2026-04-01 20:18:19 +08:00

47 lines
915 B
Vue

<template>
<router-view v-slot="{ Component }">
<keep-alive :include="KeepAliveList">
<component :is="Component" />
</keep-alive>
</router-view>
</template>
<script setup>
const router = useRouter()
const KeepAliveList = ref([])
router.beforeEach((to, from, next) => {
const keepAlive = to?.meta?.keepAlive
if (!router.hasRoute(to.name)) {
router.push('/home')
return
}
if (keepAlive) {
if (KeepAliveList.value.indexOf(to.name) === -1) {
KeepAliveList.value.push(to.name)
} else {
const index = KeepAliveList.value.findIndex((name) => name === from.name)
index > -1 ? KeepAliveList.value.splice(index, 1) : null
}
}
next()
})
</script>
<style lang="scss">
#app {
width: 100%;
height: 100%;
overflow: hidden;
@media only screen and (min-width: 500px) {
max-width: 500px;
margin: auto;
transform: scale(1);
}
}
</style>