mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-21 22:27:13 +08:00
fix(desktop): isolate backend port from the web console
This commit is contained in:
@@ -25,7 +25,7 @@ interface ApiResult {
|
||||
}
|
||||
|
||||
class ApiClient {
|
||||
private baseUrl = 'http://127.0.0.1:9899'
|
||||
private baseUrl = 'http://127.0.0.1:9876'
|
||||
|
||||
setBaseUrl(url: string) {
|
||||
this.baseUrl = url
|
||||
|
||||
@@ -9,7 +9,7 @@ interface BackendState {
|
||||
export function useBackend() {
|
||||
const [state, setState] = useState<BackendState>({
|
||||
status: 'connecting',
|
||||
port: 9899,
|
||||
port: 9876,
|
||||
})
|
||||
const pollingRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
|
||||
@@ -31,7 +31,7 @@ export function useBackend() {
|
||||
const readyRef = useRef(false)
|
||||
// Holds the latest resolved port so the visibility handler (registered once)
|
||||
// always probes the correct port without re-running the effect.
|
||||
const portRef = useRef(9899)
|
||||
const portRef = useRef(9876)
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
@@ -75,7 +75,7 @@ export function useBackend() {
|
||||
|
||||
if (api) {
|
||||
api.getBackendPort().then((port) => {
|
||||
const p = port || 9899
|
||||
const p = port || 9876
|
||||
portRef.current = p
|
||||
setState((prev) => ({ ...prev, port: p }))
|
||||
startPolling(p)
|
||||
@@ -98,7 +98,7 @@ export function useBackend() {
|
||||
}
|
||||
})
|
||||
} else {
|
||||
startPolling(9899)
|
||||
startPolling(9876)
|
||||
}
|
||||
|
||||
// When the window comes back to the foreground, re-probe immediately so a
|
||||
|
||||
Reference in New Issue
Block a user