+ export type WechatArticle = {
+ id: string;
+ title: string;
+ author: string;
+ authorAvatar: string;
+ coverImage: string;
+ summary: string;
+ publishDate: string;
+ readCount: number;
+ likeCount: number;
+ url: string;
+ category: string;
+ tags: string[];
+ isBookmarked: boolean;
+ };
+
+ export type ArticleCategory = {
+ id: string;
+ name: string;
+ color: string;
+ icon: string;
+ articleCount: number;
+ };
+
+ export const articleCategories: ArticleCategory[] = [
+ {
+ id: 'tech',
+ name: '技术',
+ color: '#3B82F6',
+ icon: 'code-slash',
+ articleCount: 12,
+ },
+ {
+ id: 'business',
+ name: '商业',
+ color: '#10B981',
+ icon: 'business',
+ articleCount: 8,
+ },
+ {
+ id: 'lifestyle',
+ name: '生活',
+ color: '#F59E0B',
+ icon: 'heart',
+ articleCount: 15,
+ },
+ {
+ id: 'education',
+ name: '教育',
+ color: '#8B5CF6',
+ icon: 'school',
+ articleCount: 6,
+ },
+ {
+ id: 'entertainment',
+ name: '娱乐',
+ color: '#EF4444',
+ icon: 'play',
+ articleCount: 10,
+ },
+ ];
+
+ export const wechatArticles: WechatArticle[] = [
+ {
+ id: '1',
+ title: 'AI技术在企业数字化转型中的应用实践',
+ author: '安迪老师',
+ authorAvatar: '/img/andy.jpg',
+ coverImage: '/img/c1.avif',
+ summary: '本文详细介绍了AI技术如何助力企业实现数字化转型,包括具体的技术方案和实施案例...',
+ publishDate: '2024-01-15',
+ readCount: 12580,
+ likeCount: 856,
+ url: 'https://example.com/article1',
+ category: 'tech',
+ tags: ['AI', '数字化转型', '企业服务'],
+ isBookmarked: true,
+ },
+ {
+ id: '2',
+ title: '2024年移动互联网发展趋势分析',
+ author: '科技前沿',
+ authorAvatar: '/img/nathan.jpg',
+ coverImage: '/img/c2.avif',
+ summary: '深度分析2024年移动互联网的发展趋势,包括新技术、新应用和新商业模式...',
+ publishDate: '2024-01-12',
+ readCount: 8920,
+ likeCount: 623,
+ url: 'https://example.com/article2',
+ category: 'tech',
+ tags: ['移动互联网', '趋势分析', '技术发展'],
+ isBookmarked: false,
+ },
+ {
+ id: '3',
+ title: '创业公司如何打造高效团队文化',
+ author: '创业邦',
+ authorAvatar: '/img/leo.jpg',
+ coverImage: '/img/c3.avif',
+ summary: '分享创业公司在团队建设方面的经验和教训,如何建立积极向上的企业文化...',
+ publishDate: '2024-01-10',
+ readCount: 15670,
+ likeCount: 1023,
+ url: 'https://example.com/article3',
+ category: 'business',
+ tags: ['创业', '团队管理', '企业文化'],
+ isBookmarked: true,
+ },
+ {
+ id: '4',
+ title: '健康生活方式:从饮食到运动的全面指南',
+ author: '健康生活',
+ authorAvatar: '/img/max.jpg',
+ coverImage: '/img/c1.avif',
+ summary: '提供全面的健康生活指南,包括营养搭配、运动计划和心理健康建议...',
+ publishDate: '2024-01-08',
+ readCount: 20340,
+ likeCount: 1456,
+ url: 'https://example.com/article4',
+ category: 'lifestyle',
+ tags: ['健康', '生活方式', '营养'],
+ isBookmarked: false,
+ },
+ {
+ id: '5',
+ title: '在线教育平台的用户体验设计',
+ author: '设计思维',
+ authorAvatar: '/img/nathan.jpg',
+ coverImage: '/img/c2.avif',
+ summary: '探讨在线教育平台如何通过优秀的用户体验设计提升学习效果和用户满意度...',
+ publishDate: '2024-01-05',
+ readCount: 9870,
+ likeCount: 567,
+ url: 'https://example.com/article5',
+ category: 'education',
+ tags: ['在线教育', '用户体验', '产品设计'],
+ isBookmarked: true,
+ },
+ {
+ id: '6',
+ title: '2024年最值得关注的科技电影',
+ author: '电影评论',
+ authorAvatar: '/img/leo.jpg',
+ coverImage: '/img/c3.avif',
+ summary: '盘点2024年即将上映的科技主题电影,分析其技术表现和艺术价值...',
+ publishDate: '2024-01-03',
+ readCount: 13450,
+ likeCount: 789,
+ url: 'https://example.com/article6',
+ category: 'entertainment',
+ tags: ['电影', '科技', '娱乐'],
+ isBookmarked: false,
+ },
+ ];
+
export type HomeItem = {
id: number;
diff Copy code
- import Image from 'next/image';
- import Card from '../ui/Card';
-
+ import React, { useState } from 'react';
import {
- IonPage,
+ IonContent,
IonHeader,
+ IonPage,
+ IonTitle,
IonToolbar,
- IonTitle,
- IonButtons,
+ IonSearchbar,
+ IonChip,
+ IonIcon,
IonButton,
- IonIcon,
- IonContent,
- IonMenuButton,
+ IonRefresher,
+ IonRefresherContent,
+ IonInfiniteScroll,
+ IonInfiniteScrollContent,
+ IonSpinner,
+ IonBadge,
} from '@ionic/react';
- import Notifications from './Notifications';
- import { useState } from 'react';
- import { notificationsOutline } from 'ionicons/icons';
- import { selectHomeItems } from '../../store/selectors';
- import Store from '../../store';
-
- type FeedCardProps = {
- title: string;
- type: string;
- text: string;
- author: string;
- authorAvatar: string;
- image: string;
- };
-
- const FeedCard = ({
- title,
- type,
- text,
- author,
- authorAvatar,
- image,
- }: FeedCardProps) => (
- <Card className="my-4 mx-auto">
- <div className="h-32 w-full relative">
- <Image
- className="rounded-t-xl object-cover min-w-full min-h-full max-w-full max-h-full"
- src={image}
- alt=""
- fill
- />
- </div>
- <div className="px-4 py-4 bg-white rounded-b-xl dark:bg-gray-900">
- <h4 className="font-bold py-0 text-s text-gray-400 dark:text-gray-500 uppercase">
- {type}
- </h4>
- <h2 className="font-bold text-2xl text-gray-800 dark:text-gray-100">
- {title}
- </h2>
- <p className="sm:text-sm text-s text-gray-500 mr-1 my-3 dark:text-gray-400">
- {text}
- </p>
- <div className="flex items-center space-x-4">
- <div className="w-10 h-10 relative">
- <Image
- src={authorAvatar}
- className="rounded-full object-cover min-w-full min-h-full max-w-full max-h-full"
- alt=""
- fill
- />
- </div>
- <h3 className="text-gray-500 dark:text-gray-200 m-l-8 text-sm font-medium">
- {author}
- </h3>
- </div>
- </div>
- </Card>
- );
-
- const Feed = () => {
- const homeItems = Store.useState(selectHomeItems);
- const [showNotifications, setShowNotifications] = useState(false);
+ import {
+ bookmark,
+ bookmarkOutline,
+ shareOutline,
+ timeOutline,
+ eyeOutline,
+ heartOutline,
+ filterOutline,
+ } from 'ionicons/icons';
+ import { useFilteredArticles, useCategories, useSelectedCategory } from '../../store/selectors';
+ import { setSearchQuery, setSelectedCategory, toggleBookmark } from '../../store/actions';
+ import { WechatArticle } from '../../mock';
+
+ const Feed: React.FC = () => {
+ const articles = useFilteredArticles();
+ const categories = useCategories();
+ const selectedCategory = useSelectedCategory();
+ const [showFilters, setShowFilters] = useState(false);
+
+ const handleRefresh = (event: CustomEvent) => {
+ setTimeout(() => {
+ event.detail.complete();
+ }, 2000);
+ };
+
+ const handleLoadMore = (event: CustomEvent) => {
+ setTimeout(() => {
+ event.detail.complete();
+ }, 1000);
+ };
+
+ const formatDate = (dateString: string) => {
+ const date = new Date(dateString);
+ const now = new Date();
+ const diffTime = Math.abs(now.getTime() - date.getTime());
+ const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
+
+ if (diffDays === 1) return '昨天';
+ if (diffDays < 7) return `${diffDays}天前`;
+ if (diffDays < 30) return `${Math.floor(diffDays / 7)}周前`;
+ return date.toLocaleDateString('zh-CN');
+ };
+
+ const formatNumber = (num: number) => {
+ if (num >= 10000) {
+ return (num / 10000).toFixed(1) + '万';
+ }
+ return num.toString();
+ };
return (
<IonPage>
<IonHeader>
<IonToolbar>
- <IonTitle>Feed</IonTitle>
- <IonButtons slot="start">
- <IonMenuButton />
- </IonButtons>
- <IonButtons slot="end">
- <IonButton onClick={() => setShowNotifications(true)}>
- <IonIcon icon={notificationsOutline} />
- </IonButton>
- </IonButtons>
+ <IonTitle>文章收藏</IonTitle>
+ <IonButton
+ slot="end"
+ fill="clear"
+ onClick={() => setShowFilters(!showFilters)}
+ >
+ <IonIcon icon={filterOutline} />
+ </IonButton>
+ </IonToolbar>
+
+ <IonToolbar>
+ <IonSearchbar
+ placeholder="搜索文章、作者或标签..."
+ onIonInput={(e) => setSearchQuery(e.detail.value || '')}
+ debounce={300}
+ />
</IonToolbar>
- </IonHeader>
- <IonContent className="ion-padding" fullscreen>
- <IonHeader collapse="condense">
+
+ {showFilters && (
<IonToolbar>
- <IonTitle size="large">Feed</IonTitle>
+ <div className="px-4 py-2 flex gap-2 overflow-x-auto">
+ <IonChip
+ color={selectedCategory === null ? 'primary' : 'medium'}
+ onClick={() => setSelectedCategory(null)}
+ >
+ 全部
+ </IonChip>
+ {categories.map((category) => (
+ <IonChip
+ key={category.id}
+ color={selectedCategory === category.id ? 'primary' : 'medium'}
+ onClick={() => setSelectedCategory(category.id)}
+ style={{ '--background': category.color }}
+ >
+ <IonIcon icon={category.icon as any} />
+ {category.name}
+ <IonBadge color="light">{category.articleCount}</IonBadge>
+ </IonChip>
+ ))}
+ </div>
</IonToolbar>
- </IonHeader>
- <Notifications
- open={showNotifications}
- onDidDismiss={() => setShowNotifications(false)}
- />
- {homeItems.map((i, index) => (
- <FeedCard {...i} key={index} />
- ))}
+ )}
+ </IonHeader>
+
+ <IonContent>
+ <IonRefresher slot="fixed" onIonRefresh={handleRefresh}>
+ <IonRefresherContent />
+ </IonRefresher>
+
+ <div className="p-4 space-y-4">
+ {articles.map((article: WechatArticle) => (
+ <div
+ key={article.id}
+ className="bg-white rounded-lg shadow-sm border border-gray-100 overflow-hidden"
+ >
+ <div className="flex">
+ <div className="flex-1 p-4">
+ <div className="flex items-start justify-between mb-2">
+ <h3 className="font-semibold text-gray-900 line-clamp-2">
+ {article.title}
+ </h3>
+ <IonButton
+ fill="clear"
+ size="small"
+ onClick={() => toggleBookmark(article.id)}
+ >
+ <IonIcon
+ icon={article.isBookmarked ? bookmark : bookmarkOutline}
+ color={article.isBookmarked ? 'primary' : 'medium'}
+ />
+ </IonButton>
+ </div>
+
+ <p className="text-sm text-gray-600 line-clamp-2 mb-3">
+ {article.summary}
+ </p>
+
+ <div className="flex items-center justify-between text-xs text-gray-500">
+ <div className="flex items-center space-x-4">
+ <div className="flex items-center">
+ <IonIcon icon={timeOutline} className="mr-1" />
+ {formatDate(article.publishDate)}
+ </div>
+ <div className="flex items-center">
+ <IonIcon icon={eyeOutline} className="mr-1" />
+ {formatNumber(article.readCount)}
+ </div>
+ <div className="flex items-center">
+ <IonIcon icon={heartOutline} className="mr-1" />
+ {formatNumber(article.likeCount)}
+ </div>
+ </div>
+
+ <IonButton
+ fill="clear"
+ size="small"
+ onClick={() => window.open(article.url, '_blank')}
+ >
+ <IonIcon icon={shareOutline} />
+ </IonButton>
+ </div>
+
+ <div className="flex items-center mt-3">
+ <img
+ src={article.authorAvatar}
+ alt={article.author}
+ className="w-6 h-6 rounded-full mr-2"
+ />
+ <span className="text-sm text-gray-700">{article.author}</span>
+ <div className="ml-auto flex gap-1">
+ {article.tags.slice(0, 2).map((tag, index) => (
+ <IonChip key={index} size="small" color="light">
+ {tag}
+ </IonChip>
+ ))}
+ </div>
+ </div>
+ </div>
+
+ {article.coverImage && (
+ <div className="w-24 h-24 flex-shrink-0">
+ <img
+ src={article.coverImage}
+ alt={article.title}
+ className="w-full h-full object-cover"
+ />
+ </div>
+ )}
+ </div>
+ </div>
+ ))}
+
+ {articles.length === 0 && (
+ <div className="text-center py-12">
+ <IonIcon
+ icon={bookmarkOutline}
+ className="text-6xl text-gray-300 mx-auto mb-4"
+ />
+ <h3 className="text-lg font-medium text-gray-900 mb-2">
+ 暂无文章
+ </h3>
+ <p className="text-gray-500">
+ {selectedCategory ? '该分类下暂无文章' : '开始收藏您喜欢的文章吧'}
+ </p>
+ </div>
+ )}
+ </div>
+
+ <IonInfiniteScroll onIonInfinite={handleLoadMore}>
+ <IonInfiniteScrollContent
+ loadingSpinner="bubbles"
+ loadingText="加载更多文章..."
+ />
+ </IonInfiniteScroll>
</IonContent>
</IonPage>
diff Copy code
- import { TodoListItem } from '../../mock';
- import Store from '../../store';
- import * as selectors from '../../store/selectors';
+ import React from 'react';
import {
- IonPage,
+ IonContent,
IonHeader,
+ IonPage,
+ IonTitle,
IonToolbar,
- IonTitle,
- IonContent,
+ IonList,
IonItem,
IonLabel,
- IonList,
+ IonIcon,
+ IonBadge,
+ IonButton,
+ IonFab,
+ IonFabButton,
+ IonModal,
+ IonHeader as ModalHeader,
+ IonToolbar as ModalToolbar,
+ IonTitle as ModalTitle,
+ IonContent as ModalContent,
+ IonButtons,
+ IonItemSliding,
+ IonItemOptions,
+ IonItemOption,
} from '@ionic/react';
-
- const ListEntry = ({ list }: { list: TodoListItem }) => {
- return (
- <IonItem routerLink={`/lists/${list.id}`} className="list-entry">
- <IonLabel>{list.name}</IonLabel>
- </IonItem>
- );
- };
+ import {
+ add,
+ close,
+ bookmark,
+ bookmarkOutline,
+ trashOutline,
+ editOutline,
+ } from 'ionicons/icons';
+ import { useCategories, useCategoryStats, useArticlesByCategory } from '../../store/selectors';
+ import { setSelectedCategory } from '../../store/actions';
+ import { useHistory } from 'react-router';
- const AllLists = () => {
- const lists = Store.useState(selectors.selectLists);
-
- return (
- <>
- {lists.map((list, i) => (
- <ListEntry list={list} key={i} />
- ))}
- </>
- );
- };
+ const Lists: React.FC = () => {
+ const categories = useCategories();
+ const categoryStats = useCategoryStats();
+ const articlesByCategory = useArticlesByCategory();
+ const history = useHistory();
+ const [showAddModal, setShowAddModal] = React.useState(false);
+
+ const handleCategoryClick = (categoryId: string) => {
+ setSelectedCategory(categoryId);
+ history.push('/feed');
+ };
- const Lists = () => {
+ const handleViewAll = () => {
+ setSelectedCategory(null);
+ history.push('/feed');
+ };
+
return (
<IonPage>
- <IonHeader translucent={true}>
+ <IonHeader>
<IonToolbar>
- <IonTitle>Lists</IonTitle>
+ <IonTitle>分类管理</IonTitle>
</IonToolbar>
</IonHeader>
- <IonContent fullscreen={true}>
- <IonHeader collapse="condense">
- <IonToolbar>
- <IonTitle size="large">Lists</IonTitle>
- </IonToolbar>
- </IonHeader>
- <IonList>
- <AllLists />
- </IonList>
+
+ <IonContent>
+ <div className="p-4">
+ {/* 统计卡片 */}
+ <div className="grid grid-cols-2 gap-4 mb-6">
+ <div className="bg-gradient-to-r from-blue-500 to-blue-600 rounded-lg p-4 text-white">
+ <div className="flex items-center justify-between">
+ <div>
+ <p className="text-sm opacity-90">总文章数</p>
+ <p className="text-2xl font-bold">
+ {Object.values(articlesByCategory).reduce((sum, articles) => sum + articles.length, 0)}
+ </p>
+ </div>
+ <IonIcon icon={bookmarkOutline} className="text-3xl opacity-80" />
+ </div>
+ </div>
+
+ <div className="bg-gradient-to-r from-green-500 to-green-600 rounded-lg p-4 text-white">
+ <div className="flex items-center justify-between">
+ <div>
+ <p className="text-sm opacity-90">已收藏</p>
+ <p className="text-2xl font-bold">
+ {Object.values(articlesByCategory).reduce((sum, articles) =>
+ sum + articles.filter(article => article.isBookmarked).length, 0
+ )}
+ </p>
+ </div>
+ <IonIcon icon={bookmark} className="text-3xl opacity-80" />
+ </div>
+ </div>
+ </div>
+
+ {/* 快速操作 */}
+ <div className="mb-6">
+ <IonButton
+ expand="block"
+ fill="outline"
+ onClick={handleViewAll}
+ className="mb-3"
+ >
+ 查看全部文章
+ </IonButton>
+ </div>
+
+ {/* 分类列表 */}
+ <IonList>
+ <IonItem>
+ <IonLabel>
+ <h2 className="font-semibold">文章分类</h2>
+ <p className="text-sm text-gray-500">按分类管理您的文章</p>
+ </IonLabel>
+ </IonItem>
+
+ {categories.map((category) => {
+ const stats = categoryStats.find(stat => stat.category === category.id);
+ const articles = articlesByCategory[category.id] || [];
+
+ return (
+ <IonItemSliding key={category.id}>
+ <IonItem
+ button
+ onClick={() => handleCategoryClick(category.id)}
+ className="py-4"
+ >
+ <div
+ className="w-12 h-12 rounded-lg flex items-center justify-center mr-4"
+ style={{ backgroundColor: category.color }}
+ >
+ <IonIcon
+ icon={category.icon as any}
+ className="text-white text-xl"
+ />
+ </div>
+
+ <IonLabel>
+ <h2 className="font-medium">{category.name}</h2>
+ <div className="flex items-center space-x-4 mt-1">
+ <span className="text-sm text-gray-500">
+ {stats?.count || 0} 篇文章
+ </span>
+ <span className="text-sm text-gray-500">
+ {stats?.bookmarkedCount || 0} 已收藏
+ </span>
+ </div>
+ </IonLabel>
+
+ <IonBadge
+ slot="end"
+ color="primary"
+ style={{ backgroundColor: category.color }}
+ >
+ {stats?.count || 0}
+ </IonBadge>
+ </IonItem>
+
+ <IonItemOptions side="end">
+ <IonItemOption
+ color="primary"
+ onClick={() => {
+ // 编辑分类功能
+ }}
+ >
+ <IonIcon icon={editOutline} />
+ </IonItemOption>
+ <IonItemOption
+ color="danger"
+ onClick={() => {
+ // 删除分类功能
+ }}
+ >
+ <IonIcon icon={trashOutline} />
+ </IonItemOption>
+ </IonItemOptions>
+ </IonItemSliding>
+ );
+ })}
+ </IonList>
+
+ {/* 最近收藏 */}
+ <div className="mt-8">
+ <h3 className="text-lg font-semibold mb-4 px-4">最近收藏</h3>
+ <IonList>
+ {Object.values(articlesByCategory)
+ .flat()
+ .filter(article => article.isBookmarked)
+ .slice(0, 5)
+ .map((article) => (
+ <IonItem key={article.id} button>
+ <img
+ src={article.authorAvatar}
+ alt={article.author}
+ className="w-10 h-10 rounded-full mr-3"
+ />
+ <IonLabel>
+ <h3 className="font-medium line-clamp-1">{article.title}</h3>
+ <p className="text-sm text-gray-500">{article.author}</p>
+ </IonLabel>
+ <IonIcon
+ icon={bookmark}
+ color="primary"
+ slot="end"
+ />
+ </IonItem>
+ ))}
+ </IonList>
+ </div>
+ </div>
+
+ {/* 添加分类按钮 */}
+ <IonFab vertical="bottom" horizontal="end" slot="fixed">
+ <IonFabButton onClick={() => setShowAddModal(true)}>
+ <IonIcon icon={add} />
+ </IonFabButton>
+ </IonFab>
+
+ {/* 添加分类模态框 */}
+ <IonModal isOpen={showAddModal} onDidDismiss={() => setShowAddModal(false)}>
+ <ModalHeader>
+ <ModalToolbar>
+ <ModalTitle>添加新分类</ModalTitle>
+ <IonButtons slot="end">
+ <IonButton onClick={() => setShowAddModal(false)}>
+ <IonIcon icon={close} />
+ </IonButton>
+ </IonButtons>
+ </ModalToolbar>
+ </ModalHeader>
+ <ModalContent>
+ <div className="p-4">
+ <p className="text-gray-500 mb-4">
+ 创建新的文章分类来更好地组织您的收藏
+ </p>
+ {/* 这里可以添加表单 */}
+ <IonButton
+ expand="block"
+ onClick={() => setShowAddModal(false)}
+ >
+ 创建分类
+ </IonButton>
+ </div>
+ </ModalContent>
+ </IonModal>
</IonContent>
</IonPage>
diff Copy code
IonList,
IonToggle,
+ IonLabel,
+ IonSelect,
+ IonSelectOption,
+ IonButton,
+ IonIcon,
+ IonItemDivider,
+ IonItemGroup,
+ IonNote,
+ IonAlert,
+ IonActionSheet,
} from '@ionic/react';
-
- import Store from '../../store';
- import * as selectors from '../../store/selectors';
+ import {
+ notificationsOutline,
+ syncOutline,
+ moonOutline,
+ languageOutline,
+ downloadOutline,
+ uploadOutline,
+ trashOutline,
+ informationCircleOutline,
+ helpCircleOutline,
+ personOutline,
+ } from 'ionicons/icons';
+ import { useSettings } from '../../store/selectors';
import { setSettings } from '../../store/actions';
- const Settings = () => {
- const settings = Store.useState(selectors.selectSettings);
+ const Settings: React.FC = () => {
+ const settings = useSettings();
+ const [showExportAlert, setShowExportAlert] = React.useState(false);
+ const [showImportAlert, setShowImportAlert] = React.useState(false);
+ const [showClearAlert, setShowClearAlert] = React.useState(false);
+
+ const handleToggleNotifications = () => {
+ setSettings({
+ ...settings,
+ enableNotifications: !settings.enableNotifications,
+ });
+ };
+
+ const handleToggleAutoSync = () => {
+ setSettings({
+ ...settings,
+ autoSync: !settings.autoSync,
+ });
+ };
+
+ const handleToggleDarkMode = () => {
+ setSettings({
+ ...settings,
+ darkMode: !settings.darkMode,
+ });
+ };
+
+ const handleLanguageChange = (event: CustomEvent) => {
+ setSettings({
+ ...settings,
+ language: event.detail.value,
+ });
+ };
+
+ const handleExportData = () => {
+ // 导出数据功能
+ setShowExportAlert(false);
+ };
+
+ const handleImportData = () => {
+ // 导入数据功能
+ setShowImportAlert(false);
+ };
+
+ const handleClearData = () => {
+ // 清除数据功能
+ setShowClearAlert(false);
+ };
+
return (
<IonPage>
<IonHeader>
<IonToolbar>
- <IonTitle>Settings</IonTitle>
+ <IonTitle>设置</IonTitle>
</IonToolbar>
</IonHeader>
+
<IonContent>
<IonList>
- <IonItem>
- <IonToggle
- checked={settings.enableNotifications}
- onIonChange={e => {
- setSettings({
- ...settings,
- enableNotifications: e.target.checked,
- });
- }}
- >
- Enable Notifications
- </IonToggle>
- </IonItem>
+ {/* 用户信息 */}
+ <IonItemGroup>
+ <IonItem>
+ <IonIcon icon={personOutline} slot="start" color="primary" />
+ <IonLabel>
+ <h2>用户信息</h2>
+ <p>管理您的账户设置</p>
+ </IonLabel>
+ </IonItem>
+ <IonItem button>
+ <IonLabel>个人资料</IonLabel>
+ <IonNote slot="end">编辑</IonNote>
+ </IonItem>
+ <IonItem button>
+ <IonLabel>账户安全</IonLabel>
+ <IonNote slot="end">设置</IonNote>
+ </IonItem>
+ </IonItemGroup>
+
+ <IonItemDivider>
+ <IonLabel>应用设置</IonLabel>
+ </IonItemDivider>
+
+ {/* 通知设置 */}
+ <IonItemGroup>
+ <IonItem>
+ <IonIcon icon={notificationsOutline} slot="start" />
+ <IonLabel>
+ <h2>通知设置</h2>
+ <p>管理应用通知</p>
+ </IonLabel>
+ </IonItem>
+ <IonItem>
+ <IonLabel>推送通知</IonLabel>
+ <IonToggle
+ slot="end"
+ checked={settings.enableNotifications}
+ onIonChange={handleToggleNotifications}
+ />
+ </IonItem>
+ </IonItemGroup>
+
+ {/* 同步设置 */}
+ <IonItemGroup>
+ <IonItem>
+ <IonIcon icon={syncOutline} slot="start" />
+ <IonLabel>
+ <h2>同步设置</h2>
+ <p>数据同步配置</p>
+ </IonLabel>
+ </IonItem>
+ <IonItem>
+ <IonLabel>自动同步</IonLabel>
+ <IonToggle
+ slot="end"
+ checked={settings.autoSync}
+ onIonChange={handleToggleAutoSync}
+ />
+ </IonItem>
+ <IonItem button>
+ <IonLabel>同步频率</IonLabel>
+ <IonNote slot="end">每小时</IonNote>
+ </IonItem>
+ </IonItemGroup>
+
+ {/* 外观设置 */}
+ <IonItemGroup>
+ <IonItem>
+ <IonIcon icon={moonOutline} slot="start" />
+ <IonLabel>
+ <h2>外观设置</h2>
+ <p>个性化您的应用</p>
+ </IonLabel>
+ </IonItem>
+ <IonItem>
+ <IonLabel>深色模式</IonLabel>
+ <IonToggle
+ slot="end"
+ checked={settings.darkMode}
+ onIonChange={handleToggleDarkMode}
+ />
+ </IonItem>
+ <IonItem>
+ <IonLabel>主题颜色</IonLabel>
+ <IonNote slot="end">蓝色</IonNote>
+ </IonItem>
+ </IonItemGroup>
+
+ {/* 语言设置 */}
+ <IonItemGroup>
+ <IonItem>
+ <IonIcon icon={languageOutline} slot="start" />
+ <IonLabel>
+ <h2>语言设置</h2>
+ <p>选择您的语言</p>
+ </IonLabel>
+ </IonItem>
+ <IonItem>
+ <IonLabel>应用语言</IonLabel>
+ <IonSelect
+ slot="end"
+ value={settings.language}
+ onIonChange={handleLanguageChange}
+ interface="popover"
+ >
+ <IonSelectOption value="zh-CN">简体中文</IonSelectOption>
+ <IonSelectOption value="en-US">English</IonSelectOption>
+ <IonSelectOption value="ja-JP">日本語</IonSelectOption>
+ </IonSelect>
+ </IonItem>
+ </IonItemGroup>
+
+ <IonItemDivider>
+ <IonLabel>数据管理</IonLabel>
+ </IonItemDivider>
+
+ {/* 数据管理 */}
+ <IonItemGroup>
+ <IonItem button onClick={() => setShowExportAlert(true)}>
+ <IonIcon icon={downloadOutline} slot="start" color="success" />
+ <IonLabel>
+ <h2>导出数据</h2>
+ <p>备份您的文章收藏</p>
+ </IonLabel>
+ </IonItem>
+ <IonItem button onClick={() => setShowImportAlert(true)}>
+ <IonIcon icon={uploadOutline} slot="start" color="primary" />
+ <IonLabel>
+ <h2>导入数据</h2>
+ <p>恢复您的文章收藏</p>
+ </IonLabel>
+ </IonItem>
+ <IonItem button onClick={() => setShowClearAlert(true)}>
+ <IonIcon icon={trashOutline} slot="start" color="danger" />
+ <IonLabel>
+ <h2>清除数据</h2>
+ <p>删除所有本地数据</p>
+ </IonLabel>
+ </IonItem>
+ </IonItemGroup>
+
+ <IonItemDivider>
+ <IonLabel>关于</IonLabel>
+ </IonItemDivider>
+
+ {/* 关于 */}
+ <IonItemGroup>
+ <IonItem button>
+ <IonIcon icon={informationCircleOutline} slot="start" />
+ <IonLabel>
+ <h2>关于应用</h2>
+ <p>版本信息和说明</p>
+ </IonLabel>
+ </IonItem>
+ <IonItem button>
+ <IonIcon icon={helpCircleOutline} slot="start" />
+ <IonLabel>
+ <h2>帮助与反馈</h2>
+ <p>获取帮助或提交反馈</p>
+ </IonLabel>
+ </IonItem>
+ <IonItem>
+ <IonLabel>版本</IonLabel>
+ <IonNote slot="end">v1.0.0</IonNote>
+ </IonItem>
+ </IonItemGroup>
</IonList>
+
+ {/* 导出确认 */}
+ <IonAlert
+ isOpen={showExportAlert}
+ onDidDismiss={() => setShowExportAlert(false)}
+ header="导出数据"
+ message="确定要导出所有文章收藏数据吗?"
+ buttons={[
+ {
+ text: '取消',
+ role: 'cancel',
+ },
+ {
+ text: '导出',
+ handler: handleExportData,
+ },
+ ]}
+ />
+
+ {/* 导入确认 */}
+ <IonAlert
+ isOpen={showImportAlert}
+ onDidDismiss={() => setShowImportAlert(false)}
+ header="导入数据"
+ message="导入数据将覆盖当前的所有数据,确定要继续吗?"
+ buttons={[
+ {
+ text: '取消',
+ role: 'cancel',
+ },
+ {
+ text: '导入',
+ handler: handleImportData,
+ },
+ ]}
+ />
+
+ {/* 清除确认 */}
+ <IonAlert
+ isOpen={showClearAlert}
+ onDidDismiss={() => setShowClearAlert(false)}
+ header="清除数据"
+ message="此操作将删除所有本地数据且无法恢复,确定要继续吗?"
+ buttons={[
+ {
+ text: '取消',
+ role: 'cancel',
+ },
+ {
+ text: '清除',
+ role: 'destructive',
+ handler: handleClearData,
+ },
+ ]}
+ />
</IonContent>
</IonPage>
diff Copy code
+ import React from 'react';
import {
- IonBackButton,
- IonButtons,
- IonCheckbox,
IonContent,
IonHeader,
- IonItem,
- IonLabel,
- IonList,
IonPage,
IonTitle,
IonToolbar,
+ IonButtons,
+ IonButton,
+ IonIcon,
+ IonCard,
+ IonCardHeader,
+ IonCardTitle,
+ IonCardSubtitle,
+ IonCardContent,
+ IonChip,
+ IonBadge,
+ IonItem,
+ IonLabel,
+ IonNote,
+ IonFab,
+ IonFabButton,
+ IonActionSheet,
} from '@ionic/react';
- import { useParams } from 'react-router-dom';
-
- import Store from '../../store';
- import * as actions from '../../store/actions';
- import * as selectors from '../../store/selectors';
- import { ListItem, TodoListItem } from '../../mock';
-
- type ListDetailParams = {
- listId: string;
- };
-
- const ListItems = ({ list }: { list: TodoListItem }) => {
- return (
- <IonList>
- {(list?.items || []).map((item, key) => (
- <ListItemEntry list={list} item={item} key={key} />
- ))}
- </IonList>
- );
- };
-
- const ListItemEntry = ({
- list,
- item,
- }: {
- list: TodoListItem;
- item: ListItem;
- }) => (
- <IonItem onClick={() => actions.setDone(list, item, !item.done)}>
- <IonLabel>{item.name}</IonLabel>
- <IonCheckbox
- aria-label={item.name}
- checked={item.done || false}
- slot="end"
- />
- </IonItem>
- );
-
- const ListDetail = () => {
- const lists = Store.useState(selectors.selectLists);
- const params = useParams<ListDetailParams>();
- const { listId } = params;
- const loadedList = lists.find(l => l.id === listId);
+ import {
+ bookmark,
+ bookmarkOutline,
+ shareOutline,
+ ellipsisVertical,
+ timeOutline,
+ eyeOutline,
+ heartOutline,
+ personOutline,
+ } from 'ionicons/icons';
+ import { useParams, useHistory } from 'react-router';
+ import { useArticles } from '../../store/selectors';
+ import { toggleBookmark } from '../../store/actions';
+
+ const ListDetail: React.FC = () => {
+ const { listId } = useParams<{ listId: string }>();
+ const articles = useArticles();
+ const history = useHistory();
+ const [showActionSheet, setShowActionSheet] = React.useState(false);
+
+ // 这里可以根据listId获取特定分类的文章
+ const categoryArticles = articles.filter(article => article.category === listId);
+
+ const formatDate = (dateString: string) => {
+ const date = new Date(dateString);
+ return date.toLocaleDateString('zh-CN', {
+ year: 'numeric',
+ month: 'long',
+ day: 'numeric',
+ });
+ };
+
+ const formatNumber = (num: number) => {
+ if (num >= 10000) {
+ return (num / 10000).toFixed(1) + '万';
+ }
+ return num.toString();
+ };
+
+ const handleShare = () => {
+ // 分享功能
+ setShowActionSheet(false);
+ };
+
+ const handleOpenInBrowser = () => {
+ // 在浏览器中打开
+ setShowActionSheet(false);
+ };
return (