diff --git a/package.json b/package.json index ea05103..7234621 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "electron-updater": "^5.3.0", "electron-webpack": "^2.8.2", "electronmon": "^1.1.2", + "local-ip-address": "^1.0.0", "material-ui-numeric-input": "^3.1.1", "react": "^16.13.1", "react-dom": "^16.13.1", diff --git a/public/electron.js b/public/electron.js index fc98cc8..358fb63 100644 --- a/public/electron.js +++ b/public/electron.js @@ -6,6 +6,7 @@ let notRelease = process.env.NOT_RELEASE || false; const { TCPConnection } = require("../src/Socket/socket.js"); const {autoUpdater} = require("electron-updater"); const log = require('electron-log'); +const localIpAddress = require("local-ip-address") autoUpdater.logger = log; autoUpdater.logger.transports.file.level = 'info'; @@ -59,6 +60,11 @@ const createWindow = () => { }); }; +ipcMain.on("getLocalIP", (event, _) => { + event.returnValue = localIpAddress(); + return true; +}); + ipcMain.on("getAllMics", (event, arg) => { if (isDev) { let res = { diff --git a/src/Components/Home/Home.css b/src/Components/Home/Home.css new file mode 100644 index 0000000..fab8e0d --- /dev/null +++ b/src/Components/Home/Home.css @@ -0,0 +1,9 @@ +.ip { + position: absolute; + top: 5%; + right: 5%; +} + +.icon-visibility { + color: white; +} \ No newline at end of file diff --git a/src/Components/Home/Home.tsx b/src/Components/Home/Home.tsx index 586095e..0604c94 100644 --- a/src/Components/Home/Home.tsx +++ b/src/Components/Home/Home.tsx @@ -1,13 +1,43 @@ -import React from 'react'; +import React, { useEffect } from "react"; import { Routes, Route, Link } from "react-router-dom"; +import "./Home.css"; +import { Button, IconButton } from "@mui/material"; +import { Visibility, VisibilityOff } from "@material-ui/icons"; +const ipcRenderer = window.require("electron").ipcRenderer; + export const Home = () => { + const [ip, setip] = React.useState(""); + const [visibility, setvisibility] = React.useState(false); + + const getLocalIp = (): Promise => { + return new Promise(async (resolve, reject) => { + const result: string = await ipcRenderer.sendSync("getLocalIP", "ping"); + resolve(result); + }); + }; + + useEffect(() => { + getLocalIp().then(res => { + if (res.length > 0) + setip(res) + }); + + }, []); + return ( <> +

+ your ip: { visibility ? ip : "*********" } + setvisibility(!visibility) } aria-label="visibility"> + { visibility ? : } + +

+

Home

ActionsReactions Compressor Level diff --git a/src/Socket/socket.js b/src/Socket/socket.js index 4e56f24..f4df09f 100644 --- a/src/Socket/socket.js +++ b/src/Socket/socket.js @@ -50,7 +50,7 @@ class TCPConnection { } sendData(obj, callback){ - obj = JSON.stringify(obj); + obj = JSON.stringify(obj) + "\r\n"; this.socket.write(obj); this.socket.once('data', (data) => { try {