Skip to content

Commit

Permalink
feat: 右键菜单支持在默认的图片查看器中预览图片
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb committed Jun 19, 2024
1 parent 0675959 commit dc8b0fb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
TODO:

- [x] 删除或者清空顺带删除图片和 base64
- [ ] 右键图片支持预览图片
- [ ] 到处 txt 直接用 id,避免重复导出
- [x] 右键图片支持预览图片
- [x] 导出 txt 直接用 id,避免重复导出
- [ ] 退出 + 退出确认
- [ ] 文件(夹)不存在时的优化
- [ ] 文件(夹)被删除时的优化

以下问题,欢迎各位 Rust 大佬指点迷津 😁

Expand Down
6 changes: 3 additions & 3 deletions src/database/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const updateSQL = async (
export const deleteSQL = async (tableName: TableName, id?: number) => {
const list = await selectSQL<HistoryItem[]>("history", { id });

const deleteImage = (item: HistoryItem) => {
const deleteImageFile = (item: HistoryItem) => {
const { type, value = "" } = item;

if (type !== "image") return;
Expand All @@ -152,12 +152,12 @@ export const deleteSQL = async (tableName: TableName, id?: number) => {
if (id) {
await executeSQL(`DELETE FROM ${tableName} WHERE id = ?;`, [id]);

deleteImage(list[0]);
deleteImageFile(list[0]);
} else {
await executeSQL(`DELETE FROM ${tableName};`);

for (const item of list) {
deleteImage(item);
deleteImageFile(item);
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ const Item: FC<ListChildComponentProps<HistoryItem[]>> = memo((props) => {
});
};

const previewImage = () => {
viewFile(value, false);
};

const downloadImage = async () => {
const fileName = value.split("/").pop();

Expand Down Expand Up @@ -160,6 +164,11 @@ const Item: FC<ListChildComponentProps<HistoryItem[]>> = memo((props) => {
hide: group !== "text",
event: exportTXT,
},
{
label: "预览图片",
hide: type !== "image",
event: previewImage,
},
{
label: "下载图片",
hide: type !== "image",
Expand Down

0 comments on commit dc8b0fb

Please sign in to comment.