From 6d0781b647eca86a94bd00e5759657793818c81a Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Fri, 9 Jan 2026 15:32:49 +0800 Subject: [PATCH] chore: tweak --- plugins/plugin-md-power/src/node/icon/prepareIcon.ts | 4 ++-- theme/src/client/composables/encrypt.ts | 2 +- theme/src/shared/locale.ts | 3 ++- theme/src/shared/options.ts | 5 +++-- theme/src/shared/pageData.ts | 3 ++- theme/src/shared/plugins.ts | 7 ++++--- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/plugins/plugin-md-power/src/node/icon/prepareIcon.ts b/plugins/plugin-md-power/src/node/icon/prepareIcon.ts index 903eeac4..c32039cf 100644 --- a/plugins/plugin-md-power/src/node/icon/prepareIcon.ts +++ b/plugins/plugin-md-power/src/node/icon/prepareIcon.ts @@ -1,5 +1,5 @@ import type { IconOptions } from '../../shared/index.js' -import { notNullish, toArray, uniqueBy } from '@pengzhanbo/utils' +import { notNullish, toArray, uniqWith } from '@pengzhanbo/utils' import { isLinkAbsolute } from '@vuepress/helper' import { isLinkHttp } from 'vuepress/shared' import { logger } from '../utils/logger.js' @@ -44,7 +44,7 @@ export function prepareIcon( let hasStyle = false let hasScript = false - for (const asset of uniqueBy(assets, (a, b) => a.link === b.link)) { + for (const asset of uniqWith(assets, (a, b) => a.link === b.link)) { if (asset.type === 'style') { hasStyle = true setupContent.push(`useStyleTag('@import url("${asset.link}");')`) diff --git a/theme/src/client/composables/encrypt.ts b/theme/src/client/composables/encrypt.ts index a75c4d58..10077ecd 100644 --- a/theme/src/client/composables/encrypt.ts +++ b/theme/src/client/composables/encrypt.ts @@ -56,7 +56,7 @@ function createMatchRegex(match: string) { return regex } -function toMatch(match: string, pagePath: string, filePathRelative: string | null) { +function toMatch(match: string, pagePath: string, filePathRelative?: string | null) { const relativePath = filePathRelative || '' if (match[0] === '^') { const regex = createMatchRegex(match) diff --git a/theme/src/shared/locale.ts b/theme/src/shared/locale.ts index fa4f2e2c..ffffc9d0 100644 --- a/theme/src/shared/locale.ts +++ b/theme/src/shared/locale.ts @@ -10,6 +10,7 @@ import type { ThemeSidebarMulti, TransitionOptions, } from './features/index.js' +import type { LiteralUnion } from './utils.js' /** * 内置的多语言配置 @@ -60,7 +61,7 @@ export interface ThemeLocale extends LocaleData { * 允许显示在导航栏的社交类型 * @default ['github', 'twitter', 'discord', 'facebook'] */ - navbarSocialInclude?: (SocialLinkIconUnion | (string & { zz_IGNORE_ME?: never }))[] + navbarSocialInclude?: LiteralUnion[] /** * 笔记配置, 笔记中的文章默认不会出现在首页文章列表 diff --git a/theme/src/shared/options.ts b/theme/src/shared/options.ts index 7e09726d..5d2449c2 100644 --- a/theme/src/shared/options.ts +++ b/theme/src/shared/options.ts @@ -1,3 +1,4 @@ +import type { Prettify } from '@pengzhanbo/utils' import type { CommentPluginOptions } from '@vuepress/plugin-comment' import type { CopyCodePluginOptions } from '@vuepress/plugin-copy-code' import type { ChangelogOptions, ContributorsOptions } from '@vuepress/plugin-git' @@ -85,7 +86,7 @@ export interface ThemeFeatureOptions { /** * 贡献者配置 */ - contributors?: boolean | ContributorsOptions & { mode?: 'inline' | 'block' } + contributors?: boolean | Prettify /** * 页面变更记录配置 @@ -120,7 +121,7 @@ export interface ThemeFeatureOptions { /** * 水印配置 */ - watermark?: boolean | (WatermarkPluginOptions & { fullPage?: boolean }) + watermark?: boolean | Prettify /** * 阅读时间、字数统计 diff --git a/theme/src/shared/pageData.ts b/theme/src/shared/pageData.ts index e44a2497..122182e5 100644 --- a/theme/src/shared/pageData.ts +++ b/theme/src/shared/pageData.ts @@ -1,3 +1,4 @@ +import type { Nullable } from '@pengzhanbo/utils' import type { GitPluginPageData } from '@vuepress/plugin-git' import type { ReadingTime } from '@vuepress/plugin-reading-time' import type { PostsCategoryItem } from './features/index.js' @@ -15,7 +16,7 @@ export interface ThemePageData extends GitPluginPageData { /** * 相对于根目录的文件路径 */ - filePathRelative: string | null + filePathRelative: Nullable /** * 阅读时间 */ diff --git a/theme/src/shared/plugins.ts b/theme/src/shared/plugins.ts index f8c8b1fa..b01889c6 100644 --- a/theme/src/shared/plugins.ts +++ b/theme/src/shared/plugins.ts @@ -1,3 +1,4 @@ +import type { Prettify } from '@pengzhanbo/utils' import type { SearchPluginOptions } from '@vuepress-plume/plugin-search' import type { CachePluginOptions } from '@vuepress/plugin-cache' import type { CommentPluginOptions } from '@vuepress/plugin-comment' @@ -105,12 +106,12 @@ export interface ThemeBuiltinPlugins { /** * 生成站点地图 */ - sitemap?: false | Omit & { hostname?: string } + sitemap?: false | Prettify & { hostname?: string }> /** * SEO */ - seo?: false | Omit & { hostname?: string } + seo?: false | Prettify & { hostname?: string }> /** * 缓存 @@ -125,7 +126,7 @@ export interface ThemeBuiltinPlugins { /** * 是否开启 水印 */ - watermark?: boolean | (WatermarkPluginOptions & { fullPage?: boolean }) + watermark?: boolean | Prettify /** * 资源链接替换