frontend: call outbound ip api

This commit is contained in:
c9s 2022-04-14 10:19:22 +08:00
parent cd957460c9
commit bf7ae3575a
2 changed files with 11 additions and 2 deletions

View File

@ -8,6 +8,12 @@ export function ping(cb) {
}); });
} }
export function queryOutboundIP(cb) {
return axios.get(baseURL + '/api/outbound-ip').then(response => {
cb(response.data.outboundIP)
});
}
export function querySyncStatus(cb) { export function querySyncStatus(cb) {
return axios.get(baseURL + '/api/environment/syncing').then(response => { return axios.get(baseURL + '/api/environment/syncing').then(response => {
cb(response.data.syncing) cb(response.data.syncing)

View File

@ -5,6 +5,7 @@ import Typography from '@material-ui/core/Typography';
import Paper from '@material-ui/core/Paper'; import Paper from '@material-ui/core/Paper';
import PlainLayout from '../../layouts/PlainLayout'; import PlainLayout from '../../layouts/PlainLayout';
import {QRCodeSVG} from 'qrcode.react'; import {QRCodeSVG} from 'qrcode.react';
import {queryOutboundIP} from '../../api/bbgo';
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
paper: { paper: {
@ -21,7 +22,9 @@ const useStyles = makeStyles((theme) => ({
})); }));
function fetchConnectUrl(cb) { function fetchConnectUrl(cb) {
cb(window.location.protocol + "//" + window.location.host) return queryOutboundIP((outboundIP) => {
cb(window.location.protocol + "//" + outboundIP + ":" + window.location.port)
})
} }
export default function Connect() { export default function Connect() {