• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript electron.Tray类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1:

app.on('ready', () => {
	tray = new electron.Tray(trayImagePath);
	let contextMenu: Electron.Menu = electron.Menu.buildFromTemplate([
		{
			label: "設定...",
			click: () => {
				createWindow();
			},
		},
		{
			label: "バージョン情報...",
			click: () => {
				dialog.showMessageBox({
					type: "info",
					buttons: [ "OK" ],
					title: "バージョン情報",
					message: "SavannaAlert バージョン 20160910",
				});
			},
		},
		{
			label: "終了",
			click: () => {
				app.quit();
			},
		},
	]);
	tray.setToolTip("SavannaAlert");
	tray.setContextMenu(contextMenu);
	tray.on("click", createWindow);
});
开发者ID:data9824,项目名称:SavannaAlert,代码行数:31,代码来源:main.ts


示例2: function

app.on('ready', function () {

    Menu.setApplicationMenu(null);

    let iconFile = process.platform === 'win32' ? 'tray.ico' : 'trayTemplate.png';
    tray = new Tray(path.normalize(`${app.getAppPath()}/icons/${iconFile}`));

    var windowOptions = Object.assign({}, {
      width: currentTheme.settings.BTWindowWidth,
      height: currentTheme.settings.BTWindowHeight,
      webPreferences: { preload:  path.resolve(`${__dirname}/preload.js`) }
    }, env.windowProperties)

    mainWindow = createWindow('main', windowOptions);

    mainWindow.loadURL(`file://${currentTheme.path}/${currentTheme.settings.BTMainFile}`);

    tray.setContextMenu(trayMenu);
    console.log('wtf');

    console.log(dialog.showMessageBox(mainWindow, {type: 'info', message: `Welcome Back, You arrived!`}));

    if (1 == 1 || env.name === 'development') {
        mainWindow.openDevTools();
    }
});
开发者ID:ryan-nauman,项目名称:spotify-mini,代码行数:26,代码来源:background.ts


示例3: function

app.on('ready', function(){
  mainWindow = new BrowserWindow({show: false});
  mainWindow.loadURL('file://' + __dirname + '/window.html');
  appIcon = new Tray(iconPath);
  var contextMenu = Menu.buildFromTemplate([
    {
      label: 'Bilge Adam Bilgilendirme Merkezi',
      icon: iconPath
    },
    {
      label: 'Duyuru',
      click: function() {
        let options: NotificationOptions = {body: "Sistem ayarları güncellemesi başlatılacaktır!"};
        createNotification("Bilge Adam Bilgilendirme", options);
      }
    },
    {
      label: 'Aç',
      click: function() {
        mainWindow.show();
      }
    },
    { 
      label: 'Kapat',
      click: function() {
        mainWindow.hide();
      }
    }
  ]);
  appIcon.setToolTip('Bilge Adam Bilgilendirme');
  appIcon.setContextMenu(contextMenu);
});
开发者ID:gencebay,项目名称:banoty,代码行数:32,代码来源:main.ts


示例4: getTray

export function getTray(store: IStore): Electron.Tray {
  if (!tray) {
    // cf. https://github.com/itchio/itch/issues/462
    // windows still displays a 16x16, whereas
    // some linux DEs don't know what to do with a @x2, etc.
    let suffix = "";
    if (os.platform() !== "linux") {
      suffix = "-small";
    }

    let base = "white";
    if (os.platform() === "win32" && !/^10\./.test(os.release())) {
      // windows older than 10 get the old colorful tray icon
      base = env.appName;
    }

    const iconName = `${base}${suffix}.png`;
    const iconPath = getImagePath("tray/" + iconName);

    tray = new Tray(iconPath);
    tray.setToolTip(env.appName);
    tray.on("click", () => {
      store.dispatch(actions.focusWindow({ window: "root", toggle: true }));
    });
    tray.on("double-click", () => {
      store.dispatch(actions.focusWindow({ window: "root" }));
    });
    tray.on("balloon-click", () => {
      if (lastNotificationAction) {
        store.dispatch(lastNotificationAction);
      }
    });
  }
  return tray;
}
开发者ID:HorrerGames,项目名称:itch,代码行数:35,代码来源:tray-persistent-state.ts


