mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 08:36:19 +08:00
feat: dark mode
This commit is contained in:
@@ -2,18 +2,50 @@
|
||||
* Vite plugin for website theme color switching
|
||||
* https://github.com/anncwb/vite-plugin-theme
|
||||
*/
|
||||
import { viteThemePlugin, mixLighten, mixDarken, tinycolor } from 'vite-plugin-theme';
|
||||
import type { Plugin } from 'vite';
|
||||
import {
|
||||
viteThemePlugin,
|
||||
antdDarkThemePlugin,
|
||||
mixLighten,
|
||||
mixDarken,
|
||||
tinycolor,
|
||||
} from 'vite-plugin-theme';
|
||||
import { getThemeColors, generateColors } from '../../config/themeConfig';
|
||||
import { generateModifyVars } from '../../generate/generateModifyVars';
|
||||
|
||||
export function configThemePlugin() {
|
||||
export function configThemePlugin(isBuild: boolean): Plugin[] {
|
||||
const colors = generateColors({
|
||||
mixDarken,
|
||||
mixLighten,
|
||||
tinycolor,
|
||||
});
|
||||
|
||||
const plugin = viteThemePlugin({
|
||||
colorVariables: [...getThemeColors(), ...colors],
|
||||
});
|
||||
return plugin;
|
||||
const plugin = [
|
||||
viteThemePlugin({
|
||||
resolveSelector: (s) => `[data-theme] ${s}`,
|
||||
colorVariables: [...getThemeColors(), ...colors],
|
||||
}),
|
||||
antdDarkThemePlugin({
|
||||
filter: (id) => {
|
||||
if (isBuild) {
|
||||
return !id.endsWith('antd.less');
|
||||
}
|
||||
return true;
|
||||
},
|
||||
// extractCss: false,
|
||||
darkModifyVars: {
|
||||
...generateModifyVars(true),
|
||||
'text-color': '#c9d1d9',
|
||||
'text-color-base': '#c9d1d9',
|
||||
'component-background': '#151515',
|
||||
// black: '#0e1117',
|
||||
// #8b949e
|
||||
'text-color-secondary': '#8b949e',
|
||||
'border-color-base': '#30363d',
|
||||
'item-active-bg': '#111b26',
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
return (plugin as unknown) as Plugin[];
|
||||
}
|
||||
|
Reference in New Issue
Block a user