Trim comments to the non-obvious why
Drop narration, history and restated-code comments across the repo, keep short ones for security boundaries, upstream quirks and ordering constraints, and record the convention in CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+7
-39
@@ -1,18 +1,6 @@
|
||||
/**
|
||||
* Route table and the single sign-in/admin route guard.
|
||||
*
|
||||
* Structure: two layout shells. `/` mounts DefaultLayout (navbar + footer, dark
|
||||
* theme) and holds most routes; `/cv` mounts CVLayout (light print theme).
|
||||
* `/stp2` is deliberately outside both — it is a bare full-bleed mock.
|
||||
*
|
||||
* Pages made in the browser (views/canvas/) have no entries here: the
|
||||
* catch-all at the end looks the path up and renders the page if one exists.
|
||||
*
|
||||
* Only the landing page is statically imported; every other view is a dynamic
|
||||
* import so Vite code-splits it into its own chunk.
|
||||
*
|
||||
* Route `name`s are public contracts (used by RouterLink/`router.push`) — don't
|
||||
* rename them.
|
||||
* Routes and the sign-in/admin guard. Canvas pages have no entries: the
|
||||
* catch-all looks them up. Route `name`s are used by links; don't rename them.
|
||||
*/
|
||||
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
@@ -44,9 +32,7 @@ const router = createRouter({
|
||||
component: () => import("@/views/admin/Admin.vue"),
|
||||
meta: { requiresAdmin: true },
|
||||
},
|
||||
// A signed-in user's own page: the gated services they have
|
||||
// been granted. /no-access is the same page with a notice,
|
||||
// where Caddy's permission gate sends a refused visitor.
|
||||
// Also /no-access, where Caddy's permission gate sends refusals.
|
||||
{
|
||||
path: "account",
|
||||
name: "account",
|
||||
@@ -76,13 +62,8 @@ const router = createRouter({
|
||||
component: () =>
|
||||
import("@/views/architecture/Architecture.vue"),
|
||||
},
|
||||
// /stp, /shrines and the shrines under it are canvas pages,
|
||||
// made from the admin panel's Pages tab and served by the
|
||||
// catch-all below. /stp's old route (views/home3/Home3.vue)
|
||||
// and the hand-written shrines (views/home/shrines/) are
|
||||
// unrouted.
|
||||
// Anything else is an admin-created canvas page if one exists
|
||||
// at that address (the Page GraphQL type), else the 404.
|
||||
// Canvas pages (/stp, /shrines, admin-created) via the
|
||||
// catch-all, else the 404.
|
||||
{
|
||||
path: ":pathMatch(.*)*",
|
||||
name: "404",
|
||||
@@ -104,26 +85,13 @@ const router = createRouter({
|
||||
name: "cv",
|
||||
component: () => import("@/views/CV/CV.vue"),
|
||||
},
|
||||
// /cv/jobs and /cv/leads moved to the job tracker app at
|
||||
// /jobs/; Caddy redirects the old paths.
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// Guard for routes marked `meta: { requiresAdmin: true }` or
|
||||
// `meta: { requiresSignIn: true }` (any account, admin or not).
|
||||
//
|
||||
// The admin flag arrives asynchronously, so navigating straight to /admin on a
|
||||
// cold load would otherwise read an empty user and bounce a legitimate admin to
|
||||
// the login page. The guard therefore awaits auth.ensureLoaded(), which issues
|
||||
// a standalone `me` query unless the user is already known.
|
||||
//
|
||||
// It deliberately does not wait on the home query (stores/homeData.js): that
|
||||
// one fans out to Spotify, Steam and Gitea, and a guard that waited on it hung
|
||||
// forever when it failed. ensureLoaded() always settles — a failed `me` reads
|
||||
// as "not signed in" — and `user` is re-read on every navigation, so a login or
|
||||
// logout during the session is honoured.
|
||||
// Awaits auth.ensureLoaded() so a cold load of /admin doesn't bounce a real
|
||||
// admin. Not the home query: that fans out to third parties and can fail.
|
||||
router.beforeEach(async (to) => {
|
||||
if (!to.meta.requiresAdmin && !to.meta.requiresSignIn) return;
|
||||
const auth = useAuthStore();
|
||||
|
||||
Reference in New Issue
Block a user