示例5: loadFullMenu

 .then(kernelSpecs => {
   if (Object.keys(kernelSpecs).length !== 0) {
     store.dispatch(setKernelSpecs(kernelSpecs));
     const menu = loadFullMenu();
     Menu.setApplicationMenu(menu);
     const logo =
       process.platform === "win32" ? "logoWhite" : "logoTemplate";
     const trayImage = join(__dirname, "..", "static", `${logo}.png`);
     tray = new Tray(trayImage);
     const trayMenu = loadTrayMenu();
     tray.setContextMenu(trayMenu);
   } else {
     dialog.showMessageBox(
       {
         type: "warning",
         title: "No Kernels Installed",
         buttons: [],
         message: "No kernels are installed on your system.",
         detail:
           "No kernels are installed on your system so you will not be " +
           "able to execute code cells in any language. You can read about " +
           "installing kernels at " +
           "https://ipython.readthedocs.io/en/latest/install/kernel_install.html"
       },
       index => {
         if (index === 0) {
           app.quit();
         }
       }
     );
   }
 })
开发者ID:nteract,项目名称:nteract,代码行数:32,代码来源:index.ts


示例6: createTrayIcon

function createTrayIcon(status: ConnectionStatus) {
  const isConnected = status === ConnectionStatus.CONNECTED;
  const trayIconImage = isConnected ? trayIconImages.connected : trayIconImages.disconnected;
  if (tray) {
    tray.setImage(trayIconImage);
  } else {
    tray = new Tray(trayIconImage);
    tray.on('click', () => {
      if (!mainWindow) {
        createWindow();
        return;
      }
      if (mainWindow.isMinimized() || !mainWindow.isVisible()) {
        mainWindow.restore();
        mainWindow.show();
        mainWindow.focus();
      } else {
        mainWindow.hide();
      }
    });
    tray.setToolTip('Outline');
  }
  // Retrieve localized strings, falling back to the pre-populated English default.
  const statusString = isConnected ? localizedStrings['connected-server-state'] :
                                     localizedStrings['disconnected-server-state'];
  const quitString = localizedStrings['quit'];
  const menuTemplate = [
    {label: statusString, enabled: false}, {type: 'separator'} as MenuItemConstructorOptions,
    {label: quitString, click: quitApp}
  ];
  tray.setContextMenu(Menu.buildFromTemplate(menuTemplate));
}
开发者ID:hlyu368,项目名称:outline-client,代码行数:32,代码来源:index.ts


示例7: Tray

