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 () => {
const url = "https://kaopucdn.azureedge.net/jsondata/news_list_beta_hans_0.json"
const res: Res = await $fetch(url)
return res
.slice(0, 30)
return res.filter(k => ["财新", "公视"].every(h => k.publisher !== h))
.map((k) => {
return {
id: k.link,

View File

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

View File

@ -36,6 +36,7 @@ export interface PrimitiveMetadata {
export interface OriginSource {
name: string
title?: string
desc?: string
/**
*
*/
@ -45,11 +46,13 @@ export interface OriginSource {
* @default false
*/
disable?: boolean
home: string
home?: string
color?: Color
sub?: Record<string, {
title: string
type?: "hottest" | "realtime"
desc?: string
home?: string
disable?: boolean
interval?: number
}>
@ -60,6 +63,8 @@ export interface Source {
title?: string
type?: "hottest" | "realtime"
color: Color
desc?: string
home?: string
disable?: boolean
interval: number
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="flex gap-2 items-center">
<span
className={clsx("w-8 h-8 rounded-full bg-cover")}
<a
className={clsx("w-8 h-8 rounded-full bg-cover hover:animate-spin")}
href={sources[id].home}
title={sources[id].desc}
style={{
backgroundImage: `url(/icons/${id.split("-")[0]}.png)`,
}}
/>
<span className="flex flex-col">
<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}
</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>}