Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/builtin/main.js
3520 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
// @ts-check
6
7
const { app, BrowserWindow, ipcMain, dialog } = require('electron');
8
const url = require('url');
9
const path = require('path');
10
11
let window = null;
12
13
ipcMain.handle('pickdir', async () => {
14
const result = await dialog.showOpenDialog(window, {
15
title: 'Choose Folder',
16
properties: ['openDirectory']
17
});
18
19
if (result.canceled || result.filePaths.length < 1) {
20
return undefined;
21
}
22
23
return result.filePaths[0];
24
});
25
26
app.once('ready', () => {
27
window = new BrowserWindow({
28
width: 800,
29
height: 600,
30
webPreferences: {
31
nodeIntegration: true,
32
contextIsolation: false,
33
enableWebSQL: false
34
}
35
});
36
window.setMenuBarVisibility(false);
37
window.loadURL(url.format({ pathname: path.join(__dirname, 'index.html'), protocol: 'file:', slashes: true }));
38
// window.webContents.openDevTools();
39
window.once('closed', () => window = null);
40
});
41
42
app.on('window-all-closed', () => app.quit());
43
44