feat: 第五轮开发 - 14项未来路线图功能完整实现
W1-W14 全部完成: - W1: 消息搜索 (ILIKE全文检索 + SearchModal) - W2: 对话导出 (JSON/Markdown/TXT三格式) - W3: 记忆时间线 DevTools 可视化 - W4: 通知推送系统 (WebSocket + Browser Notification API) - W5: 定时提醒 (30s轮询 + 重复提醒 + WebSocket推送) - W6: 每日简报 (08:00自动生成: 天气+新闻+提醒+AI摘要) - W7: IoT场景自动化 (规则引擎 10s轮询 + 条件评估 + 场景执行) - W8: 语音输入 (浏览器 Speech Recognition API) - W9: STT服务 (voice-service + whisper.cpp) - W10: TTS服务 (浏览器 Speech Synthesis + edge-tts三档回退) - W11: 文件管理 (上传/下载/缩略图/纯Go bilinear缩放) - W12: 知识库RAG (PostgreSQL tsvector + 文档分块 + 检索) - W13: 多模态 (图片上传+分析: Vision API + 本地Go分析回退) - W14: PWA (Service Worker + 离线页 + install prompt) 总计: 6个Go微服务 + 10+前端组件 + 10+ PostgreSQL表 + 4个后台调度器
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import { create } from 'zustand';
|
||||
import type { AppNotification, NotificationData } from '@/types/chat';
|
||||
|
||||
const MAX_NOTIFICATIONS = 50;
|
||||
|
||||
interface NotificationStore {
|
||||
notifications: AppNotification[];
|
||||
unreadCount: number;
|
||||
isOpen: boolean;
|
||||
|
||||
addNotification: (data: NotificationData) => void;
|
||||
markAsRead: (id: string) => void;
|
||||
markAllAsRead: () => void;
|
||||
removeNotification: (id: string) => void;
|
||||
clearAll: () => void;
|
||||
toggleOpen: () => void;
|
||||
setOpen: (open: boolean) => void;
|
||||
}
|
||||
|
||||
export const useNotificationStore = create<NotificationStore>((set) => ({
|
||||
notifications: [],
|
||||
unreadCount: 0,
|
||||
isOpen: false,
|
||||
|
||||
addNotification: (data: NotificationData) =>
|
||||
set((state) => {
|
||||
const existing = state.notifications.find((n) => n.id === data.id);
|
||||
if (existing) return state;
|
||||
|
||||
const newNotif: AppNotification = {
|
||||
...data,
|
||||
read: false,
|
||||
createdAt: Date.now(),
|
||||
};
|
||||
|
||||
const notifications = [newNotif, ...state.notifications].slice(0, MAX_NOTIFICATIONS);
|
||||
const unreadCount = notifications.filter((n) => !n.read).length;
|
||||
|
||||
return { notifications, unreadCount };
|
||||
}),
|
||||
|
||||
markAsRead: (id: string) =>
|
||||
set((state) => {
|
||||
const notifications = state.notifications.map((n) =>
|
||||
n.id === id ? { ...n, read: true } : n
|
||||
);
|
||||
const unreadCount = notifications.filter((n) => !n.read).length;
|
||||
return { notifications, unreadCount };
|
||||
}),
|
||||
|
||||
markAllAsRead: () =>
|
||||
set((state) => ({
|
||||
notifications: state.notifications.map((n) => ({ ...n, read: true })),
|
||||
unreadCount: 0,
|
||||
})),
|
||||
|
||||
removeNotification: (id: string) =>
|
||||
set((state) => {
|
||||
const notifications = state.notifications.filter((n) => n.id !== id);
|
||||
const unreadCount = notifications.filter((n) => !n.read).length;
|
||||
return { notifications, unreadCount };
|
||||
}),
|
||||
|
||||
clearAll: () => set({ notifications: [], unreadCount: 0, isOpen: false }),
|
||||
|
||||
toggleOpen: () => set((state) => ({ isOpen: !state.isOpen })),
|
||||
|
||||
setOpen: (open: boolean) => set({ isOpen: open }),
|
||||
}));
|
||||
Reference in New Issue
Block a user