Skip to content

Commit

Permalink
feat: 剪切板内容删除前确认
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb committed Jun 14, 2024
1 parent 1570eda commit 0a8c043
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { HistoryItem } from "@/types/database";
import { open } from "@tauri-apps/api/shell";
import { Typography } from "antd";
import type { FC } from "react";

Expand All @@ -11,12 +10,9 @@ const Text: FC<HistoryItem> = (props) => {
const url = isURL(content) ? content : `mailto:${content}`;

return (
<span
className="cursor-pointer text-primary"
onMouseDown={() => open(url)}
>
<a href={url} target="_blank" rel="noreferrer">
{content}
</span>
</a>
);
}

Expand Down
21 changes: 13 additions & 8 deletions src/pages/Clipboard/History/components/Popup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Icon from "@/components/Icon";
import type { HistoryItem } from "@/types/database";
import { Flex } from "antd";
import { Flex, Popconfirm } from "antd";
import clsx from "clsx";
import { FixedSizeList } from "react-window";
import {
Expand Down Expand Up @@ -143,13 +143,18 @@ const Popup = () => {
className={clsx({ "text-gold!": isCollected })}
onMouseDown={() => collect(historyData)}
/>
<Icon
hoverable
size={15}
name="i-iconamoon:trash-simple"
className="hover:text-red!"
onMouseDown={() => deleteItem(id!)}
/>
<Popconfirm
title="确定要删除吗?"
placement="left"
onConfirm={() => deleteItem(id!)}
>
<Icon
hoverable
size={15}
name="i-iconamoon:trash-simple"
className="hover:text-red!"
/>
</Popconfirm>
</Flex>
</Flex>

Expand Down
4 changes: 1 addition & 3 deletions src/pages/Clipboard/History/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ const ClipboardHistory = () => {

if (!clipboardStore.capacity) return;

const maxMinute = clipboardStore.capacity * 24 * 60;

for (const item of list) {
const { id, createTime } = item;

if (dayjs().diff(createTime, "minutes") > maxMinute) {
if (dayjs().diff(createTime, "days") >= clipboardStore.capacity) {
deleteSQL("history", id);
}
}
Expand Down

0 comments on commit 0a8c043

Please sign in to comment.