perf: remove unused css

This commit is contained in:
ibuler
2022-07-11 18:26:55 +08:00
committed by 老广
parent 7644bffe12
commit ca45f61c2c
9 changed files with 22 additions and 45 deletions

View File

@@ -1,14 +1,16 @@
import color from 'css-color-function'
import formula from './formula.json'
import defaultThemeConfig from './default.js'
import variables from '@/styles/var.scss'
export function generateColors(themeColors) {
const colors = {}
if (!themeColors) {
themeColors = defaultThemeConfig
}
let primaryColor = themeColors
let subColor = defaultThemeConfig
if (typeof themeColors === 'object') {
primaryColor = themeColors['--color-primary'] || variables.themeColor
primaryColor = themeColors['--color-primary']
subColor = Object.keys(themeColors).length > 0 ? themeColors : defaultThemeConfig
}

View File

@@ -1,7 +1,6 @@
import { changeMenuColor, generateColors, mix } from './color'
import axios from 'axios'
import formula from './formula.json'
import variables from '@/styles/var.scss'
let originalStyle = ''
@@ -64,7 +63,7 @@ export function changeThemeColors(themeColors) {
axios.spread((file, extraFile) => {
const fileData = file.data
const extraFileData = extraFile.data.replace(/[\r\n]/g, '')
originalStyle = replaceStyleColors(fileData + extraFileData)
originalStyle = replaceStyleColors(fileData + extraFileData, themeColors)
resolve()
})
)
@@ -77,8 +76,8 @@ export function changeThemeColors(themeColors) {
})
}
export function replaceStyleColors(data) {
const colors = generateColors(variables.themeColor)
export function replaceStyleColors(data, themeColors) {
const colors = generateColors(themeColors['--primary'])
const colorMap = new Map()
Object.keys(formula).forEach((key) => {
colorMap.set(colors[key], key)