add api host setting
This commit is contained in:
parent
03a494e1f1
commit
f439b3d382
@ -6,12 +6,12 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func (a *App) StartServer(port int) (string, error) {
|
||||
func (a *App) StartServer(port int, host string) (string, error) {
|
||||
python, err := GetPython()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return Cmd(python, "./backend-python/main.py", strconv.Itoa(port))
|
||||
return Cmd(python, "./backend-python/main.py", strconv.Itoa(port), host)
|
||||
}
|
||||
|
||||
func (a *App) ConvertModel(modelPath string, strategy string, outPath string) (string, error) {
|
||||
|
@ -64,5 +64,9 @@ def debug():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run("main:app", port=8000 if len(sys.argv) == 1 else int(sys.argv[1]))
|
||||
uvicorn.run(
|
||||
"main:app",
|
||||
port=8000 if len(sys.argv) < 2 else int(sys.argv[1]),
|
||||
host="127.0.0.1" if len(sys.argv) < 3 else sys.argv[2],
|
||||
)
|
||||
# debug()
|
||||
|
@ -115,5 +115,6 @@
|
||||
"Explain Code": "代码解释",
|
||||
"Werewolf": "狼人杀",
|
||||
"Blank": "空白",
|
||||
"The following is an epic science fiction masterpiece that is immortalized, with delicate descriptions and grand depictions of interstellar civilization wars.\nChapter 1.\n": "以下是不朽的科幻史诗巨著,描写细腻,刻画了宏大的星际文明战争。\n第一章\n"
|
||||
"The following is an epic science fiction masterpiece that is immortalized, with delicate descriptions and grand depictions of interstellar civilization wars.\nChapter 1.\n": "以下是不朽的科幻史诗巨著,描写细腻,刻画了宏大的星际文明战争。\n第一章\n",
|
||||
"API Host": "API主机"
|
||||
}
|
@ -110,7 +110,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
||||
|
||||
await exit(1000).catch(() => {
|
||||
});
|
||||
StartServer(port);
|
||||
StartServer(port, commonStore.settings.host);
|
||||
setTimeout(WindowShow, 1000);
|
||||
|
||||
let timeoutCount = 6;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { FC } from 'react';
|
||||
import { Page } from '../components/Page';
|
||||
import { Dropdown, Option, Switch } from '@fluentui/react-components';
|
||||
import { Dropdown, Input, Option, Switch } from '@fluentui/react-components';
|
||||
import { Labeled } from '../components/Labeled';
|
||||
import commonStore from '../stores/commonStore';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
@ -20,6 +20,7 @@ export type SettingsType = {
|
||||
autoUpdatesCheck: boolean
|
||||
giteeUpdatesSource: boolean
|
||||
cnMirror: boolean
|
||||
host: string
|
||||
}
|
||||
|
||||
export const Settings: FC = observer(() => {
|
||||
@ -87,6 +88,14 @@ export const Settings: FC = observer(() => {
|
||||
}} />
|
||||
} />
|
||||
}
|
||||
<Labeled label={t('API Host')} flex spaceBetween content={
|
||||
<Input value={commonStore.settings.host}
|
||||
onChange={(e, data) => {
|
||||
commonStore.setSettings({
|
||||
host: data.value
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
</div>
|
||||
} />
|
||||
);
|
||||
|
@ -55,7 +55,8 @@ class CommonStore {
|
||||
darkMode: !isSystemLightMode(),
|
||||
autoUpdatesCheck: true,
|
||||
giteeUpdatesSource: getUserLanguage() === 'zh',
|
||||
cnMirror: getUserLanguage() === 'zh'
|
||||
cnMirror: getUserLanguage() === 'zh',
|
||||
host: '127.0.0.1'
|
||||
};
|
||||
// about
|
||||
about: AboutContent = manifest.about;
|
||||
|
2
frontend/wailsjs/go/backend_golang/App.d.ts
vendored
2
frontend/wailsjs/go/backend_golang/App.d.ts
vendored
@ -34,6 +34,6 @@ export function ReadJson(arg1:string):Promise<any>;
|
||||
|
||||
export function SaveJson(arg1:string,arg2:any):Promise<void>;
|
||||
|
||||
export function StartServer(arg1:number):Promise<string>;
|
||||
export function StartServer(arg1:number,arg2:string):Promise<string>;
|
||||
|
||||
export function UpdateApp(arg1:string):Promise<boolean>;
|
||||
|
@ -66,8 +66,8 @@ export function SaveJson(arg1, arg2) {
|
||||
return window['go']['backend_golang']['App']['SaveJson'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function StartServer(arg1) {
|
||||
return window['go']['backend_golang']['App']['StartServer'](arg1);
|
||||
export function StartServer(arg1, arg2) {
|
||||
return window['go']['backend_golang']['App']['StartServer'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function UpdateApp(arg1) {
|
||||
|
Loading…
Reference in New Issue
Block a user