feat(projects): support loading page dark mode adaptation. (#702)
This commit is contained in:
parent
86da767e24
commit
9b9455d945
@ -61,3 +61,5 @@ export const resetCacheStrategyRecord: Record<UnionKey.ResetCacheStrategy, App.I
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const resetCacheStrategyOptions = transformRecordToOption(resetCacheStrategyRecord);
|
export const resetCacheStrategyOptions = transformRecordToOption(resetCacheStrategyRecord);
|
||||||
|
|
||||||
|
export const DARK_CLASS = 'dark';
|
||||||
|
@ -3,14 +3,20 @@ import { getRgb } from '@sa/color';
|
|||||||
import { $t } from '@/locales';
|
import { $t } from '@/locales';
|
||||||
import { localStg } from '@/utils/storage';
|
import { localStg } from '@/utils/storage';
|
||||||
import systemLogo from '@/assets/svg-icon/logo.svg?raw';
|
import systemLogo from '@/assets/svg-icon/logo.svg?raw';
|
||||||
|
import { DARK_CLASS } from '@/constants/app';
|
||||||
|
import { toggleHtmlClass } from '@/utils/common';
|
||||||
|
|
||||||
export function setupLoading() {
|
export function setupLoading() {
|
||||||
const themeColor = localStg.get('themeColor') || '#646cff';
|
const themeColor = localStg.get('themeColor') || '#646cff';
|
||||||
|
const darkMode = localStg.get('darkMode') || false;
|
||||||
const { r, g, b } = getRgb(themeColor);
|
const { r, g, b } = getRgb(themeColor);
|
||||||
|
|
||||||
const primaryColor = `--primary-color: ${r} ${g} ${b}`;
|
const primaryColor = `--primary-color: ${r} ${g} ${b}`;
|
||||||
|
|
||||||
|
if (darkMode) {
|
||||||
|
toggleHtmlClass(DARK_CLASS).add();
|
||||||
|
}
|
||||||
|
|
||||||
const loadingClasses = [
|
const loadingClasses = [
|
||||||
'left-0 top-0',
|
'left-0 top-0',
|
||||||
'left-0 bottom-0 animate-delay-500',
|
'left-0 bottom-0 animate-delay-500',
|
||||||
@ -27,14 +33,14 @@ export function setupLoading() {
|
|||||||
.join('\n');
|
.join('\n');
|
||||||
|
|
||||||
const loading = `
|
const loading = `
|
||||||
<div class="fixed-center flex-col" style="${primaryColor}">
|
<div class="fixed-center flex-col bg-layout" style="${primaryColor}">
|
||||||
${logoWithClass}
|
${logoWithClass}
|
||||||
<div class="w-56px h-56px my-36px">
|
<div class="w-56px h-56px my-36px">
|
||||||
<div class="relative h-full animate-spin">
|
<div class="relative h-full animate-spin">
|
||||||
${dot}
|
${dot}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h2 class="text-28px font-500 text-#646464">${$t('system.title')}</h2>
|
<h2 class="text-28px font-500 text-primary">${$t('system.title')}</h2>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
const app = document.getElementById('app');
|
const app = document.getElementById('app');
|
||||||
|
@ -174,6 +174,7 @@ export const useThemeStore = defineStore(SetupStoreId.Theme, () => {
|
|||||||
darkMode,
|
darkMode,
|
||||||
val => {
|
val => {
|
||||||
toggleCssDarkMode(val);
|
toggleCssDarkMode(val);
|
||||||
|
localStg.set('darkMode', val);
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
@ -5,8 +5,7 @@ import { overrideThemeSettings, themeSettings } from '@/theme/settings';
|
|||||||
import { themeVars } from '@/theme/vars';
|
import { themeVars } from '@/theme/vars';
|
||||||
import { toggleHtmlClass } from '@/utils/common';
|
import { toggleHtmlClass } from '@/utils/common';
|
||||||
import { localStg } from '@/utils/storage';
|
import { localStg } from '@/utils/storage';
|
||||||
|
import { DARK_CLASS } from '@/constants/app';
|
||||||
const DARK_CLASS = 'dark';
|
|
||||||
|
|
||||||
/** Init theme settings */
|
/** Init theme settings */
|
||||||
export function initThemeSettings() {
|
export function initThemeSettings() {
|
||||||
|
2
src/typings/storage.d.ts
vendored
2
src/typings/storage.d.ts
vendored
@ -20,6 +20,8 @@ declare namespace StorageType {
|
|||||||
refreshToken: string;
|
refreshToken: string;
|
||||||
/** The theme color */
|
/** The theme color */
|
||||||
themeColor: string;
|
themeColor: string;
|
||||||
|
/** The dark mode */
|
||||||
|
darkMode: boolean;
|
||||||
/** The theme settings */
|
/** The theme settings */
|
||||||
themeSettings: App.Theme.ThemeSetting;
|
themeSettings: App.Theme.ThemeSetting;
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user