增加template tab

This commit is contained in:
moux1024 2025-10-17 17:38:59 +08:00
parent 954774d1b1
commit 95ec751dcf

View File

@ -2,7 +2,6 @@
import type React from "react"
import { useEffect, useState } from "react"
import Link from "next/link"
import { X } from "lucide-react"
import { PcTemplateModal } from "@/components/ChatInputBox/PcTemplateModal"
import { useTemplateStoryServiceHook } from "@/app/service/Interaction/templateStoryService"
@ -22,19 +21,43 @@ const FamousTemplate: React.FC = () => {
const [isItemGenerating, setIsItemGenerating] = useState<{ [key: string]: boolean }>({})
const [activeTemplateId, setActiveTemplateId] = useState<string | null>(null)
const [isPreviewReady, setIsPreviewReady] = useState(false)
const [activeTab, setActiveTab] = useState<"all" | "music" | "animation" | "thriller">("all")
useEffect(() => {
void getTemplateStoryList()
}, [getTemplateStoryList])
const topTemplates = templateStoryList.slice(0, 10)
const filteredTemplates = templateStoryList.filter((t) => {
if (activeTab === "all") return true
const categories = (t.category || "").split(",").map((s) => s.trim().toLowerCase())
return categories.includes(activeTab)
})
const topTemplates = filteredTemplates
return (
<section data-alt="famous-template" className="w-full">
<div data-alt="famous-template-header" className="mb-4 flex items-center justify-between">
<div data-alt="famous-template-header" className="mb-4 flex items-center">
<h2 data-alt="famous-template-title" className="text-xl py-4 font-semibold text-white">
Make Movie
Scene Sparks
</h2>
<div data-alt="template-tabs" className="flex items-center gap-2 ml-4">
{(["all", "music", "animation", "thriller"] as const).map((tab) => (
<button
key={tab}
type="button"
data-alt={`template-tab-${tab}`}
onClick={() => setActiveTab(tab)}
className={`px-3 py-1 italic rounded-none text-sm transition-colors border ${
activeTab === tab
? "border-white/60 bg-white/80 text-slate-900"
: "border-white/20 text-white/80 hover:border-white/40 hover:bg-white/10"
}`}
>
{tab.toUpperCase()}
</button>
))}
</div>
</div>
{isLoading ? (