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