valaxy-theme-lolimeow 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/App.vue +105 -0
  2. package/client/index.ts +12 -83
  3. package/components/LmBackgroundLayer.vue +35 -51
  4. package/components/LmHelper.vue +12 -4
  5. package/components/LmNotice.vue +2 -3
  6. package/components/archive/LmArchiveRail.vue +3 -1
  7. package/components/article/LmArticleHeader.vue +21 -5
  8. package/components/category/LmCategoryTree.vue +3 -1
  9. package/components/core/layout.vue +12 -88
  10. package/components/home/LmHeroSocialLinks.vue +2 -3
  11. package/components/home/LmHomeContent.vue +6 -0
  12. package/components/home/LmPagination.vue +1 -2
  13. package/components/home/LmPinned.vue +1 -2
  14. package/components/home/LmPostCard.vue +46 -7
  15. package/components/home/LmPostList.vue +3 -1
  16. package/components/navbar/LmMobileDrawer.vue +6 -2
  17. package/components/plugins/LmWaline.vue +10 -5
  18. package/components/plugins/LmWalineClient.vue +32 -0
  19. package/components/search/LmFuseSearchProvider.vue +6 -4
  20. package/features/archive/archive.ts +9 -4
  21. package/features/archive/use-archive-groups.ts +4 -3
  22. package/features/archive/use-archive-timeline-state.ts +6 -2
  23. package/features/article/use-article-header-meta.ts +16 -4
  24. package/features/article/use-article-toc-state.ts +21 -23
  25. package/features/article/use-toc-scroll.ts +9 -1
  26. package/features/background/background-image.ts +3 -1
  27. package/features/background/index.ts +1 -0
  28. package/features/background/resolve-background.ts +3 -3
  29. package/features/background/runtime/use-background-preload.ts +9 -3
  30. package/features/background/types.ts +1 -1
  31. package/features/background/use-app-background-layers.ts +62 -0
  32. package/features/background/use-resolved-background.ts +4 -3
  33. package/features/category/category.ts +29 -16
  34. package/features/category/use-category-groups.ts +5 -3
  35. package/features/comment/waline-options.ts +30 -0
  36. package/features/hero/motto/hitokoto.ts +3 -1
  37. package/features/hero/motto/use-motto-playback.ts +9 -1
  38. package/features/hero/motto/use-motto-source.ts +17 -4
  39. package/features/hero/use-hero-stage.ts +6 -2
  40. package/features/home/home-grid.ts +17 -6
  41. package/features/home/home-history.ts +63 -0
  42. package/features/home/index.ts +1 -1
  43. package/features/home/pagination/pagination-normalization.ts +3 -1
  44. package/features/home/pagination/pagination-scope.ts +3 -1
  45. package/features/home/pagination/use-pagination-items.ts +6 -2
  46. package/features/home/use-home-post-feed.ts +19 -101
  47. package/features/navigation/navigation-path.ts +3 -1
  48. package/features/navigation/use-layout-shell.ts +8 -9
  49. package/features/navigation/use-nav-item-state.ts +1 -1
  50. package/features/navigation/use-navbar-visibility.ts +2 -2
  51. package/features/post/post-content.ts +3 -1
  52. package/features/post/post-cover.ts +13 -4
  53. package/features/post/use-post-card-media-state.ts +5 -2
  54. package/features/post/use-post-card-view-model.ts +19 -4
  55. package/features/search/highlight.ts +25 -8
  56. package/features/tag/tag-cloud.ts +9 -2
  57. package/features/tag/tag.ts +31 -16
  58. package/features/tag/use-packed-tag-cloud.ts +64 -61
  59. package/features/tag/use-tag-groups.ts +5 -3
  60. package/node/colors.ts +54 -15
  61. package/node/config.ts +0 -1
  62. package/node/plugins.ts +0 -53
  63. package/package.json +16 -13
  64. package/setup/main.ts +6 -0
  65. package/shared/browser/index.ts +0 -1
  66. package/shared/browser/modal.ts +15 -5
  67. package/shared/browser/motion.ts +8 -58
  68. package/shared/browser/runtime.ts +3 -58
  69. package/shared/site/index.ts +1 -0
  70. package/shared/site/use-site-posts.ts +29 -0
  71. package/styles/main.scss +7 -0
  72. package/styles/markdown/_base.scss +1 -2
  73. package/styles/markdown/_dark.scss +1 -1
  74. package/styles/markdown/_footnotes.scss +52 -0
  75. package/styles/markdown/_interactive.scss +13 -7
  76. package/styles/mixins/glass.scss +4 -2
  77. package/styles/mixins/surface.scss +5 -1
  78. package/styles/vars.scss +4 -4
  79. package/types/background.d.ts +0 -5
  80. package/valaxy.config.ts +4 -10
  81. package/features/home/history/home-history-state.ts +0 -280
  82. package/features/home/history/home-scroll-task.ts +0 -192
  83. package/features/home/history/use-home-pagination-scroll.ts +0 -185
  84. package/shared/browser/rate-limit.ts +0 -175
