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


TypeScript shell.openExternalSync方法代码示例

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


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

示例1: click

export const setDefaultApplicationMenu = () => {
  if (v8Util.getHiddenValue<boolean>(global, 'applicationMenuSet')) return

  const helpMenu: Electron.MenuItemConstructorOptions = {
    role: 'help',
    submenu: [
      {
        label: 'Learn More',
        click () {
          shell.openExternalSync('https://electronjs.org')
        }
      },
      {
        label: 'Documentation',
        click () {
          shell.openExternalSync(
            `https://github.com/electron/electron/tree/v${process.versions.electron}/docs#readme`
          )
        }
      },
      {
        label: 'Community Discussions',
        click () {
          shell.openExternalSync('https://discuss.atom.io/c/electron')
        }
      },
      {
        label: 'Search Issues',
        click () {
          shell.openExternalSync('https://github.com/electron/electron/issues')
        }
      }
    ]
  }

  const macAppMenu: Electron.MenuItemConstructorOptions = { role: 'appMenu' }
  const template: Electron.MenuItemConstructorOptions[] = [
    ...(isMac ? [macAppMenu] : []),
    { role: 'fileMenu' },
    { role: 'editMenu' },
    { role: 'viewMenu' },
    { role: 'windowMenu' },
    helpMenu
  ]

  const menu = Menu.buildFromTemplate(template)
  Menu.setApplicationMenu(menu)
}
开发者ID:doridoridoriand,项目名称:electron,代码行数:48,代码来源:default-menu.ts

示例2: BrowserWindow

	webContents.on('new-window', (event: Event, url, frameName, _disposition, options) => {
		event.preventDefault();

		if (url === 'about:blank') {
			if (frameName !== 'about:blank') {
				// Voice/video call popup
				options.show = true;
				options.titleBarStyle = 'default';
				options.webPreferences.nodeIntegration = false;
				options.webPreferences.preload = path.join(__dirname, 'browser-call.js');
				(event as any).newGuest = new BrowserWindow(options);
			}
		} else {
			if (url.startsWith(trackingUrlPrefix)) {
				url = new URL(url).searchParams.get('u')!;
			}

			shell.openExternalSync(url);
		}
	});
开发者ID:nikteg,项目名称:caprine,代码行数:20,代码来源:index.ts

示例3: URL

	webContents.on('will-navigate', (event, url) => {
		const isMessengerDotCom = (url: string): boolean => {
			const {hostname} = new URL(url);
			return hostname.endsWith('.messenger.com');
		};

		const isTwoFactorAuth = (url: string): boolean => {
			const twoFactorAuthURL = 'https://www.facebook.com/checkpoint/start';
			return url.startsWith(twoFactorAuthURL);
		};

		const isWorkChat = (url: string): boolean => {
			const {hostname, pathname} = new URL(url);

			if (hostname === 'work.facebook.com' || hostname === 'work.workplace.com') {
				return true;
			}

			if (
				// Example: https://company-name.facebook.com/login or
				//   		https://company-name.workplace.com/login
				(hostname.endsWith('.facebook.com') || hostname.endsWith('.workplace.com')) &&
				(pathname.startsWith('/login') || pathname.startsWith('/chat'))
			) {
				return true;
			}

			if (hostname === 'login.microsoftonline.com') {
				return true;
			}

			return false;
		};

		if (isMessengerDotCom(url) || isTwoFactorAuth(url) || isWorkChat(url)) {
			return;
		}

		event.preventDefault();
		shell.openExternalSync(url);
	});
开发者ID:nikteg,项目名称:caprine,代码行数:41,代码来源:index.ts

示例4:

 const openLinkExternally = (e: Event) => {
   e.preventDefault()
   shell.openExternalSync(url)
 }
开发者ID:vwvww,项目名称:electron,代码行数:4,代码来源:renderer.ts


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