docs: introduce project and keep local reports out of source delivery
This commit is contained in:
1 parent
db5762abd4
commit
d37ce57d09
45 files changed
+232
-14820
No files matched your search
+8
-1
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* 全站入口:公共购买页可在未登录时使用独立布局,其余页面沿用路由指定的布局。
|
||||
* 路由放行与组件实际挂载同时受会话约束,防止重定向等待期间仍执行受保护页面请求。
|
||||
*/
|
||||
import { computed, onMounted, onBeforeUnmount } from "vue";
|
||||
import { useRoute } from "#app";
|
||||
import { NuxtLayout, NuxtPage, NuxtRouteAnnouncer } from "#components";
|
||||
@@ -11,16 +15,19 @@ import { isPublicShop, isAuthPage, isPublicRoute } from "~/utils/access.js";
|
||||
const auth = useAuth();
|
||||
const route = useRoute();
|
||||
const theme = useTheme();
|
||||
// 只为访客切换公开购买布局;登录后的同一路由继续使用会员中心布局。
|
||||
const layout = computed(() =>
|
||||
!auth.isLoggedIn && isPublicShop(route) ? "public-order" : route.meta.layout,
|
||||
);
|
||||
// An authenticated route's component tree belongs to that session, not to a pending redirect.
|
||||
// 中间件负责导航,入口负责禁止未授权组件树挂载,两者处理的是不同的生命周期阶段。
|
||||
const canRenderRoute = computed(() => auth.isLoggedIn || isPublicRoute(route));
|
||||
// 账号切换时重新创建布局与页面,清除旧账号的局部状态;登录入口自身按路径区分。
|
||||
const routeSessionKey = computed(() =>
|
||||
isAuthPage(route.path) || route.path === "/home.htm"
|
||||
? route.path
|
||||
: auth.token || "anonymous",
|
||||
);
|
||||
// 主题监听由入口统一注册和释放,避免每次页面导航重复绑定系统主题事件。
|
||||
onMounted(theme.init);
|
||||
onBeforeUnmount(theme.dispose);
|
||||
</script>
|
||||
|
||||
Reference in new issue
Block a user