This repository was archived by the owner on Jun 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.js
More file actions
89 lines (86 loc) · 2.59 KB
/
Copy pathsettings.js
File metadata and controls
89 lines (86 loc) · 2.59 KB
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
const { ipcRenderer } = require('electron');
/**
* Try to get key from object, but return fallback if not available.
* @param {(object|array)} obj - The object (or arrays)
* @param {(string|number)} key - The key (can be a number in the case of an array)
* @param {any} fallback - Fallback value if the key is not present in the object.
*/
const fallbackRef = (obj, key, fallback) => Object.prototype.hasOwnProperty.call(obj, key) ? obj[key] : fallback;
const vm = new Vue({
el: '#vue-container',
data: {
configObject: ipcRenderer.sendSync('getValue', 'configObject'),
currentPage: 'Interface'
},
computed: {
saveWidths: {
get: function () {
return !fallbackRef(this.configObject, 'noSaveWidths', false);
},
set: function (newVal) {
this.configObject.noSaveWidths = !newVal;
}
},
offerPrevLocation: {
get: function () {
return fallbackRef(this.configObject, 'offerPrevLocation', true);
},
set: function (newVal) {
this.configObject.offerPrevLocation = newVal;
}
},
resumeSessionOnRestart: {
get: function () {
return fallbackRef(this.configObject, 'resumeSessionOnRestart', false);
},
set: function (newVal) {
this.configObject.resumeSessionOnRestart = newVal;
}
},
slideshowInterval: {
get: function () {
return fallbackRef(this.configObject, 'slideshowInterval', 1000) * 0.001;
},
set: function (newVal) {
this.configObject.slideshowInterval = newVal * 1000;
}
},
endSlideshowOnFSExit: {
get: function () {
return fallbackRef(this.configObject, 'endSlideshowOnFSExit', true);
},
set: function (newVal) {
this.configObject.endSlideshowOnFSExit = newVal;
}
},
stopSlideshowAtEnd: {
get: function () {
return fallbackRef(this.configObject, 'stopSlideshowAtEnd', false);
},
set: function (newVal) {
this.configObject.stopSlideshowAtEnd = newVal;
}
}
},
components: {
'nav-sidebar': {
data: () => ({
pages: [
'Interface',
'General',
'Slideshow'
]
}),
props: ['currentPage'],
template: '<ul id="nav-sidebar"><li v-for="item in pages" @click="openSelf(item)" :data-active="item === currentPage">{{ item }}</li></ul>',
methods: {
openSelf: function (page) {
this.$emit('update:currentPage', page);
}
}
}
}
});
window.onbeforeunload = function () {
ipcRenderer.sendSync('storeValue', ['configObject', vm.configObject]);
};