Skip to content

Commit ff21a17

Browse files
committed
Updated version of git repositoryMap
1 parent 8a6d0b8 commit ff21a17

19 files changed

Lines changed: 1358 additions & 257 deletions

docs/.vitepress/config.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { vite } from './config/vite'
88
import { getNav, getSidebar } from './menu'
99

1010

11+
1112
export default withPwa(defineConfig({
1213
title: '笔记',
1314
titleTemplate: '开发笔记',
@@ -67,14 +68,10 @@ export default withPwa(defineConfig({
6768
text: '上次更新',
6869
},
6970
darkModeSwitchLabel: '外观',
71+
lightModeSwitchTitle: '浅色',
72+
darkModeSwitchTitle: '深色',
7073
langMenuLabel: '切换语言',
7174
socialLinks: [
72-
{
73-
icon: {
74-
svg: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M512 1024C230.4 1024 0 793.6 0 512S230.4 0 512 0s512 230.4 512 512-230.4 512-512 512z m259.2-569.6H480c-12.8 0-25.6 12.8-25.6 25.6v64c0 12.8 12.8 25.6 25.6 25.6h176c12.8 0 25.6 12.8 25.6 25.6v12.8c0 41.6-35.2 76.8-76.8 76.8h-240c-12.8 0-25.6-12.8-25.6-25.6V416c0-41.6 35.2-76.8 76.8-76.8h355.2c12.8 0 25.6-12.8 25.6-25.6v-64c0-12.8-12.8-25.6-25.6-25.6H416c-105.6 0-188.8 86.4-188.8 188.8V768c0 12.8 12.8 25.6 25.6 25.6h374.4c92.8 0 169.6-76.8 169.6-169.6v-144c0-12.8-12.8-25.6-25.6-25.6z" fill="currentColor"></path></svg>',
75-
},
76-
link: 'https://gitee.com/peiyanlu/vite-press',
77-
},
7875
{ icon: 'github', link: 'https://github.com/peiyanlu/vite-press/' },
7976
],
8077
search: isDev ? local : algolia,

docs/.vitepress/config/vite.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
import { VarletImportResolver } from '@varlet/import-resolver'
2+
import icon from '@varlet/unplugin-icon-builder/vite'
13
import { resolve } from 'path'
4+
import autoImport from 'unplugin-auto-import/vite'
5+
import components from 'unplugin-vue-components/vite'
26
import { fileURLToPath } from 'url'
37
import { UserConfig } from 'vite'
48
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
@@ -15,9 +19,14 @@ export const vite: UserConfig = {
1519
find: '@theme',
1620
replacement: fileURLToPath(new URL('../theme', import.meta.url)),
1721
},
22+
{
23+
find: '@utils',
24+
replacement: fileURLToPath(new URL('../utils', import.meta.url)),
25+
},
1826
],
1927
},
2028
server: {
29+
host: '0.0.0.0',
2130
port: 5274,
2231
},
2332
plugins:
@@ -40,6 +49,16 @@ export const vite: UserConfig = {
4049
}),
4150
isProd && llmstxt(),
4251
createGitCachePlugin(),
52+
53+
components({
54+
resolvers: [ VarletImportResolver() ],
55+
}),
56+
autoImport({
57+
resolvers: [ VarletImportResolver({ autoImport: true }) ],
58+
}),
59+
icon({
60+
dir: resolve(process.cwd(), 'docs/public/icons'),
61+
}),
4362
],
4463
build: {
4564
target: 'esnext',
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
<script setup lang="ts">
2+
import SlotDocAfter from '@theme/components/SlotDocAfter.vue'
3+
import SlotDocFooterBefore from '@theme/components/SlotDocFooterBefore.vue'
4+
import { ImagePreviewService } from '@theme/directives/image-preview'
5+
import { getColor } from '@utils/index'
6+
import { StyleProvider, Themes } from '@varlet/ui'
7+
import { useEventListener } from '@vueuse/core'
8+
import { inBrowser, useData } from 'vitepress'
9+
import DefaultTheme from 'vitepress/theme'
10+
import { onMounted, provide, watchEffect } from 'vue'
11+
12+
13+
const { isDark } = useData()
14+
15+
16+
watchEffect(() => {
17+
StyleProvider({
18+
...(isDark.value ? Themes.dark : null),
19+
'--hsl-primary': '226, 55%, 45%',
20+
})
21+
})
22+
23+
const spawnParticles = (x: number, y: number, count: number = 50) => {
24+
for (let i = 0; i < count; i++) {
25+
const particle = document.createElement('div')
26+
const length = 4 + Math.random() * 4
27+
Object.assign(particle.style, {
28+
position: 'fixed',
29+
left: `${ x - length * .5 }px`,
30+
top: `${ y - length * .5 }px`,
31+
width: `${ length }px`,
32+
height: `${ length }px`,
33+
borderRadius: '50%',
34+
pointerEvents: 'none',
35+
background: getColor(),
36+
zIndex: '99999',
37+
})
38+
document.body.appendChild(particle)
39+
40+
const distance = 80 + Math.random() * 40
41+
const angle = Math.random() * Math.PI * 2
42+
const destX = Math.cos(angle) * distance
43+
const destY = Math.sin(angle) * distance
44+
particle
45+
.animate(
46+
[
47+
{ transform: 'translate(0, 0)', opacity: 1 },
48+
{ transform: `translate(${ destX }px, ${ destY }px)`, opacity: 0 },
49+
],
50+
{
51+
easing: 'ease-out',
52+
duration: 700 + Math.random() * 300,
53+
},
54+
)
55+
.onfinish = () => particle.remove()
56+
}
57+
}
58+
59+
const imagePreviewFn = () => {
60+
if (!inBrowser) return
61+
62+
const scope = document.querySelector('.VPDoc .main')
63+
if (!scope) return
64+
65+
const getUrl = (img: HTMLImageElement) => img.getAttribute('src') || ''
66+
const list = [ ...scope?.querySelectorAll('img') ].map(el => getUrl(el))
67+
68+
document
69+
.querySelectorAll<HTMLImageElement>('p > img')
70+
.forEach((img) => {
71+
img.setAttribute('style', 'cursor: pointer;')
72+
useEventListener(img, 'click', () => {
73+
ImagePreviewService.open({
74+
url: getUrl(img),
75+
previewUrlList: list,
76+
})
77+
})
78+
})
79+
}
80+
81+
const doThemeTransition = async (location: { x: number; y: number }, toggleFn: () => void, isDark: boolean) => {
82+
const style = document.createElement('style')
83+
style.innerHTML = `
84+
::view-transition-old(root),
85+
::view-transition-new(root) {
86+
animation: none;
87+
mix-blend-mode: normal;
88+
}
89+
90+
::view-transition-old(root),
91+
.dark::view-transition-new(root) {
92+
z-index: 1;
93+
}
94+
95+
::view-transition-new(root),
96+
.dark::view-transition-old(root) {
97+
z-index: 9999;
98+
}
99+
`
100+
document.head.appendChild(style)
101+
102+
const enableTransitions = () => 'startViewTransition' in document &&
103+
window.matchMedia('(prefers-reduced-motion: no-preference)').matches
104+
105+
if (!enableTransitions()) {
106+
toggleFn()
107+
return
108+
}
109+
110+
const transition = document.startViewTransition(async () => {
111+
toggleFn()
112+
await Promise.resolve()
113+
})
114+
await transition.ready
115+
116+
const { x, y } = location
117+
const maxRadius = Math.hypot(
118+
Math.max(x, innerWidth - x),
119+
Math.max(y, innerHeight - y),
120+
)
121+
const clipPath = [
122+
`circle(0px at ${ x }px ${ y }px)`,
123+
`circle(${ maxRadius }px at ${ x }px ${ y }px)`,
124+
]
125+
document.documentElement.animate(
126+
{
127+
clipPath: isDark ? clipPath.reverse() : clipPath,
128+
},
129+
{
130+
duration: 300,
131+
easing: 'ease-in',
132+
fill: 'forwards',
133+
pseudoElement: `::view-transition-${ isDark ? 'old' : 'new' }(root)`,
134+
},
135+
)
136+
}
137+
138+
139+
provide('toggle-appearance', async ({ clientX: x, clientY: y }: MouseEvent) => {
140+
await doThemeTransition(
141+
{ x, y },
142+
() => {
143+
isDark.value = !isDark.value
144+
},
145+
!isDark.value,
146+
)
147+
})
148+
149+
useEventListener('click', (e) => {
150+
spawnParticles(e.clientX, e.clientY)
151+
})
152+
153+
onMounted(() => {
154+
imagePreviewFn()
155+
})
156+
</script>
157+
158+
<template>
159+
<DefaultTheme.Layout>
160+
<template #doc-after>
161+
<SlotDocAfter />
162+
</template>
163+
164+
<template #doc-footer-before>
165+
<SlotDocFooterBefore />
166+
</template>
167+
168+
<template #layout-bottom></template>
169+
</DefaultTheme.Layout>
170+
</template>
171+
172+
<style>
173+
.VPSwitchAppearance {
174+
width: 22px !important;
175+
176+
& .check {
177+
top: calc(3px / 2);
178+
left: calc(3px / 2);
179+
transform: none !important;
180+
}
181+
}
182+
</style>

docs/.vitepress/theme/components/GiscusComment.vue

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,12 @@ import { computed, onMounted, ref, watchEffect } from 'vue'
55
66
const { title, isDark, site } = useData()
77
8-
98
const theme = computed(() => `https://peiyanlu.github.io${ site.value.base }giscus/noborder_${ isDark.value ? 'dark' : 'light' }.css`)
10-
const isGitee = ref(false)
119
12-
onMounted(() => {
13-
isGitee.value = inBrowser && location.host.includes('gitee')
14-
})
1510
</script>
1611

1712
<template>
18-
<div v-if="!isGitee" class="giscus-comment">
13+
<div id="giscus">
1914
<component
2015
is="script"
2116
:key="title+isDark"
@@ -39,7 +34,5 @@ onMounted(() => {
3934
</template>
4035

4136
<style lang="scss" scoped>
42-
.giscus-comment {
4337
44-
}
4538
</style>

docs/.vitepress/theme/components/SlotDocFooterBefore.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts" setup>
2+
import { getColor } from '@utils/index'
23
import { useData, withBase } from 'vitepress'
34
45
@@ -7,6 +8,7 @@ const { frontmatter } = useData()
78
const handleRouter = () => {
89
910
}
11+
1012
</script>
1113

1214
<template>
@@ -19,9 +21,12 @@ const handleRouter = () => {
1921
:key="tag"
2022
:href="withBase(`/archive/?tag=${encodeURIComponent(tag)}`)"
2123
>
22-
<doc-tag
23-
:text="tag"
24+
<var-button
25+
size="small"
2426
@click="handleRouter"
27+
:color="getColor()"
28+
v-text="tag"
29+
:elevation="false"
2530
/>
2631
</a>
2732
</div>

docs/.vitepress/theme/components/TextTyped.vue

Lines changed: 0 additions & 16 deletions
This file was deleted.

docs/.vitepress/theme/components/global/DocTag.vue

Lines changed: 0 additions & 25 deletions
This file was deleted.

docs/.vitepress/theme/directives/typed-text/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Directive } from 'vue'
33

44

55
interface TypedHoverOptions extends TypedOptions {
6-
text: string | string[]// 要打字的文本
6+
text: string | string[] // 要打字的文本
77
once?: boolean // 是否只打字一次
88
childSelector?: string | null // 生效的子元素
99
}

0 commit comments

Comments
 (0)