Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
任务通知线管
daoyian0e4c4e81e109
diff --git a/public/robots.txt b/public/robots.txtindex f83d3e67..0b2eaa56 100644--- a/public/robots.txt+++ b/public/robots.txt@@ -3,7 +3,7 @@ User-agent: *Allow: /# Host-Host: https://dev.aitoearn.ai+Host: https://aitoearn.ai# Sitemaps-Sitemap: https://dev.aitoearn.ai/sitemap.xml+Sitemap: https://aitoearn.ai/sitemap.xmldiff --git a/public/sitemap.xml b/public/sitemap.xmlindex fb4df72b..bb9442e3 100644--- a/public/sitemap.xml+++ b/public/sitemap.xml@@ -1,4 +1,4 @@<?xml version="1.0" encoding="UTF-8"?><sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">-<sitemap><loc>https://dev.aitoearn.ai/sitemap-0.xml</loc></sitemap>+<sitemap><loc>https://aitoearn.ai/sitemap-0.xml</loc></sitemap></sitemapindex>\ No newline at end of filediff --git a/src/api/notification.ts b/src/api/notification.tsindex c5e4ffa1..63c84c82 100644--- a/src/api/notification.ts+++ b/src/api/notification.ts@@ -4,10 +4,13 @@ export interface NotificationItem {id: string;title: string;content: string;- type: "system" | "user" | "material" | "other";- isRead: boolean;+ type: "system" | "user" | "material" | "other" | "task_reminder";+ status: "read" | "unread";+ readAt?: string;createdAt: string;updatedAt: string;+ relatedId?: string;+ userId?: string;}export interface NotificationListResponse {@@ -31,7 +34,7 @@ export const getNotificationList = (params: {pageSize?: number;type?: string;}) => {- return http.get<NotificationListResponse>("notification", { params });+ return http.get<NotificationListResponse>("notification", params );};// 获取通知详情@@ -40,8 +43,8 @@ export const getNotificationDetail = (id: string) => {};// 标记通知为已读-export const markNotificationAsRead = (id: string) => {- return http.put(`notification/read`, { id });+export const markNotificationAsRead = (notificationIds: string[]) => {+ return http.put(`notification/read`, { notificationIds });};// 全部标记为已读@@ -52,4 +55,9 @@ export const markAllNotificationsAsRead = () => {// 获取未读数量export const getUnreadCount = () => {return http.get<UnreadCountResponse>("notification/unread-count");+};++// 删除通知+export const deleteNotifications = (notificationIds: string[]) => {+ return http.delete("notification", { notificationIds } );};\ No newline at end of filediff --git a/src/app/[lng]/accounts/components/CalendarTiming/ListMode/listMode.module.scss b/src/app/[lng]/accounts/components/CalendarTiming/ListMode/listMode.module.scssindex 534e84de..ee4161fd 100644--- a/src/app/[lng]/accounts/components/CalendarTiming/ListMode/listMode.module.scss+++ b/src/app/[lng]/accounts/components/CalendarTiming/ListMode/listMode.module.scss@@ -110,7 +110,7 @@}.skeletonItem {- padding: 12px 0;+ padding: 12px 2px;border-bottom: 1px solid var(--grayColor8);&:last-child {diff --git a/src/components/notification/NotificationPanel.module.scss b/src/components/notification/NotificationPanel.module.scssindex 4604670c..d5d481b9 100644--- a/src/components/notification/NotificationPanel.module.scss+++ b/src/components/notification/NotificationPanel.module.scss@@ -1,16 +1,23 @@.notificationItem {- padding: 12px 0;+ padding: 16px;border-bottom: 1px solid #f0f0f0;cursor: pointer;- transition: background-color 0.2s;+ transition: all 0.3s ease;+ border-radius: 8px;+ margin-bottom: 8px;+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);&:hover {- background-color: #fafafa;+ background-color: #f8f9fa;+ transform: translateY(-1px);+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);}&.unread {- background-color: #f6ffed;- border-left: 3px solid #52c41a;+ background: linear-gradient(135deg, #f6ffed 0%, #e6f7ff 100%);+ position: relative;+ padding-left: 10px !important;+}}@@ -18,7 +25,10 @@display: flex;align-items: center;gap: 8px;- font-weight: 500;+ font-weight: 600;+ font-size: 16px;+ color: #262626;+ margin-bottom: 8px;}.notificationContent {@@ -29,47 +39,64 @@display: flex;justify-content: space-between;align-items: center;- margin-bottom: 8px;- font-size: 12px;- color: #666;-- .type {- background-color: #f0f0f0;- padding: 2px 6px;- border-radius: 4px;- }+ margin-bottom: 12px;+ font-size: 13px;.time {- color: #999;+ color: #8c8c8c;+ display: flex;+ align-items: center;+ font-size: 12px;}}.content {- color: #333;- line-height: 1.5;- margin-bottom: 8px;+ color: #595959;+ line-height: 1.6;+ margin-bottom: 12px;+ font-size: 14px;+ background: #fafafa;+ padding: 12px;+ border-radius: 6px;+ border-left: 3px solid #d9d9d9;+}++.actions {+ display: flex;+ justify-content: flex-end;+ gap: 8px;}.notificationDetail {h3 {- margin-bottom: 16px;- color: #333;+ margin-bottom: 20px;+ color: #262626;+ font-size: 18px;+ font-weight: 600;+ border-bottom: 2px solid #f0f0f0;+ padding-bottom: 12px;}.meta {display: flex;justify-content: space-between;- margin-bottom: 16px;- padding: 8px 12px;- background-color: #f5f5f5;- border-radius: 4px;+ margin-bottom: 20px;+ padding: 16px;+ background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);+ border-radius: 8px;font-size: 14px;color: #666;+ border: 1px solid #e9ecef;}.content {- line-height: 1.6;- color: #333;+ line-height: 1.8;+ color: #595959;white-space: pre-wrap;+ background: #fafafa;+ padding: 20px;+ border-radius: 8px;+ border: 1px solid #f0f0f0;+ font-size: 15px;}}\ No newline at end of filediff --git a/src/components/notification/NotificationPanel.tsx b/src/components/notification/NotificationPanel.tsxindex 09eef503..9e6511d1 100644--- a/src/components/notification/NotificationPanel.tsx+++ b/src/components/notification/NotificationPanel.tsx@@ -1,15 +1,17 @@"use client";import React, { useState, useEffect } from "react";-import { Badge, Button, List, Modal, message, Spin, Empty } from "antd";-import { CheckOutlined } from "@ant-design/icons";+import { Badge, Button, List, Modal, message, Spin, Empty, Popconfirm, Tooltip, Tag } from "antd";+import { CheckOutlined, DeleteOutlined, EyeOutlined, ClockCircleOutlined } from "@ant-design/icons";import { useTransClient } from "@/app/i18n/client";import { useUserStore } from "@/store/user";import {getNotificationList,+ getNotificationDetail,markNotificationAsRead,markAllNotificationsAsRead,getUnreadCount,+ deleteNotifications,type NotificationItem} from "@/api/notification";import styles from "./NotificationPanel.module.scss";@@ -70,7 +72,7 @@ const NotificationPanel: React.FC<NotificationPanelProps> = ({ visible, onClose// 标记单个通知为已读const handleMarkAsRead = async (id: string) => {try {- await markNotificationAsRead(id);+ await markNotificationAsRead([id]);message.success("标记成功");fetchNotifications();fetchUnreadCount();@@ -92,11 +94,24 @@ const NotificationPanel: React.FC<NotificationPanelProps> = ({ visible, onClose};// 查看通知详情- const handleViewDetail = (notification: NotificationItem) => {- setSelectedNotification(notification);- setDetailModalVisible(true);- if (!notification.isRead) {- handleMarkAsRead(notification.id);+ const handleViewDetail = async (notification: NotificationItem) => {+ try {+ // 调用API获取通知详情+ const response = await getNotificationDetail(notification.id);+ if (response && response.data && response.data.data) {+ setSelectedNotification(response.data.data);+ setDetailModalVisible(true);++ // 如果是未读状态,标记为已读+ if (notification.status === 'unread') {+ handleMarkAsRead(notification.id);+ }+ } else {+ message.error("获取通知详情失败");+ }+ } catch (error) {+ message.error("获取通知详情失败");+ console.error("获取通知详情失败:", error);}};@@ -122,11 +137,36 @@ const NotificationPanel: React.FC<NotificationPanelProps> = ({ visible, onClosesystem: "系统通知",user: "用户通知",material: "素材通知",+ task_reminder: "任务提醒",other: "其他通知"};return typeMap[type] || type;};+ // 获取通知类型颜色+ const getNotificationTypeColor = (type: string) => {+ const colorMap: Record<string, string> = {+ system: "blue",+ user: "green",+ material: "orange",+ task_reminder: "red",+ other: "default"+ };+ return colorMap[type] || "default";+ };++ // 删除通知+ const handleDeleteNotification = async (id: string) => {+ try {+ await deleteNotifications([id]);+ message.success("删除成功");+ fetchNotifications();+ fetchUnreadCount();+ } catch (error) {+ message.error("删除失败");+ }+ };+useEffect(() => {if (visible) {fetchNotifications();@@ -137,19 +177,34 @@ const NotificationPanel: React.FC<NotificationPanelProps> = ({ visible, onClosereturn (<><Modal- title="消息通知"+ title={+ <div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>+ <Badge count={unreadCount} size="small">+ <span style={{ fontSize: '16px', fontWeight: '600' }}>消息通知</span>+ </Badge>+ </div>+ }open={visible}onCancel={onClose}footer={[- <Button key="markAll" onClick={handleMarkAllAsRead} disabled={unreadCount === 0}>+ <Button key="markAll" onClick={handleMarkAllAsRead} disabled={unreadCount === 0} type="primary">{t('markAllAsRead')}</Button>,<Button key="close" onClick={onClose}>{t('actions.cancel')}</Button>]}- width={600}+ width={700}destroyOnHidden+ styles={{+ header: {+ borderBottom: '1px solid #f0f0f0',+ paddingBottom: '16px'+ },+ body: {+ padding: '6px'+ }+ }}><Spin spinning={loading}>{notifications.length > 0 ? (@@ -157,33 +212,54 @@ const NotificationPanel: React.FC<NotificationPanelProps> = ({ visible, onClosedataSource={notifications}renderItem={(item) => (<List.Item- className={`${styles.notificationItem} ${!item.isRead ? styles.unread : ""}`}+ className={`${styles.notificationItem} ${item.status === 'unread' ? styles.unread : ""}`}actions={[- !item.isRead && (- <Button- key="mark"- type="text"- size="small"- icon={<CheckOutlined />}- onClick={() => handleMarkAsRead(item.id)}- >- {t('markAsRead')}- </Button>- )+ item.status === 'unread' && (+ <Button+ key="mark"+ type="text"+ size="small"+ icon={<CheckOutlined />}+ onClick={() => handleMarkAsRead(item.id)}+ >+ {t('markAsRead')}+ </Button>+ ),+ <Popconfirm+ key="delete"+ title="确定要删除这条通知吗?"+ onConfirm={() => handleDeleteNotification(item.id)}+ okText="确定"+ cancelText="取消"+ >+ <Button+ type="text"+ size="small"+ danger+ icon={<DeleteOutlined />}+ >+ 删除+ </Button>+ </Popconfirm>]}><List.Item.Metatitle={<div className={styles.notificationTitle}><span>{item.title}</span>- {!item.isRead && <Badge status="processing" />}+ {item.status === 'unread' && <Badge status="processing" />}</div>}description={<div className={styles.notificationContent}><div className={styles.notificationMeta}>- <span className={styles.type}>{getNotificationTypeText(item.type)}</span>- <span className={styles.time}>{formatTime(item.createdAt)}</span>+ <Tag color={getNotificationTypeColor(item.type)}>+ {getNotificationTypeText(item.type)}+ </Tag>+ <span className={styles.time}>+ <ClockCircleOutlined style={{ marginRight: 4 }} />+ {formatTime(item.createdAt)}+ </span></div><div className={styles.content}>{item.content.length > 100@@ -191,13 +267,18 @@ const NotificationPanel: React.FC<NotificationPanelProps> = ({ visible, onClose: item.content}</div>- <Button- type="link"- size="small"- onClick={() => handleViewDetail(item)}- >- {t('viewAll')}- </Button>+ <div className={styles.actions}>+ <Tooltip title="查看详情">+ <Button+ type="link"+ size="small"+ icon={<EyeOutlined />}+ onClick={() => handleViewDetail(item)}+ >+ {t('viewAll')}+ </Button>+ </Tooltip>+ </div></div>}/>@@ -212,23 +293,50 @@ const NotificationPanel: React.FC<NotificationPanelProps> = ({ visible, onClose{/* 通知详情弹窗 */}<Modal- title={t('notifications')}+ title={+ <div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>+ <span style={{ fontSize: '16px', fontWeight: '600' }}>通知详情</span>+ </div>+ }open={detailModalVisible}onCancel={() => setDetailModalVisible(false)}footer={[- <Button key="close" onClick={() => setDetailModalVisible(false)}>- {t('actions.cancel')}+ <Button key="close" onClick={() => setDetailModalVisible(false)} type="primary">+ 关闭</Button>]}- width={500}+ width={600}+ styles={{+ header: {+ borderBottom: '1px solid #f0f0f0',+ paddingBottom: '16px'+ },+ body: {+ padding: '24px'+ }+ }}>{selectedNotification && (<div className={styles.notificationDetail}><h3>{selectedNotification.title}</h3>- <div className={styles.meta}>- <span>类型: {getNotificationTypeText(selectedNotification.type)}</span>- <span>时间: {formatTime(selectedNotification.createdAt)}</span>- </div>+ <div className={styles.meta}>+ <span>+ <Tag color={getNotificationTypeColor(selectedNotification.type)}>+ {getNotificationTypeText(selectedNotification.type)}+ </Tag>+ </span>+ <div style={{ display: 'flex', flexDirection: 'column', gap: '4px' }}>+ <span>+ <ClockCircleOutlined style={{ marginRight: 4 }} />+ 创建时间: {formatTime(selectedNotification.createdAt)}+ </span>+ {selectedNotification.readAt && (+ <span style={{ color: '#52c41a' }}>+ 已读时间: {formatTime(selectedNotification.readAt)}+ </span>+ )}+ </div>+ </div><div className={styles.content}>{selectedNotification.content}</div>