forked from lostdesign/linked
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.vue
90 lines (76 loc) · 2.08 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<template>
<router-view />
</template>
<script>
import { mapGetters, mapActions } from 'vuex'
import {
Getters as CalendarGetters,
Actions as CalendarActions
} from '@/store/modules/calendar/types'
import { Actions as FileActions } from '@/store/modules/file/types'
import {
Getters as AppGetters,
Actions as AppActions
} from '@/store/modules/app/types'
const { ipcRenderer } = require('electron')
export default {
methods: {
...mapActions('calendar', [
CalendarActions.SET_DATE,
CalendarActions.SET_DAY_TO,
CalendarActions.SET_CURRENT_WEEK
]),
...mapActions('file', [FileActions.FETCH_FILE]),
...mapActions('app', [AppActions.INIT_APP])
},
computed: {
...mapGetters('calendar', [CalendarGetters.GET_CURRENT_DATE]),
...mapGetters('app', [AppGetters.GET_LANGUAGE, AppGetters.GET_THEME])
},
mounted() {
ipcRenderer.on('open-settings', () => {
this.$router.push('settings', () => {})
})
ipcRenderer.on('set-today', () => {
this.setDate()
})
ipcRenderer.on('set-search', () => {
this.$router.push('search', () => {})
})
ipcRenderer.on('previous-day', () => {
this.setDayTo(-1)
})
ipcRenderer.on('next-day', () => {
this.setDayTo(1)
})
ipcRenderer.on('previous-week', () => {
this.setDayTo(-7)
})
ipcRenderer.on('next-week', () => {
this.setDayTo(7)
})
},
created() {
this.initApp()
this.fetchFile(this.getCurrentDate)
this.$store.subscribe((mutation) => {
if (mutation.type === `calendar/${CalendarActions.SET_DATE}`) {
this.fetchFile(this.getCurrentDate)
this.setCurrentWeek()
}
if (mutation.type === `app/${AppActions.SET_THEME}`) {
if (this.getTheme === 'dark') {
document.documentElement.classList.add('dark')
} else {
document.documentElement.classList.remove('dark')
}
}
})
if (this.getTheme === 'dark') {
document.documentElement.classList.add('dark')
} else {
document.documentElement.classList.remove('dark')
}
}
}
</script>