本文整理汇总了TypeScript中electron.app.setName方法的典型用法代码示例。如果您正苦于以下问题:TypeScript app.setName方法的具体用法?TypeScript app.setName怎么用?TypeScript app.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.app
的用法示例。
在下文中一共展示了app.setName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('overrides the name', () => {
expect(app.getName()).to.equal('Electron Test Main')
app.setName('test-name')
expect(app.getName()).to.equal('test-name')
app.setName('Electron Test')
})
示例2: 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
}
}
示例3: BrowserWindow
app.on('ready', () => {
let cursorPos = screen.getCursorScreenPoint()
let workAreaSize = screen.getDisplayNearestPoint(cursorPos).workAreaSize
app.setName('Ansel')
mainWindow = new BrowserWindow({
width: 1356,
height: 768,
title: 'Ansel',
titleBarStyle: 'hiddenInset',
backgroundColor: '#37474f', // @blue-grey-800
webPreferences: {
experimentalFeatures: true,
blinkFeatures: 'CSSGridLayout'
}
})
if (workAreaSize.width <= 1366 && workAreaSize.height <= 768)
mainWindow.maximize()
mainWindow.loadURL('file://' + __dirname + '/../../static/index.html')
mainWindow.setTitle('Ansel')
initBackgroundService(mainWindow)
initForegroundClient(mainWindow)
//let usb = new Usb()
//
//usb.scan((err, drives) => {
// mainWindow.webContents.send('scanned-devices', drives)
//})
//
//usb.watch((err, action, drive) => {
// if (action === 'add')
// mainWindow.webContents.send('add-device', drive)
// else
// mainWindow.webContents.send('remove-device', drive)
//})
if (fs.existsSync(config.settings)) {
initLibrary(mainWindow)
} else {
initDb()
ipcMain.on('settings-created', () => initLibrary(mainWindow))
}
// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
})
})
示例4: main
export function main() {
// Handle creating/removing shortcuts on Windows when
// installing/uninstalling.
if (shouldQuit()) {
app.quit();
return;
}
// Set the app's name
app.setName('Electron Fiddle');
// Ensure that there's only ever one Fiddle running
listenForProtocolHandler();
// Launch
app.on('ready', onReady);
app.on('window-all-closed', onWindowsAllClosed);
app.on('activate', getOrCreateMainWindow);
}
示例5: async
import { app } from 'electron';
import { isDevMode } from '../utils/devmode';
import { setupDialogs } from './dialogs';
import { listenForProtocolHandler, setupProtocolHandler } from './protocol';
import { setupUpdates } from './update';
import { getOrCreateMainWindow } from './windows';
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) {
app.quit();
}
app.setName('Electron Fiddle');
listenForProtocolHandler();
app.on('ready', async () => {
// If we're packaged, we want to run
// React in production mode.
if (!isDevMode()) {
process.env.NODE_ENV = 'production';
}
getOrCreateMainWindow();
const { setupMenu } = await import('./menu');
const { setupFileListeners } = await import('./files');
setupMenu();
setupProtocolHandler();
示例6:
label: "Install Additional Kernels",
click: () => {
shell.openExternal("https://nteract.io/kernels");
}
}
] as any[]
};
if (process.platform !== "darwin") {
helpDraft.submenu.unshift(shellCommands, { type: "separator" });
}
export const help = helpDraft;
const name = "nteract";
app.setName(name);
export const named = {
label: name,
submenu: [
{
label: `About ${name}`,
role: "about"
},
{
type: "separator"
},
shellCommands,
{
type: "separator"
},
示例7: setMenu
app.on('ready', () => {
app.setName("Substudy")
setMenu()
mainWindow = createMainWindow()
})
示例8: Error
if (packageJson == null) {
process.nextTick(function () {
return process.exit(1)
})
throw new Error('Unable to find a valid app')
}
// Set application's version.
if (packageJson.version != null) {
app.setVersion(packageJson.version)
}
// Set application's name.
if (packageJson.productName != null) {
app.setName(`${packageJson.productName}`.trim())
} else if (packageJson.name != null) {
app.setName(`${packageJson.name}`.trim())
}
// Set application's desktop name.
if (packageJson.desktopName != null) {
app.setDesktopName(packageJson.desktopName)
} else {
app.setDesktopName((app.getName()) + '.desktop')
}
// Set v8 flags
if (packageJson.v8Flags != null) {
v8.setFlagsFromString(packageJson.v8Flags)
}
示例9: join
let mainWindow: BrowserWindow | null;
const appFolderPath = join(app.getPath('appData'), 'CopyCat');
const settingsFile = join(appFolderPath, 'state.json');
const DEV_MODE = true;
if (!existsSync(appFolderPath)) {
mkdirSync(appFolderPath);
}
if (!existsSync(settingsFile)) {
writeFileSync(settingsFile, '{}');
}
if (DEV_MODE) {
app.setName('CopyCat');
}
let tray: Tray;
const foldersSyncing: Folder[] = [];
const foldersToSync: Folder[] = [];
const findIndex = <T>(array: T[], fn: (item: T) => boolean) => {
for (let i = 0; i < array.length; i += 1) {
if (fn(array[i])) {
return i;
}
}
return -1;
};