本文整理汇总了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();
}
});
示例2:
app.once('window-all-closed', () => app.quit());
示例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();
}
示例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
})
})
示例5:
.subscribe(() => {
if (process.platform !== `darwin`) {
app.quit();
}
});
示例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
}
示例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);
示例9: Observable
const electronReady$ = new Observable(observer => {
app.on("ready", (event: Event) => observer.next(event));
});