當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript electron.app.dock類代碼示例

本文整理匯總了TypeScript中electron.app.dock的典型用法代碼示例。如果您正苦於以下問題:TypeScript app.dock類的具體用法?TypeScript app.dock怎麽用?TypeScript app.dock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了app.dock類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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:

  ipc.on('unread-count', (_: any, unreadCount: number) => {
    if (is.macos) {
      app.dock.setBadge(unreadCount ? unreadCount.toString() : '')
    }

    if ((is.linux || is.windows) && tray) {
      const icon = unreadCount ? 'tray-icon-unread.png' : 'tray-icon.png'
      const iconPath = path.join(__dirname, '..', 'static', icon)

      tray.setImage(iconPath)
    }
  })
開發者ID:,項目名稱:,代碼行數:12,代碼來源:

示例4:

    item.once('done', (e, state) => {
      if (!mainWindow.isDestroyed()) {
        mainWindow.setProgressBar(-1);
      }

      if (state === 'interrupted') {
        mainWindow.webContents.send(DOWNLOAD, { type: 'error' });
      }

      if (state === 'completed') {
        mainWindow.webContents.send(DOWNLOAD, { type: 'success', filePath });
        app.dock.downloadFinished(filePath);
      }
    });
開發者ID:SteveTannnnng,項目名稱:Mob,代碼行數:14,代碼來源:main.ts

示例5: sendAction

		ipcMain.on('conversations', (_event: ElectronEvent, conversations: Conversation[]) => {
			if (conversations.length === 0) {
				return;
			}

			const items = conversations.map(({label, icon}, index) => {
				return {
					label: `${label}`,
					icon: nativeImage.createFromDataURL(icon),
					click: () => {
						mainWindow.show();
						sendAction('jump-to-conversation', index + 1);
					}
				};
			});
			app.dock.setMenu(Menu.buildFromTemplate([firstItem, {type: 'separator'}, ...items]));
		});
開發者ID:kusamakura,項目名稱:caprine,代碼行數:17,代碼來源:index.ts

示例6: memoize

const setTrayMenu = memoize(1, function(
  template: IMenuTemplate,
  store: IStore
) {
  const fleshedOut = fleshOutTemplate(
    "root",
    store,
    currentRuntime(),
    template
  );
  const menu = Menu.buildFromTemplate(fleshedOut);

  if (os.platform() === "darwin") {
    // don't have a tray icon on macOS, we just live in the dock
    app.dock.setMenu(menu);
  } else {
    getTray(store).setContextMenu(menu);
  }
});
開發者ID:HorrerGames,項目名稱:itch,代碼行數:19,代碼來源:tray.ts

示例7: updateBadge

function updateBadge(conversations: Conversation[]): void {
	// Ignore `Sindre messaged you` blinking
	if (!Array.isArray(conversations)) {
		return;
	}

	const messageCount = conversations.filter(({unread}) => unread).length;

	if (is.macos || is.linux) {
		if (config.get('showUnreadBadge')) {
			app.setBadgeCount(messageCount);
		}

		if (is.macos && config.get('bounceDockOnMessage') && prevMessageCount !== messageCount) {
			app.dock.bounce('informational');
			prevMessageCount = messageCount;
		}
	}

	if (is.linux || is.windows) {
		if (config.get('showUnreadBadge')) {
			tray.setBadge(messageCount > 0);
		}

		if (config.get('flashWindowOnMessage')) {
			mainWindow.flashFrame(messageCount !== 0);
		}
	}

	if (is.windows) {
		if (config.get('showUnreadBadge')) {
			if (messageCount === 0) {
				mainWindow.setOverlayIcon(null, '');
			} else {
				// Delegate drawing of overlay icon to renderer process
				mainWindow.webContents.send('render-overlay-icon', messageCount);
			}
		}
	}
}
開發者ID:kusamakura,項目名稱:caprine,代碼行數:40,代碼來源:index.ts

示例8:

 browserWindow.on("focus", () => app.dock && app.dock.setBadge(""));
開發者ID:admix,項目名稱:black-screen,代碼行數:1,代碼來源:Main.ts

示例9: it

 it('should not throw', () => {
   app.dock.hide()
   expect(app.dock.isVisible()).to.equal(false)
 })
開發者ID:malept,項目名稱:electron,代碼行數:4,代碼來源:api-app-spec.ts


注:本文中的electron.app.dock類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。