feat(projects): support theme perset to override component library presets.

This commit is contained in:
Azir-11
2025-12-02 16:07:09 +08:00
committed by Soybean
parent 73e9a0fe0b
commit 605173a1cc
5 changed files with 49 additions and 8 deletions

View File

@@ -33,6 +33,8 @@ type ThemePreset = Pick<
desc: string;
i18nkey?: string;
version: string;
/** Optional NaiveUI theme overrides */
naiveui?: App.Theme.NaiveUIThemeOverride;
};
const presetModules = import.meta.glob('@/theme/preset/*.json', { eager: true, import: 'default' });
@@ -80,7 +82,7 @@ const getPresetDesc = (preset: ThemePreset): string => {
const applyPreset = (preset: ThemePreset): void => {
const mergedPreset = defu(preset, themeSettings);
const { themeScheme, grayscale, colourWeakness, layout, watermark, ...rest } = mergedPreset;
const { themeScheme, grayscale, colourWeakness, layout, watermark, naiveui, ...rest } = mergedPreset;
themeStore.setThemeScheme(themeScheme);
themeStore.setGrayscale(grayscale);
themeStore.setColourWeakness(colourWeakness);
@@ -100,6 +102,9 @@ const applyPreset = (preset: ThemePreset): void => {
tokens: { ...rest.tokens }
});
// Apply NaiveUI theme overrides if present
themeStore.setNaiveThemeOverrides(naiveui);
window.$message?.success($t('theme.appearance.preset.applySuccess'));
};
</script>