本文整理汇总了TypeScript中electron.remote.BrowserWindow.loadURL方法的典型用法代码示例。如果您正苦于以下问题:TypeScript remote.BrowserWindow.loadURL方法的具体用法?TypeScript remote.BrowserWindow.loadURL怎么用?TypeScript remote.BrowserWindow.loadURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.remote.BrowserWindow
的用法示例。
在下文中一共展示了remote.BrowserWindow.loadURL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: dispatchPublishGist
export function dispatchPublishGist(
ownProps: { contentRef: ContentRef },
store: DesktopStore,
_event: Event
) {
const state = store.getState();
const githubToken = state.app.get("githubToken");
// The simple case -- we have a token and can publish
if (githubToken != null) {
store.dispatch(actions.publishGist(ownProps));
return;
}
// If the Github Token isn't set, use our oauth server to acquire a token
// Because the remote object from Electron main <--> renderer can be "cleaned up"
// we re-require electron here and get the remote object
const remote = require("electron").remote;
// Create our oauth window
const win = new remote.BrowserWindow({
show: false,
webPreferences: { zoomFactor: 0.75 }
});
// TODO: This needs to be moved to an epic
win.webContents.on("dom-ready", () => {
// When we're at our callback code page, keep the page hidden
if (win.webContents.getURL().indexOf("callback?code=") !== -1) {
// Extract the text content
win.webContents.executeJavaScript(
"require('electron').ipcRenderer.send('auth', document.body.textContent);"
);
remote.ipcMain.on("auth", (_event: Event, auth: string) => {
try {
const accessToken = JSON.parse(auth).access_token;
store.dispatch(actions.setGithubToken(accessToken));
const notificationSystem = selectors.notificationSystem(state);
notificationSystem.addNotification({
title: "Authenticated",
message: "🔒",
level: "info"
});
// We are now authenticated and can finally publish
store.dispatch(actions.publishGist(ownProps));
} catch (e) {
store.dispatch(actions.coreError(e));
} finally {
win.close();
}
});
} else {
win.show();
}
});
win.loadURL("https://oauth.nteract.io/github");
}