@dongnanyang/deploy-cli 0.10.1 → 0.11.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.
package/dist/tui/main.js CHANGED
@@ -1,9 +1,403 @@
1
+ import { s as listProjects } from "../project-BzJoAv1l.js";
2
+ import { n as loadConfig } from "../config-xUl8Oa3T.js";
1
3
  import { t as export_helper_default } from "../export-helper-CIEcxb5I.js";
4
+ import { i as createDocker, t as checkProjectHealth } from "../health-CZL7Ghs8.js";
2
5
  import { Box, Text, createApp, useApp, useInput } from "@vue-tui/runtime";
3
- import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, openBlock, ref, renderList, toDisplayString, withCtx } from "vue";
6
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, onScopeDispose, openBlock, ref, renderList, shallowRef, toDisplayString, toValue, watch, withCtx } from "vue";
7
+ import { ScrollBox } from "@vue-tui/components";
8
+ //#region src/tui/composables/useKeymap.ts
9
+ /** 六面板(spec 6.4):键位 1-6 与数组序一一对应 */
10
+ const PANEL_IDS = [
11
+ "projects",
12
+ "containers",
13
+ "deploy",
14
+ "status",
15
+ "tunnels",
16
+ "output"
17
+ ];
18
+ /** 面板标题(骨架/状态栏共用;中文文案) */
19
+ const PANEL_TITLES = {
20
+ projects: "Projects 项目",
21
+ containers: "Containers 容器",
22
+ deploy: "Deploy 部署",
23
+ status: "Status 状态",
24
+ tunnels: "Tunnels 隧道",
25
+ output: "Output 输出"
26
+ };
27
+ /**
28
+ * 键名归一(R16 事件模型,面板/弹窗共用):text 事件取 text、key 事件取 character ?? name。
29
+ * 多字符文本(粘贴/连打)与 paste 不归一,防误触;命名键(enter/escape/up…)原样返回 name。
30
+ */
31
+ function keyName(event) {
32
+ if (event.type === "text") return event.text.length === 1 ? event.text : void 0;
33
+ if (event.type === "key") return event.key.character ?? event.key.name;
34
+ }
35
+ /** 单字符键位(dispatchKey 用):keyName 结果中只留单字符,命名键不入内 */
36
+ function keyChar(event) {
37
+ const raw = keyName(event);
38
+ return raw !== void 0 && raw.length === 1 ? raw : void 0;
39
+ }
40
+ /** 键位分发(纯函数,单测锚点):1-6 切面板、q 退出、? 帮助;其余不分发 */
41
+ function dispatchKey(event) {
42
+ const ch = keyChar(event);
43
+ if (ch === void 0) return null;
44
+ if (ch >= "1" && ch <= "6") return {
45
+ kind: "panel",
46
+ panel: PANEL_IDS[Number(ch) - 1]
47
+ };
48
+ if (ch === "q") return { kind: "quit" };
49
+ if (ch === "?") return { kind: "help" };
50
+ return null;
51
+ }
52
+ /** 模态挂载集(R17):任一确认弹窗可见 = 全局键 1-6/q/? 停用(弹窗独占 y/n/enter/escape),防按 3 静默丢弃待确认动作 / 按 q 中途退出 */
53
+ const modalTokens = /* @__PURE__ */ new Set();
54
+ const modalOpen = ref(false);
55
+ /**
56
+ * 模态登记(ConfirmModal 在 visible 时挂闸):期间 useKeymap 全局分发暂停。
57
+ * 按组件实例计数(token 随作用域释放),多弹窗/卸载不残留。
58
+ */
59
+ function useModalGate(visible) {
60
+ const token = {};
61
+ const sync = (open) => {
62
+ if (open) modalTokens.add(token);
63
+ else modalTokens.delete(token);
64
+ modalOpen.value = modalTokens.size > 0;
65
+ };
66
+ watch(() => toValue(visible), sync, { immediate: true });
67
+ onScopeDispose(() => sync(false));
68
+ }
69
+ /** 键位路由接线:useInput 订阅 → dispatchKey → 回调;组件不碰输入流本体 */
70
+ function useKeymap(handlers) {
71
+ useInput((event) => {
72
+ if (modalOpen.value) return;
73
+ const action = dispatchKey(event);
74
+ if (action === null) return;
75
+ if (action.kind === "panel") handlers.onPanel(action.panel);
76
+ else if (action.kind === "quit") handlers.onQuit();
77
+ else handlers.onHelp();
78
+ });
79
+ }
80
+ //#endregion
81
+ //#region src/tui/components/ConfirmModal.vue
82
+ /**
83
+ * 破坏性动作二次确认弹窗(spec §6.3:down/rm/restart 等 TUI 需确认)。
84
+ * 只吃 ViewModel(visible/message),动作由父组件在 confirm 事件后执行。
85
+ * 键位:y/enter 确认、n/escape 取消;不可见时不响应。
86
+ * R17:visible 期间挂模态闸——全局键 1-6/q/? 一并停用(弹窗独占输入)。
87
+ */
88
+ const _sfc_main$6 = /*@__PURE__*/ defineComponent({
89
+ __name: "ConfirmModal",
90
+ props: {
91
+ visible: {
92
+ type: Boolean,
93
+ required: true
94
+ },
95
+ message: {
96
+ type: String,
97
+ required: true
98
+ }
99
+ },
100
+ emits: ["confirm", "cancel"],
101
+ setup(__props, { expose: __expose, emit: __emit }) {
102
+ __expose();
103
+ const props = __props;
104
+ const emit = __emit;
105
+ useModalGate(() => props.visible);
106
+ useInput((event) => {
107
+ if (!props.visible) return;
108
+ const name = keyName(event);
109
+ if (name === "y" || name === "enter") emit("confirm");
110
+ else if (name === "n" || name === "escape") emit("cancel");
111
+ }, { isActive: () => props.visible });
112
+ const __returned__ = {
113
+ props,
114
+ emit,
115
+ get Box() {
116
+ return Box;
117
+ },
118
+ get Text() {
119
+ return Text;
120
+ }
121
+ };
122
+ Object.defineProperty(__returned__, "__isScriptSetup", {
123
+ enumerable: false,
124
+ value: true
125
+ });
126
+ return __returned__;
127
+ }
128
+ });
129
+ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
130
+ return $setup.props.visible ? (openBlock(), createBlock($setup["Box"], {
131
+ key: 0,
132
+ flexDirection: "column",
133
+ borderStyle: "round",
134
+ borderColor: "yellow",
135
+ padding: 1,
136
+ marginX: 1
137
+ }, {
138
+ default: withCtx(() => [
139
+ createVNode($setup["Text"], {
140
+ bold: "",
141
+ color: "yellow"
142
+ }, {
143
+ default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("⚠ 确认操作", -1)])]),
144
+ _: 1
145
+ }),
146
+ createVNode($setup["Text"], null, {
147
+ default: withCtx(() => [createTextVNode(toDisplayString($setup.props.message), 1)]),
148
+ _: 1
149
+ }),
150
+ createVNode($setup["Text"], { dimColor: "" }, {
151
+ default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("[y] 确认 / [n] 取消", -1)])]),
152
+ _: 1
153
+ })
154
+ ]),
155
+ _: 1
156
+ })) : createCommentVNode("v-if", true);
157
+ }
158
+ var ConfirmModal_default = /*#__PURE__*/ export_helper_default(_sfc_main$6, [["render", _sfc_render$6], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/ConfirmModal.vue"]]);
159
+ //#endregion
160
+ //#region src/tui/components/ContainersPanel.vue
161
+ const _sfc_main$5 = /*@__PURE__*/ defineComponent({
162
+ __name: "ContainersPanel",
163
+ props: {
164
+ rows: {
165
+ type: Array,
166
+ required: true
167
+ },
168
+ error: {
169
+ type: String,
170
+ required: false
171
+ },
172
+ following: {
173
+ type: String,
174
+ required: false
175
+ }
176
+ },
177
+ emits: [
178
+ "logs",
179
+ "restart",
180
+ "stop",
181
+ "remove",
182
+ "refresh"
183
+ ],
184
+ setup(__props, { expose: __expose, emit: __emit }) {
185
+ __expose();
186
+ const props = __props;
187
+ const emit = __emit;
188
+ const ACTION_LABEL = {
189
+ restart: "重启",
190
+ stop: "停止",
191
+ remove: "删除"
192
+ };
193
+ const sel = ref(0);
194
+ const pending = ref(null);
195
+ const confirmMessage = computed(() => pending.value === null ? "" : `确认${ACTION_LABEL[pending.value.action]}容器 ${pending.value.name}?`);
196
+ watch(() => props.rows.length, () => {
197
+ sel.value = Math.min(sel.value, Math.max(0, props.rows.length - 1));
198
+ });
199
+ useInput((event) => {
200
+ if (pending.value !== null) return;
201
+ const name = keyName(event);
202
+ if (props.rows.length === 0) return;
203
+ if (name === "j" || name === "down") sel.value = Math.min(sel.value + 1, props.rows.length - 1);
204
+ else if (name === "k" || name === "up") sel.value = Math.max(sel.value - 1, 0);
205
+ else if (name === "l") emit("logs", props.rows[sel.value].name);
206
+ else if (name === "r") pending.value = {
207
+ action: "restart",
208
+ name: props.rows[sel.value].name
209
+ };
210
+ else if (name === "s") pending.value = {
211
+ action: "stop",
212
+ name: props.rows[sel.value].name
213
+ };
214
+ else if (name === "x") pending.value = {
215
+ action: "remove",
216
+ name: props.rows[sel.value].name
217
+ };
218
+ else if (name === "f") emit("refresh");
219
+ }, { isActive: () => pending.value === null });
220
+ function onConfirm() {
221
+ const p = pending.value;
222
+ pending.value = null;
223
+ if (p === null) return;
224
+ if (p.action === "restart") emit("restart", p.name);
225
+ else if (p.action === "stop") emit("stop", p.name);
226
+ else emit("remove", p.name);
227
+ }
228
+ const __returned__ = {
229
+ props,
230
+ emit,
231
+ ACTION_LABEL,
232
+ sel,
233
+ pending,
234
+ confirmMessage,
235
+ onConfirm,
236
+ get Box() {
237
+ return Box;
238
+ },
239
+ get Text() {
240
+ return Text;
241
+ },
242
+ ConfirmModal: ConfirmModal_default
243
+ };
244
+ Object.defineProperty(__returned__, "__isScriptSetup", {
245
+ enumerable: false,
246
+ value: true
247
+ });
248
+ return __returned__;
249
+ }
250
+ });
251
+ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
252
+ return openBlock(), createBlock($setup["Box"], {
253
+ flexDirection: "column",
254
+ flexGrow: 1,
255
+ borderStyle: "round",
256
+ borderColor: "cyan",
257
+ padding: 1
258
+ }, {
259
+ default: withCtx(() => [
260
+ createVNode($setup["Text"], {
261
+ bold: "",
262
+ color: "cyan"
263
+ }, {
264
+ default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("2. Containers 容器", -1)])]),
265
+ _: 1
266
+ }),
267
+ createVNode($setup["Box"], { flexDirection: "row" }, {
268
+ default: withCtx(() => [
269
+ createVNode($setup["Box"], { width: 2 }, {
270
+ default: withCtx(() => [createVNode($setup["Text"])]),
271
+ _: 1
272
+ }),
273
+ createVNode($setup["Box"], { width: 20 }, {
274
+ default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
275
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("NAME", -1)])]),
276
+ _: 1
277
+ })]),
278
+ _: 1
279
+ }),
280
+ createVNode($setup["Box"], { width: 24 }, {
281
+ default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
282
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("IMAGE", -1)])]),
283
+ _: 1
284
+ })]),
285
+ _: 1
286
+ }),
287
+ createVNode($setup["Box"], { width: 10 }, {
288
+ default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
289
+ default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("STATE", -1)])]),
290
+ _: 1
291
+ })]),
292
+ _: 1
293
+ }),
294
+ createVNode($setup["Box"], { flexGrow: 1 }, {
295
+ default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
296
+ default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("PORTS", -1)])]),
297
+ _: 1
298
+ })]),
299
+ _: 1
300
+ })
301
+ ]),
302
+ _: 1
303
+ }),
304
+ $setup.props.error !== void 0 ? (openBlock(), createBlock($setup["Text"], {
305
+ key: 0,
306
+ color: "red"
307
+ }, {
308
+ default: withCtx(() => [createTextVNode("加载失败: " + toDisplayString($setup.props.error), 1)]),
309
+ _: 1
310
+ })) : $setup.props.rows.length === 0 ? (openBlock(), createBlock($setup["Text"], {
311
+ key: 1,
312
+ dimColor: ""
313
+ }, {
314
+ default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("(暂无容器)", -1)])]),
315
+ _: 1
316
+ })) : createCommentVNode("v-if", true),
317
+ (openBlock(true), createElementBlock(Fragment, null, renderList($setup.props.rows, (row, i) => {
318
+ return openBlock(), createBlock($setup["Box"], {
319
+ key: row.id,
320
+ flexDirection: "row"
321
+ }, {
322
+ default: withCtx(() => [
323
+ createVNode($setup["Box"], { width: 2 }, {
324
+ default: withCtx(() => [createVNode($setup["Text"], { color: i === $setup.sel ? "cyan" : void 0 }, {
325
+ default: withCtx(() => [createTextVNode(toDisplayString(i === $setup.sel ? ">" : " "), 1)]),
326
+ _: 2
327
+ }, 1032, ["color"])]),
328
+ _: 2
329
+ }, 1024),
330
+ createVNode($setup["Box"], { width: 20 }, {
331
+ default: withCtx(() => [createVNode($setup["Text"], {
332
+ wrap: "truncate",
333
+ bold: i === $setup.sel
334
+ }, {
335
+ default: withCtx(() => [createTextVNode(toDisplayString(row.name), 1)]),
336
+ _: 2
337
+ }, 1032, ["bold"])]),
338
+ _: 2
339
+ }, 1024),
340
+ createVNode($setup["Box"], { width: 24 }, {
341
+ default: withCtx(() => [createVNode($setup["Text"], { wrap: "truncate" }, {
342
+ default: withCtx(() => [createTextVNode(toDisplayString(row.image), 1)]),
343
+ _: 2
344
+ }, 1024)]),
345
+ _: 2
346
+ }, 1024),
347
+ createVNode($setup["Box"], { width: 10 }, {
348
+ default: withCtx(() => [createVNode($setup["Text"], {
349
+ wrap: "truncate",
350
+ color: row.state === "running" ? "green" : "yellow"
351
+ }, {
352
+ default: withCtx(() => [createTextVNode(toDisplayString(row.state), 1)]),
353
+ _: 2
354
+ }, 1032, ["color"])]),
355
+ _: 2
356
+ }, 1024),
357
+ createVNode($setup["Box"], { flexGrow: 1 }, {
358
+ default: withCtx(() => [createVNode($setup["Text"], {
359
+ wrap: "truncate",
360
+ dimColor: ""
361
+ }, {
362
+ default: withCtx(() => [createTextVNode(toDisplayString(row.ports), 1)]),
363
+ _: 2
364
+ }, 1024)]),
365
+ _: 2
366
+ }, 1024)
367
+ ]),
368
+ _: 2
369
+ }, 1024);
370
+ }), 128)),
371
+ $setup.props.following !== void 0 ? (openBlock(), createBlock($setup["Text"], {
372
+ key: 2,
373
+ color: "green"
374
+ }, {
375
+ default: withCtx(() => [createTextVNode("日志跟随中: " + toDisplayString($setup.props.following), 1)]),
376
+ _: 1
377
+ })) : createCommentVNode("v-if", true),
378
+ createVNode($setup["Text"], { dimColor: "" }, {
379
+ default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode("j/k 选择 · l 日志 · r 重启 · s 停止 · x 删除 · f 刷新", -1)])]),
380
+ _: 1
381
+ }),
382
+ createVNode($setup["ConfirmModal"], {
383
+ visible: $setup.pending !== null,
384
+ message: $setup.confirmMessage,
385
+ onConfirm: $setup.onConfirm,
386
+ onCancel: _cache[0] || (_cache[0] = ($event) => $setup.pending = null)
387
+ }, null, 8, ["visible", "message"])
388
+ ]),
389
+ _: 1
390
+ });
391
+ }
392
+ var ContainersPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$5, [["render", _sfc_render$5], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/ContainersPanel.vue"]]);
393
+ //#endregion
4
394
  //#region src/tui/components/OutputPanel.vue
5
- /** 全局日志面板(spec 6.4 Output):只吃 ViewModel(logs 列表),不碰 core */
6
- const _sfc_main$2 = /*@__PURE__*/ defineComponent({
395
+ /**
396
+ * 全局日志面板(spec 6.4 Output):只吃 ViewModel(logs 列表),不碰 core。
397
+ * 滚动/截断(T4#4 递延项):ScrollBox 有界视口(内容超高即截断)+ 旧 TUI g/G 键位语义(g 到顶、G 回底跟随)、↑/↓ 逐行;
398
+ * 列表上限在 useLogs(LOGS_LIMIT 环形截断),此处只管视口。
399
+ */
400
+ const _sfc_main$4 = /*@__PURE__*/ defineComponent({
7
401
  __name: "OutputPanel",
8
402
  props: { logs: {
9
403
  type: Array,
@@ -11,8 +405,18 @@ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
11
405
  } },
12
406
  setup(__props, { expose: __expose }) {
13
407
  __expose();
408
+ const props = __props;
409
+ const scrollRef = shallowRef(null);
410
+ useInput((event) => {
411
+ const name = keyName(event);
412
+ if (name === "up") scrollRef.value?.scrollByLines(-1);
413
+ else if (name === "down") scrollRef.value?.scrollByLines(1);
414
+ else if (name === "g") scrollRef.value?.scrollToTop();
415
+ else if (name === "G") scrollRef.value?.scrollToBottom();
416
+ });
14
417
  const __returned__ = {
15
- props: __props,
418
+ props,
419
+ scrollRef,
16
420
  LEVEL_COLOR: {
17
421
  info: void 0,
18
422
  success: "green",
@@ -24,6 +428,9 @@ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
24
428
  },
25
429
  get Text() {
26
430
  return Text;
431
+ },
432
+ get ScrollBox() {
433
+ return ScrollBox;
27
434
  }
28
435
  };
29
436
  Object.defineProperty(__returned__, "__isScriptSetup", {
@@ -33,7 +440,7 @@ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
33
440
  return __returned__;
34
441
  }
35
442
  });
36
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
443
+ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
37
444
  return openBlock(), createBlock($setup["Box"], {
38
445
  flexDirection: "column",
39
446
  flexGrow: 1,
@@ -55,73 +462,382 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
55
462
  }, {
56
463
  default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("(暂无日志)", -1)])]),
57
464
  _: 1
465
+ })) : (openBlock(), createBlock($setup["ScrollBox"], {
466
+ key: 1,
467
+ ref: "scrollRef",
468
+ flexGrow: 1
469
+ }, {
470
+ default: withCtx(() => [createVNode($setup["Box"], { flexDirection: "column" }, {
471
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList($setup.props.logs, (entry, i) => {
472
+ return openBlock(), createBlock($setup["Text"], {
473
+ key: i,
474
+ color: $setup.LEVEL_COLOR[entry.level],
475
+ wrap: "truncate"
476
+ }, {
477
+ default: withCtx(() => [createTextVNode(toDisplayString(entry.time) + " [" + toDisplayString(entry.level) + "] " + toDisplayString(entry.message), 1)]),
478
+ _: 2
479
+ }, 1032, ["color"]);
480
+ }), 128))]),
481
+ _: 1
482
+ })]),
483
+ _: 1
484
+ }, 512)),
485
+ createVNode($setup["Text"], { dimColor: "" }, {
486
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("g/G 到顶/底 · ↑/↓ 逐行滚动", -1)])]),
487
+ _: 1
488
+ })
489
+ ]),
490
+ _: 1
491
+ });
492
+ }
493
+ var OutputPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$4, [["render", _sfc_render$4], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/OutputPanel.vue"]]);
494
+ //#endregion
495
+ //#region src/tui/components/ProjectsPanel.vue
496
+ /**
497
+ * Projects 面板(spec 6.4):项目列表 NAME/PATH/TYPE/ERROR + 动作事件出口。
498
+ * 只吃 ViewModel(rows);动作经 emit 交 App 接线(部署等 T6 接线)。
499
+ */
500
+ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
501
+ __name: "ProjectsPanel",
502
+ props: {
503
+ rows: {
504
+ type: Array,
505
+ required: true
506
+ },
507
+ error: {
508
+ type: String,
509
+ required: false
510
+ }
511
+ },
512
+ emits: ["deploy", "refresh"],
513
+ setup(__props, { expose: __expose, emit: __emit }) {
514
+ __expose();
515
+ const props = __props;
516
+ const emit = __emit;
517
+ const sel = ref(0);
518
+ watch(() => props.rows.length, () => {
519
+ sel.value = Math.min(sel.value, Math.max(0, props.rows.length - 1));
520
+ });
521
+ useInput((event) => {
522
+ const name = keyName(event);
523
+ if (props.rows.length === 0) return;
524
+ if (name === "j" || name === "down") sel.value = Math.min(sel.value + 1, props.rows.length - 1);
525
+ else if (name === "k" || name === "up") sel.value = Math.max(sel.value - 1, 0);
526
+ else if (name === "d") emit("deploy", props.rows[sel.value].name);
527
+ else if (name === "f") emit("refresh");
528
+ });
529
+ const __returned__ = {
530
+ props,
531
+ emit,
532
+ sel,
533
+ get Box() {
534
+ return Box;
535
+ },
536
+ get Text() {
537
+ return Text;
538
+ }
539
+ };
540
+ Object.defineProperty(__returned__, "__isScriptSetup", {
541
+ enumerable: false,
542
+ value: true
543
+ });
544
+ return __returned__;
545
+ }
546
+ });
547
+ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
548
+ return openBlock(), createBlock($setup["Box"], {
549
+ flexDirection: "column",
550
+ flexGrow: 1,
551
+ borderStyle: "round",
552
+ borderColor: "cyan",
553
+ padding: 1
554
+ }, {
555
+ default: withCtx(() => [
556
+ createVNode($setup["Text"], {
557
+ bold: "",
558
+ color: "cyan"
559
+ }, {
560
+ default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("1. Projects 项目", -1)])]),
561
+ _: 1
562
+ }),
563
+ createVNode($setup["Box"], { flexDirection: "row" }, {
564
+ default: withCtx(() => [
565
+ createVNode($setup["Box"], { width: 2 }, {
566
+ default: withCtx(() => [createVNode($setup["Text"])]),
567
+ _: 1
568
+ }),
569
+ createVNode($setup["Box"], { width: 18 }, {
570
+ default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
571
+ default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("NAME", -1)])]),
572
+ _: 1
573
+ })]),
574
+ _: 1
575
+ }),
576
+ createVNode($setup["Box"], { width: 30 }, {
577
+ default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
578
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("PATH", -1)])]),
579
+ _: 1
580
+ })]),
581
+ _: 1
582
+ }),
583
+ createVNode($setup["Box"], { width: 8 }, {
584
+ default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
585
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("TYPE", -1)])]),
586
+ _: 1
587
+ })]),
588
+ _: 1
589
+ }),
590
+ createVNode($setup["Box"], { flexGrow: 1 }, {
591
+ default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
592
+ default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("ERROR", -1)])]),
593
+ _: 1
594
+ })]),
595
+ _: 1
596
+ })
597
+ ]),
598
+ _: 1
599
+ }),
600
+ $setup.props.error !== void 0 ? (openBlock(), createBlock($setup["Text"], {
601
+ key: 0,
602
+ color: "red"
603
+ }, {
604
+ default: withCtx(() => [createTextVNode("加载失败: " + toDisplayString($setup.props.error), 1)]),
605
+ _: 1
606
+ })) : $setup.props.rows.length === 0 ? (openBlock(), createBlock($setup["Text"], {
607
+ key: 1,
608
+ dimColor: ""
609
+ }, {
610
+ default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("(暂无项目)", -1)])]),
611
+ _: 1
58
612
  })) : createCommentVNode("v-if", true),
