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 { ProtectedRoute } from '@/components/ProtectedRoute'
|
||||||
import { useToast } from '@/components/Toast'
|
import { useToast } from '@/components/Toast'
|
||||||
import { flashcardsService, type Flashcard } from '@/lib/services/flashcards'
|
import { flashcardsService, type Flashcard } from '@/lib/services/flashcards'
|
||||||
|
import { imageGenerationService } from '@/lib/services/imageGeneration'
|
||||||
|
|
||||||
interface FlashcardDetailPageProps {
|
interface FlashcardDetailPageProps {
|
||||||
params: Promise<{
|
params: Promise<{
|
||||||
|
|
@ -214,10 +215,6 @@ function FlashcardDetailContent({ cardId }: { cardId: string }) {
|
||||||
return card.primaryImageUrl || null
|
return card.primaryImageUrl || null
|
||||||
}
|
}
|
||||||
|
|
||||||
// 檢查詞彙是否有例句圖片 - 使用 API 資料
|
|
||||||
const hasExampleImage = (card: Flashcard): boolean => {
|
|
||||||
return card.hasExampleImage
|
|
||||||
}
|
|
||||||
|
|
||||||
// 詞性簡寫轉換
|
// 詞性簡寫轉換
|
||||||
const getPartOfSpeechDisplay = (partOfSpeech: string): string => {
|
const getPartOfSpeechDisplay = (partOfSpeech: string): string => {
|
||||||
|
|
@ -349,7 +346,7 @@ function FlashcardDetailContent({ cardId }: { cardId: string }) {
|
||||||
|
|
||||||
const finalStatus = await imageGenerationService.pollUntilComplete(
|
const finalStatus = await imageGenerationService.pollUntilComplete(
|
||||||
requestId,
|
requestId,
|
||||||
(status) => {
|
(status: any) => {
|
||||||
const stage = status.stages.gemini.status === 'completed'
|
const stage = status.stages.gemini.status === 'completed'
|
||||||
? 'Replicate 生成圖片中...' : 'Gemini 生成描述中...'
|
? 'Replicate 生成圖片中...' : 'Gemini 生成描述中...'
|
||||||
setGenerationProgress(stage)
|
setGenerationProgress(stage)
|
||||||
|
|
|
||||||
|
|
@ -515,9 +515,11 @@ interface SearchResultsProps {
|
||||||
onToggleFavorite: (card: Flashcard) => void
|
onToggleFavorite: (card: Flashcard) => void
|
||||||
getCEFRColor: (level: string) => string
|
getCEFRColor: (level: string) => string
|
||||||
highlightSearchTerm: (text: string, term: string) => React.ReactNode
|
highlightSearchTerm: (text: string, term: string) => React.ReactNode
|
||||||
getExampleImage: (word: string) => string | null
|
getExampleImage: (card: Flashcard) => string | null
|
||||||
hasExampleImage: (word: string) => boolean
|
hasExampleImage: (card: Flashcard) => boolean
|
||||||
onGenerateExampleImage: (card: Flashcard) => void
|
onGenerateExampleImage: (card: Flashcard) => void
|
||||||
|
generatingCards: Set<string>
|
||||||
|
generationProgress: {[cardId: string]: string}
|
||||||
router: any
|
router: any
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -532,6 +534,8 @@ function SearchResults({
|
||||||
getExampleImage,
|
getExampleImage,
|
||||||
hasExampleImage,
|
hasExampleImage,
|
||||||
onGenerateExampleImage,
|
onGenerateExampleImage,
|
||||||
|
generatingCards,
|
||||||
|
generationProgress,
|
||||||
router
|
router
|
||||||
}: SearchResultsProps) {
|
}: SearchResultsProps) {
|
||||||
if (searchState.flashcards.length === 0) {
|
if (searchState.flashcards.length === 0) {
|
||||||
|
|
@ -573,6 +577,8 @@ function SearchResults({
|
||||||
getExampleImage={getExampleImage}
|
getExampleImage={getExampleImage}
|
||||||
hasExampleImage={hasExampleImage}
|
hasExampleImage={hasExampleImage}
|
||||||
onGenerateExampleImage={() => onGenerateExampleImage(card)}
|
onGenerateExampleImage={() => onGenerateExampleImage(card)}
|
||||||
|
generatingCards={generatingCards}
|
||||||
|
generationProgress={generationProgress}
|
||||||
router={router}
|
router={router}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
@ -589,13 +595,15 @@ interface FlashcardItemProps {
|
||||||
onToggleFavorite: () => void
|
onToggleFavorite: () => void
|
||||||
getCEFRColor: (level: string) => string
|
getCEFRColor: (level: string) => string
|
||||||
highlightSearchTerm: (text: string, term: string) => React.ReactNode
|
highlightSearchTerm: (text: string, term: string) => React.ReactNode
|
||||||
getExampleImage: (word: string) => string | null
|
getExampleImage: (card: Flashcard) => string | null
|
||||||
hasExampleImage: (word: string) => boolean
|
hasExampleImage: (card: Flashcard) => boolean
|
||||||
onGenerateExampleImage: () => void
|
onGenerateExampleImage: () => void
|
||||||
|
generatingCards: Set<string>
|
||||||
|
generationProgress: {[cardId: string]: string}
|
||||||
router: any
|
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 (
|
return (
|
||||||
<div className="bg-white border border-gray-200 rounded-lg hover:shadow-md transition-all duration-200 relative">
|
<div className="bg-white border border-gray-200 rounded-lg hover:shadow-md transition-all duration-200 relative">
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue