From 3c8cd2c782ce7d02968e324440a4516b280cae4b Mon Sep 17 00:00:00 2001 From: xingyy <64720302+Concur-max@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:18:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor(app):=20=E7=A7=BB=E9=99=A4=20KeepAlive?= =?UTF-8?q?=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除了 KeepAlive 相关的代码和组件 - 移除了 Pinia相关的代码和组件 - 更新了 README 文档,删除了 Pinia 相关的说明- 移除了国际化文件中与 KeepAlive 相关的翻译项 --- README.md | 5 ----- app/app.vue | 9 +-------- app/composables/keepalive.ts | 24 ----------------------- app/middleware/route.global.ts | 7 ------- app/pages/counter/index.vue | 35 ---------------------------------- i18n/locales/en-US.json | 1 - 6 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 app/composables/keepalive.ts delete mode 100644 app/middleware/route.global.ts delete mode 100644 app/pages/counter/index.vue diff --git a/README.md b/README.md index 2d6baf6..1ab7e15 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,6 @@ - 🔥 ` diff --git a/app/composables/keepalive.ts b/app/composables/keepalive.ts deleted file mode 100644 index fbe0233..0000000 --- a/app/composables/keepalive.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { RouteLocationNormalized, RouteRecordName } from 'vue-router' -import { defineStore } from 'pinia' - -const useKeepalive = defineStore('keepalive', () => { - const routeCaches = ref([]) - - const addRoute = (route: RouteLocationNormalized) => { - if (!route.name) - return - - if (routeCaches.value.includes(route.name)) - return - - if (route?.meta?.keepalive) - routeCaches.value.push(route.name) - } - - return { - routeCaches, - addRoute, - } -}) - -export default useKeepalive diff --git a/app/middleware/route.global.ts b/app/middleware/route.global.ts deleted file mode 100644 index 2262eff..0000000 --- a/app/middleware/route.global.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { RouteLocationNormalized } from 'vue-router' -import useKeepalive from '~/composables/keepalive' - -export default defineNuxtRouteMiddleware((to: RouteLocationNormalized) => { - if (to.meta && to.meta.keepalive) - useKeepalive().addRoute(to) -}) diff --git a/app/pages/counter/index.vue b/app/pages/counter/index.vue deleted file mode 100644 index 0d63233..0000000 --- a/app/pages/counter/index.vue +++ /dev/null @@ -1,35 +0,0 @@ - - - diff --git a/i18n/locales/en-US.json b/i18n/locales/en-US.json index fe49171..06adfb6 100644 --- a/i18n/locales/en-US.json +++ b/i18n/locales/en-US.json @@ -12,7 +12,6 @@ "404Demo": "🙅 Page 404 Demo", "unocssExample": "🎨 Unocss example", "keepAlive": "🧡 KeepAlive Demo", - "persistPiniaState": "💾 Persist Pinia State", "fetch": "🏄 Network Request" }, "tabbar": {