diff --git a/plugins/plugin-md-power/src/client/components/CodeTabs.vue b/plugins/plugin-md-power/src/client/components/CodeTabs.vue index 847b83a4..b9f60611 100644 --- a/plugins/plugin-md-power/src/client/components/CodeTabs.vue +++ b/plugins/plugin-md-power/src/client/components/CodeTabs.vue @@ -157,6 +157,9 @@ function onTabNavClick(index: number): void { .vp-code-tab-nav { position: relative; + display: inline-flex; + gap: 4px; + align-items: center; padding: 0 12px; font-size: 14px; font-weight: 500; @@ -202,7 +205,7 @@ function onTabNavClick(index: number): void { .vp-code-tab-nav .vp-icon { width: 18px; height: 18px; - margin-left: 0; + margin: 0; } .vp-code-tab-nav span { diff --git a/plugins/plugin-md-power/src/shared/icon.ts b/plugins/plugin-md-power/src/shared/icon.ts index 475bb8cf..70d0bad9 100644 --- a/plugins/plugin-md-power/src/shared/icon.ts +++ b/plugins/plugin-md-power/src/shared/icon.ts @@ -62,6 +62,21 @@ export interface IconifyProvider extends IconProviderBase { * @default '' */ prefix?: LiteralUnion + + /** + * preload iconify icons + * + * 预加载 iconify 图标, + * + * + * - `string[]` 需要预加载的图标名称,`collect:name` 格式 + * - `Record` 以 collect 为 key, value 为需要预加载的图标 `name` + * 其中,如果 key 为 `preflight` 时,value 为预加载图标的 `collect:name` 格式 + * + * 此配置主要用于开发组件时,在组件中直接使用 `` 时无法触发 + * 主题的图标本地资源分析功能,通过预加载的方式直接预设为本地资源图标。 + */ + preload?: string[] | Record, string[]> } export type FontAwesomeAssetBuiltIn = 'fontawesome' | 'fontawesome-with-brands' diff --git a/theme/src/client/components/VPIconify.vue b/theme/src/client/components/VPIconify.vue index dbbc95d8..247b1973 100644 --- a/theme/src/client/components/VPIconify.vue +++ b/theme/src/client/components/VPIconify.vue @@ -26,16 +26,14 @@ const iconName = computed(() => { return prefix ? `${prefix}:${name}` : name }) -const localIconName = computed(() => normalizeIconClassname(iconName.value)) +const classname = computed(() => normalizeIconClassname(iconName.value)) async function loadRemoteIcon() { - if (icon.value) + if (classname.value || icon.value) return - if (!localIconName.value) { - loaded.value = false - icon.value = await loadIcon(name) - } + loaded.value = false + icon.value = await loadIcon(name) loaded.value = true } @@ -45,8 +43,8 @@ if (!__VUEPRESS_SSR__)