Skip to content

Commit cb8750b

Browse files
committed
✨ feat(代码示例与组件优化): 更新代码示例,增加多种编程语言的示例代码;优化TabBar组件的逻辑,确保homePath对应的tab始终存在并激活;调整KeepAlive组件的样式,提升用户体验;更新系统参数管理模块,优化搜索表单和参数管理功能,提升系统灵活性和可用性。
1 parent 67270b2 commit cb8750b

29 files changed

Lines changed: 340 additions & 1282 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ dist
33
bun.lock
44
*.DS_Store
55
*.idea
6+
*.vscode
7+
*.lock

bun.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/CodeEditor/example.tsx

Lines changed: 95 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,19 @@ helloWorld();`);
3737
const [height, setHeight] = useState(400);
3838

3939
// 示例代码
40-
const sampleCodes = {
40+
const sampleCodes: Record<SupportedLanguage, string> = {
4141
javascript: `// JavaScript 示例
4242
function fibonacci(n) {
4343
if (n <= 1) return n;
4444
return fibonacci(n - 1) + fibonacci(n - 2);
45-
}
46-
47-
console.log(fibonacci(10));`,
48-
45+
}`,
4946
python: `# Python 示例
5047
def fibonacci(n):
5148
if n <= 1:
5249
return n
5350
return fibonacci(n - 1) + fibonacci(n - 2)
5451
5552
print(fibonacci(10))`,
56-
5753
java: `// Java 示例
5854
public class Fibonacci {
5955
public static int fibonacci(int n) {
@@ -65,7 +61,6 @@ public class Fibonacci {
6561
System.out.println(fibonacci(10));
6662
}
6763
}`,
68-
6964
sql: `-- SQL 示例
7065
SELECT
7166
u.user_id,
@@ -77,7 +72,6 @@ WHERE u.created_at >= '2024-01-01'
7772
GROUP BY u.user_id, u.username
7873
HAVING order_count > 0
7974
ORDER BY order_count DESC;`,
80-
8175
json: `{
8276
"name": "示例配置",
8377
"version": "1.0.0",
@@ -92,27 +86,102 @@ ORDER BY order_count DESC;`,
9286
"错误提示",
9387
"代码格式化"
9488
]
95-
},
96-
"dependencies": {
97-
"react": "^18.0.0",
98-
"typescript": "^5.0.0"
9989
}
10090
}`,
101-
10291
groovy: `// Groovy 示例
103-
class Calculator {
104-
def add(a, b) {
105-
return a + b
106-
}
107-
108-
def multiply(a, b) {
109-
return a * b
110-
}
92+
def fibonacci(n) {
93+
if (n <= 1) return n
94+
fibonacci(n - 1) + fibonacci(n - 2)
95+
}
96+
97+
println(fibonacci(10))`,
98+
typescript: `// TypeScript 示例
99+
function fibonacci(n: number): number {
100+
if (n <= 1) return n;
101+
return fibonacci(n - 1) + fibonacci(n - 2);
111102
}
112103
113-
def calc = new Calculator()
114-
println "2 + 3 = " + calc.add(2, 3)
115-
println "4 * 5 = " + calc.multiply(4, 5)`,
104+
console.log(fibonacci(10));`,
105+
html: `<!-- HTML 示例 -->
106+
<!DOCTYPE html>
107+
<html>
108+
<head>
109+
<title>示例页面</title>
110+
</head>
111+
<body>
112+
<h1>Hello, World!</h1>
113+
<p>这是一个HTML示例。</p>
114+
</body>
115+
</html>`,
116+
css: `/* CSS 示例 */
117+
body {
118+
font-family: 'Segoe UI', Arial, sans-serif;
119+
background: #f5f5f5;
120+
color: #222;
121+
}
122+
h1 {
123+
color: #1677ff;
124+
}`,
125+
xml: `<!-- XML 示例 -->
126+
<config>
127+
<name>示例配置</name>
128+
<version>1.0.0</version>
129+
<description>这是一个XML配置文件示例</description>
130+
<settings>
131+
<theme>dark</theme>
132+
<fontSize>14</fontSize>
133+
<autoSave>true</autoSave>
134+
</settings>
135+
</config>`,
136+
yaml: `# YAML 示例
137+
name: 示例配置
138+
version: 1.0.0
139+
description: 这是一个YAML配置文件示例
140+
settings:
141+
theme: dark
142+
fontSize: 14
143+
autoSave: true
144+
features:
145+
- 语法高亮
146+
- 代码补全
147+
- 错误提示`,
148+
markdown: `# Markdown 示例
149+
150+
这是一个 **Markdown** 文档示例。
151+
152+
## 功能特性
153+
154+
- 支持标题
155+
- 支持**粗体**和*斜体*
156+
- 支持代码块
157+
158+
\`\`\`javascript
159+
console.log("Hello, World!");
160+
\`\`\`
161+
162+
> 这是一个引用块`,
163+
shell: `#!/bin/bash
164+
# Shell 脚本示例
165+
166+
echo "Hello, World!"
167+
168+
# 定义变量
169+
NAME="Nexus Admin"
170+
VERSION="1.0.0"
171+
172+
# 条件判断
173+
if [ "$VERSION" = "1.0.0" ]; then
174+
echo "当前版本: $VERSION"
175+
fi
176+
177+
# 循环
178+
for i in {1..5}; do
179+
echo "循环次数: $i"
180+
done`,
181+
plaintext: `这是一个纯文本示例
182+
支持多行文本
183+
没有语法高亮
184+
适合显示日志、配置文件等内容`
116185
};
117186

118187
// 处理代码变化
@@ -218,7 +287,7 @@ println "4 * 5 = " + calc.multiply(4, 5)`,
218287
<InputNumber
219288
id={fontSizeId}
220289
value={fontSize}
221-
onChange={setFontSize}
290+
onChange={(value) => setFontSize(value || 14)}
222291
min={10}
223292
max={24}
224293
style={{ width: '100%', marginTop: '8px' }}
@@ -232,7 +301,7 @@ println "4 * 5 = " + calc.multiply(4, 5)`,
232301
<InputNumber
233302
id={heightId}
234303
value={height}
235-
onChange={setHeight}
304+
onChange={(value) => setHeight(value || 400)}
236305
min={200}
237306
max={800}
238307
style={{ width: '100%', marginTop: '8px' }}

src/components/CodeEditor/simple-test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const SimpleTest: React.FC = () => {
1515
language="javascript"
1616
theme="vs"
1717
height="300px"
18-
onChange={setCode}
18+
onChange={(value) => setCode(value || '')}
1919
placeholder="请输入 JavaScript 代码..."
2020
/>
2121
</div>

src/components/KeepAlive/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ const KeepAlive: React.FC<KeepAliveProps> = ({ children }) => {
204204
}
205205

206206
return (
207-
<div ref={containerRef} className="h-full relative flex flex-col overflow-x-hidden overflow-y-auto">
207+
<div ref={containerRef} className="h-full relative flex flex-col p-4">
208208
{currentComponent}
209209
</div>
210210
);

0 commit comments

Comments
 (0)