-
Notifications
You must be signed in to change notification settings - Fork 9
/
exemple.js
118 lines (94 loc) · 3.06 KB
/
exemple.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
const { app, ipcMain } = require('electron');
const { PARAMS, VALUE, MicaBrowserWindow, IS_WINDOWS_11, WIN10 } = require('./main.js');
const path = require('path');
app.on('ready', () => {
const win = new MicaBrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
show: false,
// frame: false, // -> now work, you can remove the frame properly !!
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
win.setLightTheme();
if (IS_WINDOWS_11)
win.setMicaTabbedEffect();
else
win.setCustomEffect(WIN10.ACRYLIC, '#401896', .2);
// win.alwaysFocused(true); // -> allows you to keep the mica effects even if the window is no focus (decrease performance)
win.loadFile(path.join(__dirname, 'files', 'index.html'));
win.webContents.once('dom-ready', () => {
win.show();
});
// Change theme
ipcMain.on('theme', (evt, newValue) => {
switch (newValue) {
case VALUE.THEME.AUTO:
win.setAutoTheme();
break
case VALUE.THEME.LIGHT:
win.setLightTheme();
break
case VALUE.THEME.DARK:
win.setDarkTheme();
break
}
});
// Change effect
ipcMain.on('effect', (evt, newParams) => {
switch (newParams) {
case PARAMS.BACKGROUND.MICA:
win.setMicaEffect();
break
case PARAMS.BACKGROUND.TABBED_MICA:
win.setMicaTabbedEffect();
break
case PARAMS.BACKGROUND.ACRYLIC:
win.setMicaAcrylicEffect();
break
}
});
// apply effect (corner, background-color, ...)
ipcMain.on('params', (evt, params, value) => {
switch (params) {
case PARAMS.CORNER:
switch (value) {
case VALUE.CORNER.ROUND:
win.setRoundedCorner();
break
case VALUE.CORNER.ROUNDSMALL:
win.setSmallRoundedCorner();
break
case VALUE.CORNER.DONOTROUND:
win.setSquareCorner();
break
}
break
case PARAMS.BORDER_COLOR:
win.setBorderColor(value);
break
case PARAMS.CAPTION_COLOR:
win.setCaptionColor(value);
break
case PARAMS.TEXT_COLOR:
win.setTitleTextColor(value);
break
case 10:
switch (value) {
case 0:
win.setTransparent();
break
case 1:
win.setBlur();
break
case 2:
win.setAcrylic();
break
}
break
}
});
});