@windypro-rourou/dsh-logcat 0.6.4 → 0.6.5

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.
Files changed (2) hide show
  1. package/lib/client.js +33 -10
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -65,6 +65,13 @@ window.__ModuleLoader__.load({
65
65
  .lc-icobtn:hover { background: light-dark(rgba(0,0,0,.06), rgba(255,255,255,.1)); }
66
66
  .lc-icobtn[data-on] { background: light-dark(rgba(66,133,244,.12), rgba(66,133,244,.22)); border-color: rgba(66,133,244,.45); color: #4285f4; }
67
67
  .lc-hit { background: rgba(66,133,244,.28); border-radius: 2px; color: inherit; }
68
+ .lc-log.compact { font-size: 11px; line-height: 15px; }
69
+ .lc-line.lw-V { border-left: 3px solid rgba(158,158,158,.35); }
70
+ .lc-line.lw-D { border-left: 3px solid #4fc3f7; }
71
+ .lc-line.lw-I { border-left: 3px solid #4caf50; }
72
+ .lc-line.lw-W { border-left: 3px solid #fbc02d; }
73
+ .lc-line.lw-E { border-left: 3px solid #ef5350; }
74
+ .lc-line.lw-F { border-left: 3px solid #ab47bc; }
68
75
  .lc-screen-img:fullscreen { background: #000; }
69
76
  .lc-toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-bottom: 1px solid light-dark(rgba(0,0,0,.1), rgba(255,255,255,.12)); flex: none; flex-wrap: wrap; }
70
77
  .lc-select, .lc-search { background: light-dark(rgba(0,0,0,.05), rgba(255,255,255,.08)); border: 1px solid light-dark(rgba(0,0,0,.16), rgba(255,255,255,.2)); border-radius: 7px; color: inherit; font: inherit; font-size: 12px; padding: 5px 9px; }
@@ -208,6 +215,7 @@ window.__ModuleLoader__.load({
208
215
  const [keyword, setKeyword] = useState("");
209
216
  const [autoScroll, setAutoScroll] = useState(true);
210
217
  const [scrollTop, setScrollTop] = useState(0);
218
+ const [rowDensity, setRowDensity] = useState(() => { try { return localStorage.getItem("dsh-logcat-density") === "compact" ? "compact" : "std"; } catch { return "std"; } });
211
219
  const [tab, setTab] = useState(() => { try { const t = localStorage.getItem("dsh-logcat-tab"); return t === "screen" || t === "re" ? t : "log"; } catch { return "log"; } });
212
220
  const switchTab = (t) => { setTab(t); try { localStorage.setItem("dsh-logcat-tab", t); } catch { /* private mode */ } };
213
221
  const [eventsOn, setEventsOn] = useState(false);
@@ -574,6 +582,15 @@ window.__ModuleLoader__.load({
574
582
  }
575
583
  };
576
584
 
585
+ // Toggle log row density (std 20px / compact 15px, remembered).
586
+ const toggleDensity = () => {
587
+ setRowDensity((prev) => {
588
+ const next = prev === "compact" ? "std" : "compact";
589
+ try { localStorage.setItem("dsh-logcat-density", next); } catch { /* private */ }
590
+ return next;
591
+ });
592
+ };
593
+
577
594
  const device = devices.find((d) => d.serial === serial);
578
595
  const deviceState = device?.state ?? "";
579
596
  const live = connected && serial !== "" && streaming.includes(serial);
@@ -945,7 +962,7 @@ window.__ModuleLoader__.load({
945
962
  h("h2", { className: "lc-title" }, "Logcat"),
946
963
  h("span", { className: "lc-dot " + (live ? "on" : connected ? "warn" : "off") }),
947
964
  h("span", { style: { fontSize: 12, color: "var(--lc-dim, #9e9e9e)" } },
948
- live ? "实机日志流中" : connected ? "未选设备" : "未连接"),
965
+ live ? "实机日志流中" : devices.length === 0 ? "无设备" : connected ? "未选设备" : "未连接"),
949
966
  h("select", {
950
967
  className: "lc-select",
951
968
  value: serial,
@@ -986,7 +1003,11 @@ window.__ModuleLoader__.load({
986
1003
  "电量 " + stats.batteryLevel + "%" + (BATTERY_STATUS[stats.batteryStatus] !== undefined ? " · " + BATTERY_STATUS[stats.batteryStatus] : ""))
987
1004
  : null,
988
1005
  spark.bat.length >= 2 ? h(Spark, { data: spark.bat, color: "#4caf50", width: 44, height: 14, title: "电量趋势" }) : null,
989
- stats === null && serial !== "" ? h("span", { className: "lc-chip" }, "正在采集设备状态…") : null,
1006
+ stats === null && serial !== "" && devices.length > 0
1007
+ ? h("span", { className: "lc-chip" }, "正在采集设备状态…")
1008
+ : devices.length === 0
1009
+ ? h("span", { className: "lc-chip" }, "无设备 — 连接后自动采集状态")
1010
+ : null,
990
1011
  ),
991
1012
  h("div", { className: "lc-tabs" },
992
1013
  h("button", { type: "button", className: "lc-tab", "data-on": tab === "log" ? "" : undefined, onClick: () => switchTab("log") }, "日志"),
@@ -1151,10 +1172,10 @@ window.__ModuleLoader__.load({
1151
1172
  : eventsOn
1152
1173
  ? (filteredEvents.length === 0
1153
1174
  ? h("div", { className: "lc-empty" }, "events 事件缓冲(已开启流,等待事件…)")
1154
- : h(VirtualLog, { entries: filteredEvents, scrollTop, onScrollTop: setScrollTop, bodyRef, keyword, onTagClick: addKeyword, onLineDblClick: copyLine }))
1175
+ : h(VirtualLog, { entries: filteredEvents, scrollTop, onScrollTop: setScrollTop, bodyRef, keyword, onTagClick: addKeyword, onLineDblClick: copyLine, rowDensity }))
1155
1176
  : (filtered.length === 0
1156
- ? h("div", { className: "lc-empty" }, paused ? "已暂停(" + entries.length + " 条已缓冲)" : "暂无日志")
1157
- : h(VirtualLog, { entries: filtered, scrollTop, onScrollTop: setScrollTop, bodyRef, keyword, onTagClick: addKeyword, onLineDblClick: copyLine })),
1177
+ ? h("div", { className: "lc-empty" }, paused ? "已暂停(" + entries.length + " 条已缓冲)" : (devices.length === 0 ? "连接设备并开启 USB 调试后自动开始…" : "暂无日志"))
1178
+ : h(VirtualLog, { entries: filtered, scrollTop, onScrollTop: setScrollTop, bodyRef, keyword, onTagClick: addKeyword, onLineDblClick: copyLine, rowDensity })),
1158
1179
  tab === "log" && !eventsOn && live && !paused
1159
1180
  ? h("button", { type: "button", className: "lc-fab", onClick: togglePause, title: "暂停:冻结当前视图(新日志进入缓冲)" }, "⏸ 暂停")
1160
1181
  : null,
@@ -1242,6 +1263,8 @@ window.__ModuleLoader__.load({
1242
1263
  deviceState === "unauthorized"
1243
1264
  ? h("span", { style: { color: "#ef5350" } }, "⚠ 设备未授权 — 请在手机上点击“允许 USB 调试”")
1244
1265
  : null,
1266
+ h("button", { type: "button", className: "lc-btn", style: { padding: "1px 6px", marginLeft: "auto" }, onClick: toggleDensity, title: "日志行密度(标准 20px / 紧凑 15px)" },
1267
+ rowDensity === "compact" ? "密集" : "标准"),
1245
1268
  ),
1246
1269
  );
1247
1270
  }
@@ -1287,9 +1310,9 @@ window.__ModuleLoader__.load({
1287
1310
  return parts;
1288
1311
  }
1289
1312
 
1290
- /** Windowed log list: fixed 20px rows, only the visible slice is rendered. */
1291
- function VirtualLog({ entries, scrollTop, onScrollTop, bodyRef, keyword, onTagClick, onLineDblClick }) {
1292
- const ROW = 20;
1313
+ /** Windowed log list: fixed rows, only the visible slice is rendered. */
1314
+ function VirtualLog({ entries, scrollTop, onScrollTop, bodyRef, keyword, onTagClick, onLineDblClick, rowDensity }) {
1315
+ const ROW = rowDensity === "compact" ? 15 : 20;
1293
1316
  const height = useRef(0);
1294
1317
  const [viewport, setViewport] = useState({ top: 0, bottom: 100 });
1295
1318
 
@@ -1325,7 +1348,7 @@ window.__ModuleLoader__.load({
1325
1348
  rows.push(
1326
1349
  h("div", {
1327
1350
  key: i,
1328
- className: "lc-line" + (e.cont === true ? " cont" : "") + (isCrash(e) ? " crash" : ""),
1351
+ className: "lc-line" + (e.cont === true ? " cont" : "") + (isCrash(e) ? " crash" : "") + (level !== " " ? " lw-" + level : ""),
1329
1352
  style: { top: i * ROW },
1330
1353
  title: e.raw + "\n(点 tag 过滤 · 双击复制该行)",
1331
1354
  onDoubleClick: () => { if (onLineDblClick) onLineDblClick(e.raw); },
@@ -1341,7 +1364,7 @@ window.__ModuleLoader__.load({
1341
1364
 
1342
1365
  return h("div",
1343
1366
  {
1344
- className: "lc-log",
1367
+ className: "lc-log" + (rowDensity === "compact" ? " compact" : ""),
1345
1368
  ref: bodyRef,
1346
1369
  onScroll: (e) => { onScrollTop(e.target.scrollTop); },
1347
1370
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@windypro-rourou/dsh-logcat",
3
3
  "description": "Android Logcat viewer for the dsh web GUI: auto-connects to any adb device in debug mode, live logcat stream with level/keyword filters, pause/clear/export, plus agent tools (logcat_recent). Hot-pluggable — mounted via ~/.dsh/cordis.patch.yml + a profile node_modules copy, no dsh source changes.",
4
- "version": "0.6.4",
4
+ "version": "0.6.5",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.22.0",
7
7
  "engines": {