本文整理汇总了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']