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


TypeScript BrowserWindow.loadURL方法代码示例

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


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

示例1: createMainWindow

//-----------------------------------------------
// Main function
//-----------------------------------------------
function createMainWindow() {
  mainWindow = new BrowserWindow({
    width: config.get('window.width'),
    height: config.get('window.height'),
    x: config.get('window.x'),
    y: config.get('window.y')
  })

  mainWindow.loadURL(`file://${__dirname}/ui/index.html`)

  //mainWindow.webContents.openDevTools()

  mainWindow.on('close', () => {
    const win = mainWindow.getBounds()

    config.set('window.x', win.x)
    config.set('window.y', win.y)
    config.set('window.height', win.height)
    config.set('window.width', win.width)
  })

  mainWindow.on('closed', () => {
    mainWindow = null
  })
}
开发者ID:ilmaria,项目名称:laskutus-electron,代码行数:28,代码来源:main.ts

示例2: getMainWindow

function getMainWindow(): Electron.BrowserWindow {
    const workAreaSize = screen.getPrimaryDisplay().workAreaSize;

    if (!browserWindow) {
        let options: Electron.BrowserWindowOptions = {
            webPreferences: {
                experimentalFeatures: true,
                experimentalCanvasFeatures: true,
            },
            titleBarStyle: "hidden",
            resizable: true,
            minWidth: 500,
            minHeight: 300,
            width: workAreaSize.width,
            height: workAreaSize.height,
            show: false,
        };
        browserWindow = new BrowserWindow(options);

        browserWindow.loadURL("file://" + __dirname + "/../views/index.html");
        menu.setMenu(app, browserWindow);

        browserWindow.on("closed", (): void => browserWindow = undefined)
                     .on("focus", (): void => app.dock && app.dock.setBadge(""));

        browserWindow.webContents.on("did-finish-load", () => {
            browserWindow.show();
            browserWindow.focus();
        });
    }

    return browserWindow;
}
开发者ID:F2Ealexis,项目名称:black-screen,代码行数:33,代码来源:Main.ts

示例3: createWindow

function createWindow() {

  const size = screen.getPrimaryDisplay().workAreaSize;

  // Create the browser window.
  win = new BrowserWindow({
    x: 0,
    y: 0,
    width: size.width,
    height: size.height
  });

  // and load the index.html of the app.
  win.loadURL(url.format({
    protocol: 'file:',
    pathname: path.join(__dirname, '/index.html'),
    slashes: true
  }));

  if (serve) {
    win.webContents.openDevTools();
  }
  // Emitted when the window is closed.
  win.on('closed', () => {
    // Dereference the window object, usually you would store window
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    win = null;
  });
}
开发者ID:meltedspark,项目名称:electron-angular2-native,代码行数:30,代码来源:main.electron.ts

示例4: Promise

    return new Promise(resolve => {
        if (isDev || !isAnySetupRequired()) {
            const {
                loadExtensions
            } = require("eez-studio-shared/extensions/extensions") as typeof ExtensionsModule;
            loadExtensions();

            resolve();
            return;
        }

        let win = new BrowserWindow({
            width: 600,
            height: 200,
            backgroundColor: "#333",
            show: false
        });

        win.setMenu(null);
        win.loadURL(`file://${__dirname}/../setup/setup.html`);

        win.show();

        ipcMain.on("startSetup", async (event: Event) => {
            await doSetup(event.sender);
            win.close();
            resolve();
        });
    });
开发者ID:eez-open,项目名称:studio,代码行数:29,代码来源:setup.ts

示例5: createWindow

function createWindow() {
  const electronScreen = screen;
  const size = electronScreen.getPrimaryDisplay().workAreaSize;

  // Create the browser window.
  mainWindow = new BrowserWindow({
    x: 0,
    y: 0,
    width: size.width,
    height: size.height
  });

  if (liveReload) {
    require('electron-reload')(__dirname, { electron: require(`${__dirname}/node_modules/electron`) });
    mainWindow.loadURL('http://localhost:4200');
    mainWindow.webContents.openDevTools();
  } else {
    // Load the index.html of the app.
    mainWindow.loadFile('dist.electron/index.html');
  }

  // Emitted when the window is closed.
  mainWindow.on('closed', () => {
    // Dereference the window object, usually you would store window
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  });
}
开发者ID:sinedied,项目名称:sk-angular2,代码行数:29,代码来源:__electron.electron.main.ts

