当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript BrowserWindow.getAllWindows方法代码示例

本文整理汇总了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];
}
开发者ID:Real-Currents,项目名称:brackets,代码行数:7,代码来源:shell.ts

示例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());
  }
});
开发者ID:nteract,项目名称:nteract,代码行数:25,代码来源:index.ts

示例3: function

app.on("before-quit", function (event) {
    if (!windowAllClosed) {
        event.preventDefault();
        const windows = BrowserWindow.getAllWindows();
        windows.forEach((win) => win.close());
    }
});
开发者ID:zaggino,项目名称:brackets-electron,代码行数:7,代码来源:main.ts

示例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);
};
开发者ID:foxable,项目名称:app-manager,代码行数:7,代码来源:forwardToRenderer.ts

示例5: notify

function notify(title: string, message: string) {
  let windows = BrowserWindowElectron.getAllWindows()
  if (windows.length == 0) {
    return
  }

  windows[0].webContents.send("notify", title, message)
}
开发者ID:agozie,项目名称:onshape-desktop-shell,代码行数:8,代码来源:AppUpdater.ts

示例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);
     }
   };
 })
开发者ID:chauey,项目名称:ngrev,代码行数:10,代码来源:application_menu_template.ts

示例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()
  }
}
开发者ID:haimich,项目名称:billy,代码行数:14,代码来源:windows.ts

示例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();
     }
 }
开发者ID:Zzzen,项目名称:YAP,代码行数:14,代码来源:menuTemplate.ts

示例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)
  }
}
开发者ID:malept,项目名称:electron,代码行数:15,代码来源:window-helpers.ts

示例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;
}
开发者ID:rhysd,项目名称:Tui,代码行数:15,代码来源:default_menu.ts


注:本文中的electron.BrowserWindow.getAllWindows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。