forked from kesavan272006/ChronOs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
205 lines (192 loc) · 6.16 KB
/
main.js
File metadata and controls
205 lines (192 loc) · 6.16 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import { app, BrowserWindow, ipcMain, shell } from 'electron';
import path from 'path';
import { fileURLToPath } from 'url';
import { existsSync } from 'fs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const isDev = !app.isPackaged;
const appMap = {
'chrome': 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
'browser': 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
'firefox': 'C:\\Program Files\\Mozilla Firefox\\firefox.exe',
'edge': 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe',
'opera': 'C:\\Program Files\\Opera\\launcher.exe',
'brave': 'C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe',
'safari': 'C:\\Program Files\\Safari\\Safari.exe', // If installed on Windows
'vivaldi': 'C:\\Program Files\\Vivaldi\\Application\\vivaldi.exe',
'http': 'http://',
'https': 'https://',
'whatsapp': 'whatsapp://',
'discord': 'discord://',
'slack': 'slack://',
'teams': 'msteams://',
'zoom': 'zoommtg://',
'skype': 'skype://',
'telegram': 'tg://',
'signal': 'sgnl://',
'viber': 'viber://',
'messenger': 'fb-messenger://',
'outlook': 'outlook://',
'thunderbird': 'thunderbird://',
'word': 'winword.exe',
'excel': 'excel.exe',
'powerpoint': 'powerpnt.exe',
'ppt': 'powerpnt.exe',
'access': 'msaccess.exe',
'publisher': 'mspub.exe',
'onenote': 'onenote.exe',
'outlook': 'outlook.exe',
'project': 'winproj.exe',
'visio': 'visio.exe',
'notepad': 'notepad.exe',
'editor': 'notepad.exe',
'notepad++': 'C:\\Program Files\\Notepad++\\notepad++.exe',
'wordpad': 'write.exe',
'calculator': 'calc.exe',
'calc': 'calc.exe',
'paint': 'mspaint.exe',
'photoshop': 'photoshop.exe',
'illustrator': 'illustrator.exe',
'acrobat': 'acrobat.exe',
'reader': 'AcroRd32.exe',
'pdf': 'AcroRd32.exe',
'vlc': 'C:\\Program Files\\VideoLAN\\VLC\\vlc.exe',
'mediaplayer': 'wmplayer.exe',
'itunes': 'iTunes.exe',
'spotify': 'spotify.exe',
'winamp': 'winamp.exe',
'quicktime': 'quicktimeplayer.exe',
'vscode': 'code.exe',
'visualstudio': 'devenv.exe',
'eclipse': 'eclipse.exe',
'intellij': 'idea.exe',
'pycharm': 'pycharm.exe',
'webstorm': 'webstorm.exe',
'atom': 'atom.exe',
'sublime': 'sublime_text.exe',
'git': 'git-bash.exe',
'cmd': 'cmd.exe',
'powershell': 'powershell.exe',
'terminal': 'wt.exe',
'explorer': 'explorer.exe',
'7zip': '7zFM.exe',
'winrar': 'winrar.exe',
'winzip': 'winzip32.exe',
'dropbox': 'dropbox.exe',
'googledrive': 'googledrivesync.exe',
'onedrive': 'onedrive.exe',
'steam': 'steam.exe',
'epic': 'EpicGamesLauncher.exe',
'origin': 'Origin.exe',
'battlenet': 'Battle.net.exe',
'ubisoft': 'upc.exe',
'remote': 'mstsc.exe', // Remote Desktop
'anydesk': 'anydesk.exe',
'teamviewer': 'teamviewer.exe',
'antivirus': 'msseces.exe', // Windows Defender
'avast': 'avastui.exe',
'avg': 'avgui.exe',
'norton': 'norton.exe',
'malwarebytes': 'mbam.exe',
'control': 'control.exe', // Control Panel
'taskmgr': 'taskmgr.exe', // Task Manager
'regedit': 'regedit.exe', // Registry Editor
'charmap': 'charmap.exe', // Character Map
'snippingtool': 'snippingtool.exe',
'facebook': 'facebook://',
'twitter': 'twitter://',
'instagram': 'instagram://',
'linkedin': 'linkedin://',
'reddit': 'reddit://',
'pinterest': 'pinterest://',
'tiktok': 'tiktok://',
'youtube': 'youtube://',
'adobe': 'acrobat.exe',
'autocad': 'acad.exe',
'blender': 'blender.exe',
'lightroom': 'lightroom.exe',
'premiere': 'premiere.exe',
'aftereffects': 'afterfx.exe',
'illustrator': 'illustrator.exe',
'coreldraw': 'coreldraw.exe',
'maya': 'maya.exe',
'3dsmax': '3dsmax.exe',
'solidworks': 'slwworks.exe',
'virtualbox': 'virtualbox.exe',
'vmware': 'vmware.exe',
'defrag': 'dfrgui.exe',
'diskcleanup': 'cleanmgr.exe',
'dxdiag': 'dxdiag.exe',
'msconfig': 'msconfig.exe',
'services': 'services.msc',
'eventviewer': 'eventvwr.exe',
};
function createWindow() {
const win = new BrowserWindow({
width: 1000,
height: 700,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true,
sandbox: true,
nodeIntegration: false
},
});
if (isDev) {
win.loadURL('http://localhost:5173');
win.webContents.openDevTools();
} else {
const indexPath = path.join(__dirname, 'dist', 'index.html');
if (existsSync(indexPath)) {
win.loadFile(indexPath);
}
}
}
app.whenReady().then(() => {
// Enhanced application opening handler
ipcMain.handle('open-application', async (event, appName) => {
try {
console.log(`Main: Received request to open '${appName}'`);
// Normalize the app name
const normalized = appName.replace(/^(the|my|our)\s+/i, '').trim().toLowerCase();
console.log(`Normalized app name: ${normalized}`);
// Find the best matching app key
const appKey = Object.keys(appMap).find(key =>
normalized === key.toLowerCase() || normalized.includes(key.toLowerCase())
);
const appPath = appKey ? appMap[appKey] : normalized;
console.log(`Resolved path: ${appPath}`);
// Handle different types of paths
if (appPath.startsWith('http://') || appPath.startsWith('https://') || appPath.includes('://')) {
console.log('Opening external URL');
await shell.openExternal(appPath);
return { success: true, appName };
} else {
console.log('Opening path');
const result = await shell.openPath(appPath);
if (result) {
return {
success: false,
error: `Failed to open ${appName}. Error: ${result}`,
appName
};
}
return { success: true, appName };
}
} catch (error) {
console.error('Error in open-application handler:', error);
return {
success: false,
error: error.message || 'An unexpected error occurred',
appName
};
}
});
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});