feat(app): Refactor app opening logic to prevent runtime errors

This commit is contained in:
shiyu
2025-08-27 12:27:58 +08:00
parent d5d597a582
commit 2f2e1db536
3 changed files with 13 additions and 4 deletions

View File

@@ -26,6 +26,10 @@ export function getAppsForEntry(entry: VfsEntry): AppDescriptor[] {
return apps.filter(a => a.supported(entry));
}
export function getAppByKey(key: string): AppDescriptor | undefined {
return apps.find(a => a.key === key);
}
export function getDefaultAppForEntry(entry: VfsEntry): AppDescriptor | undefined {
if (entry.is_dir) return;
const ext = entry.name.split('.').pop()?.toLowerCase() || '';