vue-vben-admin/internal/vite-config/src/utils/modifyVars.ts

45 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-04-05 00:20:48 +08:00
import { generate } from '@ant-design/colors';
import { resolve } from 'node:path';
// @ts-ignore
2021-04-07 23:14:51 +08:00
import { getThemeVariables } from 'ant-design-vue/dist/theme';
2023-04-05 00:20:48 +08:00
const primaryColor = '#0960bd';
function generateAntColors(color: string, theme: 'default' | 'dark' = 'default') {
return generate(color, {
theme,
});
}
2021-04-07 23:14:51 +08:00
/**
* less global variable
*/
2023-04-05 00:20:48 +08:00
export function generateModifyVars() {
2021-04-07 23:14:51 +08:00
const palettes = generateAntColors(primaryColor);
const primary = palettes[5];
const primaryColorObj: Record<string, string> = {};
for (let index = 0; index < 10; index++) {
primaryColorObj[`primary-${index + 1}`] = palettes[index];
}
2023-04-05 00:20:48 +08:00
const modifyVars = getThemeVariables();
2021-04-07 23:14:51 +08:00
return {
...modifyVars,
// reference: Avoid repeated references
hack: `${modifyVars.hack} @import (reference) "${resolve('src/design/config.less')}";`,
'primary-color': primary,
...primaryColorObj,
'info-color': primary,
'processing-color': primary,
'success-color': '#55D187', // Success color
'error-color': '#ED6F6F', // False color
'warning-color': '#EFBD47', // Warning color
'font-size-base': '14px', // Main font size
'border-radius-base': '2px', // Component/float fillet
'link-color': primary, // Link color
2021-04-17 18:51:19 +08:00
'app-content-background': '#fafafa', // Link color
2021-04-07 23:14:51 +08:00
};
}