feat: support append desc and home in every source

This commit is contained in:
Ou 2024-10-25 22:33:35 +08:00
parent 392a24c817
commit ecc678a2bb
4 changed files with 18 additions and 6 deletions

View File

@ -9,8 +9,7 @@ type Res = {
export default defineSource(async () => { export default defineSource(async () => {
const url = "https://kaopucdn.azureedge.net/jsondata/news_list_beta_hans_0.json" const url = "https://kaopucdn.azureedge.net/jsondata/news_list_beta_hans_0.json"
const res: Res = await $fetch(url) const res: Res = await $fetch(url)
return res return res.filter(k => ["财新", "公视"].every(h => k.publisher !== h))
.slice(0, 30)
.map((k) => { .map((k) => {
return { return {
id: k.link, id: k.link,

View File

@ -228,6 +228,7 @@ export const originSources = {
"kaopu": { "kaopu": {
name: "靠谱新闻", name: "靠谱新闻",
color: "gray", color: "gray",
desc: "不一定靠谱,多看多思考",
home: "https://kaopu.news/", home: "https://kaopu.news/",
}, },
} as const satisfies Record<string, OriginSource> } as const satisfies Record<string, OriginSource>
@ -241,6 +242,8 @@ function genSources() {
name: source.name, name: source.name,
type: source.type, type: source.type,
disable: source.disable, disable: source.disable,
desc: source.desc,
home: source.home,
color: source.color ?? "primary", color: source.color ?? "primary",
interval: source.interval ?? Time.Default, interval: source.interval ?? Time.Default,
} }

View File

@ -36,6 +36,7 @@ export interface PrimitiveMetadata {
export interface OriginSource { export interface OriginSource {
name: string name: string
title?: string title?: string
desc?: string
/** /**
* *
*/ */
@ -45,11 +46,13 @@ export interface OriginSource {
* @default false * @default false
*/ */
disable?: boolean disable?: boolean
home: string home?: string
color?: Color color?: Color
sub?: Record<string, { sub?: Record<string, {
title: string title: string
type?: "hottest" | "realtime" type?: "hottest" | "realtime"
desc?: string
home?: string
disable?: boolean disable?: boolean
interval?: number interval?: number
}> }>
@ -60,6 +63,8 @@ export interface Source {
title?: string title?: string
type?: "hottest" | "realtime" type?: "hottest" | "realtime"
color: Color color: Color
desc?: string
home?: string
disable?: boolean disable?: boolean
interval: number interval: number
redirect?: SourceID redirect?: SourceID

View File

@ -96,15 +96,20 @@ function NewsCard({ id, inView, handleListeners }: NewsCardProps) {
<> <>
<div className={clsx("flex justify-between mx-2 mt-0 mb-2 items-center")}> <div className={clsx("flex justify-between mx-2 mt-0 mb-2 items-center")}>
<div className="flex gap-2 items-center"> <div className="flex gap-2 items-center">
<span <a
className={clsx("w-8 h-8 rounded-full bg-cover")} className={clsx("w-8 h-8 rounded-full bg-cover hover:animate-spin")}
href={sources[id].home}
title={sources[id].desc}
style={{ style={{
backgroundImage: `url(/icons/${id.split("-")[0]}.png)`, backgroundImage: `url(/icons/${id.split("-")[0]}.png)`,
}} }}
/> />
<span className="flex flex-col"> <span className="flex flex-col">
<span className="flex items-center gap-2"> <span className="flex items-center gap-2">
<span className="text-xl font-bold"> <span
className="text-xl font-bold"
title={sources[id].desc}
>
{sources[id].name} {sources[id].name}
</span> </span>
{sources[id]?.title && <span className={clsx("text-sm", `color-${sources[id].color} bg-base op-80 bg-op-50! px-1 rounded`)}>{sources[id].title}</span>} {sources[id]?.title && <span className={clsx("text-sm", `color-${sources[id].color} bg-base op-80 bg-op-50! px-1 rounded`)}>{sources[id].title}</span>}