nx-kv 0.25.0 → 0.26.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/CHANGELOG.md +41 -0
- package/assets/kv-get/SKILL.md +7 -11
- package/package.json +1 -1
- package/src/modules/bundled/index.js +34 -15
- package/src/modules/bundled/service.js +32 -2
- package/src/modules/localtask/index.js +36 -15
- package/src/modules/localtask/task-lifecycle.js +128 -55
- package/src/modules/localtask/task-view.js +89 -12
- package/src/web/frontend/components/md/sel-menu.jsx +112 -19
- package/src/web/frontend/components/md/task-chain.jsx +75 -0
- package/src/web/frontend/components/md/tool-bar.jsx +43 -150
- package/src/web/frontend/modules/board/ack-nodes.js +2 -2
- package/src/web/frontend/modules/md/style.css +62 -36
- package/src/web/frontend/page/dir/index.jsx +32 -15
- package/src/web/frontend/page/dir/landing.jsx +2 -2
- package/src/web/frontend/page/dir/task.jsx +356 -131
- package/src/web/frontend/panels.jsx +13 -3
- package/src/web/public/assets/{Introduction-VfytFhtV.js → Introduction-DM8UsY4h.js} +1 -1
- package/src/web/public/assets/{cloud-DolkshAI.js → cloud-CNaaEd1U.js} +1 -1
- package/src/web/public/assets/{dag-C-E5GoLz.js → dag-CbvygK6N.js} +1 -1
- package/src/web/public/assets/dir-d7zH4NlJ.js +3 -0
- package/src/web/public/assets/{group-BQTuoGyZ.js → group-CrO4vK2Z.js} +1 -1
- package/src/web/public/assets/{index-BryAyn_9.js → index-BZXYd3aX.js} +2 -2
- package/src/web/public/assets/index-DUxHMjZA.css +1 -0
- package/src/web/public/assets/{md-edit-ops-Bl0Zx0aJ.js → md-edit-ops-BIXUZ5BM.js} +1 -1
- package/src/web/public/assets/md-history-D7QLmaSB.js +5 -0
- package/src/web/public/assets/{member-picker-DwJAdKTe.js → member-picker-DACtPBSm.js} +1 -1
- package/src/web/public/assets/{overview-Crnguaek.js → overview-C_K6CESc.js} +1 -1
- package/src/web/public/assets/{progress-ijTyMRPT.js → progress-CF0jxABq.js} +1 -1
- package/src/web/public/assets/{repos-C_dN0b6h.js → repos-DNpvvMU4.js} +1 -1
- package/src/web/public/assets/{route-crumb-DZw2J3Nx.js → route-crumb-C9Y1m8Oy.js} +1 -1
- package/src/web/public/assets/{settings-C7zGy-xI.js → settings-fyoIVpgK.js} +1 -1
- package/src/web/public/assets/task-D1c-iO3T.js +6 -0
- package/src/web/public/assets/{template-slots-DhPGCIqW.js → template-slots-OwSHkvYK.js} +1 -1
- package/src/web/public/assets/{templates-xXPow5BD.js → templates-CWumcZMp.js} +1 -1
- package/src/web/public/assets/{upload-uBhGCTZ2.js → upload-DqECQ-17.js} +1 -1
- package/src/web/public/index.html +2 -2
- package/src/web/public/assets/dir-kBhfKX8r.js +0 -3
- package/src/web/public/assets/index-B48b_WIl.css +0 -1
- package/src/web/public/assets/md-history-vwtmQsFJ.js +0 -5
- package/src/web/public/assets/task-CqoiXFKL.js +0 -5
|
@@ -96,8 +96,8 @@ export function normalizeTask(t, siblings, readyOpts = {}) {
|
|
|
96
96
|
const base = {
|
|
97
97
|
id: Number(t.id) || 0,
|
|
98
98
|
text: String(t.text ?? ''),
|
|
99
|
-
// 状态词汇:pending → consumed
|
|
100
|
-
//
|
|
99
|
+
// 状态词汇:pending → consumed(已领取);完成验收后可就地回 pending(#74)。
|
|
100
|
+
// archived 仍保留给旧口径(#59 fork 取代)的残留行,不再由 reopen 写入。
|
|
101
101
|
status: t.status === 'consumed' ? 'consumed' : t.status === 'archived' ? 'archived' : 'pending',
|
|
102
102
|
roundSummary: String(t.roundSummary ?? ''),
|
|
103
103
|
createdAt: String(t.createdAt ?? ''),
|
|
@@ -123,11 +123,12 @@ export function normalizeTask(t, siblings, readyOpts = {}) {
|
|
|
123
123
|
timegoal: sanitizeTaskGoal(t.timegoal),
|
|
124
124
|
// 完成标记(localtask done 写入):带时间目标的任务未到点会被拒绝,写不进来。
|
|
125
125
|
completedAt: String(t.completedAt ?? ''),
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
//
|
|
126
|
+
// 重开轨迹(#74):就地重开,历史进 history[];forkOf 仅兼容旧 #59/#69 派生数据。
|
|
127
|
+
// history 同任务内的链节点(origin / reopen / comment),点开可旁路查看
|
|
128
|
+
// forkOf 旧派生链('队列key:旧编号')——新 reopen 不再写
|
|
129
|
+
// forkKind 最近一次事件种类(reopen / comment),或旧派生种类
|
|
130
|
+
// supersededBy / archived* 旧归档残留字段
|
|
131
|
+
history: normalizeHistory(t.history),
|
|
131
132
|
forkOf: String(t.forkOf ?? ''),
|
|
132
133
|
forkKind: t.forkKind === 'reopen' || t.forkKind === 'comment' ? t.forkKind : '',
|
|
133
134
|
supersededBy: t.supersededBy && typeof t.supersededBy === 'object' ? t.supersededBy : null,
|
|
@@ -227,11 +228,50 @@ export function topicView(t, repoCtx = null, readyOpts = {}) {
|
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
// ─── 任务链(#69) ────────────────────────────────────────────────────
|
|
230
|
-
|
|
231
|
-
|
|
231
|
+
/** 规范化任务内 history 链(#74)。非法项丢弃,顺序保留。 */
|
|
232
|
+
export function normalizeHistory(raw) {
|
|
233
|
+
if (!Array.isArray(raw)) return [];
|
|
234
|
+
const out = [];
|
|
235
|
+
for (const h of raw) {
|
|
236
|
+
if (!h || typeof h !== 'object') continue;
|
|
237
|
+
const kind = h.kind === 'comment' || h.kind === 'origin' ? h.kind : 'reopen';
|
|
238
|
+
const attachments = Array.isArray(h.attachments)
|
|
239
|
+
? h.attachments
|
|
240
|
+
.filter((a) => a && typeof a === 'object')
|
|
241
|
+
.map((a) => ({
|
|
242
|
+
id: String(a.id || ''),
|
|
243
|
+
name: String(a.name || ''),
|
|
244
|
+
type: a.type === 'image' ? 'image' : 'file',
|
|
245
|
+
size: String(a.size || ''),
|
|
246
|
+
url: a.url ? String(a.url) : '',
|
|
247
|
+
}))
|
|
248
|
+
: [];
|
|
249
|
+
out.push({
|
|
250
|
+
id: Number(h.id) || out.length + 1,
|
|
251
|
+
kind,
|
|
252
|
+
at: String(h.at ?? ''),
|
|
253
|
+
text: String(h.text ?? ''),
|
|
254
|
+
summary: String(h.summary ?? ''),
|
|
255
|
+
status: String(h.status ?? ''),
|
|
256
|
+
completedAt: String(h.completedAt ?? ''),
|
|
257
|
+
quote: String(h.quote ?? ''),
|
|
258
|
+
feedback: String(h.feedback ?? ''),
|
|
259
|
+
attachments,
|
|
260
|
+
excerpt: String(h.excerpt ?? '')
|
|
261
|
+
.replace(/^#+\s*/, '')
|
|
262
|
+
.slice(0, 100),
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
return out;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// 任务链两套来源(#74 / 兼容 #69):
|
|
269
|
+
// history[] —— 同任务内就地重开/评论节点(主路径)
|
|
270
|
+
// forkOf 派生 —— 旧「新建任务」链(祖先 + 子任务)
|
|
271
|
+
// 三个原语:
|
|
232
272
|
// resolveForkRef —— 发布侧:裸数字(同主题)/'key:id'(跨主题)规范化 + 验证父任务存在
|
|
233
273
|
// forkRow —— 按引用取行(内部;软删/迁出不算存在)
|
|
234
|
-
// taskChain ——
|
|
274
|
+
// taskChain —— 查询侧:history 节点 + 祖先链 + 子任务
|
|
235
275
|
|
|
236
276
|
function forkRow(store, ref) {
|
|
237
277
|
const m = /^(.+):(\d+)$/.exec(String(ref || ''));
|
|
@@ -280,7 +320,7 @@ function chainLite(topic, t) {
|
|
|
280
320
|
};
|
|
281
321
|
}
|
|
282
322
|
|
|
283
|
-
/**
|
|
323
|
+
/** 任务链查询:同任务 history 节点 + 旧 forkOf 祖先/子任务。 */
|
|
284
324
|
export async function taskChain({ id, cwd, key } = {}) {
|
|
285
325
|
const k = resolveTaskKey({ key, cwd });
|
|
286
326
|
const want = Number(id);
|
|
@@ -290,6 +330,41 @@ export async function taskChain({ id, cwd, key } = {}) {
|
|
|
290
330
|
if (!t) throw notFound('主题不存在: ' + k);
|
|
291
331
|
const self = (t.tasks || []).find((x) => Number(x.id) === want && !x.deletedAt && !x.migratedTo);
|
|
292
332
|
if (!self) throw notFound('任务不存在或已删除: #' + want);
|
|
333
|
+
|
|
334
|
+
const history = normalizeHistory(self.history);
|
|
335
|
+
// nodes:history 按时间序 + 当前尖(live)。面板链图只吃这一列。
|
|
336
|
+
const nodes = history.map((h) => ({
|
|
337
|
+
historyId: h.id,
|
|
338
|
+
kind: h.kind,
|
|
339
|
+
at: h.at,
|
|
340
|
+
excerpt: h.excerpt || h.feedback?.slice(0, 100) || '',
|
|
341
|
+
feedback: h.feedback,
|
|
342
|
+
quote: h.quote,
|
|
343
|
+
summary: h.summary,
|
|
344
|
+
status: h.status,
|
|
345
|
+
completedAt: h.completedAt,
|
|
346
|
+
attachmentCount: (h.attachments || []).length,
|
|
347
|
+
current: false,
|
|
348
|
+
}));
|
|
349
|
+
const tipExcerpt =
|
|
350
|
+
String(self.text ?? '')
|
|
351
|
+
.split('\n')
|
|
352
|
+
.map((l) => l.trim())
|
|
353
|
+
.find(Boolean) || '';
|
|
354
|
+
nodes.push({
|
|
355
|
+
historyId: null,
|
|
356
|
+
kind: 'current',
|
|
357
|
+
at: String(self.lastReopenedAt || self.createdAt || ''),
|
|
358
|
+
excerpt: tipExcerpt.replace(/^#+\s*/, '').slice(0, 100),
|
|
359
|
+
feedback: '',
|
|
360
|
+
quote: '',
|
|
361
|
+
summary: String(self.roundSummary || ''),
|
|
362
|
+
status: self.status,
|
|
363
|
+
completedAt: String(self.completedAt || ''),
|
|
364
|
+
attachmentCount: 0,
|
|
365
|
+
current: true,
|
|
366
|
+
});
|
|
367
|
+
|
|
293
368
|
// 祖先链:visited 防环;上限 32(这是条链不是树,合理深度远小于它——超限即数据异常)
|
|
294
369
|
const ancestors = [];
|
|
295
370
|
const seen = new Set([`${k}:${want}`]);
|
|
@@ -306,7 +381,7 @@ export async function taskChain({ id, cwd, key } = {}) {
|
|
|
306
381
|
ancestors.push(chainLite(row.topic, row.task));
|
|
307
382
|
cur = String(row.task.forkOf || '');
|
|
308
383
|
}
|
|
309
|
-
//
|
|
384
|
+
// 子任务:派生落点可能换主题(旧 reopen 带 moveTo / 评论跨队列),所以全 store 扫
|
|
310
385
|
const ref = `${k}:${want}`;
|
|
311
386
|
const children = [];
|
|
312
387
|
for (const topic of Object.values(store.topics)) {
|
|
@@ -322,6 +397,8 @@ export async function taskChain({ id, cwd, key } = {}) {
|
|
|
322
397
|
name: t.name,
|
|
323
398
|
id: want,
|
|
324
399
|
task: normalizeTask(self, t.tasks),
|
|
400
|
+
nodes,
|
|
401
|
+
history,
|
|
325
402
|
ancestors,
|
|
326
403
|
children,
|
|
327
404
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** 划选浮层:格式条 + 统一「评论/反馈」组件(可粘贴/添加图片附件) */
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { filesToAttachments } from './attachments.js';
|
|
3
4
|
|
|
4
5
|
const FMT = [
|
|
5
6
|
{ op: 'bold', label: 'B', title: '粗体', cls: 'b' },
|
|
@@ -8,6 +9,24 @@ const FMT = [
|
|
|
8
9
|
{ op: 'link', label: '链', title: '链接', cls: 'link' },
|
|
9
10
|
];
|
|
10
11
|
|
|
12
|
+
function clipboardFiles(e) {
|
|
13
|
+
const out = [];
|
|
14
|
+
const cd = e.clipboardData;
|
|
15
|
+
if (!cd) return out;
|
|
16
|
+
if (cd.files?.length) {
|
|
17
|
+
for (const f of cd.files) out.push(f);
|
|
18
|
+
}
|
|
19
|
+
if (!out.length && cd.items?.length) {
|
|
20
|
+
for (const it of cd.items) {
|
|
21
|
+
if (it.kind === 'file') {
|
|
22
|
+
const f = it.getAsFile();
|
|
23
|
+
if (f) out.push(f);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
|
|
11
30
|
export default function SelMenu({
|
|
12
31
|
at,
|
|
13
32
|
onFormat,
|
|
@@ -18,12 +37,16 @@ export default function SelMenu({
|
|
|
18
37
|
}) {
|
|
19
38
|
const [composing, setComposing] = useState(false);
|
|
20
39
|
const [draft, setDraft] = useState('');
|
|
40
|
+
const [pendingAtt, setPendingAtt] = useState({ items: [], inserts: '' });
|
|
41
|
+
const [busy, setBusy] = useState(false);
|
|
21
42
|
const taRef = useRef(null);
|
|
43
|
+
const fileRef = useRef(null);
|
|
22
44
|
|
|
23
45
|
useEffect(() => {
|
|
24
46
|
setComposing(!!at?.comment);
|
|
25
47
|
setDraft('');
|
|
26
|
-
|
|
48
|
+
setPendingAtt({ items: [], inserts: '' });
|
|
49
|
+
}, [at?.text, at?.x, at?.y, at?.comment, at?.mode]);
|
|
27
50
|
|
|
28
51
|
useEffect(() => {
|
|
29
52
|
if (!composing) return undefined;
|
|
@@ -36,25 +59,61 @@ export default function SelMenu({
|
|
|
36
59
|
const showFmt = kind === 'format' || kind === 'both';
|
|
37
60
|
const quote = String(at.text || '');
|
|
38
61
|
const quoteShort = quote.length > 72 ? `${quote.slice(0, 72)}…` : quote;
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
const
|
|
62
|
+
const isFeedback = at.mode === 'feedback' || at.mode === 'redo';
|
|
63
|
+
const cap = isFeedback ? '反馈:写下要改的地方(将新开任务)' : '划线评论(回写本任务)';
|
|
64
|
+
const canSubmit = !!draft.trim() || pendingAtt.items.length > 0;
|
|
42
65
|
|
|
43
66
|
const startCompose = () => {
|
|
44
67
|
setComposing(true);
|
|
45
|
-
onCompose?.();
|
|
68
|
+
onCompose?.();
|
|
46
69
|
};
|
|
47
70
|
|
|
48
71
|
const cancelCompose = () => {
|
|
49
72
|
setComposing(false);
|
|
50
73
|
setDraft('');
|
|
51
|
-
|
|
74
|
+
setPendingAtt({ items: [], inserts: '' });
|
|
75
|
+
onClose?.();
|
|
52
76
|
};
|
|
53
77
|
|
|
54
78
|
const submit = () => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
79
|
+
if (!canSubmit || busy) return;
|
|
80
|
+
onComment?.({
|
|
81
|
+
text: draft.trim(),
|
|
82
|
+
attachments: pendingAtt.items,
|
|
83
|
+
inserts: pendingAtt.inserts,
|
|
84
|
+
mode: isFeedback ? 'feedback' : 'comment',
|
|
85
|
+
quote,
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const pickFiles = async (fileList) => {
|
|
90
|
+
if (!fileList?.length) return;
|
|
91
|
+
setBusy(true);
|
|
92
|
+
try {
|
|
93
|
+
const { items, imageInserts, fileInserts } = await filesToAttachments(fileList);
|
|
94
|
+
const inserts = [...(imageInserts || []), ...(fileInserts || [])].join('');
|
|
95
|
+
setPendingAtt((prev) => ({
|
|
96
|
+
items: [...prev.items, ...items],
|
|
97
|
+
inserts: `${prev.inserts}${inserts}`,
|
|
98
|
+
}));
|
|
99
|
+
} finally {
|
|
100
|
+
setBusy(false);
|
|
101
|
+
if (fileRef.current) fileRef.current.value = '';
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const onPaste = (e) => {
|
|
106
|
+
const files = clipboardFiles(e);
|
|
107
|
+
if (!files.length) return; // 纯文本走默认粘贴
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
pickFiles(files);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const onDrop = (e) => {
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
e.stopPropagation();
|
|
115
|
+
const files = [...(e.dataTransfer?.files || [])];
|
|
116
|
+
if (files.length) pickFiles(files);
|
|
58
117
|
};
|
|
59
118
|
|
|
60
119
|
return (
|
|
@@ -64,13 +123,19 @@ export default function SelMenu({
|
|
|
64
123
|
style={{ left: at.x, top: at.y }}
|
|
65
124
|
role="menu"
|
|
66
125
|
onMouseDown={(e) => {
|
|
67
|
-
|
|
68
|
-
if (e.target.closest?.('textarea, input')) return;
|
|
126
|
+
if (e.target.closest?.('textarea, input, button')) return;
|
|
69
127
|
e.preventDefault();
|
|
70
128
|
}}
|
|
71
129
|
>
|
|
72
130
|
{composing ? (
|
|
73
|
-
<div
|
|
131
|
+
<div
|
|
132
|
+
className="mdw-sel-comment"
|
|
133
|
+
onDragOver={(e) => {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
e.stopPropagation();
|
|
136
|
+
}}
|
|
137
|
+
onDrop={onDrop}
|
|
138
|
+
>
|
|
74
139
|
<div className="mdw-sel-comment-cap">{cap}</div>
|
|
75
140
|
{quote ? (
|
|
76
141
|
<div className="mdw-sel-quote" title={quote}>{quoteShort}</div>
|
|
@@ -80,9 +145,10 @@ export default function SelMenu({
|
|
|
80
145
|
className="mdw-sel-comment-ta"
|
|
81
146
|
rows={3}
|
|
82
147
|
value={draft}
|
|
83
|
-
placeholder={
|
|
84
|
-
aria-label=
|
|
148
|
+
placeholder={isFeedback ? '写下反馈…可粘贴/拖入图片' : '对此处提出问题…可粘贴/拖入图片'}
|
|
149
|
+
aria-label={isFeedback ? '反馈文本' : '评论文本'}
|
|
85
150
|
onChange={(e) => setDraft(e.target.value)}
|
|
151
|
+
onPaste={onPaste}
|
|
86
152
|
onKeyDown={(e) => {
|
|
87
153
|
if (e.key === 'Escape') {
|
|
88
154
|
e.preventDefault();
|
|
@@ -96,20 +162,47 @@ export default function SelMenu({
|
|
|
96
162
|
}
|
|
97
163
|
}}
|
|
98
164
|
/>
|
|
165
|
+
{pendingAtt.items.length ? (
|
|
166
|
+
<div className="mdw-sel-att-list">
|
|
167
|
+
{pendingAtt.items.map((a) => (
|
|
168
|
+
<span key={a.id} className="mdw-sel-att-chip" title={a.name}>
|
|
169
|
+
{a.type === 'image' ? '🖼' : '📎'} {a.name}
|
|
170
|
+
</span>
|
|
171
|
+
))}
|
|
172
|
+
</div>
|
|
173
|
+
) : null}
|
|
99
174
|
<div className="mdw-sel-comment-acts">
|
|
175
|
+
<input
|
|
176
|
+
ref={fileRef}
|
|
177
|
+
type="file"
|
|
178
|
+
multiple
|
|
179
|
+
hidden
|
|
180
|
+
accept="image/*,*/*"
|
|
181
|
+
onChange={(e) => pickFiles(e.target.files)}
|
|
182
|
+
/>
|
|
183
|
+
<button
|
|
184
|
+
type="button"
|
|
185
|
+
className="ghost"
|
|
186
|
+
disabled={busy}
|
|
187
|
+
title="添加图片或附件(也可粘贴/拖入)"
|
|
188
|
+
onClick={() => fileRef.current?.click()}
|
|
189
|
+
>
|
|
190
|
+
{busy ? '上传中…' : '附件'}
|
|
191
|
+
</button>
|
|
192
|
+
<span className="grow" />
|
|
100
193
|
<button type="button" className="ghost" onClick={cancelCompose}>
|
|
101
194
|
取消
|
|
102
195
|
</button>
|
|
103
196
|
<button
|
|
104
197
|
type="button"
|
|
105
198
|
className="primary"
|
|
106
|
-
disabled={!
|
|
199
|
+
disabled={!canSubmit || busy}
|
|
107
200
|
onClick={submit}
|
|
108
201
|
>
|
|
109
|
-
{
|
|
202
|
+
{isFeedback ? '新开任务' : '回写本任务'}
|
|
110
203
|
</button>
|
|
111
204
|
</div>
|
|
112
|
-
<div className="mdw-sel-comment-hint">Ctrl/⌘+Enter
|
|
205
|
+
<div className="mdw-sel-comment-hint">Ctrl/⌘+Enter 提交 · 粘贴/拖入图片 · 附件</div>
|
|
113
206
|
</div>
|
|
114
207
|
) : (
|
|
115
208
|
<>
|
|
@@ -134,7 +227,7 @@ export default function SelMenu({
|
|
|
134
227
|
<button
|
|
135
228
|
type="button"
|
|
136
229
|
className="mdw-sel-fmt-btn comment"
|
|
137
|
-
title="划线评论 →
|
|
230
|
+
title="划线评论 → 回写本任务"
|
|
138
231
|
onClick={startCompose}
|
|
139
232
|
>
|
|
140
233
|
评论
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** 任务链可视化(#77):弹窗内展示;history 或 fork 祖先/子任务,点节点旁路查看。 */
|
|
2
|
+
import { Modal } from '../popup/index.jsx';
|
|
3
|
+
|
|
4
|
+
const KIND_LAB = {
|
|
5
|
+
origin: '起点',
|
|
6
|
+
reopen: '反馈',
|
|
7
|
+
comment: '评论',
|
|
8
|
+
current: '当前',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function ChainList({ nodes = [], onOpenNode }) {
|
|
12
|
+
if (!nodes.length) {
|
|
13
|
+
return <div className="mdw-chain-empty muted">这条任务还没有链(反馈 / 评论派生后会出现)</div>;
|
|
14
|
+
}
|
|
15
|
+
return (
|
|
16
|
+
<ol className="mdw-chain-list" aria-label="任务链节点">
|
|
17
|
+
{nodes.map((n, i) => {
|
|
18
|
+
const key = n.current
|
|
19
|
+
? 'current'
|
|
20
|
+
: n.historyId != null
|
|
21
|
+
? `h-${n.historyId}`
|
|
22
|
+
: `t-${n.dirKey || ''}-${n.taskId ?? i}`;
|
|
23
|
+
const lab = KIND_LAB[n.kind] || n.kind || '?';
|
|
24
|
+
const title = n.excerpt || n.feedback || lab;
|
|
25
|
+
const meta = [
|
|
26
|
+
n.taskId != null ? `#${n.taskId}` : null,
|
|
27
|
+
n.at || null,
|
|
28
|
+
n.attachmentCount ? `📎${n.attachmentCount}` : null,
|
|
29
|
+
]
|
|
30
|
+
.filter(Boolean)
|
|
31
|
+
.join(' · ');
|
|
32
|
+
return (
|
|
33
|
+
<li key={key} className={`mdw-chain-li${n.current ? ' is-current' : ''}`}>
|
|
34
|
+
<div className="mdw-chain-rail" aria-hidden>
|
|
35
|
+
<span className="mdw-chain-dot" />
|
|
36
|
+
{i < nodes.length - 1 ? <span className="mdw-chain-line" /> : null}
|
|
37
|
+
</div>
|
|
38
|
+
<button
|
|
39
|
+
type="button"
|
|
40
|
+
className={`mdw-chain-card${n.kind === 'comment' ? ' is-comment' : ''}`}
|
|
41
|
+
title={n.current ? '当前任务(本页)' : `查看:${title}`}
|
|
42
|
+
disabled={!!n.current}
|
|
43
|
+
onClick={() => {
|
|
44
|
+
if (!n.current) onOpenNode?.(n);
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<span className="mdw-chain-kind">{lab}</span>
|
|
48
|
+
<span className="mdw-chain-ex">{title || '—'}</span>
|
|
49
|
+
{meta ? <span className="mdw-chain-meta">{meta}</span> : null}
|
|
50
|
+
</button>
|
|
51
|
+
</li>
|
|
52
|
+
);
|
|
53
|
+
})}
|
|
54
|
+
</ol>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** 「更多 → 任务链」弹窗 */
|
|
59
|
+
export function TaskChainModal({ open, nodes, onOpenNode, onClose }) {
|
|
60
|
+
if (!open) return null;
|
|
61
|
+
return (
|
|
62
|
+
<Modal title="任务链" onClose={onClose} size="md" className="mdw-chain-modal">
|
|
63
|
+
<p className="mdw-chain-hint">从早到晚排列。点非当前节点可在旁路打开内容。</p>
|
|
64
|
+
<ChainList
|
|
65
|
+
nodes={nodes}
|
|
66
|
+
onOpenNode={(n) => {
|
|
67
|
+
onOpenNode?.(n);
|
|
68
|
+
onClose?.();
|
|
69
|
+
}}
|
|
70
|
+
/>
|
|
71
|
+
</Modal>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default ChainList;
|