Darken
This commit is contained in:
parent
89461c598f
commit
f565e60bcf
4 changed files with 58 additions and 18 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue