优化详情返回首页停留

This commit is contained in:
yml2213
2026-07-11 23:25:51 +08:00
parent f81842d46e
commit 7614c0980e
4 changed files with 120 additions and 13 deletions
+8 -1
View File
@@ -8,6 +8,9 @@ import InAppBrowserPrompt from './components/InAppBrowserPrompt.vue'
import AdminLayout from './layouts/AdminLayout.vue'
import AppLayout from './layouts/AppLayout.vue'
/** 移动端从详情返回时保留列表状态与滚动位置 */
const mobileKeepAliveIncludes = ['MobileHomeView']
const route = useRoute()
const layout = computed(() => {
if (route.path === '/m' || route.path.startsWith('/m/')) {
@@ -23,7 +26,11 @@ const layout = computed(() => {
<AdminLayout v-if="layout === 'admin'">
<RouterView />
</AdminLayout>
<RouterView v-else-if="layout === 'blank'" />
<RouterView v-else-if="layout === 'blank'" v-slot="{ Component }">
<KeepAlive :include="mobileKeepAliveIncludes" :max="5">
<component :is="Component" />
</KeepAlive>
</RouterView>
<AppLayout v-else>
<RouterView />
</AppLayout>