-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { Route } from '@/types'; | ||
import ofetch from '@/utils/ofetch'; | ||
import { namespace } from './namespace'; | ||
|
||
export const route: Route = { | ||
path: '/', | ||
categories: ['new-media', 'journal'], | ||
example: '/foodtalks', | ||
radar: [ | ||
{ | ||
source: ['www.foodtalks.cn'], | ||
}, | ||
], | ||
name: 'FoodTalks global food information network', | ||
maintainers: ['Geraldxm'], | ||
handler, | ||
url: 'www.foodtalks.cn', | ||
}; | ||
|
||
// handler should return a Data object | ||
async function handler() { | ||
const url = `https://api-we.foodtalks.cn/news/news/page?current=1&size=15&isLatest=1&language=ZH`; | ||
const response = await ofetch(url, { | ||
headers: { | ||
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,zh-TW;q=0.5', | ||
referrer: 'https://www.foodtalks.cn/', | ||
method: 'GET', | ||
mode: 'cors', | ||
credentials: 'omit', | ||
}, | ||
}); | ||
const records = response.data.records; | ||
|
||
// 将records首先转换为简单list | ||
const list = records.map((item) => ({ | ||
title: item.title, | ||
pubDate: new Date(item.publishTime), | ||
link: `https://www.foodtalks.cn/news/${item.id}`, | ||
author: item.sourceName, | ||
id: item.id, | ||
image: item.coverImg, | ||
})); | ||
|
||
// Data | ||
return { | ||
title: namespace.name, | ||
description: namespace.description, | ||
link: namespace.url, | ||
item: list, | ||
}; | ||
} | ||
|
||
/* | ||
record in records: | ||
{ | ||
id: 54596, | ||
title: '好望水照顾系列上新枸杞水;喜茶推 | ||
出补水纤体瓶 | 创新周报', | ||
language: null, | ||
coverImg: 'https://static.foodtalks.cn/image/post/43f2836e88d034c850e85eb10bb78dd5.png', | ||
summary: '我们每周将为您整理献上本周内食 | ||
品行业动态和最值得关注的资讯。', | ||
sourceType: 1, | ||
sourceId: 7632, | ||
sourceName: 'FBIF食品饮料创新', | ||
author: '', | ||
publishTime: '2024-11-25 17:52:01', | ||
parentTagCode: 'exclusives', | ||
tagCode: 'weekly', | ||
seoTitle: '好望水照顾系列上新枸杞水;喜茶 | ||
推出补水纤体瓶 | 创新周报-FoodTalks全球食品资 | ||
讯', | ||
seoKeywords: '好望水,喜茶,补水纤体瓶', | ||
score: null, | ||
status: null | ||
}, | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'FoodTalks全球食品资讯网', | ||
url: 'www.foodtalks.cn', | ||
categories: ['new-media', 'journal'], | ||
lang: 'zh-CN', | ||
description: 'FoodTalks全球食品资讯网是一个提供食品饮料行业新闻、资讯、分析和商业资源的领先在线平台。它涵盖行业趋势、市场动态、产品创新、投融资信息以及企业新闻,连接行业内的专业人士、企业和消费者。', | ||
}; |