nx-kv 0.4.1 → 0.6.0
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 +31 -0
- package/README.md +4 -1
- package/assets/groups.json +14 -0
- package/package.json +1 -1
- package/src/modules/bundled/index.js +137 -19
- package/src/modules/bundled/service.js +218 -16
- package/src/modules/sessiontask/index.js +19 -0
- package/src/modules/sessiontask/service.js +49 -0
- package/src/modules/sessiontask/view.jsx +116 -8
- package/src/web/public/assets/{CliHints-ChSGOGe2.js → CliHints-uNZoZkhO.js} +1 -1
- package/src/web/public/assets/{index-BRHRrC1Y.js → index-DDDim1NE.js} +2 -2
- package/src/web/public/assets/{view-DgoHpORS.js → view-CVVca46Z.js} +1 -1
- package/src/web/public/assets/{view-Bz43nKKp.js → view-D7T4AoiM.js} +1 -1
- package/src/web/public/assets/view-DpGJgXe_.js +1 -0
- package/src/web/public/assets/{view-BkFTel2t.js → view-DqK-OdJn.js} +1 -1
- package/src/web/public/index.html +1 -1
- package/src/web/public/assets/view-DMK3MwZZ.js +0 -1
|
@@ -36,6 +36,11 @@ export default function SessionTaskView() {
|
|
|
36
36
|
const [editText, setEditText] = useState('');
|
|
37
37
|
const [editSaving, setEditSaving] = useState(false);
|
|
38
38
|
|
|
39
|
+
// 拖拽重排(仅待领取任务)
|
|
40
|
+
const [dragId, setDragId] = useState(null);
|
|
41
|
+
const [over, setOver] = useState(null); // { id, pos:'top'|'bottom' }
|
|
42
|
+
const [reordering, setReordering] = useState(false);
|
|
43
|
+
|
|
39
44
|
const load = useCallback(async () => {
|
|
40
45
|
try {
|
|
41
46
|
setOverview(await api('/api/sessiontasks'));
|
|
@@ -169,6 +174,55 @@ export default function SessionTaskView() {
|
|
|
169
174
|
|
|
170
175
|
const tasks = active ? active.tasks.slice().reverse() : [];
|
|
171
176
|
|
|
177
|
+
// 待领取任务按「领取优先级」(数组真实顺序,未反转)排列;上移/置后据此定位相邻项
|
|
178
|
+
const pendingOrder = active ? active.tasks.filter((t) => t.status !== 'consumed') : [];
|
|
179
|
+
|
|
180
|
+
// 把 dragId 移到 beforeId 之前 / afterId 之后(数组顺序)
|
|
181
|
+
const applyReorder = (id, { beforeId, afterId }) =>
|
|
182
|
+
guard(async () => {
|
|
183
|
+
setReordering(true);
|
|
184
|
+
try {
|
|
185
|
+
await api('/api/sessiontasks/reorder', {
|
|
186
|
+
method: 'PATCH',
|
|
187
|
+
body: { cwd: active.cwd, id, beforeId, afterId },
|
|
188
|
+
});
|
|
189
|
+
toast('已调整领取优先级');
|
|
190
|
+
await load();
|
|
191
|
+
} finally {
|
|
192
|
+
setReordering(false);
|
|
193
|
+
setDragId(null);
|
|
194
|
+
setOver(null);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// 提前/置后一步(在 pending 子序列里移动),作为拖拽之外的兜底(窄屏/触屏友好)
|
|
199
|
+
const stepPriority = (t, dir) => {
|
|
200
|
+
const i = pendingOrder.findIndex((x) => x.id === t.id);
|
|
201
|
+
if (dir === 'up' && i > 0) applyReorder(t.id, { beforeId: pendingOrder[i - 1].id });
|
|
202
|
+
if (dir === 'down' && i < pendingOrder.length - 1) applyReorder(t.id, { afterId: pendingOrder[i + 1].id });
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// 表格反转显示:视觉上「上方」= 数组里更靠后。落点在目标行上半 → 拖到它数组之后;
|
|
206
|
+
// 下半 → 拖到它数组之前。
|
|
207
|
+
const onRowDragOver = (e, t) => {
|
|
208
|
+
if (dragId === null || t.status === 'consumed' || dragId === t.id) return;
|
|
209
|
+
e.preventDefault();
|
|
210
|
+
e.dataTransfer.dropEffect = 'move';
|
|
211
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
212
|
+
const pos = e.clientY < rect.top + rect.height / 2 ? 'top' : 'bottom';
|
|
213
|
+
setOver((o) => (o && o.id === t.id && o.pos === pos ? o : { id: t.id, pos }));
|
|
214
|
+
};
|
|
215
|
+
const onRowDrop = (e, t) => {
|
|
216
|
+
if (dragId === null || t.status === 'consumed' || dragId === t.id) return;
|
|
217
|
+
e.preventDefault();
|
|
218
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
219
|
+
const top = e.clientY < rect.top + rect.height / 2;
|
|
220
|
+
const moved = dragId;
|
|
221
|
+
setDragId(null);
|
|
222
|
+
setOver(null);
|
|
223
|
+
applyReorder(moved, top ? { afterId: t.id } : { beforeId: t.id });
|
|
224
|
+
};
|
|
225
|
+
|
|
172
226
|
return (
|
|
173
227
|
<>
|
|
174
228
|
<div className="card" style={{ padding: '10px 14px' }}>
|
|
@@ -298,23 +352,55 @@ export default function SessionTaskView() {
|
|
|
298
352
|
<div className="colhead">
|
|
299
353
|
<h3>该主题的任务队列</h3>
|
|
300
354
|
<span className="muted">待领取 {active.pending} · 共 {active.total} 条</span>
|
|
355
|
+
<span className="muted" style={{ fontSize: 12, marginLeft: 'auto' }}>
|
|
356
|
+
拖拽待领取行(或用「提前/置后」)调整领取优先级
|
|
357
|
+
</span>
|
|
301
358
|
</div>
|
|
302
359
|
|
|
303
360
|
<div className="card" style={{ padding: 4 }}>
|
|
304
361
|
<table>
|
|
305
362
|
<thead>
|
|
306
363
|
<tr>
|
|
364
|
+
<th style={{ width: 34 }}></th>
|
|
307
365
|
<th style={{ width: 56 }}>#</th>
|
|
308
366
|
<th>任务</th>
|
|
309
367
|
<th style={{ width: 80 }}>状态</th>
|
|
310
368
|
<th style={{ width: 160 }}>时间</th>
|
|
311
|
-
<th style={{ width:
|
|
369
|
+
<th style={{ width: 150 }}>操作</th>
|
|
312
370
|
</tr>
|
|
313
371
|
</thead>
|
|
314
372
|
<tbody>
|
|
315
373
|
{tasks.length ? (
|
|
316
|
-
tasks.map((t) =>
|
|
317
|
-
|
|
374
|
+
tasks.map((t) => {
|
|
375
|
+
const isPending = t.status !== 'consumed';
|
|
376
|
+
const isDrag = dragId === t.id;
|
|
377
|
+
const isOver = over && over.id === t.id;
|
|
378
|
+
return (
|
|
379
|
+
<tr
|
|
380
|
+
key={t.id}
|
|
381
|
+
draggable={isPending && editingId !== t.id}
|
|
382
|
+
onDragStart={(e) => {
|
|
383
|
+
setDragId(t.id);
|
|
384
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
385
|
+
try { e.dataTransfer.setData('text/plain', String(t.id)); } catch { /* 某些浏览器需 setData 才能拖拽 */ }
|
|
386
|
+
}}
|
|
387
|
+
onDragOver={(e) => onRowDragOver(e, t)}
|
|
388
|
+
onDrop={(e) => onRowDrop(e, t)}
|
|
389
|
+
onDragEnd={() => { setDragId(null); setOver(null); }}
|
|
390
|
+
style={{
|
|
391
|
+
cursor: isPending && editingId !== t.id ? 'grab' : 'default',
|
|
392
|
+
opacity: isDrag ? 0.4 : 1,
|
|
393
|
+
boxShadow: isOver
|
|
394
|
+
? over.pos === 'top'
|
|
395
|
+
? 'inset 0 2px 0 var(--ink,#14161a)'
|
|
396
|
+
: 'inset 0 -2px 0 var(--ink,#14161a)'
|
|
397
|
+
: 'none',
|
|
398
|
+
background: isOver ? 'rgba(20,22,26,.04)' : undefined,
|
|
399
|
+
}}
|
|
400
|
+
>
|
|
401
|
+
<td className="mono muted" title="按住拖拽调整优先级" style={{ textAlign: 'center', userSelect: 'none' }}>
|
|
402
|
+
{isPending ? '⠿' : ''}
|
|
403
|
+
</td>
|
|
318
404
|
<td className="mono">#{t.id}</td>
|
|
319
405
|
<td style={{ whiteSpace: 'pre-wrap' }}>
|
|
320
406
|
{editingId === t.id ? (
|
|
@@ -369,16 +455,38 @@ export default function SessionTaskView() {
|
|
|
369
455
|
</td>
|
|
370
456
|
<td className="mono">{t.consumedAt || t.createdAt}</td>
|
|
371
457
|
<td className="ops">
|
|
372
|
-
{
|
|
373
|
-
|
|
374
|
-
|
|
458
|
+
{isPending && editingId !== t.id && (() => {
|
|
459
|
+
const pi = pendingOrder.findIndex((x) => x.id === t.id);
|
|
460
|
+
return (
|
|
461
|
+
<>
|
|
462
|
+
<button className="btn small ghost" onClick={() => startEdit(t)}>编辑</button>
|
|
463
|
+
<button
|
|
464
|
+
className="btn small ghost"
|
|
465
|
+
title="提高优先级(更早被领取)"
|
|
466
|
+
disabled={reordering || pi <= 0}
|
|
467
|
+
onClick={() => stepPriority(t, 'up')}
|
|
468
|
+
>
|
|
469
|
+
提前
|
|
470
|
+
</button>
|
|
471
|
+
<button
|
|
472
|
+
className="btn small ghost"
|
|
473
|
+
title="降低优先级(更晚被领取)"
|
|
474
|
+
disabled={reordering || pi >= pendingOrder.length - 1}
|
|
475
|
+
onClick={() => stepPriority(t, 'down')}
|
|
476
|
+
>
|
|
477
|
+
置后
|
|
478
|
+
</button>
|
|
479
|
+
</>
|
|
480
|
+
);
|
|
481
|
+
})()}
|
|
375
482
|
<button className="btn small ghost" onClick={() => remove(t.id)}>删除</button>
|
|
376
483
|
</td>
|
|
377
484
|
</tr>
|
|
378
|
-
|
|
485
|
+
);
|
|
486
|
+
})
|
|
379
487
|
) : (
|
|
380
488
|
<tr>
|
|
381
|
-
<td colSpan="
|
|
489
|
+
<td colSpan="6" className="muted" style={{ textAlign: 'center', padding: '22px 0' }}>
|
|
382
490
|
(暂无任务,在上方回填第一条)
|
|
383
491
|
</td>
|
|
384
492
|
</tr>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,s as t,t as n}from"./index-
|
|
1
|
+
import{o as e,s as t,t as n}from"./index-DDDim1NE.js";var r=t();function i({module:t}){let{boot:i}=e(),a=(i?.commands||[]).filter(e=>e.module===t);return a.length?(0,r.jsxs)(`div`,{className:`cli-hint`,children:[(0,r.jsx)(`span`,{className:`cli-hint-label`,children:`CLI 等价(同构命令,加 --json 得机器可读输出):`}),a.map(e=>(0,r.jsx)(n,{className:`cli-cmd`,text:e.command,title:`点击复制:${e.usage}`,children:e.command},e.id))]}):null}export{i as t};
|