diff --git a/src/renderer/src/modules/discover/content-components.tsx b/src/renderer/src/modules/discover/DiscoverFeedForm.tsx similarity index 94% rename from src/renderer/src/modules/discover/content-components.tsx rename to src/renderer/src/modules/discover/DiscoverFeedForm.tsx index 922d84387d..2c77db7e55 100644 --- a/src/renderer/src/modules/discover/content-components.tsx +++ b/src/renderer/src/modules/discover/DiscoverFeedForm.tsx @@ -77,7 +77,7 @@ const FeedDescription = ({ description }: { description?: string }) => { The description of this feed is as follows, and you can fill out the parameter form with the relevant information.

- + {description} @@ -116,7 +116,9 @@ export const DiscoverFeedForm = ({ ...Object.fromEntries( keys.array.map((keyItem) => [ keyItem.name, - keyItem.optional ? z.string().optional() : z.string().min(1), + keyItem.optional ? + z.string().optional().nullable() : + z.string().min(1), ]), ), }), @@ -133,6 +135,7 @@ export const DiscoverFeedForm = ({ } return ret }, [route.parameters]) + const form = useForm>({ resolver: zodResolver(dynamicFormSchema), defaultValues: defaultValue, @@ -146,7 +149,8 @@ export const DiscoverFeedForm = ({ try { const fillRegexpPath = regexpPathToPath(route.path, data) const url = `rsshub://${routePrefix}${fillRegexpPath}` - const defaultView = getViewFromRoute(route) || getSidebarActiveView() as FeedViewType + const defaultView = + getViewFromRoute(route) || (getSidebarActiveView() as FeedViewType) present({ title: "Add Feed", @@ -185,7 +189,7 @@ export const DiscoverFeedForm = ({ useEffect(() => { modal?.setClickOutSideToDismiss?.(!form.formState.isDirty) - }, [form.formState.isDirty, modal?.setClickOutSideToDismiss]) + }, [form.formState.isDirty, modal, modal.setClickOutSideToDismiss]) return (
@@ -261,7 +265,12 @@ export const DiscoverFeedForm = ({ )} -
+
Preview
diff --git a/src/renderer/src/modules/discover/recommendation-content.tsx b/src/renderer/src/modules/discover/recommendation-content.tsx index c3ce6478b0..9428a59aa9 100644 --- a/src/renderer/src/modules/discover/recommendation-content.tsx +++ b/src/renderer/src/modules/discover/recommendation-content.tsx @@ -1,4 +1,4 @@ -import { DiscoverFeedForm } from "./content-components" +import { DiscoverFeedForm } from "./DiscoverFeedForm" import type { RSSHubRoute } from "./types" export const RecommendationContent = ({ diff --git a/src/renderer/src/modules/discover/rss3-form.tsx b/src/renderer/src/modules/discover/rss3-form.tsx index 937b6227ce..dbf1ec7f63 100644 --- a/src/renderer/src/modules/discover/rss3-form.tsx +++ b/src/renderer/src/modules/discover/rss3-form.tsx @@ -2,7 +2,7 @@ import { LoadingCircle } from "@renderer/components/ui/loading" import { useAuthQuery } from "@renderer/hooks/common" import { Queries } from "@renderer/queries" -import { DiscoverFeedForm } from "./content-components" +import { DiscoverFeedForm } from "./DiscoverFeedForm" export function DiscoverRSS3() { const { data, isLoading } = useAuthQuery(