mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat: read local theme on page load (#1114)
Co-authored-by: zqran <uuxnet@gmail.com>
This commit is contained in:
@@ -2,11 +2,13 @@ import { ThemeMode } from '../types';
|
||||
|
||||
export class LocalStorageThemeHelper {
|
||||
name = 'Affine-theme-mode';
|
||||
callback = new Set<() => void>();
|
||||
get = (): ThemeMode | null => {
|
||||
return localStorage.getItem(this.name) as ThemeMode | null;
|
||||
};
|
||||
set = (mode: ThemeMode) => {
|
||||
localStorage.setItem(this.name, mode);
|
||||
this.callback.forEach(cb => cb());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user