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


TypeScript app.setAsDefaultProtocolClient方法代码示例

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


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

示例1: setAsDefaultProtocolClient

/**
 * Wrapper around app.setAsDefaultProtocolClient that adds our
 * custom prefix command line switches on Windows.
 */
function setAsDefaultProtocolClient(protocol: string) {
  if (__WIN32__) {
    app.setAsDefaultProtocolClient(protocol, process.execPath, [
      '--protocol-launcher',
    ])
  } else {
    app.setAsDefaultProtocolClient(protocol)
  }
}
开发者ID:ghmoore,项目名称:desktop,代码行数:13,代码来源:main.ts

示例2: it

    it('allows a custom path and args to be specified', () => {
      expect(app.isDefaultProtocolClient(protocol, updateExe, processStartArgs)).to.equal(false)
      app.setAsDefaultProtocolClient(protocol, updateExe, processStartArgs)

      expect(app.isDefaultProtocolClient(protocol, updateExe, processStartArgs)).to.equal(true)
      expect(app.isDefaultProtocolClient(protocol)).to.equal(false)
    })
开发者ID:malept,项目名称:electron,代码行数:7,代码来源:api-app-spec.ts

示例3: constructor

	constructor() {
		const rawOnOpenUrl = fromEventEmitter(app, 'open-url', (event: Electron.Event, url: string) => ({ event, url }));

		const uriEvent = mapEvent(rawOnOpenUrl, ({ event, url }) => {
			event.preventDefault();

			try {
				return URI.parse(url);
			} catch(e) {
				return null;
			}
		});

		this.onOpenURL = filterEvent(uriEvent, uri => !!uri);

		app.setAsDefaultProtocolClient(product.urlProtocol);
	}
开发者ID:GYGit,项目名称:vscode,代码行数:17,代码来源:urlService.ts

示例4: function

import * as Electron from 'electron';
import { Menu } from 'electron';
import { Subject} from 'rxjs';
import { getSettings, dispatch } from './settings';
import { WindowStateAction } from './reducers/windowStateReducer';
import * as url from 'url';
import * as path from 'path';
import * as log from './log';
import { Emulator } from './emulator';
import { WindowManager } from './windowManager';
import * as commandLine from './commandLine'
import * as electronLocalShortcut from 'electron-localshortcut';

// Ensure further options aren't passed to Chromium
Electron.app.setAsDefaultProtocolClient('botemulator', process.execPath, [
    '--protocol-launcher',
    '--'
]);

// Uncaught exception handler
(process as NodeJS.EventEmitter).on('uncaughtException', (error: Error) => {
    console.error(error);
    log.error('[err-server]', error.message.toString(), JSON.stringify(error.stack));
});

export let mainWindow: Electron.BrowserWindow;
export let windowManager: WindowManager;

