當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。