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


TypeScript app.commandLine.appendSwitch方法代码示例

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


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

示例1: async



process.on('uncaughtException', (error) => {
    appDelegate.preventQuit = true;

    logMonitor.logException(error);
    console.error('Uncaught Exception: ', error.toString());

    if (error.stack) {
        console.error(error.stack);
    }
});


if (!environment.production) {
    app.commandLine.appendSwitch('remote-debugging-port', '9229');
}


logMonitor.install('main-process');


app.once('ready', async () => {
    try {
        await appDelegate.run();
        console.log('START! 🤔');
    } catch (error) {
        console.error(error);
        process.exit(1);
    }
});
开发者ID:suiruiw,项目名称:geeks-diary,代码行数:29,代码来源:main.ts

示例2: openMainBracketsWindow

export function openMainBracketsWindow(query: {} | string = {}): Electron.BrowserWindow {

    // compose path to brackets' index file
    const indexPath = "file:///" + convertWindowsPathToUnixPath(path.resolve(__dirname, "www", "index.html"));

    // build a query for brackets' window
    let queryString = "";
    if (_.isObject(query) && !_.isEmpty(query)) {
        const queryObj = query as _.Dictionary<string>;
        queryString = "?" + _.map(queryObj, function (value, key) {
            return key + "=" + encodeURIComponent(value);
        }).join("&");
    } else if (_.isString(query)) {
        const queryStr = query as string;
        const io1 = queryStr.indexOf("?");
        const io2 = queryStr.indexOf("#");
        if (io1 !== -1) {
            queryString = queryStr.substring(io1);
        } else if (io2 !== -1) {
            queryString = queryStr.substring(io2);
        } else {
            queryString = "";
        }
    }

    const indexUrl = indexPath + queryString;

    const winOptions = {
        title: appInfo.productName,
        x: shellConfig.getNumber("window.posX"),
        y: shellConfig.getNumber("window.posY"),
        width: shellConfig.getNumber("window.width"),
        height: shellConfig.getNumber("window.height"),
        webPreferences: {
            nodeIntegration: false,
            preload: path.resolve(__dirname, "preload.js")
        }
    };

    const bracketsPreferences = readBracketsPreferences();

    const blinkFeatures = _.get(bracketsPreferences, "shell.blinkFeatures");
    if (typeof blinkFeatures === "string" && blinkFeatures.length > 0) {
        _.set(winOptions, "webPreferences.blinkFeatures", blinkFeatures);
    }

    const disableBlinkFeatures = _.get(bracketsPreferences, "shell.disableBlinkFeatures");
    if (typeof disableBlinkFeatures === "string" && disableBlinkFeatures.length > 0) {
        _.set(winOptions, "webPreferences.disableBlinkFeatures", disableBlinkFeatures);
    }

    const smoothScrolling = _.get(bracketsPreferences, "shell.smoothScrolling", true);
    if (!smoothScrolling) {
        app.commandLine.appendSwitch("disable-smooth-scrolling");
    }

    // create the browser window
    const win = new BrowserWindow(winOptions);
    if (process.argv.indexOf("--devtools") !== -1) {
        win.webContents.openDevTools({ mode: "detach" });
    }
    wins.push(win);

    // load the index.html of the app
    log.info(`loading brackets window at ${indexUrl}`);
    win.loadURL(indexUrl);
    if (shellConfig.get("window.maximized")) {
        win.maximize();
    }

    // emitted when the window is closed
    win.on("closed", function () {
        // Dereference the window object, usually you would store windows
        // in an array if your app supports multi windows, this is the time
        // when you should delete the corresponding element.
        const io = wins.indexOf(win);
        if (io !== -1) { wins.splice(io, 1); }
    });

    // this is used to remember the size from the last time
    // emitted before the window is closed
    win.on("close", function () {
        saveWindowPositionSync(win);
    });
    win.on("maximize", function () {
        saveWindowPosition(win);
    });
    win.on("unmaximize", function () {
        saveWindowPosition(win);
    });
    win.on("resize", function () {
        saveWindowPosition(win);
    });
    win.on("move", function () {
        saveWindowPosition(win);
    });

    return win;
}
开发者ID:zaggino,项目名称:brackets-electron,代码行数:99,代码来源:main.ts

示例3: it

 it('returns the value when present', () => {
   app.commandLine.appendSwitch('foobar', 'æøåü')
   expect(app.commandLine.getSwitchValue('foobar')).to.equal('æøåü')
 })
开发者ID:malept,项目名称:electron,代码行数:4,代码来源:api-app-spec.ts

示例4: require