59
- (openBlock(true), createElementBlock(Fragment, null, renderList($setup.props.logs, (entry, i) => {
60
- return openBlock(), createBlock($setup["Text"], {
61
- key: i,
62
- color: $setup.LEVEL_COLOR[entry.level]
613
+ (openBlock(true), createElementBlock(Fragment, null, renderList($setup.props.rows, (row, i) => {
614
+ return openBlock(), createBlock($setup["Box"], {
615
+ key: row.name,
616
+ flexDirection: "row"
63
617
  }, {
64
- default: withCtx(() => [createTextVNode(toDisplayString(entry.time) + " [" + toDisplayString(entry.level) + "] " + toDisplayString(entry.message), 1)]),
618
+ default: withCtx(() => [
619
+ createVNode($setup["Box"], { width: 2 }, {
620
+ default: withCtx(() => [createVNode($setup["Text"], { color: i === $setup.sel ? "cyan" : void 0 }, {
621
+ default: withCtx(() => [createTextVNode(toDisplayString(i === $setup.sel ? ">" : " "), 1)]),
622
+ _: 2
623
+ }, 1032, ["color"])]),
624
+ _: 2
625
+ }, 1024),
626
+ createVNode($setup["Box"], { width: 18 }, {
627
+ default: withCtx(() => [createVNode($setup["Text"], {
628
+ wrap: "truncate",
629
+ bold: i === $setup.sel
630
+ }, {
631
+ default: withCtx(() => [createTextVNode(toDisplayString(row.name), 1)]),
632
+ _: 2
633
+ }, 1032, ["bold"])]),
634
+ _: 2
635
+ }, 1024),
636
+ createVNode($setup["Box"], { width: 30 }, {
637
+ default: withCtx(() => [createVNode($setup["Text"], { wrap: "truncate" }, {
638
+ default: withCtx(() => [createTextVNode(toDisplayString(row.path), 1)]),
639
+ _: 2
640
+ }, 1024)]),
641
+ _: 2
642
+ }, 1024),
643
+ createVNode($setup["Box"], { width: 8 }, {
644
+ default: withCtx(() => [createVNode($setup["Text"], { wrap: "truncate" }, {
645
+ default: withCtx(() => [createTextVNode(toDisplayString(row.type), 1)]),
646
+ _: 2
647
+ }, 1024)]),
648
+ _: 2
649
+ }, 1024),
650
+ createVNode($setup["Box"], { flexGrow: 1 }, {
651
+ default: withCtx(() => [createVNode($setup["Text"], {
652
+ wrap: "truncate",
653
+ color: "red"
654
+ }, {
655
+ default: withCtx(() => [createTextVNode(toDisplayString(row.error ?? ""), 1)]),
656
+ _: 2
657
+ }, 1024)]),
658
+ _: 2
659
+ }, 1024)
660
+ ]),
65
661
  _: 2
66
- }, 1032, ["color"]);
67
- }), 128))
662
+ }, 1024);
663
+ }), 128)),
664
+ createVNode($setup["Text"], { dimColor: "" }, {
665
+ default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("j/k 选择 · d 部署 · f 刷新", -1)])]),
666
+ _: 1
667
+ })
68
668
  ]),
