我如何在electronjs中打印桌面

时间:2021-04-11 15:58:51

标签: javascript web printing electron screenshot

const {
    app,
    BrowserWindow,
    nativeImage
} = require("electron");
let mainWindow;

require("electron-reload")(__dirname, {
    electron: require(`${__dirname}/node_modules/electron`),
});

function createWindow() {
    const icon = nativeImage.createFromPath(`${app.getAppPath()}/build/icon.png`);

    if (app.dock) {
        app.dock.setIcon(icon);
    }

    mainwindow = new BrowserWindow({
        icon,
        width: 800,
        height: 600,
        resizable: false,
        webPreferences: {
            nodeIntegration: true,
            enableRemoteModule: true,
            contextIsolation: false
        },
    });

    mainwindow.loadFile("views/index.html");
}

app.whenReady().then(createWindow);

app.on("window-all-closed", () => {
    if (process.platform !== "darwin") {
        app.quit();
    }
});

app.on("activate", () => {
    if (BrowserWindow.getAllWindows().length === 0) {
        createWindow();
    }
});

我在electronjs中的应用

有人可以帮助我吗?我有这个疑问很久了。

请尽快

..................................... ...................................

0 个答案:

没有答案
相关问题