qrcode
This commit is contained in:
parent
0cd8293472
commit
e1f9b966da
6 changed files with 97 additions and 5 deletions
|
@ -8,6 +8,7 @@ import * as yt from "youtube-search-without-api-key";
|
|||
import * as fs from "fs";
|
||||
import { Stream } from "stream";
|
||||
import * as qrcode from "qrcode-terminal";
|
||||
import * as qrcode2 from "qrcode";
|
||||
import * as os from "os";
|
||||
import {wsapi} from "./wsapi";
|
||||
|
||||
|
@ -400,6 +401,35 @@ export class Win {
|
|||
this.win.setFullScreen(flag)
|
||||
})
|
||||
|
||||
function getIp() {
|
||||
let ip = false;
|
||||
let alias = 0;
|
||||
let ifaces = os.networkInterfaces();
|
||||
for (var dev in ifaces) {
|
||||
ifaces[dev].forEach(details => {
|
||||
if (details.family === 'IPv4') {
|
||||
if (!/(loopback|vmware|internal|hamachi|vboxnet|virtualbox)/gi.test(dev + (alias ? ':' + alias : ''))) {
|
||||
if (details.address.substring(0, 8) === '192.168.' ||
|
||||
details.address.substring(0, 7) === '172.16.' ||
|
||||
details.address.substring(0, 3) === '10.'
|
||||
) {
|
||||
ip = details.address;
|
||||
++alias;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
//QR Code
|
||||
electron.ipcMain.handle('setRemoteQR', async (event , _) => {
|
||||
let url = await qrcode2.toDataURL(`http://${getIp()}:${this.remotePort}`)
|
||||
console.log(url)
|
||||
return url;
|
||||
})
|
||||
|
||||
/* *********************************************************************************************
|
||||
* Window Events
|
||||
* **********************************************************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue