valaxy-theme-lolimeow 1.2.1 → 1.3.1
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.
- package/App.vue +105 -0
- package/client/index.ts +12 -83
- package/components/LmBackgroundLayer.vue +35 -51
- package/components/LmComment.vue +11 -21
- package/components/LmHelper.vue +12 -4
- package/components/LmNotice.vue +2 -3
- package/components/archive/LmArchiveRail.vue +3 -1
- package/components/category/LmCategoryTree.vue +3 -1
- package/components/core/layout.vue +12 -88
- package/components/home/LmHeroSocialLinks.vue +2 -3
- package/components/home/LmHomeContent.vue +6 -0
- package/components/home/LmPagination.vue +1 -2
- package/components/home/LmPinned.vue +1 -2
- package/components/home/LmPostList.vue +3 -1
- package/components/navbar/LmMobileDrawer.vue +6 -2
- package/components/plugins/LmWaline.vue +6 -2
- package/components/search/LmFuseSearchProvider.vue +6 -4
- package/features/archive/archive.ts +9 -4
- package/features/archive/use-archive-groups.ts +4 -3
- package/features/archive/use-archive-timeline-state.ts +6 -2
- package/features/article/use-article-header-meta.ts +16 -4
- package/features/article/use-article-toc-state.ts +21 -23
- package/features/article/use-toc-scroll.ts +9 -1
- package/features/background/background-image.ts +3 -1
- package/features/background/index.ts +1 -0
- package/features/background/resolve-background.ts +3 -3
- package/features/background/runtime/use-background-preload.ts +9 -3
- package/features/background/types.ts +1 -1
- package/features/background/use-app-background-layers.ts +62 -0
- package/features/background/use-resolved-background.ts +4 -3
- package/features/category/category.ts +29 -16
- package/features/category/use-category-groups.ts +5 -3
- package/features/hero/motto/hitokoto.ts +3 -1
- package/features/hero/motto/use-motto-playback.ts +9 -1
- package/features/hero/motto/use-motto-source.ts +17 -4
- package/features/hero/use-hero-stage.ts +6 -2
- package/features/home/home-grid.ts +17 -6
- package/features/home/home-history.ts +63 -0
- package/features/home/index.ts +1 -1
- package/features/home/pagination/pagination-normalization.ts +3 -1
- package/features/home/pagination/pagination-scope.ts +3 -1
- package/features/home/pagination/use-pagination-items.ts +6 -2
- package/features/home/use-home-post-feed.ts +19 -101
- package/features/navigation/navigation-path.ts +3 -1
- package/features/navigation/use-layout-shell.ts +8 -9
- package/features/navigation/use-nav-item-state.ts +1 -1
- package/features/navigation/use-navbar-visibility.ts +2 -2
- package/features/post/post-content.ts +3 -1
- package/features/post/post-cover.ts +13 -4
- package/features/post/use-post-card-media-state.ts +5 -2
- package/features/post/use-post-card-view-model.ts +8 -2
- package/features/search/highlight.ts +25 -8
- package/features/tag/tag-cloud.ts +9 -2
- package/features/tag/tag.ts +31 -16
- package/features/tag/use-packed-tag-cloud.ts +64 -61
- package/features/tag/use-tag-groups.ts +5 -3
- package/node/colors.ts +54 -15
- package/node/config.ts +0 -1
- package/node/plugins.ts +0 -53
- package/package.json +14 -11
- package/setup/main.ts +6 -0
- package/shared/browser/index.ts +0 -1
- package/shared/browser/modal.ts +15 -5
- package/shared/browser/motion.ts +8 -58
- package/shared/browser/runtime.ts +3 -58
- package/shared/site/index.ts +1 -0
- package/shared/site/use-site-posts.ts +29 -0
- package/styles/main.scss +7 -0
- package/styles/markdown/_footnotes.scss +6 -0
- package/styles/mixins/glass.scss +4 -2
- package/styles/mixins/surface.scss +5 -1
- package/styles/vars.scss +4 -4
- package/types/background.d.ts +0 -5
- package/valaxy.config.ts +4 -10
- package/features/home/history/home-history-state.ts +0 -280
- package/features/home/history/home-scroll-task.ts +0 -192
- package/features/home/history/use-home-pagination-scroll.ts +0 -185
- 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 {
|
|
38
|
-
export { useLinkGroups
|
|
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
|
-
|
|
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 {
|
|
3
|
-
import { createBackgroundImageStyle, useBackgroundPreload, useBackgroundRuntime, useResolvedBackground } from '../features/background'
|
|
2
|
+
import type { BackgroundLayers } from '../features/background'
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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="
|
|
51
|
-
class="lm-bg-layer"
|
|
52
|
-
:
|
|
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="
|
|
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
|
|
57
|
+
@apply transition-opacity duration-500 ease-out;
|
|
74
58
|
will-change: opacity;
|
|
75
59
|
}
|
|
76
60
|
|
package/components/LmComment.vue
CHANGED
|
@@ -1,48 +1,38 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { useIntersectionObserver } from '@vueuse/core'
|
|
2
|
+
import { useIntersectionObserver, useMounted } from '@vueuse/core'
|
|
3
3
|
import { useAddonConfig, useFrontmatter, useSiteConfig } from 'valaxy'
|
|
4
4
|
import { computed, defineAsyncComponent, ref, useTemplateRef, watch } from 'vue'
|
|
5
5
|
import { useI18n } from 'vue-i18n'
|
|
6
6
|
import { useRoute } from 'vue-router'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const WalineComment = defineAsyncComponent(() => import('../components/plugins/LmWaline.vue'))
|
|
8
|
+
const WalineComment = defineAsyncComponent(() => import('./plugins/LmWaline.vue'))
|
|
11
9
|
|
|
12
10
|
const { t } = useI18n()
|
|
13
11
|
const siteConfig = useSiteConfig()
|
|
14
12
|
const frontmatter = useFrontmatter()
|
|
15
13
|
const waline = useAddonConfig('valaxy-addon-waline')
|
|
16
14
|
const route = useRoute()
|
|
15
|
+
const mounted = useMounted()
|
|
17
16
|
const section = useTemplateRef<HTMLElement>('section')
|
|
18
17
|
const activated = ref(false)
|
|
18
|
+
const lazy = computed(() => frontmatter.value.lazyComment ?? siteConfig.value.comment.lazy)
|
|
19
|
+
const observationTarget = computed(() => lazy.value && !activated.value
|
|
20
|
+
? section.value
|
|
21
|
+
: null)
|
|
22
|
+
const active = computed(() => mounted.value && (!lazy.value || activated.value))
|
|
19
23
|
|
|
20
24
|
watch(() => route.path, () => {
|
|
21
25
|
activated.value = false
|
|
22
26
|
})
|
|
23
|
-
useIntersectionObserver(
|
|
27
|
+
useIntersectionObserver(observationTarget, ([entry]) => {
|
|
24
28
|
if (entry?.isIntersecting)
|
|
25
29
|
activated.value = true
|
|
26
30
|
}, { rootMargin: '400px 0px' })
|
|
27
31
|
|
|
28
|
-
const provider = computed<CommentProvider | ''>(() => {
|
|
29
|
-
if (waline.value)
|
|
30
|
-
return 'waline'
|
|
31
|
-
|
|
32
|
-
return ''
|
|
33
|
-
})
|
|
34
|
-
|
|
35
32
|
const enabled = computed(() => {
|
|
36
33
|
return siteConfig.value.comment?.enable !== false
|
|
37
34
|
&& frontmatter.value.comment !== false
|
|
38
|
-
&& !!
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
const providerComponent = computed(() => {
|
|
42
|
-
if (provider.value === 'waline')
|
|
43
|
-
return WalineComment
|
|
44
|
-
|
|
45
|
-
return null
|
|
35
|
+
&& !!waline.value
|
|
46
36
|
})
|
|
47
37
|
</script>
|
|
48
38
|
|
|
@@ -56,7 +46,7 @@ const providerComponent = computed(() => {
|
|
|
56
46
|
>
|
|
57
47
|
<div class="lm-comment__content">
|
|
58
48
|
<div class="lm-comment__body">
|
|
59
|
-
<
|
|
49
|
+
<WalineComment :active="active" />
|
|
60
50
|
</div>
|
|
61
51
|
</div>
|
|
62
52
|
</section>
|
package/components/LmHelper.vue
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { useResizeObserver,
|
|
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
|
|
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
|
|
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({
|
|
41
|
+
getWindow()?.scrollTo({
|
|
42
|
+
top: 0,
|
|
43
|
+
behavior: prefersReducedMotion()
|
|
44
|
+
? 'instant'
|
|
45
|
+
: 'smooth',
|
|
46
|
+
})
|
|
39
47
|
}
|
|
40
48
|
</script>
|
|
41
49
|
|
package/components/LmNotice.vue
CHANGED
|
@@ -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
|
-
|
|
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'
|
|
20
|
+
return year === 'Unknown'
|
|
21
|
+
? unknownYearLabel
|
|
22
|
+
: year
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
/** 获取当前时间线实例内稳定且唯一的年份面板 ID。 */
|
|
@@ -15,7 +15,9 @@ const props = withDefaults(defineProps<{
|
|
|
15
15
|
|
|
16
16
|
/** 将未分类节点的内部名称转换为本地化展示文本。 */
|
|
17
17
|
function displayName(name: string) {
|
|
18
|
-
return name === 'Uncategorized'
|
|
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 {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
|
12
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
31
|
-
|
|
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)
|
|
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;
|
|
@@ -60,7 +60,9 @@ const actualColumns = computed(() => {
|
|
|
60
60
|
})
|
|
61
61
|
|
|
62
62
|
const cardLayout = computed(() => {
|
|
63
|
-
return actualColumns.value === 1
|
|
63
|
+
return actualColumns.value === 1
|
|
64
|
+
? 'alternating'
|
|
65
|
+
: 'text-first'
|
|
64
66
|
})
|
|
65
67
|
|
|
66
68
|
const gridStyle = computed(() => {
|