"use client";
import { useState, useRef, useEffect, useMemo } from "react";
import {
Table,
AlignHorizontalSpaceAround,
Loader2,
Clapperboard,
CircleArrowRight,
} from "lucide-react";
import "./style/home-page2.css";
import { usePathname, useRouter } from "next/navigation";
import { Swiper, SwiperSlide } from "swiper/react";
import "swiper/swiper-bundle.css"; // 引入样式
import { Autoplay } from "swiper/modules";
import { VideoCarouselLayout } from "@/components/video-carousel-layout";
import { VideoGridLayout } from "@/components/video-grid-layout";
import { motion, AnimatePresence } from "framer-motion";
import { LiquidButton } from "@/components/ui/liquid-glass-button";
import {
createScriptProject,
CreateScriptProjectRequest,
} from "@/api/script_project";
import { ProjectTypeEnum, ModeEnum, ResolutionEnum } from "@/app/model/enums";
import { getResourcesList, Resource } from "@/api/resources";
import { Carousel } from "antd";
import { TextCanvas } from "../common/TextCanvas";
import { fetchSubscriptionPlans, SubscriptionPlan } from "@/lib/stripe";
import { useCallbackModal } from "@/app/layout";
export function HomePage2() {
const [hPading, setHPading] = useState(0);
useEffect(() => {
// 获取当前窗口尺寸
const currentWidth = window.innerWidth;
const currentHeight = window.innerHeight;
// 计算缩放比例 (1920x1080)
const wScale = currentWidth / 1920;
const hScale = currentHeight / 1080;
// 检查app节点是否存在
const homePage = document.getElementById("home-page");
if (!homePage) {
console.error("未找到app节点");
return;
}
// setHPading((hScale || 1) * 10);
// 创建样式元素
const style = document.createElement("style");
// 设置CSS样式
style.textContent = `
#home-page {
transform-origin: top left;
transform: scale(${wScale}, ${hScale});
width: 1920px;
height: 1080px;
}
`;
// 将样式添加到head
document.head.appendChild(style);
}, []);
return (
//
);
}
/** 首屏 */
function HomeModule1() {
const router = useRouter();
return (
Ideas Become Movies
Next-Generation AI Movies Making Platform
From Ideas to Movies in just 5-10 minutes
router.push("/create")}
>
Early Access
);
}
/**核心价值 */
function HomeModule2() {
const videoList = [
{
title: "Text to Movie",
video: "/assets/module2 (1).mp4",
},
{
title: "Image to Movie",
video: "/assets/module2 (2).mp4",
},
{
title: "Template to Movie",
video: "/assets/module2 (3).mp4",
},
];
return (
Just Give Us Your Ideas
Input your idea in one sentence and MovieFlow will bring
your creativity to life
{/* 第一个视频 */}
{videoList.map((item, index) => (
{item.title}
))}
);
}
/**案例展示 */
function HomeModule3() {
const videoList = [
[
"/assets/show (1).mp4",
"/assets/show (2).mp4",
"/assets/show (3).mp4",
"/assets/show (4).mp4",
"/assets/show (5).mp4",
],
[
"/assets/show (6).mp4",
"/assets/show (7).mp4",
"/assets/show (8).mp4",
"/assets/show (9).mp4",
"/assets/show (10).mp4",
],
[
"/assets/show (11).mp4",
"/assets/show (12).mp4",
"/assets/show (13).mp4",
"/assets/show (14).mp4",
"/assets/show (15).mp4",
],
];
// 定义内容样式
const contentStyle: React.CSSProperties = {
height: "100%",
lineHeight: "10rem",
textAlign: "center",
background: "#364d79",
};
return (
Create Anything
MovieFlow can make any kind of film in high quality for you
{/* 3x3网格布局 */}
{/* 上方阴影遮罩 - 使用 mask 实现真正的渐变模糊,加重黑色 */}
{/* 下方阴影遮罩 - 使用 mask 实现真正的渐变模糊,加重黑色 */}
{videoList.map((column, columnIndex) => (
{column.map((video, videoIndex) => (
{
const videoElement = e.currentTarget;
videoElement.play();
}}
/>
))}
))}
);
}
/**电影制作工序介绍 */
function HomeModule4() {
const [activeTab, setActiveTab] = useState(0);
const processSteps = [
{
title: "The Narrative Engine",
description:
" From a single thought, it builds entire worlds and compelling plots.",
video: "/assets/module4 (3).mp4",
},
{
title: "AI Character Engine",
description:
"Cast your virtual actors. Lock them in once, for the entire story.",
video: "/assets/module4 (1).mp4",
},
{
title: "AI vision engine",
description:
"It translates your aesthetic into art, light, and cinematography for every single shot.",
video: "/assets/module4 (4).mp4",
},
{
title: "Intelligent Editing Engine",
description:
"An editing AI drives the final cut, for a story told seamlessly.",
video: "/assets/module4 (2).mp4",
},
];
const handleTabClick = (index: number) => {
setActiveTab(index);
};
return (
Edit like you think
{/* 左侧四个切换tab */}
{processSteps.map((step, index) => (
handleTabClick(index)}
className={`w-[31.75rem] h-[10.5rem] rounded-lg cursor-pointer transition-all duration-300 border ${
activeTab === index
? "bg-[#262626] border-white/20 hover:border-white/40"
: "bg-black border-white/10 hover:border-white/40"
}`}
>
{step.title}
{step.description}
))}
{/* 右侧视频播放区域 */}
);
}
/**价格方案 */
function HomeModule5() {
const [billingType, setBillingType] = useState<"month" | "year">("month");
const [plans, setPlans] = useState([]);
const { setShowCallbackModal } = useCallbackModal();
const pathname = usePathname();
// 从后端获取订阅计划数据
useEffect(() => {
const loadPlans = async () => {
try {
const plansData = await fetchSubscriptionPlans();
setPlans(plansData);
} catch (err) {
console.error("加载订阅计划失败:", err);
}
};
loadPlans();
}, []);
const pricingPlans = useMemo<
{
title: string;
price: number;
credits: string;
buttonText: string;
features: string[];
}[]
>(() => {
return plans.map((plan) => {
return {
title: plan.display_name || plan.name,
price:
billingType === "month"
? plan.price_month / 100
: plan.price_year / 100,
credits: plan.description,
buttonText: plan.is_free ? "Try For Free" : "Subscribe Now",
features: plan.features || [],
};
});
}, [plans, billingType]);
const handleSubscribe = async (planName: string) => {
if (planName === "hobby") {
return;
}
localStorage.setItem("callBackUrl", pathname);
try {
// 使用新的Checkout Session方案(更简单!)
const { createCheckoutSession, redirectToCheckout } = await import(
"@/lib/stripe"
);
// 从localStorage获取当前用户信息
const User = JSON.parse(localStorage.getItem("currentUser") || "{}");
if (!User.id) {
throw new Error("无法获取用户ID,请重新登录");
}
// 1. 创建Checkout Session
const result = await createCheckoutSession({
user_id: String(User.id),
plan_name: planName,
billing_cycle: billingType,
});
if (!result.successful || !result.data) {
throw new Error("create checkout session failed");
}
setShowCallbackModal(true)
window.open(result.data.checkout_url, '_blank');
} catch (error) {
throw new Error("create checkout session failed, please try again later");
}
};
return (
Start Creating
{/* 计费切换 */}
setBillingType("month")}
className={`box-border flex justify-center items-center w-[6rem] text-base rounded-full transition-all duration-300 ${
billingType === "month"
? "bg-white text-black"
: "text-white hover:text-gray-300"
}`}
>
Monthly
setBillingType("year")}
className={`box-border flex justify-center items-center w-[7.125rem] text-base rounded-full transition-all duration-300 ${
billingType === "year"
? "bg-white text-black"
: "text-white hover:text-gray-300"
}`}
>
Yearly - 10%
{/* 主要价格卡片 */}
{pricingPlans.map((plan, index) => (
{plan.title}
${plan.price}
/month
{plan.credits}
handleSubscribe(plan.title)}
className="w-full bg-white text-black py-[0.75rem] rounded-full mb-[1rem] hover:bg-black hover:text-white transition-colors border border-white/20"
>
{plan.buttonText}
* Billed monthly until cancelled
{plan.features.map((feature, featureIndex) => (
✓
{feature}
))}
))}
{/* 额外价格卡片 */}
Free
$0
10 Video mins and 1 AI credit per week, 1 Express avatar, 4 Exports
per week with invideo watermark.
No access to generative features.
Try For Free
Enterprise
Custom
Custom solutions for large organizations. Advanced security and
flexible pricing based on your needs.
on your needs.
Contact Us
);
}
function HomeModule6() {
return (
© 2025 MovieFlow. All rights reserved.
);
}