node-resource-utils 0.0.0-stage → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +35 -2
- package/lib/sync.js +121 -0
- package/package.json +14 -4
- package/resources/.cache/ref.b64 +1 -0
- package/resources/README.md +97 -0
- package/resources/_.env +6 -0
- package/resources/_.env.example +25 -0
- package/resources/_.gitignore +18 -0
- package/resources/_.lintstagedrc.json +9 -0
- package/resources/_.npmrc +5 -0
- package/resources/_.prettierrc +7 -0
- package/resources/commitlint.config.mjs +1 -0
- package/resources/content/docs/README.md +63 -0
- package/resources/content/docs/faq.md +107 -0
- package/resources/content/docs/features/_meta.json +5 -0
- package/resources/content/docs/features/ai.md +71 -0
- package/resources/content/docs/features/appearance.md +47 -0
- package/resources/content/docs/features/feedback.md +79 -0
- package/resources/content/docs/features/files.md +74 -0
- package/resources/content/docs/features/graph.md +66 -0
- package/resources/content/docs/features/inbox.md +61 -0
- package/resources/content/docs/guide/_meta.json +5 -0
- package/resources/content/docs/guide/account.md +76 -0
- package/resources/content/docs/guide/data.md +87 -0
- package/resources/content/docs/guide/navigation.md +81 -0
- package/resources/content/docs/guide/permissions.md +67 -0
- package/resources/content/docs/guide/system.md +92 -0
- package/resources/content/docs/quick-start.md +70 -0
- package/resources/content/docs/shortcuts.md +69 -0
- package/resources/eslint.config.mjs +17 -0
- package/resources/next-env.d.ts +6 -0
- package/resources/next.config.ts +13 -0
- package/resources/postcss.config.mjs +7 -0
- package/resources/prisma/org.config.ts +98 -0
- package/resources/prisma/schema.prisma +336 -0
- package/resources/prisma/seed.ts +721 -0
- package/resources/prisma/seedSafe.ts +347 -0
- package/resources/prisma.config.ts +14 -0
- package/resources/scripts/check-config.mjs +773 -0
- package/resources/scripts/lib/schema-graph.mjs +410 -0
- package/resources/scripts/patch-next-trace.mjs +86 -0
- package/resources/scripts/suggest-relations.mjs +105 -0
- package/resources/src/app/(admin)/ai/page.tsx +469 -0
- package/resources/src/app/(admin)/dashboard/page.tsx +260 -0
- package/resources/src/app/(admin)/demo/employees/page.tsx +508 -0
- package/resources/src/app/(admin)/demo/files/page.tsx +451 -0
- package/resources/src/app/(admin)/demo/loading/page.tsx +513 -0
- package/resources/src/app/(admin)/error.tsx +96 -0
- package/resources/src/app/(admin)/feedback/page.tsx +573 -0
- package/resources/src/app/(admin)/graph/page.tsx +1224 -0
- package/resources/src/app/(admin)/inbox/page.tsx +31 -0
- package/resources/src/app/(admin)/layout.tsx +58 -0
- package/resources/src/app/(admin)/loading.tsx +31 -0
- package/resources/src/app/(admin)/system/depts/page.tsx +415 -0
- package/resources/src/app/(admin)/system/logs/page.tsx +215 -0
- package/resources/src/app/(admin)/system/menus/page.tsx +403 -0
- package/resources/src/app/(admin)/system/roles/page.tsx +433 -0
- package/resources/src/app/(admin)/system/users/page.tsx +620 -0
- package/resources/src/app/api/account-recovery/route.ts +132 -0
- package/resources/src/app/api/ai/act/route.ts +70 -0
- package/resources/src/app/api/ai/ask/route.ts +82 -0
- package/resources/src/app/api/ai/chat/route.ts +404 -0
- package/resources/src/app/api/ai/report/route.ts +164 -0
- package/resources/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/resources/src/app/api/auth/change-password/route.ts +57 -0
- package/resources/src/app/api/auth/forgot/route.ts +98 -0
- package/resources/src/app/api/auth/register/route.ts +95 -0
- package/resources/src/app/api/auth/register-config/route.ts +51 -0
- package/resources/src/app/api/badges/route.ts +39 -0
- package/resources/src/app/api/depts/[id]/route.ts +145 -0
- package/resources/src/app/api/depts/route.ts +126 -0
- package/resources/src/app/api/docs/export/route.ts +87 -0
- package/resources/src/app/api/docs/parse/route.ts +57 -0
- package/resources/src/app/api/docs/search/route.ts +22 -0
- package/resources/src/app/api/employees/[id]/route.ts +147 -0
- package/resources/src/app/api/employees/export/route.ts +115 -0
- package/resources/src/app/api/employees/import/route.ts +205 -0
- package/resources/src/app/api/employees/route.ts +149 -0
- package/resources/src/app/api/export/route.ts +254 -0
- package/resources/src/app/api/favorites/route.ts +56 -0
- package/resources/src/app/api/feedback/ai/route.ts +31 -0
- package/resources/src/app/api/feedback/approve/route.ts +67 -0
- package/resources/src/app/api/feedback/report/route.ts +213 -0
- package/resources/src/app/api/feedback/route.ts +246 -0
- package/resources/src/app/api/files/[name]/route.ts +82 -0
- package/resources/src/app/api/graph/focus/route.ts +75 -0
- package/resources/src/app/api/graph/node/move/route.ts +48 -0
- package/resources/src/app/api/graph/node/route.ts +274 -0
- package/resources/src/app/api/graph/route.ts +272 -0
- package/resources/src/app/api/health/route.ts +11 -0
- package/resources/src/app/api/inbox/read/route.ts +36 -0
- package/resources/src/app/api/inbox/summary/route.ts +15 -0
- package/resources/src/app/api/logs/route.ts +82 -0
- package/resources/src/app/api/menus/[id]/route.ts +132 -0
- package/resources/src/app/api/menus/mine/route.ts +23 -0
- package/resources/src/app/api/menus/route.ts +89 -0
- package/resources/src/app/api/roles/[id]/menus/route.ts +73 -0
- package/resources/src/app/api/roles/[id]/route.ts +96 -0
- package/resources/src/app/api/roles/route.ts +114 -0
- package/resources/src/app/api/search/route.ts +22 -0
- package/resources/src/app/api/stats/route.ts +92 -0
- package/resources/src/app/api/upload/route.ts +38 -0
- package/resources/src/app/api/users/[id]/password/route.ts +55 -0
- package/resources/src/app/api/users/[id]/route.ts +145 -0
- package/resources/src/app/api/users/route.ts +153 -0
- package/resources/src/app/api/visits/route.ts +48 -0
- package/resources/src/app/change-password/ChangePasswordForm.tsx +174 -0
- package/resources/src/app/change-password/page.tsx +19 -0
- package/resources/src/app/docs/[[...slug]]/page.tsx +56 -0
- package/resources/src/app/docs/layout.tsx +34 -0
- package/resources/src/app/docs/loading.tsx +19 -0
- package/resources/src/app/docs/not-found.tsx +25 -0
- package/resources/src/app/forgot/page.tsx +392 -0
- package/resources/src/app/global-error.tsx +75 -0
- package/resources/src/app/globals.css +235 -0
- package/resources/src/app/layout.tsx +44 -0
- package/resources/src/app/login/page.tsx +267 -0
- package/resources/src/app/page.tsx +14 -0
- package/resources/src/app/register/page.tsx +237 -0
- package/resources/src/auth.ts +215 -0
- package/resources/src/components/AiPanel.tsx +970 -0
- package/resources/src/components/AuthContext.tsx +82 -0
- package/resources/src/components/DataTable.tsx +459 -0
- package/resources/src/components/EChart.tsx +140 -0
- package/resources/src/components/FeedbackAiModal.tsx +476 -0
- package/resources/src/components/FeedbackReportModal.tsx +479 -0
- package/resources/src/components/Markdown.tsx +532 -0
- package/resources/src/components/OntologyGraph.tsx +1196 -0
- package/resources/src/components/Providers.tsx +99 -0
- package/resources/src/components/VisitTracker.tsx +89 -0
- package/resources/src/components/admin/AdminShell.tsx +749 -0
- package/resources/src/components/admin/CountBadge.tsx +67 -0
- package/resources/src/components/admin/GlobalSearch.tsx +509 -0
- package/resources/src/components/admin/InboxBell.tsx +78 -0
- package/resources/src/components/admin/VisitStats.tsx +145 -0
- package/resources/src/components/admin/menu-icons.tsx +56 -0
- package/resources/src/components/ai/AiInputForm.tsx +351 -0
- package/resources/src/components/appearance/AppearanceDrawer.tsx +268 -0
- package/resources/src/components/appearance/AppearanceProvider.tsx +160 -0
- package/resources/src/components/docs/DocArticle.tsx +106 -0
- package/resources/src/components/docs/DocToc.tsx +100 -0
- package/resources/src/components/docs/DocsChrome.tsx +259 -0
- package/resources/src/components/docs/DocsHome.tsx +209 -0
- package/resources/src/components/docs/DocsSearch.tsx +365 -0
- package/resources/src/components/docs/docs.css +1458 -0
- package/resources/src/components/feedback/AsyncButton.tsx +108 -0
- package/resources/src/components/feedback/LoadingOverlay.tsx +125 -0
- package/resources/src/components/feedback/PressableCard.tsx +92 -0
- package/resources/src/components/feedback/README.md +97 -0
- package/resources/src/components/feedback/RouteProgress.tsx +108 -0
- package/resources/src/components/feedback/Skeleton.tsx +249 -0
- package/resources/src/components/feedback/StatCard.tsx +70 -0
- package/resources/src/components/feedback/TaskHint.tsx +153 -0
- package/resources/src/components/feedback/index.ts +93 -0
- package/resources/src/components/feedback/motion.css +204 -0
- package/resources/src/components/feedback/motion.ts +63 -0
- package/resources/src/components/feedback/useCountUp.ts +110 -0
- package/resources/src/components/feedback/usePending.ts +209 -0
- package/resources/src/components/feedback/useRowFlash.ts +40 -0
- package/resources/src/components/inbox/InboxView.tsx +409 -0
- package/resources/src/components/ui/button.tsx +35 -0
- package/resources/src/components/ui/card.tsx +37 -0
- package/resources/src/components/ui/input.tsx +19 -0
- package/resources/src/lib/ai.ts +310 -0
- package/resources/src/lib/aiContext.ts +357 -0
- package/resources/src/lib/aiForm.test.ts +191 -0
- package/resources/src/lib/aiForm.ts +532 -0
- package/resources/src/lib/aiFormTypes.ts +83 -0
- package/resources/src/lib/aiToken.ts +72 -0
- package/resources/src/lib/aiTools.ts +823 -0
- package/resources/src/lib/api.ts +160 -0
- package/resources/src/lib/appInfo.ts +128 -0
- package/resources/src/lib/appearance.ts +643 -0
- package/resources/src/lib/badge-count.ts +146 -0
- package/resources/src/lib/badges.test.ts +58 -0
- package/resources/src/lib/badges.ts +79 -0
- package/resources/src/lib/brand-mark.test.ts +87 -0
- package/resources/src/lib/brand-mark.ts +45 -0
- package/resources/src/lib/docs-shared.test.ts +148 -0
- package/resources/src/lib/docs-shared.ts +422 -0
- package/resources/src/lib/docs.ts +381 -0
- package/resources/src/lib/err-text.ts +21 -0
- package/resources/src/lib/excel.ts +152 -0
- package/resources/src/lib/favorite-path.ts +60 -0
- package/resources/src/lib/favorites.ts +59 -0
- package/resources/src/lib/features.ts +69 -0
- package/resources/src/lib/feedback-access.ts +17 -0
- package/resources/src/lib/feedbackAi.ts +1621 -0
- package/resources/src/lib/formRules.ts +76 -0
- package/resources/src/lib/format.ts +52 -0
- package/resources/src/lib/graph-cascade.ts +304 -0
- package/resources/src/lib/graph-focus.ts +301 -0
- package/resources/src/lib/graph-link.ts +17 -0
- package/resources/src/lib/graph-node-write.ts +150 -0
- package/resources/src/lib/graph-schema.ts +475 -0
- package/resources/src/lib/graph-scope.test.ts +46 -0
- package/resources/src/lib/graph-scope.ts +28 -0
- package/resources/src/lib/http.ts +157 -0
- package/resources/src/lib/inbox-types.ts +57 -0
- package/resources/src/lib/inbox.ts +55 -0
- package/resources/src/lib/menu-service.ts +204 -0
- package/resources/src/lib/notifications.ts +113 -0
- package/resources/src/lib/office.ts +531 -0
- package/resources/src/lib/ontology.ts +277 -0
- package/resources/src/lib/openaiCompat.ts +257 -0
- package/resources/src/lib/pending.ts +98 -0
- package/resources/src/lib/prisma.ts +30 -0
- package/resources/src/lib/rbac.test.ts +106 -0
- package/resources/src/lib/rbac.ts +185 -0
- package/resources/src/lib/search-data.ts +158 -0
- package/resources/src/lib/security-questions.ts +20 -0
- package/resources/src/lib/skin-theme.ts +155 -0
- package/resources/src/lib/system-config.ts +55 -0
- package/resources/src/lib/theme.ts +96 -0
- package/resources/src/lib/todos/feedback.ts +86 -0
- package/resources/src/lib/todos/index.ts +73 -0
- package/resources/src/lib/todos/types.ts +33 -0
- package/resources/src/lib/upload.ts +106 -0
- package/resources/src/lib/utils.test.ts +9 -0
- package/resources/src/lib/utils.ts +6 -0
- package/resources/src/lib/validation.test.ts +297 -0
- package/resources/src/lib/validation.ts +658 -0
- package/resources/src/lib/visit-stats.ts +109 -0
- package/resources/src/lib/visits.ts +111 -0
- package/resources/src/lib/zodField.ts +44 -0
- package/resources/tsconfig.json +41 -0
- package/resources/vitest.config.ts +16 -0
- package/resources/vitest.setup.ts +1 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
|
+
import Link from 'next/link';
|
|
5
|
+
import { useRouter } from 'next/navigation';
|
|
6
|
+
import {
|
|
7
|
+
App,
|
|
8
|
+
Badge,
|
|
9
|
+
Button,
|
|
10
|
+
Card,
|
|
11
|
+
Checkbox,
|
|
12
|
+
Col,
|
|
13
|
+
Empty,
|
|
14
|
+
Row,
|
|
15
|
+
Segmented,
|
|
16
|
+
Space,
|
|
17
|
+
Tag,
|
|
18
|
+
Typography,
|
|
19
|
+
} from 'antd';
|
|
20
|
+
import {
|
|
21
|
+
ArrowRightOutlined,
|
|
22
|
+
ClockCircleOutlined,
|
|
23
|
+
MailOutlined,
|
|
24
|
+
} from '@ant-design/icons';
|
|
25
|
+
import { iconOf } from '@/components/admin/menu-icons';
|
|
26
|
+
import { StatCard } from '@/components/feedback';
|
|
27
|
+
import { startRouteProgress } from '@/components/feedback/RouteProgress';
|
|
28
|
+
import { fmtDateTime } from '@/lib/format';
|
|
29
|
+
import { fs, MILITARY } from '@/lib/theme';
|
|
30
|
+
import type {
|
|
31
|
+
InboxData,
|
|
32
|
+
InboxNotification,
|
|
33
|
+
InboxTodoItem,
|
|
34
|
+
} from '@/lib/inbox-types';
|
|
35
|
+
|
|
36
|
+
const TYPE_LABEL: Record<string, string> = {
|
|
37
|
+
system: '系统',
|
|
38
|
+
feedback: '反馈',
|
|
39
|
+
approval: '审批',
|
|
40
|
+
business: '业务',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const LEVEL_META: Record<string, { color: string; label: string }> = {
|
|
44
|
+
info: { color: 'blue', label: '通知' },
|
|
45
|
+
success: { color: 'green', label: '完成' },
|
|
46
|
+
warning: { color: 'orange', label: '提醒' },
|
|
47
|
+
error: { color: 'red', label: '异常' },
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
function todoDotColor(level: InboxTodoItem['level']): string {
|
|
51
|
+
if (level === 'error') return MILITARY.error;
|
|
52
|
+
if (level === 'warning') return MILITARY.warning;
|
|
53
|
+
return MILITARY.primary;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 待办与消息中心。
|
|
58
|
+
*
|
|
59
|
+
* 两个标签页共用一份从服务端直出的数据:
|
|
60
|
+
* - 待办:由 `src/lib/todos` 的注册表聚合,处理完业务后自动消失
|
|
61
|
+
* - 消息:站内 Notification,支持单条已读与全部已读
|
|
62
|
+
*
|
|
63
|
+
* 页面只负责展示和已读动作,不判断权限、不拼业务查询;
|
|
64
|
+
* 新模块接入待办只需要注册一个 TodoSource,不需要改这个组件。
|
|
65
|
+
*/
|
|
66
|
+
export default function InboxView({
|
|
67
|
+
data,
|
|
68
|
+
initialTab,
|
|
69
|
+
}: {
|
|
70
|
+
data: InboxData;
|
|
71
|
+
initialTab: 'todos' | 'messages';
|
|
72
|
+
}) {
|
|
73
|
+
const { message } = App.useApp();
|
|
74
|
+
const router = useRouter();
|
|
75
|
+
const [tab, setTab] = useState<'todos' | 'messages'>(initialTab);
|
|
76
|
+
const [notifications, setNotifications] = useState<InboxNotification[]>(data.notifications);
|
|
77
|
+
const [unreadCount, setUnreadCount] = useState(data.summary.unreadCount);
|
|
78
|
+
const [unreadOnly, setUnreadOnly] = useState(false);
|
|
79
|
+
const [markingAll, setMarkingAll] = useState(false);
|
|
80
|
+
|
|
81
|
+
const todoCount = data.summary.todoCount;
|
|
82
|
+
|
|
83
|
+
const visibleNotifications = useMemo(
|
|
84
|
+
() => (unreadOnly ? notifications.filter((item) => !item.readAt) : notifications),
|
|
85
|
+
[notifications, unreadOnly]
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const broadcastChanged = () => {
|
|
89
|
+
window.dispatchEvent(new Event('inbox:changed'));
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const markRead = async (id: string): Promise<boolean> => {
|
|
93
|
+
try {
|
|
94
|
+
const res = await fetch('/api/inbox/read', {
|
|
95
|
+
method: 'POST',
|
|
96
|
+
headers: { 'Content-Type': 'application/json' },
|
|
97
|
+
body: JSON.stringify({ id }),
|
|
98
|
+
});
|
|
99
|
+
const json = (await res.json()) as {
|
|
100
|
+
code?: number;
|
|
101
|
+
data?: { unread?: number };
|
|
102
|
+
message?: string;
|
|
103
|
+
};
|
|
104
|
+
if (json?.code !== 0) throw new Error(json?.message || '标记已读失败');
|
|
105
|
+
|
|
106
|
+
setNotifications((prev) =>
|
|
107
|
+
prev.map((item) => (item.id === id && !item.readAt ? { ...item, readAt: new Date().toISOString() } : item))
|
|
108
|
+
);
|
|
109
|
+
setUnreadCount((prev) =>
|
|
110
|
+
Number.isFinite(json.data?.unread) ? Number(json.data?.unread) : Math.max(0, prev - 1)
|
|
111
|
+
);
|
|
112
|
+
broadcastChanged();
|
|
113
|
+
return true;
|
|
114
|
+
} catch (e) {
|
|
115
|
+
message.error((e as Error).message);
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const openNotification = async (item: InboxNotification) => {
|
|
121
|
+
if (!item.readAt) await markRead(item.id);
|
|
122
|
+
if (item.link) {
|
|
123
|
+
startRouteProgress();
|
|
124
|
+
router.push(item.link);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const markAllRead = async () => {
|
|
129
|
+
if (markingAll || unreadCount === 0) return;
|
|
130
|
+
setMarkingAll(true);
|
|
131
|
+
try {
|
|
132
|
+
const res = await fetch('/api/inbox/read', {
|
|
133
|
+
method: 'POST',
|
|
134
|
+
headers: { 'Content-Type': 'application/json' },
|
|
135
|
+
body: JSON.stringify({ all: true }),
|
|
136
|
+
});
|
|
137
|
+
const json = (await res.json()) as { code?: number; message?: string };
|
|
138
|
+
if (json?.code !== 0) throw new Error(json?.message || '操作失败');
|
|
139
|
+
|
|
140
|
+
const now = new Date().toISOString();
|
|
141
|
+
setNotifications((prev) => prev.map((item) => (item.readAt ? item : { ...item, readAt: now })));
|
|
142
|
+
setUnreadCount(0);
|
|
143
|
+
setUnreadOnly(false);
|
|
144
|
+
broadcastChanged();
|
|
145
|
+
message.success('已全部标为已读');
|
|
146
|
+
} catch (e) {
|
|
147
|
+
message.error((e as Error).message);
|
|
148
|
+
} finally {
|
|
149
|
+
setMarkingAll(false);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<div data-testid="inbox-page">
|
|
155
|
+
<div
|
|
156
|
+
style={{
|
|
157
|
+
display: 'flex',
|
|
158
|
+
alignItems: 'flex-start',
|
|
159
|
+
justifyContent: 'space-between',
|
|
160
|
+
gap: 16,
|
|
161
|
+
flexWrap: 'wrap',
|
|
162
|
+
marginBottom: 16,
|
|
163
|
+
}}
|
|
164
|
+
>
|
|
165
|
+
<div>
|
|
166
|
+
<Typography.Title level={4} style={{ margin: 0 }}>
|
|
167
|
+
待办与消息
|
|
168
|
+
</Typography.Title>
|
|
169
|
+
<Typography.Text type="secondary">
|
|
170
|
+
跨模块汇总待处理事项和站内消息;业务处理完成后,对应待办会自动消失。
|
|
171
|
+
</Typography.Text>
|
|
172
|
+
</div>
|
|
173
|
+
<Segmented
|
|
174
|
+
value={tab}
|
|
175
|
+
onChange={(value) => setTab(value as 'todos' | 'messages')}
|
|
176
|
+
options={[
|
|
177
|
+
{ value: 'todos', label: `待办 ${todoCount}` },
|
|
178
|
+
{ value: 'messages', label: `消息${unreadCount > 0 ? ` ${unreadCount}` : ''}` },
|
|
179
|
+
]}
|
|
180
|
+
/>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<Row gutter={[16, 16]}>
|
|
184
|
+
<Col xs={24} md={12}>
|
|
185
|
+
<StatCard
|
|
186
|
+
title="待办事项"
|
|
187
|
+
value={todoCount}
|
|
188
|
+
icon={<ClockCircleOutlined />}
|
|
189
|
+
color={MILITARY.warning}
|
|
190
|
+
onPress={() => setTab('todos')}
|
|
191
|
+
/>
|
|
192
|
+
</Col>
|
|
193
|
+
<Col xs={24} md={12}>
|
|
194
|
+
<StatCard
|
|
195
|
+
title="未读消息"
|
|
196
|
+
value={unreadCount}
|
|
197
|
+
icon={<MailOutlined />}
|
|
198
|
+
color={MILITARY.primary}
|
|
199
|
+
onPress={() => setTab('messages')}
|
|
200
|
+
/>
|
|
201
|
+
</Col>
|
|
202
|
+
</Row>
|
|
203
|
+
|
|
204
|
+
<div style={{ marginTop: 16 }}>
|
|
205
|
+
{tab === 'todos' ? (
|
|
206
|
+
data.todoGroups.length === 0 ? (
|
|
207
|
+
<Card>
|
|
208
|
+
<Empty description="当前没有待办" />
|
|
209
|
+
</Card>
|
|
210
|
+
) : (
|
|
211
|
+
<Space orientation="vertical" size={16} style={{ width: '100%' }}>
|
|
212
|
+
{data.todoGroups.map((group) => (
|
|
213
|
+
<Card
|
|
214
|
+
key={group.key}
|
|
215
|
+
title={
|
|
216
|
+
<Space size={8}>
|
|
217
|
+
<span style={{ color: MILITARY.primary }}>{iconOf(group.icon)}</span>
|
|
218
|
+
<span>{group.name}</span>
|
|
219
|
+
<Tag color="warning">{group.count}</Tag>
|
|
220
|
+
</Space>
|
|
221
|
+
}
|
|
222
|
+
extra={
|
|
223
|
+
group.count > group.items.length ? (
|
|
224
|
+
<Typography.Text type="secondary" style={{ fontSize: fs(12) }}>
|
|
225
|
+
共 {group.count} 条,显示最近 {group.items.length} 条
|
|
226
|
+
</Typography.Text>
|
|
227
|
+
) : null
|
|
228
|
+
}
|
|
229
|
+
>
|
|
230
|
+
{group.description && (
|
|
231
|
+
<Typography.Paragraph type="secondary" style={{ marginTop: 0 }}>
|
|
232
|
+
{group.description}
|
|
233
|
+
</Typography.Paragraph>
|
|
234
|
+
)}
|
|
235
|
+
{group.items.length === 0 ? (
|
|
236
|
+
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无待办" />
|
|
237
|
+
) : (
|
|
238
|
+
<div>
|
|
239
|
+
{group.items.map((item, index) => (
|
|
240
|
+
<Link
|
|
241
|
+
key={item.id}
|
|
242
|
+
href={item.link}
|
|
243
|
+
onClick={() => startRouteProgress()}
|
|
244
|
+
style={{
|
|
245
|
+
display: 'flex',
|
|
246
|
+
alignItems: 'flex-start',
|
|
247
|
+
gap: 12,
|
|
248
|
+
padding: '12px 10px',
|
|
249
|
+
borderTop: index === 0 ? 'none' : `1px solid ${MILITARY.borderSoft}`,
|
|
250
|
+
color: 'inherit',
|
|
251
|
+
textDecoration: 'none',
|
|
252
|
+
}}
|
|
253
|
+
>
|
|
254
|
+
<span
|
|
255
|
+
style={{
|
|
256
|
+
display: 'inline-block',
|
|
257
|
+
width: 8,
|
|
258
|
+
height: 8,
|
|
259
|
+
borderRadius: '50%',
|
|
260
|
+
background: todoDotColor(item.level),
|
|
261
|
+
marginTop: 7,
|
|
262
|
+
flex: '0 0 8px',
|
|
263
|
+
}}
|
|
264
|
+
/>
|
|
265
|
+
<span style={{ flex: 1, minWidth: 0 }}>
|
|
266
|
+
<span
|
|
267
|
+
style={{
|
|
268
|
+
display: 'block',
|
|
269
|
+
fontSize: fs(13.5),
|
|
270
|
+
fontWeight: 600,
|
|
271
|
+
color: MILITARY.text,
|
|
272
|
+
overflow: 'hidden',
|
|
273
|
+
textOverflow: 'ellipsis',
|
|
274
|
+
whiteSpace: 'nowrap',
|
|
275
|
+
}}
|
|
276
|
+
>
|
|
277
|
+
{item.title}
|
|
278
|
+
</span>
|
|
279
|
+
<span
|
|
280
|
+
style={{
|
|
281
|
+
display: 'block',
|
|
282
|
+
marginTop: 3,
|
|
283
|
+
fontSize: fs(12.5),
|
|
284
|
+
color: MILITARY.textMuted,
|
|
285
|
+
}}
|
|
286
|
+
>
|
|
287
|
+
{item.subtitle}
|
|
288
|
+
{item.createdAt ? ` · ${fmtDateTime(item.createdAt)}` : ''}
|
|
289
|
+
</span>
|
|
290
|
+
</span>
|
|
291
|
+
<span
|
|
292
|
+
style={{
|
|
293
|
+
flex: '0 0 auto',
|
|
294
|
+
marginTop: 2,
|
|
295
|
+
fontSize: fs(12.5),
|
|
296
|
+
color: MILITARY.primary,
|
|
297
|
+
whiteSpace: 'nowrap',
|
|
298
|
+
}}
|
|
299
|
+
>
|
|
300
|
+
去处理 <ArrowRightOutlined style={{ fontSize: fs(10) }} />
|
|
301
|
+
</span>
|
|
302
|
+
</Link>
|
|
303
|
+
))}
|
|
304
|
+
</div>
|
|
305
|
+
)}
|
|
306
|
+
</Card>
|
|
307
|
+
))}
|
|
308
|
+
</Space>
|
|
309
|
+
)
|
|
310
|
+
) : (
|
|
311
|
+
<Card
|
|
312
|
+
title={
|
|
313
|
+
<Space size={8}>
|
|
314
|
+
<MailOutlined style={{ color: MILITARY.primary }} />
|
|
315
|
+
<span>站内消息</span>
|
|
316
|
+
<Tag>{notifications.length}</Tag>
|
|
317
|
+
</Space>
|
|
318
|
+
}
|
|
319
|
+
extra={
|
|
320
|
+
<Space size={12} wrap>
|
|
321
|
+
<Checkbox
|
|
322
|
+
checked={unreadOnly}
|
|
323
|
+
onChange={(e) => setUnreadOnly(e.target.checked)}
|
|
324
|
+
>
|
|
325
|
+
只看未读
|
|
326
|
+
</Checkbox>
|
|
327
|
+
<Button
|
|
328
|
+
size="small"
|
|
329
|
+
loading={markingAll}
|
|
330
|
+
disabled={unreadCount === 0}
|
|
331
|
+
onClick={() => void markAllRead()}
|
|
332
|
+
>
|
|
333
|
+
全部已读
|
|
334
|
+
</Button>
|
|
335
|
+
</Space>
|
|
336
|
+
}
|
|
337
|
+
>
|
|
338
|
+
{visibleNotifications.length === 0 ? (
|
|
339
|
+
<Empty description={unreadOnly ? '没有未读消息' : '还没有站内消息'} />
|
|
340
|
+
) : (
|
|
341
|
+
<div>
|
|
342
|
+
{visibleNotifications.map((item) => {
|
|
343
|
+
const level = LEVEL_META[item.level] ?? LEVEL_META.info;
|
|
344
|
+
const type = TYPE_LABEL[item.type] ?? item.type;
|
|
345
|
+
return (
|
|
346
|
+
<div
|
|
347
|
+
key={item.id}
|
|
348
|
+
role="button"
|
|
349
|
+
tabIndex={0}
|
|
350
|
+
onClick={() => void openNotification(item)}
|
|
351
|
+
onKeyDown={(e) => {
|
|
352
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
353
|
+
e.preventDefault();
|
|
354
|
+
void openNotification(item);
|
|
355
|
+
}
|
|
356
|
+
}}
|
|
357
|
+
style={{
|
|
358
|
+
display: 'flex',
|
|
359
|
+
alignItems: 'flex-start',
|
|
360
|
+
gap: 12,
|
|
361
|
+
cursor: 'pointer',
|
|
362
|
+
background: item.readAt ? MILITARY.card : MILITARY.soft,
|
|
363
|
+
border: `1px solid ${item.readAt ? MILITARY.borderSoft : MILITARY.softStrong}`,
|
|
364
|
+
borderRadius: 9,
|
|
365
|
+
padding: '12px 14px',
|
|
366
|
+
marginBottom: 8,
|
|
367
|
+
}}
|
|
368
|
+
>
|
|
369
|
+
<Badge
|
|
370
|
+
status={item.readAt ? 'default' : 'processing'}
|
|
371
|
+
style={{ marginTop: 4 }}
|
|
372
|
+
/>
|
|
373
|
+
<div style={{ flex: 1, minWidth: 0 }}>
|
|
374
|
+
<Space size={8} wrap>
|
|
375
|
+
<span style={{ fontWeight: item.readAt ? 500 : 650, color: MILITARY.text }}>
|
|
376
|
+
{item.title}
|
|
377
|
+
</span>
|
|
378
|
+
<Tag color={level.color}>{level.label}</Tag>
|
|
379
|
+
<span style={{ fontSize: fs(11.5), color: MILITARY.textMuted }}>{type}</span>
|
|
380
|
+
</Space>
|
|
381
|
+
{item.body && (
|
|
382
|
+
<div
|
|
383
|
+
style={{
|
|
384
|
+
whiteSpace: 'pre-wrap',
|
|
385
|
+
marginTop: 5,
|
|
386
|
+
fontSize: fs(13),
|
|
387
|
+
lineHeight: 1.7,
|
|
388
|
+
color: MILITARY.textSecondary,
|
|
389
|
+
}}
|
|
390
|
+
>
|
|
391
|
+
{item.body}
|
|
392
|
+
</div>
|
|
393
|
+
)}
|
|
394
|
+
<div style={{ fontSize: fs(12), color: MILITARY.textMuted, marginTop: 6 }}>
|
|
395
|
+
{fmtDateTime(item.createdAt)}
|
|
396
|
+
{item.link ? ' · 点击查看详情' : ''}
|
|
397
|
+
</div>
|
|
398
|
+
</div>
|
|
399
|
+
</div>
|
|
400
|
+
);
|
|
401
|
+
})}
|
|
402
|
+
</div>
|
|
403
|
+
)}
|
|
404
|
+
</Card>
|
|
405
|
+
)}
|
|
406
|
+
</div>
|
|
407
|
+
</div>
|
|
408
|
+
);
|
|
409
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
4
|
+
import { cn } from '@/lib/utils';
|
|
5
|
+
|
|
6
|
+
const buttonVariants = cva(
|
|
7
|
+
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50',
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: 'bg-neutral-900 text-white hover:bg-neutral-800',
|
|
12
|
+
outline: 'border border-neutral-300 bg-white hover:bg-neutral-100',
|
|
13
|
+
ghost: 'hover:bg-neutral-100',
|
|
14
|
+
},
|
|
15
|
+
size: { default: 'h-9 px-4 py-2', sm: 'h-8 px-3', lg: 'h-10 px-6' },
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: { variant: 'default', size: 'default' },
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export interface ButtonProps
|
|
22
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
23
|
+
VariantProps<typeof buttonVariants> {
|
|
24
|
+
asChild?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
28
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
29
|
+
const Comp = asChild ? Slot : 'button';
|
|
30
|
+
return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />;
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
Button.displayName = 'Button';
|
|
34
|
+
|
|
35
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { cn } from '@/lib/utils';
|
|
3
|
+
|
|
4
|
+
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
5
|
+
({ className, ...props }, ref) => (
|
|
6
|
+
<div ref={ref} className={cn('rounded-xl border border-neutral-200 bg-white shadow-sm', className)} {...props} />
|
|
7
|
+
)
|
|
8
|
+
);
|
|
9
|
+
Card.displayName = 'Card';
|
|
10
|
+
|
|
11
|
+
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
12
|
+
({ className, ...props }, ref) => (
|
|
13
|
+
<div ref={ref} className={cn('flex flex-col space-y-1.5 p-6', className)} {...props} />
|
|
14
|
+
)
|
|
15
|
+
);
|
|
16
|
+
CardHeader.displayName = 'CardHeader';
|
|
17
|
+
|
|
18
|
+
const CardTitle = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
19
|
+
({ className, ...props }, ref) => (
|
|
20
|
+
<div ref={ref} className={cn('font-semibold leading-none tracking-tight', className)} {...props} />
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
CardTitle.displayName = 'CardTitle';
|
|
24
|
+
|
|
25
|
+
const CardDescription = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
26
|
+
({ className, ...props }, ref) => (
|
|
27
|
+
<div ref={ref} className={cn('text-sm text-neutral-500', className)} {...props} />
|
|
28
|
+
)
|
|
29
|
+
);
|
|
30
|
+
CardDescription.displayName = 'CardDescription';
|
|
31
|
+
|
|
32
|
+
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
33
|
+
({ className, ...props }, ref) => <div ref={ref} className={cn('p-6 pt-0', className)} {...props} />
|
|
34
|
+
);
|
|
35
|
+
CardContent.displayName = 'CardContent';
|
|
36
|
+
|
|
37
|
+
export { Card, CardHeader, CardTitle, CardDescription, CardContent };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { cn } from '@/lib/utils';
|
|
3
|
+
|
|
4
|
+
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(
|
|
5
|
+
({ className, type, ...props }, ref) => (
|
|
6
|
+
<input
|
|
7
|
+
type={type}
|
|
8
|
+
ref={ref}
|
|
9
|
+
className={cn(
|
|
10
|
+
'flex h-9 w-full rounded-md border border-neutral-300 bg-white px-3 py-1 text-sm shadow-sm placeholder:text-neutral-400 focus-visible:outline-none focus-visible:ring-2 disabled:opacity-50',
|
|
11
|
+
className
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
|
+
);
|
|
17
|
+
Input.displayName = 'Input';
|
|
18
|
+
|
|
19
|
+
export { Input };
|