package/App.vue ADDED
@@ -0,0 +1,105 @@
1
+ <script setup lang="ts">
2
+ import { useI18n } from 'vue-i18n'
3
+ import { useAppBackgroundLayers } from './features/background'
4
+ import { useLayoutShell } from './features/navigation'
5
+
6
+ // Valaxy 只挂载一次本组件,且位于路由视图之外:这里的背景、阅读表层、导航、搜索与回顶按钮
7
+ // 不随布局切换重建。背景运行时因此在整个会话内只有一份,切页不会打断随机轮换。
8
+ const { t } = useI18n()
9
+ const {
10
+ closeDrawer,
11
+ closeSearch,
12
+ headerVisible,
13
+ isDrawerOpen,
14
+ isHomeLayout,
15
+ isSearchOpen,
16
+ navItems,
17
+ openSearch,
18
+ pageSurfaceStyle,
19
+ toggleDrawer,
20
+ } = useLayoutShell()
21
+ // 清晰层与首页的模糊副本共用这一份图层数据,两者显示同一张图并同步淡入。
22
+ const backgroundLayers = useAppBackgroundLayers()
23
+ </script>
24
+
25
+ <template>
26
+ <!-- 非首页的阅读表层盖满整页,壁纸没有需要保持清晰的区域,直接模糊背景层。 -->
27
+ <LmBackgroundLayer :layers="backgroundLayers" :blurred="!isHomeLayout" />
28
+
29
+ <div class="lm-page-surface-layer" :style="pageSurfaceStyle" aria-hidden="true">
30
+ <!-- 首页 Hero 区要露出清晰壁纸,阅读表层内另放一份模糊副本。 -->
31
+ <LmBackgroundLayer
32
+ v-if="isHomeLayout && (backgroundLayers.baseImageStyle || backgroundLayers.incomingImageStyle)"
33
+ :layers="backgroundLayers"
34
+ blurred
35
+ />
36
+ </div>
37
+
38
+ <button
39
+ v-if="isDrawerOpen"
40
+ type="button"
41
+ class="lm-mobile-drawer-backdrop"
42
+ :aria-label="t('button.closeMobileNav')"
43
+ @click="closeDrawer"
44
+ />
45
+
46
+ <div
47
+ class="transition-transform duration-250 ease-in-out inset-x-0 top-0 fixed z-[var(--lm-z-navbar)]"
48
+ :class="headerVisible ? 'translate-y-0' : '-translate-y-full'"
49
+ >
50
+ <div class="w-full">
51
+ <LmNav
52
+ :drawer-open="isDrawerOpen"
53
+ :items="navItems"
54
+ @toggle-mobile-drawer="toggleDrawer"
55
+ @open-search="openSearch"
56
+ />
57
+ <LmMobileDrawer
58
+ :open="isDrawerOpen"
59
+ :items="navItems"
60
+ @close="closeDrawer"
61
+ />
62
+ </div>
63
+ </div>
64
+
65
+ <LmSearchModal
66
+ :open="isSearchOpen"
67
+ @close="closeSearch"
68
+ />
69
+
70
+ <LmHelper />
71
+ </template>
72
+
73
+ <style lang="scss" scoped>
74
+ .lm-mobile-drawer-backdrop {
75
+ @apply fixed inset-0 z-[var(--lm-z-drawer-backdrop)] border-0 bg-transparent p-0 md:hidden;
76
+ }
77
+
78
+ .lm-page-surface-layer {
79
+ // 外层只定义阅读区域边界,相对 #app 定位;首页从 Hero 底部开始,其余页面覆盖整页。
80
+ // top 由内联样式提供(首页为 Hero 高度,其余页面为 0),SSR 阶段即已确定。
81
+ position: absolute;
82
+ left: 0;
83
+ right: 0;
84
+ top: 0;
85
+ bottom: 0;
86
+ z-index: var(--lm-z-page-surface);
87
+ pointer-events: none;
88
+ // clip-path 会连固定定位的后代一起裁剪:首页的模糊壁纸副本铺满视口,只在阅读区域内可见。
89
+ clip-path: inset(0);
90
+
91
+ // 着色层盖在模糊壁纸之上。壁纸由背景图层自己模糊,这里不使用 backdrop-filter。
92
+ // 着色层只占一个视口,避免长文章产生与文档等高的合成层;
93
+ // sticky 直接跟随文档滚动,无需 JS 测量;短页面限制在外层高度内。
94
+ &::after {
95
+ content: '';
96
+ display: block;
97
+ position: sticky;
98
+ top: 0;
99
+ height: 100vh;
100
+ height: 100dvh;
101
+ max-height: 100%;
102
+ background: color-mix(in srgb, var(--lm-c-bg-glass) 62%, transparent);
103
+ }
104
+ }
105
+ </style>
package/client/index.ts CHANGED
@@ -1,96 +1,25 @@
1
+ // 主题的公开浏览器入口:主题配置,以及各内置页面背后的数据,供站点自己实现页面或覆盖组件时使用。
2
+ // 其余 features/、shared/ 路径都是内部实现,随版本调整,不在此导出。
1
3
  /* eslint-disable perfectionist/sort-exports */
