fix: 修復Flashcards頁面TypeScript類型錯誤
- 添加imageGenerationService導入修復未定義錯誤 - 修正getExampleImage和hasExampleImage函數類型簽名 - 添加缺失的generatingCards和generationProgress屬性 - 移除未使用的hasExampleImage函數 - 為status參數添加類型註解 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
3fdd8bd6c3
commit
74932e58ff
|
|
@ -6,6 +6,7 @@ import { Navigation } from '@/components/Navigation'
|
|||
import { ProtectedRoute } from '@/components/ProtectedRoute'
|
||||
import { useToast } from '@/components/Toast'
|
||||
import { flashcardsService, type Flashcard } from '@/lib/services/flashcards'
|
||||
import { imageGenerationService } from '@/lib/services/imageGeneration'
|
||||
|
||||
interface FlashcardDetailPageProps {
|
||||
params: Promise<{
|
||||
|
|
@ -214,10 +215,6 @@ function FlashcardDetailContent({ cardId }: { cardId: string }) {
|
|||
return card.primaryImageUrl || null
|
||||
}
|
||||
|
||||
// 檢查詞彙是否有例句圖片 - 使用 API 資料
|
||||
const hasExampleImage = (card: Flashcard): boolean => {
|
||||
return card.hasExampleImage
|
||||
}
|
||||
|
||||
// 詞性簡寫轉換
|
||||
const getPartOfSpeechDisplay = (partOfSpeech: string): string => {
|
||||
|
|
@ -349,7 +346,7 @@ function FlashcardDetailContent({ cardId }: { cardId: string }) {
|
|||
|
||||
const finalStatus = await imageGenerationService.pollUntilComplete(
|
||||
requestId,
|
||||
(status) => {
|
||||
(status: any) => {
|
||||
const stage = status.stages.gemini.status === 'completed'
|
||||
? 'Replicate 生成圖片中...' : 'Gemini 生成描述中...'
|
||||
setGenerationProgress(stage)
|
||||
|
|
|
|||
|
|
@ -515,9 +515,11 @@ interface SearchResultsProps {
|
|||
onToggleFavorite: (card: Flashcard) => void
|
||||
getCEFRColor: (level: string) => string
|
||||
highlightSearchTerm: (text: string, term: string) => React.ReactNode
|
||||
getExampleImage: (word: string) => string | null
|
||||
hasExampleImage: (word: string) => boolean
|
||||
getExampleImage: (card: Flashcard) => string | null
|
||||
hasExampleImage: (card: Flashcard) => boolean
|
||||
onGenerateExampleImage: (card: Flashcard) => void
|
||||
generatingCards: Set<string>
|
||||
generationProgress: {[cardId: string]: string}
|
||||
router: any
|
||||
}
|
||||
|
||||
|
|
@ -532,6 +534,8 @@ function SearchResults({
|
|||
getExampleImage,
|
||||
hasExampleImage,
|
||||
onGenerateExampleImage,
|
||||
generatingCards,
|
||||
generationProgress,
|
||||
router
|
||||
}: SearchResultsProps) {
|
||||
if (searchState.flashcards.length === 0) {
|
||||
|
|
@ -573,6 +577,8 @@ function SearchResults({
|
|||
getExampleImage={getExampleImage}
|
||||
hasExampleImage={hasExampleImage}
|
||||
onGenerateExampleImage={() => onGenerateExampleImage(card)}
|
||||
generatingCards={generatingCards}
|
||||
generationProgress={generationProgress}
|
||||
router={router}
|
||||
/>
|
||||
))}
|
||||
|
|
@ -589,13 +595,15 @@ interface FlashcardItemProps {
|
|||
onToggleFavorite: () => void
|
||||
getCEFRColor: (level: string) => string
|
||||
highlightSearchTerm: (text: string, term: string) => React.ReactNode
|
||||
getExampleImage: (word: string) => string | null
|
||||
hasExampleImage: (word: string) => boolean
|
||||
getExampleImage: (card: Flashcard) => string | null
|
||||
hasExampleImage: (card: Flashcard) => boolean
|
||||
onGenerateExampleImage: () => void
|
||||
generatingCards: Set<string>
|
||||
generationProgress: {[cardId: string]: string}
|
||||
router: any
|
||||
}
|
||||
|
||||
function FlashcardItem({ card, searchTerm, onEdit, onDelete, onToggleFavorite, getCEFRColor, highlightSearchTerm, getExampleImage, hasExampleImage, onGenerateExampleImage, router }: FlashcardItemProps) {
|
||||
function FlashcardItem({ card, searchTerm, onEdit, onDelete, onToggleFavorite, getCEFRColor, highlightSearchTerm, getExampleImage, hasExampleImage, onGenerateExampleImage, generatingCards, generationProgress, router }: FlashcardItemProps) {
|
||||
return (
|
||||
<div className="bg-white border border-gray-200 rounded-lg hover:shadow-md transition-all duration-200 relative">
|
||||
<div className="p-4">
|
||||
|
|
|
|||
Loading…
Reference in New Issue