|
5 | 5 |
|
6 | 6 | import type { CSSVariableConfig } from './cssVariables' |
7 | 7 | import { downloadFile } from '@md/shared/utils' |
8 | | -import { extractCSSVariables, resolveCSSVariables } from './cssVariableResolver' |
9 | 8 | import { generateCSSVariables } from './cssVariables' |
10 | 9 |
|
11 | 10 | /** |
@@ -39,49 +38,7 @@ export function exportMergedTheme( |
39 | 38 | customCSS, |
40 | 39 | ].filter(Boolean).join(`\n`) |
41 | 40 |
|
42 | | - // 3. 提取变量映射 |
43 | | - const variablesMap = extractCSSVariables(variablesCSS) |
44 | | - |
45 | | - // 4. 解析变量(将 CSS 变量替换为实际值) |
46 | | - const resolvedCSS = resolveCSSVariables(mergedCSS, variablesMap) |
47 | | - |
48 | | - // 5. 下载文件 |
49 | | - downloadFile(resolvedCSS, `text/css`, `${fileName}.css`) |
50 | | - |
51 | | - return resolvedCSS |
52 | | -} |
53 | | - |
54 | | -/** |
55 | | - * 导出带变量的主题(推荐) |
56 | | - * @param customCSS - 用户自定义的CSS内容 |
57 | | - * @param baseThemeCSS - 基础主题CSS |
58 | | - * @param config - 配置项 |
59 | | - * @param fileName - 导出文件名 |
60 | | - */ |
61 | | -export function exportThemeWithVariables( |
62 | | - customCSS: string, |
63 | | - baseThemeCSS: string, |
64 | | - config: CSSVariableConfig, |
65 | | - fileName: string, |
66 | | -) { |
67 | | - const variablesCSS = generateCSSVariables(config) |
68 | | - |
69 | | - const mergedCSS = [ |
70 | | - `/**`, |
71 | | - ` * MD 主题导出(包含 CSS 变量)`, |
72 | | - ` * 导出时间: ${new Date().toLocaleString()}`, |
73 | | - ` * 说明: 该文件使用 CSS 变量,可通过修改 :root 中的变量值来调整主题`, |
74 | | - ` */`, |
75 | | - ``, |
76 | | - variablesCSS, |
77 | | - ``, |
78 | | - baseThemeCSS, |
79 | | - ``, |
80 | | - `/* 自定义样式 */`, |
81 | | - customCSS, |
82 | | - ].filter(Boolean).join(`\n`) |
83 | | - |
84 | | - downloadFile(mergedCSS, `text/css`, `${fileName}.css`) |
| 41 | + downloadFile(mergedCSS, `${fileName}.css`, `text/css`) |
85 | 42 |
|
86 | 43 | return mergedCSS |
87 | 44 | } |
0 commit comments