import { ChevronDown, ChevronRight, FileText, Globe } from 'lucide-react' import { TFile } from 'obsidian' import { useState } from 'react' import { useApp } from '../../contexts/AppContext' import { t } from '../../lang/helpers' function WebsiteReadItem({ websiteResult, }: { websiteResult: { url: string, content: string } }) { const app = useApp() const handleClick = () => { // 现在url字段实际上是markdown文件路径,直接在Obsidian中打开 const file = app.vault.getAbstractFileByPath(websiteResult.url) if (file instanceof TFile) { app.workspace.getLeaf('tab').openFile(file) } } const getContentSize = (content: string) => { const bytes = new Blob([content]).size if (bytes < 1024) return `${bytes} B` if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB` return `${(bytes / (1024 * 1024)).toFixed(1)} MB` } const getFileBaseName = (filePath: string) => { return filePath.split('/').pop()?.replace('.md', '') || 'website' } const truncatePath = (filePath: string, maxLength: number = 60) => { if (filePath.length <= maxLength) return filePath return '...' + filePath.substring(filePath.length - maxLength) } return (