(id, setCardInfo, setFullUrl)
| 465 | return canParsedTypes.includes(type) && realId.length > 0 |
| 466 | }, |
| 467 | async fetch(id, setCardInfo, setFullUrl) { |
| 468 | const [type, realId] = id.split('/') |
| 469 | |
| 470 | setCardInfo({ |
| 471 | classNames: { cardRoot: '!w-full' }, |
| 472 | }) |
| 473 | const json = await fetch(`/api/tmdb/${type}/${realId}?language=zh-CN`) |
| 474 | .then((r) => r.json()) |
| 475 | .catch((err) => { |
| 476 | console.error('Error fetching TMDB data:', err) |
| 477 | throw err |
| 478 | }) |
| 479 | |
| 480 | const title = type === 'tv' ? json.name : json.title |
| 481 | const originalTitle = |
| 482 | type === 'tv' ? json.original_name : json.original_title |
| 483 | setCardInfo({ |
| 484 | title: ( |
| 485 | <span className="flex flex-wrap items-end gap-2"> |
| 486 | <span>{title}</span> |
| 487 | {title !== originalTitle && ( |
| 488 | <span className="text-sm opacity-70">({originalTitle})</span> |
| 489 | )} |
| 490 | <span className="inline-flex shrink-0 items-center gap-1 self-center text-xs text-orange-400 dark:text-yellow-500"> |
| 491 | <MingcuteStarHalfFill /> |
| 492 | <span className="font-sans font-medium"> |
| 493 | {json.vote_average > 0 && json.vote_average.toFixed(1)} |
| 494 | </span> |
| 495 | </span> |
| 496 | </span> |
| 497 | ), |
| 498 | desc: ( |
| 499 | <span className="line-clamp-none overflow-visible whitespace-pre-wrap"> |
| 500 | {json.overview} |
| 501 | </span> |
| 502 | ), |
| 503 | image: `https://image.tmdb.org/t/p/w500${json.poster_path}`, |
| 504 | color: uniqolor(json.name, { |
| 505 | saturation: [30, 35], |
| 506 | lightness: [60, 70], |
| 507 | }).color, |
| 508 | |
| 509 | classNames: { |
| 510 | image: 'self-start !h-[75px] !w-[50px]', |
| 511 | cardRoot: '!w-full !flex-row-reverse', |
| 512 | }, |
| 513 | }) |
| 514 | json.homepage && setFullUrl(json.homepage) |
| 515 | }, |
| 516 | } |
| 517 | |
| 518 | const fetchLeetCodeQuestionData: FetchObject = { |
no test coverage detected