feat(notify): 站内通知补齐完成、到期逾期与知识事件
CI / backend (push) Waiting to run

This commit is contained in:
Steven
2026-11-10 13:47:56 +08:00
parent 4b7627d70e
commit f54df70811
15 changed files with 791 additions and 32 deletions
+2
View File
@@ -224,6 +224,8 @@ export interface AppNotification {
id: string;
kind: string;
item_id: string | null;
/** 事项类型:知识要跳阅读页,工单跳工单页,任务回任务页。 */
item_kind: "task" | "ticket" | "knowledge" | null;
item_title: string | null;
title: string;
body: string;
+17 -5
View File
@@ -2,21 +2,33 @@ import { useCallback, useEffect, useMemo, useState } from "react";
import { useNavigate, useParams } from "react-router-dom";
import { AppShell } from "../components/AppShell";
import { Bell, Check, TicketIcon, Inbox, Clock } from "../components/icons";
import { Bell, Book, Check, TicketIcon, Inbox, Clock, Flag } from "../components/icons";
import { Button, EmptyState, PageHeader, SkeletonRows } from "../components/ui";
import { api, ApiError } from "../lib/client";
import type { AppNotification } from "../lib/types";
const PAGE = 30;
/** 工单类通知点开跳到工单页,其余回任务页——都带 `?open=`,落地即展开那一条。 */
/**
* 点开跳到哪:知识走独立阅读页(整屏),工单去工单页,其余回任务页——
* 后两者都带 `?open=`,落地即展开那一条。判断以 `item_kind` 为准,
* 因为"知识被评论"的通知 kind 是 item_commented,光看 kind 会跳错页。
*/
function targetOf(wsId: string, n: AppNotification): string {
if (!n.item_id) return `/w/${wsId}/notifications`;
const isTicket = n.kind.startsWith("ticket_");
return isTicket ? `/w/${wsId}/tickets?open=${n.item_id}` : `/w/${wsId}?open=${n.item_id}`;
if (n.item_kind === "knowledge" || n.kind.startsWith("knowledge_")) {
return `/w/${wsId}/knowledge/${n.item_id}`;
}
if (n.item_kind === "ticket" || n.kind.startsWith("ticket_")) {
return `/w/${wsId}/tickets?open=${n.item_id}`;
}
return `/w/${wsId}?open=${n.item_id}`;
}
function iconOf(kind: string) {
if (kind.startsWith("knowledge_")) return <Book size={15} />;
if (kind === "task_due_soon") return <Clock size={15} />;
if (kind === "task_overdue") return <Flag size={15} />;
if (kind.startsWith("ticket_")) return <TicketIcon size={15} />;
if (kind === "item_commented") return <Inbox size={15} />;
return <Bell size={15} />;
@@ -113,7 +125,7 @@ export function NotificationsPage() {
<PageHeader
eyebrow="事情有动静时,这里会告诉你"
title="通知"
desc="工单被接受、提交、验收,任务被指派、改状态,有人在你关注的事情下说话,都会落在这里。"
desc="任务被指派、完成、快到期或已逾期,工单被接受/验收,知识待核对/已发布,以及有人在你关注的事情下说话,都会落在这里。"
actions={
<>
<Button variant="ghost" size="sm" onClick={() => void load(true)} disabled={loading}>