From 27a80fad88eb956e361001084975ef9d25d24b21 Mon Sep 17 00:00:00 2001 From: haishan Date: Mon, 18 Sep 2023 22:39:03 +0800 Subject: [PATCH] Run prettier --- src/api/connections.ts | 10 +- src/api/logs.ts | 2 +- src/api/proxies.ts | 6 +- src/api/rules.ts | 2 +- src/api/traffic.ts | 15 ++- src/api/version.ts | 2 +- src/app.tsx | 2 +- src/components/APIConfig.tsx | 2 +- src/components/APIDiscovery.tsx | 12 +- src/components/BackendList.tsx | 4 +- src/components/Button.tsx | 4 +- src/components/CollapsibleSectionHeader.tsx | 2 +- src/components/Config.tsx | 24 ++-- src/components/ConnectionTable.module.scss | 4 +- src/components/ConnectionTable.tsx | 134 ++++++++++---------- src/components/Connections.tsx | 30 ++--- src/components/Input.tsx | 2 +- src/components/Logs.tsx | 14 +- src/components/ModalCloseAllConnections.tsx | 12 +- src/components/Search.tsx | 14 +- src/components/StateProvider.tsx | 14 +- src/components/SwitchThemed.tsx | 7 +- src/components/ToggleSwitch.tsx | 2 +- src/components/TrafficChart.tsx | 10 +- src/components/TrafficChartSample.tsx | 2 +- src/components/TrafficNow.tsx | 4 +- src/components/about/About.tsx | 2 +- src/components/proxies/Proxy.tsx | 14 +- src/components/proxies/ProxyGroup.tsx | 2 +- src/components/proxies/ProxyPageFab.tsx | 2 +- src/components/proxies/Settings.tsx | 5 +- src/components/proxies/hooks.tsx | 15 +-- src/components/proxies/proxies.hooks.tsx | 2 +- src/components/rules/rules.hooks.tsx | 10 +- src/components/shared/BaseModal.module.scss | 4 +- src/components/shared/BaseModal.tsx | 12 +- src/components/shared/Basic.tsx | 5 +- src/components/shared/ThemeSwitcher.tsx | 5 +- src/hooks/useLineChart.ts | 2 +- src/hooks/useRemainingViewPortHeight.ts | 2 +- src/hooks/useTextInput.ts | 4 +- src/misc/chart-lib.ts | 2 +- src/misc/errors.ts | 5 +- src/misc/i18n.ts | 2 +- src/misc/storage.ts | 2 +- src/store/app.ts | 4 +- src/store/configs.ts | 4 +- src/store/logs.ts | 2 +- src/store/proxies.tsx | 8 +- src/store/types.ts | 6 +- src/sw.ts | 4 +- src/swRegistration.ts | 4 +- 52 files changed, 268 insertions(+), 197 deletions(-) diff --git a/src/api/connections.ts b/src/api/connections.ts index 5ac27b909..89289c57c 100644 --- a/src/api/connections.ts +++ b/src/api/connections.ts @@ -61,8 +61,14 @@ export function fetchData(apiConfig: ClashAPIConfig, listener: unknown): Unsubsc const ws = new WebSocket(url); let frozenState = false; - const onFrozen = () => { frozenState = true; ws.close(); }, - onResume = () => { frozenState = false; fetchData(apiConfig, undefined); }; + const onFrozen = () => { + frozenState = true; + ws.close(); + }, + onResume = () => { + frozenState = false; + fetchData(apiConfig, undefined); + }; document.addEventListener('freeze', onFrozen, { capture: true, once: true }); document.addEventListener('resume', onResume, { capture: true, once: true }); diff --git a/src/api/logs.ts b/src/api/logs.ts index 044a31b1a..a0daee159 100644 --- a/src/api/logs.ts +++ b/src/api/logs.ts @@ -146,6 +146,6 @@ function fetchLogsWithFetch(apiConfig: LogsAPIConfig, appendLog: AppendLogFn) { // eslint-disable-next-line no-console console.log('GET /logs error:', err.message); - } + }, ); } diff --git a/src/api/proxies.ts b/src/api/proxies.ts index 1fa5acc3b..34f407a49 100644 --- a/src/api/proxies.ts +++ b/src/api/proxies.ts @@ -25,7 +25,7 @@ export async function fetchProxies(config: ClashAPIConfig) { export async function requestToSwitchProxy( apiConfig: ClashAPIConfig, groupName: string, - name: string + name: string, ) { const body = { name }; const { url, init } = getURLAndInit(apiConfig); @@ -41,7 +41,7 @@ export async function requestToSwitchProxy( export async function requestDelayForProxy( apiConfig: ClashAPIConfig, name: string, - latencyTestUrl = 'http://www.gstatic.com/generate_204' + latencyTestUrl = 'http://www.gstatic.com/generate_204', ) { const { url, init } = getURLAndInit(apiConfig); const qs = `timeout=5000&url=${encodeURIComponent(latencyTestUrl)}`; @@ -69,6 +69,6 @@ export async function healthcheckProviderByName(config: ClashAPIConfig, name: st const options = { ...init, method: 'GET' }; return await fetch( url + '/providers/proxies/' + encodeURIComponent(name) + '/healthcheck', - options + options, ); } diff --git a/src/api/rules.ts b/src/api/rules.ts index 4d18c2376..cfe1b07fe 100644 --- a/src/api/rules.ts +++ b/src/api/rules.ts @@ -15,7 +15,7 @@ type RuleAPIItem = { function normalizeAPIResponse(json: { rules: Array }): Array { invariant( json.rules && json.rules.length >= 0, - 'there is no valid rules list in the rules API response' + 'there is no valid rules list in the rules API response', ); // attach an id diff --git a/src/api/traffic.ts b/src/api/traffic.ts index 0f2f79564..b8a827516 100644 --- a/src/api/traffic.ts +++ b/src/api/traffic.ts @@ -7,7 +7,7 @@ const textDecoder = new TextDecoder('utf-8'); const Size = 150; -type Traffic = { up: number; down: number } +type Traffic = { up: number; down: number }; const traffic = { labels: Array(Size).fill(0), @@ -85,7 +85,10 @@ function fetchData(apiConfig: ClashAPIConfig) { const ws = new WebSocket(url); let frozenState = false; - const onFrozen = () => { frozenState = true; ws.close(); }, + const onFrozen = () => { + frozenState = true; + ws.close(); + }, onResume = () => { frozenState = false; @@ -99,10 +102,10 @@ function fetchData(apiConfig: ClashAPIConfig) { document.addEventListener('freeze', onFrozen, { capture: true, once: true }); document.addEventListener('resume', onResume, { capture: true, once: true }); - ws.addEventListener('error', function(_ev) { + ws.addEventListener('error', function (_ev) { wsState = 3; }); - ws.addEventListener('close', function(_ev) { + ws.addEventListener('close', function (_ev) { wsState = 3; if (!frozenState) { // For unexpected close, remove listeners and re-fetch @@ -112,7 +115,7 @@ function fetchData(apiConfig: ClashAPIConfig) { fetchDataWithFetch(apiConfig); } }); - ws.addEventListener('message', function(event) { + ws.addEventListener('message', function (event) { parseAndAppend(event.data); }); return traffic; @@ -135,7 +138,7 @@ function fetchDataWithFetch(apiConfig: ClashAPIConfig) { // eslint-disable-next-line no-console console.log('fetch /traffic error', err); fetched = false; - } + }, ); return traffic; } diff --git a/src/api/version.ts b/src/api/version.ts index 78ceb834c..bbb3be456 100644 --- a/src/api/version.ts +++ b/src/api/version.ts @@ -8,7 +8,7 @@ type VersionData = { export async function fetchVersion( endpoint: string, - apiConfig: ClashAPIConfig + apiConfig: ClashAPIConfig, ): Promise { let json = {}; try { diff --git a/src/app.tsx b/src/app.tsx index 65e6ed9d9..23b5c5fe7 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -43,7 +43,7 @@ Modal.setAppElement(rootEl); root.render( - + , ); setTimeout(() => { diff --git a/src/components/APIConfig.tsx b/src/components/APIConfig.tsx index 1761573df..521a82fe2 100644 --- a/src/components/APIConfig.tsx +++ b/src/components/APIConfig.tsx @@ -73,7 +73,7 @@ function APIConfig({ dispatch }: { dispatch: DispatchFn }) { onConfirm(); }, - [onConfirm] + [onConfirm], ); const detectApiServer = async () => { diff --git a/src/components/APIDiscovery.tsx b/src/components/APIDiscovery.tsx index 42e78fd2b..3ed59e53f 100644 --- a/src/components/APIDiscovery.tsx +++ b/src/components/APIDiscovery.tsx @@ -15,10 +15,14 @@ import { connect } from './StateProvider'; const { useCallback, useEffect } = React; -function APIDiscovery({ dispatch, apiConfig, modals }: { - dispatch: DispatchFn, - apiConfig: ClashAPIConfig, - modals: StateModals, +function APIDiscovery({ + dispatch, + apiConfig, + modals, +}: { + dispatch: DispatchFn; + apiConfig: ClashAPIConfig; + modals: StateModals; }) { if (!window.fetch) { const { detail } = errors[DOES_NOT_SUPPORT_FETCH]; diff --git a/src/components/BackendList.tsx b/src/components/BackendList.tsx index 40b8dc828..26868fac0 100644 --- a/src/components/BackendList.tsx +++ b/src/components/BackendList.tsx @@ -34,13 +34,13 @@ function BackendListImpl({ (conf: ClashAPIConfig) => { removeClashAPIConfig(conf); }, - [removeClashAPIConfig] + [removeClashAPIConfig], ); const onSelect = React.useCallback( (conf: ClashAPIConfig) => { selectClashAPIConfig(conf); }, - [selectClashAPIConfig] + [selectClashAPIConfig], ); return ( diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 8125edc02..76e2cc5db 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -41,12 +41,12 @@ function Button(props: ButtonProps, ref: React.Ref) { if (isLoading) return; onClick && onClick(e); }, - [isLoading, onClick] + [isLoading, onClick], ); const btnClassName = cx( s0.btn, { [s0.minimal]: kind === 'minimal', [s0.circular]: kind === 'circular' }, - className + className, ); return (