cardbuddy 0.8.0 → 0.9.1

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.
@@ -13,8 +13,8 @@
13
13
  RadioButton·CheckGroup 选择 / globalSet 等只写这里),不污染 rootScope、不触发保存
14
14
  高亮,事件代码里 `this.data.xxx` 也读这里,调试变更永不落盘。
15
15
 
16
- 注:「绑定错误」已移至底部状态栏(类 VSCode 面板),点击状态栏问题指示器在
17
- 底部弹出错误面板查看,不再作为此处的标签页。
16
+ 注:「变量绑定」已移至底部状态栏(类 VSCode 面板),点击状态栏指示器在
17
+ 底部弹出面板查看,不再作为此处的标签页。
18
18
  -->
19
19
  <template>
20
20
  <aside class="debug">
@@ -147,16 +147,18 @@
147
147
  节点属性面板:组件结构 tab 双击节点弹出(可编辑写回)。
148
148
  事件编辑已并入本面板的「事件」页签(meta 驱动),不再有独立弹层。
149
149
  -->
150
- <NodeInspector
151
- v-if="inspectingComp"
152
- :key="inspectKey"
153
- :comp="inspectingComp"
154
- :comp-names="compNames"
155
- :rt="rt"
156
- @apply="onApply"
157
- @commit="onCommit"
158
- @close="inspectingComp = null"
159
- />
150
+ <Transition name="modal">
151
+ <NodeInspector
152
+ v-if="inspectingComp"
153
+ :key="inspectKey"
154
+ :comp="inspectingComp"
155
+ :comp-names="compNames"
156
+ :rt="rt"
157
+ @apply="onApply"
158
+ @commit="onCommit"
159
+ @close="inspectingComp = null"
160
+ />
161
+ </Transition>
160
162
 
161
163
  <!--
162
164
  事件编辑弹框:点击结构树「事件」徽标时单独弹出,与属性面板解耦。
@@ -182,7 +184,7 @@
182
184
  不触发保存高亮、调试变更永不落盘。
183
185
  -->
184
186
  <!--
185
- 底部弹出面板(运行态 / 事件 / 绑定错误):Teleport 到 App 的 #app-workside-panels,
187
+ 底部弹出面板(运行态 / 事件 / 变量绑定):Teleport 到 App 的 #app-workside-panels,
186
188
  宽度贯穿中右两栏、紧贴右缘(与共同底栏同一容器机制,贴近 VSCode 底部面板)。
187
189
  defer:目标与 Teleport 同属本应用组件树,挂载时目标尚未插入 document,须等整个
188
190
  应用挂载完成后再解析(Vue 3.5+)。chrome-off 截图模式下禁用 Teleport,回落本面板内。
@@ -212,7 +214,7 @@
212
214
  中右两栏共同的底栏(贴近 VSCode 布局)。defer:目标与 Teleport 同属本应用组件树,
213
215
  挂载时目标尚未插入 document,须等整个应用挂载完成后再解析(Vue 3.5+)。
214
216
  chrome-off 截图模式下禁用 Teleport,回落到本面板内渲染(随面板一起隐藏)。
215
- 左侧「问题」指示器展示绑定错误数,点击弹出/收起错误面板;右侧展示当前卡片与卡片总数。
217
+ 左侧三枚指示器(运行态 / 变量绑定 / 事件)点击弹出或收起对应底部面板;右侧展示当前卡片与卡片总数。
216
218
  -->
217
219
  <Teleport defer to="#app-workside-bar" :disabled="chromeOff">
218
220
  <section class="statusbar">
@@ -244,17 +246,21 @@
244
246
  :title="eventStatusTitle"
245
247
  >
246
248
  <span class="statusbar__icon">{{ eventCount ? (eventErrors.length ? '⚠' : '☰') : '✓' }}</span>
247
- <span>{{ eventCount ? eventCount + ' 条事件' : '无事件' }}</span>
249
+ <span>{{ eventCount ? eventCount + ' 条事件记录' : '无事件记录' }}</span>
248
250
  </button>