2
4
 
5
+ export { useThemeConfig } from '../shared/config'
6
+
3
7
  export type { AboutSocialLink } from '../features/about'
4
8
  export { useAboutProfile } from '../features/about'
5
9
 
6
- export { useArticleHeaderMeta, useArticleTocState } from '../features/article'
7
-
8
10
  export type { ArchiveEntry, ArchiveGroup } from '../features/archive'
9
- export {
10
- buildArchiveGroups,
11
- normalizeArchiveCategories,
12
- resolveArchiveYear,
13
- useArchiveGroups,
14
- useArchiveTimelineState,
15
- } from '../features/archive'
16
-
17
- export { useBackgroundRuntime, useResolvedBackground } from '../features/background'
11
+ export { useArchiveGroups } from '../features/archive'
18
12
 
19
13
  export type { CategoryEntry, CategoryNode } from '../features/category'
20
- export {
21
- buildCategoryTree,
22
- countCategoryNodes,
23
- normalizeCategorySegments,
24
- useCategoryGroups,
25
- } from '../features/category'
26
-
27
- export type { TypewriterRenderOptions } from '../features/hero'
28
- export { useHeroMotto, useHeroStage, useTypewriter } from '../features/hero'
14
+ export { useCategoryGroups } from '../features/category'
29
15
 
30
- export {
31
- useHomePaginationScrollBehavior,
32
- useHomePostFeed,
33
- usePaginationItems,
34
- usePinnedEntries,
35
- } from '../features/home'
16
+ export { usePinnedEntries } from '../features/home'
36
17
 
37
- export type { LinkStatus, ResolvedLinkGroup, ResolvedLinkItem } from '../features/link'
38
- export { useLinkGroups, useLinkStatus } from '../features/link'
18
+ export type { ResolvedLinkGroup, ResolvedLinkItem } from '../features/link'
19
+ export { useLinkGroups } from '../features/link'
39
20
 
40
- export {
41
- isExternalNavLink,
42
- resolveInternalNavRoute,
43
- shouldOpenNavLinkWithWindow,
44
- shouldShowExternalNavIndicator,
45
- useLayoutShell,
46
- useMobileDrawer,
47
- useNavActive,
48
- useNavbarTools,
49
- useNavbarVisibility,
50
- useNavItemState,
51
- } from '../features/navigation'
52
-
53
- export {
54
- POST_CARD_COVER_LOAD_TIMEOUT_MS,
55
- usePostCardMediaState,
56
- usePostCardViewModel,
57
- } from '../features/post'
58
-
59
- export type {
60
- ProjectAction,
61
- ResolvedProjectGroup,
62
- ResolvedProjectItem,
63
- } from '../features/project'
21
+ export type { ProjectAction, ResolvedProjectGroup, ResolvedProjectItem } from '../features/project'
64
22
  export { useProjectGroups } from '../features/project'
