mirror of
				https://github.com/soybeanjs/soybean-admin.git
				synced 2025-11-04 15:53:43 +08:00 
			
		
		
		
	fix(projects): fix app loading theme color
This commit is contained in:
		@@ -10,20 +10,21 @@ const loadingClasses = [
 | 
			
		||||
  'right-0 bottom-0 animate-delay-1500'
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
const style = addThemeColorCssVars();
 | 
			
		||||
 | 
			
		||||
function addThemeColorCssVars() {
 | 
			
		||||
  const themeColor = localStg.get('themeColor') || '#646cff';
 | 
			
		||||
 | 
			
		||||
  const { r, g, b } = getRgbOfColor(themeColor);
 | 
			
		||||
 | 
			
		||||
  const cssVars = `--primary-color: ${r} ${g} ${b}`;
 | 
			
		||||
  document.documentElement.style.cssText = cssVars;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
addThemeColorCssVars();
 | 
			
		||||
  return cssVars;
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="fixed-center flex-col">
 | 
			
		||||
  <div class="fixed-center flex-col" :style="style">
 | 
			
		||||
    <SystemLogo class="text-128px text-primary" />
 | 
			
		||||
    <div class="w-56px h-56px my-36px">
 | 
			
		||||
      <div class="relative h-full animate-spin">
 | 
			
		||||
 
 | 
			
		||||
@@ -126,11 +126,13 @@ export const useThemeStore = defineStore(SetupStoreId.Theme, () => {
 | 
			
		||||
      { immediate: true }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // themeColors change, update css vars
 | 
			
		||||
    // themeColors change, update css vars and storage theme color
 | 
			
		||||
    watch(
 | 
			
		||||
      themeColors,
 | 
			
		||||
      () => {
 | 
			
		||||
      val => {
 | 
			
		||||
        setupThemeVarsToHtml();
 | 
			
		||||
 | 
			
		||||
        localStg.set('themeColor', val.primary);
 | 
			
		||||
      },
 | 
			
		||||
      { immediate: true }
 | 
			
		||||
    );
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user