249
- <!-- 本地开发服务连接状态:连接图标 + 状态文案,颜色与右上角「连接」按钮实时同步(复用 devSvcClass / devSvcTitle / devSvcLabel) -->
250
- <span
251
+ <!-- 本地开发服务连接状态:连接图标 + 状态文案,颜色与右上角「连接」按钮实时同步(复用 devSvcClass / devSvcTitle / devSvcLabel)。
252
+ 可点击:弹出 / 收起底部「服务日志」面板(实时镜像所连 cardbuddy 终端输出)。
253
+ 语义色本身已表达连接态,故不设选中态,仅 hover 提示可点。 -->
254
+ <button
251
255
  class="statusbar__item statusbar__conn"
252
256
  :class="devSvcClass"
253
- :title="devSvcTitle"
257
+ type="button"
258
+ :title="devSvcTitle + '(点击查看服务日志)'"
259
+ @click="toggleErrorPanel('svclog')"
254
260
  >
255
261
  <svg class="statusbar__conn-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><use href="#icon-link" /></svg>
256
262
  <span>{{ devSvcLabel }}</span>
257
- </span>
263
+ </button>
258
264
  <span class="statusbar__spacer"></span>
259
265
  <span class="statusbar__item statusbar__item--right">{{ cardId }}</span>
260
266
  <span class="statusbar__item statusbar__item--right">{{ cardCount }} 张卡片</span>
@@ -266,8 +272,13 @@
266
272
  <!-- 顶缘拖拽条:与竖向分隔条同规格(命中 6px / 高亮 3px),仅分割边缘触发 -->
267
273
  <div class="panelhead__edge" :class="{ 'is-dragging': panelDragging }" title="拖拽调整面板高度" @mousedown.prevent="startResize"></div>
268
274
  <div class="errpanel__head">
269
- <span class="errpanel__title">{{ errorPanel === 'event' ? '事件面板' : '绑定错误' }}</span>
270
- <!-- 事件面板:日志 / 错误 tab 并入头部单行(一次只看一类);绑定错误面板无 tab -->
275
+ <span class="errpanel__title">{{ errorPanel === 'svclog' ? '服务日志' : errorPanel === 'event' ? '事件记录' : '绑定错误记录' }}</span>
276
+ <!-- 服务日志:标题后给一枚读数(行数 + 实时态),与事件面板 tab 同一位置语言 -->
277
+ <span v-if="errorPanel === 'svclog'" class="svclog__meta">
278
+ {{ svcLogs.length }} 行<span v-if="svcLogDropped"> · 已滚动淘汰 {{ svcLogDropped }}</span>
279
+ <i class="svclog__dot" :class="svcLogLive ? 'is-live' : 'is-off'"></i>{{ svcLogLive ? '实时' : '未连接' }}
280
+ </span>
281
+ <!-- 事件面板:日志 / 错误 tab 并入头部单行(一次只看一类);变量绑定面板无 tab -->
271
282
  <div v-if="errorPanel === 'event'" class="errpanel__tabs">
272
283
  <button
273
284
  type="button"
@@ -299,14 +310,75 @@
299
310
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none"
300
311
  stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-trash" /></svg>
301
312
  </button>
313
+ <button
314
+ v-if="errorPanel === 'svclog'"
315
+ class="errpanel__iconbtn"
316
+ :class="{ 'is-done': svcCopied }"
317
+ type="button"
318
+ :disabled="!svcLogs.length"
319
+ :title="svcCopied ? '已复制' : '复制全部日志(纯文本,去 ANSI)'"
320
+ @click="copySvcLogs"
321
+ >
322
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2" /><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" /></svg>
323
+ </button>
324
+ <button
325
+ v-if="errorPanel === 'svclog'"
326
+ class="errpanel__iconbtn svclog__follow"
327
+ :class="{ 'is-on': svcLogFollow }"
328
+ type="button"
329
+ :title="svcLogFollow ? '跟随最新输出(点击暂停)' : '已暂停跟随(点击回到最新)'"
330
+ @click="toggleSvcFollow"
331
+ >
332
+ <!-- 下箭头图标:跟随最新输出 -->
333
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19" /><polyline points="19 12 12 19 5 12" /></svg>
334
+ </button>
335
+ <button
336
+ v-if="errorPanel === 'svclog'"
337
+ class="errpanel__iconbtn errpanel__clear"
338
+ type="button"
339
+ :disabled="!svcLogs.length"
340
+ title="清空面板(不影响服务端缓冲)"
341
+ @click="clearSvcLogs"
342
+ >
343
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none"
344
+ stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-trash" /></svg>
345
+ </button>
302
346
  <button class="errpanel__iconbtn errpanel__close" type="button" title="关闭" @click="errorPanel = ''">
