From ef37c59e055a990ce247b265b27d3fcef430a243 Mon Sep 17 00:00:00 2001 From: 杨磊 <505174330@qq.com> Date: 星期五, 15 八月 2025 10:19:18 +0800 Subject: [PATCH] first submit --- src/layout/base.vue | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/src/layout/base.vue b/src/layout/base.vue new file mode 100644 index 0000000..ba58e06 --- /dev/null +++ b/src/layout/base.vue @@ -0,0 +1,25 @@ +<template> + <keep-alive v-if="keepAliveList.length > 0" :include="keepAliveList"> + <router-view /> + </keep-alive> + <router-view v-else /> +</template> + +<script> +import { mapState } from "vuex"; +export default { + data() { + return {}; + }, + computed: { + ...mapState(["keepAliveList"]) + }, + watch: { + $route(to, from) { + if (to.meta.keepAlive && this.keepAliveList.indexOf(to.name) == -1) { + this.$store.commit("addKeepAlive", to.name); + } + } + } +}; +</script> -- Gitblit v1.9.1