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


TypeScript app.getLoginItemSettings方法代码示例

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


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

示例1: it

    it('correctly sets and unsets the LoginItem', function () {
      expect(app.getLoginItemSettings().openAtLogin).to.equal(false)

      app.setLoginItemSettings({ openAtLogin: true })
      expect(app.getLoginItemSettings().openAtLogin).to.equal(true)

      app.setLoginItemSettings({ openAtLogin: false })
      expect(app.getLoginItemSettings().openAtLogin).to.equal(false)
    })
开发者ID:malept,项目名称:electron,代码行数:9,代码来源:api-app-spec.ts

示例2: async

	webContents.on('dom-ready', async () => {
		await updateAppMenu();

		webContents.insertCSS(readFileSync(path.join(__dirname, '..', 'css', 'browser.css'), 'utf8'));
		webContents.insertCSS(readFileSync(path.join(__dirname, '..', 'css', 'dark-mode.css'), 'utf8'));
		webContents.insertCSS(readFileSync(path.join(__dirname, '..', 'css', 'vibrancy.css'), 'utf8'));
		webContents.insertCSS(
			readFileSync(path.join(__dirname, '..', 'css', 'code-blocks.css'), 'utf8')
		);

		if (config.get('useWorkChat')) {
			webContents.insertCSS(
				readFileSync(path.join(__dirname, '..', 'css', 'workchat.css'), 'utf8')
			);
		}

		if (existsSync(path.join(app.getPath('userData'), 'custom.css'))) {
			webContents.insertCSS(readFileSync(path.join(app.getPath('userData'), 'custom.css'), 'utf8'));
		}

		if (config.get('launchMinimized') || app.getLoginItemSettings().wasOpenedAsHidden) {
			mainWindow.hide();
		} else {
			mainWindow.show();
		}

		webContents.send('toggle-mute-notifications', config.get('notificationsMuted'));
		webContents.send('toggle-message-buttons', config.get('showMessageButtons'));

		webContents.executeJavaScript(
			readFileSync(path.join(__dirname, 'notifications-isolated.js'), 'utf8')
		);
	});
开发者ID:kusamakura,项目名称:caprine,代码行数:33,代码来源:index.ts

示例3: EstablishElectronWindow

