Merge remote-tracking branch 'origin/dev' into feat/beta-public
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -22,6 +22,7 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "~/components/ui/select"
|
||||
import { EllipsisHorizontalTextWithTooltip } from "~/components/ui/typography"
|
||||
import { nextFrame } from "~/lib/dom"
|
||||
import type { FeedViewType } from "~/lib/enum"
|
||||
import {
|
||||
@@ -84,16 +85,28 @@ const FeedDescription = ({ description }: { description?: string }) => {
|
||||
)
|
||||
}
|
||||
|
||||
const routeParamsKeyPrefix = "route-params-"
|
||||
|
||||
export type RouteParams = Record<
|
||||
string,
|
||||
{
|
||||
description: string
|
||||
default?: string
|
||||
}
|
||||
>
|
||||
|
||||
export const DiscoverFeedForm = ({
|
||||
route,
|
||||
routePrefix,
|
||||
noDescription,
|
||||
submitButtonClassName,
|
||||
routeParams,
|
||||
}: {
|
||||
route: RSSHubRoute
|
||||
routePrefix: string
|
||||
noDescription?: boolean
|
||||
submitButtonClassName?: string
|
||||
routeParams?: RouteParams
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const keys = useMemo(
|
||||
@@ -121,13 +134,22 @@ export const DiscoverFeedForm = ({
|
||||
() =>
|
||||
z.object({
|
||||
...Object.fromEntries(
|
||||
keys.map((keyItem) => [
|
||||
keyItem.name,
|
||||
keyItem.optional ? z.string().optional().nullable() : z.string().min(1),
|
||||
]),
|
||||
keys
|
||||
.map((keyItem) => [
|
||||
keyItem.name,
|
||||
keyItem.optional ? z.string().optional().nullable() : z.string().min(1),
|
||||
])
|
||||
.concat(
|
||||
routeParams
|
||||
? Object.entries(routeParams).map(([key]) => [
|
||||
`${routeParamsKeyPrefix}${key}`,
|
||||
z.string(),
|
||||
])
|
||||
: [],
|
||||
),
|
||||
),
|
||||
}),
|
||||
[keys],
|
||||
[keys, routeParams],
|
||||
)
|
||||
|
||||
const defaultValue = useMemo(() => {
|
||||
@@ -150,10 +172,30 @@ export const DiscoverFeedForm = ({
|
||||
const { present, dismissAll } = useModalStack()
|
||||
|
||||
const onSubmit = useCallback(
|
||||
(data: Record<string, string>) => {
|
||||
(_data: Record<string, string>) => {
|
||||
const data = Object.fromEntries(
|
||||
Object.entries(_data).filter(([key]) => !key.startsWith(routeParamsKeyPrefix)),
|
||||
)
|
||||
|
||||
try {
|
||||
const fillRegexpPath = regexpPathToPath(route.path, data)
|
||||
const routeParamsPath = encodeURIComponent(
|
||||
Object.entries(_data)
|
||||
.filter(([key, value]) => key.startsWith(routeParamsKeyPrefix) && value)
|
||||
.map(([key, value]) => [key.slice(routeParamsKeyPrefix.length), value])
|
||||
.map(([key, value]) => `${key}=${value}`)
|
||||
.join("&"),
|
||||
)
|
||||
|
||||
const fillRegexpPath = regexpPathToPath(
|
||||
routeParams && routeParamsPath
|
||||
? route.path.slice(0, route.path.indexOf("/:routeParams"))
|
||||
: route.path,
|
||||
data,
|
||||
)
|
||||
const url = `rsshub://${routePrefix}${fillRegexpPath}`
|
||||
|
||||
const finalUrl = routeParams && routeParamsPath ? `${url}/${routeParamsPath}` : url
|
||||
|
||||
const defaultView = getViewFromRoute(route) || (getSidebarActiveView() as FeedViewType)
|
||||
|
||||
present({
|
||||
@@ -161,7 +203,7 @@ export const DiscoverFeedForm = ({
|
||||
content: () => (
|
||||
<FeedForm
|
||||
asWidget
|
||||
url={url}
|
||||
url={finalUrl}
|
||||
defaultValues={{
|
||||
view: defaultView.toString(),
|
||||
}}
|
||||
@@ -180,7 +222,7 @@ export const DiscoverFeedForm = ({
|
||||
}
|
||||
}
|
||||
},
|
||||
[dismissAll, form, keys, present, route.path, routePrefix],
|
||||
[dismissAll, form, keys, present, route, routeParams, routePrefix],
|
||||
)
|
||||
|
||||
const formElRef = useRef<HTMLFormElement>(null)
|
||||
@@ -259,6 +301,26 @@ export const DiscoverFeedForm = ({
|
||||
</FormItem>
|
||||
)
|
||||
})}
|
||||
{routeParams && (
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
{Object.entries(routeParams).map(([key, value]) => (
|
||||
<FormItem key={`${routeParamsKeyPrefix}${key}`} className="flex flex-col space-y-2">
|
||||
<FormLabel className="capitalize">{key}</FormLabel>
|
||||
<Input
|
||||
{...form.register(`${routeParamsKeyPrefix}${key}`)}
|
||||
placeholder={value.default}
|
||||
/>
|
||||
{!!value.description && (
|
||||
<EllipsisHorizontalTextWithTooltip>
|
||||
<Markdown className="text-xs text-theme-foreground/50">
|
||||
{value.description}
|
||||
</Markdown>
|
||||
</EllipsisHorizontalTextWithTooltip>
|
||||
)}
|
||||
</FormItem>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{!noDescription && (
|
||||
<>
|
||||
<FeedDescription description={route.description} />
|
||||
|
||||
@@ -244,7 +244,7 @@ const FeedInnerForm = ({
|
||||
|
||||
onSuccess?.()
|
||||
},
|
||||
async onError(err) {
|
||||
onError(err) {
|
||||
toastFetchError(err)
|
||||
},
|
||||
})
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import { LoadingCircle } from "~/components/ui/loading"
|
||||
import { useAuthQuery } from "~/hooks/common"
|
||||
import { Queries } from "~/queries"
|
||||
|
||||
import type { RouteParams } from "./DiscoverFeedForm"
|
||||
import { DiscoverFeedForm } from "./DiscoverFeedForm"
|
||||
|
||||
const transformRouteParams: RouteParams = {
|
||||
title: { description: "The title of the RSS", default: "Extract from <title>" },
|
||||
item: { description: "The HTML elements as item using CSS selector", default: "html" },
|
||||
itemTitle: {
|
||||
description: "The HTML elements as title in item using CSS selector",
|
||||
default: "item element",
|
||||
},
|
||||
itemTitleAttr: {
|
||||
description: "The attributes of title element as title",
|
||||
default: "Element text",
|
||||
},
|
||||
itemLink: {
|
||||
description: "The HTML elements as link in item using CSS selector",
|
||||
default: "item element",
|
||||
},
|
||||
itemLinkAttr: { description: "The attributes of link element as link", default: "href" },
|
||||
itemDesc: {
|
||||
description: "The HTML elements as description in item using CSS selector",
|
||||
default: "item element",
|
||||
},
|
||||
itemDescAttr: {
|
||||
description: "The attributes of description element as description",
|
||||
default: "Element html",
|
||||
},
|
||||
itemPubDate: {
|
||||
description: "The HTML elements as pubDate in item using CSS selector",
|
||||
default: "item element",
|
||||
},
|
||||
itemPubDateAttr: {
|
||||
description: "The attributes of pubDate element as pubDate",
|
||||
default: "Element html",
|
||||
},
|
||||
}
|
||||
|
||||
export function DiscoverTransform() {
|
||||
const { data, isLoading } = useAuthQuery(
|
||||
Queries.discover.rsshubNamespace({
|
||||
namespace: "rsshub",
|
||||
}),
|
||||
{
|
||||
meta: {
|
||||
persist: true,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="center mt-12 flex w-full flex-col gap-8">
|
||||
<LoadingCircle size="large" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{data?.rsshub.routes && (
|
||||
<div className="w-[512px]">
|
||||
<DiscoverFeedForm
|
||||
routePrefix="rsshub"
|
||||
route={data?.rsshub.routes["/transform/html/:url/:routeParams"]}
|
||||
routeParams={transformRouteParams}
|
||||
noDescription
|
||||
submitButtonClassName="justify-center"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import { useOnClickOutside } from "usehooks-ts"
|
||||
import { ActionButton, Button, IconButton } from "~/components/ui/button"
|
||||
import { Kbd, KbdCombined } from "~/components/ui/kbd/Kbd"
|
||||
import { RootPortal } from "~/components/ui/portal"
|
||||
import { ElECTRON_CUSTOM_TITLEBAR_HEIGHT, HotKeyScopeMap } from "~/constants"
|
||||
import { ElECTRON_CUSTOM_TITLEBAR_HEIGHT, HotKeyScopeMap, isElectronBuild } from "~/constants"
|
||||
import { shortcuts } from "~/constants/shortcuts"
|
||||
import { useI18n } from "~/hooks/common"
|
||||
import { cn, getOS } from "~/lib/utils"
|
||||
@@ -51,7 +51,9 @@ export const MarkAllReadWithOverlay = forwardRef<
|
||||
<m.div
|
||||
ref={setPopoverRef}
|
||||
initial={{ y: -70 }}
|
||||
animate={{ y: getOS() === "Windows" ? -ElECTRON_CUSTOM_TITLEBAR_HEIGHT : 0 }}
|
||||
animate={{
|
||||
y: isElectronBuild && getOS() === "Windows" ? -ElECTRON_CUSTOM_TITLEBAR_HEIGHT : 0,
|
||||
}}
|
||||
exit={{ y: -70 }}
|
||||
transition={{ type: "spring", damping: 20, stiffness: 300 }}
|
||||
className="shadow-modal absolute z-50 bg-theme-modal-background-opaque shadow"
|
||||
|
||||
@@ -261,7 +261,9 @@ const WideModeButton = () => {
|
||||
: t("entry_list_header.switch_to_normalmode")
|
||||
}
|
||||
>
|
||||
<i className={cn(!isWideMode ? "i-mgc-align-justify-cute-re" : "i-mgc-layout-4-cute-re")} />
|
||||
<i
|
||||
className={cn(isWideMode ? "i-mgc-align-justify-cute-re" : "i-mgc-align-left-cute-re")}
|
||||
/>
|
||||
</ActionButton>
|
||||
</ImpressionView>
|
||||
)
|
||||
|
||||
@@ -14,12 +14,12 @@ export const EntryPlaceholderLogo = () => {
|
||||
<div
|
||||
onContextMenu={stopPropagation}
|
||||
className={cn(
|
||||
"flex w-full min-w-0 flex-col items-center justify-center gap-1 text-balance px-12 pb-6 text-center text-lg font-medium text-zinc-400 duration-500",
|
||||
"flex w-full min-w-0 flex-col items-center justify-center gap-1 px-12 pb-6 text-center text-lg font-medium text-zinc-400 duration-500",
|
||||
!logoShow && "translate-y-[-50px] opacity-0",
|
||||
)}
|
||||
>
|
||||
<Logo className="size-16 opacity-40 grayscale" />
|
||||
<span className="max-w-[60ch]">{title}</span>
|
||||
<div className="line-clamp-3 w-[60ch] max-w-full">{title}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,11 @@ import { showNativeMenu } from "~/lib/native-menu"
|
||||
import { cn, sortByAlphabet } from "~/lib/utils"
|
||||
import { getPreferredTitle, useAddFeedToFeedList, useFeedStore } from "~/store/feed"
|
||||
import { useOwnedList } from "~/store/list"
|
||||
import { subscriptionActions, useSubscriptionByFeedId } from "~/store/subscription"
|
||||
import {
|
||||
subscriptionActions,
|
||||
subscriptionCategoryExist,
|
||||
useSubscriptionByFeedId,
|
||||
} from "~/store/subscription"
|
||||
import { useFeedUnreadStore } from "~/store/unread"
|
||||
|
||||
import { useModalStack } from "../../components/ui/modal/stacked/hooks"
|
||||
@@ -219,7 +223,8 @@ function FeedCategoryImpl({ data: ids, view, categoryOpenStateData }: FeedCatego
|
||||
{
|
||||
type: "text",
|
||||
label: t("sidebar.feed_column.context_menu.delete_category"),
|
||||
click: async () => {
|
||||
hide: !folderName || !subscriptionCategoryExist(folderName),
|
||||
click: () => {
|
||||
present({
|
||||
title: t("sidebar.feed_column.context_menu.delete_category_confirmation", {
|
||||
folderName,
|
||||
|
||||
@@ -139,6 +139,7 @@ function FeedListImpl({ className, view }: { className?: string; view: number })
|
||||
className="font-bold"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
if (!document.hasFocus()) return
|
||||
if (view !== undefined) {
|
||||
navigateEntry({
|
||||
entryId: null,
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react
|
||||
import { useDebounceCallback, useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { softSpringPreset } from "~/components/ui/constants/spring"
|
||||
import { RootPortal } from "~/components/ui/portal"
|
||||
import { useInputComposition, useRefValue } from "~/hooks/common"
|
||||
import { tipcClient } from "~/lib/client"
|
||||
import { nextFrame } from "~/lib/dom"
|
||||
@@ -117,7 +118,7 @@ const CmdFImpl: FC<{
|
||||
e.preventDefault()
|
||||
nativeSearch(value)
|
||||
}}
|
||||
className="center shadow-perfect fixed right-8 top-12 z-[1000] size-9 w-64 gap-2 rounded-2xl border bg-zinc-50/90 pl-3 pr-2 backdrop-blur duration-200 focus-within:border-accent dark:bg-neutral-800/80"
|
||||
className="center shadow-perfect fixed right-8 top-12 size-9 w-64 gap-2 rounded-2xl border bg-zinc-50/90 pl-3 pr-2 backdrop-blur duration-200 focus-within:border-accent dark:bg-neutral-800/80"
|
||||
>
|
||||
<div className="relative h-full grow">
|
||||
<input
|
||||
@@ -238,22 +239,24 @@ export const CmdF = () => {
|
||||
setShow(true)
|
||||
})
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{show && (
|
||||
<m.div
|
||||
className="relative z-[1000]"
|
||||
initial={{ opacity: 0.8, y: -150 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
exit={{ opacity: 0, y: -150 }}
|
||||
transition={softSpringPreset}
|
||||
>
|
||||
<CmdFImpl
|
||||
onClose={() => {
|
||||
setShow(false)
|
||||
}}
|
||||
/>
|
||||
</m.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
<RootPortal>
|
||||
<AnimatePresence>
|
||||
{show && (
|
||||
<m.div
|
||||
className="fixed top-0 w-full"
|
||||
initial={{ opacity: 0.8, y: -150 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
exit={{ opacity: 0, y: -150 }}
|
||||
transition={softSpringPreset}
|
||||
>
|
||||
<CmdFImpl
|
||||
onClose={() => {
|
||||
setShow(false)
|
||||
}}
|
||||
/>
|
||||
</m.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</RootPortal>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ export const TransactionsSection: Component = ({ className }) => {
|
||||
</Tabs>
|
||||
<div className={cn("w-fit min-w-0 grow overflow-x-auto", className)}>
|
||||
<Table className="w-full table-fixed">
|
||||
<TableHeader className="sticky top-0 z-10 bg-theme-background">
|
||||
<TableHeader className="sticky top-0 bg-theme-background">
|
||||
<TableRow className="[&_*]:!pl-0 [&_*]:!font-semibold">
|
||||
<TableHead>{t("wallet.transactions.type")}</TableHead>
|
||||
<TableHead>{t("wallet.transactions.amount")}</TableHead>
|
||||
|
||||
@@ -397,7 +397,7 @@ const SubscriptionItem: FC<{
|
||||
!isLoose && "flex items-center",
|
||||
)}
|
||||
>
|
||||
<div className="truncate font-medium leading-none">{subscription.feeds?.title}</div>
|
||||
<div className="truncate font-medium leading-tight">{subscription.feeds?.title}</div>
|
||||
{isLoose && (
|
||||
<div className="mt-1 line-clamp-1 text-xs text-zinc-500">
|
||||
{subscription.feeds?.description}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { from } from "dnum"
|
||||
import type { FC } from "react"
|
||||
import { useState } from "react"
|
||||
import { useNavigate } from "react-router-dom"
|
||||
|
||||
import { Button } from "~/components/ui/button"
|
||||
import { Divider } from "~/components/ui/divider"
|
||||
@@ -14,7 +15,6 @@ import { UserAvatar } from "~/modules/user/UserAvatar"
|
||||
import { useWallet, useWalletTipMutation } from "~/queries/wallet"
|
||||
|
||||
import { useFeedClaimModal } from "../claim"
|
||||
import { useSettingModal } from "../settings/modal/hooks-hack"
|
||||
import { Balance } from "./balance"
|
||||
|
||||
const DEFAULT_RECOMMENDED_TIP = 10
|
||||
@@ -65,12 +65,12 @@ const TipModalContent_: FC<{
|
||||
|
||||
const { dismiss } = useCurrentModal()
|
||||
|
||||
const settingModalPresent = useSettingModal()
|
||||
|
||||
const claimFeed = useFeedClaimModal({
|
||||
feedId,
|
||||
})
|
||||
|
||||
const navigate = useNavigate()
|
||||
|
||||
if (myWallet.isPending) {
|
||||
return <Loading />
|
||||
}
|
||||
@@ -80,7 +80,7 @@ const TipModalContent_: FC<{
|
||||
<div className="flex w-[80vw] max-w-[350px] flex-col gap-5">
|
||||
<p className="text-sm text-theme-foreground/80">{t("tip_modal.no_wallet")}</p>
|
||||
<div className="flex justify-end">
|
||||
<Button variant="primary" onClick={() => nextFrame(() => settingModalPresent("wallet"))}>
|
||||
<Button variant="primary" onClick={() => nextFrame(() => navigate("/power"))}>
|
||||
{t("tip_modal.create_wallet")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user