global status

This commit is contained in:
josc146
2023-05-23 12:50:53 +08:00
parent 9a3657e6ea
commit 3aaf16b38b
5 changed files with 38 additions and 28 deletions

View File

@@ -1,4 +1,4 @@
import commonStore, { ModelStatus } from '../stores/commonStore';
import commonStore, { Status } from '../stores/commonStore';
export const readRoot = async () => {
const port = commonStore.getCurrentModelConfig().apiParameters.apiPort;
@@ -36,15 +36,15 @@ export const updateConfig = async (body: any) => {
});
};
export const getStatus = async (timeout?: number): Promise<ModelStatus | undefined> => {
export const getStatus = async (timeout?: number): Promise<Status | undefined> => {
const controller = new AbortController();
if (timeout)
setTimeout(() => controller.abort(), timeout);
const port = commonStore.getCurrentModelConfig().apiParameters.apiPort;
let ret: ModelStatus | undefined;
let ret: Status | undefined;
await fetch(`http://127.0.0.1:${port}/status`, { signal: controller.signal }).then(r => r.json()).then(data => {
ret = data.status;
ret = data;
}).catch(() => {
});
return ret;