Skip to content

Commit e54348a

Browse files
committed
05-01 又是一次大更啊
1. 切换包管理器为pnpm,更新相应文件和README 2. 完善CDocInfo.vue,完善版权声明,并对文档头部区域做了美化 3. 侧边栏滚动更新,并额外对os做了适配。见: github.com/vuejs/vitepress/pull/5194 4. LocalNav标题新增动画 5. 更新小说《磊水》 6. 样式修改,主要更改了背景遮罩颜色,以提高可读性
1 parent b94a628 commit e54348a

20 files changed

Lines changed: 3379 additions & 4805 deletions

.github/workflows/deploy.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ jobs:
3434
uses: actions/checkout@v5
3535
with:
3636
fetch-depth: 0 # 如果未启用 lastUpdated,则不需要
37-
# - uses: pnpm/action-setup@v4 # 如果使用 pnpm,请取消此区域注释
38-
# with:
39-
# version: 9
37+
- uses: pnpm/action-setup@v4 # 如果使用 pnpm,请取消此区域注释
38+
with:
39+
version: 10
4040
# - uses: oven-sh/setup-bun@v1 # 如果使用 Bun,请取消注释
4141
- name: 初始化 Node.js
4242
uses: actions/setup-node@v6
4343
with:
4444
node-version: 24
45-
cache: npm #pnpm / yarn
45+
cache: pnpm #npm / yarn
4646
- name: 配置 Pages
4747
uses: actions/configure-pages@v4
4848
- name: 安装依赖
49-
run: npm ci
49+
run: pnpm install --frozen-lockfile
5050
- name: 构建 VitePress 页面
51-
run: npm run docs:build #pnpm docs:build / yarn docs:build / bun run docs:build
51+
run: pnpm docs:build #npm docs:build / yarn docs:build / bun run docs:build
5252
- name: 上传构建产物
5353
uses: actions/upload-pages-artifact@v3
5454
with:

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@ LKN是Lukoning的缩写哦喵🌟!
99

1010
首先得有Node.js喵,建议安装版本24(LTS)或最新版喵,最低版本20喵
1111

12-
克隆本仓库,然后在仓库根目录润这行神秘代码喵
12+
猫猫喜欢pnpm姐姐喵~pnpm姐姐不在的话,请在corepack处召唤pnpm姐姐喵
1313

14+
```bash
15+
corepack enable
16+
corepack prepare pnpm@latest --activate
1417
```
15-
npm ci
18+
19+
克隆本仓库,然后在仓库根目录润这行神秘代码喵:
20+
21+
```bash
22+
pnpm install --frozen-lockfile
1623
```
1724

1825
这样构建猫猫的依赖环境就完成了喵\~
@@ -21,22 +28,22 @@ npm ci
2128

2229
回归正话喵,可以开始构建猫猫了喵:
2330

24-
```
25-
npm run docs:build
31+
```bash
32+
pnpm docs:build
2633
```
2734

2835
不出喵意料的话,猫猫十几秒后就构建成了喵,可以在`docs/.vitepress/dist`找到猫猫哦喵
2936

3037
构建成了喵后,想在浏览器浏览猫猫呜喵?可以润以下代码,然后访问控制台输出的URL喵:
3138

32-
```
33-
npm run docs:preview
39+
```bash
40+
pnpm docs:preview
3441
```
3542

3643
如不想构建,或者想要喵实时预览修改,也可以润以下代码喵:
3744

