|
@@ -6,6 +6,7 @@ import { MESSAGE_TAB } from "@/constants";
|
|
import { useNotificationStore } from "@/store/NotificationStore";
|
|
import { useNotificationStore } from "@/store/NotificationStore";
|
|
import { Eraser, FileText } from "lucide-react";
|
|
import { Eraser, FileText } from "lucide-react";
|
|
import dayjs from "dayjs";
|
|
import dayjs from "dayjs";
|
|
|
|
+import { renderNoticeLength } from "@/utils/utils";
|
|
|
|
|
|
interface MessageModalProps {
|
|
interface MessageModalProps {
|
|
visible: boolean;
|
|
visible: boolean;
|
|
@@ -20,7 +21,9 @@ const MessageModal: React.FC<MessageModalProps> = ({
|
|
}) => {
|
|
}) => {
|
|
const [activeKey, setActiveKey] = useState(MESSAGE_TAB.UNREAD);
|
|
const [activeKey, setActiveKey] = useState(MESSAGE_TAB.UNREAD);
|
|
const { notifications } = useNotificationStore();
|
|
const { notifications } = useNotificationStore();
|
|
- console.log("notifications", notifications);
|
|
|
|
|
|
+ const unreadNotifications = notifications.filter(
|
|
|
|
+ (notification) => notification.status === MESSAGE_TAB.UNREAD
|
|
|
|
+ );
|
|
|
|
|
|
const tabItems: TabsProps["items"] = [
|
|
const tabItems: TabsProps["items"] = [
|
|
{
|
|
{
|
|
@@ -32,15 +35,11 @@ const MessageModal: React.FC<MessageModalProps> = ({
|
|
label: (
|
|
label: (
|
|
<span className="flex">
|
|
<span className="flex">
|
|
未读{" "}
|
|
未读{" "}
|
|
- <span className="text-xs text-white bg-red-500 rounded-full w-5 h-5 flex justify-center items-center">
|
|
|
|
- {notifications.filter(
|
|
|
|
- (notification) => notification.status === MESSAGE_TAB.UNREAD
|
|
|
|
- ).length > 9
|
|
|
|
- ? "9+"
|
|
|
|
- : notifications.filter(
|
|
|
|
- (notification) => notification.status === MESSAGE_TAB.UNREAD
|
|
|
|
- ).length}
|
|
|
|
- </span>
|
|
|
|
|
|
+ {!!unreadNotifications.length && (
|
|
|
|
+ <span className="ml-1 text-xs text-white bg-red-500 rounded-full w-5 h-5 flex justify-center items-center">
|
|
|
|
+ {renderNoticeLength(unreadNotifications)}
|
|
|
|
+ </span>
|
|
|
|
+ )}
|
|
</span>
|
|
</span>
|
|
),
|
|
),
|
|
},
|
|
},
|
|
@@ -54,7 +53,11 @@ const MessageModal: React.FC<MessageModalProps> = ({
|
|
<Modal
|
|
<Modal
|
|
title={
|
|
title={
|
|
<div className="flex items-center">
|
|
<div className="flex items-center">
|
|
- <span>消息中心 (1)</span>
|
|
|
|
|
|
+ <span>
|
|
|
|
+ 消息中心{" "}
|
|
|
|
+ {!!renderNoticeLength(notifications) &&
|
|
|
|
+ `(${renderNoticeLength(notifications)})`}
|
|
|
|
+ </span>
|
|
<div className="cursor-pointer hover:bg-gray-100 rounded-md px-2 py-1 ml-2 text-xs flex justify-center items-center gap-1">
|
|
<div className="cursor-pointer hover:bg-gray-100 rounded-md px-2 py-1 ml-2 text-xs flex justify-center items-center gap-1">
|
|
<Eraser size={12} />
|
|
<Eraser size={12} />
|
|
清除消息
|
|
清除消息
|
|
@@ -111,10 +114,10 @@ const MessageModal: React.FC<MessageModalProps> = ({
|
|
{message.footer || "祝您工作顺利!"}
|
|
{message.footer || "祝您工作顺利!"}
|
|
</p>
|
|
</p>
|
|
<div className="mt-2 flex space-x-2 justify-end">
|
|
<div className="mt-2 flex space-x-2 justify-end">
|
|
- <Button size="middle">知道了</Button>
|
|
|
|
<Button type="primary" size="middle">
|
|
<Button type="primary" size="middle">
|
|
- 去查看
|
|
|
|
|
|
+ 知道了
|
|
</Button>
|
|
</Button>
|
|
|
|
+ <Button size="middle">去查看</Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|