当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript app.setName方法代码示例

本文整理汇总了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')
    })
开发者ID:malept,项目名称:electron,代码行数:7,代码来源:api-app-spec.ts

示例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
  }
}
开发者ID:malept,项目名称:electron,代码行数:49,代码来源:main.ts

示例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
    })
})
开发者ID:m0g,项目名称:ansel,代码行数:54,代码来源:entry.ts

示例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);
}
开发者ID:bpasero,项目名称:fiddle,代码行数:19,代码来源:main.ts

示例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();
开发者ID:cocoflan,项目名称:fiddle-electron,代码行数:31,代码来源:main.ts

示例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"
    },
开发者ID:nteract,项目名称:nteract,代码行数:31,代码来源:menu.ts

示例7: setMenu

app.on('ready', () => {
  app.setName("Substudy")
  setMenu()
  mainWindow = createMainWindow()
})
开发者ID:emk,项目名称:substudy,代码行数:5,代码来源:index.ts

示例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)
}
开发者ID:vwvww,项目名称:electron,代码行数:30,代码来源:init.ts

示例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;
};
开发者ID:istvan-antal,项目名称:copycat,代码行数:30,代码来源:main.ts


注:本文中的electron.app.setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。