38-
```
39-
npm run docs:dev
45+
```bash
46+
pnpm docs:dev
4047
```
4148

4249
此法可在局域网中使用个中形状的计算机访问喵\~でも此时不能搜索喵。

docs/.vitepress/components/CDocInfo.vue

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
import { useNavigatorLanguage } from '@vueuse/core'
55
import { computed, onMounted, shallowRef, useTemplateRef, watchEffect } from 'vue'
66
import { useData } from 'vitepress'
7+
import VPBadge from 'vitepress/dist/client/theme-default/components/VPBadge.vue'
78
89
defineOptions({ name: "CDocInfo" })
910
10-
const { theme, page, lang: pageLang } = useData()
11+
const { theme, page, lang: pageLang, frontmatter } = useData()
1112
const { language: browserLang } = useNavigatorLanguage()
1213
1314
const timeRef = useTemplateRef('timeRef')
@@ -28,11 +29,11 @@ const updatedDatetime = shallowRef('')
2829
// potential differences in timezones of the server and clients
2930
onMounted(() => {
3031
watchEffect(() => {
31-
const lang = theme.value.lastUpdated?.formatOptions?.forceLocale
32+
const lang = theme.value.CDocInfo?.lastUpdated?.formatOptions?.forceLocale
3233
? pageLang.value
3334
: browserLang.value
3435
35-
const option = theme.value.lastUpdated?.formatOptions ?? {
36+
const option = theme.value.CDocInfo?.lastUpdated?.formatOptions ?? {
3637
dateStyle: 'medium',
3738
timeStyle: 'medium'
3839
}
@@ -51,26 +52,34 @@ onMounted(() => {
5152

5253
<template>
5354
<div class="CDocInfo">
54-
<p class="doc-info created-time">
55-
{{ theme.lastUpdated?.createdText || 'Created time' }}:
56-
<time ref="createdTimeRef" :datetime="createdIsoDatetime">{{ createdDatetime }}</time>
57-
</p>
58-
<p class="doc-info last-updated">
59-
{{ theme.lastUpdated?.text || theme.lastUpdatedText || 'Last updated' }}:
60-
<time ref="timeRef" :datetime="updatedIsoDatetime">{{ updatedDatetime }}</time>
61-
</p>
55+
<VPBadge :type="'info'" class="doc-info author" v-if="frontmatter.author !== false">
56+
{{ theme.CDocInfo?.authorText || 'Author' }}:
57+
{{ frontmatter.author || theme.CDocInfo?.defaultAuthor || 'Unknown' }}
58+
</VPBadge>
59+
<VPBadge :type="'info'" class="doc-info created-time" v-if="frontmatter.createdDate !== false">
60+
{{ theme.CDocInfo?.lastUpdated?.createdText || 'Created time' }}:
61+
<time ref="createdTimeRef" :datetime="createdIsoDatetime">{{ createdDatetime }}</time>
62+
</VPBadge>
63+
<VPBadge :type="'info'" class="doc-info last-updated" v-if="frontmatter.lastUpdated !== false">
64+
{{ theme.CDocInfo?.lastUpdated?.text || theme.lastUpdatedText || 'Last updated' }}:
65+
<time ref="timeRef" :datetime="updatedIsoDatetime">{{ updatedDatetime }}</time>
66+
</VPBadge>
67+
<VPBadge :type="'info'" class="doc-info license" v-if="frontmatter.license !== false && (frontmatter.license || theme.CDocInfo?.defaultLicense)">
68+
{{ theme.CDocInfo?.licenseText || 'License' }}:
69+
{{ frontmatter.license || theme.CDocInfo?.defaultLicense }}
70+
</VPBadge>
71+
<VPBadge :type="'info'" class="doc-info copyright" v-if="frontmatter.copyright !== false && (frontmatter.copyright || theme.CDocInfo?.defaultCopyright)">
72+
{{ theme.CDocInfo?.copyrightText || 'Copyright Notice' }}:
73+
{{ frontmatter.copyright || theme.CDocInfo?.defaultCopyright }}
74+
</VPBadge>
6275
</div>
63-
6476
</template>
6577

6678
<style scoped>
6779
.CDocInfo {
68-
margin-bottom: 16px;
80+
margin-bottom: 4px;
6981
}
7082
.doc-info {
71-
line-height: 24px;
72-
font-size: 14px;
73-
font-weight: 500;
74-
color: var(--vp-c-text-2);
83+
margin: 2px;
7584
}
7685
</style>

docs/.vitepress/components/LKNLocalNav.vue

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts" setup>
22
import { useWindowScroll } from '@vueuse/core'
3-
import { computed, onMounted, ref } from 'vue'
3+
import { computed, onMounted, onUnmounted, ref } from 'vue'
44
import { useData } from 'vitepress'
55
import { useLayout } from 'vitepress/dist/client/theme-default/composables/layout'
66
import VPLocalNavOutlineDropdown from './LKNLocalNavOutlineDropdown.vue'
@@ -18,15 +18,26 @@ const { isHome, hasSidebar, headers, hasLocalNav } = useLayout()
1818
const { y } = useWindowScroll()
1919
2020
const navHeight = ref(0)
21+
const showTitle = ref(false)
22+
23+
// 滚动事件处理
24+
function onScroll() {
25+
showTitle.value = window.scrollY > 350; //滚动阈值 px
26+
}
27+
2128
2229
onMounted(() => {
2330
navHeight.value = parseInt(
2431
getComputedStyle(document.documentElement).getPropertyValue(
2532
'--vp-nav-height'
2633
)
27-
)
34+
);
35+
window.addEventListener('scroll', onScroll);
36+
onScroll();
2837
})
2938
39+
onUnmounted(() => window.removeEventListener('scroll', onScroll))
40+
3041
const classes = computed(() => {
3142
return {
3243
VPLocalNav: true,
@@ -55,9 +66,11 @@ const classes = computed(() => {
5566
{{ theme.sidebarMenuLabel || 'Menu' }}
5667
</span>
5768
</button>
58-
<span class="title">
59-
{{ frontmatter.title || '' }}
60-
</span>
69+
<Transition name="title">
70+
<span v-if="showTitle" class="title">
71+
{{ frontmatter.title || '' }}
72+
</span>
73+
</Transition>
6174

6275
<VPLocalNavOutlineDropdown :headers :navHeight />
6376
</div>
@@ -150,17 +163,31 @@ const classes = computed(() => {
150163
top: 50%;
151164
left: 50%;
152165
transform: translate(-50%, -50%); /*还有这种解法?*/
153-
padding-top: 4px;
166+
padding-top: 2px;
154167
text-align: center;
155168
letter-spacing: -0.02em;
156-
font-size: 16px;
169+
font-size: 14px;
157170
font-weight: 500;
158-
line-height: 20px;
171+
line-height: 16px;
159172
}
160173
161174
@media (min-width: 960px) {
162175
.title {
163176
display: none;
164177
}
165178
}
179+
180+
.title-enter-active,
181+
.title-leave-active {
182+
transition: opacity .2s, transform .3s;
183+
}
184+
185+
.title-enter-from {
186+
opacity: 0;
187+
transform: translate(-50%, calc(-50% + 10px));
188+
}
189+
.title-leave-to {
190+
opacity: 0;
191+
transform: translate(-50%, calc(-50% - 10px));
192+
}
166193
</style>

0 commit comments

Comments
 (0)