本文整理汇总了TypeScript中browser-window.on函数的典型用法代码示例。如果您正苦于以下问题:TypeScript on函数的具体用法?TypeScript on怎么用?TypeScript on使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了on函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getMainWindow
function getMainWindow() {
const workAreaSize = require('screen').getPrimaryDisplay().workAreaSize;
if (!browserWindow) {
browserWindow = new BrowserWindow({
'web-preferences': {
'experimental-features': true,
'experimental-canvas-features': true,
'subpixel-font-scaling': true,
'overlay-scrollbars': true
},
resizable: true,
'min-width': 500,
'min-height': 300,
width: workAreaSize.width,
height: workAreaSize.height,
show: false
});
browserWindow.loadURL('file://' + __dirname + '/../views/index.html');
menu.setMenu(app, browserWindow);
browserWindow.on('closed', (): void => browserWindow = null);
browserWindow.webContents.on('did-finish-load', () => {
browserWindow.show();
browserWindow.focus();
});
}
return browserWindow;
}
示例2: function
app.on('ready', function() {
mainWindow = new BrowserWindow({width: 800, height: 600});
mainWindow.loadURL('file://' + __dirname + '/../html/index.html');
mainWindow.on('closed', function() {
mainWindow = null;
});
})
示例3: Promise
return new Promise((resolve, reject) => {
let auth_win = new BrowserWindow({
width: 800,
height: 600,
'node-integration': false,
'web-preferences': {
'node-integration': false,
'web-security': true,
}
});
auth_win.on('close', function(){ auth_win = null; });
const resolveCode = (event: Event, url: string) => {
const raw_code = /code=([^&]*)/.exec(url) || null;
const code = (raw_code && raw_code.length > 1) ? raw_code[1] : null;
const error = /\?error=(.+)$/.exec(url);
if (error) {
event.preventDefault();
console.log('login failed!');
setTimeout(() => auth_win.close(), 0);
reject(error);
} else if (code) {
setTimeout(() => auth_win.close(), 0);
resolve(code);
}
}
auth_win.webContents.on('will-navigate', (e: Event, u: string) => resolveCode(e, u));
auth_win.webContents.on('did-finish-load', (e: Event) => resolveCode(e, auth_win.webContents.getUrl()));
const url = 'https://github.com/login/oauth/authorize?client_id=' + CLIENT_ID;
auth_win.loadUrl(url);
}).then(this.authenticate.bind(this));
示例4: BrowserWindow
app.on('ready', () => {
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600});
// and load the index.html of the app.
var [_, _, testName] = process.argv;
if (testName === "index") {
mainWindow.loadUrl(`file://${__dirname}/index.html`);
} else {
var fs = require('fs');
fs.readFile(__dirname + "/ui-test.template.html", 'utf8', (err,data) => {
var result = data.replace("$$ENTER_HERE$$", testName);
fs.writeFile(`${__dirname}/ui-test-${testName}.html`, result, 'utf8', (err) => {
mainWindow.loadUrl(`file://${__dirname}/ui-test-${testName}.html`);
});
});
}
// Open the devtools.
// mainWindow.openDevTools();
// 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.
mainWindow = null;
});
});
示例5: getMainWindow
function getMainWindow(): Electron.BrowserWindow {
const screen: Electron.Screen = require("screen");
const workAreaSize = screen.getPrimaryDisplay().workAreaSize;
if (!browserWindow) {
let options: Electron.BrowserWindowOptions = {
webPreferences: {
experimentalFeatures: true,
experimentalCanvasFeatures: true,
},
titleBarStyle: "hidden",
resizable: true,
minWidth: 500,
minHeight: 300,
width: workAreaSize.width,
height: workAreaSize.height,
show: false,
};
browserWindow = new browserWindowConstructor(options);
browserWindow.loadURL("file://" + __dirname + "/../views/index.html");
menu.setMenu(app, browserWindow);
browserWindow.on("closed", (): void => browserWindow = undefined)
.on("focus", (): void => app.dock && app.dock.setBadge(""));
browserWindow.webContents.on("did-finish-load", () => {
browserWindow.show();
browserWindow.focus();
});
}
return browserWindow;
}
示例6: function
app.on('ready', function() {
// ブラウザ(Chromium)の起動, 初期画面のロード
mainWindow = new BrowserWindow({width: 800, height: 600});
mainWindow.loadUrl('file://' + __dirname + '/../index.html');
mainWindow.on('closed', function() {
mainWindow = null;
});
});
示例7: function
app.on('ready', function () {
mainWindow = new BrowserWindow({
'width': 601,
'height': 600,
'min-width': 601,
'min-height': 600,
frame: false
});
mainWindow.loadUrl(`file://${__dirname}/windows/index.html`);
// mainWindow.openDevTools();
mainWindow.on('closed', function () {
mainWindow = null;
});
});
示例8: function
app.on('ready', function() {
// Create the browser window.
mainWindow = new BrowserWindow({ width: 800, height: 600 });
// and load the index.html of the app.
mainWindow.loadUrl('file://' + __dirname + '/../lib/views/index.html');
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// 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.
mainWindow = null;
});
});
示例9: require
app.on('ready', () => {
const display_size = require('screen').getPrimaryDisplay().workAreaSize;
let win = new BrowserWindow({
width: display_size.width,
height: display_size.height,
'title-bar-style': 'hidden-inset',
});
win.on('closed', () => {
win = null;
app.quit();
});
win.loadUrl(index_html);
setMenu();
});
示例10: function
app.on('ready', function () {
mainWindow = new BrowserWindow({
width: 1024,
height: 768,
resizable: true
});
shell = new shellModule.ShellModel(utils.getUserHome());
shell.registerCallback();
// mainWindow.openDevTools();
mainWindow.loadUrl(`file://${__dirname}/../static/index.html`);
mainWindow.on('closed', function () {
// deref the window
// for multiple windows store them in an array
shell = null;
mainWindow = null;
});
});