Skip to content

Commit

Permalink
feat: 禁用打包后的右键菜单
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb committed Jun 9, 2024
1 parent 8e90868 commit 4330a89
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ const App = () => {

Object.assign(clipboardStore, payload);
});

if (isDev()) return;

document.addEventListener("contextmenu", (event) => {
if (getSelection()?.toString().trim()) return;

event.preventDefault();
});
});

return (
Expand Down
19 changes: 17 additions & 2 deletions src/pages/Clipboard/History/components/Popup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Icon from "@/components/Icon";
import type { HistoryItem } from "@/types/database";
import type { HistoryItem, HistoryType } from "@/types/database";
import { Flex } from "antd";
import clsx from "clsx";
import { FixedSizeList } from "react-window";
Expand Down Expand Up @@ -28,6 +28,21 @@ const Popup = () => {
}
};

const getChineseType = (type: HistoryType) => {
switch (type) {
case "text":
return "文本";
case "rtf":
return "富文本";
case "html":
return "HTML";
case "image":
return "图片";
case "files":
return "文件(夹)";
}
};

const collect = async (data: HistoryItem) => {
const { id, isCollected } = data;

Expand Down Expand Up @@ -64,7 +79,7 @@ const Popup = () => {
className="h-full rounded-6 bg-white p-6 shadow"
>
<Flex justify="space-between" className="color-2 text-12">
<span>{type}</span>
<span>{getChineseType(type!)}</span>
<span>{createTime}</span>
<Icon
hoverable
Expand Down

0 comments on commit 4330a89

Please sign in to comment.