MegaNav.tsx
5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import { useState } from "react";
import { CloseOutlined, FolderOutlined, SettingOutlined } from "@ant-design/icons";
import { MEGA_NAV, MEGA_COLUMNS } from "@/utils/data";
interface Props {
onClose: () => void;
onOpen: (screen: string, label: string) => void;
}
export default function MegaNav({ onClose, onOpen }: Props) {
const [activeId, setActiveId] = useState<string>(
MEGA_NAV.find((s) => s.active)?.id ?? "sys"
);
const columns = MEGA_COLUMNS[activeId] ?? [];
return (
<div
style={{
position: "fixed",
inset: 0,
background: "rgba(0,0,0,0.4)",
zIndex: 100,
display: "flex",
}}
onClick={onClose}
>
<div
onClick={(e) => e.stopPropagation()}
style={{
display: "flex",
flex: 1,
background: "#fff",
margin: "60px auto",
maxWidth: 1100,
height: "calc(100% - 120px)",
border: "1px solid var(--border)",
boxShadow: "0 6px 32px rgba(0,0,0,0.3)",
}}
>
<div
style={{
width: 200,
borderRight: "1px solid var(--border)",
background: "var(--bg-app)",
overflow: "auto",
}}
>
{MEGA_NAV.map((s) => {
const active = s.id === activeId;
return (
<div
key={s.id}
onClick={() => setActiveId(s.id)}
style={{
display: "flex",
alignItems: "center",
gap: 8,
padding: "8px 12px",
fontSize: 12,
cursor: "pointer",
color: active ? "var(--accent-strong)" : "var(--text)",
background: active ? "var(--accent-soft)" : "transparent",
borderLeft: active ? "3px solid var(--accent)" : "3px solid transparent",
fontWeight: active ? 500 : 400,
}}
>
{s.id === "sys" ? <SettingOutlined /> : <FolderOutlined />}
{s.label}
</div>
);
})}
</div>
<div
style={{
flex: 1,
display: "flex",
flexDirection: "column",
overflow: "hidden",
}}
>
<div
style={{
display: "flex",
alignItems: "center",
padding: "10px 16px",
borderBottom: "1px solid var(--border)",
}}
>
<div style={{ flex: 1, fontSize: 14, fontWeight: 500 }}>
{MEGA_NAV.find((s) => s.id === activeId)?.label}
</div>
<button
onClick={onClose}
style={{
background: "transparent",
border: "none",
cursor: "pointer",
fontSize: 14,
color: "var(--text-muted)",
}}
>
<CloseOutlined />
</button>
</div>
<div
style={{
flex: 1,
overflow: "auto",
padding: 16,
display: "grid",
gridTemplateColumns: "repeat(auto-fill, minmax(200px, 1fr))",
gap: 16,
alignContent: "start",
}}
>
{columns.length === 0 && (
<div style={{ color: "var(--text-faint)", fontSize: 12 }}>
此分类暂无配置内容
</div>
)}
{columns.map((col) => (
<div key={col.title}>
<div
style={{
fontSize: 12,
fontWeight: 500,
color: "var(--text-muted)",
paddingBottom: 6,
borderBottom: "1px solid var(--border)",
marginBottom: 6,
}}
>
{col.title}
</div>
{col.items.map((it) => (
<div
key={it.label}
onClick={() => {
if (it.screen) {
onOpen(it.screen, it.label);
onClose();
}
}}
style={{
padding: "5px 6px",
fontSize: 12,
cursor: it.screen ? "pointer" : "default",
color: it.screen
? it.featured
? "var(--accent-strong)"
: "var(--text)"
: "var(--text-faint)",
fontWeight: it.featured ? 500 : 400,
borderRadius: 2,
}}
onMouseEnter={(e) => {
if (it.screen) e.currentTarget.style.background = "var(--bg-row-hover)";
}}
onMouseLeave={(e) => {
e.currentTarget.style.background = "transparent";
}}
>
{it.label}
</div>
))}
</div>
))}
</div>
</div>
</div>
</div>
);
}