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,260 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useMemo } from 'react';
|
|
4
|
+
import { useQuery } from '@tanstack/react-query';
|
|
5
|
+
import axios from 'axios';
|
|
6
|
+
import { Alert, App, Card, Col, Row, Table, Tag, Typography } from 'antd';
|
|
7
|
+
import { HOME_STATS, HOME_WELCOME, IS_CONFIGURED } from '@/lib/appInfo';
|
|
8
|
+
import { iconOf } from '@/components/admin/menu-icons';
|
|
9
|
+
import type { ColumnsType } from 'antd/es/table';
|
|
10
|
+
import {
|
|
11
|
+
ApartmentOutlined,
|
|
12
|
+
FileTextOutlined,
|
|
13
|
+
IdcardOutlined,
|
|
14
|
+
SafetyCertificateOutlined,
|
|
15
|
+
TeamOutlined,
|
|
16
|
+
} from '@ant-design/icons';
|
|
17
|
+
import type { EChartsCoreOption } from 'echarts/core';
|
|
18
|
+
import EChart from '@/components/EChart';
|
|
19
|
+
import { StatCard } from '@/components/feedback';
|
|
20
|
+
import { fmtDateTime } from '@/lib/format';
|
|
21
|
+
import { fs, MILITARY } from '@/lib/theme';
|
|
22
|
+
import { useChartPalette, useSkinInk } from '@/components/appearance/AppearanceProvider';
|
|
23
|
+
|
|
24
|
+
type LogRow = {
|
|
25
|
+
id: string;
|
|
26
|
+
username: string | null;
|
|
27
|
+
module: string;
|
|
28
|
+
action: string;
|
|
29
|
+
path: string | null;
|
|
30
|
+
status: number;
|
|
31
|
+
createdAt: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type Stats = {
|
|
35
|
+
userCount: number;
|
|
36
|
+
roleCount: number;
|
|
37
|
+
empCount: number;
|
|
38
|
+
deptCount: number;
|
|
39
|
+
logCount: number;
|
|
40
|
+
empByDept: { name: string; value: number }[];
|
|
41
|
+
empTrend: { date: string; count: number }[];
|
|
42
|
+
genderRatio: { name: string; value: number }[];
|
|
43
|
+
recentLogs: LogRow[];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const logColumns: ColumnsType<LogRow> = [
|
|
47
|
+
{ title: '时间', dataIndex: 'createdAt', width: 180, render: (v: string) => fmtDateTime(v) },
|
|
48
|
+
{ title: '操作人', dataIndex: 'username', width: 120, render: (v: string | null) => v || '-' },
|
|
49
|
+
{ title: '模块', dataIndex: 'module', width: 120 },
|
|
50
|
+
{ title: '动作', dataIndex: 'action', width: 100 },
|
|
51
|
+
{ title: '路径', dataIndex: 'path', ellipsis: true, render: (v: string | null) => v || '-' },
|
|
52
|
+
{
|
|
53
|
+
title: '结果',
|
|
54
|
+
dataIndex: 'status',
|
|
55
|
+
width: 90,
|
|
56
|
+
render: (v: number) => (v === 1 ? <Tag color="success">成功</Tag> : <Tag color="error">失败</Tag>),
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
export default function DashboardPage() {
|
|
61
|
+
const { message } = App.useApp();
|
|
62
|
+
/** 图表不认 CSS 变量:色板与关键色都取当前皮肤的字面色 */
|
|
63
|
+
const palette = useChartPalette();
|
|
64
|
+
const ink = useSkinInk();
|
|
65
|
+
|
|
66
|
+
const { data, isLoading, isError, error } = useQuery({
|
|
67
|
+
queryKey: ['stats'],
|
|
68
|
+
queryFn: async (): Promise<Stats> => {
|
|
69
|
+
const { data } = await axios.get('/api/stats');
|
|
70
|
+
if (!data || data.code !== 0) throw new Error(data?.message || '加载失败');
|
|
71
|
+
return data.data as Stats;
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (isError) message.error(`看板数据加载失败:${(error as Error).message}`);
|
|
77
|
+
}, [isError, error, message]);
|
|
78
|
+
|
|
79
|
+
// echarts 的 option 每次都是新对象,useMemo 让图表只在数据变化时重新 setOption
|
|
80
|
+
const deptOption = useMemo<EChartsCoreOption>(
|
|
81
|
+
() => ({
|
|
82
|
+
tooltip: { trigger: 'axis' },
|
|
83
|
+
grid: { left: 48, right: 24, top: 32, bottom: 48 },
|
|
84
|
+
xAxis: {
|
|
85
|
+
type: 'category',
|
|
86
|
+
data: (data?.empByDept ?? []).map((d) => d.name),
|
|
87
|
+
axisLabel: { interval: 0 },
|
|
88
|
+
},
|
|
89
|
+
yAxis: { type: 'value', minInterval: 1 },
|
|
90
|
+
series: [
|
|
91
|
+
{
|
|
92
|
+
type: 'bar',
|
|
93
|
+
data: (data?.empByDept ?? []).map((d) => d.value),
|
|
94
|
+
barMaxWidth: 42,
|
|
95
|
+
itemStyle: { borderRadius: [4, 4, 0, 0], color: ink.primary },
|
|
96
|
+
label: { show: true, position: 'top' },
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
}),
|
|
100
|
+
[data?.empByDept, ink]
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const genderOption = useMemo<EChartsCoreOption>(
|
|
104
|
+
() => ({
|
|
105
|
+
tooltip: { trigger: 'item' },
|
|
106
|
+
color: palette,
|
|
107
|
+
legend: { bottom: 0 },
|
|
108
|
+
series: [
|
|
109
|
+
{
|
|
110
|
+
type: 'pie',
|
|
111
|
+
radius: ['45%', '70%'],
|
|
112
|
+
center: ['50%', '45%'],
|
|
113
|
+
data: data?.genderRatio ?? [],
|
|
114
|
+
label: { formatter: '{b}: {c} 人' },
|
|
115
|
+
emphasis: { itemStyle: { shadowBlur: 12, shadowColor: 'rgba(0,0,0,.25)' } },
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
}),
|
|
119
|
+
[data?.genderRatio, palette]
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const trendOption = useMemo<EChartsCoreOption>(
|
|
123
|
+
() => ({
|
|
124
|
+
tooltip: { trigger: 'axis' },
|
|
125
|
+
grid: { left: 48, right: 24, top: 32, bottom: 48 },
|
|
126
|
+
xAxis: { type: 'category', data: (data?.empTrend ?? []).map((d) => d.date) },
|
|
127
|
+
yAxis: { type: 'value', minInterval: 1 },
|
|
128
|
+
series: [
|
|
129
|
+
{
|
|
130
|
+
type: 'line',
|
|
131
|
+
smooth: true,
|
|
132
|
+
data: (data?.empTrend ?? []).map((d) => d.count),
|
|
133
|
+
areaStyle: { opacity: 0.12 },
|
|
134
|
+
itemStyle: { color: palette[1] },
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
}),
|
|
138
|
+
[data?.empTrend, palette]
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const cards = useMemo(() => {
|
|
142
|
+
// ★ 未配置(APP_NAME 还是默认值)时走脚手架自带的 5 张卡,保留下钻链接,
|
|
143
|
+
// 保证"刚解压就能演示";一旦按题目配过,就完全由 appInfo.ts 的 HOME_STATS 决定。
|
|
144
|
+
// 以前这里写死卡片、HOME_STATS 只是摆设 —— 提示词让 AI 改 appInfo,
|
|
145
|
+
// 改完首页却一点没变,check:config 还照样通过,等于白改。
|
|
146
|
+
if (!IS_CONFIGURED) {
|
|
147
|
+
return [
|
|
148
|
+
{ title: '用户总数', value: data?.userCount, icon: <TeamOutlined />, color: palette[0], href: '/system/users', suffix: undefined },
|
|
149
|
+
{ title: '角色数量', value: data?.roleCount, icon: <SafetyCertificateOutlined />, color: palette[1], href: '/system/roles', suffix: undefined },
|
|
150
|
+
{ title: '员工总数', value: data?.empCount, icon: <IdcardOutlined />, color: palette[2], href: '/demo/employees', suffix: undefined },
|
|
151
|
+
{ title: '部门数量', value: data?.deptCount, icon: <ApartmentOutlined />, color: palette[3], href: '/system/depts', suffix: undefined },
|
|
152
|
+
{ title: '操作日志', value: data?.logCount, icon: <FileTextOutlined />, color: palette[4], href: '/system/logs', suffix: undefined },
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
// 业务指标:数字按 key 从 /api/stats 取,取不到就显示 0(不编造)
|
|
156
|
+
const raw = (data ?? {}) as unknown as Record<string, number | undefined>;
|
|
157
|
+
return HOME_STATS.map((s, i) => ({
|
|
158
|
+
title: s.label,
|
|
159
|
+
value: raw[s.key],
|
|
160
|
+
icon: iconOf(s.icon),
|
|
161
|
+
color: s.color ?? palette[i % palette.length],
|
|
162
|
+
href: s.href,
|
|
163
|
+
suffix: s.suffix,
|
|
164
|
+
}));
|
|
165
|
+
}, [data, palette]);
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
|
169
|
+
{/* 页头:和 AI 中心保持同一套「小标题 + 主标题」节奏 */}
|
|
170
|
+
<div
|
|
171
|
+
style={{
|
|
172
|
+
display: 'flex',
|
|
173
|
+
alignItems: 'flex-end',
|
|
174
|
+
justifyContent: 'space-between',
|
|
175
|
+
gap: 12,
|
|
176
|
+
flexWrap: 'wrap',
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
<div>
|
|
180
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
|
181
|
+
<span style={{ width: 6, height: 6, background: MILITARY.accent, display: 'inline-block' }} />
|
|
182
|
+
<span style={{ fontSize: fs(10.5), letterSpacing: 3, color: MILITARY.textMuted, fontWeight: 600 }}>
|
|
183
|
+
OVERVIEW
|
|
184
|
+
</span>
|
|
185
|
+
</div>
|
|
186
|
+
<div style={{ fontSize: fs(20), fontWeight: 700, color: MILITARY.text, marginTop: 4 }}>工作台</div>
|
|
187
|
+
{/* 欢迎语是 appInfo 里的可配置项:填了就在标题下显示一行业务语境 */}
|
|
188
|
+
{HOME_WELCOME ? (
|
|
189
|
+
<div style={{ fontSize: fs(12), color: MILITARY.textMuted, marginTop: 4 }}>{HOME_WELCOME}</div>
|
|
190
|
+
) : null}
|
|
191
|
+
</div>
|
|
192
|
+
<div style={{ fontSize: fs(12), color: MILITARY.textMuted }}>统计口径:当前数据库全量数据</div>
|
|
193
|
+
</div>
|
|
194
|
+
{/* ★ 未配置警告:APP_NAME 还是默认值,说明还没按题目配置。
|
|
195
|
+
目的是让"忘了改"不可能被忽略。改完 appInfo.ts 后自动消失。 */}
|
|
196
|
+
{!IS_CONFIGURED && (
|
|
197
|
+
<Alert
|
|
198
|
+
type="error"
|
|
199
|
+
showIcon
|
|
200
|
+
banner
|
|
201
|
+
title="首页还是脚手架默认内容,请先配置系统身份"
|
|
202
|
+
description={
|
|
203
|
+
<div>
|
|
204
|
+
修改 <Typography.Text code>src/lib/appInfo.ts</Typography.Text>:
|
|
205
|
+
把 <Typography.Text code>APP_NAME</Typography.Text> 改成题目里的系统名、
|
|
206
|
+
<Typography.Text code>HOME_STATS</Typography.Text> 换成业务指标、
|
|
207
|
+
把本页图表换成业务相关的内容、
|
|
208
|
+
把 <Typography.Text code>SHOW_DEMO_ACCOUNT_HINT</Typography.Text> 设为 false。
|
|
209
|
+
然后运行 <Typography.Text code>npm run check:config</Typography.Text> 校验。
|
|
210
|
+
</div>
|
|
211
|
+
}
|
|
212
|
+
/>
|
|
213
|
+
)}
|
|
214
|
+
<Row gutter={[16, 16]}>
|
|
215
|
+
{cards.map((c) => (
|
|
216
|
+
<Col key={c.title} xs={12} sm={8} md={8} lg={Math.floor(24 / cards.length)} xl={Math.floor(24 / cards.length)}>
|
|
217
|
+
<StatCard
|
|
218
|
+
title={c.title}
|
|
219
|
+
value={c.value}
|
|
220
|
+
icon={c.icon}
|
|
221
|
+
color={c.color}
|
|
222
|
+
href={c.href}
|
|
223
|
+
suffix={c.suffix}
|
|
224
|
+
loading={isLoading}
|
|
225
|
+
/>
|
|
226
|
+
</Col>
|
|
227
|
+
))}
|
|
228
|
+
</Row>
|
|
229
|
+
|
|
230
|
+
<Row gutter={[16, 16]}>
|
|
231
|
+
<Col xs={24} lg={14}>
|
|
232
|
+
<Card title="各部门人数" style={{ boxShadow: MILITARY.shadowSm, border: `1px solid ${MILITARY.borderSoft}` }}>
|
|
233
|
+
<EChart option={deptOption} loading={isLoading} height={300} />
|
|
234
|
+
</Card>
|
|
235
|
+
</Col>
|
|
236
|
+
<Col xs={24} lg={10}>
|
|
237
|
+
<Card title="员工性别分布" style={{ boxShadow: MILITARY.shadowSm, border: `1px solid ${MILITARY.borderSoft}` }}>
|
|
238
|
+
<EChart option={genderOption} loading={isLoading} height={300} />
|
|
239
|
+
</Card>
|
|
240
|
+
</Col>
|
|
241
|
+
</Row>
|
|
242
|
+
|
|
243
|
+
<Card title="月度入职趋势" style={{ boxShadow: MILITARY.shadowSm, border: `1px solid ${MILITARY.borderSoft}` }}>
|
|
244
|
+
<EChart option={trendOption} loading={isLoading} height={260} />
|
|
245
|
+
</Card>
|
|
246
|
+
|
|
247
|
+
<Card title="最近操作" style={{ boxShadow: MILITARY.shadowSm, border: `1px solid ${MILITARY.borderSoft}` }}>
|
|
248
|
+
<Table<LogRow>
|
|
249
|
+
rowKey="id"
|
|
250
|
+
size="small"
|
|
251
|
+
columns={logColumns}
|
|
252
|
+
dataSource={data?.recentLogs ?? []}
|
|
253
|
+
loading={isLoading}
|
|
254
|
+
pagination={false}
|
|
255
|
+
locale={{ emptyText: '暂无操作记录' }}
|
|
256
|
+
/>
|
|
257
|
+
</Card>
|
|
258
|
+
</div>
|
|
259
|
+
);
|
|
260
|
+
}
|