diff --git a/web/src/lib/Figure.svelte b/web/src/lib/Figure.svelte index f7e262d..b352d4a 100644 --- a/web/src/lib/Figure.svelte +++ b/web/src/lib/Figure.svelte @@ -5,7 +5,7 @@ import OCRTable from './OCRTable.svelte'; import { marked } from 'marked'; import { ChevronLeft, ChevronRight, X, Hash, Library, Folder, FileClock } from 'lucide-svelte'; - import { appIconMap } from '$lib/utils'; + import { translateAppName } from '$lib/utils'; import LucideIcon from '$lib/components/LucideIcon.svelte'; /** @@ -127,7 +127,7 @@
- +

{title}

diff --git a/web/src/lib/utils.ts b/web/src/lib/utils.ts index 153466f..182f421 100644 --- a/web/src/lib/utils.ts +++ b/web/src/lib/utils.ts @@ -61,30 +61,59 @@ export const flyAndScale = ( }; }; -export const appIconMap: Record = { - "Cursor": "Code", - "Google Chrome": "Chrome", - "IINA": "Youtube", - "微信": "MessageSquareCode", - "预览": "Eye", - "iTerm2": "SquareTerminal", - "企业微信": "MessageSquareCode", - "IntelliJ IDEA": "Code", - "Microsoft Edge": "Globe", - "腾讯会议": "MessagesSquare", - "访达": "Folder", - "邮件": "Mail", - "备忘录": "NotebookTabs", - "日历": "CalendarFold", - "UserNotificationCenter": "Bell", - "Electron": "Atom", - "Firefox": "Globe", - "Safari浏览器": "Compass", - "熊掌记": "NotebookTabs", - "Alacritty": "SquareTerminal", - "系统设置": "Settings", - "股市": "CircleDollarSign", - "活动监视器": "Activity", - "Brave Browser": "Globe", - "Code": "Code", -}; +export function translateAppName(appName: string): string | undefined { + // Remove the '.exe' suffix for Windows app names + const cleanedAppName = appName.replace(/\.exe$/, ''); + + const appIconMap: Record = { + "chrome": "Chrome", + "firefox": "Globe", + "edge": "Globe", + "msedge": "Globe", + "code": "Code", + "cursor": "Code", + + "windows app beta": "LayoutGrid", + "windows app preview": "LayoutGrid", + + "google chrome": "Chrome", + "iina": "Youtube", + "微信": "MessageSquareCode", + "预览": "Eye", + "iterm2": "SquareTerminal", + "企业微信": "MessageSquareCode", + "intellij idea": "Code", + "microsoft edge": "Globe", + "腾讯会议": "Phone", + "访达": "Folder", + "邮件": "Mail", + "备忘录": "NotebookTabs", + "日历": "CalendarFold", + "usernotificationcenter": "Bell", + "electron": "Atom", + "safari浏览器": "Compass", + "熊掌记": "NotebookTabs", + "alacritty": "SquareTerminal", + "系统设置": "Settings", + "股市": "CircleDollarSign", + "活动监视器": "Activity", + "brave browser": "Globe", + + "windowsterminal": "SquareTerminal", + "explorer": "Folder", + "clash for windows": "Globe", + "mpv": "Youtube", + "searchhost": "Search", + "lockapp": "Lock", + "thunder": "CloudDownload", + "xlliveud": "CloudDownload", + "ollama app": "Bot", + "githubdesktop": "Github", + }; + + // Try to match the cleaned app name (case-insensitive) + const iconName = appIconMap[cleanedAppName.toLowerCase()]; + + // If no match is found, return undefined + return iconName; +} diff --git a/web/src/routes/+page.svelte b/web/src/routes/+page.svelte index e2964c6..2938d5e 100644 --- a/web/src/routes/+page.svelte +++ b/web/src/routes/+page.svelte @@ -8,7 +8,7 @@ import { formatDistanceToNow } from 'date-fns'; import Logo from '$lib/components/Logo.svelte'; import { onMount } from 'svelte'; - import { appIconMap } from '$lib/utils'; + import { translateAppName } from '$lib/utils'; import LucideIcon from '$lib/components/LucideIcon.svelte'; let searchString = ''; @@ -267,11 +267,11 @@ return filename(document.filepath); } - function getAppName(document: any): string | null { - if (document.metadata_entries && document.metadata_entries.some((entry) => entry.key === 'active_app')) { - return document.metadata_entries.find((entry) => entry.key === 'active_app').value; + function getAppName(document: any): string { + if (document.metadata_entries && document.metadata_entries.some((entry: any) => entry.key === 'active_app')) { + return document.metadata_entries.find((entry: any) => entry.key === 'active_app').value; } else { - return null; + return "unknown"; } } @@ -368,7 +368,7 @@
- + {getAppName(hit.document)}
{/if}