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


TypeScript electron.app类代码示例

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


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

示例1: createWindow

import * as path from 'path';
import * as appConfig from './app-config';

let window:any;

var createWindow = () => {
    window = new Electron.BrowserWindow({
        width: 1400,
        height: 800,
        title: 'Hello World'
    });
    window.loadURL(`file://${path.join(appConfig.APP_TEMPLATE_PATH, '/index.html')}`);
    // window.webContents.openDevTools();
    window.on('closed', () => {
        window = null;
    });
};

Electron.app.on('ready', createWindow);

Electron.app.on('window-all-closed', () => {
    if (process.platform !== 'drawin') {
        Electron.app.quit();
    }
});

Electron.app.on('activate', () => {
    if (window == null) {
        createWindow();
    }
});
开发者ID:TrojanBox,项目名称:electron-bootstrap,代码行数:31,代码来源:main.ts

示例2:

app.once('window-all-closed', () => app.quit());
开发者ID:haifengkao,项目名称:NyaoVim-Unofficial,代码行数:1,代码来源:main.ts

示例3: constructor

	constructor() {
		this._appRoot = path.dirname(URI.parse(require.toUrl('')).fsPath);
		this._currentWorkingDirectory = process.env['VSCODE_CWD'] || process.cwd();
		this._appHome = app.getPath('userData');
		this._appSettingsHome = path.join(this._appHome, 'User');
		this._appSettingsPath = path.join(this._appSettingsHome, 'settings.json');
		this._appKeybindingsPath = path.join(this._appSettingsHome, 'keybindings.json');

		// Remove the Electron executable
		let [, ...args] = process.argv;

		// If dev, remove the first non-option argument: it's the app location
		if (!this.isBuilt) {
			const index = arrays.firstIndex(args, a => !/^-/.test(a));

			if (index > -1) {
				args.splice(index, 1);
			}
		}

		// Finally, prepend any extra arguments from the 'argv' file
		if (fs.existsSync(path.join(this._appRoot, 'argv'))) {
			const extraargs: string[] = JSON.parse(fs.readFileSync(path.join(this._appRoot, 'argv'), 'utf8'));
			args = [...extraargs, ...args];
		}

		const argv = parseArgs(args);

		const debugBrkExtensionHostPort = getNumericValue(argv.debugBrkPluginHost, 5870);
		const debugExtensionHostPort = getNumericValue(argv.debugPluginHost, 5870, this.isBuilt ? void 0 : 5870);
		const pathArguments = parsePathArguments(this._currentWorkingDirectory, argv._, argv.goto);
		const timestamp = parseInt(argv.timestamp);
		const debugBrkFileWatcherPort = getNumericValue(argv.debugBrkFileWatcherPort, void 0);

		this._cliArgs = Object.freeze({
			pathArguments: pathArguments,
			programStart: types.isNumber(timestamp) ? timestamp : 0,
			enablePerformance: argv.performance,
			verboseLogging: argv.verbose,
			debugExtensionHostPort: debugBrkExtensionHostPort || debugExtensionHostPort,
			debugBrkExtensionHost: !!debugBrkExtensionHostPort,
			logExtensionHostCommunication: argv.logExtensionHostCommunication,
			debugBrkFileWatcherPort: debugBrkFileWatcherPort,
			openNewWindow: argv['new-window'],
			openInSameWindow: argv['reuse-window'],
			gotoLineMode: argv.goto,
			diffMode: argv.diff && pathArguments.length === 2,
			extensionsHomePath: normalizePath(argv.extensionHomePath),
			extensionDevelopmentPath: normalizePath(argv.extensionDevelopmentPath),
			extensionTestsPath: normalizePath(argv.extensionTestsPath),
			disableExtensions: argv['disable-extensions'],
			locale: argv.locale,
			waitForWindowClose: argv.wait
		});

		this._isTestingFromCli = this.cliArgs.extensionTestsPath && !this.cliArgs.debugBrkExtensionHost;
		this._userHome = path.join(os.homedir(), product.dataFolderName);
		this._userExtensionsHome = this.cliArgs.extensionsHomePath || path.join(this._userHome, 'extensions');
		this._mainIPCHandle = this.getMainIPCHandle();
		this._sharedIPCHandle = this.getSharedIPCHandle();
	}
