feat(版本): 完善研发计划与预警已读
关键改动: - 增加版本表单、发布校验和调研方向进度规则 - 扩展小宝预警已读状态、风险签名和今日证据 - 补充组长权限、加班查看范围、活动记录与相关测试 Co-Authored-By: Codex GPT-5 <codex@openai.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { usePathname, useRouter } from 'next/navigation';
|
||||
import { Inbox, Package, FolderKanban, Tag, Users, LayoutGrid, Lightbulb, Clock, Shield, Settings, Sparkles, TriangleAlert } from 'lucide-react';
|
||||
import { useHasPermission } from '@/components/auth/Guard';
|
||||
@@ -7,8 +8,15 @@ import { useXiaobaoWarningRisks } from '@/hooks/useXiaobaoWarningRisks';
|
||||
import { useWorkspaceWorkItems } from '@/hooks/useWorkspaceWorkItems';
|
||||
import { useAuthStore } from '@/stores/useAuthStore';
|
||||
import { useMemberStore } from '@/stores/useMemberStore';
|
||||
import { useXiaobaoRiskStore } from '@/stores/useXiaobaoRiskStore';
|
||||
import { useXiaobaoWarningReadStore } from '@/stores/useXiaobaoWarningReadStore';
|
||||
import { getWorkspacePendingCount } from '@/lib/workspace-engine';
|
||||
import { getXiaobaoWarningRiskCount } from '@/lib/xiaobao-warning-view';
|
||||
import { buildXiaobaoRiskInsightPendingKey } from '@/lib/xiaobao-risk-suggestion';
|
||||
import {
|
||||
filterXiaobaoRiskWarnings,
|
||||
getXiaobaoWarningRiskCount,
|
||||
getXiaobaoWarningUnreadUpdateCount,
|
||||
} from '@/lib/xiaobao-warning-view';
|
||||
|
||||
type NavItemConfig = {
|
||||
label: string;
|
||||
@@ -180,17 +188,31 @@ function NavItem({ item, active, onNavigate, workspacePendingCount }: {
|
||||
|
||||
function XiaobaoRiskNavBadge() {
|
||||
const { risks } = useXiaobaoWarningRisks();
|
||||
const user = useAuthStore((s) => s.user);
|
||||
const pendingInsightKeys = useXiaobaoRiskStore((s) => s.pendingInsightKeys);
|
||||
const { readStates, readStateLoaded, fetchReadStates } = useXiaobaoWarningReadStore();
|
||||
useEffect(() => {
|
||||
if (user?.id) fetchReadStates();
|
||||
}, [fetchReadStates, user?.id]);
|
||||
|
||||
const count = getXiaobaoWarningRiskCount(risks);
|
||||
if (count <= 0) return null;
|
||||
|
||||
return <NavCountBadge count={count} />;
|
||||
const warningRisks = filterXiaobaoRiskWarnings(risks).map((risk) => (
|
||||
pendingInsightKeys.includes(buildXiaobaoRiskInsightPendingKey(risk))
|
||||
? { ...risk, aiInsightUpdating: true }
|
||||
: risk
|
||||
));
|
||||
const unreadUpdateCount = readStateLoaded ? getXiaobaoWarningUnreadUpdateCount(warningRisks, readStates, user?.id) : 0;
|
||||
return <NavCountBadge count={count} tone={unreadUpdateCount > 0 ? 'update' : 'risk'} />;
|
||||
}
|
||||
|
||||
function NavCountBadge({ count }: { count: number }) {
|
||||
function NavCountBadge({ count, tone = 'risk' }: { count: number; tone?: 'risk' | 'update' }) {
|
||||
if (count <= 0) return null;
|
||||
const toneClass = tone === 'update' ? 'bg-blue-600' : 'bg-red-600';
|
||||
|
||||
return (
|
||||
<span className="ml-auto inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full bg-red-600 px-1.5 text-[10px] font-semibold leading-none text-white">
|
||||
<span className={`ml-auto inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full px-1.5 text-[10px] font-semibold leading-none text-white ${toneClass}`}>
|
||||
{count > 99 ? '99+' : count}
|
||||
</span>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user