feat: save images to eagle
This commit is contained in:
@@ -39,6 +39,39 @@ app.whenReady().then(() => {
|
||||
}).popup()
|
||||
})
|
||||
|
||||
ipcMain.on(
|
||||
"save-to-eagle",
|
||||
async (
|
||||
event,
|
||||
data: {
|
||||
url: string
|
||||
images: string[]
|
||||
},
|
||||
) => {
|
||||
try {
|
||||
const res = await fetch("http://localhost:41595/api/item/addFromURLs", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
items: data.images?.map((image) => ({
|
||||
url: image,
|
||||
website: data.url,
|
||||
headers: {
|
||||
referer: data.url,
|
||||
},
|
||||
})),
|
||||
}),
|
||||
})
|
||||
const result = await res.json()
|
||||
event.reply("save-to-eagle-reply", result)
|
||||
} catch (error) {
|
||||
event.reply("save-to-eagle-reply", null)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
createWindow()
|
||||
|
||||
app.on("activate", function () {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M256 512C397.385 512 512 397.385 512 256C512 114.615 397.385 0 256 0C114.615 0 0 114.615 0 256C0 397.385 114.615 512 256 512Z" fill="url(#paint0_linear)"/>
|
||||
<path d="M385.7 369.2C376.3 381.2 358.3 401 329.6 415.4C302.4 429.1 275.8 432.9 254.5 432.8C248.2 432.8 242.4 432.4 237.1 431.9C232.6 420 228 403.6 226.7 384C225.3 363.2 226.9 325.7 249.9 288.3C268.1 258.6 291.8 241.8 306.7 233.2C306.5 237.7 306.6 241.9 306.7 245.8C307 252.8 307.8 258.5 308.4 262.4C310.2 273.4 317.1 307.9 345.8 338.9C360.2 354.4 375.3 363.8 385.7 369.2Z" fill="#80BBFF"/>
|
||||
<path d="M385.7 369.2C376.3 381.2 358.3 401 329.6 415.4C302.4 429.1 275.8 432.9 254.5 432.8C248.2 432.8 242.4 432.4 237.1 431.9C232.6 420 228 403.6 226.7 384C225.3 363.2 226.9 325.7 249.9 288.3C268.1 258.6 291.8 241.8 306.7 233.2C306.5 237.7 306.6 241.9 306.7 245.8C307 252.8 307.8 258.5 308.4 262.4C310.2 273.4 317.1 307.9 345.8 338.9C360.2 354.4 375.3 363.8 385.7 369.2Z" fill="url(#paint1_linear)"/>
|
||||
<path d="M312 199C306.9 217.1 306.1 233.4 306.7 245.7C299.1 251 289.7 258.6 280.4 268.9C256.8 295.2 248.6 322.9 245.8 334.2C243.1 345.1 237.1 374.5 246.4 409.8C248.8 418.8 251.7 426.5 254.5 432.8C233.4 432.7 217.4 428.9 210.8 427.1C201.4 424.6 175.9 417.4 150.4 398.2C145.5 394.5 140.7 390.5 135.9 385.9C136.6 373.4 138.7 357.9 144.3 340.9C152.6 315.4 165 297 173.8 285.9C163 288.2 152.3 290.5 141.5 292.8C147.3 276.8 158.1 254.7 178.4 234.5C227 186.2 292.9 186.2 315.8 187.8C314.2 191.7 313 195.4 312 199Z" fill="url(#paint2_linear)"/>
|
||||
<path d="M312 199C306.9 217.1 306.1 233.4 306.7 245.7C299.1 251 289.7 258.6 280.4 268.9C256.8 295.2 248.6 322.9 245.8 334.2C243.1 345.1 237.1 374.5 246.4 409.8C248.8 418.8 251.7 426.5 254.5 432.8C233.4 432.7 217.4 428.9 210.8 427.1C201.4 424.6 175.9 417.4 150.4 398.2C145.5 394.5 140.7 390.5 135.9 385.9C136.6 373.4 138.7 357.9 144.3 340.9C152.6 315.4 165 297 173.8 285.9C163 288.2 152.3 290.5 141.5 292.8C147.3 276.8 158.1 254.7 178.4 234.5C227 186.2 292.9 186.2 315.8 187.8C314.2 191.7 313 195.4 312 199Z" fill="url(#paint3_linear)"/>
|
||||
<path d="M312 199C306.9 217.1 306.1 233.4 306.7 245.7C299.1 251 289.7 258.6 280.4 268.9C256.8 295.2 248.6 322.9 245.8 334.2C243.1 345.1 237.1 374.5 246.4 409.8C248.8 418.8 251.7 426.5 254.5 432.8C233.4 432.7 217.4 428.9 210.8 427.1C201.4 424.6 175.9 417.4 150.4 398.2C145.5 394.5 140.7 390.5 135.9 385.9C136.6 373.4 138.7 357.9 144.3 340.9C152.6 315.4 165 297 173.8 285.9C163 288.2 152.3 290.5 141.5 292.8C147.3 276.8 158.1 254.7 178.4 234.5C227 186.2 292.9 186.2 315.8 187.8C314.2 191.7 313 195.4 312 199Z" fill="url(#paint4_linear)"/>
|
||||
<path opacity="0.8" d="M312 199C306.9 217.1 306.1 233.4 306.7 245.7C299.1 251 289.7 258.6 280.4 268.9C256.8 295.2 248.6 322.9 245.8 334.2C243.1 345.1 237.1 374.5 246.4 409.8C248.8 418.8 251.7 426.5 254.5 432.8C233.4 432.7 217.4 428.9 210.8 427.1C201.4 424.6 175.9 417.4 150.4 398.2C145.5 394.5 140.7 390.5 135.9 385.9C136.6 373.4 138.7 357.9 144.3 340.9C152.6 315.4 165 297 173.8 285.9C163 288.2 152.3 290.5 141.5 292.8C147.3 276.8 158.1 254.7 178.4 234.5C227 186.2 292.9 186.2 315.8 187.8C314.2 191.7 313 195.4 312 199Z" fill="url(#paint5_linear)"/>
|
||||
<path opacity="0.5" d="M254.4 432.9C240.4 432.9 228.5 431.2 219.5 429.3C210.1 427.4 193.6 423.2 174.9 413.6C161.8 406.9 152.9 400.3 150.2 398.3C140 390.6 132.2 382.8 126.6 376.4C128.5 356.4 133.2 340.8 137.1 330.5C150.9 294 173.2 272.2 184.8 269.5C191 268.1 198.2 267.4 198.2 267.4C203.3 266.9 207.3 266.8 210.2 266.8C215.1 266.7 219.6 266.9 223.6 267.2C221.6 270.7 218.9 275.7 216.1 281.8C210.3 294.6 201.6 313.2 201.6 336.3C201.6 365.3 213.6 386.1 218.6 394.5C230.6 414.6 245.5 426.7 254.4 432.9Z" fill="url(#paint6_linear)"/>
|
||||
<path d="M363.9 122.5C353.4 130.6 331.7 149.5 318.1 181.8C315.6 187.7 313.6 193.4 312.1 199C304.5 198.6 294.6 198.6 283.3 200.1C263.5 202.6 248.2 208.2 238.9 212.2C229.2 216.4 213.1 224.5 196.6 239.1C181.8 252.1 171.9 265.5 165.6 275.7C171 273.5 177.4 271.3 184.9 269.7C194.6 267.6 203.3 267 210.2 267C203.6 272.3 195.2 279.8 186.7 290.1C178.2 300.4 167.7 315.7 160.1 336C150.6 361.3 149.6 384 150.2 398.5C135.8 387.7 121.5 373.1 110 353.4C105.3 345.3 78.2 297 93.6 237.1C101.4 206.6 117 185.5 126.5 174.5C120.1 176.2 112.4 178.8 104 183C94.5 187.7 87.1 193.1 81.6 197.6C87.9 182.9 113.2 128 175.3 99.4C225.4 76.4 288.6 75.5 337.5 103.4C349.2 110 357.9 117.1 363.9 122.5Z" fill="white"/>
|
||||
<path d="M403.6 218.6C396.8 218.2 389.4 218.1 381.6 218.8C366.7 220 355 223.2 348.5 225.2C339.4 228 331.9 231.3 326.1 234.2C326.6 220.3 329.3 209 331.7 201.2C333 197 334.4 193.2 335.8 189.9C347.7 192.3 362.1 196.5 377.7 203.8C387.3 208.4 396 213.5 403.6 218.6Z" fill="#B2D6FF"/>
|
||||
<path d="M403.6 218.6C396.8 218.2 389.4 218.1 381.6 218.8C366.7 220 355 223.2 348.5 225.2C339.4 228 331.9 231.3 326.1 234.2C326.6 220.3 329.3 209 331.7 201.2C333 197 334.4 193.2 335.8 189.9C347.7 192.3 362.1 196.5 377.7 203.8C387.3 208.4 396 213.5 403.6 218.6Z" fill="url(#paint7_linear)"/>
|
||||
<path d="M425.2 254.8C419.5 248 411.9 240 402 232.3C394.8 226.6 387.8 222.2 381.6 218.8C371.8 213.4 363.4 210.1 358 208.2C348 204.6 338.9 202.5 331.6 201.3C334.3 192.6 337.5 185.7 339.7 181.3C340.7 179.3 344 172.9 349 165.8C358.5 152.3 369.6 142.4 378.5 135.8C382.8 138.5 388.4 142.4 394.2 148C396.5 150.2 404.4 158 411.7 170.5C420.5 185.5 423.4 198.8 424.9 205.7C428.4 221.8 428.6 238.6 425.2 254.8Z" fill="white"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear" x1="256" y1="-31.2207" x2="256" y2="237.826" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#4DA1FF"/>
|
||||
<stop offset="1" stop-color="#0072EE"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear" x1="310.007" y1="538.34" x2="303.954" y2="288.445" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="white" stop-opacity="0"/>
|
||||
<stop offset="1" stop-color="#1A86FF" stop-opacity="0.4"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear" x1="143.509" y1="394.42" x2="244.677" y2="309.68" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="white"/>
|
||||
<stop offset="1" stop-color="#B2D6FF"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear" x1="95.6468" y1="395.392" x2="242.211" y2="316.274" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="white"/>
|
||||
<stop offset="1" stop-color="#B2D6FF"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint4_linear" x1="219.568" y1="303.883" x2="235.133" y2="193.78" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="white" stop-opacity="0"/>
|
||||
<stop offset="1" stop-color="#4DA1FF" stop-opacity="0.4"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint5_linear" x1="253.657" y1="328.578" x2="186.788" y2="228.851" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="white" stop-opacity="0"/>
|
||||
<stop offset="1" stop-color="#4DA1FF" stop-opacity="0.4"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint6_linear" x1="206.395" y1="344.213" x2="158.18" y2="318.828" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="white" stop-opacity="0"/>
|
||||
<stop offset="1" stop-color="#4DA1FF" stop-opacity="0.3"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint7_linear" x1="373.968" y1="264.232" x2="360.133" y2="207.162" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="white" stop-opacity="0"/>
|
||||
<stop offset="1" stop-color="#4DA1FF" stop-opacity="0.4"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 7.1 KiB |
@@ -6,7 +6,7 @@ import { EntryContextMenu } from "./context-menu"
|
||||
|
||||
export function ArticleItem({ entry }: { entry: EntriesResponse[number] }) {
|
||||
return (
|
||||
<EntryContextMenu url={entry.url} view={0}>
|
||||
<EntryContextMenu entry={entry} view={0}>
|
||||
<div className="flex my-5 px-2 py-3">
|
||||
<FeedIcon feed={entry.feeds} />
|
||||
<div className="line-clamp-5 text-sm flex-1 -mt-0.5 leading-tight">
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
ContextMenuTrigger,
|
||||
} from "@renderer/components/ui/context-menu"
|
||||
import { useEntryActions } from "@renderer/hooks/useEntryActions"
|
||||
import { EntriesResponse } from "@renderer/lib/types"
|
||||
|
||||
export const items = [
|
||||
[
|
||||
@@ -18,6 +19,11 @@ export const items = [
|
||||
className: "i-mingcute-world-2-line",
|
||||
action: "openInBrowser",
|
||||
},
|
||||
{
|
||||
name: "Save Images to Eagle",
|
||||
icon: "/eagle.svg",
|
||||
action: "save-to-eagle",
|
||||
},
|
||||
{
|
||||
name: "Share",
|
||||
className: "i-mingcute-share-2-line",
|
||||
@@ -27,17 +33,20 @@ export const items = [
|
||||
]
|
||||
|
||||
export function EntryContextMenu({
|
||||
entry,
|
||||
view,
|
||||
url,
|
||||
children,
|
||||
}: {
|
||||
entry: EntriesResponse[number]
|
||||
view: number
|
||||
url?: string
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
if (!url) return children
|
||||
if (!entry?.url) return children
|
||||
|
||||
const { execAction } = useEntryActions(url)
|
||||
const { execAction } = useEntryActions({
|
||||
url: entry.url,
|
||||
images: entry.images,
|
||||
})
|
||||
|
||||
return (
|
||||
<ContextMenu>
|
||||
|
||||
@@ -17,7 +17,7 @@ export function EntryContent({ entry }: { entry: ActivedEntry }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<EntryShare url={entry?.url} view={0} />
|
||||
<EntryShare entry={entry} view={0} />
|
||||
<m.div
|
||||
className="px-5 py-5 overflow-y-auto h-full"
|
||||
initial={{ opacity: 0.01, y: 100 }}
|
||||
|
||||
@@ -7,22 +7,43 @@ import {
|
||||
import { cn } from "@renderer/lib/utils"
|
||||
import { useEntryActions } from "@renderer/hooks/useEntryActions"
|
||||
import { items } from "@renderer/components/entry-column/context-menu"
|
||||
import { ActivedEntry } from "@renderer/lib/types"
|
||||
|
||||
export function EntryShare({ view, url }: { view: number; url?: string }) {
|
||||
if (!url) return null
|
||||
export function EntryShare({
|
||||
view,
|
||||
entry,
|
||||
}: {
|
||||
view: number
|
||||
entry: ActivedEntry
|
||||
}) {
|
||||
if (!entry?.url) return null
|
||||
|
||||
const { execAction } = useEntryActions(url)
|
||||
const { execAction } = useEntryActions({
|
||||
url: entry.url,
|
||||
images: entry.images,
|
||||
})
|
||||
|
||||
return (
|
||||
<div className="px-5 h-14 flex items-center text-lg justify-end text-zinc-500 gap-5">
|
||||
<TooltipProvider delayDuration={300}>
|
||||
{items[view].map((item) => (
|
||||
<Tooltip>
|
||||
<Tooltip key={item.name}>
|
||||
<TooltipTrigger className="flex items-center my-2">
|
||||
<i
|
||||
className={cn(item.className, "cursor-pointer no-drag-region")}
|
||||
onClick={() => execAction(item.action)}
|
||||
/>
|
||||
{item.icon ? (
|
||||
<img
|
||||
className="w-4 h-4 grayscale cursor-pointer no-drag-region"
|
||||
src={item.icon}
|
||||
onClick={() => execAction(item.action)}
|
||||
/>
|
||||
) : (
|
||||
<i
|
||||
className={cn(
|
||||
item.className,
|
||||
"cursor-pointer no-drag-region",
|
||||
)}
|
||||
onClick={() => execAction(item.action)}
|
||||
/>
|
||||
)}
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="bottom">{item.name}</TooltipContent>
|
||||
</Tooltip>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import { useToast } from "@renderer/components/ui/use-toast"
|
||||
import { useCallback } from "react"
|
||||
|
||||
export const useEntryActions = (url: string) => {
|
||||
export const useEntryActions = ({
|
||||
url,
|
||||
images,
|
||||
}: {
|
||||
url: string
|
||||
images?: string[]
|
||||
}) => {
|
||||
const { toast } = useToast()
|
||||
|
||||
const execAction = useCallback(
|
||||
@@ -20,6 +26,28 @@ export const useEntryActions = (url: string) => {
|
||||
case "share":
|
||||
window.electron.ipcRenderer.send("share-url", 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,
|
||||
})
|
||||
break
|
||||
}
|
||||
},
|
||||
[toast],
|
||||
|
||||
Reference in New Issue
Block a user