forked from 77media/video-flow
增加template tab
This commit is contained in:
parent
954774d1b1
commit
95ec751dcf
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
import type React from "react"
|
import type React from "react"
|
||||||
import { useEffect, useState } from "react"
|
import { useEffect, useState } from "react"
|
||||||
import Link from "next/link"
|
|
||||||
import { X } from "lucide-react"
|
import { X } from "lucide-react"
|
||||||
import { PcTemplateModal } from "@/components/ChatInputBox/PcTemplateModal"
|
import { PcTemplateModal } from "@/components/ChatInputBox/PcTemplateModal"
|
||||||
import { useTemplateStoryServiceHook } from "@/app/service/Interaction/templateStoryService"
|
import { useTemplateStoryServiceHook } from "@/app/service/Interaction/templateStoryService"
|
||||||
@ -22,19 +21,43 @@ const FamousTemplate: React.FC = () => {
|
|||||||
const [isItemGenerating, setIsItemGenerating] = useState<{ [key: string]: boolean }>({})
|
const [isItemGenerating, setIsItemGenerating] = useState<{ [key: string]: boolean }>({})
|
||||||
const [activeTemplateId, setActiveTemplateId] = useState<string | null>(null)
|
const [activeTemplateId, setActiveTemplateId] = useState<string | null>(null)
|
||||||
const [isPreviewReady, setIsPreviewReady] = useState(false)
|
const [isPreviewReady, setIsPreviewReady] = useState(false)
|
||||||
|
const [activeTab, setActiveTab] = useState<"all" | "music" | "animation" | "thriller">("all")
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void getTemplateStoryList()
|
void getTemplateStoryList()
|
||||||
}, [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 (
|
return (
|
||||||
<section data-alt="famous-template" className="w-full">
|
<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">
|
<h2 data-alt="famous-template-title" className="text-xl py-4 font-semibold text-white">
|
||||||
Make Movie
|
Scene Sparks
|
||||||
</h2>
|
</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>
|
</div>
|
||||||
|
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user