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


TypeScript app.dock.setMenu方法代碼示例

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


在下文中一共展示了app.dock.setMenu方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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

示例2: 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

示例3: it

 it('keeps references to the menu', () => {
   app.dock.setMenu(new Menu())
   const v8Util = process.electronBinding('v8_util')
   v8Util.requestGarbageCollectionForTesting()
 })
開發者ID:malept,項目名稱:electron,代碼行數:5,代碼來源:api-app-spec.ts

示例4: updateAppMenu

(async () => {
	await Promise.all([ensureOnline(), app.whenReady()]);

	const trackingUrlPrefix = `https://l.${domain}/l.php`;

	await updateAppMenu();
	mainWindow = createMainWindow();
	tray.create(mainWindow);

	if (is.macos) {
		const firstItem: MenuItemConstructorOptions = {
			label: 'Mute Notifications',
			type: 'checkbox',
			checked: config.get('notificationsMuted'),
			click() {
				mainWindow.webContents.send('toggle-mute-notifications');
			}
		};

		dockMenu = Menu.buildFromTemplate([firstItem]);
		app.dock.setMenu(dockMenu);

		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]));
		});
	}

	// Update badge on conversations change
	ipcMain.on('conversations', (_event: ElectronEvent, conversations: Conversation[]) => {
		updateBadge(conversations);
	});

	enableHiresResources();

	const {webContents} = mainWindow;

	webContents.on('dom-ready', async () => {
		await updateAppMenu();

		webContents.insertCSS(readFileSync(path.join(__dirname, '..', 'css', 'browser.css'), 'utf8'));
		webContents.insertCSS(readFileSync(path.join(__dirname, '..', 'css', 'dark-mode.css'), 'utf8'));
		webContents.insertCSS(readFileSync(path.join(__dirname, '..', 'css', 'vibrancy.css'), 'utf8'));
		webContents.insertCSS(
			readFileSync(path.join(__dirname, '..', 'css', 'code-blocks.css'), 'utf8')
		);

		if (config.get('useWorkChat')) {
			webContents.insertCSS(
				readFileSync(path.join(__dirname, '..', 'css', 'workchat.css'), 'utf8')
			);
		}

		if (existsSync(path.join(app.getPath('userData'), 'custom.css'))) {
			webContents.insertCSS(readFileSync(path.join(app.getPath('userData'), 'custom.css'), 'utf8'));
		}

		if (config.get('launchMinimized') || app.getLoginItemSettings().wasOpenedAsHidden) {
			mainWindow.hide();
		} else {
			mainWindow.show();
		}

		webContents.send('toggle-mute-notifications', config.get('notificationsMuted'));
		webContents.send('toggle-message-buttons', config.get('showMessageButtons'));

		webContents.executeJavaScript(
			readFileSync(path.join(__dirname, 'notifications-isolated.js'), 'utf8')
		);
	});

	webContents.on('new-window', (event: Event, url, frameName, _disposition, options) => {
		event.preventDefault();

		if (url === 'about:blank') {
			if (frameName !== 'about:blank') {
				// Voice/video call popup
				options.show = true;
				options.titleBarStyle = 'default';
				options.webPreferences.nodeIntegration = false;
				options.webPreferences.preload = path.join(__dirname, 'browser-call.js');
				(event as any).newGuest = new BrowserWindow(options);
			}
		} else {
			if (url.startsWith(trackingUrlPrefix)) {
				url = new URL(url).searchParams.get('u')!;
			}
//.........這裏部分代碼省略.........
開發者ID:kusamakura,項目名稱:caprine,代碼行數:101,代碼來源:index.ts


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