mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
cleanup
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { useParams, useRouter } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import {
|
import {
|
||||||
ResizablePanelGroup,
|
ResizablePanelGroup,
|
||||||
@@ -16,6 +16,7 @@ import { usePanelStore } from "@/stores/panel-store";
|
|||||||
import { useProjectStore } from "@/stores/project-store";
|
import { useProjectStore } from "@/stores/project-store";
|
||||||
import { EditorProvider } from "@/components/editor-provider";
|
import { EditorProvider } from "@/components/editor-provider";
|
||||||
import { usePlaybackControls } from "@/hooks/use-playback-controls";
|
import { usePlaybackControls } from "@/hooks/use-playback-controls";
|
||||||
|
import { Onboarding } from "@/components/onboarding";
|
||||||
|
|
||||||
export default function Editor() {
|
export default function Editor() {
|
||||||
const {
|
const {
|
||||||
@@ -36,12 +37,12 @@ export default function Editor() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const projectId = params.project_id as string;
|
const projectId = params.project_id as string;
|
||||||
const handledProjectIds = useRef<Set<string>>(new Set());
|
const handledProjectIds = useRef<Set<string>>(new Set());
|
||||||
|
const [isOnboardingOpen, setIsOnboardingOpen] = useState(true);
|
||||||
|
|
||||||
usePlaybackControls();
|
usePlaybackControls();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const initProject = async () => {
|
const initProject = async () => {
|
||||||
|
|
||||||
if (!projectId) return;
|
if (!projectId) return;
|
||||||
|
|
||||||
if (activeProject?.id === projectId) {
|
if (activeProject?.id === projectId) {
|
||||||
@@ -139,6 +140,12 @@ export default function Editor() {
|
|||||||
</ResizablePanelGroup>
|
</ResizablePanelGroup>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<Onboarding
|
||||||
|
isOpen={isOnboardingOpen}
|
||||||
|
onClose={() => {
|
||||||
|
setIsOnboardingOpen(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</EditorProvider>
|
</EditorProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
"use client";
|
"use client"
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from "@/components/ui/card";
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
@@ -28,8 +29,15 @@ import { useProjectStore } from "@/stores/project-store";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { DeleteProjectDialog } from "@/components/delete-project-dialog";
|
import { DeleteProjectDialog } from "@/components/delete-project-dialog";
|
||||||
import { RenameProjectDialog } from "@/components/rename-project-dialog";
|
import { RenameProjectDialog } from "@/components/rename-project-dialog";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
export default function ProjectsPage() {
|
export default function ProjectsPage() {
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV !== "development") {
|
||||||
|
toast.error("You are not allowed to access this page");
|
||||||
|
redirect("/");
|
||||||
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
createNewProject,
|
createNewProject,
|
||||||
savedProjects,
|
savedProjects,
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from "./ui/dialog";
|
||||||
|
|
||||||
|
interface OnboardingProps {
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Onboarding({ isOpen, onClose }: OnboardingProps) {
|
||||||
|
return (
|
||||||
|
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>Welcome to Clipture</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
Let's get you started with the basics.
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@ import type { NextRequest } from "next/server";
|
|||||||
import { env } from "./env";
|
import { env } from "./env";
|
||||||
|
|
||||||
export async function middleware(request: NextRequest) {
|
export async function middleware(request: NextRequest) {
|
||||||
|
const protectedPaths = ["/editor", "/projects"];
|
||||||
|
|
||||||
// Handle fuckcapcut.com domain redirect
|
// Handle fuckcapcut.com domain redirect
|
||||||
if (request.headers.get("host") === "fuckcapcut.com") {
|
if (request.headers.get("host") === "fuckcapcut.com") {
|
||||||
return NextResponse.redirect("https://opencut.app/why-not-capcut", 301);
|
return NextResponse.redirect("https://opencut.app/why-not-capcut", 301);
|
||||||
@@ -10,7 +12,7 @@ export async function middleware(request: NextRequest) {
|
|||||||
|
|
||||||
const path = request.nextUrl.pathname;
|
const path = request.nextUrl.pathname;
|
||||||
|
|
||||||
if (path.startsWith("/editor") && env.NODE_ENV === "production") {
|
if (protectedPaths.includes(path) && env.NODE_ENV === "production") {
|
||||||
const homeUrl = new URL("/", request.url);
|
const homeUrl = new URL("/", request.url);
|
||||||
homeUrl.searchParams.set("redirect", request.url);
|
homeUrl.searchParams.set("redirect", request.url);
|
||||||
return NextResponse.redirect(homeUrl);
|
return NextResponse.redirect(homeUrl);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { toast } from "sonner";
|
|||||||
import { useMediaStore } from "./media-store";
|
import { useMediaStore } from "./media-store";
|
||||||
import { useTimelineStore } from "./timeline-store";
|
import { useTimelineStore } from "./timeline-store";
|
||||||
import { generateUUID } from "@/lib/utils";
|
import { generateUUID } from "@/lib/utils";
|
||||||
|
import { env } from "@/env";
|
||||||
|
|
||||||
interface ProjectStore {
|
interface ProjectStore {
|
||||||
activeProject: TProject | null;
|
activeProject: TProject | null;
|
||||||
@@ -36,6 +37,16 @@ export const useProjectStore = create<ProjectStore>((set, get) => ({
|
|||||||
isInitialized: false,
|
isInitialized: false,
|
||||||
|
|
||||||
createNewProject: async (name: string) => {
|
createNewProject: async (name: string) => {
|
||||||
|
try {
|
||||||
|
if (process.env.NODE_ENV !== "development") {
|
||||||
|
toast.error("Project creation is disabled outside development environment");
|
||||||
|
throw new Error("Not allowed in production");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
toast.error("Failed to create new project");
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
const newProject: TProject = {
|
const newProject: TProject = {
|
||||||
id: generateUUID(),
|
id: generateUUID(),
|
||||||
name,
|
name,
|
||||||
|
|||||||
Reference in New Issue
Block a user