mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
fix(projects): fix update theme color
This commit is contained in:
@ -2,6 +2,7 @@ import { computed, effectScope, onScopeDispose, ref, toRefs, watch } from 'vue';
|
||||
import type { Ref } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useEventListener, usePreferredColorScheme } from '@vueuse/core';
|
||||
import { getColorPalette } from '@sa/color-palette';
|
||||
import { SetupStoreId } from '@/enum';
|
||||
import { localStg } from '@/utils/storage';
|
||||
import { addThemeVarsToHtml, createThemeToken, getNaiveTheme, initThemeSettings, toggleCssDarkMode } from './shared';
|
||||
@ -79,10 +80,15 @@ export const useThemeStore = defineStore(SetupStoreId.Theme, () => {
|
||||
* @param color Theme color
|
||||
*/
|
||||
function updateThemeColors(key: App.Theme.ThemeColorKey, color: string) {
|
||||
// get a color palette by provided color and color name, and use the suitable color
|
||||
const colorPalette = getColorPalette(color, key);
|
||||
|
||||
const mainColor = colorPalette.main.hexcode;
|
||||
|
||||
if (key === 'primary') {
|
||||
settings.value.themeColor = color;
|
||||
settings.value.themeColor = mainColor;
|
||||
} else {
|
||||
settings.value.otherColor[key] = color;
|
||||
settings.value.otherColor[key] = mainColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user