feat: refactor code

This commit is contained in:
shinya
2025-06-29 20:36:03 +08:00
parent 0b0048209f
commit 5c8360d9dd
8 changed files with 40 additions and 95 deletions

View File

@@ -6,6 +6,7 @@ import { Suspense, useEffect, useState } from 'react';
// 客户端收藏 API
import { clearAllFavorites, getAllFavorites } from '@/lib/db.client';
import { DoubanItem, DoubanResult } from '@/lib/types';
import CapsuleSwitch from '@/components/CapsuleSwitch';
import ContinueWatching from '@/components/ContinueWatching';
@@ -14,18 +15,6 @@ import PageLayout from '@/components/PageLayout';
import ScrollableRow from '@/components/ScrollableRow';
import VideoCard from '@/components/VideoCard';
interface DoubanItem {
title: string;
poster: string;
rate?: string;
}
interface DoubanResponse {
code: number;
message: string;
list: DoubanItem[];
}
function HomeClient() {
const [activeTab, setActiveTab] = useState('home');
const [hotMovies, setHotMovies] = useState<DoubanItem[]>([]);
@@ -56,12 +45,12 @@ function HomeClient() {
]);
if (moviesResponse.ok) {
const moviesData: DoubanResponse = await moviesResponse.json();
const moviesData: DoubanResult = await moviesResponse.json();
setHotMovies(moviesData.list);
}
if (tvShowsResponse.ok) {
const tvShowsData: DoubanResponse = await tvShowsResponse.json();
const tvShowsData: DoubanResult = await tvShowsResponse.json();
setHotTvShows(tvShowsData.list);
}
} finally {