mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 19:26:00 +00:00
context menu, editing connection
This commit is contained in:
5
web/src/utility/axios.js
Normal file
5
web/src/utility/axios.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import axios from 'axios';
|
||||
|
||||
export default axios.create({
|
||||
baseURL: 'http://localhost:3000',
|
||||
});
|
||||
13
web/src/utility/common.js
Normal file
13
web/src/utility/common.js
Normal file
@@ -0,0 +1,13 @@
|
||||
export class LoadingToken {
|
||||
constructor() {
|
||||
this.isCanceled = false;
|
||||
}
|
||||
|
||||
cancel() {
|
||||
this.isCanceled = true;
|
||||
}
|
||||
}
|
||||
|
||||
export function sleep(milliseconds) {
|
||||
return new Promise(resolve => window.setTimeout(() => resolve(null), milliseconds));
|
||||
}
|
||||
16
web/src/utility/useFetch.js
Normal file
16
web/src/utility/useFetch.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import React from 'react';
|
||||
import axios from './axios';
|
||||
|
||||
export default function useFetch(url, defValue) {
|
||||
const [value, setValue] = React.useState(defValue);
|
||||
|
||||
async function loadValue() {
|
||||
const resp = await axios.get(url);
|
||||
setValue(resp.data);
|
||||
}
|
||||
React.useEffect(() => {
|
||||
loadValue();
|
||||
}, [url]);
|
||||
|
||||
return value;
|
||||
}
|
||||
Reference in New Issue
Block a user