diff options
| author | Kevin <[email protected]> | 2021-05-31 18:58:56 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-05-31 18:58:56 +0800 |
| commit | d4015f64237b2b429a04af0ebe82fdf883b45b01 (patch) | |
| tree | d5f28b916d02c6cad68befa220b1a50eb40c3be6 /src/api | |
| parent | 13dcb7d6532a07bb86c54139c9e9d19eb892de4e (diff) | |
Add level query to log websocket url fix #589 (#590)
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/logs.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/api/logs.ts b/src/api/logs.ts index 1958638..5965588 100644 --- a/src/api/logs.ts +++ b/src/api/logs.ts @@ -1,8 +1,7 @@ -import { ClashAPIConfig } from 'src/types'; +import { LogsAPIConfig } from 'src/types'; -import { buildWebSocketURL, getURLAndInit } from '../misc/request-helper'; +import { buildLogsWebSocketURL, getURLAndInit } from '../misc/request-helper'; -type LogsAPIConfig = ClashAPIConfig & { logLevel: string }; type LogEntry = { time?: string; id?: string; @@ -77,9 +76,10 @@ let controller: AbortController; // https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/readyState let wsState: number; export function fetchLogs(apiConfig: LogsAPIConfig, appendLog: AppendLogFn) { + if (apiConfig.logLevel === 'uninit') return; if (fetched || wsState === 1) return; wsState = 1; - const url = buildWebSocketURL(apiConfig, endpoint); + const url = buildLogsWebSocketURL(apiConfig, endpoint); const ws = new WebSocket(url); ws.addEventListener('error', () => (wsState = 3)); ws.addEventListener('close', function (_ev) { |
