diff --git a/docs/OVERVIEW.md b/docs/OVERVIEW.md index 789604b..2e16786 100644 --- a/docs/OVERVIEW.md +++ b/docs/OVERVIEW.md @@ -145,13 +145,14 @@ Conventions worth knowing: ### Shell ``` -┌──────────────────────────────────────────────────────────┐ -│ [book mark] paper-doc 论文 模板 [mark] │ header -├───────────────────┬──────────────────────────────────────┤ +┌───────────────────┬──────────────────────────────────────┐ +│ [mark] paper-doc │ 论文 模板 [mk] │ header +├───────────────────┼──────────────────────────────────────┤ │ 模板配置 │ │ second-level │ 模板列表 │ │ menu, left │ 字段管理 │ │ └───────────────────┴──────────────────────────────────────┘ + <- 208px -> ``` The mark appears at both ends of the header. The second-level menu sits on the @@ -159,9 +160,28 @@ The mark appears at both ends of the header. The second-level menu sits on the which menu it belongs to and deep links render correctly on first paint. Routes without a `section` (the welcome page) show no menu. -Which side the menu lands on follows from its DOM order inside the flex row in -`App.vue` — first child, left — so moving it is a one-block change there rather -than a stylesheet override. +Two things about this layout are deliberate and easy to break by accident: + +- **Which side the menu lands on follows from its DOM order** inside the flex + row in `App.vue` — first child, left. Moving it is a one-block change there, + not a stylesheet override. +- **The logo block is exactly as wide as the rail.** Both read `asideWidth()` + from `src/layout.ts`, so they cannot drift apart, and collapsing the rail + narrows the logo block with it (dropping the wordmark and centring the mark). + The header's own padding is zeroed for this; the two insets come from + `ASIDE_INSET` so the mark lines up with the section title below it. + +The column also carries through to the content: the rail is 208px and both the +top nav's first item and `.el-main` are inset a further 20px by their own +Element Plus defaults, so the menu text, the page body, and the page header all +start on the same vertical line. + +### Shell metrics + +`src/layout.ts` is the single source for the rail's width and inset. It is a +module rather than CSS custom properties because `el-aside` takes its width +through a prop, which would otherwise fight an inline style coming from the +stylesheet. ### Routes diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 6c57f21..7926a77 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -12,8 +12,11 @@ import { RouterView, RouterLink, useRoute } from 'vue-router' import AppLogo from '@/components/AppLogo.vue' import SectionAside from '@/components/SectionAside.vue' +import { ASIDE_INSET, asideWidth } from '@/layout' +import { useAppStore } from '@/stores/app' const route = useRoute() +const appStore = useAppStore() /** The two top-level sections. `index` is the path `el-menu` routes to. */ const TOP_MENU = [ @@ -36,12 +39,27 @@ const activeTop = computed(() => { }) const section = computed(() => (route.meta.section as string | undefined) ?? '') + +/** + * The logo block is exactly as wide as the second-level menu below it, so the + * two stack into one column instead of leaving a ragged left edge. Both read + * `asideWidth`, so collapsing the rail narrows the logo block with it. + */ +const brandWidth = computed(() => asideWidth(appStore.asideCollapsed))