示例6: createCheckoutWindow

    public createCheckoutWindow(payload: string, settings: any, serviceUrl: string) {
        let page = URL.format({
            protocol: 'file',
            slashes: true,
            pathname: path.join(__dirname, '../client/payments/index.html')
        });
        page += '?' + payload;

        let checkoutWindow = new Electron.BrowserWindow({
            width: 1000,
            height: 620,
            title: 'Checkout with Microsoft Emulator'
        });
        this.add(checkoutWindow);

        checkoutWindow.webContents['checkoutState'] = {
            settings: settings,
            serviceUrl: serviceUrl
        };

        checkoutWindow.on('closed', () => {
            this.remove(checkoutWindow);
        });

        // checkoutWindow.webContents.openDevTools();

        // Load a remote URL
        checkoutWindow.loadURL(page);

        checkoutWindow.webContents.setZoomLevel(getSettings().windowState.zoomLevel);
    }
开发者ID:kpreeti096,项目名称:BotFramework-Emulator,代码行数:31,代码来源:windowManager.ts

示例7: createMainWindow

function createMainWindow() {
  // Construct new BrowserWindow
  const window = new BrowserWindow({
    webPreferences: {
      // Allowing loading file:// URLs, etc., for now.
      webSecurity: false
    }
  })

  // Set url for `win`
    // points to `webpack-dev-server` in development
    // points to `index.html` in production
  const url = isDevelopment
    ? `http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`
    : `file://${__dirname}/index.html`

  if (isDevelopment) {
    window.webContents.openDevTools()
  }

  window.loadURL(url)

  window.on('closed', () => {
    mainWindow = null
  })

  window.webContents.on('devtools-opened', () => {
    window.focus()
    setImmediate(() => {
      window.focus()
    })
  })

  return window
}
开发者ID:emk,项目名称:substudy,代码行数:35,代码来源:index.ts

示例8: getCurrentSchedule

 getCurrentSchedule((schedule) => {
   let posterWindow = new BrowserWindow({width: 795, height: 800, show: debug});
   if (debug) {
     posterWindow.webContents.openDevTools();
   }
   posterWindow.setMenu(null);
   posterWindow.loadURL(`file://${__dirname}/poster.html`);
   ipcMain.once('+main:poster-angular-up', () => {
     if (debug) {
       posterWindow.webContents.send('+view:debug-enabled');
     }
     posterWindow.webContents.send('+view:open-schedule', schedule, month);
   });
   ipcMain.once('+main:poster-ready', () => {
     posterWindow.webContents['_printToPDF'](posterPrintingSetting, (err, data) => {
       if (err) throw err;
       fs.writeFile(filename, data, (err) => {
         if (err) throw err;
         console.log('Write PDF successfully.');
         dialog.showMessageBox({
           type: 'info',
           title: 'PDF Saved',
           message: 'Poster rendered and saved to file.',
           buttons: ['OK'],
         });
         if (!debug) {
           posterWindow.close();
         }
       });
     });
   });
 });
开发者ID:molisani,项目名称:fcp-schedule,代码行数:32,代码来源:electron-main.ts

示例9: createWindow

function createWindow() {
  // Create the browser window.
  win = new BrowserWindow({
    width: 800, height: 600,
    webPreferences: {
      nodeIntegration: false
    }
  });

  // and load the index.html of the app.
  win.loadURL(`file://${__dirname}/index.html`);

  // Open the DevTools.
  win.webContents.openDevTools();

  // Emitted when the window is closed.
  win.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.
    win = null;
  });

  ipcMain.send('ipc10', [10]);
}
开发者ID:hiroshi-cl,项目名称:electron-ipc,代码行数:25,代码来源:main.ts

示例10: createWindow

function createWindow() {
  // Create the browser window.
  win = new BrowserWindow({ width: 800, height: 600 });

  // and load the index.html of the app.
  win.loadURL(
    url.format({
      pathname: path.join(__dirname, "index.html"),
      protocol: "file:",
      slashes: true
    })
  );

  // Open the DevTools.
  win.webContents.openDevTools();

  // Emitted when the window is closed.
  win.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.
    win = null;
  });

  protocol.registerBufferProtocol("dictp", async (request, callback) => {
    const urlContents = request.url.substr(8).split(":");
    const type = urlContents[0]; // image/audio/lookup
    if (type === "image" || type === "audio") {
      await loadResources(request, callback);
    } else if (type === "lookup") {
    }
  });
}
开发者ID:searene,项目名称:lantastic,代码行数:33,代码来源:Main.ts

