vscode/build/builtin/main.js

34 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-01-30 05:04:27 +08:00
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
2021-01-13 17:48:04 +08:00
const { app, BrowserWindow, ipcMain, dialog } = require('electron');
2018-01-30 05:04:27 +08:00
const url = require('url');
const path = require('path');
let window = null;
2021-01-13 17:48:04 +08:00
ipcMain.handle('pickdir', async () => {
const result = await dialog.showOpenDialog(window, {
title: 'Choose Folder',
properties: ['openDirectory']
});
if (result.canceled || result.filePaths.length < 1) {
return undefined;
}
return result.filePaths[0];
});
2018-01-30 05:04:27 +08:00
app.once('ready', () => {
window = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true, webviewTag: true, enableWebSQL: false, nativeWindowOpen: true } });
2018-01-30 05:04:27 +08:00
window.setMenuBarVisibility(false);
window.loadURL(url.format({ pathname: path.join(__dirname, 'index.html'), protocol: 'file:', slashes: true }));
// window.webContents.openDevTools();
window.once('closed', () => window = null);
});
2020-05-28 03:47:39 +08:00
app.on('window-all-closed', () => app.quit());