fix: update error handling to avoid unused catch variables and improve code clarity

This commit is contained in:
shiyu
2025-12-18 15:51:20 +08:00
parent b582a89d08
commit 7c38c0045b
26 changed files with 130 additions and 113 deletions

View File

@@ -57,8 +57,8 @@ export const AppWindowsLayer: React.FC<AppWindowsLayerProps> = ({ windows, onClo
const { id, startX, startY, originX, originY } = dragRef.current;
const dx = e.clientX - startX;
const dy = e.clientY - startY;
let newX = Math.max(0, originX + dx);
let newY = Math.max(0, originY + dy);
const newX = Math.max(0, originX + dx);
const newY = Math.max(0, originY + dy);
dragRef.current.newX = newX;
dragRef.current.newY = newY;
const el = windowEls.current[id];

View File

@@ -6,6 +6,7 @@ import { useSystemStatus } from '../../contexts/SystemContext';
export const OfficeViewerApp: React.FC<AppComponentProps> = ({ filePath, onRequestClose }) => {
const systemStatus = useSystemStatus();
const fileDomain = systemStatus?.file_domain;
const [url, setUrl] = useState<string>();
const [loading, setLoading] = useState(true);
const [err, setErr] = useState<string>();
@@ -19,7 +20,7 @@ export const OfficeViewerApp: React.FC<AppComponentProps> = ({ filePath, onReque
vfsApi.getTempLinkToken(filePath.replace(/^\/+/, ''))
.then(res => {
if (cancelled) return;
const baseUrl = systemStatus?.file_domain || window.location.origin;
const baseUrl = fileDomain || window.location.origin;
const fullUrl = new URL(res.url, baseUrl).href;
const officeUrl = `https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(fullUrl)}`;
setUrl(officeUrl);
@@ -38,7 +39,7 @@ export const OfficeViewerApp: React.FC<AppComponentProps> = ({ filePath, onReque
return () => {
cancelled = true;
};
}, [filePath]);
}, [filePath, fileDomain]);
if (loading) {
return (

View File

@@ -47,7 +47,7 @@ export const PluginAppHost: React.FC<PluginAppHostProps> = ({ plugin, filePath,
if (pluginRef.current?.unmount && containerRef.current) {
pluginRef.current.unmount(containerRef.current);
}
} catch {}
} catch { void 0; }
},
);
@@ -96,7 +96,7 @@ export const PluginAppOpenHost: React.FC<PluginAppOpenHostProps> = ({ plugin, on
const p = pluginRef.current;
if (p?.unmountApp) return p.unmountApp(containerRef.current);
if (p?.unmount) return p.unmount(containerRef.current);
} catch { }
} catch { void 0; }
},
);

View File

@@ -9,13 +9,14 @@ const MarkdownEditor = React.lazy(() => import('@uiw/react-md-editor'));
const { Header, Content } = Layout;
const MAX_PREVIEW_BYTES = 1024 * 1024; // 1MB
export const TextEditorApp: React.FC<AppComponentProps> = ({ filePath, entry, onRequestClose }) => {
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const [content, setContent] = useState('');
const [initialContent, setInitialContent] = useState('');
const [truncated, setTruncated] = useState(false);
const MAX_PREVIEW_BYTES = 1024 * 1024; // 1MB
const isDirty = content !== initialContent;
const onRequestCloseRef = useRef(onRequestClose);
onRequestCloseRef.current = onRequestClose;

View File

@@ -21,8 +21,7 @@ async function loadApps() {
try {
const items = await pluginsApi.list();
items.filter(p => p.enabled !== false).forEach((p) => registerPluginAsApp(p));
} catch (e) {
}
} catch { void 0; }
}
function registerPluginAsApp(p: PluginItem) {
@@ -104,5 +103,5 @@ export async function reloadPluginApps() {
: undefined;
}
});
} catch { }
} catch { void 0; }
}