admin-vben/build/generate/generateModifyVars.ts

37 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-07-29 10:46:43 +00:00
import { resolve } from 'node:path'
2023-03-18 13:10:54 +00:00
import { getThemeVariables } from 'ant-design-vue/dist/theme'
2023-07-29 10:46:43 +00:00
import { generateAntColors, primaryColor } from '../config/themeConfig'
2023-03-18 13:10:54 +00:00
/**
* less global variable
*/
export function generateModifyVars(dark = false) {
const palettes = generateAntColors(primaryColor)
const primary = palettes[5]
const primaryColorObj: Record<string, string> = {}
2023-07-29 10:46:43 +00:00
for (let index = 0; index < 10; index++)
2023-03-18 13:10:54 +00:00
primaryColorObj[`primary-${index + 1}`] = palettes[index]
const modifyVars = getThemeVariables({ dark })
return {
...modifyVars,
// Used for global import to avoid the need to import each style file separately
// reference: Avoid repeated references
2023-07-29 10:46:43 +00:00
'hack': `${modifyVars.hack} @import (reference) "${resolve('src/design/config.less')}";`,
2023-03-18 13:10:54 +00:00
'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
2023-07-29 10:46:43 +00:00
// 'border-color-base': '#EEEEEE',
2023-03-18 13:10:54 +00:00
'font-size-base': '14px', // Main font size
'border-radius-base': '2px', // Component/float fillet
'link-color': primary, // Link color
2023-07-29 10:46:43 +00:00
'app-content-background': '#fafafa', // Link color
2023-03-18 13:10:54 +00:00
}
}