zen-gitsync 2.6.3 → 2.6.4
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/package.json +1 -1
- package/src/config.js +2 -1
- package/src/ui/public/assets/index-42GyTYVk.css +1 -0
- package/src/ui/public/assets/index-C-nRMJvh.js +59 -0
- package/src/ui/public/assets/{vendor-DBEYYHfT.js → vendor-DtkI0iJs.js} +11 -11
- package/src/ui/public/index.html +3 -3
- package/src/ui/server/index.js +144 -0
- package/src/ui/public/assets/index-DhhwG1j0.css +0 -1
- package/src/ui/public/assets/index-DkDsLMia.js +0 -59
package/src/ui/public/index.html
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
8
|
<title>Zen-GitSync - Git同步工具</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-C-nRMJvh.js"></script>
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-DtkI0iJs.js">
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/vendor-D9qDBEE1.css">
|
|
12
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/index-42GyTYVk.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<div id="app"></div>
|
package/src/ui/server/index.js
CHANGED
|
@@ -156,6 +156,55 @@ async function startUIServer(noOpen = false, savePort = false) {
|
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
158
|
|
|
159
|
+
// 在新终端中执行自定义命令
|
|
160
|
+
app.post('/api/exec-in-terminal', async (req, res) => {
|
|
161
|
+
try {
|
|
162
|
+
const { command } = req.body || {};
|
|
163
|
+
if (!command || typeof command !== 'string' || !command.trim()) {
|
|
164
|
+
return res.status(400).json({ success: false, error: 'command 不能为空' });
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
console.log(`在终端中执行命令: ${command}`);
|
|
168
|
+
|
|
169
|
+
// 根据操作系统选择合适的终端命令
|
|
170
|
+
let terminalCommand;
|
|
171
|
+
|
|
172
|
+
if (process.platform === 'win32') {
|
|
173
|
+
// Windows: 使用 start 命令打开新的 cmd 窗口
|
|
174
|
+
// /K 参数表示执行命令后保持窗口打开
|
|
175
|
+
terminalCommand = `start cmd /K "cd /d ${currentProjectPath} && ${command}"`;
|
|
176
|
+
} else if (process.platform === 'darwin') {
|
|
177
|
+
// macOS: 使用 osascript 打开 Terminal.app
|
|
178
|
+
const script = `tell application "Terminal" to do script "cd ${currentProjectPath} && ${command}"`;
|
|
179
|
+
terminalCommand = `osascript -e '${script}'`;
|
|
180
|
+
} else {
|
|
181
|
+
// Linux: 尝试常见的终端模拟器
|
|
182
|
+
terminalCommand = `gnome-terminal -- bash -c "cd ${currentProjectPath} && ${command}; exec bash" || xterm -e "cd ${currentProjectPath} && ${command}; bash"`;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// 执行命令打开新终端
|
|
186
|
+
const { exec } = await import('child_process');
|
|
187
|
+
exec(terminalCommand, (error, stdout, stderr) => {
|
|
188
|
+
if (error) {
|
|
189
|
+
console.error('打开终端失败:', error);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
res.json({
|
|
194
|
+
success: true,
|
|
195
|
+
message: `已在新终端中执行命令`,
|
|
196
|
+
command: command,
|
|
197
|
+
path: currentProjectPath
|
|
198
|
+
});
|
|
199
|
+
} catch (error) {
|
|
200
|
+
console.error('在终端中执行命令失败:', error);
|
|
201
|
+
res.status(500).json({
|
|
202
|
+
success: false,
|
|
203
|
+
error: `在终端中执行命令失败: ${error.message}`
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
159
208
|
// API路由
|
|
160
209
|
// 移除了 /api/status 端点,因为前端只使用 porcelain 格式
|
|
161
210
|
|
|
@@ -1397,6 +1446,101 @@ async function startUIServer(noOpen = false, savePort = false) {
|
|
|
1397
1446
|
}
|
|
1398
1447
|
})
|
|
1399
1448
|
|
|
1449
|
+
// 保存自定义命令
|
|
1450
|
+
app.post('/api/config/save-custom-command', express.json(), async (req, res) => {
|
|
1451
|
+
try {
|
|
1452
|
+
const { command } = req.body
|
|
1453
|
+
|
|
1454
|
+
if (!command || !command.name || !command.command) {
|
|
1455
|
+
return res.status(400).json({ success: false, error: '缺少必要参数' })
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
const config = await configManager.loadConfig()
|
|
1459
|
+
|
|
1460
|
+
// 确保自定义命令数组存在
|
|
1461
|
+
if (!Array.isArray(config.customCommands)) {
|
|
1462
|
+
config.customCommands = []
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
// 生成唯一ID
|
|
1466
|
+
const id = `cmd_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`
|
|
1467
|
+
const newCommand = {
|
|
1468
|
+
id,
|
|
1469
|
+
name: command.name,
|
|
1470
|
+
description: command.description || '',
|
|
1471
|
+
directory: command.directory || '',
|
|
1472
|
+
command: command.command
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
config.customCommands.push(newCommand)
|
|
1476
|
+
await configManager.saveConfig(config)
|
|
1477
|
+
|
|
1478
|
+
res.json({ success: true, command: newCommand })
|
|
1479
|
+
} catch (error) {
|
|
1480
|
+
res.status(500).json({ success: false, error: error.message })
|
|
1481
|
+
}
|
|
1482
|
+
})
|
|
1483
|
+
|
|
1484
|
+
// 删除自定义命令
|
|
1485
|
+
app.post('/api/config/delete-custom-command', express.json(), async (req, res) => {
|
|
1486
|
+
try {
|
|
1487
|
+
const { id } = req.body
|
|
1488
|
+
|
|
1489
|
+
if (!id) {
|
|
1490
|
+
return res.status(400).json({ success: false, error: '缺少命令ID参数' })
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
const config = await configManager.loadConfig()
|
|
1494
|
+
|
|
1495
|
+
if (Array.isArray(config.customCommands)) {
|
|
1496
|
+
const index = config.customCommands.findIndex(cmd => cmd.id === id)
|
|
1497
|
+
if (index !== -1) {
|
|
1498
|
+
config.customCommands.splice(index, 1)
|
|
1499
|
+
await configManager.saveConfig(config)
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
res.json({ success: true })
|
|
1504
|
+
} catch (error) {
|
|
1505
|
+
res.status(500).json({ success: false, error: error.message })
|
|
1506
|
+
}
|
|
1507
|
+
})
|
|
1508
|
+
|
|
1509
|
+
// 更新自定义命令
|
|
1510
|
+
app.post('/api/config/update-custom-command', express.json(), async (req, res) => {
|
|
1511
|
+
try {
|
|
1512
|
+
const { id, command } = req.body
|
|
1513
|
+
|
|
1514
|
+
if (!id || !command || !command.name || !command.command) {
|
|
1515
|
+
return res.status(400).json({ success: false, error: '缺少必要参数' })
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
const config = await configManager.loadConfig()
|
|
1519
|
+
|
|
1520
|
+
if (Array.isArray(config.customCommands)) {
|
|
1521
|
+
const index = config.customCommands.findIndex(cmd => cmd.id === id)
|
|
1522
|
+
if (index !== -1) {
|
|
1523
|
+
config.customCommands[index] = {
|
|
1524
|
+
id,
|
|
1525
|
+
name: command.name,
|
|
1526
|
+
description: command.description || '',
|
|
1527
|
+
directory: command.directory || '',
|
|
1528
|
+
command: command.command
|
|
1529
|
+
}
|
|
1530
|
+
await configManager.saveConfig(config)
|
|
1531
|
+
} else {
|
|
1532
|
+
return res.status(404).json({ success: false, error: '未找到指定命令' })
|
|
1533
|
+
}
|
|
1534
|
+
} else {
|
|
1535
|
+
return res.status(404).json({ success: false, error: '命令列表不存在' })
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
res.json({ success: true })
|
|
1539
|
+
} catch (error) {
|
|
1540
|
+
res.status(500).json({ success: false, error: error.message })
|
|
1541
|
+
}
|
|
1542
|
+
})
|
|
1543
|
+
|
|
1400
1544
|
// 提交更改
|
|
1401
1545
|
app.post('/api/commit', express.json(), async (req, res) => {
|
|
1402
1546
|
try {
|