ms-vite-plugin 1.1.14 → 1.1.16
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/mcp/tools.js +27 -17
- package/package.json +1 -1
package/dist/mcp/tools.js
CHANGED
|
@@ -371,7 +371,7 @@ function ensureDeviceLogSubscription(ip, port) {
|
|
|
371
371
|
function buildDeviceLogSnapshotText(limit, runtimeStatusLimit) {
|
|
372
372
|
const recentLogs = deviceLogSubscriptionState.logs
|
|
373
373
|
.slice(-limit)
|
|
374
|
-
.map((log) => `[${log.timestamp}] [${log.level.toUpperCase()}] ${log.message}`);
|
|
374
|
+
.map((log) => `[${formatDisplayTimestamp(log.timestamp)}] [${log.level.toUpperCase()}] ${log.message}`);
|
|
375
375
|
const recentRuntimeStatus = deviceLogSubscriptionState.runtimeStatus
|
|
376
376
|
.slice(-runtimeStatusLimit)
|
|
377
377
|
.map((entry) => formatRuntimeStatusEntry(entry));
|
|
@@ -393,6 +393,21 @@ function buildDeviceLogSnapshotText(limit, runtimeStatusLimit) {
|
|
|
393
393
|
: "无运行状态",
|
|
394
394
|
].join("\n");
|
|
395
395
|
}
|
|
396
|
+
/**
|
|
397
|
+
* 按日志页面风格格式化时间
|
|
398
|
+
* @param value ISO 时间字符串
|
|
399
|
+
* @returns 返回 `yyyy/mm/dd hh:mm:ss.xxx` 风格文本,异常时回退原值
|
|
400
|
+
* @example
|
|
401
|
+
* formatDisplayTimestamp("2026-05-07T11:34:48.776Z")
|
|
402
|
+
*/
|
|
403
|
+
function formatDisplayTimestamp(value) {
|
|
404
|
+
const date = new Date(value);
|
|
405
|
+
if (Number.isNaN(date.getTime())) {
|
|
406
|
+
return value;
|
|
407
|
+
}
|
|
408
|
+
const pad = (number, length = 2) => String(number).padStart(length, "0");
|
|
409
|
+
return `${date.getFullYear()}/${pad(date.getMonth() + 1)}/${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}`;
|
|
410
|
+
}
|
|
396
411
|
/**
|
|
397
412
|
* 将日志订阅连接状态转为中文文本
|
|
398
413
|
* @param status 原始连接状态
|
|
@@ -416,19 +431,6 @@ function formatDeviceLogSubscriptionStatus(status) {
|
|
|
416
431
|
return status;
|
|
417
432
|
}
|
|
418
433
|
}
|
|
419
|
-
/**
|
|
420
|
-
* 将 runtime_status 中的布尔值转为中文状态文本
|
|
421
|
-
* @param value 原始布尔值
|
|
422
|
-
* @returns true 返回“是”,false 返回“否”,其它情况返回“unknown”
|
|
423
|
-
* @example
|
|
424
|
-
* formatBooleanStatusText(true)
|
|
425
|
-
*/
|
|
426
|
-
function formatBooleanStatusText(value) {
|
|
427
|
-
if (typeof value === "boolean") {
|
|
428
|
-
return value ? "是" : "否";
|
|
429
|
-
}
|
|
430
|
-
return "未知";
|
|
431
|
-
}
|
|
432
434
|
/**
|
|
433
435
|
* 将 runtime_status 中的内存数值格式化为可读文本
|
|
434
436
|
* @param value 原始数值
|
|
@@ -456,9 +458,17 @@ function formatRuntimeStatusEntry(entry) {
|
|
|
456
458
|
? raw.memory
|
|
457
459
|
: {};
|
|
458
460
|
return [
|
|
459
|
-
`[${entry.timestamp}]`,
|
|
460
|
-
`UI: ${
|
|
461
|
-
|
|
461
|
+
`[${formatDisplayTimestamp(entry.timestamp)}]`,
|
|
462
|
+
`UI: ${typeof raw.isUIShowing === "boolean"
|
|
463
|
+
? raw.isUIShowing
|
|
464
|
+
? "显示中"
|
|
465
|
+
: "未显示"
|
|
466
|
+
: "未知"}`,
|
|
467
|
+
`脚本: ${typeof raw.isRunning === "boolean"
|
|
468
|
+
? raw.isRunning
|
|
469
|
+
? "运行中"
|
|
470
|
+
: "未运行"
|
|
471
|
+
: "未知"}`,
|
|
462
472
|
`总内存: ${formatRuntimeMetricText(memory.total, " MB")}`,
|
|
463
473
|
`可用: ${formatRuntimeMetricText(memory.available, " MB")}`,
|
|
464
474
|
`已用: ${formatRuntimeMetricText(memory.used, " MB")}`,
|