Enhance Mihomo WebSocket handling and documentation updates
- 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:
@@ -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(/^\/+/, '');
|
||||
|
||||
Reference in New Issue
Block a user