在要加载的地址后没跟上userAgent对象即可修改

function createWindow () {
   win = new BrowserWindow({width: 800, height: 600});
   newWin.loadURL(winURL + '#/qinbaobao', {userAgent: args[0].userAgent})  // 此处写 你要打开的路由地址
   win.on('closed', () => {
     win = null
   });
}

隔离cookie,每个子窗口的cookie互不干扰

      const newWin = new BrowserWindow({
        width:900,
        height:620,
        minWidth:900,
        minHeight:620,
        frame:true,//是否显示边缘框
        fullscreen:false, //是否全屏显示
        title:"项目名",
        autoHideMenuBar:true,
        webPreferences: {
          nodeIntegration: true,
          // preload: path.resolve(__dirname, 'preload.js'),
          partition: 'fjhkdlsjflkdsjflktret',
          contextIsolation: false
        }
      })

在webPreferences中添加partition属性,并且partition的值为一个字符串,保持每创建一个子窗口partition的值都不相同就行了

Logo

前往低代码交流专区

更多推荐