From 57a99ae31b342c27033a6bcdddc3afaa6a47b7ab Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Sun, 5 Oct 2025 21:18:10 +0800 Subject: [PATCH] fix: clean up all empty catch blocks in Terminal components MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了 Terminal 组件中的所有 8 个空 catch 块: - Desktop/Apps/Terminal/Terminal.tsx: 修复 5 个空 catch 块 - Mobile/Apps/Terminal/Terminal.tsx: 修复 3 个空 catch 块 所有空块都添加了描述性注释。这是空块修复的最后一批。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/ui/Desktop/Apps/Terminal/Terminal.tsx | 20 +++++++++++++++----- src/ui/Mobile/Apps/Terminal/Terminal.tsx | 12 +++++++++--- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/ui/Desktop/Apps/Terminal/Terminal.tsx b/src/ui/Desktop/Apps/Terminal/Terminal.tsx index 7367ff6f..1a53502e 100644 --- a/src/ui/Desktop/Apps/Terminal/Terminal.tsx +++ b/src/ui/Desktop/Apps/Terminal/Terminal.tsx @@ -99,7 +99,9 @@ export const Terminal = forwardRef(function SSHTerminal( if (terminal && typeof (terminal as any).refresh === "function") { (terminal as any).refresh(0, terminal.rows - 1); } - } catch (_) {} + } catch { + // Ignore terminal refresh errors + } } function scheduleNotify(cols: number, rows: number) { @@ -161,7 +163,9 @@ export const Terminal = forwardRef(function SSHTerminal( scheduleNotify(cols, rows); hardRefresh(); } - } catch (_) {} + } catch { + // Ignore resize notification errors + } }, refresh: () => hardRefresh(), }), @@ -480,7 +484,9 @@ export const Terminal = forwardRef(function SSHTerminal( await navigator.clipboard.writeText(text); return; } - } catch (_) {} + } catch { + // Clipboard API not available, fallback to textarea method + } const textarea = document.createElement("textarea"); textarea.value = text; textarea.style.position = "fixed"; @@ -500,7 +506,9 @@ export const Terminal = forwardRef(function SSHTerminal( if (navigator.clipboard && navigator.clipboard.readText) { return await navigator.clipboard.readText(); } - } catch (_) {} + } catch { + // Clipboard read not available or not permitted + } return ""; } @@ -560,7 +568,9 @@ export const Terminal = forwardRef(function SSHTerminal( const pasteText = await readTextFromClipboard(); if (pasteText) terminal.paste(pasteText); } - } catch (_) {} + } catch { + // Ignore clipboard operation errors + } }; element?.addEventListener("contextmenu", handleContextMenu); diff --git a/src/ui/Mobile/Apps/Terminal/Terminal.tsx b/src/ui/Mobile/Apps/Terminal/Terminal.tsx index ac164b98..4a442686 100644 --- a/src/ui/Mobile/Apps/Terminal/Terminal.tsx +++ b/src/ui/Mobile/Apps/Terminal/Terminal.tsx @@ -73,7 +73,9 @@ export const Terminal = forwardRef(function SSHTerminal( if (terminal && typeof (terminal as any).refresh === "function") { (terminal as any).refresh(0, terminal.rows - 1); } - } catch (_) {} + } catch { + // Ignore terminal refresh errors + } } function scheduleNotify(cols: number, rows: number) { @@ -122,7 +124,9 @@ export const Terminal = forwardRef(function SSHTerminal( scheduleNotify(cols, rows); hardRefresh(); } - } catch (_) {} + } catch { + // Ignore resize notification errors + } }, refresh: () => hardRefresh(), }), @@ -175,7 +179,9 @@ export const Terminal = forwardRef(function SSHTerminal( `\r\n[${msg.message || t("terminal.disconnected")}]`, ); } - } catch (error) {} + } catch { + // Ignore message parsing errors + } }); ws.addEventListener("close", (event) => {