-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.js
More file actions
95 lines (84 loc) · 2.23 KB
/
Copy pathconfig.js
File metadata and controls
95 lines (84 loc) · 2.23 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
90
91
92
93
94
95
const fs = require('fs');
const path = require('path');
class Config {
constructor() {
this.configPath = path.join(__dirname, 'settings.json');
this.defaults = {
windowOpacity: 100,
taskbarOpacity: 100,
blurEffect: 20,
globalOpacity: 100,
theme: 'midnight',
videoTheme: null,
themeOverlay: {
enabled: false,
intensity: 30,
blend: 'overlay'
},
videoOptimization: {
enabled: true,
playbackRate: 0.5,
blur: true,
blurAmount: 2
},
syntaxHighlighting: {
html: false,
css: false,
javascript: false,
cpp: false
}
};
this.settings = this.loadSettings();
}
loadSettings() {
try {
if (fs.existsSync(this.configPath)) {
const data = fs.readFileSync(this.configPath, 'utf8');
return { ...this.defaults, ...JSON.parse(data) };
}
} catch (error) {
console.error('Błąd podczas ładowania ustawień:', error);
}
return this.defaults;
}
saveSettings(settings) {
try {
fs.writeFileSync(this.configPath, JSON.stringify(settings, null, 2));
this.settings = settings;
} catch (error) {
console.error('Błąd podczas zapisywania ustawień:', error);
}
}
get(key) {
return this.settings[key];
}
set(key, value) {
this.settings[key] = value;
this.saveSettings(this.settings);
}
setNestedValue(parent, key, value) {
if (!this.settings[parent]) {
this.settings[parent] = {};
}
this.settings[parent][key] = value;
console.log(`Zapisuję ustawienie: ${parent}.${key} = ${value}`);
this.saveSettings(this.settings);
// Sprawdź, czy ustawienia zostały zapisane
const saved = this.loadSettings();
console.log('Aktualne ustawienia:', saved);
if (saved[parent]?.[key] !== value) {
console.error('Błąd zapisu ustawień!');
}
}
getVideoOptimization() {
return this.settings.videoOptimization || this.defaults.videoOptimization;
}
setVideoOptimization(options) {
this.settings.videoOptimization = {
...this.settings.videoOptimization,
...options
};
this.saveSettings(this.settings);
}
}
module.exports = new Config();