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


TypeScript app.dock.setIcon方法代码示例

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


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

示例1: windowBounds

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

    let options: Electron.BrowserWindowConstructorOptions = {
        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 (app.dock) {
        app.dock.setIcon(nativeImage.createFromPath("build/icon.png"));
    } else {
        browserWindow.setIcon(nativeImage.createFromPath("build/icon.png"));
    }

    browserWindow.loadURL("file://" + __dirname + "/../views/index.html");

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

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

示例2: createWindow

    loading.then((loaded: [Config, WatchDog]) => {
        const [config, dog] = loaded;
        global.config = config;
        const icon_path = path.join(__dirname, '..', '..', 'images', 'shibainu.png');

        let win = createWindow(config, icon_path);
        win.once('closed', function() {
            win = null;
        });

        const html = 'file://' + path.join(__dirname, '..', '..', 'static', 'index.html');
        win.loadURL(html);

        dog.wakeup(win.webContents);

        win.webContents.on('will-navigate', function(e: Event, url: string) {
            e.preventDefault();
            shell.openExternal(url);
        });

        menu.build(win);

        if (process.argv[0].endsWith('Electron') && process.platform === 'darwin') {
            // Note:
            // If Shiba is run as npm package, replace dock app icon
            app.dock.setIcon(icon_path);
        }

        if (process.env.NODE_ENV === 'development') {
            win.webContents.once('devtools-opened', () => setImmediate(() => win.focus()));
            win.webContents.openDevTools({mode: 'detach'});
        }
    }).catch(e => {
开发者ID:Sheshouzuo,项目名称:Shiba,代码行数:33,代码来源:mainu.ts

示例3: windowBounds

import {app, ipcMain, nativeImage, BrowserWindow, screen} from "electron";
import {readFileSync} from "fs";
import {windowBoundsFilePath} from "../utils/Common";

if (app.dock) {
    app.dock.setIcon(nativeImage.createFromPath("build/icon.png"));
}

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);
    }
开发者ID:admix,项目名称:black-screen,代码行数:31,代码来源:Main.ts

示例4: createRootWindow

async function createRootWindow(store: IStore) {
  const window = "root";
  const role: ItchWindowRole = "main";
  const userBounds = config.get(BOUNDS_CONFIG_KEY) || {};
  const bounds = {
    x: -1,
    y: -1,
    width: 1250,
    height: 720,
    ...userBounds,
  };
  const { width, height } = bounds;
  const center = bounds.x === -1 && bounds.y === -1;

  let opts: Electron.BrowserWindowConstructorOptions = {
    ...commonBrowserWindowOpts(),
    title: app.getName(),
    width,
    height,
    center,
    show: false,
  };
  const nativeWindow = new BrowserWindow(opts);
  store.dispatch(
    actions.windowOpened({
      window,
      role,
      nativeId: nativeWindow.id,
      initialURL: "itch://library",
    })
  );

  if (os.platform() === "darwin") {
    try {
      app.dock.setIcon(getIconPath());
    } catch (err) {
      logger.warn(`Could not set dock icon: ${err.stack}`);
    }
  }

  if (!center) {
    nativeWindow.setPosition(bounds.x, bounds.y);
  }
  ensureWindowInsideDisplay(nativeWindow);

  nativeWindow.on("close", (e: any) => {
    const prefs = store.getState().preferences || { closeToTray: true };

    let { closeToTray } = prefs;
    if (env.integrationTests) {
      // always let app close in testing
      closeToTray = false;
    }

    if (closeToTray) {
      logger.debug("Close to tray enabled");
    } else {
      logger.debug("Close to tray disabled, quitting!");
      process.nextTick(() => {
        store.dispatch(actions.quit({}));
      });
      return;
    }

    if (!nativeWindow.isVisible()) {
      logger.info("Main window hidden, letting it close");
      return;
    }

    if (!prefs.gotMinimizeNotification) {
      store.dispatch(
        actions.updatePreferences({
          gotMinimizeNotification: true,
        })
      );

      const i18n = store.getState().i18n;
      store.dispatch(
        actions.notify({
          title: t(i18n, ["notification.see_you_soon.title"]),
          body: t(i18n, ["notification.see_you_soon.message"]),
        })
      );
    }

    // hide, never destroy
    e.preventDefault();
    logger.info("Hiding main window");
    nativeWindow.hide();
  });

  hookNativeWindow(store, window, nativeWindow);

  nativeWindow.on("maximize", (e: any) => {
    config.set(MAXIMIZED_CONFIG_KEY, true);
  });

  nativeWindow.on("unmaximize", (e: any) => {
    config.set(MAXIMIZED_CONFIG_KEY, false);
  });
//.........这里部分代码省略.........
开发者ID:HorrerGames,项目名称:itch,代码行数:101,代码来源:main-window.ts

示例5: createRootWindow

async function createRootWindow(store: Store) {
  const wind = "root";
  const role: WindRole = "main";
  const userBounds = config.get(BOUNDS_CONFIG_KEY) || {};
  const bounds = {
    x: -1,
    y: -1,
    width: 1250,
    height: 720,
    ...userBounds,
  };
  const { width, height } = bounds;
  const center = bounds.x === -1 && bounds.y === -1;

  let opts: Electron.BrowserWindowConstructorOptions = {
    ...commonBrowserWindowOpts(store),
    title: app.getName(),
    width,
    height,
    center,
  };
  const nativeWindow = new BrowserWindow(opts);
  store.dispatch(
    actions.windOpened({
      wind,
      role,
      nativeId: nativeWindow.id,
      initialURL: "itch://library",
    })
  );

  if (process.platform === "darwin") {
    try {
      app.dock.setIcon(getIconPath());
    } catch (err) {
      logger.warn(`Could not set dock icon: ${err.stack}`);
    }
  }

  if (!center) {
    nativeWindow.setPosition(bounds.x, bounds.y);
  }
  ensureWindowInsideDisplay(nativeWindow);

  nativeWindow.on("close", (e: any) => {});

  hookNativeWindow(store, wind, nativeWindow);

  nativeWindow.on("maximize", (e: any) => {
    config.set(MAXIMIZED_CONFIG_KEY, true);
  });

  nativeWindow.on("unmaximize", (e: any) => {
    config.set(MAXIMIZED_CONFIG_KEY, false);
  });

  nativeWindow.loadURL(makeAppURL({ wind, role }));

  if (parseInt(process.env.DEVTOOLS || "0", 10) > 0) {
    openAppDevTools(nativeWindow);
  }
}
开发者ID:itchio,项目名称:itch,代码行数:62,代码来源:winds.ts

示例6: open_window


//.........这里部分代码省略.........
            const twitter = new Twitter();
            twitter.prepareClient({
                consumer_key,
                consumer_secret,
                access_token: access.token,
                access_token_secret: access.token_secret,
            });
            twitter.sender = new IpcSender(win.webContents);

            if (should_use_dummy_data) {
                twitter
                    .sendDummyAccount()
                    .then(() => twitter.sendDummyStream())
                    .catch(e => log.error('Unexpected error on dummy stream:', e));
                return;
            }

            twitter
                .sendAuthenticatedAccount()
                .catch(err => {
                    if (!err || (err instanceof Error) || err[0].code !== 32) {
                        log.error('Unexpected error on verifying account:', err);
                        return;
                    }
                    log.debug('Retry authentication flow');
                    return authenticate(consumer_key, consumer_secret)
                        .then((a: AccessToken) => {
                            if (!a.token || !a.token_secret) {
                                log.error('Invalid access tokens:', a);
                                return;
                            }
                            twitter.prepareClient({
                                consumer_key,
                                consumer_secret,
                                access_token: a.token,
                                access_token_secret: a.token_secret,
                            });
                        })
                        .then(() => twitter.sendAuthenticatedAccount())
                        .catch(e => {
                            log.error('Give up: Second authentication try failed.  If you use environment variables for tokens, please check them:', e);
                        });
                })
                .then(() => Promise.all([
                    twitter.fetchMuteIds(),
                    twitter.fetchNoRetweets(),
                    twitter.fetchBlockIds(),
                    twitter.fetchHomeTimeline(),
                    twitter.fetchMentionTimeline(),
                ]))
                .then(([mute_ids, no_retweet_ids, block_ids, tweets, mentions]) => {
                    // Note: Merge mute list with block list
                    for (const m of mute_ids) {
                        if (block_ids.indexOf(m) === -1) {
                            block_ids.push(m);
                        }
                    }
                    log.debug('Total rejected ids: ', block_ids.length);
                    twitter.sender.send('yf:rejected-ids', block_ids);
                    twitter.sender.send('yf:no-retweet-ids', no_retweet_ids);
                    for (const tw of tweets) {
                        twitter.sender.send('yf:tweet', tw);
                    }
                    twitter.sender.send('yf:mentions', mentions);
                })
                .then(() => twitter.connectToStream())
                .catch((e: any) => log.error('Unexpected error on streaming', e));

            powerMonitor.on('suspend', () => {
                log.debug("PC's going to suspend, stop streaming");
                if (!should_use_dummy_data) {
                    twitter.stopStreaming();
                }
            });
            powerMonitor.on('resume', () => {
                log.debug("PC's resuming, will reconnect after 3secs: " + twitter.isStopped());
                if (twitter.isStopped() && !should_use_dummy_data) {
                    twitter.sendConnectionFailure();
                    twitter.connectToStream();
                }
            });

        });
    } else {
        log.error('Failed to get access tokens');
    }

    win.loadURL(index_html);

    if (isRunFromNpmPackageOnDarwin()) {
        app.dock.setIcon(icon_path);
    }

    setApplicationMenu(win);

    if (process.env.NODE_ENV === 'development') {
        win.webContents.on('devtools-opened', () => setImmediate(() => win.focus()));
        win.webContents.openDevTools({mode: 'detach'});
    }
}
开发者ID:DevenLu,项目名称:YourFukurou,代码行数:101,代码来源:main.ts

示例7: createMainWindow

// This method will be called when Electron has done everything
// initialization and ready for creating browser windows.
app.on('ready', () => {
  createMainWindow()
  createReaderWindow()
})

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 (mainWindow === null) {
    createMainWindow()
  }
  if (readerWindow === null) {
    createReaderWindow()
  }
})

// set dock icon on mac os x
if (process.platform === 'darwin') {
  app.dock.setIcon(path.join(__dirname, '/app/assets/image/logo-128x128.png'))
}

// bind ipc actions
ipcMain.on('open-reader', (event, arg) => {
  mainWindow.hide()
  readerWindow.show()
  readerWindow.webContents.send('reader-open-book', arg)
})
开发者ID:makaria,项目名称:GReader,代码行数:29,代码来源:main.ts


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