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