本文整理汇总了TypeScript中electron.BrowserWindow.getAllWindows方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BrowserWindow.getAllWindows方法的具体用法?TypeScript BrowserWindow.getAllWindows怎么用?TypeScript BrowserWindow.getAllWindows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.BrowserWindow
的用法示例。
在下文中一共展示了BrowserWindow.getAllWindows方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getMainWindow
export function getMainWindow(): Electron.BrowserWindow {
const wins = BrowserWindow.getAllWindows();
if (wins.length > 1) {
console.warn(`getMainWindow() -> ${wins.length} windows open`);
}
return wins[0];
}
示例2:
app.on("before-quit", e => {
// We use Electron's before-quit to give us a hook to into full app quit events,
// such as Command+Q on macOS.
// This is broken on Windows due to a bug in Electron; see #3549.
// For most Windows workflows the user will be closing individual notebook windows directly,
// so we just avoid this code path for now.
if (process.platform === "win32") {
return;
}
const windows = BrowserWindow.getAllWindows();
if (
// `win.close()` teardown is async, so `isVisible` is more reliable, see #3656
windows.filter(win => win.isVisible()).length > 0 &&
store.getState().get("quittingState") === QUITTING_STATE_NOT_STARTED
) {
e.preventDefault();
store.dispatch(setQuittingState(QUITTING_STATE_QUITTING));
// Trigger each windows' closeNotebookEpic. If and when all windows are closed,
// the window-all-closed event will fire and we will complete the quit action.
windows.forEach(win => win.close());
}
});
示例3: function
app.on("before-quit", function (event) {
if (!windowAllClosed) {
event.preventDefault();
const windows = BrowserWindow.getAllWindows();
windows.forEach((win) => win.close());
}
});
示例4: next
export const forwardToRenderer: Middleware = (store: MiddlewareAPI<AppState>) => (next: Dispatch<AppState>) => (action: AppAction) =>
{
const openWindows = BrowserWindow.getAllWindows();
openWindows.forEach(window => window.webContents.send(REDUX_SYNC, createLocalAction(action)));
return next(action);
};
示例5: notify
function notify(title: string, message: string) {
let windows = BrowserWindowElectron.getAllWindows()
if (windows.length == 0) {
return
}
windows[0].webContents.send("notify", title, message)
}
示例6: click
submenu: Object.keys(getConfig().themes || []).map(label => {
return {
label,
click() {
const window = BrowserWindow.getAllWindows()[0];
onThemeChange(label);
window.webContents.send(Message.ChangeTheme, label);
}
};
})
示例7: reload
export function reload(focusedWindow) {
if (focusedWindow) {
// on reload, start fresh and close any old
// open secondary windows
if (focusedWindow.id === 1) {
BrowserWindow.getAllWindows().forEach((win) => {
if (win.id > 1) {
win.close()
}
})
}
focusedWindow.reload()
}
}
示例8:
click: (item: Electron.MenuItem, focusedWindow: Electron.BrowserWindow) => {
if (focusedWindow) {
// on reload, start fresh and close any old
// open secondary windows
if (focusedWindow.id === 1) {
BrowserWindow.getAllWindows().forEach(function (win) {
if (win.id > 1) {
win.close();
}
});
}
focusedWindow.reload();
}
}
示例9: async
export const closeWindow = async (
window: BrowserWindow | null = null,
{ assertNotWindows } = { assertNotWindows: true }
) => {
if (window && !window.isDestroyed()) {
const isClosed = emittedOnce(window, 'closed')
window.setClosable(true)
window.close()
await isClosed
}
if (assertNotWindows) {
expect(BrowserWindow.getAllWindows()).to.have.lengthOf(0)
}
}
示例10: getWindow
function getWindow(win: Electron.BrowserWindow | null): Electron.BrowserWindow | null {
if (win && win.webContents) {
return win;
}
const wins = BrowserWindow.getAllWindows();
if (wins.length === 0) {
return null;
}
const w = wins[0];
w.focus();
if (!w.webContents) {
return null;
}
return w;
}