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


TypeScript app.getName方法代码示例

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


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

示例1: it

    it('overrides the name', () => {
      expect(app.getName()).to.equal('Electron Test Main')
      app.setName('test-name')

      expect(app.getName()).to.equal('test-name')
      app.setName('Electron Test')
    })
开发者ID:malept,项目名称:electron,代码行数:7,代码来源:api-app-spec.ts

示例2: createSelector

 return createSelector(getI18n, getSpace, (i18n, sp) => {
   const nativeWindow = getNativeWindow(store.getState(), window);
   if (nativeWindow && !nativeWindow.isDestroyed()) {
     const label = t(i18n, sp.label());
     let title: string;
     if (label) {
       title = `${label} - ${app.getName()}`;
     } else {
       title = `${app.getName()}`;
     }
     nativeWindow.setTitle(title);
   }
 });
开发者ID:itchio,项目名称:itch,代码行数:13,代码来源:winds.ts

示例3: loadApplicationPackage

function loadApplicationPackage (packagePath: string) {
  // Add a flag indicating app is started from default app.
  Object.defineProperty(process, 'defaultApp', {
    configurable: false,
    enumerable: true,
    value: true
  })

  try {
    // Override app name and version.
    packagePath = path.resolve(packagePath)
    const packageJsonPath = path.join(packagePath, 'package.json')
    if (fs.existsSync(packageJsonPath)) {
      let packageJson
      try {
        packageJson = require(packageJsonPath)
      } catch (e) {
        showErrorMessage(`Unable to parse ${packageJsonPath}\n\n${e.message}`)
        return
      }

      if (packageJson.version) {
        app.setVersion(packageJson.version)
      }
      if (packageJson.productName) {
        app.setName(packageJson.productName)
      } else if (packageJson.name) {
        app.setName(packageJson.name)
      }
      app.setPath('userData', path.join(app.getPath('appData'), app.getName()))
      app.setPath('userCache', path.join(app.getPath('cache'), app.getName()))
      app.setAppPath(packagePath)
    }

    try {
      Module._resolveFilename(packagePath, module, true)
    } catch (e) {
      showErrorMessage(`Unable to find Electron app at ${packagePath}\n\n${e.message}`)
      return
    }

    // Run the app.
    Module._load(packagePath, module, true)
  } catch (e) {
    console.error('App threw an error during load')
    console.error(e.stack || e)
    throw e
  }
}
开发者ID:malept,项目名称:electron,代码行数:49,代码来源:main.ts

示例4: setMainMenu

function setMainMenu() {
  const template = [{
    label: isWindows ? 'Kendo UI' : app.getName(),
    submenu: [{
      label: isWindows ? 'Exit Kendo UI Dashboard' : `Quit ${app.getName()}`,
      accelerator: isWindows ? 'Alt+F4' : 'CmdOrCtrl+Q',
      click() {
        app.quit();
      }
    }]
  }];

  const menu = Menu.buildFromTemplate(template);
  Menu.setApplicationMenu(menu);
}
开发者ID:telerik,项目名称:kendo-angular2,代码行数:15,代码来源:main.ts

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

示例6: isSubmenu

    .map((item) => {
      const { label } = item;

      // Append the "Settings" item
      if (
        process.platform === 'darwin'
        && label === app.getName()
        && isSubmenu(item.submenu)
      ) {
        item.submenu.splice(2, 0, ...getPreferencesItems());
      }

      // Tweak "View" menu
      if (label === 'View' && isSubmenu(item.submenu)) {
        item.submenu = item.submenu.filter((subItem) => subItem.label !== 'Toggle Developer Tools'); // Remove "Toggle Developer Tools"
        item.submenu.push({ type: 'separator' }, { role: 'resetzoom' }, { role: 'zoomin' }, { role: 'zoomout' }); // Add zooming actions
        item.submenu.push({ type: 'separator' }, {
          label: 'Toggle Soft Wrap',
          click: () => ipcMainManager.send(IpcEvents.MONACO_TOGGLE_OPTION, [ 'wordWrap' ]),
        });
        item.submenu.push({ type: 'separator' }, {
          label: 'Toggle Mini Map',
          click: () => ipcMainManager.send(IpcEvents.MONACO_TOGGLE_OPTION, [ 'minimap.enabled' ]),
        });
      }

      // Append items to "Help"
      if (label === 'Help' && isSubmenu(item.submenu)) {
        item.submenu = getHelpItems();
      }

      return item;
    });
