2025-11-18 17:36:30 +08:00
|
|
|
import React from 'react';
|
2025-11-19 11:05:18 +08:00
|
|
|
import { grassNewsData } from './NewsData'; // 引入基层新闻数据
|
2025-11-18 17:36:30 +08:00
|
|
|
|
|
|
|
|
interface NewsProps {
|
|
|
|
|
title?: string;
|
|
|
|
|
description?: string;
|
|
|
|
|
time?: string;
|
|
|
|
|
type?: string;
|
|
|
|
|
url?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NewsItem: React.FC<NewsProps> = ({ title = '', time = '', url = '' }) => {
|
|
|
|
|
return (
|
|
|
|
|
<div className="mb-4">
|
|
|
|
|
<div
|
|
|
|
|
onClick={() => url && window.open(url)}
|
|
|
|
|
className="flex items-center justify-between hover:text-blue-600 cursor-pointer transition duration-300 ease-in-out"
|
|
|
|
|
>
|
|
|
|
|
<h3 className="text-lg font-semibold text-gray-800">{title}</h3>
|
|
|
|
|
<p className="text-sm text-gray-500">{time}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-19 11:05:18 +08:00
|
|
|
// 使用基层新闻数据渲染列表
|
2025-11-18 17:36:30 +08:00
|
|
|
const List: React.FC = () => {
|
2025-11-19 11:05:18 +08:00
|
|
|
// 调用 grassNewsData 函数获取基层新闻数据
|
|
|
|
|
const baseNews = grassNewsData();
|
|
|
|
|
|
2025-11-18 17:36:30 +08:00
|
|
|
return (
|
2025-11-19 11:05:18 +08:00
|
|
|
<div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className="p-6">
|
2025-11-18 17:36:30 +08:00
|
|
|
<ul className="space-y-4">
|
2025-11-19 11:05:18 +08:00
|
|
|
{baseNews.map((news) => (
|
|
|
|
|
<NewsItem key={news.id} title={news.title} time={news.time} url={news.url} />
|
2025-11-18 17:36:30 +08:00
|
|
|
))}
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default List;
|