var openUrls = [];
var onOpenUrl = function (event, url) {
    event.preventDefault();
    if (process.platform === 'darwin') {
开发者ID:sarthakfx,项目名称:BotFramework-Emulator,代码行数:32,代码来源:main.ts

示例5: now

app.on('ready', () => {
  if (isDuplicateInstance || handlingSquirrelEvent) {
    return
  }

  readyTime = now() - launchTime

  app.setAsDefaultProtocolClient('x-github-client')

  if (__DEV__) {
    app.setAsDefaultProtocolClient('x-github-desktop-dev-auth')
  } else {
    app.setAsDefaultProtocolClient('x-github-desktop-auth')
  }

  // Also support Desktop Classic's protocols.
  if (__DARWIN__) {
    app.setAsDefaultProtocolClient('github-mac')
  } else if (__WIN32__) {
    app.setAsDefaultProtocolClient('github-windows')
  }

  createWindow()

  let menu = buildDefaultMenu()
  Menu.setApplicationMenu(menu)

  ipcMain.on(
    'update-preferred-app-menu-item-labels',
    (
      event: Electron.IpcMessageEvent,
      labels: { editor?: string; shell: string }
    ) => {
      menu = buildDefaultMenu(labels.editor, labels.shell)
      Menu.setApplicationMenu(menu)
      if (mainWindow) {
        mainWindow.sendAppMenu()
      }
    }
  )

  ipcMain.on('menu-event', (event: Electron.IpcMessageEvent, args: any[]) => {
    const { name }: { name: MenuEvent } = event as any
    if (mainWindow) {
      mainWindow.sendMenuEvent(name)
    }
  })

  /**
   * An event sent by the renderer asking that the menu item with the given id
   * is executed (ie clicked).
   */
  ipcMain.on(
    'execute-menu-item',
    (event: Electron.IpcMessageEvent, { id }: { id: string }) => {
      const menuItem = findMenuItemByID(menu, id)
      if (menuItem) {
        const window = BrowserWindow.fromWebContents(event.sender)
        const fakeEvent = { preventDefault: () => {}, sender: event.sender }
        menuItem.click(fakeEvent, window, event.sender)
      }
    }
  )

  ipcMain.on(
    'update-menu-state',
    (
      event: Electron.IpcMessageEvent,
      items: Array<{ id: string; state: IMenuItemState }>
    ) => {
      let sendMenuChangedEvent = false

      for (const item of items) {
        const { id, state } = item
        const menuItem = findMenuItemByID(menu, id)

        if (menuItem) {
          // Only send the updated app menu when the state actually changes
          // or we might end up introducing a never ending loop between
          // the renderer and the main process
          if (
            state.enabled !== undefined &&
            menuItem.enabled !== state.enabled
          ) {
            menuItem.enabled = state.enabled
            sendMenuChangedEvent = true
          }
        } else {
          fatalError(`Unknown menu id: ${id}`)
        }
      }

      if (sendMenuChangedEvent && mainWindow) {
        mainWindow.sendAppMenu()
      }
    }
  )

  ipcMain.on(
    'show-contextual-menu',
//.........这里部分代码省略.........
开发者ID:tamdao,项目名称:desktop,代码行数:101,代码来源:main.ts

示例6: interceptShadowsocksLink

  // Someone tried to run a second instance, we should focus our window.
  if (mainWindow) {
    if (mainWindow.isMinimized() || !mainWindow.isVisible()) {
      mainWindow.restore();
      mainWindow.show();
    }
    mainWindow.focus();
  }
});

if (isSecondInstance) {
  console.log('another instance is running - exiting');
  app.quit();
}

app.setAsDefaultProtocolClient('ss');

function interceptShadowsocksLink(argv: string[]) {
  if (argv.length > 1) {
    const protocol = 'ss://';
    let url = argv[1];
    if (url.startsWith(protocol)) {
      if (mainWindow) {
        // The system adds a trailing slash to the intercepted URL (before the fragment).
        // Remove it before sending to the UI.
        url = `${protocol}${url.substr(protocol.length).replace(/\//g, '')}`;
        mainWindow.webContents.send('add-server', url);
      } else {
        console.error('called with URL but mainWindow not open');
      }
    }
开发者ID:hlyu368,项目名称:outline-client,代码行数:31,代码来源:index.ts

示例7: async


//.........这里部分代码省略.........
                    `There was an error with the certificate for ` +
                    `\`${certificate.subjectName}\` issued by \`${
                      certificate.issuerName
                    }\`.\n\n` +
                    `Please check your proxy configuration and try again.`,
                  detail: `If you ignore this error, the rest of the app might not work correctly.`,
                  buttons: [
                    {
                      label: "Ignore and continue",
                      className: "secondary",
                    },
                    {
                      label: ["menu.file.quit"],
                      action: actions.quit({}),
                    },
                  ],
                  widgetParams: null,
                })
              )
            );
          }
        );
        logger.debug(`Set up certificate error handler`);
      } catch (e) {
        logger.error(
          `Could not set up certificate error handler: ${e.stack ||
            e.message ||
            e}`
        );
      }

      try {
        const { session } = require("electron");
        const netSession = session.fromPartition(NET_PARTITION_NAME, {
          cache: false,
        });

        const envSettings: string =
          process.env.https_proxy ||
          process.env.HTTPS_PROXY ||
          process.env.http_proxy ||
          process.env.HTTP_PROXY;

        let proxySettings = {
          proxy: null as string,
          source: "os" as ProxySource,
        };

        if (envSettings) {
          logger.info(`Got proxy settings from environment: ${envSettings}`);
          proxySettings = {
            proxy: envSettings,
            source: "env",
          };
          testProxy = true;
          store.dispatch(actions.proxySettingsDetected(proxySettings));
        }
        await applyProxySettings(netSession, proxySettings);
      } catch (e) {
        logger.warn(
          `Could not detect proxy settings: ${e ? e.message : "unknown error"}`
        );
      }

      store.dispatch(actions.boot({}));
      dispatchedBoot = true;

      if (env.production && env.appName === "itch") {
        try {
          app.setAsDefaultProtocolClient("itchio");
          app.setAsDefaultProtocolClient("itch");
        } catch (e) {
          logger.error(
            `Could not set app as default protocol client: ${e.stack ||
              e.message ||
              e}`
          );
        }
      }

      if (process.platform === "win32") {
        try {
          await visualElements.createIfNeeded(new MinimalContext());
        } catch (e) {
          logger.error(
            `Could not run visualElements: ${e.stack || e.message || e}`
          );
        }
      }
    } catch (e) {
      throw e;
    } finally {
      const t2 = Date.now();
      logger.info(`preboot ran in ${elapsed(t1, t2)}`);
    }

    if (!dispatchedBoot) {
      store.dispatch(actions.boot({}));
    }
  });
开发者ID:HorrerGames,项目名称:itch,代码行数:101,代码来源:preboot.ts


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