-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
config.js
79 lines (63 loc) · 1.89 KB
/
config.js
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
var Config = require('electron-config');
var instance,
path = '';
if (typeof __dirname !== 'undefined') {
path = __dirname;
}
/*
* Configs that should be saved locally must be listed here
* */
var userPreferences = {
alwaysOnTop : true,
windowPosition : 'trayCenter',
userAgent : 'Mozilla/5.0 (iPad; CPU OS 9_0 like Mac OS X) AppleWebKit/601.1.17 (KHTML, like Gecko) Version/8.0 Mobile/13A175 Safari/600.1.',
globalShortcuts : true
};
var defaults = {
showOnRightClick : false,
externalLinks : false,
icon : path + '/icons/logo-icon-black-and-white/icon.iconset/icon_16x16.png',
iconPressed : path + '/icons/logo-icon-black-and-white-inverse/icon.iconset/icon_16x16.png',
width : 400,
height : 400,
preloadWindow : true,
showDockIcon : false
};
function AppConfig() {
var config = new Config();
if (typeof config.store === 'object') {
if (Object.keys(config.store).length !== Object.keys(userPreferences).length) {
for (var key in config.store) {
if (config.has(key)) {
if (!userPreferences.hasOwnProperty(key)) {
config.delete(key);
}
}
}
}
/*
* Save config file locally into config.json
* */
config.set(Object.assign(userPreferences, config.store));
}
this.config = config;
Object.defineProperty(this, 'store', {
get : function () {
return {
all : Object.assign(defaults, config.store),
userPreferences : config.store,
defaults : defaults
}
}
});
}
AppConfig.prototype = {
update : function (config) {
this.config.set(config);
}
};
var getInstance = function () {
instance = instance || new AppConfig();
return instance;
};
module.exports = getInstance();