Skip to content

Commit ec1f807

Browse files
committed
✨ 可展开描述 & 使用 twcss 简化
1 parent 1d9c1c6 commit ec1f807

File tree

3 files changed

+98
-193
lines changed

3 files changed

+98
-193
lines changed

docs-java/start/basic/server-dir-structure.mdx

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ import { serverDirStructureData } from "@site/src/data/structures/serverDirStruc
1010

1111
我们先来简单看一眼 插件端 的文件夹结构 (以 Purpur 为例):
1212

13-
:::tip
14-
15-
将鼠标悬停在 **** 图标上查看详细说明!
16-
17-
:::
18-
1913
<StructureExplorer data={serverDirStructureData} />
2014

2115
对于类似 Catserver 的混合服务器,文件夹结构是类似的,基本就多了 `/mods` 文件夹,少了 Bukkit 的下游服务器特有的配置 (如 `purpur.yml` 等)。
@@ -26,72 +20,6 @@ import { serverDirStructureData } from "@site/src/data/structures/serverDirStruc
2620

2721
:::
2822

29-
## 根目录下的一些文件
30-
31-
- `.console_history`
32-
33-
存放了控制台 (又叫后台) 曾经使用过的指令,方便你使用键盘中的 ↑ 键快捷查找曾使用的指令,也可用于查看后台异常。
34-
35-
- `banned-ips.json`
36-
37-
以 JSON 格式存放的被 ban IP 玩家的 UUID 及游戏名称等相关信息,一旦玩家被 banip,此 IP 将无法再进入服务器。
38-
39-
- `banned-players.json`
40-
41-
以 JSON 格式存放了被 ban 玩家的 UUID 及游戏名称等相关信息,离线服 ban 玩家后换 ID 即可进入服务器,而正版服无法通过改名重新进入服务器。
42-
43-
- `bukkit.yml`
44-
45-
由 Bukkit 派生得到的服务端都有的文件。保存着 Bukkit 所提供的最基本的设置选项。
46-
47-
- `commands.yml`
48-
49-
它提供了一种快速而简单的方法来强制服务器使用 Mojang 提供的命令 (而不是 Bukkit 中内置的命令) 而不产生冲突。
50-
51-
- `eula.txt`
52-
53-
在首次开服的时候,我们需要同意 EULA 协议。
54-
55-
- `help.yml`
56-
57-
一些插件的帮助信息会出现在这里面,一般不需要进行什么修改。
58-
59-
- `ops.json`
60-
61-
以 JSON 格式存放了 OP 玩家的 UUID 及游戏名称等相关信息。
62-
63-
- `purpur.jar`
64-
65-
你可以改名叫任何名字 (只要以 `.jar` 结尾,且在启动脚本中对应修改)
66-
67-
- `purpur.yml`
68-
69-
Purpur 服务器特有的配置文件,极其详细的配置项,功能非常丰富,几乎可以替代数款插件。
70-
71-
- `permissions.yml`
72-
73-
是默认的权限定义 YAML 文件,在启动时自动生成。它的主要功能是将权限节点组合到一个文件中,以便权限插件 (以及使用权限的插件) 可以在整个系统中使用它。
74-
75-
- [`server.properties`](https://minecraft-zh.gamepedia.com/Server.properties)
76-
77-
服务端的一些基本设置就在里面,如设置端口,设置游戏难度,设置游戏模式 (生存、创造等) 等。
78-
79-
- `spigot.yml`
80-
81-
Spigot 服务器都有的配置文件。
82-
83-
- `usercache.json`
84-
85-
储存着用名字及 UUID 信息的缓存文件。
86-
87-
- `version_history`
88-
89-
一些 Minecraft 和服务端核心的版本信息,一般记录着曾经使用过的版本。
90-
91-
- `whitelist.json`
92-
93-
白名单列表。(如果你在[`server.properties`](https://minecraft-zh.gamepedia.com/Server.properties)中开启了白名单,你就可以在该文件中添加和管理谁被允许或不被允许进入服务器。)
94-
9523
至此,大部分的以 Bukkit 为基础的服务器核心服务端的结构已经大致呈现在你眼前。
9624

9725
:::tip

src/components/StructureExplorer.tsx

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const PrefixLine = ({ levels }: PrefixLineProps): JSX.Element => {
4747

4848
export default function ConfigurationStructureDiagram({ data = [] }: StructureExplorerProps = {}): JSX.Element {
4949
const [popupNode, setPopupNode] = useState<ExplorerNode | null>(null);
50+
const [showDescriptionBelow, setShowDescriptionBelow] = useState(false);
5051

5152
const renderNode = (node: ExplorerNode, level: number = 0, isLast: boolean = true, ancestors: boolean[] = []) => {
5253
const isFolder = node.type === "folder";
@@ -109,31 +110,40 @@ export default function ConfigurationStructureDiagram({ data = [] }: StructureEx
109110
<span className={"config-node-contents-wrapper"}>{node.name}</span>
110111
</span>
111112
)}
112-
{hasDescription && (
113-
<div style={{ position: "relative", display: "inline-block" }}>
114-
<span
115-
className={"config-explorer-popup-window-open-tag"}
116-
onMouseEnter={handleNodeOpening}
117-
>
118-
119-
</span>
120-
<div className={"config-explorer-popup-window-container"}>
121-
<div
122-
className={clsx(
123-
"config-explorer-popup-window",
124-
popupNode !== node && "display--none"
125-
)}
113+
{hasDescription &&
114+
(showDescriptionBelow ? null : (
115+
<div style={{ position: "relative", display: "inline-block" }}>
116+
<span
117+
className={"config-explorer-popup-window-open-tag"}
118+
onMouseEnter={handleNodeOpening}
126119
>
127-
<strong>简介:</strong>
128-
<br />
129-
{node.description}
120+
121+
</span>
122+
<div className={"config-explorer-popup-window-container"}>
123+
<div
124+
className={clsx(
125+
"config-explorer-popup-window",
126+
popupNode !== node && "display--none"
127+
)}
128+
>
129+
<strong>简介:</strong>
130+
<br />
131+
{node.description}
132+
</div>
130133
</div>
131134
</div>
132-
</div>
133-
)}
135+
))}
134136
</div>
135137
</div>
136138

139+
{showDescriptionBelow && hasDescription && (
140+
<div className="config-explorer-description-below">
141+
<PrefixLine levels={ancestors} />
142+
<span className="tree-line">{isLast ? " " : "│ "}</span>
143+
<div className="config-explorer-description-text">{node.description}</div>
144+
</div>
145+
)}
146+
137147
{hasChildren &&
138148
node.children &&
139149
node.children.map((child, index) => (
@@ -147,6 +157,29 @@ export default function ConfigurationStructureDiagram({ data = [] }: StructureEx
147157

148158
return (
149159
<div>
160+
<div style={{ marginBottom: "12px" }}>
161+
<button
162+
onClick={() => setShowDescriptionBelow(!showDescriptionBelow)}
163+
style={{
164+
padding: "6px 12px",
165+
fontSize: "14px",
166+
borderRadius: "6px",
167+
border: "1px solid",
168+
borderColor: showDescriptionBelow
169+
? "var(--ifm-color-primary)"
170+
: "var(--ifm-color-emphasis-300)",
171+
backgroundColor: showDescriptionBelow
172+
? "var(--ifm-color-primary)"
173+
: "var(--ifm-background-color)",
174+
color: showDescriptionBelow ? "white" : "var(--ifm-font-color-base)",
175+
cursor: "pointer",
176+
fontWeight: "500",
177+
transition: "all 0.2s ease"
178+
}}
179+
>
180+
{showDescriptionBelow ? "📖 隐藏说明" : "📖 显示说明"}
181+
</button>
182+
</div>
150183
<pre className={"config-explorer-code-outer-container"}>
151184
{data.map((item) => (
152185
<div key={item.name}>{renderNode(item)}</div>

src/css/structure_explorer.css

Lines changed: 46 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,105 @@
1+
@layer theme, base, components, utilities;
2+
3+
@import "tailwindcss/theme.css" layer(theme);
4+
@import "tailwindcss/utilities.css" layer(utilities);
5+
16
/* Outer Container */
27
.config-explorer-code-outer-container {
3-
overflow: visible;
4-
display: flex;
5-
flex-direction: column;
8+
@apply overflow-visible flex flex-col;
69
}
710

811
/* File Node */
912
.config-explorer-file-node {
10-
display: flex;
11-
align-items: center;
12-
border-radius: 10px;
13-
width: fit-content;
14-
flex-shrink: 0;
15-
white-space: nowrap;
16-
cursor: default;
13+
@apply flex items-center rounded-[10px] w-fit shrink-0 whitespace-nowrap cursor-default;
1714
}
1815

19-
.config-explorer-file-node-with-link {
20-
font-weight: bold;
16+
.config-explorer-file-node-with-link,
17+
.config-explorer-file-folder-node-with-link {
18+
@apply font-bold;
2119
}
2220

23-
.config-explorer-file-node-with-link:hover {
24-
background-color: rgba(0, 0, 0, 0.1);
25-
cursor: pointer;
26-
text-decoration: none;
21+
.config-explorer-file-node-with-link:hover,
22+
.config-explorer-file-folder-node-with-link:hover {
23+
@apply bg-black/10 cursor-pointer no-underline;
2724
}
2825

2926
/* File Folder Node */
3027
.config-explorer-file-folder-node {
31-
display: flex;
32-
align-items: center;
33-
width: fit-content;
28+
@apply flex items-center w-fit cursor-default no-underline;
3429
color: var(--config-node-highlight-text-color);
3530
}
3631

37-
.config-explorer-file-folder-node:hover {
38-
cursor: default;
39-
text-decoration: none;
40-
color: var(--config-node-highlight-text-color);
41-
}
42-
43-
/* File Folder Node with Link */
4432
.config-explorer-file-folder-node-with-link {
45-
font-weight: bold;
46-
color: var(--ifm-link-color);
47-
}
48-
49-
.config-explorer-file-folder-node-with-link:hover {
50-
background-color: rgba(0, 0, 0, 0.1);
51-
cursor: pointer;
52-
text-decoration: none;
5333
color: var(--ifm-link-color);
5434
}
5535

56-
/* Popup Window Container */
36+
/* Popup Window */
5737
.config-explorer-popup-window-container {
58-
position: relative;
59-
display: inline-block;
60-
vertical-align: middle;
38+
@apply relative inline-block align-middle;
6139
}
6240

63-
/* Popup Window */
6441
.config-explorer-popup-window {
42+
@apply absolute p-2.5 rounded border-0 whitespace-normal z-20;
6543
background-color: var(--config-node-popup-background-color);
66-
padding: 10px;
6744
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
68-
border-radius: 5px;
69-
margin-left: 5px;
70-
margin-top: -5px;
71-
width: max-content;
7245
min-width: 200px;
7346
max-width: 500px;
74-
z-index: 20;
75-
white-space: normal;
76-
position: absolute;
47+
width: max-content;
7748
left: 20px;
7849
top: -10px;
50+
margin-left: 5px;
51+
margin-top: -5px;
7952
}
8053

8154
.config-explorer-popup-window-open-tag {
82-
z-index: 5;
83-
margin-left: 3px;
84-
}
85-
86-
.config-explorer-popup-window-open-tag:hover {
87-
font-weight: bold;
88-
cursor: pointer;
89-
}
90-
91-
/* Tree Line Components */
92-
.tree-line {
93-
font-size: 14px;
94-
color: #bbbbbb;
95-
display: inline-block;
96-
font-family: monospace;
97-
letter-spacing: 0;
98-
line-height: 1;
55+
@apply z-5 ml-0.75 cursor-pointer font-normal hover:font-bold;
9956
}
10057

58+
/* Tree Components */
59+
.tree-line,
10160
.prefix-line {
102-
font-size: 14px;
103-
color: #bbbbbb;
104-
display: inline-block;
105-
font-family: monospace;
106-
letter-spacing: 0;
107-
line-height: 1;
61+
@apply text-sm text-slate-400 inline-block font-mono leading-none;
10862
}
10963

11064
/* Node Icon */
11165
.config-explorer-node-icon {
112-
font-size: 23px;
66+
@apply text-2xl mr-1.25;
67+
color: var(--config-node-highlight-text-color);
11368
}
11469

115-
/* Node */
116-
.config-explorer-node {
117-
align-items: flex-start;
118-
position: relative;
119-
display: flex;
120-
flex-direction: column;
121-
flex-shrink: 0;
70+
/* Node Structure */
71+
.config-explorer-node,
72+
.config-explorer-node-noflex {
73+
@apply items-start relative flex flex-col shrink-0;
74+
}
75+
76+
.config-explorer-node-noflex {
77+
@apply my-1.25;
12278
}
12379

12480
.config-explorer-node-header {
125-
display: flex;
126-
align-items: center;
127-
margin: 0;
128-
padding: 0;
81+
@apply flex items-center;
12982
}
13083

13184
.config-explorer-node-content {
132-
display: flex;
133-
align-items: center;
85+
@apply flex items-center;
13486
}
13587

136-
/* Node without Flex */
137-
.config-explorer-node-noflex {
138-
align-items: flex-start;
139-
position: relative;
140-
display: flex;
141-
flex-direction: column;
142-
margin: 5px 0 5px 0;
88+
.config-node-contents-wrapper {
89+
@apply mx-1.25 flex items-center text-base;
14390
}
14491

145-
.config-node-contents-wrapper {
146-
margin: 0 5px 0 0;
147-
display: flex;
148-
align-items: center;
149-
font-size: 15px;
92+
/* Description Below */
93+
.config-explorer-description-below {
94+
@apply flex items-start my-0.5 py-0.5 text-xs leading-relaxed;
15095
}
15196

152-
.config-explorer-icon {
153-
/* Make it go back to the original color */
154-
color: var(--config-node-highlight-text-color);
155-
margin-right: 5px;
97+
.config-explorer-description-text {
98+
@apply text-gray-400 whitespace-normal wrap-break-word flex-1;
99+
max-width: 600px;
156100
}
157101

158-
/* Display None */
102+
/* Utility */
159103
.display--none {
160-
display: none;
104+
@apply hidden;
161105
}

0 commit comments

Comments
 (0)