feat(projects): custom unocss colors support opacity

This commit is contained in:
Soybean
2023-03-13 20:36:35 +08:00
parent f73e3f648d
commit 488e6e3204
5 changed files with 133 additions and 39 deletions

View File

@ -17,7 +17,7 @@
<script setup lang="ts">
import { useAppInfo } from '@/composables';
import { localStg } from '@/utils';
import { localStg, getRgbOfColor } from '@/utils';
import themeSettings from '@/settings/theme.json';
const { title } = useAppInfo();
@ -32,7 +32,10 @@ const lodingClasses = [
function addThemeColorCssVars() {
const defaultColor = themeSettings.themeColor;
const themeColor = localStg.get('themeColor') || defaultColor;
const cssVars = `--primary-color: ${themeColor}`;
const { r, g, b } = getRgbOfColor(themeColor);
const cssVars = `--primary-color: ${r},${g},${b}`;
document.documentElement.style.cssText = cssVars;
}