feat: update localization strings for audiobook features and enhance UI interactions
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useState, useEffect, useCallback, useRef } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { toast } from 'sonner'
|
||||
import { Book, Plus, Trash2, RefreshCw, Download, ChevronDown, ChevronUp, Play, Square, Pencil, Check, X, Loader2, Zap, Settings2, PanelLeftClose, PanelLeftOpen } from 'lucide-react'
|
||||
import { Book, Plus, Trash2, RefreshCw, Download, ChevronDown, ChevronUp, Play, Square, Pencil, Check, X, Loader2, Zap, Settings2, PanelLeftClose, PanelLeftOpen, Wand2, Volume2, Bot } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Textarea } from '@/components/ui/textarea'
|
||||
@@ -1199,6 +1199,7 @@ function ChaptersPanel({
|
||||
}
|
||||
}, [segments, detail])
|
||||
|
||||
const isAIMode = project.source_type === 'ai_generated'
|
||||
const hasChapters = detail && detail.chapters.length > 0 && ['ready', 'generating', 'done'].includes(status)
|
||||
|
||||
return (
|
||||
@@ -1211,11 +1212,13 @@ function ChaptersPanel({
|
||||
<div className="flex items-center gap-1 flex-wrap">
|
||||
{detail!.chapters.some(c => ['pending', 'error', 'ready'].includes(c.status)) && (
|
||||
<Button size="xs" variant="outline" disabled={loadingAction} onClick={onParseAll}>
|
||||
{t('projectCard.chapters.parseAll')}
|
||||
{isAIMode ? <Bot className="h-3 w-3 mr-1" /> : <Wand2 className="h-3 w-3 mr-1" />}
|
||||
{t(isAIMode ? 'projectCard.chapters.parseAllAI' : 'projectCard.chapters.parseAll')}
|
||||
</Button>
|
||||
)}
|
||||
{detail!.chapters.some(c => c.status === 'ready') && (
|
||||
<Button size="xs" variant="outline" disabled={loadingAction} onClick={onGenerateAll}>
|
||||
<Volume2 className="h-3 w-3 mr-1" />
|
||||
{t('projectCard.chapters.generateAll')}
|
||||
</Button>
|
||||
)}
|
||||
@@ -1260,7 +1263,8 @@ function ChaptersPanel({
|
||||
<span className="shrink-0 flex items-center gap-1.5" onClick={e => e.stopPropagation()}>
|
||||
{ch.status === 'pending' && (
|
||||
<Button size="xs" variant="outline" onClick={() => onParseChapter(ch.id, ch.title)}>
|
||||
{t('projectCard.chapters.parse')}
|
||||
{isAIMode ? <Bot className="h-3 w-3 mr-1" /> : <Wand2 className="h-3 w-3 mr-1" />}
|
||||
{t(isAIMode ? 'projectCard.chapters.parseAI' : 'projectCard.chapters.parse')}
|
||||
</Button>
|
||||
)}
|
||||
{ch.status === 'parsing' && (
|
||||
@@ -1274,10 +1278,12 @@ function ChaptersPanel({
|
||||
setExpandedChapters(prev => { const n = new Set(prev); n.add(ch.id); return n })
|
||||
onGenerate(ch.chapter_index)
|
||||
}}>
|
||||
<Volume2 className="h-3 w-3 mr-1" />
|
||||
{t('projectCard.chapters.generate')}
|
||||
</Button>
|
||||
<Button size="xs" variant="ghost" className="text-muted-foreground" disabled={loadingAction} onClick={() => onParseChapter(ch.id, ch.title)}>
|
||||
{t('projectCard.chapters.reparse')}
|
||||
<Button size="xs" variant="outline" disabled={loadingAction} onClick={() => onParseChapter(ch.id, ch.title)}>
|
||||
{isAIMode ? <Bot className="h-3 w-3 mr-1" /> : <Wand2 className="h-3 w-3 mr-1" />}
|
||||
{t(isAIMode ? 'projectCard.chapters.reparseAI' : 'projectCard.chapters.reparse')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
@@ -1289,11 +1295,11 @@ function ChaptersPanel({
|
||||
{(ch.status === 'done' || (ch.status === 'ready' && chAllDone)) && (
|
||||
<>
|
||||
<span className="text-[11px] text-muted-foreground">{t('projectCard.chapters.doneBadge', { count: chDone })}</span>
|
||||
<Button size="xs" variant="ghost" className="text-muted-foreground" disabled={loadingAction} onClick={() => {
|
||||
<Button size="xs" variant="outline" disabled={loadingAction} onClick={() => {
|
||||
setExpandedChapters(prev => { const n = new Set(prev); n.add(ch.id); return n })
|
||||
onGenerate(ch.chapter_index, true)
|
||||
}}>
|
||||
<RefreshCw className="h-3 w-3" />{t('projectCard.chapters.generate')}
|
||||
<RefreshCw className="h-3 w-3 mr-0.5" /><Volume2 className="h-3 w-3 mr-1" />{t('projectCard.chapters.generate')}
|
||||
</Button>
|
||||
<Button size="icon" variant="ghost" className="h-6 w-6" onClick={() => onDownload(ch.chapter_index)} title={t('projectCard.downloadAll')}>
|
||||
<Download className="h-3 w-3" />
|
||||
@@ -1302,7 +1308,8 @@ function ChaptersPanel({
|
||||
)}
|
||||
{ch.status === 'error' && (
|
||||
<Button size="xs" variant="outline" className="text-destructive border-destructive/40" onClick={() => onParseChapter(ch.id, ch.title)}>
|
||||
{t('projectCard.chapters.reparse')}
|
||||
{isAIMode ? <Bot className="h-3 w-3 mr-1" /> : <Wand2 className="h-3 w-3 mr-1" />}
|
||||
{t(isAIMode ? 'projectCard.chapters.reparseAI' : 'projectCard.chapters.reparse')}
|
||||
</Button>
|
||||
)}
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user