CD配唱片
2025-05-09 9e493433014bbc80a3fb2fe3642fd9f4e7467888
src/App.vue
@@ -1,8 +1,8 @@
<template>
  <el-config-provider :locale="locale === 'zh' ? zhCnEl : enUsEl">
    <!-- <keep-alive :include="cachedViews">
    <keep-alive :include="cachedViewsList">
      <router-view />
    </keep-alive> -->
    </keep-alive>
    <router-view />
  </el-config-provider>
</template>
@@ -14,17 +14,21 @@
import { useI18n } from "vue-i18n"; //要在js中使用国际化
const { locale } = useI18n();
import useSettingsStore from "@/store/modules/settings";
import useTagsViewStore from "@/store/modules/tagsView"
import { handleThemeStyle } from "@/utils/theme";
const route = useRoute();
const router = useRouter();
const cachedViews = computed(() => {
  console.log(router.getRoutes(),"router.getRoutes()")
const cachedViewsList = ref([]);
const tagsViewStore = useTagsViewStore();
const cachedViews = function() {
  return router
    .getRoutes() // 获取所有路由
    .filter((r) => r.meta && r.meta.keepAlive) // 过滤出需要缓存的路由
    .map((r) => r.name); // 获取路由名称作为缓存键值
});
    .getRoutes()
    .filter((r) => r.meta && r.meta.noCache)
    .map((r) => r.name);
};
onMounted(() => {
  cachedViewsList.value = tagsViewStore.cachedViews;
  console.log(cachedViewsList.value,"router.getRoutes()")
  nextTick(() => {
    // 初始化主题样式
    handleThemeStyle(useSettingsStore().theme);