// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// No Node.js APIs are available in this process because
// `nodeIntegration` is turned off. Use `preload.js` to
// selectively enable features needed in the rendering
// process.
var userAgent = navigator.userAgent.toLowerCase()
if (userAgent.indexOf(' electron/') > -1) {
    const { ipcRenderer } = nodeRequire('electron');
    var printUtil = {
        //获取打印机列表
        getPrint(fn) {
            ipcRenderer.send('allPrint');
            ipcRenderer.on('printName', (event, data) => {
                //console.log(data); //data就是返回的打印机数据列表
                //let select = document.getElementById('printOption');
                // var selectHtml = '';
                // data.forEach(ele => {
                //     selectHtml += `<option value="${ele.name}">${ele.name}</option>`;
                // });
                fn(data);
            });
        },

        //开始打印
        startPrint(vhtml, device) {
            if (!ipcRenderer) return;
            ipcRenderer.send('print-start', {
                html: vhtml,
                deviceName: device
            });
        }

    }

}
