()
| 22 | |
| 23 | panelComponent() { |
| 24 | const PhoneProxy = () => { |
| 25 | const [port, setPort] = useState(null as null | number); |
| 26 | const [address, setAddress] = useState(null as null | string); |
| 27 | |
| 28 | const { t } = useTranslation(); |
| 29 | |
| 30 | useEffect(() => { |
| 31 | this.coreAPI.eventEmmitter.emit('lightproxy-restart-proxy-with-lan'); |
| 32 | message.info(t('Visiable on LAN enabled')); |
| 33 | }, []); |
| 34 | |
| 35 | useEffect(() => { |
| 36 | (async () => { |
| 37 | const _port = await getWhistlePort(this.coreAPI); |
| 38 | setPort(_port); |
| 39 | })(); |
| 40 | }, []); |
| 41 | |
| 42 | useLayoutEffect(() => { |
| 43 | (async () => { |
| 44 | const _address = await this.coreAPI.getIp(); |
| 45 | if (_address !== address) { |
| 46 | setAddress(_address); |
| 47 | } |
| 48 | })(); |
| 49 | }); |
| 50 | |
| 51 | function copyProxyAddress() { |
| 52 | clipboard.writeText(`${address}:${port}`); |
| 53 | message.success(t('WIFI proxy address has been copied to the pasteboard')); |
| 54 | } |
| 55 | function copyCertAddress() { |
| 56 | clipboard.writeText(`http://${address}:${port}/cgi-bin/rootca`); |
| 57 | message.success(t('Cert address has been copied to the pasteboard')); |
| 58 | } |
| 59 | |
| 60 | |
| 61 | return ( |
| 62 | <div className="lightproxy-phoneproxy-container"> |
| 63 | <div className="lightproxy-phoneproxy-qrcode"> |
| 64 | <QrCode size={256} value={`http://${address}:${port}/cgi-bin/rootca`}></QrCode> |
| 65 | </div> |
| 66 | <div className="title"> |
| 67 | <span className="margin10">{t('Scan to install cert')}</span> |
| 68 | <a className="margin10"href={`http://${address}:${port}/cgi-bin/rootca`}>{t('Click to download cert')}</a> |
| 69 | <span className="button" onClick={copyCertAddress}>{t('Click to copy cert link')}</span> |
| 70 | </div> |
| 71 | <div className="title" onClick={copyProxyAddress}> |
| 72 | <span>{t('Setting WIFI proxy to')}</span> |
| 73 | <a>{`${address}:${port}`}</a> |
| 74 | </div> |
| 75 | </div> |
| 76 | ); |
| 77 | }; |
| 78 | |
| 79 | return PhoneProxy; |
| 80 | } |
nothing calls this directly
no test coverage detected