diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts index 2e003178..b60b350d 100644 --- a/docs/.vuepress/config.ts +++ b/docs/.vuepress/config.ts @@ -1,4 +1,5 @@ -import * as path from 'path' +import * as path from 'node:path' +import process from 'node:process' import { viteBundler } from '@vuepress/bundler-vite' import { webpackBundler } from '@vuepress/bundler-webpack' import { defineUserConfig } from '@vuepress/cli' diff --git a/docs/2.preview/主题效果预览.md b/docs/2.preview/主题效果预览.md index ff6d8a9a..553b9d5c 100644 --- a/docs/2.preview/主题效果预览.md +++ b/docs/2.preview/主题效果预览.md @@ -167,15 +167,25 @@ function foo() { ``` ::: note 注释 -注释内容 +注释内容 [link](https://github.com/pengzhanbo) `inline code` +```js +const a = 1 +const b = 2 +const c = a + b +``` ::: ::: info 信息 -信息内容 +信息内容 [link](https://github.com/pengzhanbo) `inline code` +```js +const a = 1 +const b = 2 +const c = a + b +``` ::: ::: tip 提示 -提示内容 +提示内容 [link](https://github.com/pengzhanbo) `inline code` ```js const a = 1 const b = 2 @@ -184,7 +194,7 @@ const c = a + b ::: ::: warning 警告 -警告内容 +警告内容 [link](https://github.com/pengzhanbo) `inline code` ```js const a = 1 const b = 2 @@ -193,7 +203,7 @@ const c = a + b ::: ::: caution 错误 -错误内容 +错误内容 [link](https://github.com/pengzhanbo) `inline code` ```js const a = 1 const b = 2 @@ -202,7 +212,7 @@ const c = a + b ::: ::: important 重要 -重要内容 +重要内容 [link](https://github.com/pengzhanbo) `inline code` ```js const a = 1 const b = 2 @@ -210,14 +220,6 @@ const c = a + b ``` ::: -::: info -代码 -```ts -const a = 1 -const b = 2 -``` -::: - **代码演示** diff --git a/plugins/plugin-blog-data/src/client/composables/useBlogPostData.ts b/plugins/plugin-blog-data/src/client/composables/useBlogPostData.ts index b302671f..f146b15a 100644 --- a/plugins/plugin-blog-data/src/client/composables/useBlogPostData.ts +++ b/plugins/plugin-blog-data/src/client/composables/useBlogPostData.ts @@ -15,7 +15,7 @@ export function useBlogPostData< return blogPostData as BlogDataRef } -if (import.meta.webpackHot || import.meta.hot) { +if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) { __VUE_HMR_RUNTIME__.updateBlogData = (data: BlogPostData) => { blogPostData.value = data } diff --git a/plugins/plugin-blog-data/src/node/plugin.ts b/plugins/plugin-blog-data/src/node/plugin.ts index db19a4b6..ab811115 100644 --- a/plugins/plugin-blog-data/src/node/plugin.ts +++ b/plugins/plugin-blog-data/src/node/plugin.ts @@ -34,18 +34,11 @@ export function blogDataPlugin({ ignoreInitial: true, }) - watcher.on( - 'add', - async () => await preparedBlogData(app, pageFilter, pluginOptions), - ) - watcher.on( - 'change', - async () => await preparedBlogData(app, pageFilter, pluginOptions), - ) - watcher.on( - 'unlink', - async () => await preparedBlogData(app, pageFilter, pluginOptions), - ) + const handler = () => preparedBlogData(app, pageFilter, pluginOptions) + + watcher.on('add', handler) + watcher.on('change', handler) + watcher.on('unlink', handler) watchers.push(watcher) }, diff --git a/plugins/plugin-notes-data/src/client/composables/notesDate.ts b/plugins/plugin-notes-data/src/client/composables/notesDate.ts index 372df0fd..bf357409 100644 --- a/plugins/plugin-notes-data/src/client/composables/notesDate.ts +++ b/plugins/plugin-notes-data/src/client/composables/notesDate.ts @@ -15,7 +15,7 @@ export function useNotesData< return notesData as NotesDataRef } -if (import.meta.webpackHot || import.meta.hot) { +if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) { __VUE_HMR_RUNTIME__.updateNotesData = (data: NotesData) => { notesData.value = data } diff --git a/plugins/plugin-page-collection/README.md b/plugins/plugin-page-collection/README.md index 98541a4a..0cc31342 100644 --- a/plugins/plugin-page-collection/README.md +++ b/plugins/plugin-page-collection/README.md @@ -38,7 +38,7 @@ 效果: ``` html - 阅读数:99 +阅读数:99 ``` ## 结构 diff --git a/theme/src/client/components/BackToTop.vue b/theme/src/client/components/BackToTop.vue index e1a71c34..7b2e6d77 100644 --- a/theme/src/client/components/BackToTop.vue +++ b/theme/src/client/components/BackToTop.vue @@ -20,7 +20,7 @@ const isScrolling = ref(false) const progress = computed( () => (y.value / (bodyHeight.value - windowHeight.value)) * 100, ) -const percent = computed(() => `${Math.round(progress.value)}%`) +const percent = computed(() => `${Math.round(progress.value) || 0}%`) const stroke = computed(() => `calc(${Math.PI * progress.value}% - ${4 * Math.PI}px) calc(${Math.PI * 100}% - ${4 * Math.PI}px)`, @@ -86,7 +86,9 @@ function handleClick() { box-shadow: var(--vp-shadow-2); background-color: var(--vp-c-bg); inset-inline-end: 1rem; - transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease; + transition: + background-color 0.25s ease, + box-shadow 0.25s ease; } .back-to-top-button .percent, diff --git a/theme/src/client/components/BlogExtract.vue b/theme/src/client/components/BlogExtract.vue index 115ea983..364e0900 100644 --- a/theme/src/client/components/BlogExtract.vue +++ b/theme/src/client/components/BlogExtract.vue @@ -146,13 +146,17 @@ const showBlogExtract = computed(() => { background-color: var(--vp-c-bg); border-top-left-radius: 12px; border-top-right-radius: 12px; - box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.1), 0 -1px 4px rgba(0, 0, 0, 0.1); + box-shadow: + 0 -3px 12px rgba(0, 0, 0, 0.1), + 0 -1px 4px rgba(0, 0, 0, 0.1); transform: translateY(100%); transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1); } .dark .blog-modal-container { - box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.3), 0 -1px 4px rgba(0, 0, 0, 0.27); + box-shadow: + 0 -3px 12px rgba(0, 0, 0, 0.3), + 0 -1px 4px rgba(0, 0, 0, 0.27); } .blog-modal-container.open { diff --git a/theme/src/client/components/Flyout/MenuLink.vue b/theme/src/client/components/Flyout/MenuLink.vue index 2edfbd0b..a50f24ee 100644 --- a/theme/src/client/components/Flyout/MenuLink.vue +++ b/theme/src/client/components/Flyout/MenuLink.vue @@ -44,7 +44,9 @@ const page = usePageData() font-weight: 500; color: var(--vp-c-text-1); white-space: nowrap; - transition: background-color 0.25s, color 0.25s; + transition: + background-color 0.25s, + color 0.25s; } .link:hover { diff --git a/theme/src/client/components/Flyout/index.vue b/theme/src/client/components/Flyout/index.vue index bb50e609..af98edc1 100644 --- a/theme/src/client/components/Flyout/index.vue +++ b/theme/src/client/components/Flyout/index.vue @@ -66,11 +66,11 @@ export default { diff --git a/theme/src/client/components/LocalNav.vue b/theme/src/client/components/LocalNav.vue index 024eced5..29a4a7ca 100644 --- a/theme/src/client/components/LocalNav.vue +++ b/theme/src/client/components/LocalNav.vue @@ -82,7 +82,9 @@ const showLocalNav = computed(() => { padding-top: var(--vp-layout-top-height, 0px); width: 100%; background-color: var(--vp-local-nav-bg-color); - transition: border-color 0.5s, background-color 0.5s; + transition: + border-color 0.5s, + background-color 0.5s; } .local-nav.fixed { diff --git a/theme/src/client/components/LocalNavOutlineDropdown.vue b/theme/src/client/components/LocalNavOutlineDropdown.vue index 7e9841e8..d37c79c5 100644 --- a/theme/src/client/components/LocalNavOutlineDropdown.vue +++ b/theme/src/client/components/LocalNavOutlineDropdown.vue @@ -110,7 +110,7 @@ function scrollToTop() { padding: 2px 0; } -.open>.icon { +.open > .icon { transform: rotate(90deg); } @@ -148,11 +148,11 @@ function scrollToTop() { } .flyout-enter-active { - transition: all .2s ease-out; + transition: all 0.2s ease-out; } .flyout-leave-active { - transition: all .15s ease-in; + transition: all 0.15s ease-in; } .flyout-enter-from, diff --git a/theme/src/client/components/Nav/NavBarHamburger.vue b/theme/src/client/components/Nav/NavBarHamburger.vue index 1073b423..45f6809b 100644 --- a/theme/src/client/components/Nav/NavBarHamburger.vue +++ b/theme/src/client/components/Nav/NavBarHamburger.vue @@ -83,7 +83,10 @@ defineEmits<(e: 'click') => void>() .navbar-hamburger.active:hover .middle, .navbar-hamburger.active:hover .bottom { background-color: var(--vp-c-text-2); - transition: top 0.25s, background-color 0.25s, transform 0.25s; + transition: + top 0.25s, + background-color 0.25s, + transform 0.25s; } .top, @@ -93,7 +96,10 @@ defineEmits<(e: 'click') => void>() width: 16px; height: 2px; background-color: var(--vp-c-text-1); - transition: top 0.25s, background-color 0.5s, transform 0.25s; + transition: + top 0.25s, + background-color 0.5s, + transform 0.25s; } .top { diff --git a/theme/src/client/components/Nav/NavBarSearch.vue b/theme/src/client/components/Nav/NavBarSearch.vue index 6034c418..aeec97b6 100644 --- a/theme/src/client/components/Nav/NavBarSearch.vue +++ b/theme/src/client/components/Nav/NavBarSearch.vue @@ -23,6 +23,12 @@ } } +@media print { + .navbar-search { + display: none; + } +} + /* plugin-docsearch */ .DocSearch { --docsearch-primary-color: var(--vp-c-brand-1); @@ -73,8 +79,8 @@ } .navbar-search #docsearch-container { - min-width: 32px; - } + min-width: 32px; +} @media (min-width: 768px) { .navbar-search .DocSearch-Button { @@ -171,7 +177,9 @@ font-family: var(--vp-font-family-base); font-size: 12px; font-weight: 500; - transition: color 0.5s, border-color 0.5s; + transition: + color 0.5s, + border-color 0.5s; } .DocSearch-Button .DocSearch-Button-Key + .DocSearch-Button-Key { @@ -217,7 +225,7 @@ /* plugin-search */ .navbar-search .search-box input { - padding: 0 0.3rem 0 1.575rem; + padding: 0 0.4rem 0 1.555rem; background-position: 0.5rem 0.4rem; } /* plugin-search */ diff --git a/theme/src/client/components/Nav/NavScreenMenuGroup.vue b/theme/src/client/components/Nav/NavScreenMenuGroup.vue index 9be6f87a..f40608e3 100644 --- a/theme/src/client/components/Nav/NavScreenMenuGroup.vue +++ b/theme/src/client/components/Nav/NavScreenMenuGroup.vue @@ -114,7 +114,9 @@ function toggle() { width: 14px; height: 14px; fill: var(--vp-c-text-2); - transition: fill 0.5s, transform 0.25s; + transition: + fill 0.5s, + transform 0.25s; } .group:first-child { diff --git a/theme/src/client/components/Nav/NavScreenMenuLink.vue b/theme/src/client/components/Nav/NavScreenMenuLink.vue index 8c0c85bd..e7e6522c 100644 --- a/theme/src/client/components/Nav/NavScreenMenuLink.vue +++ b/theme/src/client/components/Nav/NavScreenMenuLink.vue @@ -27,7 +27,9 @@ const closeScreen = inject('close-screen') as () => void font-size: 14px; font-weight: 500; color: var(--vp-c-text-1); - transition: border-color 0.25s, color 0.25s; + transition: + border-color 0.25s, + color 0.25s; } .nav-screen-menu-link:hover { diff --git a/theme/src/client/components/PageAside.vue b/theme/src/client/components/PageAside.vue index 5d1d4a50..9dcce554 100644 --- a/theme/src/client/components/PageAside.vue +++ b/theme/src/client/components/PageAside.vue @@ -96,7 +96,9 @@ function handlePrint() { width: 2px; height: 18px; background-color: var(--vp-c-brand-1); - transition: top 0.25s cubic-bezier(0, 1, 0.5, 1), background-color 0.5s, + transition: + top 0.25s cubic-bezier(0, 1, 0.5, 1), + background-color 0.5s, opacity 0.25s; } diff --git a/theme/src/client/components/PageMeta.vue b/theme/src/client/components/PageMeta.vue index 6ea516cb..ff9f9b7d 100644 --- a/theme/src/client/components/PageMeta.vue +++ b/theme/src/client/components/PageMeta.vue @@ -140,7 +140,7 @@ const hasMeta = computed(() => readingTime.value.times || tags.value.length || c } .page-meta-wrapper .reading-time span { - margin-right: 0.5rem; + margin-right: 8px; } .page-meta-wrapper .reading-time span:last-of-type { diff --git a/theme/src/client/components/Sidebar.vue b/theme/src/client/components/Sidebar.vue index 7265f8c1..91789ccc 100644 --- a/theme/src/client/components/Sidebar.vue +++ b/theme/src/client/components/Sidebar.vue @@ -71,14 +71,18 @@ watch( overflow-x: hidden; overflow-y: auto; transform: translateX(-100%); - transition: opacity 0.5s, transform 0.5s cubic-bezier(0.19, 1, 0.22, 1); + transition: + opacity 0.5s, + transform 0.5s cubic-bezier(0.19, 1, 0.22, 1); } .sidebar-wrapper.open { opacity: 1; visibility: visible; transform: translateX(0); - transition: opacity 0.25s, transform 0.5s cubic-bezier(0.19, 1, 0.22, 1); + transition: + opacity 0.25s, + transform 0.5s cubic-bezier(0.19, 1, 0.22, 1); } .dark .sidebar-wrapper { diff --git a/theme/src/client/components/Switch.vue b/theme/src/client/components/Switch.vue index 690d0424..6d997e03 100644 --- a/theme/src/client/components/Switch.vue +++ b/theme/src/client/components/Switch.vue @@ -18,7 +18,9 @@ flex-shrink: 0; border: 1px solid var(--vp-input-border-color); background-color: var(--vp-input-switch-bg-color); - transition: border-color 0.25s ease, background-color 0.25s ease; + transition: + border-color 0.25s ease, + background-color 0.25s ease; } .switch-wrapper:hover { diff --git a/theme/src/client/components/VButton.vue b/theme/src/client/components/VButton.vue index c674fa0a..3b902243 100644 --- a/theme/src/client/components/VButton.vue +++ b/theme/src/client/components/VButton.vue @@ -56,11 +56,17 @@ function linkTo(e: Event) { text-align: center; font-weight: 600; white-space: nowrap; - transition: color 0.25s, border-color 0.25s, background-color 0.25s; + transition: + color 0.25s, + border-color 0.25s, + background-color 0.25s; } .VPButton:active { - transition: color 0.1s, border-color 0.1s, background-color 0.1s; + transition: + color 0.1s, + border-color 0.1s, + background-color 0.1s; } .VPButton.medium { diff --git a/theme/src/client/components/VFooter.vue b/theme/src/client/components/VFooter.vue index 4c6009ff..2b45dec2 100644 --- a/theme/src/client/components/VFooter.vue +++ b/theme/src/client/components/VFooter.vue @@ -44,7 +44,9 @@ const { hasSidebar } = useSidebar() .plume-footer :deep(a) { text-decoration-line: underline; text-underline-offset: 2px; - transition: color, text-underline-offset 0.25s; + transition: + color, + text-underline-offset 0.25s; } .plume-footer :deep(a:hover) { diff --git a/theme/src/client/composables/locale.ts b/theme/src/client/composables/locale.ts index b59730db..250e51ad 100644 --- a/theme/src/client/composables/locale.ts +++ b/theme/src/client/composables/locale.ts @@ -1,23 +1,11 @@ -import { usePageLang, useSiteData } from '@vuepress/client' +import { useRouteLocale } from '@vuepress/client' import { computed } from 'vue' import { normalizeLink } from '../utils' export function useLocaleLink(link: string) { - const site = useSiteData() - const locale = usePageLang() - - const links = computed(() => { - const locales = site.value.locales - const links: Record = {} - Object.keys(locales).forEach((key) => { - const locale = locales[key] - locale.lang && (links[locale.lang] = key) - }) - return links - }) + const prefix = useRouteLocale() return computed(() => { - const prefix = links.value[locale.value] || '/' - return normalizeLink(prefix + link) + return normalizeLink(prefix.value + link) }) } diff --git a/theme/src/client/composables/readingTime.ts b/theme/src/client/composables/readingTime.ts index dd0489b9..8df4b944 100644 --- a/theme/src/client/composables/readingTime.ts +++ b/theme/src/client/composables/readingTime.ts @@ -15,15 +15,15 @@ export const readingTimeLocales = { }, 'zh-CN': { - word: '约 $word 字', - less1Minute: '小于 1 分钟', - time: '大约 $time 分钟', + word: '约$word字', + less1Minute: '小于1分钟', + time: '大约$time分钟', }, 'zh-TW': { - word: '約 $word 字', - less1Minute: '小於 1 分鐘', - time: '大约 $time 分鐘', + word: '約$word字', + less1Minute: '小於1分鐘', + time: '大约$time分鐘', }, 'de': { diff --git a/theme/src/client/layouts/NotFound.vue b/theme/src/client/layouts/NotFound.vue index afab378b..0be90c63 100644 --- a/theme/src/client/layouts/NotFound.vue +++ b/theme/src/client/layouts/NotFound.vue @@ -94,7 +94,9 @@ const themeData = useThemeLocaleData() font-size: 14px; font-weight: 500; color: var(--vp-c-brand); - transition: border-color 0.25s, color 0.25s; + transition: + border-color 0.25s, + color 0.25s; } .link:hover { diff --git a/theme/templates/build.html b/theme/templates/build.html index c804a1d0..e71f0de1 100644 --- a/theme/templates/build.html +++ b/theme/templates/build.html @@ -1,18 +1,20 @@ - + - - - - + + + +