/** * 加载配置页面函数 */ const path=require('path'); const os=require('os'); const log = require("."+path.sep+"set_log").clog; const electron = require('electron'); const app = electron.app; const screen = electron.screen; const BrowserWindow = electron.BrowserWindow; let setting ={ createSetWindow:function(apppath,respath,main,lnks_url,updateHandle){ //阻止应用多开 const gotTheLock = app.requestSingleInstanceLock(); if (!gotTheLock) { app.quit(); } log.info("加载设置窗口..."); let win = new BrowserWindow({ width: (screen.getPrimaryDisplay().workAreaSize.width/4)*3, height: (screen.getPrimaryDisplay().workAreaSize.height/4)*3, title: "钜星科技便民问诊系统 版本 2.0", icon: respath +path.sep+"static"+path.sep+"images"+path.sep+"justar.ico", webPreferences: { //是否启用node继承 nodeIntegration: true, //禁止加载页面调用到electron得window.open nativeWindowOpen: true, //防止require引入失败 contextIsolation:false, } }); win.setMenu(null); main.registerDevTool(win); win.loadFile(apppath+path.sep+"src"+path.sep+"views"+path.sep+"setting.html"); win.webContents.on('did-frame-finish-load',function (){ //传递配置的configs参数 if(os.type()=='Windows_NT'){ lnks_url=lnks_url.replaceAll("/",path.sep); } win.webContents.send('toConfig',[respath,os.homedir()+path.sep+lnks_url]); }); //监听最后一个窗口被关闭时,退出程序 win.on("close", (e) => { e.preventDefault(); main.exitSoft(respath); }); updateHandle(win); } } module.exports=setting;