示例11: createWindow

function createWindow() {
  mainWindow = new BrowserWindow({height: 650, width: 900, show: debug});
  if (debug) {
    mainWindow.webContents.openDevTools();
  }
  mainWindow.loadURL(`file://${__dirname}/index.html`);
  if (process.platform === 'darwin') {
    Menu.setApplicationMenu(createMenu());
  } else {
    mainWindow.setMenu(createMenu());
  }
  ipcMain.once('+main:angular-up', () => {
    if (debug) {
      mainWindow.webContents.send('+view:debug-enabled');
    }
    if (startFile) {
      openScheduleFromFile(startFile);
    }
    mainWindow.show();
  });
  ipcMain.on('+main:new-schedule', () => {
    createNewSchedule();
  });
  ipcMain.on('+main:open-schedule', () => {
    openScheduleFileDialog();
  });
  mainWindow.on('closed', () => {
    mainWindow = null;
    app.quit();
  });
};
开发者ID:molisani,项目名称:fcp-schedule,代码行数:31,代码来源:electron-main.ts

示例12: function

app.on('ready', function(){
  mainWindow = new BrowserWindow({show: false});
  mainWindow.loadURL('file://' + __dirname + '/window.html');
  appIcon = new Tray(iconPath);
  var contextMenu = Menu.buildFromTemplate([
    {
      label: 'Bilge Adam Bilgilendirme Merkezi',
      icon: iconPath
    },
    {
      label: 'Duyuru',
      click: function() {
        let options: NotificationOptions = {body: "Sistem ayarları güncellemesi başlatılacaktır!"};
        createNotification("Bilge Adam Bilgilendirme", options);
      }
    },
    {
      label: 'Aç',
      click: function() {
        mainWindow.show();
      }
    },
    { 
      label: 'Kapat',
      click: function() {
        mainWindow.hide();
      }
    }
  ]);
  appIcon.setToolTip('Bilge Adam Bilgilendirme');
  appIcon.setContextMenu(contextMenu);
});
开发者ID:gencebay,项目名称:banoty,代码行数:32,代码来源:main.ts

示例13: BrowserWindow

const createMainWindow = () => {
  // Create the browser window.
  mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    icon: path.join(__dirname, 'app/assets/image/logo-128x128.png'),
    titleBarStyle: 'hidden'
  })

  // and load the index.html of the app.
  mainWindow.loadURL(path.join('file://', __dirname, 'index.html'))

  MenuUtils.initMenu()

  // 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
  })

   // Prevent external resources from being loaded (like images)
  // when dropping them on the WebView.
  // See https://github.com/electron/electron/issues/5919
  mainWindow.webContents.on('will-navigate', (event) => {
    event.preventDefault()
  })
}
开发者ID:makaria,项目名称:GReader,代码行数:29,代码来源:main.ts

示例14: async

export const load = async (appUrl: string) => {
  await app.whenReady()

  const options: BrowserWindowConstructorOptions = {
    width: 900,
    height: 600,
    autoHideMenuBar: true,
    backgroundColor: '#FFFFFF',
    webPreferences: {
      contextIsolation: true,
      preload: path.resolve(__dirname, 'renderer.js'),
      webviewTag: false
    },
    useContentSize: true,
    show: false
  }

  if (process.platform === 'linux') {
    options.icon = path.join(__dirname, 'icon.png')
  }

  mainWindow = new BrowserWindow(options)

  mainWindow.on('ready-to-show', () => mainWindow!.show())

  mainWindow.loadURL(appUrl)
  mainWindow.focus()
}
开发者ID:vwvww,项目名称:electron,代码行数:28,代码来源:default_app.ts

示例15: BrowserWindow

app.on('ready', () => {
	mainWindow = new BrowserWindow({ width: 400, height: 400, frame: false })
	mainWindow.loadURL(`file://${__dirname}/renderer/index.html`)
	mainWindow.webContents.openDevTools() // TODO: only if debug mode
	mainWindow.on('closed', (): void => mainWindow = null)
	mainWindow.setMenu(null)
})
开发者ID:castaneai,项目名称:nowpl,代码行数:7,代码来源:app.ts


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