feat: tipc showShareMenu and saveToEagle

This commit is contained in:
DIYgod
2024-05-18 18:56:43 +08:00
parent 4f20e29414
commit d4ea0962d1
3 changed files with 57 additions and 66 deletions
+16 -22
View File
@@ -2,6 +2,7 @@ import { useToast } from "@renderer/components/ui/use-toast"
import { useCallback } from "react"
import { ofetch } from "ofetch"
import { useQuery } from "@tanstack/react-query"
import { client } from "@renderer/lib/client"
export const useCheckEagle = () =>
useQuery({
@@ -57,7 +58,7 @@ export const useEntryActions = ({
const { toast } = useToast()
const execAction = useCallback(
(action: string) => {
async (action: string) => {
switch (action) {
case "copyLink":
navigator.clipboard.writeText(url)
@@ -70,29 +71,22 @@ export const useEntryActions = ({
window.open(url, "_blank")
break
case "share":
window.electron.ipcRenderer.send("share-url", url)
client.showShareMenu(url)
break
case "save-to-eagle":
window.electron.ipcRenderer.once(
"save-to-eagle-reply",
(_, response) => {
if (response?.status === "success") {
toast({
duration: 3000,
description: "Saved to Eagle.",
})
} else {
toast({
duration: 3000,
description: "Failed to save to Eagle.",
})
}
},
)
window.electron.ipcRenderer.send("save-to-eagle", {
url,
images,
})
if (!images?.length) return
const response = await client.saveToEagle({ url, images })
if (response?.status === "success") {
toast({
duration: 3000,
description: "Saved to Eagle.",
})
} else {
toast({
duration: 3000,
description: "Failed to save to Eagle.",
})
}
break
}
},