开发者ID:bpasero,项目名称:fiddle,代码行数:33,代码来源:menu.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: async

  watcher.on(actions.openWind, async (store, action) => {
    let { initialURL } = action.payload;
    const rs = store.getState();

    initialURL = normalizeURL(initialURL);

    const secondaryWindowParams = opensInWindow(initialURL);
    if (secondaryWindowParams) {
      // see if we already have a window with that initialURL
      for (const wind of Object.keys(rs.winds)) {
        const windState = rs.winds[wind];
        if (windState.properties.initialURL === initialURL) {
          const nativeWin = getNativeWindow(rs, wind);
          if (nativeWin) {
            nativeWin.show();
            nativeWin.focus();
            return;
          }
        }
      }
    }

    let width = 800;
    let height = 600;
    if (secondaryWindowParams) {
      width = secondaryWindowParams.width || width;
      height = secondaryWindowParams.height || height;
    }
    const opts: BrowserWindowConstructorOptions = {
      ...commonBrowserWindowOpts(store),
      title: app.getName(),
      width,
      height,
    };

    const nativeWindow = new BrowserWindow(opts);
    const wind = `secondary-${secondaryWindowSeed++}`;
    const role: WindRole = "secondary";
    store.dispatch(
      actions.windOpened({
        wind,
        role,
        nativeId: nativeWindow.id,
        initialURL: initialURL,
      })
    );

    const configKey = `${initialURL}-bounds`;
    const bounds = config.get(configKey);
    if (bounds) {
      nativeWindow.setBounds(bounds);
    }

    nativeWindow.loadURL(makeAppURL({ wind, role }));
    hookNativeWindow(store, wind, nativeWindow);
  });
开发者ID:itchio,项目名称:itch,代码行数:56,代码来源:winds.ts

示例9: createWindow

function createWindow(): void {
  mainWindow = new BrowserWindow({
    title: app.getName(),
    titleBarStyle: 'hiddenInset',
    webPreferences: {
      nodeIntegration: false,
      nativeWindowOpen: true,
      preload: path.join(__dirname, 'preload')
    }
  })

  // Use the window state to set the mainWindow bounds
  WindowState.use('main', mainWindow)

  mainWindow.loadURL('https://mail.google.com')

  mainWindow.webContents.on('dom-ready', () => {
    addCustomCSS(mainWindow)

    // Initialize minimal mode if the setting is turned on
    initMinimalMode()
  })

  mainWindow.on('close', e => {
    if (!isQuitting) {
      e.preventDefault()
      mainWindow.blur()
      mainWindow.hide()
    }
  })

  ipc.on('unread-count', (_: any, unreadCount: number) => {
    if (is.macos) {
      app.dock.setBadge(unreadCount ? unreadCount.toString() : '')
    }

    if ((is.linux || is.windows) && tray) {
      const icon = unreadCount ? 'tray-icon-unread.png' : 'tray-icon.png'
      const iconPath = path.join(__dirname, '..', 'static', icon)

      tray.setImage(iconPath)
    }
  })
}
开发者ID:,项目名称:,代码行数:44,代码来源:

示例10: showRestartDialog

export function showRestartDialog(enabled: boolean): void {
  const state = enabled ? 'enable' : 'disable'

  dialog.showMessageBox(
    {
      type: 'info',
      buttons: ['Restart', 'Cancel'],
      message: 'Restart required',
      detail: `To ${state} debug mode, please restart ${app.getName()}`
    },
    response => {
      // If restart was clicked (index of 0), restart the app
      if (response === 0) {
        app.relaunch()
        app.quit()
      }
    }
  )
}
开发者ID:,项目名称:,代码行数:19,代码来源:


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