65
23
 
66
- export type {
67
- LmFuseSearchItem,
68
- LmFuseSearchResult,
69
- LmSearchHighlightPart,
70
- } from '../features/search'
71
- export {
72
- collectQueryRanges,
73
- createHighlightParts,
74
- mergeRanges,
75
- resolveSearchText,
76
- stripSearchHtml,
77
- useLmFuseSearch,
78
- useSearchModal,
79
- } from '../features/search'
80
-
81
- export type {
82
- TagCloudSourceItem,
83
- TagCloudViewItem,
84
- TagEntry,
85
- TagGroup,
86
- } from '../features/tag'
87
- export {
88
- buildTagCloudItems,
89
- buildTagGroups,
90
- countTaggedPosts,
91
- createTagId,
92
- normalizeTags,
93
- useTagGroups,
94
- } from '../features/tag'
95
-
96
- export { useThemeConfig } from '../shared/config'
24
+ export type { TagEntry, TagGroup } from '../features/tag'
25
+ export { useTagGroups } from '../features/tag'
@@ -1,65 +1,32 @@
1
1
  <script lang="ts" setup>
2
- import { computed } from 'vue'
3
- import { createBackgroundImageStyle, useBackgroundPreload, useBackgroundRuntime, useResolvedBackground } from '../features/background'
2
+ import type { BackgroundLayers } from '../features/background'
4
3
 
5
- const background = useResolvedBackground('app')
6
- const runtimeBackground = useBackgroundRuntime('app', background)
7
-
8
- // 全局背景在每个页面都会加载,预加载让下载早于脚本水合开始。
9
- useBackgroundPreload('app')
10
-
11
- const placeholderStyle = computed(() => runtimeBackground.placeholderStyle.value)
12
- const hasBaseImageLayer = computed(() => Boolean(runtimeBackground.currentImageUrl.value))
13
- const hasIncomingImageLayer = computed(() => Boolean(runtimeBackground.incomingImageUrl.value))
14
- const incomingImageVisible = computed(() => runtimeBackground.incomingImageVisible.value)
15
-
16
- // 全局背景层只消费 app scope 的结果,不读取 hero.cover。
17
- // 这样首页 Hero 是否存在独立封面,不会反向影响整页壳层背景。
18
- const baseImageStyle = computed(() => {
19
- if (!hasBaseImageLayer.value)
20
- return {}
21
-
22
- return createBackgroundImageStyle(runtimeBackground.currentImageUrl.value, {
23
- fixed: background.value.fixed,
24
- position: background.value.position,
25
- size: background.value.size,
26
- })
27
- })
28
-
29
- const incomingImageStyle = computed(() => {
30
- if (!hasIncomingImageLayer.value)
31
- return {}
32
-
33
- return createBackgroundImageStyle(runtimeBackground.incomingImageUrl.value, {
34
- fixed: background.value.fixed,
35
- position: background.value.position,
36
- size: background.value.size,
37
- })
38
- })
39
-
40
- const overlayStyle = computed(() => ({
41
- opacity: String(background.value.overlayOpacity),
42
- background: 'linear-gradient(180deg, var(--lm-c-overlay-base), var(--lm-c-overlay-tint))',
43
- }))
4
+ defineProps<{
5
+ /** 由 `useAppBackgroundLayers()` 提供的图层数据。 */
6
+ layers: BackgroundLayers
7
+ /** 是否模糊图片层;用于阅读表层后方的壁纸。 */
8
+ blurred?: boolean
9
+ }>()
44
10
  </script>
45
11
 
46
12
  <template>
47
13
  <div class="pointer-events-none inset-0 fixed z-[var(--lm-z-base)] overflow-hidden" aria-hidden="true">
48
- <div class="lm-bg-layer" :style="placeholderStyle" />
14
+ <div class="lm-bg-layer" :style="layers.placeholderStyle" />
49
15
  <div
