diff --git a/apps/renderer/src/modules/power/ranking/index.tsx b/apps/renderer/src/modules/power/ranking/index.tsx index 8dc3b7277..2a2527e24 100644 --- a/apps/renderer/src/modules/power/ranking/index.tsx +++ b/apps/renderer/src/modules/power/ranking/index.tsx @@ -58,7 +58,7 @@ export const PowerRanking: Component = ({ className }) => { {!!hasGap && ( <> - ... + ...
@@ -66,14 +66,14 @@ export const PowerRanking: Component = ({ className }) => { )} - {!!row.rank && rankNumber(row.rank)} - + {!!row.rank && rankNumber(row.rank)} + - +
{
- - {!!row.level && } - + {!!row.level && }
) })} - ... + ... diff --git a/apps/renderer/src/pages/(main)/(layer)/(subview)/rsshub/index.tsx b/apps/renderer/src/pages/(main)/(layer)/(subview)/rsshub/index.tsx new file mode 100644 index 000000000..a3230e99c --- /dev/null +++ b/apps/renderer/src/pages/(main)/(layer)/(subview)/rsshub/index.tsx @@ -0,0 +1,131 @@ +import { Logo } from "@follow/components/icons/logo.jsx" +import { Button } from "@follow/components/ui/button/index.js" +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@follow/components/ui/table/index.jsx" +import type { RSSHubModel } from "@follow/models" +import { useTranslation } from "react-i18next" + +import { whoami } from "~/atoms/user" +import { useAuthQuery } from "~/hooks/common" +import { useSubViewTitle } from "~/modules/app-layout/subview/hooks" +import { UserAvatar } from "~/modules/user/UserAvatar" +import { Queries } from "~/queries" + +export function Component() { + const { t } = useTranslation("settings") + + useSubViewTitle("words.rsshub") + + const list = useAuthQuery(Queries.rsshub.list()) + + return ( +
+
{t("words.rsshub", { ns: "common" })}
+
{t("rsshub.public_instances")}
+ +
+ ) +} + +function List({ data }: { data?: RSSHubModel[] }) { + const { t } = useTranslation("settings") + const me = whoami() + + return ( + + + + + + {t("rsshub.table.owner")} + + + {t("rsshub.table.description")} + + + {t("rsshub.table.price")} + + + {t("rsshub.table.userCount")} + + + {t("rsshub.table.userLimit")} + + + + + + + Official + + + + Follow + + + Follow Built-in RSSHub + + + 0 + + + * + Unlimited + + + + + + + {data?.map((instance, index) => { + return ( + + + {(() => { + const flag: string[] = [] + if (index === 0) { + flag.push("In use") + } + if (instance.ownerUserId === me?.id) { + flag.push("Yours") + } + return flag.join(" / ") + })()} + + + + + {instance.description} + + + {instance.price} + + + {instance.userCount} + {instance.userLimit || t("rsshub.table.unlimited")} + + + {index === 0 && } + {index !== 0 && } + {me?.id === instance.ownerUserId && ( + + )} + + + + ) + })} + +
+ ) +} diff --git a/apps/renderer/src/queries/_.ts b/apps/renderer/src/queries/_.ts index 00dd8cb9e..84b188e23 100644 --- a/apps/renderer/src/queries/_.ts +++ b/apps/renderer/src/queries/_.ts @@ -6,5 +6,6 @@ export { entries } from "./entries" export { feed } from "./feed" export { invitations } from "./invitations" export { lists } from "./lists" +export { rsshub } from "./rsshub" export { subscription } from "./subscriptions" export { wallet } from "./wallet" diff --git a/apps/renderer/src/queries/rsshub.ts b/apps/renderer/src/queries/rsshub.ts new file mode 100644 index 000000000..d2c0d3fbe --- /dev/null +++ b/apps/renderer/src/queries/rsshub.ts @@ -0,0 +1,53 @@ +import { useMutation } from "@tanstack/react-query" + +import { apiClient } from "~/lib/api-fetch" +import { defineQuery } from "~/lib/defineQuery" + +import type { MutationBaseProps } from "./types" + +export const useUseRSSHubMutation = ({ onError }: MutationBaseProps = {}) => + useMutation({ + mutationFn: (id: string) => apiClient.rsshub.use.$post({ json: { id } }), + + onError: (error) => { + onError?.(error) + }, + }) + +export const useAddRSSHubMutation = ({ onError }: MutationBaseProps = {}) => + useMutation({ + mutationFn: ({ baseUrl, accessKey }: { baseUrl: string; accessKey: string }) => + apiClient.rsshub.$post({ + json: { + baseUrl, + accessKey, + }, + }), + + onError: (error) => { + onError?.(error) + }, + }) + +export const useDeleteRSSHubMutation = ({ onError }: MutationBaseProps = {}) => + useMutation({ + mutationFn: (id: string) => apiClient.rsshub.$delete({ json: { id } }), + + onError: (error) => { + onError?.(error) + }, + }) + +export const rsshub = { + get: ({ id }: { id: string }) => + defineQuery(["rsshub", "get", id], async () => { + const res = await apiClient.rsshub.$get({ query: { id } }) + return res.data + }), + + list: () => + defineQuery(["rsshub", "list"], async () => { + const res = await apiClient.rsshub.list.$get() + return res.data + }), +} diff --git a/locales/common/en.json b/locales/common/en.json index a06725c85..74a1ff4d5 100644 --- a/locales/common/en.json +++ b/locales/common/en.json @@ -36,6 +36,7 @@ "words.result": "result", "words.result_one": "result", "words.result_other": "results", + "words.rsshub": "RSSHub", "words.save": "Save", "words.submit": "Submit", "words.update": "Update", diff --git a/locales/errors/en.json b/locales/errors/en.json index 5ed38a44e..88659a001 100644 --- a/locales/errors/en.json +++ b/locales/errors/en.json @@ -52,5 +52,9 @@ "10002": "Inbox limit exceeded", "10003": "Inbox permission denied", "11000": "RSSHub route not found", + "11001": "You are not the owner of this RSSHub instance", + "11002": "RSSHub is in use", + "11003": "RSSHub not found", + "11004": "RSSHub user limit exceeded", "12000": "Action limit exceeded" } diff --git a/locales/settings/en.json b/locales/settings/en.json index 4bb871309..606ab21de 100644 --- a/locales/settings/en.json +++ b/locales/settings/en.json @@ -278,6 +278,16 @@ "profile.title": "Profile Settings", "profile.updateSuccess": "Profile updated.", "profile.update_password_success": "Password updated.", + "rsshub.public_instances": "Instances", + "rsshub.table.description": "Description", + "rsshub.table.edit": "Edit", + "rsshub.table.inuse": "In Use", + "rsshub.table.owner": "Owner", + "rsshub.table.price": "Price", + "rsshub.table.unlimited": "Unlimited", + "rsshub.table.use": "Use", + "rsshub.table.userCount": "User Count", + "rsshub.table.userLimit": "User Limit", "titles.about": "About", "titles.actions": "Actions", "titles.appearance": "Appearance", diff --git a/packages/components/src/ui/table/variants.tsx b/packages/components/src/ui/table/variants.tsx index 3a0542271..fa8689ff3 100644 --- a/packages/components/src/ui/table/variants.tsx +++ b/packages/components/src/ui/table/variants.tsx @@ -15,7 +15,7 @@ export const tableHeadVariants = cva("", { export const tableCellVariants = cva("", { variants: { size: { - default: "p-4", + default: "px-4 py-2", sm: "py-1 pr-2 [&:last-child]:pr-0", }, }, diff --git a/packages/models/src/types.ts b/packages/models/src/types.ts index b316a1da8..9ffe7d4a7 100644 --- a/packages/models/src/types.ts +++ b/packages/models/src/types.ts @@ -146,3 +146,12 @@ export const TransactionTypes = ["mint", "purchase", "tip", "withdraw", "airdrop export type WalletModel = ExtractBizResponse["data"][number] export type ServerConfigs = ExtractBizResponse["data"] + +export type RSSHubModel = Omit< + ExtractBizResponse["data"][number], + "userCount" +> & { + baseUrl?: string | null + accessKey?: string | null + userCount?: number +} diff --git a/packages/shared/src/hono.ts b/packages/shared/src/hono.ts index a040987f7..8ad921c63 100644 --- a/packages/shared/src/hono.ts +++ b/packages/shared/src/hono.ts @@ -2836,6 +2836,7 @@ declare const subscriptionsRelations: drizzle_orm.Relations<"subscriptions", { users: drizzle_orm.One<"user", true>; feeds: drizzle_orm.One<"feeds", true>; timeline: drizzle_orm.Many<"timeline">; + rsshubUsage: drizzle_orm.One<"rsshub_usage", true>; }>; declare const timeline: drizzle_orm_pg_core.PgTableWithColumns<{ @@ -4160,15 +4161,15 @@ declare const invitationsOpenAPISchema: zod.ZodObject<{ }, zod.UnknownKeysParam, zod.ZodTypeAny, { code: string; createdAt: string | null; - usedAt: string | null; fromUserId: string; toUserId: string | null; + usedAt: string | null; }, { code: string; createdAt: string | null; - usedAt: string | null; fromUserId: string; toUserId: string | null; + usedAt: string | null; }>; declare const invitationsRelations: drizzle_orm.Relations<"invitations", { users: drizzle_orm.One<"user", false>; @@ -4756,6 +4757,272 @@ type MessagingData = { description: string; }; +declare const rsshub: drizzle_orm_pg_core.PgTableWithColumns<{ + name: "rsshub"; + schema: undefined; + columns: { + id: drizzle_orm_pg_core.PgColumn<{ + name: "id"; + tableName: "rsshub"; + dataType: "string"; + columnType: "PgText"; + data: string; + driverParam: string; + notNull: true; + hasDefault: true; + isPrimaryKey: true; + isAutoincrement: false; + hasRuntimeDefault: true; + enumValues: [string, ...string[]]; + baseColumn: never; + identity: undefined; + generated: undefined; + }, {}, {}>; + baseUrl: drizzle_orm_pg_core.PgColumn<{ + name: "base_url"; + tableName: "rsshub"; + dataType: "string"; + columnType: "PgText"; + data: string; + driverParam: string; + notNull: true; + hasDefault: false; + isPrimaryKey: false; + isAutoincrement: false; + hasRuntimeDefault: false; + enumValues: [string, ...string[]]; + baseColumn: never; + identity: undefined; + generated: undefined; + }, {}, {}>; + accessKey: drizzle_orm_pg_core.PgColumn<{ + name: "access_key"; + tableName: "rsshub"; + dataType: "string"; + columnType: "PgText"; + data: string; + driverParam: string; + notNull: false; + hasDefault: false; + isPrimaryKey: false; + isAutoincrement: false; + hasRuntimeDefault: false; + enumValues: [string, ...string[]]; + baseColumn: never; + identity: undefined; + generated: undefined; + }, {}, {}>; + ownerUserId: drizzle_orm_pg_core.PgColumn<{ + name: "owner_user_id"; + tableName: "rsshub"; + dataType: "string"; + columnType: "PgText"; + data: string; + driverParam: string; + notNull: true; + hasDefault: false; + isPrimaryKey: false; + isAutoincrement: false; + hasRuntimeDefault: false; + enumValues: [string, ...string[]]; + baseColumn: never; + identity: undefined; + generated: undefined; + }, {}, {}>; + price: drizzle_orm_pg_core.PgColumn<{ + name: "price"; + tableName: "rsshub"; + dataType: "number"; + columnType: "PgInteger"; + data: number; + driverParam: string | number; + notNull: true; + hasDefault: false; + isPrimaryKey: false; + isAutoincrement: false; + hasRuntimeDefault: false; + enumValues: undefined; + baseColumn: never; + identity: undefined; + generated: undefined; + }, {}, {}>; + description: drizzle_orm_pg_core.PgColumn<{ + name: "description"; + tableName: "rsshub"; + dataType: "string"; + columnType: "PgText"; + data: string; + driverParam: string; + notNull: false; + hasDefault: false; + isPrimaryKey: false; + isAutoincrement: false; + hasRuntimeDefault: false; + enumValues: [string, ...string[]]; + baseColumn: never; + identity: undefined; + generated: undefined; + }, {}, {}>; + userLimit: drizzle_orm_pg_core.PgColumn<{ + name: "user_limit"; + tableName: "rsshub"; + dataType: "number"; + columnType: "PgInteger"; + data: number; + driverParam: string | number; + notNull: false; + hasDefault: false; + isPrimaryKey: false; + isAutoincrement: false; + hasRuntimeDefault: false; + enumValues: undefined; + baseColumn: never; + identity: undefined; + generated: undefined; + }, {}, {}>; + }; + dialect: "pg"; +}>; +declare const rsshubOpenAPISchema: zod.ZodObject<{ + id: zod.ZodString; + baseUrl: zod.ZodString; + accessKey: zod.ZodNullable; + ownerUserId: zod.ZodString; + price: zod.ZodNumber; + description: zod.ZodNullable; + userLimit: zod.ZodNullable; +}, zod.UnknownKeysParam, zod.ZodTypeAny, { + description: string | null; + id: string; + ownerUserId: string; + baseUrl: string; + accessKey: string | null; + price: number; + userLimit: number | null; +}, { + description: string | null; + id: string; + ownerUserId: string; + baseUrl: string; + accessKey: string | null; + price: number; + userLimit: number | null; +}>; +declare const rsshubUsage: drizzle_orm_pg_core.PgTableWithColumns<{ + name: "rsshub_usage"; + schema: undefined; + columns: { + id: drizzle_orm_pg_core.PgColumn<{ + name: "id"; + tableName: "rsshub_usage"; + dataType: "string"; + columnType: "PgText"; + data: string; + driverParam: string; + notNull: true; + hasDefault: true; + isPrimaryKey: true; + isAutoincrement: false; + hasRuntimeDefault: true; + enumValues: [string, ...string[]]; + baseColumn: never; + identity: undefined; + generated: undefined; + }, {}, {}>; + rsshubId: drizzle_orm_pg_core.PgColumn<{ + name: "rsshub_id"; + tableName: "rsshub_usage"; + dataType: "string"; + columnType: "PgText"; + data: string; + driverParam: string; + notNull: true; + hasDefault: false; + isPrimaryKey: false; + isAutoincrement: false; + hasRuntimeDefault: false; + enumValues: [string, ...string[]]; + baseColumn: never; + identity: undefined; + generated: undefined; + }, {}, {}>; + userId: drizzle_orm_pg_core.PgColumn<{ + name: "user_id"; + tableName: "rsshub_usage"; + dataType: "string"; + columnType: "PgText"; + data: string; + driverParam: string; + notNull: true; + hasDefault: false; + isPrimaryKey: false; + isAutoincrement: false; + hasRuntimeDefault: false; + enumValues: [string, ...string[]]; + baseColumn: never; + identity: undefined; + generated: undefined; + }, {}, {}>; + hash: drizzle_orm_pg_core.PgColumn<{ + name: "hash"; + tableName: "rsshub_usage"; + dataType: "string"; + columnType: "PgText"; + data: string; + driverParam: string; + notNull: false; + hasDefault: false; + isPrimaryKey: false; + isAutoincrement: false; + hasRuntimeDefault: false; + enumValues: [string, ...string[]]; + baseColumn: never; + identity: undefined; + generated: undefined; + }, {}, {}>; + expiresAt: drizzle_orm_pg_core.PgColumn<{ + name: "expires_at"; + tableName: "rsshub_usage"; + dataType: "date"; + columnType: "PgTimestamp"; + data: Date; + driverParam: string; + notNull: false; + hasDefault: false; + isPrimaryKey: false; + isAutoincrement: false; + hasRuntimeDefault: false; + enumValues: undefined; + baseColumn: never; + identity: undefined; + generated: undefined; + }, {}, {}>; + }; + dialect: "pg"; +}>; +declare const rsshubUsageOpenAPISchema: zod.ZodObject<{ + id: zod.ZodString; + rsshubId: zod.ZodString; + userId: zod.ZodString; + hash: zod.ZodNullable; + expiresAt: zod.ZodNullable; +}, zod.UnknownKeysParam, zod.ZodTypeAny, { + id: string; + userId: string; + hash: string | null; + rsshubId: string; + expiresAt: string | null; +}, { + id: string; + userId: string; + hash: string | null; + rsshubId: string; + expiresAt: string | null; +}>; +declare const rsshubUsageRelations: drizzle_orm.Relations<"rsshub_usage", { + rsshub: drizzle_orm.One<"rsshub", true>; +}>; + declare const settings: drizzle_orm_pg_core.PgTableWithColumns<{ name: "settings"; schema: undefined; @@ -9208,9 +9475,9 @@ declare const auth: { invitation: { code: string; createdAt: Date | null; - usedAt: Date | null; fromUserId: string; toUserId: string | null; + usedAt: Date | null; } | undefined; role: "user" | "trial"; } | null>; @@ -9376,9 +9643,9 @@ declare const auth: { invitation: { code: string; createdAt: Date | null; - usedAt: Date | null; fromUserId: string; toUserId: string | null; + usedAt: Date | null; } | undefined; role: "user" | "trial"; } | null>; @@ -10810,8 +11077,8 @@ declare const _routes: hono_hono_base.HonoBase | hono_types.MergeSchemaPath<{ "/": { $delete: { @@ -12335,7 +12621,96 @@ declare const _routes: hono_hono_base.HonoBase, "/">; +}, "/probes"> | hono_types.MergeSchemaPath<{ + "/": { + $post: { + input: { + json: { + baseUrl: string; + accessKey?: string | undefined; + }; + }; + output: { + code: 0; + }; + outputFormat: "json"; + status: 200; + }; + }; +} & { + "/list": { + $get: { + input: {}; + output: { + code: 0; + data: { + description: string | null; + id: string; + ownerUserId: string; + price: number; + userLimit: number | null; + userCount: number; + }[]; + }; + outputFormat: "json"; + status: 200; + }; + }; +} & { + "/": { + $delete: { + input: { + json: { + id: string; + }; + }; + output: { + code: 0; + }; + outputFormat: "json"; + status: 200; + }; + }; +} & { + "/use": { + $post: { + input: { + json: { + id: string; + }; + }; + output: { + code: 0; + }; + outputFormat: "json"; + status: 200; + }; + }; +} & { + "/": { + $get: { + input: { + query: { + id: string; + }; + }; + output: { + code: 0; + data: { + description: string | null; + id: string; + ownerUserId: string; + baseUrl: string; + accessKey: string | null; + price: number; + userLimit: number | null; + }; + }; + outputFormat: "json"; + status: 200; + }; + }; +}, "/rsshub">, "/">; type AppType = typeof _routes; -export { type ActionsModel, type AirdropActivity, type AppType, type AttachmentsModel, type AuthSession, type AuthUser, CommonEntryFields, type ConditionItem, type DetailModel, type EntriesModel, type EntryReadHistoriesModel, type ExtraModel, type FeedModel, type MediaModel, type MessagingData, MessagingType, type SettingsModel, account, achievements, achievementsOpenAPISchema, actions, actionsItemOpenAPISchema, actionsOpenAPISchema, actionsRelations, activityEnum, airdrops, airdropsOpenAPISchema, attachmentsZodSchema, authPlugins, boosts, collections, collectionsOpenAPISchema, collectionsRelations, detailModelSchema, entries, entriesOpenAPISchema, entriesRelations, entryReadHistories, entryReadHistoriesOpenAPISchema, entryReadHistoriesRelations, extraZodSchema, feedPowerTokens, feedPowerTokensOpenAPISchema, feedPowerTokensRelations, feeds, feedsOpenAPISchema, feedsRelations, inboxHandleSchema, inboxes, inboxesEntries, inboxesEntriesInsertOpenAPISchema, type inboxesEntriesModel, inboxesEntriesOpenAPISchema, inboxesEntriesRelations, inboxesOpenAPISchema, inboxesRelations, invitations, invitationsOpenAPISchema, invitationsRelations, languageSchema, levels, levelsOpenAPISchema, levelsRelations, lists, listsOpenAPISchema, listsRelations, listsSubscriptions, listsSubscriptionsOpenAPISchema, listsSubscriptionsRelations, listsTimeline, listsTimelineOpenAPISchema, listsTimelineRelations, lower, mediaZodSchema, messaging, messagingOpenAPISchema, messagingRelations, session, settings, subscriptions, subscriptionsOpenAPISchema, subscriptionsRelations, timeline, timelineOpenAPISchema, timelineRelations, transactionType, transactions, transactionsOpenAPISchema, transactionsRelations, user, users, usersOpenApiSchema, usersRelations, verification, wallets, walletsOpenAPISchema, walletsRelations }; +export { type ActionsModel, type AirdropActivity, type AppType, type AttachmentsModel, type AuthSession, type AuthUser, CommonEntryFields, type ConditionItem, type DetailModel, type EntriesModel, type EntryReadHistoriesModel, type ExtraModel, type FeedModel, type MediaModel, type MessagingData, MessagingType, type SettingsModel, account, achievements, achievementsOpenAPISchema, actions, actionsItemOpenAPISchema, actionsOpenAPISchema, actionsRelations, activityEnum, airdrops, airdropsOpenAPISchema, attachmentsZodSchema, authPlugins, boosts, collections, collectionsOpenAPISchema, collectionsRelations, detailModelSchema, entries, entriesOpenAPISchema, entriesRelations, entryReadHistories, entryReadHistoriesOpenAPISchema, entryReadHistoriesRelations, extraZodSchema, feedPowerTokens, feedPowerTokensOpenAPISchema, feedPowerTokensRelations, feeds, feedsOpenAPISchema, feedsRelations, inboxHandleSchema, inboxes, inboxesEntries, inboxesEntriesInsertOpenAPISchema, type inboxesEntriesModel, inboxesEntriesOpenAPISchema, inboxesEntriesRelations, inboxesOpenAPISchema, inboxesRelations, invitations, invitationsOpenAPISchema, invitationsRelations, languageSchema, levels, levelsOpenAPISchema, levelsRelations, lists, listsOpenAPISchema, listsRelations, listsSubscriptions, listsSubscriptionsOpenAPISchema, listsSubscriptionsRelations, listsTimeline, listsTimelineOpenAPISchema, listsTimelineRelations, lower, mediaZodSchema, messaging, messagingOpenAPISchema, messagingRelations, rsshub, rsshubOpenAPISchema, rsshubUsage, rsshubUsageOpenAPISchema, rsshubUsageRelations, session, settings, subscriptions, subscriptionsOpenAPISchema, subscriptionsRelations, timeline, timelineOpenAPISchema, timelineRelations, transactionType, transactions, transactionsOpenAPISchema, transactionsRelations, user, users, usersOpenApiSchema, usersRelations, verification, wallets, walletsOpenAPISchema, walletsRelations };