This commit is contained in:
syuilo
2018-09-29 00:01:11 +09:00
parent 1fa4d0d3f8
commit 6a82e94c54
15 changed files with 287 additions and 31 deletions

View File

@ -14,11 +14,11 @@ import App from './app.vue';
import checkForUpdate from './common/scripts/check-for-update';
import MiOS, { API } from './mios';
import { version, codename, lang } from './config';
import applyTheme from './common/scripts/theme';
const defaultTheme = require('../theme/light.json');
import { builtinThemes, applyTheme } from './theme';
const lightTheme = require('../theme/light.json');
if (localStorage.getItem('theme') == null) {
applyTheme(defaultTheme);
applyTheme(lightTheme);
}
Vue.use(Vuex);
@ -92,6 +92,35 @@ export default (callback: (launch: (router: VueRouter, api?: (os: MiOS) => API)
const launch = (router: VueRouter, api?: (os: MiOS) => API) => {
os.apis = api ? api(os) : null;
//#region theme
os.store.watch(s => {
return s.device.darkmode;
}, v => {
const themes = os.store.state.device.themes.concat(builtinThemes);
const dark = themes.find(t => t.meta.id == os.store.state.device.darkTheme);
const light = themes.find(t => t.meta.id == os.store.state.device.lightTheme);
applyTheme(v ? dark : light);
});
os.store.watch(s => {
return s.device.lightTheme;
}, v => {
const themes = os.store.state.device.themes.concat(builtinThemes);
const theme = themes.find(t => t.meta.id == v);
if (!os.store.state.device.darkmode) {
applyTheme(theme);
}
});
os.store.watch(s => {
return s.device.darkTheme;
}, v => {
const themes = os.store.state.device.themes.concat(builtinThemes);
const theme = themes.find(t => t.meta.id == v);
if (os.store.state.device.darkmode) {
applyTheme(theme);
}
});
//#endregion
//#region shadow
const shadow = '0 3px 8px rgba(0, 0, 0, 0.2)';
if (os.store.state.settings.useShadow) document.documentElement.style.setProperty('--shadow', shadow);