From 936b0b4851501f62d22210bfafcde3ea15d4319d Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Fri, 19 Jul 2024 03:17:28 +0800 Subject: [PATCH] perf: optimize package import --- .../src/client/clientConfig.ts | 12 -------- .../plugin-content-update/src/node/plugin.ts | 2 +- .../src/client/components/Iconify.vue | 10 +++---- .../src/client/composables/index.ts | 1 + .../src/client/{clientConfig.ts => config.ts} | 4 +-- plugins/plugin-iconify/src/client/index.ts | 2 -- plugins/plugin-iconify/src/node/index.ts | 2 +- plugins/plugin-iconify/src/node/plugin.ts | 30 +++++++++---------- plugins/plugin-iconify/src/shared/index.ts | 5 ---- .../src/node/prepareConfigFile.ts | 7 ----- .../src/client/components/SearchBox.vue | 5 ++-- .../src/client/components/SearchButton.vue | 2 +- .../src/client/composables/index.ts | 1 + .../plugin-search/src/client/utils/index.ts | 1 + theme/src/client/components/Blog/VPBlog.vue | 2 +- .../client/components/Blog/VPBlogArchives.vue | 3 +- .../client/components/Blog/VPBlogAside.vue | 2 +- .../components/Blog/VPBlogCategories.vue | 3 +- .../client/components/Blog/VPBlogExtract.vue | 3 +- .../src/client/components/Blog/VPBlogNav.vue | 2 +- .../client/components/Blog/VPBlogProfile.vue | 2 +- .../src/client/components/Blog/VPBlogTags.vue | 3 +- .../client/components/Blog/VPCategories.vue | 2 +- .../components/Blog/VPCategoriesGroup.vue | 2 +- .../client/components/Blog/VPPagination.vue | 2 +- .../src/client/components/Blog/VPPostItem.vue | 2 +- .../src/client/components/Blog/VPPostList.vue | 2 +- theme/src/client/components/Home/VPHome.vue | 2 +- .../client/components/Home/VPHomeBanner.vue | 2 +- .../src/client/components/Home/VPHomeBox.vue | 2 +- .../src/client/components/Home/VPHomeHero.vue | 3 +- .../client/components/Home/VPHomeProfile.vue | 2 +- theme/src/client/components/Nav/VPNav.vue | 3 +- theme/src/client/components/Nav/VPNavBar.vue | 3 +- .../components/Nav/VPNavBarAppearance.vue | 2 +- .../client/components/Nav/VPNavBarExtra.vue | 3 +- .../client/components/Nav/VPNavBarMenu.vue | 2 +- .../components/Nav/VPNavBarMenuGroup.vue | 4 +-- .../components/Nav/VPNavBarMenuLink.vue | 4 +-- .../components/Nav/VPNavBarSocialLinks.vue | 2 +- .../client/components/Nav/VPNavBarTitle.vue | 3 +- .../components/Nav/VPNavBarTranslations.vue | 3 +- .../components/Nav/VPNavScreenAppearance.vue | 2 +- .../client/components/Nav/VPNavScreenMenu.vue | 2 +- .../Nav/VPNavScreenMenuGroupLink.vue | 2 +- .../components/Nav/VPNavScreenMenuLink.vue | 2 +- .../components/Nav/VPNavScreenSocialLinks.vue | 2 +- .../Nav/VPNavScreenTranslations.vue | 2 +- theme/src/client/components/VPBackToTop.vue | 2 +- theme/src/client/components/VPButton.vue | 2 +- theme/src/client/components/VPContent.vue | 3 +- theme/src/client/components/VPDoc.vue | 12 ++++---- .../client/components/VPDocAsideOutline.vue | 3 +- theme/src/client/components/VPDocFooter.vue | 12 ++++---- theme/src/client/components/VPDocMeta.vue | 10 ++++--- .../client/components/VPDocOutlineItem.vue | 2 +- theme/src/client/components/VPEncryptForm.vue | 3 +- .../src/client/components/VPEncryptGlobal.vue | 2 +- theme/src/client/components/VPEncryptPage.vue | 2 +- theme/src/client/components/VPFlyout.vue | 2 +- theme/src/client/components/VPFooter.vue | 3 +- theme/src/client/components/VPFriends.vue | 3 +- theme/src/client/components/VPFriendsItem.vue | 2 +- theme/src/client/components/VPLink.vue | 2 +- theme/src/client/components/VPLocalNav.vue | 5 +--- .../components/VPLocalNavOutlineDropdown.vue | 4 +-- theme/src/client/components/VPMenuLink.vue | 2 +- theme/src/client/components/VPSidebar.vue | 2 +- .../src/client/components/VPSidebarGroup.vue | 4 +-- theme/src/client/components/VPSidebarItem.vue | 4 +-- .../client/components/VPSwitchAppearance.vue | 2 +- .../client/components/VPTransitionDrop.vue | 2 +- .../components/VPTransitionFadeSlideY.vue | 3 +- theme/src/client/composables/index.ts | 7 +++++ .../src/client/composables/latest-updated.ts | 2 +- theme/src/client/composables/nav.ts | 5 ++-- theme/src/client/composables/sidebar.ts | 3 +- theme/src/client/layouts/Layout.vue | 4 +-- theme/src/client/layouts/NotFound.vue | 2 +- theme/src/client/utils/index.ts | 1 + theme/src/client/utils/resolveNavLink.ts | 2 +- theme/src/node/autoFrontmatter/generator.ts | 4 +-- theme/src/node/autoFrontmatter/readFile.ts | 2 +- theme/src/node/defineConfig.ts | 7 +---- theme/src/node/loadConfig/compiler.ts | 2 +- theme/src/node/loadConfig/loader.ts | 3 +- theme/src/node/plugins/getPlugins.ts | 5 ---- theme/src/node/prepare/prepareSidebar.ts | 2 +- theme/src/node/theme.ts | 3 +- theme/src/node/utils/path.ts | 2 +- theme/src/shared/index.ts | 5 ++-- theme/src/shared/options/plugins.ts | 7 +++-- theme/src/shared/resolved/index.ts | 2 ++ 93 files changed, 147 insertions(+), 182 deletions(-) delete mode 100644 plugins/plugin-content-update/src/client/clientConfig.ts create mode 100644 plugins/plugin-iconify/src/client/composables/index.ts rename plugins/plugin-iconify/src/client/{clientConfig.ts => config.ts} (65%) delete mode 100644 plugins/plugin-iconify/src/client/index.ts delete mode 100644 plugins/plugin-iconify/src/shared/index.ts create mode 100644 plugins/plugin-search/src/client/utils/index.ts create mode 100644 theme/src/shared/resolved/index.ts diff --git a/plugins/plugin-content-update/src/client/clientConfig.ts b/plugins/plugin-content-update/src/client/clientConfig.ts deleted file mode 100644 index bad236a4..00000000 --- a/plugins/plugin-content-update/src/client/clientConfig.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { defineClientConfig } from 'vuepress/client' -import type { ClientConfig } from 'vuepress/client' -import { Content } from './components/Content.js' - -export default defineClientConfig({ - enhance({ app }) { - if (app._context.components.Content) - delete app._context.components.Content - - app.component('Content', Content) - }, -}) as ClientConfig diff --git a/plugins/plugin-content-update/src/node/plugin.ts b/plugins/plugin-content-update/src/node/plugin.ts index 6d041dee..cff5534a 100644 --- a/plugins/plugin-content-update/src/node/plugin.ts +++ b/plugins/plugin-content-update/src/node/plugin.ts @@ -6,6 +6,6 @@ const __dirname = getDirname(import.meta.url) export function contentUpdatePlugin(): Plugin { return { name: '@vuepress-plume/plugin-content-update', - clientConfigFile: path.resolve(__dirname, '../client/clientConfig.js'), + clientConfigFile: path.resolve(__dirname, '../client/config.js'), } } diff --git a/plugins/plugin-iconify/src/client/components/Iconify.vue b/plugins/plugin-iconify/src/client/components/Iconify.vue index 977b8dc6..cd675ccb 100644 --- a/plugins/plugin-iconify/src/client/components/Iconify.vue +++ b/plugins/plugin-iconify/src/client/components/Iconify.vue @@ -4,7 +4,7 @@ import { ClientOnly } from 'vuepress/client' import type { IconifyRenderMode } from '@iconify/vue' import type { StyleValue } from 'vue' import { computed, toRefs } from 'vue' -import { useIconify } from '../composables/iconify.js' +import { useIconify } from '../composables/index.js' const props = withDefaults( defineProps<{ @@ -31,13 +31,13 @@ const { name } = toRefs(props) const { icon, loaded } = useIconify(name) const size = computed(() => { - const size = props.size || __VUEPRESS_PLUGIN_ICONIFY_DEFAULT_SIZE__ + const size = props.size || __VP_ICONIFY_SIZE__ if (String(Number(size)) === size) return `${size}px` return size }) -const color = computed(() => props.color || __VUEPRESS_PLUGIN_ICONIFY_DEFAULT_COLOR__) +const color = computed(() => props.color || __VP_ICONIFY_COLOR__) const bind = computed(() => ({ icon: icon.value, @@ -55,8 +55,8 @@ const bind = computed(() => ({