Repository navigation
Expand file tree
/
Copy pathApp.tsx
More file actions
124 lines (116 loc) · 3.81 KB
/
Copy pathApp.tsx
File metadata and controls
124 lines (116 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import { Card } from "@heroui/react";
import { lazy, Suspense, useEffect, useState } from "react";
import { useI18n } from "./contexts/I18nContext";
import { EditorLoadingSkeleton } from "./components/video-editor/layout/EditorLoadingSkeleton";
const HudWindow = lazy(() => import("./components/launch/HudWindow"));
const SourceSelector = lazy(() =>
import("./components/launch/SourceSelector").then((module) => ({
default: module.SourceSelector,
})),
);
const CountdownOverlay = lazy(() =>
import("./components/countdown/CountdownOverlay").then((module) => ({
default: module.CountdownOverlay,
})),
);
const UpdateToastWindow = lazy(() =>
import("./components/launch/UpdateToastWindow").then((module) => ({
default: module.UpdateToastWindow,
})),
);
const EditorWindow = lazy(() => import("./components/video-editor/EditorWindow"));
const TeleprompterWindow = lazy(() => import("./components/teleprompter/TeleprompterWindow"));
const DrawingOverlay = lazy(() => import("./components/drawing/DrawingOverlay"));
const DrawingToolbar = lazy(() => import("./components/drawing/DrawingToolbar"));
export default function App() {
const [windowType] = useState(
() => new URLSearchParams(window.location.search).get("windowType") || "",
);
const { t } = useI18n();
const appIconSrc = "/app-icons/camverse-128.png";
useEffect(() => {
document.documentElement.dataset.windowType = windowType;
if (
windowType === "hud-overlay" ||
windowType === "source-selector" ||
windowType === "countdown" ||
windowType === "update-toast" ||
windowType === "drawing-overlay" ||
windowType === "drawing-toolbar"
) {
document.body.style.background = "transparent";
document.documentElement.style.background = "transparent";
document.getElementById("root")?.style.setProperty("background", "transparent");
}
if (windowType === "hud-overlay") {
document.documentElement.classList.add("hud-overlay-window");
document.body.classList.add("hud-overlay-window");
document.getElementById("root")?.classList.add("hud-overlay-window");
window.electronAPI?.hudOverlaySetIgnoreMouse?.(true);
} else if (windowType === "update-toast") {
document.documentElement.style.overflow = "visible";
document.body.style.overflow = "visible";
document.getElementById("root")?.style.setProperty("overflow", "visible");
}
}, [windowType]);
useEffect(() => {
document.title =
windowType === "editor"
? t("app.editorTitle", "CamVerse Editor")
: windowType === "teleprompter"
? "Teleprompter"
: t("app.name", "CamVerse");
}, [windowType, t]);
let content;
switch (windowType) {
case "hud-overlay":
content = <HudWindow />;
break;
case "source-selector":
content = <SourceSelector />;
break;
case "countdown":
content = <CountdownOverlay />;
break;
case "update-toast":
content = <UpdateToastWindow />;
break;
case "editor":
content = <EditorWindow />;
break;
case "teleprompter":
content = <TeleprompterWindow />;
break;
case "drawing-overlay":
content = <DrawingOverlay />;
break;
case "drawing-toolbar":
content = <DrawingToolbar />;
break;
default:
content = (
<div className="flex h-full w-full items-center justify-center bg-editor-bg text-foreground">
<Card className="flex-row items-center gap-4 px-6 py-5">
<img
src={appIconSrc}
alt={t("app.name", "CamVerse")}
className="h-12 w-12 rounded-xl"
/>
<div>
<h1 className="text-xl font-semibold tracking-tight">
{t("app.name", "CamVerse")}
</h1>
<p className="text-sm text-foreground/65">
{t("app.subtitle", "Screen recording and editing")}
</p>
</div>
</Card>
</div>
);
}
return (
<Suspense fallback={windowType === "editor" ? <EditorLoadingSkeleton /> : null}>
{content}
</Suspense>
);
}