lint(gui): move root fn to config module
This commit is contained in:
parent
58ea836e20
commit
87bf27ea64
|
@ -1,4 +1,4 @@
|
|||
import { Maybe } from '@apextoaster/js-utils';
|
||||
import { doesExist, Maybe } from '@apextoaster/js-utils';
|
||||
|
||||
import { Img2ImgParams, InpaintParams, ModelParams, OutpaintParams, STATUS_SUCCESS, Txt2ImgParams, UpscaleParams } from './client.js';
|
||||
|
||||
|
@ -76,3 +76,14 @@ export async function loadConfig(): Promise<Config> {
|
|||
throw new Error('could not load config');
|
||||
}
|
||||
}
|
||||
|
||||
export function getApiRoot(config: Config): string {
|
||||
const query = new URLSearchParams(window.location.search);
|
||||
const api = query.get('api');
|
||||
|
||||
if (doesExist(api)) {
|
||||
return api;
|
||||
} else {
|
||||
return config.api.root;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* eslint-disable no-console */
|
||||
import { doesExist, mustDefault, mustExist } from '@apextoaster/js-utils';
|
||||
import { mustDefault, mustExist } from '@apextoaster/js-utils';
|
||||
import { merge } from 'lodash';
|
||||
import * as React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
|
@ -13,20 +13,9 @@ import { ParamsVersionError } from './components/error/ParamsVersion.js';
|
|||
import { ServerParamsError } from './components/error/ServerParams.js';
|
||||
import { OnnxError } from './components/OnnxError.js';
|
||||
import { OnnxWeb } from './components/OnnxWeb.js';
|
||||
import { Config, loadConfig, PARAM_VERSION } from './config.js';
|
||||
import { getApiRoot, loadConfig, PARAM_VERSION } from './config.js';
|
||||
import { ClientContext, ConfigContext, createStateSlices, OnnxState, StateContext } from './state.js';
|
||||
|
||||
export function getApiRoot(config: Config): string {
|
||||
const query = new URLSearchParams(window.location.search);
|
||||
const api = query.get('api');
|
||||
|
||||
if (doesExist(api)) {
|
||||
return api;
|
||||
} else {
|
||||
return config.api.root;
|
||||
}
|
||||
}
|
||||
|
||||
export async function main() {
|
||||
// load config from GUI server
|
||||
const config = await loadConfig();
|
||||
|
|
Loading…
Reference in New Issue