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


TypeScript Menu.buildFromTemplate方法代码示例

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


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

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

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

示例3:

const setApplicationMenu = () => {
  const menus = [editMenuTemplate];
  if (env.name !== 'production') {
    menus.push(devMenuTemplate);
  }
  Menu.setApplicationMenu(Menu.buildFromTemplate(menus));
};
开发者ID:Dorokhov,项目名称:azure-tools,代码行数:7,代码来源:background.ts

示例4:

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

示例5: createWindow

export function createWindow() {

  const electronScreen = screen;
  const size = electronScreen.getPrimaryDisplay().workAreaSize;

  // Create the browser window.
  win = new BrowserWindow({
    width: 1200,
    height: 900,
    title: pkg.productName,
    icon: path.join(__dirname, '../resources/icon.png')
  });

  Menu.setApplicationMenu(Menu.buildFromTemplate(menuTemplate));

  // and load the index.html of the app.
  win.loadURL(`file://${__dirname}/index.html`);

  // Emitted when the window is closed.
  win.on('closed', () => {
    // Dereference the window object, usually you would store window
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    win = null;
  });
}
开发者ID:uhlibraries-digital,项目名称:brays,代码行数:26,代码来源:main.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

	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

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

示例9:

  browserWindow.webContents.on('context-menu', (_event, props) => {
    const { editFlags } = props;

    const template: Array<MenuItemConstructorOptions> = [
      ...getRunItems(),
      ...getMonacoItems(props),
      {
        id: 'cut',
        label: 'Cut',
        role: editFlags.canCut ? 'cut' : '',
        enabled: editFlags.canCut
      }, {
        id: 'copy',
        label: 'Copy',
        role: editFlags.canCopy ? 'copy' : '',
        enabled: editFlags.canCopy
      }, {
        id: 'paste',
        label: 'Paste',
        role: editFlags.canPaste ? 'paste' : '',
        enabled: editFlags.canPaste
      }, {
        type: 'separator'
      },
      ...getInspectItems(browserWindow, props)
    ];

    const menu = Menu.buildFromTemplate(template);
    menu.popup({});
  });
开发者ID:bpasero,项目名称:fiddle,代码行数:30,代码来源:context-menu.ts

示例10: showMainWindow

function showMainWindow() {
  const mainWindow = wm.create({
    autoHideMenuBar: true,
    show: false
  });
  // restore window size
  const size = environment.data.windowSize;
  if (size) {
    mainWindow.setSize(size.width, size.height);
  }
  mainWindow.center();
  if (size && size.maximized) {
    mainWindow.maximize();
  }
  mainWindow.on("close", () => {
    // save window size
    const maximized = mainWindow.isMaximized();
    mainWindow.restore();
    const [width, height] = mainWindow.getSize();
    environment.setWindowSize(width, height, maximized);
  });
  mainWindow.setMenu(Electron.Menu.buildFromTemplate(template));
  mainWindow.loadURL(`file://${__dirname}/${html}`);
  mainWindow.show();
}
开发者ID:wonderful-panda,项目名称:inazuma,代码行数:25,代码来源:main.ts


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