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


TypeScript electron.Menu类代码示例

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


在下文中一共展示了Menu类的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:

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

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

示例4: registerShortcuts

const __refreshMenu = _.debounce(function () {
    Menu.setApplicationMenu(Menu.buildFromTemplate(_.cloneDeep(menuTemplate)));
    globalShortcut.unregisterAll();
    const mainWindow = shell.getMainWindow();
    if (mainWindow.isFocused()) {
        menuTemplate.forEach((menuItem) => registerShortcuts(menuItem));
    }
}, 100);
开发者ID:Real-Currents,项目名称:brackets,代码行数:8,代码来源:app-menu.ts

示例5: function

var setApplicationMenu = function () {
    var menus :Electron.MenuItemOptions[];
    menus = [editMenuTemplate];
    if (env.name !== 'production') {
        menus.push(devMenuTemplate);
    }
    Menu.setApplicationMenu(Menu.buildFromTemplate(menus));
};
开发者ID:frieck,项目名称:electron-angular2-boilerplate,代码行数:8,代码来源:background.ts

示例6: function

const setMenu = (mainWindow: MainWindow) => {
  const buildedMenu = Menu.buildFromTemplate([
    {
      label: 'File',
      submenu: [
        { label: 'New File', accelerator: 'Command+N', click: () => {
          FileManager.getInstance().resetFile();
        }},
        { label: 'Open...' , accelerator: 'Command+O', click: () => {
          FileManager.getInstance().openFile();
        }},
        { type: 'separator' },
        { label: 'Save', accelerator: 'Command+S', click: () => {
          FileManager.getInstance().saveFile();
        }},
        { label: 'Save As...', click: () => {
          FileManager.getInstance().saveAsNewFile();
        }},
        { type: 'separator' },
        { label: 'Export To PDF', click: () => {
          ExportWindow.getInstance().createWindow(MainWindow.getInstance().getText());
        }},
        { 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:' }
      ]
    },
    {
      label: 'Play',
      submenu: [
        { label: 'Play Slideshow', accelerator: 'Command+P', click: () => PresentationWindow.getInstance().createWindow() }
      ]
    },
    {
      label: 'View',
      submenu: [
        {
          label: 'Toggle Developer Tools',
          accelerator: 'Alt+Command+I',
          click: function() { mainWindow.getBrowserWindow().webContents.toggleDevTools(); }
        }
      ]
    }
  ]);

  Menu.setApplicationMenu(buildedMenu);
};
开发者ID:shtakai,项目名称:cafe-pitch,代码行数:58,代码来源:menu.ts

示例7: registerShortcuts

const __refreshMenu = _.debounce(function () {
    Menu.setApplicationMenu(Menu.buildFromTemplate(_.cloneDeep(menuTemplate)));
    const mainWindow = shell.getMainWindow();
    if (mainWindow.isFocused()) {
        currentShortcuts = {};
        menuTemplate.forEach((menuItem) => registerShortcuts(mainWindow, menuItem));
        mainWindow.webContents.send("updateShortcuts", JSON.stringify(currentShortcuts));
    }
}, 100);
开发者ID:zaggino,项目名称:brackets-electron,代码行数:9,代码来源:app-menu.ts

示例8: buildMenu

export function buildMenu() {
    let menuItems: Electron.MenuItemConstructorOptions[] = [];
    if (process.platform === "win32") {
        // サービスをinjectionするようになったらnewはしないけども。
        menuItems = new DefaultMenu().build();
    }
    const menu = Menu.buildFromTemplate(menuItems);
    Menu.setApplicationMenu(menu);
}
开发者ID:defvar,项目名称:toyctron,代码行数:9,代码来源:index.ts

示例9: addMenuItemClickConnector

    socket.on('menu-setApplicationMenu', (menuItems) => {
        const menu = Menu.buildFromTemplate(menuItems);

        addMenuItemClickConnector(menu.items, (id) => {
            socket.emit("menuItemClicked", id);
        });

        Menu.setApplicationMenu(menu);
    });
开发者ID:E024,项目名称:Electron.NET,代码行数:9,代码来源:menu.ts

示例10: build

export function build(mainWin: Electron.BrowserWindow, cfg: config.Config) {
  const template = [{
    label: 'Menu',
    id: 'menu',
    submenu: [
      {
        label: 'Reload',
        click: () => mainWin.reload(),
      },
      {
        label: 'Toggle DevTools',
        click: () => mainWin.webContents.toggleDevTools(),
      },
      {
        type: 'separator'
      },
      {
        label: 'Quit',
        click: () => mainWin.close(),
      }
    ]
  },
  {
    label: 'Thema',
    id: 'thema',
    submenu: [
      {
        label: 'Normal',
        id: 'thema-normal',
        type: 'checkbox',
        checked: (cfg.thema == 'thema-normal'),
        click: () => {
          mainWin.webContents.executeJavaScript("changeThema('thema-normal')")
        }
      },
      {
        label: 'Dark',
        id: 'thema-dark',
        type: 'checkbox',
        checked: (cfg.thema == 'thema-dark'),
        click: () => {
          mainWin.webContents.executeJavaScript("changeThema('thema-dark')")
        }
      }
    ]
  }];

  const menu = electron.Menu.buildFromTemplate(template);
  electron.Menu.setApplicationMenu(menu);

  return menu;
};
开发者ID:civic,项目名称:markcat,代码行数:52,代码来源:menu.ts


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