refactor: update MitmServerCard and MitmToolCard to use modalError instead of message for error handling

- Replaced message state with modalError in both components for better error management.
- Removed unused message display logic and adjusted action handling to improve clarity.
- Enhanced error handling in doAction and doDnsAction functions to ignore errors gracefully.
- Updated API call responses to streamline user feedback on actions.
This commit is contained in:
decolua
2026-03-20 12:44:20 +07:00
parent 6af8043f2a
commit c8d2497423
8 changed files with 117 additions and 103 deletions
+13 -2
View File
@@ -241,15 +241,26 @@ export async function spawnQuickTunnel(localPort, onUrlUpdate) {
reject(new Error("Quick tunnel timed out"));
}, 90000);
let lastUrl = null;
const handleLog = (data) => {
const msg = data.toString();
const tunnelUrl = getQuickTunnelUrlFromLog(msg);
if (tunnelUrl && !resolved) {
if (!tunnelUrl) return;
if (!resolved) {
// First URL — resolve the promise, do NOT call onUrlUpdate (caller handles initial register)
resolved = true;
lastUrl = tunnelUrl;
clearTimeout(timeout);
cleanup();
resolve({ child, tunnelUrl });
// Notify caller of URL (for re-registration on URL change)
return;
}
// URL changed after initial connect — notify caller to re-register
if (tunnelUrl !== lastUrl) {
lastUrl = tunnelUrl;
if (onUrlUpdate) onUrlUpdate(tunnelUrl);
}
};