@@ -18,9 +18,6 @@ import { RecommendationContent } from "~/modules/discover/RecommendationContent"
18
18
import { FeedIcon } from "~/modules/feed/feed-icon"
19
19
import { Queries } from "~/queries"
20
20
21
- type Language = "all" | "eng" | "cmn"
22
- type DiscoverCategories = ( typeof RSSHubCategories ) [ number ] | string
23
-
24
21
const LanguageMap = {
25
22
all : "all" ,
26
23
eng : "en" ,
@@ -29,24 +26,23 @@ const LanguageMap = {
29
26
30
27
type RouteData = Awaited < ReturnType < typeof apiClient . discover . rsshub . $get > > [ "data" ]
31
28
32
- const fetchRsshubPopular = ( category : DiscoverCategories , lang : Language ) => {
33
- return Queries . discover . rsshubCategory ( {
34
- // category: "popular",
35
- categories : category === "all" ? "popular" : `${ category } ` ,
36
- lang : LanguageMap [ lang ] ,
37
- } )
38
- }
39
29
export const Component = ( ) => {
40
30
const { t } = useTranslation ( )
41
31
const lang = useUISettingKey ( "discoverLanguage" )
42
32
const category = useParams ( ) . category as ( typeof RSSHubCategories ) [ number ]
43
33
const title = t ( `discover.category.${ category } ` , { ns : "common" } )
44
34
useSubViewTitle ( title )
45
35
46
- const rsshubPopular = useAuthQuery ( fetchRsshubPopular ( category , lang ) , {
47
- staleTime : 1000 * 60 * 60 * 24 , // 1 day
48
- placeholderData : keepPreviousData ,
49
- } )
36
+ const rsshubPopular = useAuthQuery (
37
+ Queries . discover . rsshubCategory ( {
38
+ categories : category === "all" ? "popular" : `${ category } ` ,
39
+ lang : LanguageMap [ lang ] ,
40
+ } ) ,
41
+ {
42
+ staleTime : 1000 * 60 * 60 * 24 , // 1 day
43
+ placeholderData : keepPreviousData ,
44
+ } ,
45
+ )
50
46
51
47
const data : RouteData = rsshubPopular . data as any
52
48
const { isLoading } = rsshubPopular
@@ -171,6 +167,11 @@ const RecommendationListItem = ({
171
167
}
172
168
} , [ data ] )
173
169
170
+ const rsshubAnalytics = useAuthQuery ( Queries . discover . rsshubAnalytics ( ) , {
171
+ staleTime : 1000 * 60 * 60 * 24 , // 1 day
172
+ placeholderData : keepPreviousData ,
173
+ } )
174
+
174
175
return (
175
176
< Card className = "shadow-background border-border overflow-hidden rounded-lg border transition-shadow duration-200 hover:shadow-md" >
176
177
< div className = "border-border flex items-center gap-3 border-b p-4" >
@@ -194,7 +195,7 @@ const RecommendationListItem = ({
194
195
< Link
195
196
to = { `/discover/category/${ c } ` }
196
197
key = { c }
197
- className = { `bg-accent/10 cursor-pointer rounded-full px-2 py-0.5 duration-200 ${
198
+ className = { `bg-accent/10 flex cursor-pointer items-center rounded-full px-2 py-0.5 duration-200 ${
198
199
! RSSHubCategories . includes ( c ) ? "pointer-events-none opacity-50" : ""
199
200
} `}
200
201
>
@@ -213,10 +214,12 @@ const RecommendationListItem = ({
213
214
if ( Array . isArray ( routeData . path ) ) {
214
215
routeData . path = routeData . path . find ( ( p ) => p === route ) ?? routeData . path [ 0 ]
215
216
}
217
+ const subscriptionCount =
218
+ rsshubAnalytics . data ?. [ `/${ routePrefix } ${ routeData . path } ` ] ?. subscriptionCount
216
219
return (
217
220
< li
218
221
key = { route }
219
- className = "hover:bg-material-opaque -mx-4 flex items-center rounded p-2 px-5 transition-colors"
222
+ className = "hover:bg-material-opaque -mx-4 flex items-center gap-8 rounded p-2 px-5 transition-colors"
220
223
role = "button"
221
224
onClick = { ( ) => {
222
225
present ( {
@@ -232,15 +235,23 @@ const RecommendationListItem = ({
232
235
} )
233
236
} }
234
237
>
235
- < div className = "bg-accent mr-2 size-1.5 rounded-full" />
236
- < div className = "relative h-5 grow" >
237
- < div className = "absolute inset-0 flex items-center gap-2 text-sm" >
238
- < EllipsisHorizontalTextWithTooltip >
239
- { routeData . name }
240
- </ EllipsisHorizontalTextWithTooltip >
241
- < div className = "text-text-secondary shrink-0 text-xs" > { `rsshub://${ routePrefix } ${ routeData . path } ` } </ div >
238
+ < div className = "flex flex-1 items-center gap-2" >
239
+ < div className = "bg-accent mr-2 size-1.5 rounded-full" />
240
+ < div className = "relative h-5 grow" >
241
+ < div className = "absolute inset-0 flex items-center gap-3 text-sm" >
242
+ < EllipsisHorizontalTextWithTooltip >
243
+ { routeData . name }
244
+ </ EllipsisHorizontalTextWithTooltip >
245
+ < EllipsisHorizontalTextWithTooltip className = "text-text-secondary text-xs" > { `rsshub://${ routePrefix } ${ routeData . path } ` } </ EllipsisHorizontalTextWithTooltip >
246
+ </ div >
242
247
</ div >
243
248
</ div >
249
+ { subscriptionCount && (
250
+ < div className = "flex items-center gap-0.5 text-xs" >
251
+ < i className = "i-mgc-fire-cute-re" />
252
+ { subscriptionCount }
253
+ </ div >
254
+ ) }
244
255
</ li >
245
256
)
246
257
} ) }
0 commit comments