diff options
Diffstat (limited to 'app.js')
-rw-r--r-- | app.js | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -5,11 +5,18 @@ const app = new Vue({ | |||
5 | offline: false, | 5 | offline: false, |
6 | filter: '', | 6 | filter: '', |
7 | vlayout: true, | 7 | vlayout: true, |
8 | overrideDark: null | 8 | isDark: null |
9 | }, | 9 | }, |
10 | created: function () { | 10 | created: function () { |
11 | let that = this; | 11 | let that = this; |
12 | |||
13 | this.isDark = 'overrideDark' in localStorage ? | ||
14 | JSON.parse(localStorage.overrideDark) : matchMedia("(prefers-color-scheme: dark)").matches; | ||
12 | 15 | ||
16 | if ('vlayout' in localStorage) { | ||
17 | this.vlayout = JSON.parse(localStorage.vlayout) | ||
18 | } | ||
19 | |||
13 | this.checkOffline(); | 20 | this.checkOffline(); |
14 | that.getConfig().then(function (config) { | 21 | that.getConfig().then(function (config) { |
15 | that.config = config; | 22 | that.config = config; |
@@ -23,13 +30,6 @@ const app = new Vue({ | |||
23 | } | 30 | } |
24 | }, false); | 31 | }, false); |
25 | }, | 32 | }, |
26 | computed: { | ||
27 | isDark: function() { | ||
28 | return this.overrideDark !== null | ||
29 | ? this.overrideDark | ||
30 | : matchMedia("(prefers-color-scheme: dark)").matches; | ||
31 | } | ||
32 | }, | ||
33 | methods: { | 33 | methods: { |
34 | checkOffline: function () { | 34 | checkOffline: function () { |
35 | let that = this; | 35 | let that = this; |
@@ -53,8 +53,13 @@ const app = new Vue({ | |||
53 | }); | 53 | }); |
54 | }, | 54 | }, |
55 | toggleTheme: function() { | 55 | toggleTheme: function() { |
56 | this.overrideDark = !this.isDark; | 56 | this.isDark = !this.isDark; |
57 | } | 57 | localStorage.overrideDark = this.isDark; |
58 | }, | ||
59 | toggleLayout: function() { | ||
60 | this.vlayout = !this.vlayout; | ||
61 | localStorage.vlayout = this.vlayout; | ||
62 | }, | ||
58 | } | 63 | } |
59 | }); | 64 | }); |
60 | 65 | ||