frontend: run prettier

This commit is contained in:
ycdesu 2022-06-14 15:33:22 +08:00
parent 258675b93a
commit 19dfd6d219
3 changed files with 25 additions and 28 deletions

View File

@ -16,13 +16,15 @@ export function queryOutboundIP(cb) {
}
const triggerSync = async () => {
return axios.post<any>(baseURL + '/api/environment/sync')
}
return axios.post<any>(baseURL + '/api/environment/sync');
};
export { triggerSync };
export function querySyncStatus(cb) {
return axios.get<any>(baseURL + '/api/environment/syncing').then((response) => {
return axios
.get<any>(baseURL + '/api/environment/syncing')
.then((response) => {
cb(response.data.syncing);
});
}
@ -99,7 +101,9 @@ export function querySessionSymbols(sessionName, cb) {
}
export function queryTrades(params, cb) {
axios.get<any>(baseURL + '/api/trades', { params: params }).then((response) => {
axios
.get<any>(baseURL + '/api/trades', { params: params })
.then((response) => {
cb(response.data.trades || []);
});
}

View File

@ -9,9 +9,9 @@ import Container from '@mui/material/Container';
import SideBar from '../components/SideBar';
import ConnectWallet from '../components/ConnectWallet';
import { Box } from "@mui/material";
import {throttle} from "../src/utils";
import {triggerSync} from "../api/bbgo";
import { Box } from '@mui/material';
import { throttle } from '../src/utils';
import { triggerSync } from '../api/bbgo';
const useStyles = makeStyles((theme) => ({
root: {
@ -30,26 +30,19 @@ const useStyles = makeStyles((theme) => ({
container: {},
toolbar: {
justifyContent: 'space-between',
}
},
}));
const ToolbarButton = styled('button')(({ theme }) => ({
padding: theme.spacing(1)
})
)
padding: theme.spacing(1),
}));
function SyncButton() {
const handleClick = throttle(async () => {
await triggerSync()
}, 2000)
await triggerSync();
}, 2000);
return (
<ToolbarButton
onClick={handleClick}
>
Sync
</ToolbarButton>
);
return <ToolbarButton onClick={handleClick}>Sync</ToolbarButton>;
}
export default function DashboardLayout({ children }) {

View File

@ -29,9 +29,9 @@ export function throttle(fn, delayMillis) {
let permitted = true;
return () => {
if (permitted) {
fn.apply(this, arguments)
permitted = false
setTimeout(() => permitted = true, delayMillis)
}
fn.apply(this, arguments);
permitted = false;
setTimeout(() => (permitted = true), delayMillis);
}
};
}