This commit is contained in:
syuilo
2018-05-24 05:46:09 +09:00
parent 89461c598f
commit f565e60bcf
4 changed files with 58 additions and 18 deletions

View File

@@ -16,16 +16,29 @@ export default Vue.extend({
data() {
return {
fetching: true,
user: null
user: null,
unwatchDarkmode: null
};
},
watch: {
$route: 'fetch'
},
created() {
document.documentElement.style.background = '#fff';
const applyBg = v =>
document.documentElement.style.setProperty('background', v ? '#191b22' : '#fff', 'important');
this.$nextTick(() => applyBg(this.$store.state.device.darkmode));
this.unwatchDarkmode = this.$store.watch(s => {
return s.device.darkmode;
}, applyBg);
this.fetch();
},
beforeDestroy() {
document.documentElement.style.removeProperty('background');
this.unwatchDarkmode();
},
methods: {
fetch() {
this.fetching = true;