From 6ba817ffb7ed148a2cec747fac1e67879bb5236b Mon Sep 17 00:00:00 2001 From: cooder Date: Sun, 10 Mar 2024 15:50:07 +0800 Subject: [PATCH] feat: export opml --- apps/web/src/pages/feeds/index.tsx | 61 +++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/apps/web/src/pages/feeds/index.tsx b/apps/web/src/pages/feeds/index.tsx index 2d9303b..f59d4d2 100644 --- a/apps/web/src/pages/feeds/index.tsx +++ b/apps/web/src/pages/feeds/index.tsx @@ -91,6 +91,38 @@ const Feeds = () => { return feedData?.items.find((item) => item.id === currentMpId); }, [currentMpId, feedData?.items]); + const handleExportOpml = async (ev) => { + ev.preventDefault(); + ev.stopPropagation(); + if (!feedData?.items?.length) { + console.warn('没有订阅源'); + return; + } + + let opmlContent = ` + + + WeWeRSS 所有订阅源 + + + `; + + feedData?.items.forEach((sub) => { + opmlContent += ` \n`; + }); + + opmlContent += ` + `; + + const blob = new Blob([opmlContent], { type: 'text/xml;charset=utf-8;' }); + const link = document.createElement('a'); + link.href = URL.createObjectURL(blob); + link.download = 'WeWeRSS-All.opml'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + }; + return ( <>
@@ -236,15 +268,26 @@ const Feeds = () => {
) : ( - - RSS - +
+ + 导出OPML + + + + RSS + +
)}