本文整理汇总了TypeScript中browser-window.loadUrl函数的典型用法代码示例。如果您正苦于以下问题:TypeScript loadUrl函数的具体用法?TypeScript loadUrl怎么用?TypeScript loadUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loadUrl函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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;
});
});
示例2: 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));
示例3: 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;
});
});
示例4: 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;
});
});
示例5: 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;
});
});
示例6: BrowserWindow
app.on('ready', () => {
let win = new BrowserWindow({
width: app_config.width,
height: app_config.height,
});
win.loadUrl(index_html);
let fetcher = new TrendFetcher(
win.webContents,
app_config.languages,
app_config.proxy || undefined
);
auth.getToken().then((access_token: string) => {
fetcher.setToken(access_token);
});
let app_icon = new Tray(normal_icon);
const context_menu = Menu.buildFromTemplate([
{
label: 'Show Window',
click: () => win.show(),
},
{
label: 'Force Update',
click: () => fetcher.doScraping(),
},
{
label: 'Quit',
accelerator: 'CmdOrCtrl+Q',
click: () => app.quit(),
}
]);
app_icon.setContextMenu(context_menu);
ipc.on('renderer-ready', () => fetcher.start());
ipc.on('force-update-repos', () => fetcher.doScraping());
ipc.on('tray-icon-normal', () => app_icon.setImage(normal_icon));
ipc.on('tray-icon-notified', () => app_icon.setImage(notified_icon));
ipc.on('start-github-login', () => doLogin(fetcher, win.webContents));
if (app_config.hot_key !== '') {
shortcut.register(
app_config.hot_key,
() => win.isVisible() ? win.hide() : win.show()
);
}
});
示例7: 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();
});
示例8: 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;
});
});
示例9: invokeLangPicker
// Note: Ensure app is already ready
export default function invokeLangPicker(colors: {[lang: string]: string}) {
let picker_win = new BrowserWindow({
width: 600,
height: 800,
});
picker_win.loadUrl('file://' + path.join(__dirname, '..', '..', 'langpicker.html'));
picker_win.on('closed', function(){ picker_win = null; });
picker_win.webContents.on('dom-ready', () => picker_win.webContents.send('lang-picker-data', colors));
return new Promise(resolve => {
ipc.on('picked-langs', (event: Event, langs: string[]) => {
console.log('picked!: ' + JSON.stringify(langs));
if (langs.length === 0) {
langs.push('all');
}
resolve(langs);
});
}).catch(err => {
console.log(err);
return ['all']; // Fallback
});
}
示例10: BrowserWindow
app.on('ready', () => {
var mainWindow = new BrowserWindow({ width: 800, height: 600 });
mainWindow.on('closed', () => { mainWindow = null; });
mainWindow.openDevTools();
mainWindow.loadUrl('file://' + __dirname + '/../index.html');
});