303
347
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="5" x2="19" y2="19" /><line x1="19" y1="5" x2="5" y2="19" /></svg>
304
348
  </button>
305
349
  </span>
306
350
  </div>
307
- <div class="errpanel__body">
351
+ <div
352
+ class="errpanel__body"
353
+ :class="{ 'errpanel__body--term': errorPanel === 'svclog' && svcLogs.length }"
354
+ ref="errBody"
355
+ @scroll.passive="onErrBodyScroll"
356
+ >
357
+ <!-- 服务日志面板:本地服务(cardbuddy)终端输出的实时镜像。
358
+ 服务端按行镜像 stdout/stderr 并保留原始 ANSI,这里经 preview/ansi.js 还原配色,
359
+ 因此面板固定深色终端底(chalk 调色板取自深色令牌,浅底不可读)。 -->
360
+ <template v-if="errorPanel === 'svclog'">
361
+ <div v-if="!svcLogs.length" class="empty-state">
362
+ <span class="empty-state__badge" aria-hidden="true">
363
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
364
+ <polyline points="4 17 10 11 4 5" />
365
+ <line x1="12" y1="19" x2="20" y2="19" />
366
+ </svg>
367
+ </span>
368
+ <p class="debug__empty">{{ svcEmptyText }}</p>
369
+ <p class="empty-state__hint">{{ svcEmptyHint }}</p>
370
+ </div>
371
+ <div v-else class="svclog">
372
+ <div
373
+ v-for="row in svcLogs"
374
+ :key="row.seq || row.t"
375
+ class="svclog__line"
376
+ :class="'svclog__line--' + row.level"
377
+ ><span class="svclog__text" v-html="row.html"></span></div>
378
+ </div>
379
+ </template>
308
380
  <!-- 事件面板:按当前 tab 只渲染日志或错误一类 -->
309
- <template v-if="errorPanel === 'event'">
381
+ <template v-else-if="errorPanel === 'event'">
310
382
  <template v-if="eventTab === 'log'">
311
383
  <!-- 空状态占位:与 API 调用面板同款(虚线徽章 + 线性图标 + 文案 + 弱提示) -->
312
384
  <div v-if="!logs.length" class="empty-state">
@@ -353,7 +425,7 @@
353
425
  </ul>
354
426
  </template>
355
427
  </template>
356
- <!-- 绑定错误面板:仅错误列表 -->
428
+ <!-- 变量绑定面板:仅错误列表 -->
357
429
  <template v-else>
358
430
  <div v-if="!panelErrors.length" class="empty-state">
359
431
  <span class="empty-state__badge" aria-hidden="true">
@@ -394,7 +466,38 @@ import { nodeClipboard } from '@/runtime/clipboard-node.js'
394
466
  import { CodeJar } from 'codejar'
395
467
  import Prism from 'prismjs'
396
468
  import 'prismjs/components/prism-json'
