mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-05-21 05:27:29 +08:00
feat: refactor code
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user