|
@@ -79,6 +79,46 @@ const FONT_STYLES = {
|
|
|
small: 'font-sans text-xs',
|
|
small: 'font-sans text-xs',
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+// 默认轮播图数据
|
|
|
|
|
+const defaultBanners = [
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 1,
|
|
|
|
|
+ title: '银龄智慧平台',
|
|
|
|
|
+ description: '专为银龄人群打造的智慧服务平台',
|
|
|
|
|
+ image: '/images/banner1.jpg',
|
|
|
|
|
+ fallbackImage: '/images/placeholder-banner.jpg',
|
|
|
|
|
+ link: '/'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 2,
|
|
|
|
|
+ title: '银龄岗位招聘',
|
|
|
|
|
+ description: '发现适合您的银龄岗位机会',
|
|
|
|
|
+ image: '/images/banner2.jpg',
|
|
|
|
|
+ fallbackImage: '/images/placeholder-banner.jpg',
|
|
|
|
|
+ link: '/silver-jobs'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 3,
|
|
|
|
|
+ title: '银龄智库',
|
|
|
|
|
+ description: '分享知识,传承智慧',
|
|
|
|
|
+ image: '/images/banner3.jpg',
|
|
|
|
|
+ fallbackImage: '/images/placeholder-banner.jpg',
|
|
|
|
|
+ link: '/silver-wisdom'
|
|
|
|
|
+ }
|
|
|
|
|
+];
|
|
|
|
|
+
|
|
|
|
|
+// 默认分类图标数据
|
|
|
|
|
+const defaultCategories = [
|
|
|
|
|
+ { name: '银龄岗位', path: '/silver-jobs', image: '/images/category-jobs.png', color: COLORS.accent.blue },
|
|
|
|
|
+ { name: '银龄智库', path: '/silver-wisdom', image: '/images/category-knowledge.png', color: COLORS.accent.green },
|
|
|
|
|
+ { name: '银龄人才', path: '/silver-talents', image: '/images/category-talents.png', color: COLORS.accent.red },
|
|
|
|
|
+ { name: '时间银行', path: '/time-bank', image: '/images/category-timebank.png', color: COLORS.accent.blue },
|
|
|
|
|
+ { name: '老年大学', path: '/elderly-universities', image: '/images/category-university.png', color: COLORS.accent.green },
|
|
|
|
|
+ { name: '政策资讯', path: '/policy-news', image: '/images/category-policy.png', color: COLORS.accent.red },
|
|
|
|
|
+ { name: '企业认证', path: '/company-certification', image: '/images/category-cert.png', color: COLORS.accent.blue },
|
|
|
|
|
+ { name: '个人中心', path: '/profile', image: '/images/category-profile.png', color: COLORS.accent.green }
|
|
|
|
|
+];
|
|
|
|
|
+
|
|
|
// 政策资讯转换工具(已迁移到HomeIcons模块)
|
|
// 政策资讯转换工具(已迁移到HomeIcons模块)
|
|
|
// 轮播图数据现在通过 useHomeIcons 获取
|
|
// 轮播图数据现在通过 useHomeIcons 获取
|
|
|
|
|
|
|
@@ -240,45 +280,12 @@ const NewHomePage: React.FC = () => {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 错误状态处理
|
|
|
|
|
|
|
+ // 错误状态处理 - 改为日志记录而不是中断渲染
|
|
|
if (isError || isIconsError) {
|
|
if (isError || isIconsError) {
|
|
|
- return (
|
|
|
|
|
- <div className="min-h-screen bg-white flex items-center justify-center">
|
|
|
|
|
- <div className="text-center p-8">
|
|
|
|
|
- <h2 className="text-xl font-bold text-gray-800 mb-2">加载失败</h2>
|
|
|
|
|
- <p className="text-gray-600 mb-4">请检查网络连接或重新登录</p>
|
|
|
|
|
- <button
|
|
|
|
|
- onClick={() => window.location.reload()}
|
|
|
|
|
- className="px-4 py-2 bg-blue-600 text-white rounded-full"
|
|
|
|
|
- >
|
|
|
|
|
- 重新加载
|
|
|
|
|
- </button>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ console.error('数据加载错误:', { isError, isIconsError, error });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 未登录状态处理
|
|
|
|
|
- if (!user) {
|
|
|
|
|
- return (
|
|
|
|
|
- <div className="min-h-screen bg-white">
|
|
|
|
|
- <header className="px-4 py-4 bg-white shadow-sm">
|
|
|
|
|
- <div className="flex items-center justify-between mb-3">
|
|
|
|
|
- <HeaderLogo />
|
|
|
|
|
- </div>
|
|
|
|
|
- <div className="text-center py-8">
|
|
|
|
|
- <h2 className="text-lg font-bold mb-4">请先登录</h2>
|
|
|
|
|
- <button
|
|
|
|
|
- onClick={() => navigate('/login')}
|
|
|
|
|
- className="px-6 py-2 bg-blue-600 text-white rounded-full"
|
|
|
|
|
- >
|
|
|
|
|
- 立即登录
|
|
|
|
|
- </button>
|
|
|
|
|
- </div>
|
|
|
|
|
- </header>
|
|
|
|
|
- </div>
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 移除未登录状态的特殊处理,所有用户都可以查看首页内容
|
|
|
|
|
|
|
|
// 数据转换与排序
|
|
// 数据转换与排序
|
|
|
const recommendedJobs = transformJobs(homeData.recommendedJobs || [])
|
|
const recommendedJobs = transformJobs(homeData.recommendedJobs || [])
|
|
@@ -300,24 +307,28 @@ const NewHomePage: React.FC = () => {
|
|
|
|
|
|
|
|
const timeBankActivities = transformTimeBank(homeData.timeBankActivities || []);
|
|
const timeBankActivities = transformTimeBank(homeData.timeBankActivities || []);
|
|
|
|
|
|
|
|
- // 转换轮播图数据(来自HomeIcons管理)
|
|
|
|
|
- const banners = dynamicBanners.map(banner => ({
|
|
|
|
|
- id: banner.id,
|
|
|
|
|
- title: banner.title,
|
|
|
|
|
- description: banner.description || '',
|
|
|
|
|
- image: banner.file?.fullUrl || unsplash.getPlaceholderImage(undefined, banner.id),
|
|
|
|
|
- fallbackImage: '/images/placeholder-banner.jpg',
|
|
|
|
|
- link: banner.linkUrl || '#'
|
|
|
|
|
- }));
|
|
|
|
|
|
|
+ // 转换轮播图数据(来自HomeIcons管理或使用默认数据)
|
|
|
|
|
+ const banners = dynamicBanners.length > 0
|
|
|
|
|
+ ? dynamicBanners.map(banner => ({
|
|
|
|
|
+ id: banner.id,
|
|
|
|
|
+ title: banner.title,
|
|
|
|
|
+ description: banner.description || '',
|
|
|
|
|
+ image: banner.file?.fullUrl || unsplash.getPlaceholderImage(undefined, banner.id),
|
|
|
|
|
+ fallbackImage: '/images/placeholder-banner.jpg',
|
|
|
|
|
+ link: banner.linkUrl || '#'
|
|
|
|
|
+ }))
|
|
|
|
|
+ : defaultBanners;
|
|
|
|
|
|
|
|
- // 转换分类图标数据 - 只使用动态数据
|
|
|
|
|
- const categories = dynamicCategories.map(category => ({
|
|
|
|
|
- name: category.title,
|
|
|
|
|
- icon: BriefcaseIcon, // 默认图标,后续可根据需要扩展
|
|
|
|
|
- path: category.linkUrl || '/',
|
|
|
|
|
- color: COLORS.accent.blue,
|
|
|
|
|
- image: category.file?.fullUrl
|
|
|
|
|
- }));
|
|
|
|
|
|
|
+ // 转换分类图标数据 - 使用动态数据或默认数据
|
|
|
|
|
+ const categories = dynamicCategories.length > 0
|
|
|
|
|
+ ? dynamicCategories.map(category => ({
|
|
|
|
|
+ name: category.title,
|
|
|
|
|
+ icon: BriefcaseIcon, // 默认图标,后续可根据需要扩展
|
|
|
|
|
+ path: category.linkUrl || '/',
|
|
|
|
|
+ color: COLORS.accent.blue,
|
|
|
|
|
+ image: category.file?.fullUrl
|
|
|
|
|
+ }))
|
|
|
|
|
+ : defaultCategories;
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div className="min-h-screen" style={{ backgroundColor: COLORS.ink.light }}>
|
|
<div className="min-h-screen" style={{ backgroundColor: COLORS.ink.light }}>
|