chore: color lib change to colord

This commit is contained in:
chansee97 2024-04-15 16:08:14 +08:00
parent b952de3402
commit 5d1eb3cb3c
2 changed files with 4 additions and 5 deletions

View File

@ -54,7 +54,7 @@
"@tinymce/tinymce-vue": "^5.1.1", "@tinymce/tinymce-vue": "^5.1.1",
"@vueuse/core": "^10.9.0", "@vueuse/core": "^10.9.0",
"alova": "^2.19.0", "alova": "^2.19.0",
"chroma-js": "^2.4.2", "colord": "^2.9.3",
"echarts": "^5.5.0", "echarts": "^5.5.0",
"md-editor-v3": "^4.11.3", "md-editor-v3": "^4.11.3",
"performant-array-to-tree": "^1.11.0", "performant-array-to-tree": "^1.11.0",
@ -70,7 +70,6 @@
"@antfu/eslint-config": "^2.13.3", "@antfu/eslint-config": "^2.13.3",
"@iconify-json/icon-park-outline": "^1.1.15", "@iconify-json/icon-park-outline": "^1.1.15",
"@iconify/vue": "^4.1.1", "@iconify/vue": "^4.1.1",
"@types/chroma-js": "^2.4.4",
"@types/node": "^20.12.7", "@types/node": "^20.12.7",
"@types/qs": "^6.9.14", "@types/qs": "^6.9.14",
"@vitejs/plugin-vue": "^5.0.4", "@vitejs/plugin-vue": "^5.0.4",

View File

@ -1,5 +1,5 @@
import type { GlobalThemeOverrides } from 'naive-ui' import type { GlobalThemeOverrides } from 'naive-ui'
import chroma from 'chroma-js' import { colord } from 'colord'
import { set } from 'radash' import { set } from 'radash'
import themeConfig from './theme.json' import themeConfig from './theme.json'
import { local, setLocale } from '@/utils' import { local, setLocale } from '@/utils'
@ -74,8 +74,8 @@ export const useAppStore = defineStore('app-store', {
}, },
/* 设置主题色 */ /* 设置主题色 */
setPrimaryColor(color: string) { setPrimaryColor(color: string) {
const brightenColor = chroma(color).brighten(1).hex() const brightenColor = colord(color).lighten(0.1).toHex()
const darkenColor = chroma(color).darken(1).hex() const darkenColor = colord(color).darken(0.05).toHex()
set(this.theme, 'common.primaryColor', color) set(this.theme, 'common.primaryColor', color)
set(this.theme, 'common.primaryColorHover', brightenColor) set(this.theme, 'common.primaryColorHover', brightenColor)
set(this.theme, 'common.primaryColorPressed', darkenColor) set(this.theme, 'common.primaryColorPressed', darkenColor)