69
669
  _: 1
70
670
  });
71
671
  }
72
- var OutputPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$2, [["render", _sfc_render$2], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/OutputPanel.vue"]]);
672
+ var ProjectsPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$3, [["render", _sfc_render$3], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/ProjectsPanel.vue"]]);
73
673
  //#endregion
74
- //#region src/tui/composables/useKeymap.ts
75
- /** 六面板(spec 6.4):键位 1-6 与数组序一一对应 */
76
- const PANEL_IDS = [
77
- "projects",
78
- "containers",
79
- "deploy",
80
- "status",
81
- "tunnels",
82
- "output"
83
- ];
84
- /** 面板标题(骨架/状态栏共用;中文文案) */
85
- const PANEL_TITLES = {
86
- projects: "Projects 项目",
87
- containers: "Containers 容器",
88
- deploy: "Deploy 部署",
89
- status: "Status 状态",
90
- tunnels: "Tunnels 隧道",
91
- output: "Output 输出"
92
- };
674
+ //#region src/tui/components/StatusPanel.vue
93
675
  /**
94
- * 提取单字符键位:text 事件取 text、key 事件取 character/name(同一输入事实只出一个公共事件,不会双发)。
95
- * 多字符文本(粘贴/连打)不分发,防误触退出。
676
+ * Status 面板(spec 6.4):项目健康聚合 CONTAINERS/HTTP/NGINX(口径同 CLI status 表格)。
677
+ * 只吃 ViewModel(rows);单行错误降级展示(检查失败/配置不可用行 + 继续,M2-T2 #10 的 UI 面)。
96
678
  */
97
- function keyChar(event) {
98
- let raw;
99
- if (event.type === "text") raw = event.text;
100
- else if (event.type === "key") raw = event.key.character ?? event.key.name;
101
- return raw !== void 0 && raw.length === 1 ? raw : void 0;
102
- }
103
- /** 键位分发(纯函数,单测锚点):1-6 切面板、q 退出、? 帮助;其余不分发 */
104
- function dispatchKey(event) {
105
- const ch = keyChar(event);
106
- if (ch === void 0) return null;
107
- if (ch >= "1" && ch <= "6") return {
108
- kind: "panel",
109
- panel: PANEL_IDS[Number(ch) - 1]
110
- };
111
- if (ch === "q") return { kind: "quit" };
112
- if (ch === "?") return { kind: "help" };
113
- return null;
114
- }
115
- /** 键位路由接线:useInput 订阅 → dispatchKey → 回调;组件不碰输入流本体 */
116
- function useKeymap(handlers) {
117
- useInput((event) => {
118
- const action = dispatchKey(event);
119
- if (action === null) return;
120
- if (action.kind === "panel") handlers.onPanel(action.panel);
121
- else if (action.kind === "quit") handlers.onQuit();
122
- else handlers.onHelp();
679
+ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
680
+ __name: "StatusPanel",
681
+ props: {
682
+ rows: {
683
+ type: Array,
684
+ required: true
685
+ },
686
+ error: {
687
+ type: String,
688
+ required: false
689
+ }
690
+ },
691
+ emits: ["refresh"],
692
+ setup(__props, { expose: __expose, emit: __emit }) {
693
+ __expose();
694
+ const props = __props;
695
+ const emit = __emit;
696
+ useInput((event) => {
697
+ if (keyName(event) === "f") emit("refresh");
698
+ });
699
+ const __returned__ = {
700
+ props,
701
+ emit,
702
+ get Box() {
703
+ return Box;
704
+ },
705
+ get Text() {
706
+ return Text;
707
+ }
708
+ };
709
+ Object.defineProperty(__returned__, "__isScriptSetup", {
710
+ enumerable: false,
711
+ value: true
712
+ });
713
+ return __returned__;
714
+ }
715
+ });
716
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
717
+ return openBlock(), createBlock($setup["Box"], {
718
+ flexDirection: "column",
719
+ flexGrow: 1,
720
+ borderStyle: "round",
721
+ borderColor: "cyan",
722
+ padding: 1
723
+ }, {
724
+ default: withCtx(() => [
725
+ createVNode($setup["Text"], {
726
+ bold: "",
727
+ color: "cyan"
728
+ }, {
729
+ default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("4. Status 状态", -1)])]),
730
+ _: 1
731
+ }),
732
+ createVNode($setup["Box"], { flexDirection: "row" }, {
733
+ default: withCtx(() => [
734
+ createVNode($setup["Box"], { width: 20 }, {
735
+ default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
736
+ default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("NAME", -1)])]),
737
+ _: 1
738
+ })]),
739
+ _: 1
740
+ }),
741
+ createVNode($setup["Box"], { width: 16 }, {
742
+ default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
743
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("CONTAINERS", -1)])]),
744
+ _: 1
745
+ })]),
746
+ _: 1
747
+ }),
748
+ createVNode($setup["Box"], { width: 8 }, {
749
+ default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
750
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("HTTP", -1)])]),
751
+ _: 1
752
+ })]),
753
+ _: 1
754
+ }),
755
+ createVNode($setup["Box"], { flexGrow: 1 }, {
756
+ default: withCtx(() => [createVNode($setup["Text"], { bold: "" }, {
757
+ default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("NGINX", -1)])]),
758
+ _: 1
759
+ })]),
760
+ _: 1
761
+ })
762
+ ]),
763
+ _: 1
764
+ }),
765
+ $setup.props.error !== void 0 ? (openBlock(), createBlock($setup["Text"], {
766
+ key: 0,
767
+ color: "red"
768
+ }, {
769
+ default: withCtx(() => [createTextVNode("加载失败: " + toDisplayString($setup.props.error), 1)]),
770
+ _: 1
771
+ })) : $setup.props.rows.length === 0 ? (openBlock(), createBlock($setup["Text"], {
772
+ key: 1,
773
+ dimColor: ""
774
+ }, {
775
+ default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("(暂无项目)", -1)])]),
776
+ _: 1
777
+ })) : createCommentVNode("v-if", true),
778
+ (openBlock(true), createElementBlock(Fragment, null, renderList($setup.props.rows, (row) => {
779
+ return openBlock(), createElementBlock(Fragment, { key: row.name }, [
780
+ createVNode($setup["Box"], { flexDirection: "row" }, {
781
+ default: withCtx(() => [
782
+ createVNode($setup["Box"], { width: 20 }, {
783
+ default: withCtx(() => [createVNode($setup["Text"], { wrap: "truncate" }, {
784
+ default: withCtx(() => [createTextVNode(toDisplayString(row.name), 1)]),
785
+ _: 2
786
+ }, 1024)]),
787
+ _: 2
788
+ }, 1024),
789
+ createVNode($setup["Box"], { width: 16 }, {
790
+ default: withCtx(() => [createVNode($setup["Text"], {
791
+ wrap: "truncate",
792
+ color: row.error !== void 0 ? "red" : void 0
793
+ }, {
794
+ default: withCtx(() => [createTextVNode(toDisplayString(row.containers), 1)]),
795
+ _: 2
796
+ }, 1032, ["color"])]),
797
+ _: 2
798
+ }, 1024),
799
+ createVNode($setup["Box"], { width: 8 }, {
800
+ default: withCtx(() => [createVNode($setup["Text"], {
801
+ wrap: "truncate",
802
+ color: row.http === "FAIL" ? "red" : row.http === "-" ? void 0 : "green"
803
+ }, {
804
+ default: withCtx(() => [createTextVNode(toDisplayString(row.http), 1)]),
805
+ _: 2
806
+ }, 1032, ["color"])]),
807
+ _: 2
808
+ }, 1024),
809
+ createVNode($setup["Box"], { flexGrow: 1 }, {
810
+ default: withCtx(() => [createVNode($setup["Text"], {
811
+ wrap: "truncate",
812
+ color: row.nginx === "✓" ? "green" : row.nginx === "✗" ? "red" : void 0
813
+ }, {
814
+ default: withCtx(() => [createTextVNode(toDisplayString(row.nginx), 1)]),
815
+ _: 2
816
+ }, 1032, ["color"])]),
817
+ _: 2
818
+ }, 1024)
819
+ ]),
820
+ _: 2
821
+ }, 1024),
822
+ createCommentVNode(" 单行降级详情(CLI status 的 error 行口径),不中断后续行 "),
823
+ row.error !== void 0 ? (openBlock(), createBlock($setup["Text"], {
824
+ key: 0,
825
+ color: "red"
826
+ }, {
827
+ default: withCtx(() => [createTextVNode(toDisplayString(row.error), 1)]),
828
+ _: 2
829
+ }, 1024)) : createCommentVNode("v-if", true)
830
+ ], 64);
831
+ }), 128)),
832
+ createVNode($setup["Text"], { dimColor: "" }, {
833
+ default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("f 刷新", -1)])]),
834
+ _: 1
835
+ })
836
+ ]),
837
+ _: 1
123
838
  });
