當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript module._load函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。