Skip to content

Commit 0ba19d5

Browse files
committed
fix(projects): fix app loading theme color
1 parent b30c035 commit 0ba19d5

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/components/common/app-loading.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ const loadingClasses = [
1010
'right-0 bottom-0 animate-delay-1500'
1111
];
1212
13+
const style = addThemeColorCssVars();
14+
1315
function addThemeColorCssVars() {
1416
const themeColor = localStg.get('themeColor') || '#646cff';
1517
1618
const { r, g, b } = getRgbOfColor(themeColor);
1719
1820
const cssVars = `--primary-color: ${r} ${g} ${b}`;
19-
document.documentElement.style.cssText = cssVars;
20-
}
2121
22-
addThemeColorCssVars();
22+
return cssVars;
23+
}
2324
</script>
2425

2526
<template>
26-
<div class="fixed-center flex-col">
27+
<div class="fixed-center flex-col" :style="style">
2728
<SystemLogo class="text-128px text-primary" />
2829
<div class="w-56px h-56px my-36px">
2930
<div class="relative h-full animate-spin">

src/store/modules/theme/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ export const useThemeStore = defineStore(SetupStoreId.Theme, () => {
126126
{ immediate: true }
127127
);
128128

129-
// themeColors change, update css vars
129+
// themeColors change, update css vars and storage theme color
130130
watch(
131131
themeColors,
132-
() => {
132+
val => {
133133
setupThemeVarsToHtml();
134+
135+
localStg.set('themeColor', val.primary);
134136
},
135137
{ immediate: true }
136138
);

0 commit comments

Comments
 (0)