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


TypeScript BrowserWindow.setTitle方法代码示例

本文整理汇总了TypeScript中electron.BrowserWindow.setTitle方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BrowserWindow.setTitle方法的具体用法?TypeScript BrowserWindow.setTitle怎么用?TypeScript BrowserWindow.setTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在electron.BrowserWindow的用法示例。


在下文中一共展示了BrowserWindow.setTitle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: 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

示例2: getSettings

const createMainWindow = () => {

    const windowTitle = "Bot Framework Emulator";

    const settings = getSettings();
    let initBounds: Electron.Rectangle = {
        width: settings.windowState.width || 0,
        height: settings.windowState.height || 0,
        x: settings.windowState.left || 0,
        y: settings.windowState.top || 0,
    }
    if (windowIsOffScreen(initBounds)) {
        let display = Electron.screen.getAllDisplays().find(display => display.id === settings.windowState.displayId);
        display = display || Electron.screen.getDisplayMatching(initBounds);
        initBounds.x = display.workArea.x;
        initBounds.y = display.workArea.y;
    }
    mainWindow = new Electron.BrowserWindow(
        {
            show: false,
            backgroundColor: '#f7f7f7',
            width: initBounds.width,
            height: initBounds.height,
            x: initBounds.x,
            y: initBounds.y
        });
    mainWindow.setTitle(windowTitle);
    windowManager = new WindowManager();

    //mainWindow.webContents.openDevTools();

    if (process.platform === 'darwin') {
        // Create the Application's main menu
        var template: Electron.MenuItemConstructorOptions[] = [
            {
                label: windowTitle,
                submenu: [
                    { label: "About", click: () => Emulator.send('show-about') },
                    { type: "separator" },
                    { label: "Quit", accelerator: "Command+Q", click: () => Electron.app.quit() }
                ]
            }, {
            label: "Edit",
            submenu: [
                { label: "Undo", accelerator: "CmdOrCtrl+Z", role: "undo" },
                { label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", role: "redo" },
                { type: "separator" },
                { label: "Cut", accelerator: "CmdOrCtrl+X", role: "cut" },
                { label: "Copy", accelerator: "CmdOrCtrl+C", role: "copy" },
                { label: "Paste", accelerator: "CmdOrCtrl+V", role: "paste" },
                { label: "Select All", accelerator: "CmdOrCtrl+A", role: "selectall" }
            ]}
        ];
        Menu.setApplicationMenu(Menu.buildFromTemplate(template));
    } else {
        Menu.setApplicationMenu(null);
    }

    const rememberBounds = () => {
        const bounds = mainWindow.getBounds();
        dispatch<WindowStateAction>({
            type: 'Window_RememberBounds',
            state: {
                displayId: Electron.screen.getDisplayMatching(bounds).id,
                width: bounds.width,
                height: bounds.height,
                left: bounds.x,
                top: bounds.y
            }
        });
    }

    mainWindow.on('resize', () => {
        rememberBounds();
    });

    mainWindow.on('move', () => {
        rememberBounds();
    });

    mainWindow.on('closed', function () {
        windowManager.closeAll();
        mainWindow = null;
    });

    mainWindow.on('restore', () => {
        if (windowIsOffScreen(mainWindow.getBounds())) {
            const bounds = mainWindow.getBounds();
            let display = Electron.screen.getAllDisplays().find(display => display.id === getSettings().windowState.displayId);
            display = display || Electron.screen.getDisplayMatching(bounds);
            mainWindow.setPosition(display.workArea.x, display.workArea.y);
            dispatch<WindowStateAction>({
                type: 'Window_RememberBounds',
                state: {
                    displayId: display.id,
                    width: bounds.width,
                    height: bounds.height,
                    left: display.workArea.x,
                    top: display.workArea.y
                }
//.........这里部分代码省略.........
开发者ID:sarthakfx,项目名称:BotFramework-Emulator,代码行数:101,代码来源:main.ts


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