124
839
  }
840
+ var StatusPanel_default = /*#__PURE__*/ export_helper_default(_sfc_main$2, [["render", _sfc_render$2], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/StatusPanel.vue"]]);
125
841
  //#endregion
126
842
  //#region src/tui/components/StatusBar.vue
127
843
  const _sfc_main$1 = /*@__PURE__*/ defineComponent({
@@ -180,6 +896,8 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
180
896
  var StatusBar_default = /*#__PURE__*/ export_helper_default(_sfc_main$1, [["render", _sfc_render$1], ["__file", "/Users/yangdongnan/work/deploy-cli/src/tui/components/StatusBar.vue"]]);
181
897
  //#endregion
182
898
  //#region src/tui/composables/useLogs.ts
899
+ /** 日志列表上限(T4#4 递延项):超出环形截断最旧行,防长会话无界增长 */
900
+ const LOGS_LIMIT = 2e3;
183
901
  /** 全局日志条目(响应式列表,单例) */
184
902
  const entries = ref([]);
185
903
  function now() {
@@ -196,6 +914,7 @@ function useLogs() {
196
914
  level,
197
915
  message
198
916
  });
917
+ if (entries.value.length > 2e3) entries.value.splice(0, entries.value.length - LOGS_LIMIT);
199
918
  };
200
919
  return {
201
920
  logs: entries,
@@ -211,13 +930,200 @@ function useLogs() {
211
930
  };
212
931
  }
213
932
  //#endregion
933
+ //#region src/tui/composables/useContainers.ts
934
+ /** docker ps 一行 → 行 VM(字段透传,展示裁剪在组件) */
935
+ function toRow$2(c) {
936
+ return {
937
+ id: c.id,
938
+ name: c.name,
939
+ image: c.image,
940
+ state: c.state,
941
+ status: c.status,
942
+ ports: c.ports
943
+ };
944
+ }
945
+ /**
946
+ * Containers 面板数据面(M2-T5):DockerApi → 响应式 ViewModel + 破坏性动作执行面。
947
+ * 破坏性动作(restart/stop/remove)的二次确认在 ContainersPanel(ConfirmModal);此处只执行。
948
+ */
949
+ function useContainers(opts = {}) {
950
+ const docker = () => opts.docker ?? createDocker();
951
+ const rows = ref([]);
952
+ const error = ref(void 0);
953
+ const following = ref(void 0);
954
+ const { info, warn, error: logError, pushLine } = useLogs();
955
+ /** 过期刷新丢弃(快速切面板/连按 f 不得交错回写) */
956
+ let seq = 0;
957
+ async function refresh() {
958
+ const my = ++seq;
959
+ try {
960
+ const list = (await docker().listContainers({ all: true })).map(toRow$2);
961
+ if (my !== seq) return;
962
+ rows.value = list;
963
+ error.value = void 0;
964
+ } catch (err) {
965
+ if (my !== seq) return;
966
+ rows.value = [];
967
+ error.value = err instanceof Error ? err.message : String(err);
968
+ }
969
+ }
970
+ async function followLogs(idOrName) {
971
+ if (following.value !== void 0) {
972
+ warn(`已在跟随容器 ${following.value} 的日志,忽略新请求: ${idOrName}`);
973
+ return;
974
+ }
975
+ following.value = idOrName;
976
+ info(`跟随容器日志: ${idOrName}(tail 200 + follow,Output 面板查看)`);
977
+ try {
978
+ const result = await docker().logs(idOrName, {
979
+ tail: 200,
980
+ follow: true,
981
+ onLine: pushLine
982
+ });
983
+ if (result.code !== 0) logError(`容器日志跟随中断: ${idOrName}(exit ${result.code})`);
984
+ } catch (err) {
985
+ const reason = err instanceof Error ? err.message : String(err);
986
+ logError(`容器日志跟随失败: ${idOrName}: ${reason}`);
987
+ } finally {
988
+ following.value = void 0;
989
+ }
990
+ }
991
+ return {
992
+ rows,
993
+ error,
994
+ following,
995
+ refresh,
996
+ restart: (idOrName) => docker().restart(idOrName),
997
+ stop: (idOrName) => docker().stop(idOrName),
998
+ remove: (idOrName, o) => docker().remove(idOrName, o),
999
+ followLogs
1000
+ };
1001
+ }
1002
+ //#endregion
1003
+ //#region src/tui/composables/useHealth.ts
1004
+ /** ProjectHealth → 三列单元格(复刻 CLI status formatRow 口径) */
1005
+ function toRow$1(health) {
1006
+ const total = health.containers.length;
1007
+ const running = health.containers.filter((c) => c.state === "running").length;
1008
+ return {
1009
+ name: health.name,
1010
+ containers: total === 0 ? "无容器" : `${running}/${total} running`,
1011
+ http: health.http === void 0 ? "-" : health.http.ok ? String(health.http.status) : "FAIL",
1012
+ nginx: health.nginxPresent === void 0 ? "-" : health.nginxPresent ? "✓" : "✗"
1013
+ };
1014
+ }
1015
+ /** 坏配置行降级(口径同 CLI status:`项目配置不可用: <name>: <reason>`) */
1016
+ function configErrorRow(project) {
1017
+ const reason = project.error ?? "";
1018
+ return {
1019
+ name: project.name,
1020
+ containers: "配置不可用",
1021
+ http: "-",
1022
+ nginx: "-",
1023
+ error: `项目配置不可用: ${project.name}: ${reason}`
1024
+ };
1025
+ }
1026
+ /** 单项目检查失败降级(M2-T2 #10 的 UI 面:`检查失败` 行 + 继续,口径同 CLI status) */
1027
+ function checkErrorRow(name, reason) {
1028
+ return {
1029
+ name,
1030
+ containers: "检查失败",
1031
+ http: "-",
1032
+ nginx: "-",
1033
+ error: `项目健康检查失败: ${name}: ${reason}`
1034
+ };
1035
+ }
1036
+ /**
1037
+ * Status 面板数据面(M2-T5):逐项目 checkProjectHealth 聚合 → 响应式行列表。
1038
+ * 单项目异常按行降级(配置不可用/检查失败行 + 继续),不得一坏全断(M2-T2 #10)。
1039
+ */
1040
+ function useHealth(opts = {}) {
1041
+ const rows = ref([]);
1042
+ const error = ref(void 0);
1043
+ /** 过期刷新丢弃(HTTP 探测可达数秒,快速连刷不得交错回写) */
1044
+ let seq = 0;
1045
+ async function rowFor(project) {
1046
+ if (!project.config) return configErrorRow(project);
1047
+ try {
1048
+ return toRow$1(await checkProjectHealth(project.config, {
1049
+ docker: opts.docker,
1050
+ runner: opts.runner,
1051
+ nginx: opts.nginx
1052
+ }));
1053
+ } catch (err) {
1054
+ const reason = err instanceof Error ? err.message : String(err);
1055
+ return checkErrorRow(project.name, reason);
1056
+ }
1057
+ }
1058
+ async function refresh() {
1059
+ const my = ++seq;
1060
+ let projects;
1061
+ try {
1062
+ projects = listProjects(opts.load ? opts.load() : loadConfig());
1063
+ error.value = void 0;
1064
+ } catch (err) {
1065
+ rows.value = [];
1066
+ error.value = err instanceof Error ? err.message : String(err);
1067
+ return;
1068
+ }
1069
+ const out = [];
1070
+ for (const project of projects) {
1071
+ if (my !== seq) return;
1072
+ out.push(await rowFor(project));
1073
+ if (my === seq) rows.value = [...out];
1074
+ }
1075
+ }
1076
+ return {
1077
+ rows,
1078
+ error,
1079
+ refresh
1080
+ };
1081
+ }
1082
+ //#endregion
1083
+ //#region src/tui/composables/useProjects.ts
1084
+ /** RegisteredProject → 行 VM:坏配置降级 type '-' + ERROR 列(listProjects 已做单行降级) */
1085
+ function toRow(project) {
1086
+ return {
1087
+ name: project.name,
1088
+ path: project.path,
1089
+ type: project.config?.type ?? "-",
1090
+ error: project.error
1091
+ };
1092
+ }
1093
+ /**
1094
+ * Projects 面板数据面(M2-T5):core(loadConfig+listProjects)→ 响应式 ViewModel。
1095
+ * 组件只吃 VM;注册表读取失败降级为单行错误提示,不抛。
1096
+ */
1097
+ function useProjects(opts = {}) {
1098
+ const rows = ref([]);
1099
+ const error = ref(void 0);
1100
+ function refresh() {
1101
+ try {
1102
+ const cfg = opts.load ? opts.load() : loadConfig();
1103
+ rows.value = listProjects(cfg).map(toRow);
1104
+ error.value = void 0;
1105
+ } catch (err) {
1106
+ rows.value = [];
1107
+ error.value = err instanceof Error ? err.message : String(err);
1108
+ }
1109
+ }
1110
+ return {
1111
+ rows,
1112
+ error,
1113
+ refresh
1114
+ };
1115
+ }
1116
+ //#endregion
214
1117
  //#region src/tui/App.vue
215
1118
  const _sfc_main = /*@__PURE__*/ defineComponent({
216
1119
  __name: "App",
217
1120
  setup(__props, { expose: __expose }) {
218
1121
  __expose();
219
1122
  const { exit } = useApp();
220
- const { logs } = useLogs();
1123
+ const { logs, info, success, error: logError } = useLogs();
1124
+ const { rows: projectRows, error: projectError, refresh: refreshProjects } = useProjects();
1125
+ const { rows: containerRows, error: containerError, following, refresh: refreshContainers, restart, stop, remove, followLogs } = useContainers();
1126
+ const { rows: healthRows, error: healthError, refresh: refreshHealth } = useHealth();
221
1127
  const activePanel = ref("projects");
222
1128
  const helpVisible = ref(false);
223
1129
  useKeymap({
@@ -230,11 +1136,59 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
230
1136
  helpVisible.value = !helpVisible.value;
231
1137
  }
232
1138
  });
1139
+ watch(activePanel, (panel) => {
1140
+ if (panel === "projects") refreshProjects();
1141
+ else if (panel === "containers") refreshContainers();
1142
+ else if (panel === "status") refreshHealth();
1143
+ }, { immediate: true });
1144
+ const ACTION_LABEL = {
1145
+ restart: "重启",
1146
+ stop: "停止",
1147
+ remove: "删除"
1148
+ };
1149
+ /** Containers 破坏性动作(面板 ConfirmModal 确认后才到达此处):执行 → 日志 → 刷新列表 */
1150
+ async function onContainerAction(action, name) {
1151
+ info(`${ACTION_LABEL[action]}容器: ${name}`);
1152
+ try {
1153
+ const result = action === "restart" ? await restart(name) : action === "stop" ? await stop(name) : await remove(name);
1154
+ if (result.code === 0) {
1155
+ success(`${ACTION_LABEL[action]}容器成功: ${name}`);
1156
+ await refreshContainers();
1157
+ } else logError(`${ACTION_LABEL[action]}容器失败: ${name}(exit ${result.code})`);
1158
+ } catch (err) {
1159
+ const reason = err instanceof Error ? err.message : String(err);
1160
+ logError(`${ACTION_LABEL[action]}容器失败: ${name}: ${reason}`);
1161
+ }
1162
+ }
1163
+ /** 日志跟随:useContainers.followLogs → core onLine → useLogs → Output 面板 */
1164
+ function onLogs(name) {
1165
+ followLogs(name);
1166
+ }
233
1167
  const __returned__ = {
234
1168
  exit,
235
1169
  logs,
1170
+ info,
1171
+ success,
1172
+ logError,
1173
+ projectRows,
1174
+ projectError,
1175
+ refreshProjects,
1176
+ containerRows,
1177
+ containerError,
1178
+ following,
1179
+ refreshContainers,
1180
+ restart,
1181
+ stop,
1182
+ remove,
1183
+ followLogs,
1184
+ healthRows,
1185
+ healthError,
1186
+ refreshHealth,
236
1187
  activePanel,
237
1188
  helpVisible,
1189
+ ACTION_LABEL,
1190
+ onContainerAction,
1191
+ onLogs,
238
1192
  panelTitle: computed(() => `${PANEL_IDS.indexOf(activePanel.value) + 1}. ${PANEL_TITLES[activePanel.value]}`),
239
1193
  get Box() {
240
1194
  return Box;
@@ -242,7 +1196,10 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
242
1196
  get Text() {
243
1197
  return Text;
244
1198
  },
1199
+ ContainersPanel: ContainersPanel_default,
245
1200
  OutputPanel: OutputPanel_default,
1201
+ ProjectsPanel: ProjectsPanel_default,
1202
+ StatusPanel: StatusPanel_default,
246
1203
  StatusBar: StatusBar_default,
247
1204
  get PANEL_IDS() {
248
1205
  return PANEL_IDS;
@@ -275,25 +1232,58 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
275
1232
  bold: "",
276
1233
  color: "cyan"
277
1234
  }, {
278
- default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Deploy CLI", -1)])]),
1235
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("Deploy CLI", -1)])]),
279
1236
  _: 1
280
1237
  }), createVNode($setup["Text"], { dimColor: "" }, {
281
- default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("1 Projects · 2 Containers · 3 Deploy · 4 Status · 5 Tunnels · 6 Output", -1)])]),
1238
+ default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("1 Projects · 2 Containers · 3 Deploy · 4 Status · 5 Tunnels · 6 Output", -1)])]),
282
1239
  _: 1
