From 4aacca3b40fa8961f30c130a678960d93ec5fa6b Mon Sep 17 00:00:00 2001
From: Stephen Zhou <38493346+hyoban@users.noreply.github.com>
Date: Tue, 31 Dec 2024 15:45:54 +0800
Subject: [PATCH] feat: allow custom rsshub url, close #2084
---
.../modules/settings/tabs/data-control.tsx | 63 +++++++++++++++++--
locales/settings/en.json | 2 +
packages/shared/src/hono.ts | 6 +-
3 files changed, 66 insertions(+), 5 deletions(-)
diff --git a/apps/renderer/src/modules/settings/tabs/data-control.tsx b/apps/renderer/src/modules/settings/tabs/data-control.tsx
index dcabec5d5..27de9ee66 100644
--- a/apps/renderer/src/modules/settings/tabs/data-control.tsx
+++ b/apps/renderer/src/modules/settings/tabs/data-control.tsx
@@ -1,10 +1,23 @@
import { CarbonInfinitySymbol } from "@follow/components/icons/infinify.jsx"
import { Button, MotionButtonBase } from "@follow/components/ui/button/index.js"
+import {
+ Form,
+ FormControl,
+ FormDescription,
+ FormField,
+ FormItem,
+ FormLabel,
+ FormMessage,
+} from "@follow/components/ui/form/index.js"
+import { Input } from "@follow/components/ui/input/Input.js"
import { Label } from "@follow/components/ui/label/index.jsx"
import { Slider } from "@follow/components/ui/slider/index.js"
import { env } from "@follow/shared/env"
+import { zodResolver } from "@hookform/resolvers/zod"
import { useQuery } from "@tanstack/react-query"
+import { useForm } from "react-hook-form"
import { useTranslation } from "react-i18next"
+import { z } from "zod"
import { setGeneralSetting, useGeneralSettingValue } from "~/atoms/settings/general"
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
@@ -99,10 +112,11 @@ export const SettingDataControl = () => {
description: t("general.export.description"),
buttonText: t("general.export.button"),
action: () => {
- const link = document.createElement("a")
- link.href = `${env.VITE_API_URL}/subscriptions/export`
- link.download = "follow.opml"
- link.click()
+ present({
+ title: t("general.export.label"),
+ clickOutsideToDismiss: true,
+ content: () => ,
+ })
},
},
@@ -130,6 +144,47 @@ export const SettingDataControl = () => {
)
}
+const exportFeedFormSchema = z.object({
+ rsshubUrl: z.string().url().optional(),
+})
+
+const ExportFeedsForm = () => {
+ const { t } = useTranslation("settings")
+
+ const form = useForm>({
+ resolver: zodResolver(exportFeedFormSchema),
+ })
+
+ function onSubmit(values: z.infer) {
+ const link = document.createElement("a")
+ link.href = `${env.VITE_API_URL}/subscriptions/export${values.rsshubUrl ? `?RSSHubURL=${values.rsshubUrl}` : ""}`
+ link.download = "follow.opml"
+ link.click()
+ }
+
+ return (
+
+
+ )
+}
+
/**
* @description clean web app service worker cache
*/
diff --git a/locales/settings/en.json b/locales/settings/en.json
index cc53c8f45..e7e510aef 100644
--- a/locales/settings/en.json
+++ b/locales/settings/en.json
@@ -120,6 +120,8 @@
"general.export.button": "Export",
"general.export.description": "Export your feeds to an OPML file.",
"general.export.label": "Export Feeds",
+ "general.export.rsshub_url.description": "Default base URL for RSSHub route, leave it empty to use https://rsshub.app.",
+ "general.export.rsshub_url.label": "RSSHub URL",
"general.export_database.button": "Export",
"general.export_database.description": "Export your database to a JSON file.",
"general.export_database.label": "Export Database",
diff --git a/packages/shared/src/hono.ts b/packages/shared/src/hono.ts
index 8ac0e080c..9d6e4a312 100644
--- a/packages/shared/src/hono.ts
+++ b/packages/shared/src/hono.ts
@@ -11508,7 +11508,11 @@ declare const _routes: hono_hono_base.HonoBase