50
- v-if="hasBaseImageLayer"
51
- class="lm-bg-layer"
52
- :style="baseImageStyle"
16
+ v-if="layers.baseImageStyle"
17
+ class="lm-bg-layer lm-bg-image"
18
+ :class="{ 'lm-bg-image--blurred': blurred }"
19
+ :style="layers.baseImageStyle"
53
20
  />
54
21
  <div
55
- v-if="hasIncomingImageLayer"
56
- class="lm-bg-fade-layer"
57
- :class="incomingImageVisible ? 'opacity-100' : 'opacity-0'"
58
- :style="incomingImageStyle"
22
+ v-if="layers.incomingImageStyle"
23
+ class="lm-bg-layer lm-bg-image lm-bg-fade-layer"
24
+ :class="[layers.incomingImageVisible ? 'opacity-100' : 'opacity-0', { 'lm-bg-image--blurred': blurred }]"
25
+ :style="layers.incomingImageStyle"
59
26
  />
60
27
  <div
61
28
  class="lm-bg-layer"
62
- :style="overlayStyle"
29
+ :style="layers.overlayStyle"
63
30
  />
64
31
  </div>
65
32
  </template>
@@ -69,8 +36,25 @@ const overlayStyle = computed(() => ({
69
36
  @apply inset-0 absolute;
70
37
  }
71
38
 
39
+ /*
40
+ * 图片层向外扩出两倍模糊半径,多出的部分由容器裁掉:
41
+ * filter 在边缘才有真实像素可采样,不会向透明衰减。
42
+ * 清晰层与模糊层使用同一几何,首页 Hero 与阅读表层交界处的图像才能对齐。
43
+ */
44
+ .lm-bg-image {
45
+ inset: -12px;
46
+ }
47
+
48
+ /*
49
+ * 阅读表层后方的壁纸是静止的,由图片层自己的 filter 模糊,
50
+ * 替代表层用 backdrop-filter 在每一帧重新模糊。
51
+ */
52
+ .lm-bg-image--blurred {
53
+ filter: blur(6px) saturate(1.04);
54
+ }
55
+
72
56
  .lm-bg-fade-layer {
73
- @apply inset-0 absolute transition-opacity duration-500 ease-out;
57
+ @apply transition-opacity duration-500 ease-out;
74
58
  will-change: opacity;
75
59
  }
76
60
 
@@ -1,11 +1,12 @@
1
1
  <script setup lang="ts">
2
- import { useResizeObserver, useWindowScroll, useWindowSize } from '@vueuse/core'
2
+ import { useResizeObserver, useWindowSize } from '@vueuse/core'
3
+ import { useWindowScrollY } from 'valaxy'
3
4
  import { computed, onMounted, ref, shallowRef, useId, watch } from 'vue'
4
5
  import { useI18n } from 'vue-i18n'
5
6
  import { getDocumentBody, getDocumentElement, getWindow, prefersReducedMotion } from '../shared/browser'
6
7
 
7
8
  const { t } = useI18n()
8
- const { y } = useWindowScroll()
9
+ const y = useWindowScrollY()
9
10
  const { height: viewportHeight } = useWindowSize({ initialHeight: 0 })
10
11
  const documentBody = shallowRef<HTMLElement>()
11
12
  const documentHeight = ref(0)
@@ -28,14 +29,21 @@ watch(viewportHeight, measureDocument)
28
29
  const showBackToTop = computed(() => y.value > 120)
29
30
  const scrollProgress = computed(() => {
30
31
  const maxScroll = documentHeight.value - viewportHeight.value
31
- return maxScroll > 0 ? Math.min(1, Math.max(0, y.value / maxScroll)) : 0
32
+ return maxScroll > 0
33
+ ? Math.min(1, Math.max(0, y.value / maxScroll))
34
+ : 0
32
35
  })
33
36
  const fillHeight = computed(() => 50 * scrollProgress.value)
34
37
  const buttonTitle = computed(() => `${t('button.backToTop')} · ${Math.round(scrollProgress.value * 100)}%`)
35
38
 
36
39
  /** 按用户动态效果偏好返回顶部。 */
37
40
  function backToTop() {
38
- getWindow()?.scrollTo({ top: 0, behavior: prefersReducedMotion() ? 'instant' : 'smooth' })
41
+ getWindow()?.scrollTo({
42
+ top: 0,
43
+ behavior: prefersReducedMotion()
44
+ ? 'instant'
45
+ : 'smooth',
46
+ })
39
47
  }
40
48
  </script>
41
49
 
@@ -110,8 +110,7 @@ function closeNotice() {
110
110
  @include lm-surface-panel(
111
111
  color-mix(in srgb, var(--lm-c-bg-glass) 72%, transparent),
112
112
  color-mix(in srgb, var(--lm-c-border-hover) 42%, transparent),
113
- 0 14px 30px rgb(15 23 42 / 0.08),
114
- 14px
113
+ 0 14px 30px rgb(15 23 42 / 0.08)
115
114
  );
116
115
 
117
116
  @apply mt-4 relative grid grid-cols-[auto_minmax(0,1fr)_auto] rounded-3 items-center gap-3 overflow-hidden border px-4 py-3 md:gap-3.5;
@@ -145,7 +144,7 @@ function closeNotice() {
145
144
  var(--lm-c-primary-soft),
146
145
  var(--lm-c-primary-border-subtle),
147
146
  0 8px 18px rgb(15 23 42 / 0.06),
148
- 10px
147
+ null
149
148
  );
150
149
 
151
150
  @apply relative z-[var(--lm-z-raised)] inline-flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full;
@@ -17,7 +17,9 @@ const emit = defineEmits<{
17
17
 
18
18
  /** 将缺失年份的内部占位值转换为本地化展示文本。 */
19
19
  function displayYear(year: string, unknownYearLabel: string) {
20
- return year === 'Unknown' ? unknownYearLabel : year
20
+ return year === 'Unknown'
21
+ ? unknownYearLabel
22
+ : year
21
23
  }
22
24
 
23
25
  /** 获取当前时间线实例内稳定且唯一的年份面板 ID。 */
@@ -1,7 +1,9 @@
1
1
  <script setup lang="ts">
2
+ import { computed } from 'vue'
2
3
  import { useArticleHeaderMeta } from '../../features/article'
3
4
 
4
5
  const {
6
+ frontmatter,
5
7
  title,
6
8
  cover,
7
9
  categories,
@@ -9,14 +11,24 @@ const {
9
11
  publishedDate,
10
12
  infoItems,
11
13
  } = useArticleHeaderMeta()
14
+
15
+ const hasImageCover = computed(() => !!cover.value && !frontmatter.value.coverComponent)
12
16
  </script>
13
17
 
14
18
  <template>
15
19
  <header
16
20
  class="lm-article-header"
17
- :class="{ 'lm-article-header--plain': !cover }"
21
+ :class="{ 'lm-article-header--plain': !hasImageCover }"
18
22
  >
19
- <div v-if="cover" class="lm-article-header__cover">
23
+ <ValaxyCover
24
+ v-if="frontmatter.coverComponent"
25
+ class="lm-article-header__component-cover"
26
+ :src="cover"
27
+ :component="frontmatter.coverComponent"
28
+ :component-props="frontmatter.coverProps"
29
+ context="page"
30
+ />
31
+ <div v-else-if="cover" class="lm-article-header__cover">
20
32
  <LmImage
21
33
  :src="cover"
22
34
  alt=""
@@ -45,14 +57,14 @@ const {
45
57
 
46
58
  <div
47
59
  class="lm-article-header__content"
48
- :class="{ 'lm-article-header__content--plain': !cover }"
60
+ :class="{ 'lm-article-header__content--plain': !hasImageCover }"
49
61
  >
50
- <h1 v-if="!cover" class="lm-article-header__title">
62
+ <h1 v-if="!hasImageCover" class="lm-article-header__title">
51
63
  {{ title }}
52
64
  </h1>
53
65
 
54
66
  <LmArticleMeta
55
- v-if="!cover"
67
+ v-if="!hasImageCover"
56
68
  :published-date="publishedDate"
57
69
  :info-items="infoItems"
58
70
  :categories="categories"
@@ -71,6 +83,10 @@ const {
71
83
  @apply md:pt-24 pt-22;
72
84
  }
73
85
 
86
+ .lm-article-header__component-cover {
87
+ @apply mx-auto mb-6 max-w-3xl;
88
+ }
89
+
74
90
  .lm-article-header__cover {
75
91
  @apply relative overflow-hidden;
76
92
  min-height: 22rem;
@@ -15,7 +15,9 @@ const props = withDefaults(defineProps<{
15
15
 
16
16
  /** 将未分类节点的内部名称转换为本地化展示文本。 */
17
17
  function displayName(name: string) {
18
- return name === 'Uncategorized' ? props.uncategorizedLabel : name
18
+ return name === 'Uncategorized'
19
+ ? props.uncategorizedLabel
20
+ : name
19
21
  }
20
22
  </script>
21
23
 
@@ -1,69 +1,25 @@
1
1
  <script setup lang="ts">
2
- import { useI18n } from 'vue-i18n'
3
- import { useRouter } from 'vue-router'
4
- import { useHomePaginationScrollBehavior } from '../../features/home'
5
- import { useLayoutShell } from '../../features/navigation'
2
+ import { computed } from 'vue'
3
+ import { useRoute } from 'vue-router'
4
+ import { useThemeConfig } from '../../shared/config'
6
5
 
7
6
  defineProps<{
8
7
  hideFooter?: boolean
9
8
  }>()
10
9
 
11
- const router = useRouter()
12
- const { t } = useI18n()
13
- const {
14
- closeDrawer,
15
- closeSearch,
16
- headerVisible,
17
- isDrawerOpen,
18
- isSearchOpen,
19
- navItems,
20
- openSearch,
21
- pageSurfaceStyle,
22
- showGlobalNotice,
23
- toggleDrawer,
24
- } = useLayoutShell()
10
+ const themeConfig = useThemeConfig()
11
+ const route = useRoute()
25
12
 
26
- useHomePaginationScrollBehavior(router)
13
+ // 首页的公告由文章流渲染在 Hero 之后;这里只负责其余页面顶部的全局公告。
14
+ const showGlobalNotice = computed(() => {
15
+ const notice = themeConfig.value.notice
16
+ return route.meta.layout !== 'home' && notice.enable && notice.scope === 'global' && Boolean(notice.message?.trim())
17
+ })
27
18
  </script>
28
19
 
29
20
  <template>
30
- <div class="min-h-screen antialiased relative isolate">
31
- <LmBackgroundLayer />
32
-
33
- <button
34
- v-if="isDrawerOpen"
35
- type="button"
36
- class="lm-mobile-drawer-backdrop"
37
- :aria-label="t('button.closeMobileNav')"
38
- @click="closeDrawer"
39
- />
40
-
41
- <div
42
- class="transition-transform duration-250 ease-in-out inset-x-0 top-0 fixed z-[var(--lm-z-navbar)]"
43
- :class="headerVisible ? 'translate-y-0' : '-translate-y-full'"
44
- >
45
- <div class="w-full">
46
- <LmNav
47
- :drawer-open="isDrawerOpen"
48
- :items="navItems"
49
- @toggle-mobile-drawer="toggleDrawer"
50
- @open-search="openSearch"
51
- />
52
- <LmMobileDrawer
53
- :open="isDrawerOpen"
54
- :items="navItems"
55
- @close="closeDrawer"
56
- />
57
- </div>
58
- </div>
59
-
60
- <LmSearchModal
61
- :open="isSearchOpen"
62
- @close="closeSearch"
63
- />
64
-
65
- <div class="lm-page-surface-layer" :style="pageSurfaceStyle" aria-hidden="true" />
66
-
21
+ <!-- 背景、阅读表层、导航、搜索与回顶按钮由主题的 App.vue 常驻渲染,这里只放随页面变化的文档流内容。 -->
22
+ <div class="min-h-screen">
67
23
  <div v-if="showGlobalNotice" class="lm-global-notice">
68
24
  <LmNotice />
69
25
  </div>
@@ -75,44 +31,12 @@ useHomePaginationScrollBehavior(router)
75
31
  <!-- 浮层与正文、页脚同级,避免被正文的层叠上下文限制。 -->
76
32
  <slot name="overlay" />
77
33
 
78
- <LmHelper />
79
-
80
34
  <LmFooter v-if="!hideFooter" />
81
35
  </div>
82
36
  </template>
83
37
 
84
38
  <style lang="scss" scoped>
85
- .lm-mobile-drawer-backdrop {
86
- @apply fixed inset-0 z-[var(--lm-z-drawer-backdrop)] border-0 bg-transparent p-0 md:hidden;
87
- }
88
-
89
39
  .lm-global-notice {
90
40
  @apply relative z-[var(--lm-z-content)] mx-auto w-full max-w-6xl pt-12 px-4 sm:px-6 xl:px-0;
91
41
  }
92
-
93
- .lm-page-surface-layer {
94
- // 外层只定义阅读区域边界;首页从 Hero 底部开始,其余页面覆盖整个壳层。
95
- // top 由内联样式提供(首页为 Hero 高度,其余页面为 0),SSR 阶段即已确定。
96
- position: absolute;
97
- left: 0;
98
- right: 0;
99
- top: 0;
100
- bottom: 0;
101
- z-index: var(--lm-z-page-surface);
102
- pointer-events: none;
103
-
104
- // 模糊只占一个视口,避免长文章产生巨大的滤镜合成层和边缘绘制缝隙。
105
- // sticky 直接跟随文档滚动,无需 JS 测量;短页面限制在外层高度内。
106
- &::before {
107
- content: '';
108
- display: block;
109
- position: sticky;
110
- top: 0;
111
- height: 100vh;
112
- height: 100dvh;
113
- max-height: 100%;
114
- background: color-mix(in srgb, var(--lm-c-bg-glass) 62%, transparent);
115
- backdrop-filter: blur(6px) saturate(1.04);
116
- }
117
- }
118
42
  </style>
@@ -46,10 +46,9 @@ const props = defineProps<{
46
46
  .lm-hero-social-link {
47
47
  @apply inline-flex h-9 w-9 items-center justify-center rounded-full border transition-all duration-250 ease-out;
48
48
  @include lm-surface-panel(
49
- color-mix(in srgb, var(--lm-c-bg-glass) 58%, transparent),
49
+ color-mix(in srgb, var(--lm-c-bg-glass) 78%, transparent),
50
50
  color-mix(in srgb, var(--lm-c-border) 62%, transparent),
51
- 0 8px 16px rgb(15 23 42 / 0.08),
52
- var(--lm-hero-surface-blur)
51
+ 0 8px 16px rgb(15 23 42 / 0.08)
53
52
  );
54
53
  color: var(--lm-hero-social-color);
55
54
  opacity: 0.9;
@@ -37,8 +37,14 @@ const {
37
37
  base-path="/"
38
38
  />
39
39
 
40
+ <!--
41
+ 每加载一页换一个新的触发点元素:观察器只在相交状态变化时回调,
42
+ 新加的一页不够高时触发点一直处于相交状态,沿用旧元素就不会再有回调。
43
+ 新元素被观察时会立即报告当前状态,仍在预加载范围内就接着加载下一页。
44
+ -->
40
45
  <div
41
46
  v-if="isInfiniteScroll && hasMorePosts"
47
+ :key="pagedPosts.length"
42
48
  ref="infiniteScrollTrigger"
43
49
  class="h-1 w-full"
44
50
  aria-hidden="true"
@@ -99,8 +99,7 @@ onMounted(() => {
99
99
  @include lm-surface-panel(
100
100
  color-mix(in srgb, var(--lm-c-bg-glass) 62%, transparent),
101
101
  color-mix(in srgb, var(--lm-c-border) 68%, transparent),
102
- 0 10px 18px rgb(15 23 42 / 0.08),
103
- var(--lm-blur-panel)
102
+ 0 10px 18px rgb(15 23 42 / 0.08)
104
103
  );
105
104
  color: var(--lm-c-text-secondary);
106
105
  }
@@ -83,8 +83,7 @@ const {
83
83
  @include lm-surface-panel(
84
84
  color-mix(in srgb, var(--lm-c-bg-glass) 30%, transparent),
85
85
  color-mix(in srgb, var(--lm-c-border-hover) 34%, transparent),
86
- 0 14px 28px rgb(15 23 42 / 0.08),
87
- 8px
86
+ 0 14px 28px rgb(15 23 42 / 0.08)
88
87
  );
89
88
 
90
89
  @apply block overflow-hidden rounded-6 no-underline snap-start;