xiaozuoassistant 0.2.41 → 0.2.43
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/dist/server/core/logger.js +1 -1
- package/dist/server/index.js +42 -2
- package/package.json +1 -1
|
@@ -26,7 +26,7 @@ const fileTransport = new winston.transports.DailyRotateFile({
|
|
|
26
26
|
datePattern: 'YYYY-MM-DD',
|
|
27
27
|
zippedArchive: true, // Archive old logs (gzip)
|
|
28
28
|
maxSize: '20m', // Rotate if size exceeds 20MB (optional safety)
|
|
29
|
-
maxFiles: '
|
|
29
|
+
maxFiles: '3d', // Keep logs for 3 days only
|
|
30
30
|
createSymlink: true, // Create a symlink 'app.log' pointing to current log
|
|
31
31
|
symlinkName: 'app.log',
|
|
32
32
|
level: 'info'
|
package/dist/server/index.js
CHANGED
|
@@ -206,7 +206,41 @@ app.delete('/api/sessions/:id', async (req, res) => {
|
|
|
206
206
|
// 简单的目录列举接口
|
|
207
207
|
app.post('/api/fs/list', async (req, res) => {
|
|
208
208
|
try {
|
|
209
|
-
|
|
209
|
+
let dirPath = req.body.path;
|
|
210
|
+
// 如果没有提供路径,在 Windows 上默认返回驱动器列表;在 Mac/Linux 返回根目录或 Home
|
|
211
|
+
if (!dirPath) {
|
|
212
|
+
if (process.platform === 'win32') {
|
|
213
|
+
// Windows: 返回所有可用驱动器 (A-Z)
|
|
214
|
+
try {
|
|
215
|
+
// 使用 child_process 执行 wmic 命令获取逻辑磁盘
|
|
216
|
+
const { execSync } = require('child_process');
|
|
217
|
+
const stdout = execSync('wmic logicaldisk get name').toString();
|
|
218
|
+
const drives = stdout.split('\n')
|
|
219
|
+
.map((line) => line.trim())
|
|
220
|
+
.filter((line) => line.length === 2 && line.endsWith(':'))
|
|
221
|
+
.map((drive) => drive + '\\');
|
|
222
|
+
if (drives.length > 0) {
|
|
223
|
+
return res.json({
|
|
224
|
+
current: 'PC',
|
|
225
|
+
parent: null,
|
|
226
|
+
items: drives.map((d) => ({ name: d, isDirectory: true, path: d }))
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch (e) {
|
|
231
|
+
// 如果 wmic 失败,退退为默认 C 盘
|
|
232
|
+
dirPath = 'C:\\';
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
// Mac/Linux: 默认为用户主目录
|
|
237
|
+
dirPath = require('os').homedir();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// 处理特殊情况:当当前是 Windows 的驱动器列表页面时,如果点击了某个驱动器,这里就是正常路径
|
|
241
|
+
if (dirPath === 'PC') {
|
|
242
|
+
dirPath = 'C:\\';
|
|
243
|
+
}
|
|
210
244
|
// Use fsPromises for async operations which returns proper types for withFileTypes
|
|
211
245
|
const items = await fsPromises.readdir(dirPath, { withFileTypes: true });
|
|
212
246
|
const result = items.map(item => ({
|
|
@@ -214,9 +248,15 @@ app.post('/api/fs/list', async (req, res) => {
|
|
|
214
248
|
isDirectory: item.isDirectory(),
|
|
215
249
|
path: path.join(dirPath, item.name)
|
|
216
250
|
})).filter(item => item.isDirectory && !item.name.startsWith('.')); // 仅列出目录,忽略隐藏目录
|
|
251
|
+
// 在 Windows 上,计算父目录时需要特别处理根目录 (例如 C:\ 的父目录应该是驱动器列表 'PC')
|
|
252
|
+
let parentDir = path.dirname(dirPath);
|
|
253
|
+
if (process.platform === 'win32' && parentDir === dirPath) {
|
|
254
|
+
// 如果 dirname(C:\) 还是 C:\,说明到顶了,父级应该展示磁盘列表
|
|
255
|
+
parentDir = 'PC';
|
|
256
|
+
}
|
|
217
257
|
res.json({
|
|
218
258
|
current: dirPath,
|
|
219
|
-
parent:
|
|
259
|
+
parent: parentDir,
|
|
220
260
|
items: result
|
|
221
261
|
});
|
|
222
262
|
}
|