-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathpatch.main.js
84 lines (80 loc) · 3.36 KB
/
patch.main.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
define(['vs/platform/windows/electron-main/windowImpl', 'vs/platform/windows/electron-main/windows', 'electron', 'vs/modules/utils'], (windowImpl, windows, electron, utils) => {
function findeCodeWindow() {
for (const key in windowImpl) { if (windowImpl[key] instanceof Function && windowImpl[key].toString().startsWith('class extends')) { return key; } }
}
const codeWindowKey = 'CodeWindow' in windowImpl ? 'CodeWindow' : findeCodeWindow();
function findDefaultBrowserWindowOptions() {
for (const key in windows) { if (windows[key] instanceof Function && windows[key].toString?.() !== 'windowsMainService') { return key; } }
}
const defaultBrowserWindowOptionsKey = 'defaultBrowserWindowOptions' in windows ? 'defaultBrowserWindowOptions' : findDefaultBrowserWindowOptions();
if (codeWindowKey) {
windowImpl[codeWindowKey] = class CodeWindow extends windowImpl[codeWindowKey] {
constructor(
appConfig,
logService,
loggerMainService,
environmentMainService,
policyService,
userDataProfilesService,
fileService,
applicationStorageMainService,
storageMainService,
configurationService,
themeMainService,
workspacesManagementMainService,
backupMainService,
telemetryService,
dialogMainService,
lifecycleMainService,
productService,
protocolMainService,
windowsMainService,
stateService) {
try {
const config = (configurationService.getValue && configurationService.getValue('apc.electron')) || {};
const originalGetBackgroundColor = themeMainService?.getBackgroundColor?.bind(themeMainService);
if (originalGetBackgroundColor) {
themeMainService.getBackgroundColor = () => config.backgroundColor ?? originalGetBackgroundColor();
utils.override(electron.BrowserWindow, "setBackgroundColor", function (original, [color]) { });
utils.override(electron.BrowserWindow, "setTrafficLightPosition", function () { });
}
if (defaultBrowserWindowOptionsKey) {
const originalDefaultBrowserWindowOptions = windows[defaultBrowserWindowOptionsKey];
windows[defaultBrowserWindowOptionsKey] = (...args) => {
return { ...originalDefaultBrowserWindowOptions(...args), ...config };
};
}
else {
for (const key in config) {
Object.defineProperty(Object.prototype, key, {
get() { return config[key]; },
set() { },
configurable: true
});
}
}
super(...arguments);
for (const key in config) { delete Object.prototype[key]; }
} catch (error) {
console.log('***************');
console.log('***************');
console.log('***************');
console.log(error);
console.log('***************');
console.log('***************');
console.log('***************');
super(...arguments);
}
}
};
}
else {
console.log('***************');
console.log('***************');
console.log('***************');
console.log('not found windowImpl.CodeWindow');
console.log('***************');
console.log('***************');
console.log('***************');
}
});