Skip to content

Commit b17a07c

Browse files
committed
✨ 添加演示模式
1 parent 2e73ae9 commit b17a07c

File tree

4 files changed

+39
-7
lines changed

4 files changed

+39
-7
lines changed

app/src/pages/_app.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { StageSaveManager } from "../core/service/dataFileService/StageSaveManag
2323
import { Settings } from "../core/service/Settings";
2424
import { Stage } from "../core/stage/Stage";
2525
import { StageDumper } from "../core/stage/StageDumper";
26-
import { fileAtom, isWindowCollapsingAtom } from "../state";
26+
import { fileAtom, isClassroomModeAtom, isWindowCollapsingAtom } from "../state";
2727
import { cn } from "../utils/cn";
2828
import { PathString } from "../utils/pathString";
2929
import { appScale, getCurrentWindow, isDesktop, isMac, isMobile, isWeb } from "../utils/platform";
@@ -48,6 +48,7 @@ export default function App() {
4848
const navigate = useNavigate();
4949
const location = useLocation();
5050
const [file, setFile] = useAtom(fileAtom);
51+
const [isClassroomMode] = useAtom(isClassroomModeAtom);
5152
const filename = React.useMemo(() => PathString.absolute2file(file), [file]);
5253
const [useNativeTitleBar, setUseNativeTitleBar] = React.useState(false);
5354
const [isWindowCollapsing, setIsWindowCollapsing] = useAtom(isWindowCollapsingAtom);
@@ -249,6 +250,7 @@ export default function App() {
249250
{/* 左上角菜单按钮 */}
250251
<IconButton
251252
tooltip="菜单"
253+
className={cn(isClassroomMode && "opacity-0")}
252254
onClick={(e) => {
253255
if (location.pathname !== "/") {
254256
if (location.pathname.startsWith("/welcome")) {
@@ -277,21 +279,25 @@ export default function App() {
277279
>
278280
{location.pathname === "/" ? isMenuOpen ? <RectangleEllipsis /> : <Menu /> : <ChevronLeft />}
279281
</IconButton>
282+
280283
<IconButton
281284
onClick={(e) => {
282285
e.stopPropagation();
283286
setIsTagPanelOpen(!isTagPanelOpen);
284287
}}
285288
tooltip="标签节点"
289+
className={cn(isClassroomMode && "opacity-0")}
286290
>
287291
<Tag className={cn("cursor-pointer", isTagPanelOpen ? "rotate-90" : "")} />
288292
</IconButton>
293+
289294
{/* 逻辑节点按钮 */}
290295
<IconButton
291296
onClick={(e) => {
292297
e.stopPropagation();
293298
setIsLogicNodePanelOpen(!isLogicNodePanelOpen);
294299
}}
300+
className={cn(isClassroomMode && "opacity-0")}
295301
tooltip="逻辑节点"
296302
>
297303
<Cpu className={cn("cursor-pointer", isLogicNodePanelOpen ? "rotate-45" : "")} />
@@ -307,6 +313,7 @@ export default function App() {
307313
className={cn("hover:cursor-move active:scale-100 active:cursor-grabbing", {
308314
"text-yellow-500": isSaved,
309315
"flex-1": isDesktop,
316+
"opacity-0": isClassroomMode,
310317
})}
311318
tooltip="拖动窗口"
312319
>
@@ -319,6 +326,7 @@ export default function App() {
319326
className={cn(
320327
isSaved ? "text-icon-button-text" : "text-yellow-500",
321328
"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",
329+
isClassroomMode && "opacity-0",
322330
)}
323331
>
324332
{filename + (isSaved ? "" : t("unsaved"))}
@@ -332,14 +340,15 @@ export default function App() {
332340
e.stopPropagation();
333341
setIsStartFilePanelOpen(!isStartFilePanelOpen);
334342
}}
343+
className={cn(isClassroomMode && "opacity-0")}
335344
tooltip="设置启动时打开的文件"
336345
disabled={isMobile}
337346
>
338347
<Zap className={cn("cursor-pointer", isStartFilePanelOpen ? "rotate-45 scale-125" : "")} />
339348
</IconButton>
340349
{isDesktop && (
341350
<IconButton
342-
className={cn(isWindowCollapsing && "animate-bounce")}
351+
className={cn(isWindowCollapsing && "animate-bounce", isClassroomMode && "opacity-0")}
343352
onClick={async (e) => {
344353
e.stopPropagation();
345354
// const size = await getCurrentWindow().outerSize();
@@ -363,7 +372,9 @@ export default function App() {
363372

364373
{/* 右上角窗口控制按钮 */}
365374
{isDesktop && !useNativeTitleBar && !isMac && !isWeb && (
366-
<Button className="right-4 top-4 flex items-center gap-1 active:scale-100">
375+
<Button
376+
className={cn("right-4 top-4 flex items-center gap-1 active:scale-100", isClassroomMode && "opacity-0")}
377+
>
367378
<ChevronDown
368379
onClick={() => getCurrentWindow().minimize()}
369380
className="transition hover:opacity-80 active:scale-75"

app/src/pages/_app_menu.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import {
1616
FolderOpen,
1717
Fullscreen,
1818
Info,
19+
MonitorX,
1920
MoreHorizontal,
21+
Presentation,
2022
// PartyPopper,
2123
RefreshCcw,
2224
Save,
@@ -33,7 +35,7 @@ import { useNavigate } from "react-router-dom";
3335
import { Camera } from "../core/stage/Camera";
3436
import { StageDumper } from "../core/stage/StageDumper";
3537
import { StageManager } from "../core/stage/stageManager/StageManager";
36-
import { fileAtom, isExportTreeTextPanelOpenAtom, isRecentFilePanelOpenAtom } from "../state";
38+
import { fileAtom, isClassroomModeAtom, isExportTreeTextPanelOpenAtom, isRecentFilePanelOpenAtom } from "../state";
3739
import { cn } from "../utils/cn";
3840
import { getCurrentWindow, isDesktop, isWeb } from "../utils/platform";
3941
// import { writeTextFile } from "@tauri-apps/plugin-fs";
@@ -55,6 +57,7 @@ import { StageHistoryManager } from "../core/stage/stageManager/StageHistoryMana
5557
export default function AppMenu({ className = "", open = false }: { className?: string; open: boolean }) {
5658
const navigate = useNavigate();
5759
const [file, setFile] = useAtom(fileAtom);
60+
const [isClassroomMode, setIsClassroomMode] = useAtom(isClassroomModeAtom);
5861
const { t } = useTranslation("appMenu");
5962
const [, setRecentFilePanelOpen] = useAtom(isRecentFilePanelOpenAtom);
6063
const [, setExportTreeTextPanelOpen] = useAtom(isExportTreeTextPanelOpenAtom);
@@ -519,6 +522,14 @@ export default function AppMenu({ className = "", open = false }: { className?:
519522
>
520523
help
521524
</Col>
525+
<Col
526+
icon={isClassroomMode ? <MonitorX /> : <Presentation />}
527+
onClick={() => {
528+
setIsClassroomMode(!isClassroomMode);
529+
}}
530+
>
531+
{isClassroomMode ? "退出演示" : "演示模式"}
532+
</Col>
522533
</Row>
523534
{!isWeb && (
524535
<Row icon={<AppWindow />} title={t("window.title")}>

app/src/pages/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Settings } from "../core/service/Settings";
77
import { Canvas } from "../core/stage/Canvas";
88
import { Stage } from "../core/stage/Stage";
99
import { useAtom } from "jotai";
10-
import { isWindowCollapsingAtom } from "../state";
10+
import { isClassroomModeAtom, isWindowCollapsingAtom } from "../state";
1111
import { CursorNameEnum } from "../types/cursors";
1212
import DetailsEditSidePanel from "./_details_edit_side_panel";
1313
import DetailsEditSmallPanel from "./_details_edit_small_panel";
@@ -24,6 +24,7 @@ export default function Home() {
2424
const [isProtectPrivacy, setIsProtectPrivacy] = React.useState(false);
2525

2626
const [isWindowCollapsing] = useAtom(isWindowCollapsingAtom);
27+
const [isClassroomMode] = useAtom(isClassroomModeAtom);
2728

2829
useEffect(() => {
2930
const handleResize = () => {
@@ -119,11 +120,11 @@ export default function Home() {
119120

120121
return (
121122
<>
122-
{!isWindowCollapsing && <Toolbar />}
123+
{!isWindowCollapsing && !isClassroomMode && <Toolbar />}
123124
<SearchingNodePanel />
124125
{/* 这个打算被取代 */}
125126
{nodeDetailsPanel === "small" ? <DetailsEditSmallPanel /> : <DetailsEditSidePanel />}
126-
{!isWindowCollapsing && <HintText />}
127+
{!isWindowCollapsing && !isClassroomMode && <HintText />}
127128
{/* TODO: 下面这个写法有点奇怪 rgba值太长了 */}
128129
<div
129130
style={{

app/src/state.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,13 @@ export const isRecentFilePanelOpenAtom = atom(false);
1818
*/
1919
export const isExportTreeTextPanelOpenAtom = atom(false);
2020

21+
/**
22+
* 当前窗口是否折叠
23+
*/
2124
export const isWindowCollapsingAtom = atom(false);
25+
26+
/**
27+
* 是否进入演示模式
28+
* (老师专用)
29+
*/
30+
export const isClassroomModeAtom = atom(false);

0 commit comments

Comments
 (0)