From fa54208b9650979c13a97921794d514db7e18e1b Mon Sep 17 00:00:00 2001 From: bdim404 Date: Thu, 12 Mar 2026 18:33:44 +0800 Subject: [PATCH] feat: update button sizes and styles for improved UI consistency in Audiobook and button components --- qwen3-tts-backend/core/tts_service.py | 2 +- .../src/components/ui/button.tsx | 1 + qwen3-tts-frontend/src/pages/Audiobook.tsx | 83 +++++++++++-------- 3 files changed, 50 insertions(+), 36 deletions(-) diff --git a/qwen3-tts-backend/core/tts_service.py b/qwen3-tts-backend/core/tts_service.py index c8300c0..d4f96eb 100644 --- a/qwen3-tts-backend/core/tts_service.py +++ b/qwen3-tts-backend/core/tts_service.py @@ -457,7 +457,7 @@ class IndexTTS2Backend: vec = [0.0] * 8 score = 0.8 if len(matched) == 1 else 0.5 for idx in matched: - vec[idx] = score + vec[idx] = 0.2 if idx == 1 else score return vec async def generate( diff --git a/qwen3-tts-frontend/src/components/ui/button.tsx b/qwen3-tts-frontend/src/components/ui/button.tsx index 36496a2..b73633a 100644 --- a/qwen3-tts-frontend/src/components/ui/button.tsx +++ b/qwen3-tts-frontend/src/components/ui/button.tsx @@ -22,6 +22,7 @@ const buttonVariants = cva( size: { default: "h-10 px-4 py-2", sm: "h-9 rounded-md px-3", + xs: "h-6 rounded-md px-2 text-xs", lg: "h-11 rounded-md px-8", icon: "h-10 w-10", }, diff --git a/qwen3-tts-frontend/src/pages/Audiobook.tsx b/qwen3-tts-frontend/src/pages/Audiobook.tsx index cc2079c..56e096c 100644 --- a/qwen3-tts-frontend/src/pages/Audiobook.tsx +++ b/qwen3-tts-frontend/src/pages/Audiobook.tsx @@ -409,7 +409,7 @@ function ProjectListSidebar({ )} @@ -758,6 +758,7 @@ function ChaptersPanel({ const [regeneratingSegs, setRegeneratingSegs] = useState>(new Set()) const [audioVersions, setAudioVersions] = useState>({}) const prevSegStatusRef = useRef>({}) + const initialExpandDoneRef = useRef(false) useEffect(() => { if (!scrollToChapterId) return @@ -823,12 +824,23 @@ function ChaptersPanel({ const generatingChapterIds = detail.chapters .filter(ch => segments.some(s => s.chapter_index === ch.chapter_index && s.status === 'generating')) .map(ch => ch.id) - if (generatingChapterIds.length === 0) return - setExpandedChapters(prev => { - const next = new Set(prev) - generatingChapterIds.forEach(id => next.add(id)) - return next.size === prev.size ? prev : next - }) + if (generatingChapterIds.length > 0) { + setExpandedChapters(prev => { + const next = new Set(prev) + generatingChapterIds.forEach(id => next.add(id)) + return next.size === prev.size ? prev : next + }) + return + } + if (!initialExpandDoneRef.current) { + initialExpandDoneRef.current = true + const chapterIdsWithSegs = detail.chapters + .filter(ch => segments.some(s => s.chapter_index === ch.chapter_index)) + .map(ch => ch.id) + if (chapterIdsWithSegs.length > 0) { + setExpandedChapters(new Set(chapterIdsWithSegs)) + } + } }, [segments, detail]) const hasChapters = detail && detail.chapters.length > 0 && ['ready', 'generating', 'done'].includes(status) @@ -842,17 +854,17 @@ function ChaptersPanel({ {hasChapters && (
{detail!.chapters.some(c => ['pending', 'error', 'ready'].includes(c.status)) && ( - )} {detail!.chapters.some(c => c.status === 'ready') && ( - )} {detail!.chapters.some(c => ['pending', 'error'].includes(c.status)) && detail!.chapters.some(c => c.status === 'ready') && ( - )} @@ -882,7 +894,7 @@ function ChaptersPanel({
{/* Chapter header — flat, full-width, click to expand */} )} @@ -902,13 +914,13 @@ function ChaptersPanel({ )} {ch.status === 'ready' && !chGenerating && !chAllDone && !generatingChapterIndices.has(ch.chapter_index) && ( <> - - @@ -918,22 +930,22 @@ function ChaptersPanel({ {t('projectCard.chapters.segmentProgress', { done: chDone, total: chTotal })} )} - {ch.status === 'ready' && chAllDone && ( + {(ch.status === 'done' || (ch.status === 'ready' && chAllDone)) && ( <> {t('projectCard.chapters.doneBadge', { count: chDone })} - - )} {ch.status === 'error' && ( - )} @@ -979,19 +991,19 @@ function ChaptersPanel({
{!isEditing ? ( <> - - ) : ( <> - - @@ -1484,22 +1496,22 @@ export default function Audiobook() { {t(`status.${displayStatus}`, { defaultValue: displayStatus })} {status === 'pending' && ( - )} {status === 'ready' && ( - )} {status === 'done' && ( - )} -
@@ -1537,14 +1549,14 @@ export default function Audiobook() { {chaptersError > 0 && ( <> ({t('projectCard.chaptersError', { count: chaptersError })}) - )}
{chaptersParsing > 0 && totalCount > 0 && ( - )} @@ -1560,7 +1572,7 @@ export default function Audiobook() { {t('projectCard.segmentsProgress', { done: doneCount, total: totalCount })}
{!chaptersParsing && hasGenerating && ( - )} @@ -1570,7 +1582,7 @@ export default function Audiobook() { )} {chaptersParsing > 0 && !totalCount && (
-
@@ -1591,6 +1603,7 @@ export default function Audiobook() { onScrollToChapter={(id) => setScrollToChapterId(id)} />