开发者ID:Ayush-Mahajan,项目名称:vscode,代码行数:61,代码来源:env.ts

示例4: BrowserWindow

    protocol,
    Tray,
    clipboard,
    crashReporter,
    nativeImage,
    screen,
    shell
} from 'electron'

// crashReporter.start(null)

var mainWindow: Electron.BrowserWindow = null;

app.on('window-all-closed', () => {
    if (process.platform != 'darwin') {
        app.quit()
    }
})

app.on('ready', () => {
    mainWindow = new BrowserWindow({
        width: 800,
        height: 600
    })
    mainWindow.loadURL('file://' + __dirname + '/../../index.html')

    mainWindow.on('closed', () => {
        mainWindow = null
    })
})
开发者ID:kakajika,项目名称:Labbie,代码行数:30,代码来源:main.ts

示例5:

 .subscribe(() => {
     if (process.platform !== `darwin`) {
         app.quit();
     }
 });
开发者ID:LakeMaps,项目名称:hangashore,代码行数:5,代码来源:index.ts

示例6: decorateURL

import { app, dialog, BrowserWindow, shell, ipcMain } from 'electron'
import * as path from 'path'

let mainWindow: BrowserWindow | null = null

// Quit when all windows are closed.
app.on('window-all-closed', () => {
  app.quit()
})

function decorateURL (url: string) {
  // safely add `?utm_source=default_app
  const parsedUrl = new URL(url)
  parsedUrl.searchParams.append('utm_source', 'default_app')
  return parsedUrl.toString()
}

// Find the shortest path to the electron binary
const absoluteElectronPath = process.execPath
const relativeElectronPath = path.relative(process.cwd(), absoluteElectronPath)
const electronPath = absoluteElectronPath.length < relativeElectronPath.length
  ? absoluteElectronPath
  : relativeElectronPath

const indexPath = path.resolve(app.getAppPath(), 'index.html')

function isTrustedSender (webContents: Electron.WebContents) {
  if (webContents !== (mainWindow && mainWindow.webContents)) {
    return false
  }
开发者ID:malept,项目名称:electron,代码行数:30,代码来源:default_app.ts

示例7: BrowserWindow

import "source-map-support/register";
import * as util from "util";
import { app, BrowserWindow, ipcMain } from "electron";

let windows: GitHubElectron.BrowserWindow[] = [];

let openWindow = (uri: string, options: GitHubElectron.BrowserWindowOptions) => {
    let window = new BrowserWindow(options);
    windows.push(window);
    window.loadURL("file://" + __dirname + uri);
    window.on("closed", () => windows.splice(windows.indexOf(window)));
};

app.on("window-all-closed", () => {
    // FIXME: quit on close should be a setting
    // if (process.platform != "darwin") {
    app.quit();
    // }
});

app.on("ready", () => {
    ipcMain.on("console-log", (event, msg, ...args) => {
        if (typeof msg !== "string") {
            msg = util.inspect(msg);
        }
        console.log("[Browser] " + msg, ...args);
    });
    ipcMain.on("console-error", (event, msg, ...args) => {
        if (typeof msg !== "string") {
            msg = util.inspect(msg);
        }
        console.error("[Browser ERROR] " + msg, ...args);
开发者ID:gitter-badger,项目名称:mongoForge,代码行数:32,代码来源:main.ts

示例8:

 index => {
   if (index === 0) {
     app.quit();
   }
 }
开发者ID:nteract,项目名称:nteract,代码行数:5,代码来源:index.ts

示例9: Observable

const electronReady$ = new Observable(observer => {
  app.on("ready", (event: Event) => observer.next(event));
});
开发者ID:nteract,项目名称:nteract,代码行数:3,代码来源:index.ts


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