本文整理汇总了TypeScript中electron.BrowserWindow.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BrowserWindow.on方法的具体用法?TypeScript BrowserWindow.on怎么用?TypeScript BrowserWindow.on使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.BrowserWindow
的用法示例。
在下文中一共展示了BrowserWindow.on方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
app.on("ready", function () {
mainWindow = new BrowserWindow({ width: 600, height: 500});
mainWindow.loadURL("file://" + __dirname + "/index.html");
mainWindow.on("closed", function () {
mainWindow = null;
});
});
示例2: BrowserWindow
ipcMain.on('new-file', () => {
newFileWindow = new BrowserWindow({
width: 500,
height: 300,
modal: true,
parent: mainWindow,
minimizable: false,
resizable: false,
show: false
});
newFileWindow.loadURL(`file://${__dirname}/../../resources/views/newFile.html`);
newFileWindow.setMenu(null);
newFileWindow.on('ready-to-show', () => {
newFileWindow.show();
});
newFileWindow.on('closed', function () {
newFileWindow = null;
});
});
示例3: bootstrapAppWindow
function bootstrapAppWindow() {
mainWindow = createMainWindow();
// and load the index.html of the app.
mainWindow.loadURL('http://localhost:3000');
// Open the DevTools.
// mainWindow.webContents.openDevTools({ mode: 'right' });
mainWindow.webContents.openDevTools({ mode: 'undocked' });
// Emitted when the window is closed.
mainWindow.on('closed', () => (mainWindow = null));
}
示例4: BrowserWindow
app.on('ready', () => {
// win = new BrowserWindow({ width: 800, height: 600, show: false ,autoHideMenuBar: true});
win = new BrowserWindow();
win.setMenuBarVisibility(false);
win.webContents.openDevTools();
// win.setVisibleOnAllWorkspaces(false);
win.on('closed', () => {
win = null;
});
win.loadURL('file:///' + path.join(__dirname, '../pages/index.html'));
// win.show();
});
示例5: createWindow
function createWindow(): void {
mainWindow = new Electron.BrowserWindow({
fullscreen: true,
webPreferences: {
preload: `${__dirname}/preload.js`
}
});
mainWindow.loadURL(`file://${__dirname}/index.html`);
mainWindow.on('close', () => {
mainWindow = null;
});
}
示例6: function
app.on('ready', function() {
// 新規ウィンドウ作成
mainWindow = new BrowserWindow({ width: 800, height: 600 });
// index.htmlを開く
mainWindow.loadURL('file://' + __dirname + '/index.html');
// ウィンドウが閉じられたら、ウィンドウへの参照を破棄する。
mainWindow.on('closed', function() {
mainWindow = null;
});
});
示例7: BrowserWindow
ipcMain.on('color-picker', (event, details) => {
colorWindow = new BrowserWindow({
width: 550,
height: 365,
show: false,
darkTheme: true,
hasShadow: true,
parent: mainWindow,
resizable: false
});
colorWindow.loadURL(`file://${__dirname}/resources/views/color.html`);
colorWindow.setMenu(null);
// Close the window when it is no longer focused
colorWindow.on('blur', () => { colorWindow.close(); });
// Display window when render is complete
colorWindow.on('ready-to-show', () => {
colorWindow.show();
colorWindow.webContents.send('init', details);
// colorWindow.webContents.openDevTools();
});
});
示例8:
var createWindow = () => {
window = new Electron.BrowserWindow({
width: 1400,
height: 800,
title: 'Hello World'
});
window.loadURL(`file://${path.join(appConfig.APP_TEMPLATE_PATH, '/index.html')}`);
// window.webContents.openDevTools();
window.on('closed', () => {
window = null;
});
};
示例9: createWindow
// tslint:disable-next-line:only-arrow-functions
function createWindow() {
tray = new Tray(`${__dirname}/icon-menu-play.png`);
tray.setTitle('...');
/* const contextMenu = Menu.buildFromTemplate([
{ label: 'Item1', type: 'radio' },
{ label: 'Item2', type: 'radio' },
{ label: 'Item3', type: 'radio', checked: true },
{ label: 'Item4', type: 'radio' }
]);
tray.setToolTip('This is my application.');
tray.setContextMenu(contextMenu); */
const windowConfiguration = {
autoHideMenuBar: true,
// tslint:disable-next-line:no-magic-numbers
width: DEV_MODE ? 700 : 300,
// tslint:disable-next-line:no-magic-numbers
height: DEV_MODE ? 518 : 118,
};
if (process.platform === 'win32') {
// tslint:disable-next-line:no-magic-numbers
windowConfiguration.width *= 1.5;
// tslint:disable-next-line:no-magic-numbers
windowConfiguration.height *= 1.5;
}
// Create the browser window.
mainWindow = new BrowserWindow(windowConfiguration);
const mainUrl = process.env.MAIN_APP_URL || join('file://', __dirname, '/index.html');
console.log(`Loading: ${mainUrl}`);
mainWindow.loadURL(mainUrl);
if (DEV_MODE) {
console.log('Enable DevTools');
mainWindow.webContents.openDevTools({ detach: true });
}
// Open the DevTools.
// mainWindow.webContents.openDevTools({ detach: true });
// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
// tslint:disable-next-line:no-null-keyword
mainWindow = null;
});
}
示例10: Promise
return new Promise((resolve, reject) => {
let login_window = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
webSecurity: true,
nodeIntegration: false,
},
});
login_window.webContents.on('will-navigate', (event: Event, url: string) => {
event.preventDefault();
log.debug('Login window: will-navigate: ', url);
const match = url.match(/\?oauth_token=([^&]*)&oauth_verifier=([^&]*)/);
if (!match) {
return;
}
oauth.getOAuthAccessToken(request_token, request_token_secret, match[2], (err, token, token_secret) => {
log.debug('access token:', token);
if (err) {
setTimeout(() => login_window.close(), 0);
reject(err);
return;
}
const access = {
token,
token_secret,
};
resolve(access);
writeFile(config_path, JSON.stringify(access), e => {
if (e) {
log.warn('Failed to store tokens to a token.json', e);
}
login_window.close();
});
});
});
login_window.on('closed', () => {
login_window = null;
});
const login_url = `https://twitter.com/oauth/authenticate?oauth_token=${request_token}`;
log.debug('Start authentication:', login_url);
login_window.loadURL(login_url);
});