| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- /**
- * Copyright (c) 2013-Now https://jeesite.com All rights reserved.
- * No deletion without permission, or be held responsible to law.
- * @author ThinkGem
- */
- import { createRequire } from 'node:module';
- import { generateAntColors, primaryColor, darkPrimaryColor } from './themeConfig';
- // import { getThemeVariables } from 'ant-design-vue/dist/theme';
- import { theme } from 'ant-design-vue';
- // ant-design-vue 仅在 CJS 产物(lib)中提供该方法的默认导出,直接用 import 会被包装成模块对象,
- // 这里通过 require 取回真正的默认导出。
- const requireCjs = createRequire(import.meta.url);
- const convertLegacyToken = (
- requireCjs('ant-design-vue/lib/theme/convertLegacyToken') as {
- default: (mapToken: any) => Record<string, any>;
- }
- ).default;
- /**
- * less global variable
- */
- export function generateModifyVars(dark = false) {
- const palettes = generateAntColors(primaryColor);
- const primary = dark ? darkPrimaryColor : palettes[5];
- // const primaryColorObj: Record<string, string> = {};
- // for (let index = 0; index < 10; index++) {
- // primaryColorObj[`primary-${index + 1}`] = palettes[index];
- // }
- // const modifyVars = getThemeVariables({ dark: false });
- const { darkAlgorithm, defaultAlgorithm, defaultSeed } = theme;
- const mapToken = dark ? darkAlgorithm(defaultSeed) : defaultAlgorithm(defaultSeed);
- const modifyVars = convertLegacyToken(mapToken);
- // const modifyVars = convertLegacyToken(mapToken);
- // !!dark && console.log('modifyVars', dark, modifyVars);
- return {
- ...modifyVars,
- // Used for global import to avoid the need to import each style file separately
- // reference: Avoid repeated references
- // hack: `${modifyVars.hack} @import (reference) "${__dirname + '/../../core/design/var/index.less'}";`,
- hack: `true; @import (reference) "${__dirname + '/../../src/core/design/var/index.less'}";`,
- // ...primaryColorObj,
- 'primary-color': primary,
- 'link-color': primary,
- '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': '6px',
- // 'content-bg-striped': '#fafafa',
- };
- }
|