feat: allow custom rsshub url, close #2084
This commit is contained in:
parent
0a0b39b5f8
commit
4aacca3b40
|
|
@ -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: () => <ExportFeedsForm />,
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
|
|
@ -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<z.infer<typeof exportFeedFormSchema>>({
|
||||
resolver: zodResolver(exportFeedFormSchema),
|
||||
})
|
||||
|
||||
function onSubmit(values: z.infer<typeof exportFeedFormSchema>) {
|
||||
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 (
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4 text-sm">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="rsshubUrl"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>{t("general.export.rsshub_url.label")}</FormLabel>
|
||||
<FormControl>
|
||||
<Input type="url" placeholder="https://rsshub.app" {...field} />
|
||||
</FormControl>
|
||||
<FormDescription>{t("general.export.rsshub_url.description")}</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<Button type="submit">{t("ok", { ns: "common" })}</Button>
|
||||
</form>
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description clean web app service worker cache
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -11508,7 +11508,11 @@ declare const _routes: hono_hono_base.HonoBase<Env, ({
|
|||
} & {
|
||||
"/export": {
|
||||
$get: {
|
||||
input: {};
|
||||
input: {
|
||||
query: {
|
||||
RSSHubURL?: string | undefined;
|
||||
};
|
||||
};
|
||||
output: {};
|
||||
outputFormat: string;
|
||||
status: 200;
|
||||
|
|
|
|||
Loading…
Reference in New Issue