feat: instance default theme

This commit is contained in:
syuilo
2022-03-01 23:58:01 +09:00
parent bc9157a03b
commit ba4ef23d6b
10 changed files with 93 additions and 5 deletions

View File

@ -15,6 +15,7 @@ if (localStorage.getItem('accounts') != null) {
import { computed, createApp, watch, markRaw, version as vueVersion } from 'vue';
import compareVersions from 'compare-versions';
import * as JSON5 from 'json5';
import widgets from '@/widgets';
import directives from '@/directives';
@ -159,7 +160,9 @@ if ($i && $i.token) {
}
//#endregion
fetchInstance().then(() => {
const fetchInstanceMetaPromise = fetchInstance();
fetchInstanceMetaPromise.then(() => {
localStorage.setItem('v', instance.version);
// Init service worker
@ -267,6 +270,14 @@ window.matchMedia('(prefers-color-scheme: dark)').addListener(mql => {
});
//#endregion
fetchInstanceMetaPromise.then(() => {
if (defaultStore.state.themeInitial) {
if (instance.defaultLightTheme != null) ColdDeviceStorage.set('lightTheme', JSON5.parse(instance.defaultLightTheme));
if (instance.defaultDarkTheme != null) ColdDeviceStorage.set('darkTheme', JSON5.parse(instance.defaultDarkTheme));
defaultStore.set('themeInitial', false);
}
});
// shortcut
document.addEventListener('keydown', makeHotkey({
'd': () => {