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) {
return axios.get(baseURL + '/api/environment/syncing').then(response => {
cb(response.data.syncing)
@ -71,7 +77,7 @@ export function querySessions(cb) {
}
export function querySessionSymbols(sessionName, cb) {
return axios.get(baseURL + `/api/sessions/${ sessionName }/symbols`, {})
return axios.get(baseURL + `/api/sessions/${sessionName}/symbols`, {})
.then(response => {
cb(response.data.symbols || [])
});

View File

@ -5,6 +5,7 @@ import Typography from '@material-ui/core/Typography';
import Paper from '@material-ui/core/Paper';
import PlainLayout from '../../layouts/PlainLayout';
import {QRCodeSVG} from 'qrcode.react';
import {queryOutboundIP} from '../../api/bbgo';
const useStyles = makeStyles((theme) => ({
paper: {
@ -21,7 +22,9 @@ const useStyles = makeStyles((theme) => ({
}));
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() {