@2o3t/electron-window-manager 中文文档教程

发布于 5年前 浏览 27 项目主页 更新于 3年前

@2o3t/electron-window-manager

Installation

yarn add @2o3t/electron-window-manager

Usage

在主进程中

// in main process
const { app } = require('electron')
const path = require('path')
const wm = require('@2o3t/electron-window-manager')

app.on('ready', () => {
    const mainWindow = wm.createMainWindow({
        width: 1000, height: 400,
        url: path.resolve(__dirname, 'index.html'),
        args: {
            data: 'hi',
        },
        webPreferences: {
            preload: './preload.js',
        },
    });

    // or
    // const win = wm.createWindow({
    //     width: 1000, height: 400,
    //     url: path.resolve(__dirname, 'index.html'),
    //     args: {
    //         data: 'hi',
    //     },
    // });
});

,您必须

// preload.js
require('@2o3t/electron-window-manager').parseArgs();

在渲染器进程中创建 preload.js

// in renderer process
console.log(__ARGS__);

API

const wm = require('@2o3t/electron-window-manager')

// return boolean
wm.hasMain();

// return main window
wm.getMain();

// add new window
wm.add(win);

// remove a window
wm.remove(win);

// destroy all
wm.destroy();


// return center size
wm.centerSize();

wm.screenBounds();

wm.screenWorkAreas();

wm.findWin(winID);

wm.all();

wm.allWithoutMain();

@2o3t/electron-window-manager

Installation

yarn add @2o3t/electron-window-manager

Usage

in main process

// in main process
const { app } = require('electron')
const path = require('path')
const wm = require('@2o3t/electron-window-manager')

app.on('ready', () => {
    const mainWindow = wm.createMainWindow({
        width: 1000, height: 400,
        url: path.resolve(__dirname, 'index.html'),
        args: {
            data: 'hi',
        },
        webPreferences: {
            preload: './preload.js',
        },
    });

    // or
    // const win = wm.createWindow({
    //     width: 1000, height: 400,
    //     url: path.resolve(__dirname, 'index.html'),
    //     args: {
    //         data: 'hi',
    //     },
    // });
});

you must create preload.js

// preload.js
require('@2o3t/electron-window-manager').parseArgs();

in renderer process

// in renderer process
console.log(__ARGS__);

API

const wm = require('@2o3t/electron-window-manager')

// return boolean
wm.hasMain();

// return main window
wm.getMain();

// add new window
wm.add(win);

// remove a window
wm.remove(win);

// destroy all
wm.destroy();


// return center size
wm.centerSize();

wm.screenBounds();

wm.screenWorkAreas();

wm.findWin(winID);

wm.all();

wm.allWithoutMain();
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文