electron实现qq快捷登录的方法示例(2)

import {ipcMain, BrowserWindow, shell} from 'electron' ipcMain.on('qqLogin', (event, data) => { const loginWindow = new BrowserWindow({ width: 750, height: 450, resizable: false, minimizable: false, maximizable: false, webPreferences: { devTools: false, } }); loginWindow.setMenu(null); loginWindow.loadURL(data.url); loginWindow.webContents.on('new-window', (event, url) => { event.preventDefault(); shell.openExternal(url); }); const content = loginWindow.webContents; content.on('will-navigate', (e, status, url,) => { content.on('did-get-response-details', (e, status, url, originalURL, httpResponseCode, requestMethod, referrer, header) => { if (httpResponseCode === 200) { event.sender.send('reply', header); loginWindow.close(); } }) }); });

注意点

返回的header里面是一个数组 这种写法真是坑爹啊! 还要去写一个 header.token[0] 这种写法有点不喜欢 但是没法子!

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/32be1a45e071a24273a2e42994f67b71.html