Blame view

internal/vite-config/src/utils/modifyVars.ts 1.31 KB
1
import { resolve } from 'node:path';
2
3
4

import { generate } from '@ant-design/colors';
// @ts-ignore: typo
Vben authored
5
import { getThemeVariables } from 'ant-design-vue/dist/theme';
6
7
8
9
10
11
12
13

const primaryColor = '#0960bd';

function generateAntColors(color: string, theme: 'default' | 'dark' = 'default') {
  return generate(color, {
    theme,
  });
}
Vben authored
14
15
16
17

/**
 * less global variable
 */
18
export function generateModifyVars() {
Vben authored
19
20
21
22
23
24
25
26
27
  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];
  }
28
  const modifyVars = getThemeVariables();
Vben authored
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  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
43
    'app-content-background': '#fafafa', //   Link color
Vben authored
44
45
  };
}