diff --git a/backend-golang/rwkv.go b/backend-golang/rwkv.go index c41bdb1..683459e 100644 --- a/backend-golang/rwkv.go +++ b/backend-golang/rwkv.go @@ -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) { diff --git a/backend-python/main.py b/backend-python/main.py index 90262b7..3f84fc3 100644 --- a/backend-python/main.py +++ b/backend-python/main.py @@ -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() diff --git a/frontend/src/_locales/zh-hans/main.json b/frontend/src/_locales/zh-hans/main.json index e668905..69165d6 100644 --- a/frontend/src/_locales/zh-hans/main.json +++ b/frontend/src/_locales/zh-hans/main.json @@ -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主机" } \ No newline at end of file diff --git a/frontend/src/components/RunButton.tsx b/frontend/src/components/RunButton.tsx index 16bf05c..0039723 100644 --- a/frontend/src/components/RunButton.tsx +++ b/frontend/src/components/RunButton.tsx @@ -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; diff --git a/frontend/src/pages/Settings.tsx b/frontend/src/pages/Settings.tsx index 3062661..1afcdbe 100644 --- a/frontend/src/pages/Settings.tsx +++ b/frontend/src/pages/Settings.tsx @@ -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(() => { }} /> } /> } + { + commonStore.setSettings({ + host: data.value + }); + }} /> + } /> } /> ); diff --git a/frontend/src/stores/commonStore.ts b/frontend/src/stores/commonStore.ts index e576787..4c1b035 100644 --- a/frontend/src/stores/commonStore.ts +++ b/frontend/src/stores/commonStore.ts @@ -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; diff --git a/frontend/wailsjs/go/backend_golang/App.d.ts b/frontend/wailsjs/go/backend_golang/App.d.ts index 242d251..28eb46e 100644 --- a/frontend/wailsjs/go/backend_golang/App.d.ts +++ b/frontend/wailsjs/go/backend_golang/App.d.ts @@ -34,6 +34,6 @@ export function ReadJson(arg1:string):Promise; export function SaveJson(arg1:string,arg2:any):Promise; -export function StartServer(arg1:number):Promise; +export function StartServer(arg1:number,arg2:string):Promise; export function UpdateApp(arg1:string):Promise; diff --git a/frontend/wailsjs/go/backend_golang/App.js b/frontend/wailsjs/go/backend_golang/App.js index 159bb67..92cad3a 100644 --- a/frontend/wailsjs/go/backend_golang/App.js +++ b/frontend/wailsjs/go/backend_golang/App.js @@ -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) {