///<reference path="window/main.ts"/>
import { MessageServer, AppMessageServer } from './backgroundLibs/msg/msg';
import { AdBlocking } from './backgroundLibs/adblocking/adblocking';
import { Shortcuts } from './backgroundLibs/shortcuts/shortcuts';
import { RemoteServer }  from './backgroundLibs/remote/remote';
import { Settings } from './backgroundLibs/settings/settings';
import { Updater } from './backgroundLibs/updater/updater';
import { app, BrowserWindow, Tray, Menu } from 'electron';
import { log, error } from './backgroundLibs/log/log';
import AutoLaunch = require('auto-launch');
import path = require('path');
import url = require('url');

app.commandLine.appendSwitch('widevine-cdm-path', path.join(__dirname, 'widevine', 'widevinecdmadapter.dll'));
app.commandLine.appendSwitch('widevine-cdm-version', '1.4.8.984');

const appData = app.getPath('appData');
const logger = require('logger').createLogger(path.join(appData, 'media-app', 'log.log'));

export namespace MediaApp {
	let resolveBrowserWindow: (win: Electron.BrowserWindow) => void = null;

	export namespace Refs {
		export let tray: Electron.Tray = null;
		export let messageServer: MessageServer = null;
		export let idGenerator: AppMessageServer = null;
		export let activeWindow: Electron.BrowserWindow = null;
		export let activeWindowPromise: Promise<Electron.BrowserWindow> = new Promise((resolve) => {
			resolveBrowserWindow = resolve;
		});
		export const DEBUG = !!process.argv.filter(arg => arg.indexOf('debugging') > -1).length;		
开发者ID:SanderRonde,项目名称:youtube-music-app,代码行数:31,代码来源:app.ts

示例5: main

export function main() {
  mainLogger.info(
    `${env.appName}@${app.getVersion()} on electron@${
      process.versions.electron
    } in ${env.production ? "production" : "development"}`
  );

  if (process.env.CAPSULE_LIBRARY_PATH) {
    // disable acceleration when captured by capsule
    app.disableHardwareAcceleration();
  } else {
    try {
      const prefs = loadPreferencesSync();
      if (prefs.disableHardwareAcceleration) {
        app.disableHardwareAcceleration();
      }
    } catch (e) {
      // oh well
    }
  }

  if (env.production) {
    app.enableMixedSandbox();
  }

  // cf. https://github.com/itchio/itch/issues/2026
  app.commandLine.appendSwitch("ignore-connections-limit", "127.0.0.1");

  if (process.env.ITCH_IGNORE_CERTIFICATE_ERRORS === "1") {
    app.commandLine.appendSwitch("ignore-certificate-errors");
  }
  protocol.registerStandardSchemes(["itch-cave", "itch"]);

  let store: Store = require("main/store").default;

  let onReady = () => {
    if (!env.integrationTests) {
      const shouldQuit = app.makeSingleInstance((argv, cwd) => {
        // we only get inside this callback when another instance
        // is launched - so this executes in the context of the main instance
        store.dispatch(
          actions.processUrlArguments({
            args: argv,
          })
        );
        store.dispatch(actions.focusWind({ wind: "root" }));
      });
      if (shouldQuit) {
        app.exit(0);
        return;
      }
    }

    store.dispatch(
      actions.processUrlArguments({
        args: process.argv,
      })
    );

    globalShortcut.register("Control+Alt+Backspace", function() {
      store.dispatch(actions.forceCloseLastGame({}));
    });

    // Emitted when the application is activated. Various actions can trigger
    // this event, such as launching the application for the first time,
    // attempting to re-launch the application when it's already running, or
    // clicking on the application's dock or taskbar icon.
    app.on("activate", () => {
      store.dispatch(actions.focusWind({ wind: "root" }));
    });

    app.on("before-quit", e => {
      e.preventDefault();
      store.dispatch(actions.quit({}));
    });

    store.dispatch(actions.preboot({}));

    setInterval(() => {
      try {
        store.dispatch(actions.tick({}));
      } catch (e) {
        mainLogger.error(`While dispatching tick: ${e.stack}`);
      }
    }, 1 * 1000 /* every second */);
  };
  app.on("ready", onReady);

  app.on("will-finish-launching", () => {
    app.setAppUserModelId(appUserModelId);
  });

  // macOS (Info.pList)
  app.on("open-url", (e: Event, url: string) => {
    if (isItchioURL(url)) {
      // otherwise it'll err -600
      e.preventDefault();
      store.dispatch(actions.handleItchioURI({ uri: url }));
    }
  });
//.........这里部分代码省略.........
开发者ID:itchio,项目名称:itch,代码行数:101,代码来源:main.ts

示例6: electronDebug

electronDebug({
	enabled: true, // TODO: This is only enabled to allow `Command+R` because messenger sometimes gets stuck after computer waking up
	showDevTools: false
});

electronDl();
electronContextMenu();

const domain = config.get('useWorkChat') ? 'facebook.com' : 'messenger.com';

app.setAppUserModelId('com.sindresorhus.caprine');

// Disables broken color space correction in Chromium.
// You can see differing background color on the login screen.
// https://github.com/electron/electron/issues/9671
app.commandLine.appendSwitch('disable-color-correct-rendering');

if (!config.get('hardwareAcceleration')) {
	app.disableHardwareAcceleration();
}

if (!isDev) {
	log.transports.file.level = 'info';
	autoUpdater.logger = log;

	const FOUR_HOURS = 1000 * 60 * 60 * 4;
	setInterval(() => {
		autoUpdater.checkForUpdates();
	}, FOUR_HOURS);

	autoUpdater.checkForUpdates();
开发者ID:kusamakura,项目名称:caprine,代码行数:31,代码来源:index.ts

示例7: createWindow

// user wants to use eg. NW.js, Electron or just the web. Additionally
// @types/electron was removed from package.json as it appears to no longer be
// updated and installing it will show an warning when compiling via Grunt.

import * as path from "path";
import { app, BrowserWindow } from "electron";

let mainWindow: Electron.BrowserWindow;

// found an issue with recent versions of electron in that focus would run crazy
// in certain situations.
//
// issue: https://github.com/electron/electron/issues/7655
//
// this command line switch seems to make the problem go away
app.commandLine.appendSwitch("enable-use-zoom-for-dsf", "false");

function createWindow(): void {
  mainWindow = new BrowserWindow({
    fullscreenable: true,
    autoHideMenuBar: true,
    useContentSize: true,
    icon: `${__dirname}${path.sep}..${path.sep}public${path.sep}images${path.sep}toby.png`,
    backgroundColor: "#000",
    width: 640,
    height: 400,
    minWidth: 640,
    minHeight: 400,
    show: false
  });
  mainWindow.setMenu(null);
开发者ID:frankhale,项目名称:toby,代码行数:31,代码来源:electron.ts

示例8: main

function main() {
  if (process.env.CAPSULE_LIBRARY_PATH) {
    // disable acceleration when captured by capsule
    app.disableHardwareAcceleration();
  } else {
    try {
      const prefs = loadPreferencesSync();
      if (prefs.disableHardwareAcceleration) {
        app.disableHardwareAcceleration();
      }
    } catch (e) {
      // oh well
    }
  }

  if (env.production) {
    app.enableMixedSandbox();
  }

  if (process.env.ITCH_IGNORE_CERTIFICATE_ERRORS === "1") {
    app.commandLine.appendSwitch("ignore-certificate-errors");
  }
  protocol.registerStandardSchemes(["itch-cave"]);

  let store: IStore = require("main/store").default;

  let onReady = () => {
    if (!env.integrationTests) {
      const shouldQuit = app.makeSingleInstance((argv, cwd) => {
        // we only get inside this callback when another instance
        // is launched - so this executes in the context of the main instance
        store.dispatch(
          actions.processUrlArguments({
            args: argv,
          })
        );
        store.dispatch(actions.focusWindow({ window: "root" }));
      });

      if (shouldQuit) {
        app.exit(0);
        return;
      }
    }

    store.dispatch(
      actions.processUrlArguments({
        args: process.argv,
      })
    );

    globalShortcut.register("Control+Alt+Backspace", function() {
      store.dispatch(actions.forceCloseLastGame({}));
    });

    if (rt) {
      rt.end();
    }

    store.dispatch(actions.preboot({}));

    setInterval(() => {
      try {
        store.dispatch(actions.tick({}));
      } catch (e) {
        logger.error(`While dispatching tick: ${e.stack}`);
      }
    }, 1 * 1000 /* every second */);
  };
  app.on("ready", onReady);

  app.on("will-finish-launching", () => {
    app.setAppUserModelId(appUserModelId);
  });

  // macOS (Info.pList)
  app.on("open-url", (e: Event, url: string) => {
    if (isItchioURL(url)) {
      // otherwise it'll err -600
      e.preventDefault();
      store.dispatch(actions.handleItchioURI({ uri: url }));
    }
  });
}
开发者ID:HorrerGames,项目名称:itch,代码行数:84,代码来源:metal.ts


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