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


TypeScript app.on方法代码示例

本文整理汇总了TypeScript中electron.app.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript app.on方法的具体用法?TypeScript app.on怎么用?TypeScript app.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在electron.app的用法示例。


在下文中一共展示了app.on方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createWindow

    }

    if (win.isVisible()) {
      win.hide();
    } else {
      win.show();
    }
  });
}

try {
  // This method will be called when Electron has finished
  // initialization and is ready to create browser windows.
  // Some APIs can only be used after this event occurs.
  app.on("ready", () => {
    createWindow();
    createTray();
  });

  // Quit when all windows are closed.
  app.on("window-all-closed", () => {
    // On OS X it is common for applications and their menu bar
    // to stay active until the user quits explicitly with Cmd + Q
    if (process.platform !== "darwin") {
      app.quit();
    }
  });

  app.on("activate", () => {
    // On OS X it"s common to re-create a window in the app when the
    // dock icon is clicked and there are no other windows open.
    if (win == null) {
开发者ID:stargeizer,项目名称:noia-node-gui,代码行数:32,代码来源:main.ts

示例2: windowBounds

app.on("ready", () => {
    const bounds = windowBounds();

    let options: Electron.BrowserWindowOptions = {
        webPreferences: {
            experimentalFeatures: true,
            experimentalCanvasFeatures: true,
        },
        titleBarStyle: "hidden",
        resizable: true,
        minWidth: 500,
        minHeight: 300,
        width: bounds.width,
        height: bounds.height,
        x: bounds.x,
        y: bounds.y,
        show: false,
    };
    const browserWindow = new BrowserWindow(options);

    if (process.env.REACT_EXTENSION_PATH) {
        BrowserWindow.addDevToolsExtension(process.env.REACT_EXTENSION_PATH);
    }

    browserWindow.loadURL("file://" + __dirname + "/../views/index.html");
    menu.setMenu(app, browserWindow);

    browserWindow.on("focus", () => app.dock && app.dock.setBadge(""));

    browserWindow.webContents.on("did-finish-load", () => {
        browserWindow.show();
        browserWindow.focus();
    });

    app.on("open-file", (event, file) => browserWindow.webContents.send("change-working-directory", file));
});
开发者ID:Alubatm,项目名称:black-screen,代码行数:36,代码来源:Main.ts

示例3: Promise

 new Promise(resolve => app.on("ready", resolve)),
开发者ID:kyo-ago,项目名称:lifter,代码行数:1,代码来源:index.ts

示例4: ensureMainWindow

    {
      role: 'window',
      submenu: [
        { role: 'minimize' },
        { role: 'close' },
      ]
    },
  ]
  const menu = Menu.buildFromTemplate(template)
  Menu.setApplicationMenu(menu)
}

// Quit application when all windows are closed
app.on('window-all-closed', () => {
  // On macOS it is common for applications to stay open
  // until the user explicitly quits
  if (process.platform !== 'darwin') app.quit()
})

app.on('activate', () => {
  // On macOS it is common to re-create a window
  // even after all windows have been closed
  ensureMainWindow()
})

// Create main BrowserWindow when electron is ready
app.on('ready', () => {
  app.setName("Substudy")
  setMenu()
  mainWindow = createMainWindow()
})
开发者ID:emk,项目名称:substudy,代码行数:31,代码来源:index.ts

示例5: BrowserWindow

app.on('ready', () => {
    ////////////////////////////////////////////////////////////////////////////
    /// Setup the main window
    ////////////////////////////////////////////////////////////////////////////
    mainWindow = new BrowserWindow({
        width: 1024,
        height: 600,
        show: false
    });
    mainWindow.loadURL(`file://${__dirname}/../resources/views/index.html`);
    mainWindow.on('ready', () => {
        mainWindow.show();
    });
    mainWindow.on('ready-to-show', () => {
        mainWindow.show();
    });

    ////////////////////////////////////////////////////////////////////////////
    /// Register key bindings to the main window
    ////////////////////////////////////////////////////////////////////////////
    keybindings.forEach(binding => {
        globalShortcut.register(binding.key, () => {
            mainWindow.webContents.send(binding.command);
        });
    });

    require('./listeners/save')(mainWindow);
    require('./listeners/open')(mainWindow);
    require('./listeners/new')(mainWindow);
});
开发者ID:TheColorRed,项目名称:photo-editor,代码行数:30,代码来源:main.ts

示例6: registerProtocolForLinux

    start: (config) => {

        // Register protocol for linux (update .desktop and mimeapps.list files)
        if (process.platform === "linux") {
            registerProtocolForLinux();
        }

        // Protocol handler for darwin
        app.setAsDefaultProtocolClient("rabix-composer");
        app.on("open-url", function (event, url) {
            openExternalFiles(url);
            focusMainWindow();
        });

        // File handler for darwin
        app.on("open-file", function (event, filePath) {
            openExternalFiles(filePath);
            focusMainWindow();
        });

        // Initial File handler for win32 and linux
        if (process.platform === "win32" || process.platform === "linux") {
            openExternalFiles(...getFilePathsFromArgs(process.argv.slice(1)));
        }

        // File/Protocol handler for win32 and linux
        const runningInstanceExists = app.makeSingleInstance((argv) => {
            // Someone tried to run a second instance, we should focus our window.

            // Protocol handler for win32 and linux
            // argv: An array of the second instance’s (command line / deep linked) arguments
            if (process.platform === "win32" || process.platform === "linux") {
                // Keep only command line / deep linked arguments
                openExternalFiles(...getFilePathsFromArgs(argv.slice(1)));
            }

            focusMainWindow();
        });

        // If there is already a running instance of Composer, shut down this new one and let the existing one handle incoming data
        if (runningInstanceExists) {
            app.quit();
            return
        }

        // This method will be called when Electron has finished
        // initialization and is ready to create browser windows.
        // Some APIs can only be used after this event occurs.
        app.on("ready", () => start(config));

        // Quit when all windows are closed.
        app.on("window-all-closed", () => {

            // On macOS it is common for applications and their menu bar
            // to stay active until the user quits explicitly with Cmd + Q
            // if (process.platform !== "darwin") {
            //     app.quit();
            // }

            app.quit();

        });

        // This is not needed unless we add functionality again of re-creating window from menu bar (macOS)
        // app.on("activate", () => {
        //     // On macOS it's common to re-create a window in the App when the
        //     // dock icon is clicked and there are no other windows open.
        //     if (win === null) {
        //         start(config);
        //     }
        // });

    }
开发者ID:hmenager,项目名称:composer,代码行数:73,代码来源:main.common.ts

示例7: async

  watcher.on(actions.preboot, async (store, action) => {
    let dispatchedBoot = false;

    let t1 = Date.now();
    try {
      const system: ISystemState = {
        appName: app.getName(),
        appVersion: app.getVersion().replace(/\-.*$/, ""),
        platform: os.itchPlatform(),
        arch: os.arch(),
        macos: os.platform() === "darwin",
        windows: os.platform() === "win32",
        linux: os.platform() === "linux",
        sniffedLanguage: app.getLocale(),
        homePath: app.getPath("home"),
        userDataPath: app.getPath("userData"),
        proxy: null,
        proxySource: null,
        quitting: false,
      };
      store.dispatch(actions.systemAssessed({ system }));

      try {
        await loadPreferences(store);
      } catch (e) {
        logger.error(
          `Could not load preferences: ${e.stack || e.message || e}`
        );
      }

      try {
        app.on(
          "certificate-error",
          (ev, webContents, url, error, certificate, callback) => {
            // do not trust
            callback(false);

            logger.error(
              `Certificate error: ${error} issued by ${
                certificate.issuerName
              } for ${certificate.subjectName}`
            );

            // TODO: that's super annoying as a modal.

            store.dispatch(
              actions.openModal(
                modalWidgets.naked.make({
                  window: "root",
                  title: `Certificate error: ${error}`,
                  message:
                    `There was an error with the certificate for ` +
                    `\`${certificate.subjectName}\` issued by \`${
                      certificate.issuerName
                    }\`.\n\n` +
                    `Please check your proxy configuration and try again.`,
                  detail: `If you ignore this error, the rest of the app might not work correctly.`,
                  buttons: [
                    {
                      label: "Ignore and continue",
                      className: "secondary",
                    },
                    {
                      label: ["menu.file.quit"],
                      action: actions.quit({}),
                    },
                  ],
                  widgetParams: null,
                })
              )
            );
          }
        );
        logger.debug(`Set up certificate error handler`);
      } catch (e) {
        logger.error(
          `Could not set up certificate error handler: ${e.stack ||
            e.message ||
            e}`
        );
      }

      try {
        const { session } = require("electron");
        const netSession = session.fromPartition(NET_PARTITION_NAME, {
          cache: false,
        });

        const envSettings: string =
          process.env.https_proxy ||
          process.env.HTTPS_PROXY ||
          process.env.http_proxy ||
          process.env.HTTP_PROXY;

        let proxySettings = {
          proxy: null as string,
          source: "os" as ProxySource,
        };

        if (envSettings) {
//.........这里部分代码省略.........
开发者ID:HorrerGames,项目名称:itch,代码行数:101,代码来源:preboot.ts

示例8: SocketManager

import * as electron from 'electron';  // Module to control application life.
import * as fs from 'fs';
import * as rimraf from 'rimraf';

import {SocketManager} from "./scripts/connect";

var socket = new SocketManager();
//190.128.55.241;
socket.Connect("10.253.109.5", 9999);
global["socket"] = socket;

// Quit when all windows are closed.
electron.app.on('window-all-closed', () => {
    if (process.platform != "darwin") {
        electron.app.quit();
    }
});

electron.app.on("ready", () => {
    // Create the browser window.
    var mainWindow = new electron.BrowserWindow({
        "width": 920,
        "height": 550,
        "minWidth": 920,
        "minHeight": 550
    });

    var registerWindow = new electron.BrowserWindow({
        "width": 920,
        "height": 550,
        "minWidth": 920,
开发者ID:edoren,项目名称:ChatClient,代码行数:31,代码来源:index.ts

示例9: function

Usage:
  $ shiba [--detach|--version] [{direcotyr/file to watch}]

Environment:
  OS:       ${process.platform}-${process.arch}
  Electron: ${versions.electron}
  Chrome:   ${versions.chrome}
  Node.js:  ${versions.node}
`);
    app.quit();
}
// }}}

// Main Window {{{
app.on('window-all-closed', function() { app.quit(); });

type DisplaySize = Electron.Dimension & {[k: string]: number};

function createWindow(config: Config, icon_path: string) {
    const display_size = screen.getPrimaryDisplay().workAreaSize as DisplaySize;

    function getConfigLength(key: 'width'|'height'): number {
        const len = config[key];
        const default_len = default_config[key];
        switch (typeof len) {
            case 'string': {
                if (len === 'max') {
                    return display_size[key];
                }
                return default_len;
开发者ID:WondermSwift,项目名称:Shiba,代码行数:30,代码来源:mainu.ts

示例10: createWindow

    useContentSize: true,
    icon: `${__dirname}${path.sep}..${path.sep}public${path.sep}images${path.sep}toby.png`,
    backgroundColor: "#000",
    width: 640,
    height: 400,
    minWidth: 640,
    minHeight: 400,
    show: false
  });
  mainWindow.setMenu(null);
  mainWindow.loadURL(`file://${__dirname}/index.html`);
  mainWindow.webContents.on("did-finish-load", () => {
    mainWindow.show();
    // mainWindow.webContents.openDevTools();
  });
  mainWindow.on("closed", (e: any) => {
    mainWindow = null;
  });
}
app.on("ready", createWindow);
app.on("window-all-closed", () => {
  if (process.platform !== "darwin") {
    app.quit();
  }
});
app.on("activate", () => {
  if (mainWindow === null) {
    createWindow();
  }
});
开发者ID:frankhale,项目名称:toby,代码行数:30,代码来源:electron.ts


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