本文整理匯總了TypeScript中electron.app._setDefaultAppPaths方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript app._setDefaultAppPaths方法的具體用法?TypeScript app._setDefaultAppPaths怎麽用?TypeScript app._setDefaultAppPaths使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類electron.app
的用法示例。
在下文中一共展示了app._setDefaultAppPaths方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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.name = packageJson.productName
} else if (packageJson.name) {
app.name = packageJson.name
}
app._setDefaultAppPaths(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
}
}
示例2:
app.name = `${packageJson.name}`.trim()
}
// Set application's desktop name.
if (packageJson.desktopName != null) {
app.setDesktopName(packageJson.desktopName)
} else {
app.setDesktopName(`${app.name}.desktop`)
}
// Set v8 flags
if (packageJson.v8Flags != null) {
v8.setFlagsFromString(packageJson.v8Flags)
}
app._setDefaultAppPaths(packagePath)
// Load the chrome devtools support.
require('@electron/internal/browser/devtools')
// Load the chrome extension support.
require('@electron/internal/browser/chrome-extension')
// Load protocol module to ensure it is populated on app ready
require('@electron/internal/browser/api/protocol')
// Set main startup script of the app.
const mainStartupScript = packageJson.main || 'index.js'
const KNOWN_XDG_DESKTOP_VALUES = ['Pantheon', 'Unity:Unity7', 'pop:GNOME']