From ecc678a2bbe029f7b05de685954b006968626eff Mon Sep 17 00:00:00 2001 From: Ou Date: Fri, 25 Oct 2024 22:33:35 +0800 Subject: [PATCH] feat: support append desc and home in every source --- server/sources/kaopu.ts | 3 +-- shared/sources.ts | 3 +++ shared/types.ts | 7 ++++++- src/components/column/card.tsx | 11 ++++++++--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/server/sources/kaopu.ts b/server/sources/kaopu.ts index 1032bd1..b134d47 100644 --- a/server/sources/kaopu.ts +++ b/server/sources/kaopu.ts @@ -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, diff --git a/shared/sources.ts b/shared/sources.ts index 6d1b797..bbdd327 100644 --- a/shared/sources.ts +++ b/shared/sources.ts @@ -228,6 +228,7 @@ export const originSources = { "kaopu": { name: "靠谱新闻", color: "gray", + desc: "不一定靠谱,多看多思考", home: "https://kaopu.news/", }, } as const satisfies Record @@ -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, } diff --git a/shared/types.ts b/shared/types.ts index a8d8ae5..3f26acb 100644 --- a/shared/types.ts +++ b/shared/types.ts @@ -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 @@ -60,6 +63,8 @@ export interface Source { title?: string type?: "hottest" | "realtime" color: Color + desc?: string + home?: string disable?: boolean interval: number redirect?: SourceID diff --git a/src/components/column/card.tsx b/src/components/column/card.tsx index 0967973..c8eaa18 100644 --- a/src/components/column/card.tsx +++ b/src/components/column/card.tsx @@ -96,15 +96,20 @@ function NewsCard({ id, inView, handleListeners }: NewsCardProps) { <>
- - + {sources[id].name} {sources[id]?.title && {sources[id].title}}