|
|
@@ -119,16 +119,39 @@ const PolicyNewsDetailPage: React.FC = () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- const images = news.images ? [news.images] : [];
|
|
|
+ // 获取政策资讯的图片列表
|
|
|
+ const getImages = () => {
|
|
|
+ const images: string[] = [];
|
|
|
+
|
|
|
+ // 优先使用关联的文件
|
|
|
+ if (news.files && news.files.length > 0) {
|
|
|
+ news.files.forEach(file => {
|
|
|
+ // 只添加图片类型的文件
|
|
|
+ if (file.type && file.type.startsWith('image/')) {
|
|
|
+ images.push(file.fullUrl);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果没有关联的图片文件,使用旧的 images 字段
|
|
|
+ if (images.length === 0 && news.images) {
|
|
|
+ const legacyImages = news.images.split(',').map(img => img.trim()).filter(img => img);
|
|
|
+ images.push(...legacyImages);
|
|
|
+ }
|
|
|
+
|
|
|
+ return images;
|
|
|
+ };
|
|
|
+
|
|
|
+ const images = getImages();
|
|
|
|
|
|
return (
|
|
|
<div className="min-h-screen pb-16" style={{ backgroundColor: COLORS.ink.light }}>
|
|
|
{/* 头部导航 */}
|
|
|
- <header
|
|
|
+ <header
|
|
|
className="sticky top-0 z-10 shadow-sm border-b border-opacity-20"
|
|
|
- style={{
|
|
|
+ style={{
|
|
|
backgroundColor: COLORS.ink.light,
|
|
|
- borderColor: COLORS.ink.medium
|
|
|
+ borderColor: COLORS.ink.medium
|
|
|
}}
|
|
|
>
|
|
|
<div className="px-4 py-4 flex items-center justify-between">
|
|
|
@@ -190,7 +213,7 @@ const PolicyNewsDetailPage: React.FC = () => {
|
|
|
<span>{news.viewCount} 阅读</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <span
|
|
|
+ <span
|
|
|
className="px-3 py-1 rounded-full text-xs"
|
|
|
style={{
|
|
|
backgroundColor: COLORS.accent.blue,
|
|
|
@@ -204,18 +227,31 @@ const PolicyNewsDetailPage: React.FC = () => {
|
|
|
|
|
|
{/* 图片展示 */}
|
|
|
{images.length > 0 && (
|
|
|
- <div className="grid grid-cols-1 gap-4">
|
|
|
- {images.map((image, index) => (
|
|
|
+ <div className="space-y-4">
|
|
|
+ {images.length === 1 ? (
|
|
|
<img
|
|
|
- key={index}
|
|
|
- src={image.trim()}
|
|
|
- alt={`政策资讯图片 ${index + 1}`}
|
|
|
+ src={images[0]}
|
|
|
+ alt={`政策资讯图片`}
|
|
|
className="w-full h-64 object-cover rounded-xl"
|
|
|
onError={(e) => {
|
|
|
(e.target as HTMLImageElement).src = '/images/placeholder-banner.jpg';
|
|
|
}}
|
|
|
/>
|
|
|
- ))}
|
|
|
+ ) : (
|
|
|
+ <div className="grid grid-cols-2 gap-3">
|
|
|
+ {images.slice(0, 4).map((image, index) => (
|
|
|
+ <img
|
|
|
+ key={index}
|
|
|
+ src={image}
|
|
|
+ alt={`政策资讯图片 ${index + 1}`}
|
|
|
+ className={`w-full object-cover rounded-lg ${images.length === 3 && index === 0 ? 'col-span-2 h-48' : 'h-32'}`}
|
|
|
+ onError={(e) => {
|
|
|
+ (e.target as HTMLImageElement).src = '/images/placeholder-banner.jpg';
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
</div>
|
|
|
)}
|
|
|
|