397
- import { apiFetch } from '@/api.js'
469
+ import { apiFetch, subscribeServiceLog, fetchServiceLogs } from '@/api.js'
470
+ // 服务日志面板:终端 ANSI(SGR)→ HTML,1:1 还原 cardbuddy 的 chalk 配色
471
+ import { ansiToHtml, stripAnsi } from '@/ansi.js'
472
+
473
+ /** 服务日志在前端保留的最大行数(与服务端环形缓冲同量级,超出裁剪最旧的)。 */
474
+ const SVC_MAX_LINES = 800
475
+
476
+ /**
477
+ * 行级别判定:只认 logger.js 的行首标签(HH:MM:SS.mmm INFO/OK/WARN/ERR),
478
+ * 其余输出(console.* / 第三方 / vite)统一 info,避免把卡片内容里的「错误」字样误判。
479
+ */
480
+ function svcLevelOf(plain) {
481
+ const m = /^\d{2}:\d{2}:\d{2}\.\d{3}\s+(INFO|OK\s|WARN|ERR)\b/.exec(plain)
482
+ if (m) {
483
+ const tag = m[1].trim()
484
+ return tag === 'ERR' ? 'error' : tag === 'WARN' ? 'warn' : tag === 'OK' ? 'ok' : 'info'
485
+ }
486
+ return 'info'
487
+ }
488
+
489
+ /** 服务端日志行 { seq, t, text } → 面板行(ANSI 转 HTML 只做一次,避免每次重渲染重复解析)。 */
490
+ function toSvcRow(line) {
491
+ const text = String(line && line.text != null ? line.text : '')
492
+ const plain = stripAnsi(text)
493
+ return {
494
+ seq: Number(line && line.seq) || 0,
495
+ t: Number(line && line.t) || 0,
496
+ level: svcLevelOf(plain),
497
+ plain,
498
+ html: ansiToHtml(text),
499
+ }
500
+ }
398
501
 
399
502
  // copyText 已抽到 @/runtime/clipboard.js,供 DebugPanel 与 NodeInspector 共用
400
503
 
@@ -437,6 +540,9 @@ export default {
437
540
  devSvcClass: { type: String, default: 'app__btn--warn' },
438
541
  devSvcTitle: { type: String, default: '' },
439
542
  devSvcLabel: { type: String, default: '' },
543
+ // 本地服务连接态('' | unconfigured | connecting | open | closed):
544
+ // 服务日志面板据此给出空态文案(未配置 / 连接中 / 已断开)。
545
+ devSvcConn: { type: String, default: '' },
440
546
  // 纯净截图模式(?chrome=off):禁用状态栏 Teleport,使其留在本面板内随面板隐藏
441
547
  chromeOff: { type: Boolean, default: false },
442
548
  },
@@ -444,13 +550,26 @@ export default {
444
550
  return {
445
551
  copied: false,
446
552
  copyTimer: null,
447
- // 底部错误面板模式:''(收起) | 'binding'(绑定错误) | 'event'(事件执行错误)
553
+ // 底部面板模式:''(收起) | 'binding'(变量绑定错误) | 'event'(事件日志 / 执行错误)
448
554
  errorPanel: '',
449
555
  // 事件面板内部 tab:'log'(主动日志) | 'err'(执行错误),打开面板时按是否有错误自动定位
450
556
  eventTab: 'log',
557
+ // 服务日志面板(errorPanel === 'svclog'):本地服务终端输出的实时镜像
558
+ svcLogs: [],
559
+ // 已收到的最大 seq:断线重连后用 GET /__logs?since= 精确补齐缺口
560
+ svcLogSeq: 0,
561
+ // 清空面板时记录的水位线:此后取历史不会把已清掉的行再拉回来
562
+ svcLogFloor: 0,
563
+ svcLogLive: false,
564
+ // 自动跟随最新输出;用户向上翻阅即暂停,回到底部自动恢复
565
+ svcLogFollow: true,
566
+ svcLogDropped: 0,
567
+ svcLogLoading: false,
568
+ svcLogErr: '',
569
+ svcCopied: false,
451
570
  // 运行态面板:默认收起;点击状态栏「运行态」指示器切换
452
571
  statePanelOpen: false,
453
- // 运行态 / 绑定错误 / 事件 三个底部面板互斥,共用同一高度变量(px);
572
+ // 运行态 / 变量绑定 / 事件 三个底部面板互斥,共用同一高度变量(px);
454
573
  // 可被顶部抓手拖拽调整,并持久化到 localStorage(cardbuddy:debug-panel-height)
455
574
  panelH: this.loadPanelH(),
456
575
  // 底部面板头部拖拽进行中:头部高亮与竖向分隔条 .is-dragging 同一语言
@@ -476,6 +595,24 @@ export default {
476
595
  }
477
596
  },
478
597
  computed: {
598
+ /** 服务日志空态标题:按连接态区分「没配 / 没连上 / 连上了但还没输出」 */
599
+ svcEmptyText() {
600
+ if (this.devSvcConn === 'unconfigured') return '未配置本地开发服务'
601
+ if (this.devSvcConn === 'open') return '暂无服务日志'
602
+ return '本地服务未连接'
603
+ },
604
+ svcEmptyHint() {
605
+ if (this.svcLogErr) {
606
+ return '取历史失败:' + this.svcLogErr + '(本地服务需升级到支持 /__logs 的 cardbuddy 版本)'
607
+ }
608
+ if (this.devSvcConn === 'unconfigured') {
609
+ return '在顶栏「连接」中配置本地开发服务地址后,这里会实时镜像该服务终端的彩色输出'
610
+ }
611
+ if (this.devSvcConn === 'open') {
612
+ return 'cardbuddy 终端的输出(含配色)会实时镜像到这里;试试同步、保存、校验或截图'
613
+ }
614
+ return '连接恢复后自动继续;服务端保留最近 ' + SVC_MAX_LINES + ' 行历史,重连不丢'
615
+ },
479
616
  // 依赖 revision,使 setData 后数据绑定实时刷新
480
617
  scopeText() {
481
618
  void this.rt.revision
@@ -513,8 +650,8 @@ export default {
513
650
  return 'is-ok'
514
651
  },
515
652
  eventStatusTitle() {
516
- if (this.eventErrors.length) return '查看事件面板(含错误)'
517
- if (this.logs.length) return '查看事件面板(含日志)'
653
+ if (this.eventErrors.length) return '查看事件(含错误)'
654
+ if (this.logs.length) return '查看事件(含日志)'
518
655
  return '无事件记录'
519
656
  },
520
657
  panelErrors() {
@@ -544,6 +681,12 @@ export default {
544
681
  },
545
682
  },
546
683
  watch: {
684
+ // 服务日志采用懒订阅:面板打开才建 SSE(浏览器对同源并发连接有限,不与
685
+ // cards-changed / code-bridge 常驻连接抢位),关闭即退订,历史由服务端缓冲补。
686
+ errorPanel(mode) {
687
+ if (mode === 'svclog') this.startSvcLog()
688
+ else this.stopSvcLog()
689
+ },
547
690
  // 切换卡片时退出 Raw 模式,避免编辑内容与新卡片数据不一致;
548
691
  // 同时关闭属性面板,避免展示旧卡片节点;并拉取导入来源元数据。
549
692
  cardId: {
@@ -587,9 +730,10 @@ export default {
587
730
  // DebugPanel 一般常驻,但保险起见卸载时销毁 CodeJar、清理可能残留的拖拽监听
588
731
  this.destroyJar()
589
732
  this.cancelResize()
733
+ this.stopSvcLog()
590
734
  },
591
735
  methods: {
592
- // 三个底部面板互斥:运行态 / 绑定错误 / 事件 不会同时出现。
736
+ // 三个底部面板互斥:运行态 / 变量绑定 / 事件 不会同时出现。
593
737
  // 点开运行态即关闭错误/事件面板。
594
738
  toggleStatePanel() {
595
739
  this.statePanelOpen = !this.statePanelOpen
@@ -606,7 +750,7 @@ export default {
606
750
  }
607
751
  },
608
752
  /**
609
- * 拖拽调整底部面板(运行态 / 绑定错误 / 事件)高度:挂在面板头部(已有 .statepanel__head /
753
+ * 拖拽调整底部面板(运行态 / 变量绑定 / 事件)高度:挂在面板头部(已有 .statepanel__head /
610
754
  * .errpanel__head,无专门拖拽节点),与预览区宽度调节同一套 mousedown 机制。
611
755
  * 在头部按下后监听 document 的 mousemove / mouseup;向上拖(clientY 减小)增大面板高度,
612
756
  * 向下拖减小,符合底部停靠面板的直觉。高度夹在 [120px, 视窗 60%],并实时同步到两个面板
@@ -804,6 +948,107 @@ export default {
804
948
  clearEventLogs() {
805
949
  this.rt.clearEventLogs()
806
950
  },
951
+ /** 打开服务日志:先补历史(含上次清空后的水位线),再建立 SSE 实时订阅。 */
952
+ async startSvcLog() {
953
+ this.svcLogFollow = true
954
+ await this.pullSvcLogHistory(0)
955
+ if (this._svcUnsub) return
956
+ this._svcUnsub = subscribeServiceLog(
957
+ (payload) => this.appendSvcLogs(payload && payload.lines),
958
+ (state) => {
959
+ this.svcLogLive = state === 'open'
960
+ // 断线重连成功后按 seq 补漏:缓冲仍在服务端,不会丢行也不会重复
961
+ if (state === 'open' && this.svcLogSeq) this.pullSvcLogHistory(this.svcLogSeq)
962
+ }
963
+ )
964
+ },
965
+ /** 关闭服务日志:退订 SSE(面板数据保留,下次打开按水位线增量补齐)。 */
966
+ stopSvcLog() {
967
+ if (this._svcUnsub) {
968
+ this._svcUnsub()
969
+ this._svcUnsub = null
970
+ }
971
+ this.svcLogLive = false
972
+ },
973
+ /**
974
+ * 拉取服务日志历史。
975
+ * @param {number} since 0 = 全量(取最新 SVC_MAX_LINES 行);>0 = 只取 seq 大于它的行
976
+ */
977
+ async pullSvcLogHistory(since) {
978
+ if (this.svcLogLoading) return
979
+ this.svcLogLoading = true
980
+ const from = Math.max(Number(since) || 0, this.svcLogFloor)
981
+ try {
982
+ const snap = await fetchServiceLogs({ limit: SVC_MAX_LINES, since: from })
983
+ this.svcLogErr = ''
984
+ if (snap && snap.enabled === false) {
985
+ this.svcLogErr = '服务端已关闭日志流(CARDBUDDY_STREAM_LOGS=0)'
986
+ } else {
987
+ this.svcLogDropped = (snap && snap.dropped) || 0
988
+ if (snap && snap.seq) this.svcLogSeq = Math.max(this.svcLogSeq, snap.seq)
989
+ const rows = ((snap && snap.lines) || []).map(toSvcRow)
990
+ // from > 0 是断线补漏:走同一条去重/裁剪/跟随逻辑,避免与实时流重叠
991
+ if (from) this.appendSvcLogs(rows)
992
+ else this.svcLogs = rows
993
+ this.scrollSvcToBottom(true)
994
+ }
995
+ } catch (e) {
996
+ this.svcLogErr = (e && e.message) || String(e)
997
+ } finally {
998
+ this.svcLogLoading = false
999
+ }
1000
+ },
1001
+ /** 追加实时行:按 seq 去重(历史与实时流可能重叠)、裁剪上限、按需跟随滚动。 */
1002
+ appendSvcLogs(lines) {
1003
+ const list = Array.isArray(lines) ? lines : []
1004
+ if (!list.length) return
1005
+ const rows = []
1006
+ for (const l of list) {
1007
+ // 既接受服务端原始行 { seq, t, text },也接受已转换好的面板行(含 html)
1008
+ const row = l && l.html != null ? l : toSvcRow(l)
1009
+ const seq = Number(row.seq) || 0
1010
+ if (seq && seq <= this.svcLogSeq) continue
1011
+ if (seq) this.svcLogSeq = seq
1012
+ rows.push(row)
1013
+ }
1014
+ if (!rows.length) return
1015
+ const next = this.svcLogs.concat(rows)
1016
+ this.svcLogs = next.length > SVC_MAX_LINES ? next.slice(next.length - SVC_MAX_LINES) : next
1017
+ if (this.svcLogFollow) this.scrollSvcToBottom()
1018
+ },
1019
+ clearSvcLogs() {
1020
+ this.svcLogFloor = this.svcLogSeq
1021
+ this.svcLogs = []
1022
+ this.svcLogDropped = 0
1023
+ },
1024
+ /** 复制全部日志为纯文本(去掉 ANSI),便于贴到工单 / IM 里排障。 */
1025
+ async copySvcLogs() {
1026
+ const ok = await copyText(this.svcLogs.map((r) => r.plain).join('\n'))
1027
+ if (!ok) return
1028
+ this.svcCopied = true
1029
+ if (this._svcCopiedTimer) clearTimeout(this._svcCopiedTimer)
1030
+ this._svcCopiedTimer = setTimeout(() => {
1031
+ this.svcCopied = false
1032
+ }, 1200)
1033
+ },
1034
+ toggleSvcFollow() {
1035
+ this.svcLogFollow = !this.svcLogFollow
1036
+ if (this.svcLogFollow) this.scrollSvcToBottom(true)
1037
+ },
1038
+ scrollSvcToBottom(force) {
1039
+ if (!force && !this.svcLogFollow) return
1040
+ this.$nextTick(() => {
1041
+ const el = this.$refs.errBody
1042
+ if (el) el.scrollTop = el.scrollHeight
1043
+ })
1044
+ },
1045
+ /** 面板体滚动:距底 24px 内视为「在底部」并恢复跟随,否则暂停(用户正在往上翻)。 */
1046
+ onErrBodyScroll() {
1047
+ if (this.errorPanel !== 'svclog') return
1048
+ const el = this.$refs.errBody
1049
+ if (!el) return
1050
+ this.svcLogFollow = el.scrollHeight - el.scrollTop - el.clientHeight < 24
1051
+ },
807
1052
  /** 日志 / 错误行首时间戳:HH:MM:SS 等宽对齐,单行多带一份定位信息 */
808
1053
  fmtTime(t) {
809
1054
  if (!t) return '--:--:--'
@@ -58,9 +58,11 @@
58
58
  </svg>
59
59
  </button>
60
60
  <div v-if="helpOpen" class="ee-help__mask" @click="helpOpen = false"></div>
61
+ <Transition name="pop">
61
62
  <div v-if="helpOpen" class="ee-help__pop" @click.stop>
62
63
  <p class="ee-help__text">{{ helpText }}</p>
63
64
  </div>
65
+ </Transition>
64
66
  </aside>
65
67
 
66
68
  <section class="ee-detail">
@@ -16,7 +16,7 @@
16
16
  -->
17
17
  <template>
18
18
  <div class="ni-overlay">
19
- <div class="ni-panel">
19
+ <div class="ni-panel modal-card">
20
20
  <div class="ni-head">
21
21
  <span class="ni-title">
22
22
  节点属性 · {{ compName }}
@@ -1,6 +1,7 @@
1
1
  <template>
2
+ <transition name="modal">
2
3
  <div v-if="visible" class="rp-mask" @click.self="$emit('close')">
3
- <div class="rp-card" role="dialog" aria-label="远端预览二维码">
4
+ <div class="rp-card modal-card" role="dialog" aria-label="远端预览二维码">
4
5
  <div class="rp-head">
5
6
  <span class="rp-title">远端预览(真机扫码)</span>
6
7
  <button class="rp-x" type="button" @click="$emit('close')" aria-label="关闭">×</button>
@@ -26,6 +27,7 @@
26
27
  </div>
27
28
  </div>
28
29
  </div>
30
+ </transition>
29
31
  </template>
30
32
 
31
33
  <script>
@@ -172,6 +172,7 @@
172
172
  <line x1="12" y1="17" x2="12" y2="17.01" />
173
173
  </svg>
174
174
  </button>
175
+ <Transition name="pop">
175
176
  <div v-if="helpOpen" class="st__help-pop" @click.stop>
176
177
  <div class="st__help-pop-head">
177
178
  <span class="st__help-pop-title">快捷键</span>
@@ -189,6 +190,7 @@
189
190
  </li>
190
191
  </ul>
191
192
  </div>
193
+ </Transition>
192
194
  </div>
193
195
  </div>
194
196
  </template>