本文整理汇总了TypeScript中module._load函数的典型用法代码示例。如果您正苦于以下问题:TypeScript _load函数的具体用法?TypeScript _load怎么用?TypeScript _load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_load函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: loadApplicationPackage
function loadApplicationPackage (packagePath: string) {
// Add a flag indicating app is started from default app.
Object.defineProperty(process, 'defaultApp', {
configurable: false,
enumerable: true,
value: true
})
try {
// Override app name and version.
packagePath = path.resolve(packagePath)
const packageJsonPath = path.join(packagePath, 'package.json')
if (fs.existsSync(packageJsonPath)) {
let packageJson
try {
packageJson = require(packageJsonPath)
} catch (e) {
showErrorMessage(`Unable to parse ${packageJsonPath}\n\n${e.message}`)
return
}
if (packageJson.version) {
app.setVersion(packageJson.version)
}
if (packageJson.productName) {
app.setName(packageJson.productName)
} else if (packageJson.name) {
app.setName(packageJson.name)
}
app.setPath('userData', path.join(app.getPath('appData'), app.getName()))
app.setPath('userCache', path.join(app.getPath('cache'), app.getName()))
app.setAppPath(packagePath)
}
try {
Module._resolveFilename(packagePath, module, true)
} catch (e) {
showErrorMessage(`Unable to find Electron app at ${packagePath}\n\n${e.message}`)
return
}
// Run the app.
Module._load(packagePath, module, true)
} catch (e) {
console.error('App threw an error during load')
console.error(e.stack || e)
throw e
}
}
开发者ID:malept,项目名称:electron,代码行数:49,代码来源:main.ts
示例2: join
const DISCORD_APP_ROOT = process.env.DISCORD_APP_ROOT || join(__dirname, "../app.asar")
PatchModule("electron", {
// Injector for the renderer thread
// Based on the injector in https://github.com/DiscordInjections/DiscordInjections
BrowserWindow: Object.assign(function(userOptions: BrowserWindowConstructorOptions) {
const options = Object.assign({}, userOptions);
options.webPreferences = Object.assign({}, options.webPreferences)
options.webPreferences.preload = join(dirname(DISCORD_APP_ROOT), "app");
options.webPreferences.webSecurity = false;
options.webPreferences.experimentalFeatures = true;
const win = new BrowserWindow(options);
// Allow the renderer process to act on the options
win.__options = userOptions
return win;
}, BrowserWindow)
}, {
BrowserWindow: "../../browser-window.js"
})
// Starting the application
const Module = require("module");
const AppPath = DISCORD_APP_ROOT;
const AppPackage = require(join(AppPath, "package.json"));
// Adjust electron root
app.getAppPath = () => AppPath;
// Load Discord
Module._load(join(AppPath, AppPackage.main || "index.js"), null, true);
开发者ID:devpixel12,项目名称:twitchcord-1,代码行数:30,代码来源:main.ts
示例3: import
return false
}
// Workaround for electron/electron#5050 and electron/electron#9046
if (currentPlatformSupportsAppIndicator()) {
process.env.XDG_CURRENT_DESKTOP = 'Unity'
}
// Quit when all windows are closed and no other one is listening to this.
app.on('window-all-closed', () => {
if (app.listenerCount('window-all-closed') === 1) {
app.quit()
}
})
Promise.all([
import('@electron/internal/browser/default-menu'),
app.whenReady
]).then(([{ setDefaultApplicationMenu }]) => {
// Create default menu
setDefaultApplicationMenu()
})
if (packagePath) {
// Finally load app's main.js and transfer control to C++.
Module._load(path.join(packagePath, mainStartupScript), Module, true)
} else {
console.error('Failed to locate a valid package to load (app, app.asar or default_app.asar)')
console.error('This normally means you\'ve damaged the Electron package somehow')
}
开发者ID:vwvww,项目名称:electron,代码行数:30,代码来源:init.ts
注:本文中的module._load函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论