浏览代码

feat: Add pin button

MystiPanda 1 年之前
父节点
当前提交
5ceac03db1
共有 1 个文件被更改,包括 18 次插入0 次删除
  1. 18 0
      src/components/layout/layout-control.tsx

+ 18 - 0
src/components/layout/layout-control.tsx

@@ -5,6 +5,8 @@ import {
   CropSquareRounded,
   FilterNoneRounded,
   HorizontalRuleRounded,
+  PushPinOutlined,
+  PushPinRounded,
 } from "@mui/icons-material";
 import { useState } from "react";
 
@@ -12,12 +14,28 @@ export const LayoutControl = () => {
   const minWidth = 40;
 
   const [isMaximized, setIsMaximized] = useState(false);
+  const [isPined, setIsPined] = useState(false);
   appWindow.isMaximized().then((isMaximized) => {
     setIsMaximized(() => isMaximized);
   });
 
   return (
     <>
+      <Button
+        size="small"
+        sx={{ minWidth, svg: { transform: "scale(0.9)" } }}
+        onClick={() => {
+          appWindow.setAlwaysOnTop(!isPined);
+          setIsPined((isPined) => !isPined);
+        }}
+      >
+        {isPined ? (
+          <PushPinRounded fontSize="small" />
+        ) : (
+          <PushPinOutlined fontSize="small" />
+        )}
+      </Button>
+
       <Button
         size="small"
         sx={{ minWidth, svg: { transform: "scale(0.9)" } }}