Compare commits
2 Commits
99e86b2ff5
...
8869d052a1
| Author | SHA1 | Date |
|---|---|---|
|
|
8869d052a1 | |
|
|
0df78f08bd |
|
|
@ -16,8 +16,14 @@ const NewsItem: React.FC<NewsProps> = ({ title = '', time = '', url = '' }) => {
|
|||
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 className="flex items-center">
|
||||
<div className="w-2 h-2 bg-white rounded-full mr-2"></div>
|
||||
<h3 className="text-lg font-semibold text-white hover:text-blue-600">{title}</h3>
|
||||
</div>
|
||||
|
||||
{/* 时间部分:右侧 */}
|
||||
<p className="text-sm text-white hover:text-blue-600 text-right">{time}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ const NewsItem: React.FC<NewsProps> = ({ title = '', time = '', url = '' }) => {
|
|||
return (
|
||||
<div className="mb-4">
|
||||
<div
|
||||
onClick={() => url && window.open(url)}
|
||||
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>
|
||||
<h3 className="text-lg font-semibold text-gray-800 hover:text-blue-600 transition duration-300 ease-in-out">{title}</h3>
|
||||
<p className="text-sm text-gray-500">{time}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -28,34 +28,55 @@ const NewsList: React.FC = () => {
|
|||
const educationNews = mockNewsData.filter((news) => news.type === "教育");
|
||||
|
||||
return (
|
||||
<div className="bg-gray-100 p-6 rounded-lg shadow-md w-4/5 mx-auto">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
|
||||
<div className="bg-gray-50 p-8 rounded-2xl shadow-xl w-4/5 mx-auto">
|
||||
{/* 使用 Flexbox 将两个列表放在一行 */}
|
||||
<div className="flex gap-8">
|
||||
{/* 科技新闻 */}
|
||||
<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-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-md transition duration-300 ease-in-out">
|
||||
更多科技新闻
|
||||
<div className="flex-1 bg-white rounded-lg shadow-md">
|
||||
{/* 标题栏:独立于列表之外 */}
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<div className="bg-blue-500 text-white px-6 py-3 font-bold text-4xl">
|
||||
科技新闻
|
||||
</div>
|
||||
<button className="text-base text-blue-300 hover:text-blue-400 transition duration-200 pl-6 pr-6">
|
||||
[查看更多]
|
||||
</button>
|
||||
</div>
|
||||
<ul className="space-y-4">
|
||||
|
||||
{/* 新闻列表 */}
|
||||
<ul className="space-y-4 pl-6 pr-6 pb-6">
|
||||
{techNews.map((news) => (
|
||||
<NewsItem key={news.id} title={news.title} time={news.time} url={news.url} />
|
||||
<NewsItem
|
||||
key={news.id}
|
||||
title={news.title}
|
||||
time={news.time}
|
||||
url={news.url} // 确保 mockNewsData 中有 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">
|
||||
更多教育新闻
|
||||
<div className="flex-1 bg-white rounded-lg shadow-md">
|
||||
{/* 标题栏:独立于列表之外 */}
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<div className="bg-blue-500 text-white px-6 py-3 font-bold text-4xl">
|
||||
教育新闻
|
||||
</div>
|
||||
<button className="text-base text-blue-300 hover:text-blue-400 transition duration-200 pl-6 pr-6">
|
||||
[查看更多]
|
||||
</button>
|
||||
</div>
|
||||
<ul className="space-y-4">
|
||||
|
||||
{/* 新闻列表 */}
|
||||
<ul className="space-y-4 pl-6 pr-6 pb-6">
|
||||
{educationNews.map((news) => (
|
||||
<NewsItem key={news.id} title={news.title} time={news.time} url={news.url} />
|
||||
<NewsItem
|
||||
key={news.id}
|
||||
title={news.title}
|
||||
time={news.time}
|
||||
url={news.url} // 确保 mockNewsData 中有 url 字段
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import List from '@/components/list/List';
|
|||
|
||||
export default function GrassrootsDynamics() {
|
||||
return (
|
||||
<div className="flex bg-white rounded-2xl mx-auto w-4/5">
|
||||
<div className="flex rounded-2xl mx-auto w-4/5 h-140 mt-10 p-10">
|
||||
<div className="w-2/5 p-6 flex flex-col items-center justify-center relative">
|
||||
<div >
|
||||
<img
|
||||
|
|
@ -15,7 +15,7 @@ export default function GrassrootsDynamics() {
|
|||
</div>
|
||||
|
||||
{/* 右边列表 */}
|
||||
<div className="w-3/5 text-white p-6">
|
||||
<div className="w-3/5 p-6 flex flex-col bg-[#0e93df] text-white">
|
||||
<List />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue