diff --git a/apps/renderer/src/pages/(main)/(layer)/(subview)/rsshub/index.tsx b/apps/renderer/src/pages/(main)/(layer)/(subview)/rsshub/index.tsx index 89ebdddef..46246f5f5 100644 --- a/apps/renderer/src/pages/(main)/(layer)/(subview)/rsshub/index.tsx +++ b/apps/renderer/src/pages/(main)/(layer)/(subview)/rsshub/index.tsx @@ -143,25 +143,24 @@ function List({ data }: { data?: RSSHubModel[] }) { {instance.userLimit || t("rsshub.table.unlimited")}
- {status?.data?.usage?.rsshubId === instance.id && ( - - )} - {status?.data?.usage?.rsshubId !== instance.id && ( - - )} + {me?.id === instance.ownerUserId && ( )} @@ -175,18 +174,23 @@ function List({ data }: { data?: RSSHubModel[] }) { ) } -const formSchema = z.object({ - months: z.coerce.number().min(1).max(12), -}) - const SetModalContent = ({ dismiss, instance }: { dismiss: () => void; instance: RSSHubModel }) => { const { t } = useTranslation("settings") const setRSSHubMutation = useSetRSSHubMutation() + const details = useAuthQuery(Queries.rsshub.get({ id: instance.id })) + const hasPurchase = !!details.data?.purchase + + const formSchema = z.object({ + months: z.coerce + .number() + .min(hasPurchase ? 0 : 1) + .max(12), + }) const form = useForm>({ resolver: zodResolver(formSchema), defaultValues: { - months: 1, + months: hasPurchase ? 0 : 1, }, }) @@ -235,6 +239,16 @@ const SetModalContent = ({ dismiss, instance }: { dismiss: () => void; instance:
+ {details.data?.purchase && ( +
+
+ {t("rsshub.useModal.purchase_expires_at")} +
+
+ {new Date(details.data.purchase.expiresAt).toLocaleString()} +
+
+ )}
{instance.price > 0 && ( @@ -247,7 +261,7 @@ const SetModalContent = ({ dismiss, instance }: { dismiss: () => void; instance:
- + {t("rsshub.useModal.month")} diff --git a/apps/renderer/src/queries/rsshub.ts b/apps/renderer/src/queries/rsshub.ts index 27c986c4e..50d71eeb7 100644 --- a/apps/renderer/src/queries/rsshub.ts +++ b/apps/renderer/src/queries/rsshub.ts @@ -11,9 +11,13 @@ export const useSetRSSHubMutation = ({ onError }: MutationBaseProps = {}) => mutationFn: (data: { id: string | null; durationInMonths?: number }) => apiClient.rsshub.use.$post({ json: data }), - onSuccess: () => { + onSuccess: (_, variables) => { rsshub.list().invalidate() rsshub.status().invalidate() + + if (variables.id) { + rsshub.get({ id: variables.id }).invalidate() + } }, onError: (error) => { diff --git a/locales/errors/en.json b/locales/errors/en.json index 88659a001..a0d9c57d8 100644 --- a/locales/errors/en.json +++ b/locales/errors/en.json @@ -56,5 +56,6 @@ "11002": "RSSHub is in use", "11003": "RSSHub not found", "11004": "RSSHub user limit exceeded", + "11005": "RSSHub purchase not found", "12000": "Action limit exceeded" } diff --git a/locales/settings/en.json b/locales/settings/en.json index 97aa26cab..cc53c8f45 100644 --- a/locales/settings/en.json +++ b/locales/settings/en.json @@ -291,6 +291,7 @@ "rsshub.useModal.about": "About this Instance", "rsshub.useModal.month": "month", "rsshub.useModal.months_label": "The number of months you want to purchase", + "rsshub.useModal.purchase_expires_at": "You have purchased this Instance, and your purchase expires at", "rsshub.useModal.title": "RSSHub Instance", "rsshub.useModal.useWith": "Use with {{amount}} Power", "titles.about": "About", diff --git a/packages/shared/src/hono.ts b/packages/shared/src/hono.ts index 979236e6b..8ac0e080c 100644 --- a/packages/shared/src/hono.ts +++ b/packages/shared/src/hono.ts @@ -12726,13 +12726,19 @@ declare const _routes: hono_hono_base.HonoBase