利用electron-vue实现第三方网页的网络及操作。
1.第三方cookie的获取。
new 一个BrowserWindow,loadUrl('第三方网页地址')。
const session = require('electron').remote.session;
getCookie() {
session.defaultSession.cookies.get({url:"第三方Url"},(error, cookies)=>{
console.log(cookies);
cookie的设置
session.defaultSession.cookies.set(
url:"url",
name:"cookie名称",
value:"cookie值"
,(err)=>{})
2.elctron载入第三方网页,解决与jquery的冲突(原因是Electron 在运行环境中引入了 Node.js,默认启用了Node.js的require模块,而这些框架为了支持commondJS标准,当Window中存在require时,会启用模块引入的方式。所以在 DOM 中有一些额外的变量,比如module、exports和require。这导致了许多库不能正常运行,因为它们也需要将同名的变量加入运行环境中。)
newwin = new BrowserWindow({
webPreferences: {
nodeIntegration: true,
webSecurity: true,
preload: path.resolve(path.join(__dirname, 'source/preload.js'))
width: 400,
height: 720,
frame:false,
parent: mainWindow, //mainWindow是主窗口
preload.js
const path = require('path')
document.addEventListener("DOMNodeInserted", function(event) {