Enhance Mihomo WebSocket handling and documentation updates
Publish telemt-api gateway Docker image / test (push) Successful in 29s
Publish telemt-api gateway Docker image / build-and-push (push) Successful in 2m26s

- Updated `GATEWAY_RUN.md` to clarify the use of native WebSocket connections for `/traffic` and `/memory`, detailing the authorization process and fallback HTTP GET requests.
- Modified the Svelte component to implement native WebSocket loops for real-time traffic and memory metrics, improving data retrieval and connection stability.
- Refactored the traffic and memory polling functions to integrate WebSocket handling, ensuring a more robust and responsive user experience.
This commit is contained in:
Denozordec
2026-03-31 01:47:23 +07:00
parent 82dd7dd1bf
commit 8b7233159a
3 changed files with 130 additions and 5 deletions
+3 -2
View File
@@ -21,8 +21,9 @@ export function mihomoUrl(alias: string, path: string): string {
}
/**
* WebSocket к тому же origin (ws / wss).
* Для /traffic и /memory во фронте предпочтительнее потоковый GET через `mihomoUrl` — тот же прокси, что и для REST; WS из браузера часто рвётся за nginx.
* WebSocket к шлюзу: `ws(s)://…/api/{alias}/mihomo/{path}`.
* Authorization к Mihomo подставляет шлюз; браузеру токен не нужен.
* Обзор Mihomo: нативный WS для /traffic и /memory + резервный потоковый GET при необходимости.
*/
export function mihomoWsUrl(alias: string, path: string): string {
const p = path.replace(/^\/+/, '');