function EstablishElectronWindow() {
  // If not prod, install Vue devtools.
  if (isDev) {
    require('vue-devtools').install()
  }
  /* Check whether we are started in the hidden state as part of the computer startup process. */
  const loginSettings = elc.app.getLoginItemSettings()
  let hiddenStartAtBoot = loginSettings.wasOpenedAsHidden
  // ^ Only applies to Mac OS
  if (process.platform === 'win32') {
    // ^ Windows version of above
    for (let arg of process.argv) {
      if (arg === '--hidden') {
        hiddenStartAtBoot = true
      }
    }
  }

  // Create the browser window.
  // let dm = elc.screen.getPrimaryDisplay().size
  let bounds = getWinBounds()
  let windowSpec: any = {
    show: false,
    // width: dm.width * 0.8,
    width: bounds.w,
    // height: dm.height * 0.8,
    height: bounds.h,
    title: 'Aether',
    fullscreenWindowTitle: true,
    backgroundColor: '#292b2f',
    disableBlinkFeatures: 'Auxclick', // disable middle click new window
    autoHideMenuBar: true,
    webPreferences: {
      // blinkFeatures: 'OverlayScrollbars'
    },
  }
  if (process.platform === 'win32') {
    windowSpec.frame = false // We have our traffic lights implementation for Win
  }
  if (process.platform === 'darwin') {
    windowSpec.titleBarStyle = 'hiddenInset' // Mac traffic lights
  }
  if (process.platform === 'linux') {
    windowSpec.darkTheme = true // GTK3+ Only
    // Nothing specific for the frame for now.
  }
  win = new elc.BrowserWindow(windowSpec)
  win.once('ready-to-show', function() {
    // We want to show the window only after Electron is done readying itself.
    setTimeout(function() {
      if (!hiddenStartAtBoot) {
        win.show()
      }
    }, 100)
    // Unfortunately, there's a race condition from the Electron side here (I might be making a mistake also, but it is simple enough to reproduce that there is not much space for me to make a mistake). If the setTimeout is 0 or is not present, there's about 1/10 chance the window is painted but completely frozen. Having 100ms seems to make it go away, but it's a little icky, because that basically is my guess. Not great. Hopefully they'll fix this in upcoming Electron 3.
  })
  win.loadFile('index.html')
  if (isDev) {
    // Open the DevTools.
    win.webContents.openDevTools({ mode: 'bottom' })
  }

  // win.webContents.openDevTools({ mode: 'bottom' })

  win.on('close', function(e: any) {
    e.preventDefault()
    // ^ Prevents the app from continuing on with destroying the window element. We need that element.
    closeAppWindow()
    // DOM_READY = false // This is useful when the electron window fully shuts down, not when it's not fully shut down.
  })

  win.webContents.on('dom-ready', function() {
    DOM_READY = true
    // This is needed because the renderer process won't be able to respond to IPC requests before this event happens.

    if (process.platform == 'win32') {
      /*----------  Windows specific deep linker  ----------*/
      /*
        This is the windows-specific implementation of the open-url in the will-finish-launching event.

        This code is available in two different places. This one handles deep-linking from cold boot.
      */
      // Keep only command line / deep linked arguments
      if (typeof process.argv.slice(1)[0] !== 'undefined') {
        linkToLoadAtBoot = process.argv.slice(1)[0].substring(8)
      }
    }
    // Normal open-url event works for Mac and Linux
    if (linkToLoadAtBoot.length > 0) {
      ipc.callRenderer(win, 'RouteTo', linkToLoadAtBoot)
    }
  })
  win.webContents.on('will-navigate', function(e: any, reqUrl: any) {
    e.preventDefault()
    elc.shell.openExternal(reqUrl)
    // return
    // let getHost = function(url: any) { require('url').parse(url).host }
    // let reqHost = getHost(reqUrl)
    // let isExternal = reqHost && reqHost != getHost(win.webContents.getURL())
    // if (isExternal) {
//.........这里部分代码省略.........
开发者ID:nehbit,项目名称:aether-public,代码行数:101,代码来源:mainmain.ts

示例4: updateMenu


//.........这里部分代码省略.........
			}
		},
		{
			label: 'Show Unread Badge',
			type: 'checkbox',
			checked: config.get('showUnreadBadge'),
			click() {
				config.set('showUnreadBadge', !config.get('showUnreadBadge'));
			}
		},
		{
			label: 'Hardware Acceleration',
			type: 'checkbox',
			checked: config.get('hardwareAcceleration'),
			click() {
				config.set('hardwareAcceleration', !config.get('hardwareAcceleration'));
				showRestartDialog('Caprine needs to be restarted to change hardware acceleration.');
			}
		},
		{
			label: 'Always on Top',
			type: 'checkbox',
			accelerator: 'CommandOrControl+Shift+T',
			checked: config.get('alwaysOnTop'),
			click(menuItem, focusedWindow) {
				config.set('alwaysOnTop', menuItem.checked);
				focusedWindow.setAlwaysOnTop(menuItem.checked);
			}
		},
		{
			label: 'Launch at Login',
			visible: is.macos || is.windows,
			type: 'checkbox',
			checked: app.getLoginItemSettings().openAtLogin,
			click(menuItem) {
				app.setLoginItemSettings({
					openAtLogin: menuItem.checked,
					openAsHidden: menuItem.checked
				});
			}
		},
		{
			label: 'Auto Hide Menu Bar',
			type: 'checkbox',
			visible: !is.macos,
			checked: config.get('autoHideMenuBar'),
			click(menuItem, focusedWindow) {
				config.set('autoHideMenuBar', menuItem.checked);
				focusedWindow.setAutoHideMenuBar(menuItem.checked);
				focusedWindow.setMenuBarVisibility(!menuItem.checked);
			}
		},
		{
			label: 'Flash Window on Message',
			type: 'checkbox',
			visible: !is.macos,
			checked: config.get('flashWindowOnMessage'),
			click(menuItem) {
				config.set('flashWindowOnMessage', menuItem.checked);
			}
		},
		{
			label: 'Launch Minimized',
			type: 'checkbox',
			visible: !is.macos,
			checked: config.get('launchMinimized'),
开发者ID:nikteg,项目名称:caprine,代码行数:67,代码来源:menu.ts


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