11import { useAtom } from "jotai" ;
2- import { ChevronDown , ChevronLeft , ChevronUp , Cpu , Diamond , Menu , RectangleEllipsis , Tag , X , Zap } from "lucide-react" ;
2+ import {
3+ ChevronDown ,
4+ ChevronLeft ,
5+ ChevronUp ,
6+ Cpu ,
7+ Diamond ,
8+ Menu ,
9+ RectangleEllipsis ,
10+ SquareArrowUp ,
11+ Tag ,
12+ X ,
13+ Zap ,
14+ } from "lucide-react" ;
315import React from "react" ;
416import { useTranslation } from "react-i18next" ;
517import { Outlet , useLocation , useNavigate } from "react-router-dom" ;
@@ -10,7 +22,7 @@ import { StageSaveManager } from "../core/service/dataFileService/StageSaveManag
1022import { Settings } from "../core/service/Settings" ;
1123import { Stage } from "../core/stage/Stage" ;
1224import { StageDumper } from "../core/stage/StageDumper" ;
13- import { fileAtom } from "../state" ;
25+ import { fileAtom , isWindowCollapsingAtom } from "../state" ;
1426import { cn } from "../utils/cn" ;
1527import { PathString } from "../utils/pathString" ;
1628import { appScale , getCurrentWindow , isDesktop , isMac , isMobile , isWeb } from "../utils/platform" ;
@@ -21,6 +33,7 @@ import LogicNodePanel from "./_logic_node_panel";
2133import RecentFilesPanel from "./_recent_files_panel" ;
2234import StartFilePanel from "./_start_file_panel" ;
2335import TagPanel from "./_tag_panel" ;
36+ import { LogicalSize } from "@tauri-apps/api/dpi" ;
2437
2538export default function App ( ) {
2639 const [ maxmized , setMaxmized ] = React . useState ( false ) ;
@@ -37,6 +50,8 @@ export default function App() {
3750 const [ file , setFile ] = useAtom ( fileAtom ) ;
3851 const filename = React . useMemo ( ( ) => PathString . absolute2file ( file ) , [ file ] ) ;
3952 const [ useNativeTitleBar , setUseNativeTitleBar ] = React . useState ( false ) ;
53+ const [ isWindowCollapsing , setIsWindowCollapsing ] = useAtom ( isWindowCollapsingAtom ) ;
54+
4055 const { t } = useTranslation ( "app" ) ;
4156
4257 React . useEffect ( ( ) => {
@@ -320,17 +335,40 @@ export default function App() {
320335 ) }
321336 </ >
322337 ) }
323-
324- { /* 右上角图钉按钮 */ }
338+ { /* 右上角闪电按钮 */ }
325339 < IconButton
326340 onClick = { ( e ) => {
327341 e . stopPropagation ( ) ;
328342 setIsStartFilePanelOpen ( ! isStartFilePanelOpen ) ;
329343 } }
330344 tooltip = "设置启动时打开的文件"
345+ disabled = { isMobile }
331346 >
332347 < Zap className = { cn ( "cursor-pointer" , isStartFilePanelOpen ? "rotate-45 scale-125" : "" ) } />
333348 </ IconButton >
349+ { isDesktop && (
350+ < IconButton
351+ onClick = { async ( e ) => {
352+ e . stopPropagation ( ) ;
353+ // const size = await getCurrentWindow().outerSize();
354+ const tauriWindow = getCurrentWindow ( ) ;
355+ if ( isWindowCollapsing ) {
356+ // 纵向展开
357+ tauriWindow . setSize ( new LogicalSize ( 1100 , 800 ) ) ;
358+ tauriWindow . setAlwaysOnTop ( false ) ;
359+ } else {
360+ // 纵向收起
361+ tauriWindow . setSize ( new LogicalSize ( 1100 , 100 ) ) ;
362+ tauriWindow . setAlwaysOnTop ( true ) ;
363+ }
364+ setIsWindowCollapsing ( ! isWindowCollapsing ) ;
365+ } }
366+ tooltip = { isWindowCollapsing ? "展开并取消顶置窗口" : "卷起并顶置窗口" }
367+ >
368+ < SquareArrowUp className = { cn ( "cursor-pointer" , isWindowCollapsing ? "rotate-180 scale-125" : "" ) } />
369+ </ IconButton >
370+ ) }
371+
334372 { /* 右上角窗口控制按钮 */ }
335373 { isDesktop && ! useNativeTitleBar && ! isMac && ! isWeb && (
336374 < Button className = "right-4 top-4 flex items-center gap-1 active:scale-100" >
0 commit comments