283
1240
  })]),
284
1241
  _: 1
285
1242
  }),
286
- createCommentVNode(" 主面板区:1-5 骨架占位(内容随 M2 后续任务实现),6=全局日志 "),
1243
+ createCommentVNode(" 主面板区:1/2/4/6 实装,3 Deploy(T6)/5 Tunnels(T7)骨架占位 "),
287
1244
  createVNode($setup["Box"], {
288
1245
  flexDirection: "column",
289
1246
  flexGrow: 1,
290
1247
  paddingX: 1
291
1248
  }, {
292
- default: withCtx(() => [$setup.activePanel === "output" ? (openBlock(), createBlock($setup["OutputPanel"], {
1249
+ default: withCtx(() => [createCommentVNode(" 项目动作出口(deploy)先挂 emit,T6 接线 "), $setup.activePanel === "projects" ? (openBlock(), createBlock($setup["ProjectsPanel"], {
293
1250
  key: 0,
1251
+ rows: $setup.projectRows,
1252
+ error: $setup.projectError,
1253
+ onRefresh: $setup.refreshProjects
1254
+ }, null, 8, [
1255
+ "rows",
1256
+ "error",
1257
+ "onRefresh"
1258
+ ])) : $setup.activePanel === "containers" ? (openBlock(), createBlock($setup["ContainersPanel"], {
1259
+ key: 1,
1260
+ rows: $setup.containerRows,
1261
+ error: $setup.containerError,
1262
+ following: $setup.following,
1263
+ onLogs: $setup.onLogs,
1264
+ onRestart: _cache[0] || (_cache[0] = (name) => $setup.onContainerAction("restart", name)),
1265
+ onStop: _cache[1] || (_cache[1] = (name) => $setup.onContainerAction("stop", name)),
1266
+ onRemove: _cache[2] || (_cache[2] = (name) => $setup.onContainerAction("remove", name)),
1267
+ onRefresh: $setup.refreshContainers
1268
+ }, null, 8, [
1269
+ "rows",
1270
+ "error",
1271
+ "following",
1272
+ "onRefresh"
1273
+ ])) : $setup.activePanel === "status" ? (openBlock(), createBlock($setup["StatusPanel"], {
1274
+ key: 2,
1275
+ rows: $setup.healthRows,
1276
+ error: $setup.healthError,
1277
+ onRefresh: $setup.refreshHealth
1278
+ }, null, 8, [
1279
+ "rows",
1280
+ "error",
1281
+ "onRefresh"
1282
+ ])) : $setup.activePanel === "output" ? (openBlock(), createBlock($setup["OutputPanel"], {
1283
+ key: 3,
294
1284
  logs: $setup.logs
295
1285
  }, null, 8, ["logs"])) : (openBlock(), createBlock($setup["Box"], {
296
- key: 1,
1286
+ key: 4,
297
1287
  flexDirection: "column",
298
1288
  flexGrow: 1,
299
1289
  borderStyle: "round",
@@ -306,7 +1296,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
306
1296
  default: withCtx(() => [createTextVNode(toDisplayString($setup.panelTitle), 1)]),
307
1297
  _: 1
308
1298
  }), createVNode($setup["Text"], { dimColor: "" }, {
309
- default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("(骨架占位:面板内容随 M2 后续任务实现)", -1)])]),
1299
+ default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("(骨架占位:面板内容随 M2 后续任务实现)", -1)])]),
310
1300
  _: 1
311
1301
  })]),
312
1302
  _: 1
@@ -327,7 +1317,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
327
1317
  bold: "",
328
1318
  color: "yellow"
329
1319
  }, {
330
- default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("快捷键帮助", -1)])]),
1320
+ default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("快捷键帮助", -1)])]),
331
1321
  _: 1
332
1322
  }),
333
1323
  (openBlock(true), createElementBlock(Fragment, null, renderList($setup.PANEL_IDS, (id, i) => {
@@ -337,7 +1327,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
337
1327
  }, 1024);
338
1328
  }), 128)),
339
1329
  createVNode($setup["Text"], null, {
340
- default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("? 打开/关闭帮助 │ q 退出", -1)])]),
1330
+ default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode("? 打开/关闭帮助 │ q 退出", -1)])]),
341
1331
  _: 1
342
1332
  })
343
1333
  ]),