app.on("ready", () => {
  // window
  MainWindow.getInstance().show()

  // tray
  const tray = new Tray(`${__dirname}/images/icon.png`)
  const menu = Menu.buildFromTemplate([
    {label: "Setting", click: () => SettingWindow.getInstance().show()},
    {label: "Quit", click: () => app.quit()},
  ])
  tray.setToolTip(app.getName())
  tray.setContextMenu(menu)

  // menu
  Menu.setApplicationMenu(Menu.buildFromTemplate([{
    label: "Application",
    submenu: [
      { label: "About Application", selector: "orderFrontStandardAboutPanel:" },
      { type: "separator" },
      { label: "Quit", accelerator: "Command+Q", click: () => app.quit() },
    ]}, {
    label: "Edit",
    submenu: [
      { label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:" },
      { label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" },
      { type: "separator" },
      { label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" },
      { label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
      { label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" },
      { label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" },
    ]},
  ]))
})
开发者ID:namikingsoft,项目名称:snotido,代码行数:33,代码来源:app.ts


示例8: click

	create: (win: BrowserWindow) => {
		if (is.macos || tray) {
			return;
		}

		const iconPath = path.join(__dirname, '..', 'static', 'IconTray.png');

		const toggleWin = (): void => {
			if (win.isVisible()) {
				win.hide();
			} else {
				win.show();
			}
		};

		const contextMenu = Menu.buildFromTemplate([
			{
				label: 'Toggle',
				click() {
					toggleWin();
				}
			},
			{
				type: 'separator'
			},
			{
				role: 'quit'
			}
		]);

		tray = new Tray(iconPath);
		tray.setToolTip(`${app.getName()}`);
		tray.setContextMenu(contextMenu);
		tray.on('click', toggleWin);
	},
开发者ID:kusamakura,项目名称:caprine,代码行数:35,代码来源:tray.ts


示例9: EstablishTray

function EstablishTray() {
  if (tray !== null) {
    return
  }
  /*----------  Tray functions  ----------*/

  /*----------  Tray functions END  ----------*/
  let trayIconLocation = ''
  if (process.platform === 'darwin') {
    trayIconLocation = 'ext_dep/images/TrayTemplate.png'
  }
  if (process.platform === 'win32') {
    trayIconLocation = 'ext_dep/images/WindowsTrayIconAlt3.png'
    // trayIconLocation = "ext_dep/images/WindowsTrayIcon.ico"
  }
  if (process.platform === 'linux') {
    trayIconLocation = 'ext_dep/images/LinuxTrayIcon.png'
  }
  tray = new elc.Tray(path.join(__dirname, trayIconLocation))
  tray.setToolTip('Aether')
  const contextMenu = elc.Menu.buildFromTemplate(contextMenuTemplate)
  tray.setContextMenu(contextMenu)
  tray.on('click', () => {
    // On windows, the convention is that when an icon in the tray is clicked, it should spawn the app window.
    if (process.platform === 'win32') {
      openAppWindow()
    }
  })
}
开发者ID:nehbit,项目名称:aether-public,代码行数:29,代码来源:mainmain.ts


示例10: createWindow

// tslint:disable-next-line:only-arrow-functions
function createWindow() {
    tray = new Tray(`${__dirname}/icon-menu-play.png`);
    tray.setTitle('...');
    /* const contextMenu = Menu.buildFromTemplate([
        { label: 'Item1', type: 'radio' },
        { label: 'Item2', type: 'radio' },
        { label: 'Item3', type: 'radio', checked: true },
        { label: 'Item4', type: 'radio' }
    ]);
    tray.setToolTip('This is my application.');
    tray.setContextMenu(contextMenu); */
    const windowConfiguration = {
        autoHideMenuBar: true,
        // tslint:disable-next-line:no-magic-numbers
        width: DEV_MODE ? 700 : 300,
        // tslint:disable-next-line:no-magic-numbers
        height: DEV_MODE ? 518 : 118,
    };

    if (process.platform === 'win32') {
        // tslint:disable-next-line:no-magic-numbers
        windowConfiguration.width *= 1.5;
        // tslint:disable-next-line:no-magic-numbers
        windowConfiguration.height *= 1.5;
    }

    // Create the browser window.
    mainWindow = new BrowserWindow(windowConfiguration);

    const mainUrl = process.env.MAIN_APP_URL || join('file://', __dirname, '/index.html');

    console.log(`Loading: ${mainUrl}`);

    mainWindow.loadURL(mainUrl);

    if (DEV_MODE) {
        console.log('Enable DevTools');
        mainWindow.webContents.openDevTools({ detach: true });
    }

    // Open the DevTools.
    // mainWindow.webContents.openDevTools({ detach: true });

    // Emitted when the window is closed.
    mainWindow.on('closed', () => {
        // Dereference the window object, usually you would store windows
        // in an array if your app supports multi windows, this is the time
        // when you should delete the corresponding element.
        // tslint:disable-next-line:no-null-keyword
        mainWindow = null;
    });
}
开发者ID:istvan-antal,项目名称:timetrack,代码行数:53,代码来源:main.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript electron.WebContents类代码示例发布时间:2022-05-25
下一篇:
TypeScript electron.Notification类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap