样式修改

This commit is contained in:
jinsir 2025-11-18 16:20:33 +08:00
parent e73c01dc48
commit 7fbeca06bb
1 changed files with 42 additions and 17 deletions

View File

@ -11,12 +11,13 @@ interface NewsProps {
const NewsItem: React.FC<NewsProps> = ({ title = '', time = '', url = '' }) => { const NewsItem: React.FC<NewsProps> = ({ title = '', time = '', url = '' }) => {
return ( return (
<div> <div className="mb-4">
<div onClick={() => url && window.open(url)} <div
className="flex items-center justify-between hover:text-blue-500 onClick={() => url && window.open(url)}
cursor-pointer w-96"> className="flex items-center justify-between hover:text-blue-600 cursor-pointer transition duration-300 ease-in-out"
<h3 >{title}</h3> >
<p >{time}</p> <h3 className="text-lg font-semibold text-gray-800">{title}</h3>
<p className="text-sm text-gray-500">{time}</p>
</div> </div>
</div> </div>
); );
@ -25,16 +26,40 @@ const NewsItem: React.FC<NewsProps> = ({ title = '', time = '', url = '' }) => {
// 使用新闻数据渲染列表 // 使用新闻数据渲染列表
const NewsList: React.FC = () => { const NewsList: React.FC = () => {
return ( return (
<div> <div className="bg-gray-100 p-6 rounded-lg shadow-md">
<ul className="flex flex-col items-center h-screen"> <div className="grid grid-cols-1 md:grid-cols-2 gap-8">
{mockNewsData.map((news) => ( {/* 科技新闻 */}
<NewsItem title={news.title} time={news.time} url={news.url} /> <div className="bg-white p-6 rounded-lg shadow-sm">
))} <div className="flex items-center justify-between mb-4">
</ul> <p className="text-xl font-bold text-gray-900"></p>
<button className="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-md transition duration-300 ease-in-out">
</button>
</div>
<ul className="space-y-4">
{mockNewsData.map((news, index) => (
<NewsItem key={index} title={news.title} time={news.time} url={news.url} />
))}
</ul>
</div>
{/* 社会新闻 */}
<div className="bg-white p-6 rounded-lg shadow-sm">
<div className="flex items-center justify-between mb-4">
<p className="text-xl font-bold text-gray-900"></p>
<button className="bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded-md transition duration-300 ease-in-out">
</button>
</div>
<ul className="space-y-4">
{mockNewsData.map((news, index) => (
<NewsItem key={index} title={news.title} time={news.time} url={news.url} />
))}
</ul>
</div>
</div>
</div> </div>
); );
}; };
export default NewsList; export default NewsList;