Skip to content

Commit

Permalink
fix(projects): fix app loading theme color
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Jan 17, 2024
1 parent b30c035 commit 0ba19d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/components/common/app-loading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
6 changes: 4 additions & 2 deletions src/store/modules/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
);
Expand Down

1 comment on commit 0ba19d5

@vercel
Copy link

@vercel vercel bot commented on 0ba19d5 Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

soybean-admin – ./

soybean-admin-eta.vercel.app
soybean-admin-git-main-soybeanjs.vercel.app
soybean-admin-soybeanjs.vercel.app

Please sign in to comment.