nx-kv 0.53.4 → 0.54.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 +46 -0
- package/assets/nx-kv/references/A01-/351/242/206/345/217/226/344/273/273/345/212/241.md +2 -1
- package/assets/nx-kv/references/B02-CLI/351/200/237/346/237/245.md +1 -0
- package/package.json +1 -1
- package/src/core/db/migrations/index.ts +2 -0
- package/src/core/db/migrations/v9.sql +111 -0
- package/src/core/db/version.ts +3 -1
- package/src/modules/localtask/actions/_manifest.generated.ts +6 -0
- package/src/modules/localtask/actions/localtask-add.ts +6 -1
- package/src/modules/localtask/actions/localtask-claim.ts +7 -1
- package/src/modules/localtask/actions/localtask-done.ts +2 -0
- package/src/modules/localtask/actions/localtask-get.ts +2 -0
- package/src/modules/localtask/actions/localtask-plan.ts +38 -0
- package/src/modules/localtask/actions/localtask-reopen.ts +2 -0
- package/src/modules/localtask/actions/localtask-tasks.ts +113 -0
- package/src/modules/localtask/actions/localtask-update.ts +6 -1
- package/src/modules/localtask/contract-views.ts +129 -0
- package/src/modules/localtask/task-ops.ts +49 -0
- package/src/runtime/dartgen.ts +32 -7
- package/src/shared/task-status.ts +12 -0
- package/src/web/frontend/api/cli-tree.json +30 -0
- package/src/web/frontend/api/client.generated.ts +25 -0
- package/src/web/frontend/components/status-tag/model.ts +4 -2
- package/src/web/frontend/components/tool-acts/modules.ts +2 -0
- package/src/web/frontend/page/dir/api.ts +8 -0
- package/src/web/frontend/page/dir/landing.tsx +42 -0
- package/src/web/frontend/styles/board.css +2 -0
- package/src/web/public/assets/app-context-CR7f0AtI.js +1 -0
- package/src/web/public/assets/{bar-BBGb6Y5_.js → bar-BnAUiBVi.js} +1 -1
- package/src/web/public/assets/{board-view-BJCwrtHc.js → board-view-CUeSVy9F.js} +1 -1
- package/src/web/public/assets/{composer-launch-CjUpcCqD.js → composer-launch-DMiU1boX.js} +1 -1
- package/src/web/public/assets/{composer-panel-ECutPtRA.js → composer-panel-D2OattCj.js} +1 -1
- package/src/web/public/assets/{dag-DISpxumr.js → dag-BzD3ZlnO.js} +1 -1
- package/src/web/public/assets/dir-BOhkvibf.js +3 -0
- package/src/web/public/assets/{doc-CmGraKDe.js → doc-ByHuXtbj.js} +2 -2
- package/src/web/public/assets/{frontmatter-b044qTyx.js → frontmatter-DEIM0yF2.js} +2 -2
- package/src/web/public/assets/{group-BA0tiEYP.js → group-0T2ZesQD.js} +1 -1
- package/src/web/public/assets/{index-C2C8mDHD.js → index-B2y5VfCY.js} +2 -2
- package/src/web/public/assets/index-B3LEHx5-.css +1 -0
- package/src/web/public/assets/{md-history-8KUZ9ipc.js → md-history-DUv-eEJZ.js} +5 -5
- package/src/web/public/assets/{md-parse-Bqb35k5w.js → md-parse-uaOFbIcA.js} +1 -1
- package/src/web/public/assets/{member-picker-CQksP35E.js → member-picker-B_LsCqNq.js} +1 -1
- package/src/web/public/assets/{model-lEeblPg0.js → model-Co--HRvt.js} +1 -1
- package/src/web/public/assets/{overview-VC4HFUS_.js → overview-DfrlYtyR.js} +1 -1
- package/src/web/public/assets/{progress-D0qBwZIV.js → progress-BsodHm4N.js} +2 -2
- package/src/web/public/assets/{refs-BhgP7Ryy.js → refs-D2v1gDms.js} +1 -1
- package/src/web/public/assets/{repo-form-modal-B_ruPwr0.js → repo-form-modal-DAhj7-rY.js} +1 -1
- package/src/web/public/assets/{repos-DP6AFrI6.js → repos-CyZSu5OK.js} +8 -8
- package/src/web/public/assets/{route-crumb-BHZU-2HE.js → route-crumb-CkhC1zw2.js} +1 -1
- package/src/web/public/assets/{settings-C_8mDUqx.js → settings-BjaJ9Ch2.js} +2 -2
- package/src/web/public/assets/status-tag-BKA9au1l.js +1 -0
- package/src/web/public/assets/{task-row-3OXcmAJb.js → task-row-CHSIDNmR.js} +1 -1
- package/src/web/public/assets/{task-IoEm4Lmw.js → task-skIHoMBy.js} +5 -5
- package/src/web/public/assets/task-utils-Bdx7ApC1.js +12 -0
- package/src/web/public/assets/{templates-B2zDwQG0.js → templates-dDCoK97L.js} +1 -1
- package/src/web/public/assets/use-rail-drag-BeDwWqzF.js +1 -0
- package/src/web/public/assets/{workspace-BwpvQUst.js → workspace-C0PPPfA1.js} +3 -3
- package/src/web/public/index.html +14 -14
- package/src/web/public/assets/app-context-B0QwHGOd.js +0 -1
- package/src/web/public/assets/dir-B8B1sEfY.js +0 -3
- package/src/web/public/assets/index-59ZF4OlE.css +0 -1
- package/src/web/public/assets/status-tag-DC7mdpkI.js +0 -1
- package/src/web/public/assets/task-utils-BqIPKFHQ.js +0 -12
- package/src/web/public/assets/use-rail-drag-2mF0AHna.js +0 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// localtask 的**跨语言出参视图**(契约用,见 ActionMeta.output)。
|
|
2
|
+
//
|
|
3
|
+
// 为什么单独一个文件:`localtask.get` / `claim` / `done` / `reopen` / `add` / `update`
|
|
4
|
+
// 六条 action 都要往外说话,其中「一条任务长什么样」必须**只写一次**——写成六份,
|
|
5
|
+
// 字段迟早分叉,端侧就会看到「同一个东西,两个名字」。
|
|
6
|
+
//
|
|
7
|
+
// 一条纪律:**这里是视图,不是 service 的返回结构**。
|
|
8
|
+
// · `localtask.list` 刻意不声明 `tasks`(每个主题挂着全部任务,某主题实测 194 条);
|
|
9
|
+
// · `claim` / `done` / `reopen` 刻意不声明 `task` 整体,只给 `taskId`——
|
|
10
|
+
// 端侧要看详情就调 `localtask.get`,别让「领一条」变成「解码一份长正文」;
|
|
11
|
+
// · 声明少了不影响服务端返回(契约不裁剪运行时响应,见设计 §4.3),
|
|
12
|
+
// CLI 与 HTTP 的完整返回一个字都不变。
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
|
|
15
|
+
/** 正文里引用到的一个附件(服务端已标好本地路径与用法)。 */
|
|
16
|
+
export const attachmentView = z.object({
|
|
17
|
+
id: z.string(),
|
|
18
|
+
kind: z.string().describe('file / url / task / ref …'),
|
|
19
|
+
kindLabel: z.string().describe('给人看的种类名'),
|
|
20
|
+
name: z.string(),
|
|
21
|
+
sizeText: z.string().describe('已格式化的大小(65.8 KB);url 类可能为空串'),
|
|
22
|
+
isImage: z.boolean(),
|
|
23
|
+
size: z.int().optional(),
|
|
24
|
+
mime: z.string().optional(),
|
|
25
|
+
note: z.string().optional().describe('附件上的备注(原型图、日志…)'),
|
|
26
|
+
localPath: z.string().optional().describe('本机绝对路径;未落盘时为空'),
|
|
27
|
+
exists: z.boolean().optional().describe('本地文件是否还在'),
|
|
28
|
+
needsSync: z.boolean().optional(),
|
|
29
|
+
cmd: z.string().optional().describe('需要同步时给用户的一条命令'),
|
|
30
|
+
usage: z.string().optional().describe('agent/端侧该怎么用它(已在本机就直接读)'),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/** 一条任务:端侧详情页要显示的全部字段。 */
|
|
34
|
+
export const taskView = z.object({
|
|
35
|
+
id: z.int().describe('任务编号(主题内自增,跨主题不唯一)'),
|
|
36
|
+
text: z.string().describe('正文(Markdown,可能带 frontmatter)'),
|
|
37
|
+
status: z.string().describe('pending / claimed / done / cancelled'),
|
|
38
|
+
round: z.int().describe('第几轮(每次重开 +1)'),
|
|
39
|
+
roundSummary: z.string().describe('本轮完成总结;未完成时为空串'),
|
|
40
|
+
reopenCount: z.int(),
|
|
41
|
+
childCount: z.int(),
|
|
42
|
+
childRoundCount: z.int(),
|
|
43
|
+
createdAt: z.string(),
|
|
44
|
+
consumedAt: z.string().describe('被领取的时间;未领取为空串'),
|
|
45
|
+
pickupSec: z.int().nullable().describe('入队到领取的秒数;未领取为 null'),
|
|
46
|
+
completedAt: z.string(),
|
|
47
|
+
doneAt: z.string(),
|
|
48
|
+
feedback: z.string().describe('完成总结原文(与服务端历史同一份)'),
|
|
49
|
+
claimedBy: z.string().describe('领取方标识(agent / 端侧)'),
|
|
50
|
+
claimedByName: z.string(),
|
|
51
|
+
claimedFrom: z.string().describe('local / global'),
|
|
52
|
+
ready: z.boolean().describe('当前是否「可领取」'),
|
|
53
|
+
blocksFollowing: z.boolean().describe('是否为闸门任务'),
|
|
54
|
+
blockBy: z.array(z.string()).describe('依赖的任务 id(全部完成后本条才可领)'),
|
|
55
|
+
deletedAt: z.string(),
|
|
56
|
+
archivedAt: z.string(),
|
|
57
|
+
archivedReason: z.string(),
|
|
58
|
+
attachments: z
|
|
59
|
+
.array(attachmentView)
|
|
60
|
+
.optional()
|
|
61
|
+
.describe('正文引用到的附件;标注失败时整个字段缺失(fail-open)'),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 「领一条」的结果视图。
|
|
66
|
+
*
|
|
67
|
+
* status 是**三态闭集**:ok 领到 / timeout 暂时没活 / blocked 被依赖或闸门挡住。
|
|
68
|
+
* 端侧据此决定「进详情」「停在队列」「解释为什么领不了」,不必解析错误文本。
|
|
69
|
+
*
|
|
70
|
+
* 只回**编号**不回整条任务:领到手的那一刻端侧要跳详情,但详情页的正文、
|
|
71
|
+
* 附件、轮次是 `localtask.get` 的活 —— 让「领一条」顺手多解码一份长正文,
|
|
72
|
+
* 是端侧最容易被拖慢的地方(历史某主题一条正文 200KB)。
|
|
73
|
+
*/
|
|
74
|
+
export const claimView = z.object({
|
|
75
|
+
status: z.enum(['ok', 'timeout', 'blocked']).describe('领取结果:ok / timeout / blocked'),
|
|
76
|
+
taskId: z.int().optional().describe('领到的任务编号(status=ok 时有)'),
|
|
77
|
+
name: z.string().optional().describe('主题名'),
|
|
78
|
+
summary: z.string().optional().describe('主题现状'),
|
|
79
|
+
timeoutMs: z.int().optional().describe('timeout 时的等待上限(毫秒)'),
|
|
80
|
+
instant: z.boolean().optional().describe('是否为「没活就立刻回」的即时模式'),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/** 「新建一条」的结果视图(只回编号:详情交给 `localtask.get`)。 */
|
|
84
|
+
export const addView = z.object({
|
|
85
|
+
status: z.string(),
|
|
86
|
+
id: z.int().describe('新任务编号'),
|
|
87
|
+
name: z.string().optional().describe('落进哪个主题'),
|
|
88
|
+
cwd: z.string().optional(),
|
|
89
|
+
delivered: z.boolean().optional().describe('是否即时投递给正在 wait 的 agent'),
|
|
90
|
+
queued: z.boolean().optional().describe('是否只是排队等人领取'),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
/** 「改正文」的结果视图(只回编号)。 */
|
|
94
|
+
export const updateView = z.object({
|
|
95
|
+
status: z.string(),
|
|
96
|
+
id: z.int().describe('被改的任务编号'),
|
|
97
|
+
name: z.string().optional().describe('当前所在主题'),
|
|
98
|
+
cwd: z.string().optional(),
|
|
99
|
+
moved: z.boolean().optional().describe('是否因归属变了而换了队列'),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
/** 「标完成」的结果视图。 */
|
|
103
|
+
export const doneView = z.object({
|
|
104
|
+
status: z.string().describe('ok / blocked'),
|
|
105
|
+
completed: z.boolean().optional().describe('本次是否真的标成了完成'),
|
|
106
|
+
already: z.boolean().optional().describe('之前就已经完成过(无需重复标记)'),
|
|
107
|
+
completedAt: z.string().optional(),
|
|
108
|
+
reason: z.string().optional().describe('blocked 的原因:not_claimed / goal_not_reached …'),
|
|
109
|
+
remainingSec: z.int().optional().describe('时间目标未到点时还差多少秒'),
|
|
110
|
+
deadline: z.string().optional().describe('时间目标的截止时间'),
|
|
111
|
+
hint: z.string().optional().describe('给人看的下一步提示'),
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 「重开 / 评论」的结果视图。
|
|
116
|
+
*
|
|
117
|
+
* 注意 `id` 是**新任务**的编号,`parentId` 才是被评论的那条——
|
|
118
|
+
* 端侧提交完评价后应该跳到 `id`,否则会停在一条已经被历史压住的任务上。
|
|
119
|
+
*/
|
|
120
|
+
export const reopenView = z.object({
|
|
121
|
+
status: z.string(),
|
|
122
|
+
id: z.int().describe('重开后产生的新任务编号'),
|
|
123
|
+
parentId: z.int().optional().describe('被重开的原任务编号'),
|
|
124
|
+
kind: z.string().optional().describe('reopen(验收反馈)/ comment(划选评论)'),
|
|
125
|
+
name: z.string().optional(),
|
|
126
|
+
moved: z.boolean().optional().describe('是否因正文里的归属变了而换了队列'),
|
|
127
|
+
reopened: z.boolean().optional(),
|
|
128
|
+
forked: z.boolean().optional(),
|
|
129
|
+
});
|
|
@@ -492,3 +492,52 @@ export async function forkTask({ cwd: rawCwd, key: rawKey, id }: TaskAddress = {
|
|
|
492
492
|
});
|
|
493
493
|
return { ...res, forked: true, from: { key, id: want } };
|
|
494
494
|
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* #126:在 `pending ↔ plan` 之间切换一条任务的状态。
|
|
498
|
+
*
|
|
499
|
+
* plan 是**不进队列的临时草稿**:脑子里的想法照样写成任务存进库,但因为不是 pending,
|
|
500
|
+
* 所有 `status='pending'` 的取任务路径(get / wait / 全局池 / 闸门扫描)天然看不到它。
|
|
501
|
+
* 只允许双向切换 pending↔plan,其余状态(claimed/done/cancelled)不许直接转,
|
|
502
|
+
* 免得把正在跑或已定格的活悄悄改掉。
|
|
503
|
+
*/
|
|
504
|
+
export async function setPlanStatus({
|
|
505
|
+
cwd: rawCwd,
|
|
506
|
+
key: rawKey,
|
|
507
|
+
id,
|
|
508
|
+
to = 'plan',
|
|
509
|
+
} = {} as any): Promise<Record<string, any>> {
|
|
510
|
+
const key = resolveTaskKey({ key: rawKey, cwd: rawCwd });
|
|
511
|
+
const want = Number(id);
|
|
512
|
+
if (!Number.isFinite(want) || want <= 0) throw badInput('缺少参数 --id <任务编号>');
|
|
513
|
+
const target = String(to || '').trim();
|
|
514
|
+
if (target !== 'plan' && target !== 'pending') throw badInput('--to 只能是 plan 或 pending');
|
|
515
|
+
|
|
516
|
+
openStore();
|
|
517
|
+
const t = topicsRepo.getTopic(key);
|
|
518
|
+
const task = t && (t.tasks || []).find((x: any) => Number(x.id) === want && !x.deletedAt && !x.migratedTo);
|
|
519
|
+
if (!task) throw notFound(`主题「${t ? t.name : key}」里没有 #${want} 任务`);
|
|
520
|
+
const from = String(task.status || 'pending');
|
|
521
|
+
if (from === target) {
|
|
522
|
+
return { status: 'ok', changed: false, id: want, key, name: t!.name, from, to: target };
|
|
523
|
+
}
|
|
524
|
+
if (target === 'plan' && from !== 'pending') {
|
|
525
|
+
throw badInput(`只有待领取任务能转成草稿(#${want} 现在是 ${from})`);
|
|
526
|
+
}
|
|
527
|
+
if (target === 'pending' && from !== 'plan') {
|
|
528
|
+
throw badInput(`只有草稿能转回待领取(#${want} 现在是 ${from})`);
|
|
529
|
+
}
|
|
530
|
+
const updated = tasksRepo.updateTaskByKey(key, want, { status: target });
|
|
531
|
+
if (!updated) throw notFound(`任务不存在: #${want}`);
|
|
532
|
+
topicsRepo.updateTopic(key, { bumpRevision: true });
|
|
533
|
+
return {
|
|
534
|
+
status: 'ok',
|
|
535
|
+
changed: true,
|
|
536
|
+
id: want,
|
|
537
|
+
key,
|
|
538
|
+
name: t!.name,
|
|
539
|
+
from,
|
|
540
|
+
to: target,
|
|
541
|
+
task: updated,
|
|
542
|
+
};
|
|
543
|
+
}
|
package/src/runtime/dartgen.ts
CHANGED
|
@@ -53,6 +53,25 @@ function collect(output: TypeNode, models: Map<string, TypeNode & { k: 'model' }
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
* 入参去重:同一个 Dart 形参只能出现一次。
|
|
58
|
+
*
|
|
59
|
+
* 为什么会重名:action 的 input 允许「两种写法指向同一个字段」的别名
|
|
60
|
+
* (`--goal-prompt` 与驼峰 `goalPrompt`,CLI 与 HTTP body 各用各的)。
|
|
61
|
+
* 生成器按 camelCase 取形参名,两个别名就撞成同一个 `goalPrompt` ——
|
|
62
|
+
* Dart 侧直接编译不过(duplicate parameter name)。这里按「优先没有连字符的写法」
|
|
63
|
+
* 只留一个:发出去的 body 键名仍然是 action 声明过的,语义不变。
|
|
64
|
+
*/
|
|
65
|
+
function dedupeInput(input: FieldDesc[]): FieldDesc[] {
|
|
66
|
+
const byName = new Map<string, FieldDesc>();
|
|
67
|
+
for (const f of input) {
|
|
68
|
+
const n = dartName(f.name);
|
|
69
|
+
const prev = byName.get(n);
|
|
70
|
+
if (!prev || (prev.name.includes('-') && !f.name.includes('-'))) byName.set(n, f);
|
|
71
|
+
}
|
|
72
|
+
return [...byName.values()];
|
|
73
|
+
}
|
|
74
|
+
|
|
56
75
|
/** Dart 类型名 */
|
|
57
76
|
function dartType(t: TypeNode): string {
|
|
58
77
|
switch (t.k) {
|
|
@@ -155,7 +174,9 @@ function paramOf(f: FieldDesc): string {
|
|
|
155
174
|
: f.kind === 'enum'
|
|
156
175
|
? 'String'
|
|
157
176
|
: 'String';
|
|
158
|
-
|
|
177
|
+
// 位置参数上写 `required` 是语法错误(Dart 只允许命名参数带它):
|
|
178
|
+
// 必填与否已经由「非空类型 + 没有默认值」表达,这里不能再加修饰符。
|
|
179
|
+
return `${type}${f.required ? '' : '?'} ${dartName(f.name)}`;
|
|
159
180
|
}
|
|
160
181
|
|
|
161
182
|
function methodNameOf(id: string, used: Set<string>): string {
|
|
@@ -203,10 +224,11 @@ export function emitDartPackage(snapshot: ContractSnapshot): Record<string, stri
|
|
|
203
224
|
const root = rootModels.get(a.id)!;
|
|
204
225
|
if (root.k !== 'model') throw new Error(`action ${a.id} 的出参不是模型`);
|
|
205
226
|
const [method, path] = (a.http ?? 'GET ').split(' ') as [string, string];
|
|
206
|
-
const
|
|
227
|
+
const fields = dedupeInput(a.input);
|
|
228
|
+
const params = fields.map(paramOf).join(', ');
|
|
207
229
|
const isGet = method === 'GET' || method === 'HEAD';
|
|
208
|
-
const body = isGet ? 'null' : bodyMap(
|
|
209
|
-
const query = isGet ? queryMap(
|
|
230
|
+
const body = isGet ? 'null' : bodyMap(fields);
|
|
231
|
+
const query = isGet ? queryMap(fields) : 'const <String, String>{}';
|
|
210
232
|
methodLines.push(
|
|
211
233
|
[
|
|
212
234
|
...docComment(a.summary, ' '),
|
|
@@ -315,14 +337,17 @@ function queryMap(input: FieldDesc[]): string {
|
|
|
315
337
|
if (!input.length) return 'const <String, String>{}';
|
|
316
338
|
const lines = input.map((f) => {
|
|
317
339
|
const v = dartName(f.name);
|
|
340
|
+
// 必填字段没有「没给」这种状态:它的 Dart 类型就是非空,写 `if (x != null)` 只会
|
|
341
|
+
// 让 analyzer 报 unnecessary_null_comparison(其余 action 里全是要判空的,所以分开写)
|
|
342
|
+
const guard = f.required ? '' : `if (${v} != null) `;
|
|
318
343
|
if (f.kind === 'array') {
|
|
319
|
-
return `
|
|
344
|
+
return ` ${guard}'${f.name}': (${v} as List).join(','),`;
|
|
320
345
|
}
|
|
321
346
|
if (f.kind === 'kv' || f.kind === 'raw') {
|
|
322
|
-
return `
|
|
347
|
+
return ` ${guard}'${f.name}': jsonEncode(${v}),`;
|
|
323
348
|
}
|
|
324
349
|
// 生成 Dart 的 '${x}' 插值:这里用拼接写,避免在模板串里嵌套插值把自己绕晕
|
|
325
|
-
return '
|
|
350
|
+
return ' ' + guard + "'" + f.name + "': '${" + v + "}',";
|
|
326
351
|
});
|
|
327
352
|
return ['<String, String>{', ...lines, ' }'].join('\n');
|
|
328
353
|
}
|
|
@@ -26,6 +26,8 @@ export const TASK_STATUS = Object.freeze({
|
|
|
26
26
|
CLAIMED: 'claimed',
|
|
27
27
|
DONE: 'done',
|
|
28
28
|
CANCELLED: 'cancelled',
|
|
29
|
+
/** #126:临时草稿态——存在库里,但绝不进队列、不被 get/wait 领取 */
|
|
30
|
+
PLAN: 'plan',
|
|
29
31
|
} as const);
|
|
30
32
|
|
|
31
33
|
/** 全部合法状态(顺序即面板展示顺序:待领取 → 已领取 → 已完成 → 已取消)。 */
|
|
@@ -34,6 +36,7 @@ export const TASK_STATUSES: readonly string[] = Object.freeze([
|
|
|
34
36
|
TASK_STATUS.CLAIMED,
|
|
35
37
|
TASK_STATUS.DONE,
|
|
36
38
|
TASK_STATUS.CANCELLED,
|
|
39
|
+
TASK_STATUS.PLAN,
|
|
37
40
|
]);
|
|
38
41
|
|
|
39
42
|
/** 状态的中文标签(CLI / 面板共用一份,避免两处措辞不同)。 */
|
|
@@ -42,6 +45,7 @@ export const STATUS_TAG: Record<string, string> = Object.freeze({
|
|
|
42
45
|
claimed: '已领取',
|
|
43
46
|
done: '已完成',
|
|
44
47
|
cancelled: '已取消',
|
|
48
|
+
plan: '草稿',
|
|
45
49
|
});
|
|
46
50
|
|
|
47
51
|
/** 状态是否合法。 */
|
|
@@ -94,6 +98,14 @@ export function isCancelled(t?: TaskRowLike | null): boolean {
|
|
|
94
98
|
return isLive(t) && t?.status === TASK_STATUS.CANCELLED;
|
|
95
99
|
}
|
|
96
100
|
|
|
101
|
+
/**
|
|
102
|
+
* 草稿(#126):临时态,不是 pending、不是 open、不是终态。
|
|
103
|
+
* 所有 `status='pending'` 的取任务路径天然排除它——不需要在每条 SQL 里补条件。
|
|
104
|
+
*/
|
|
105
|
+
export function isPlan(t?: TaskRowLike | null): boolean {
|
|
106
|
+
return isLive(t) && t?.status === TASK_STATUS.PLAN;
|
|
107
|
+
}
|
|
108
|
+
|
|
97
109
|
/**
|
|
98
110
|
* 终态:done / cancelled。
|
|
99
111
|
* 依赖闸门用它判「这一条不会再动了,别永久挡住后面的人」(旧口径把 archived 也算终态)。
|
|
@@ -1377,6 +1377,21 @@
|
|
|
1377
1377
|
},
|
|
1378
1378
|
"children": []
|
|
1379
1379
|
},
|
|
1380
|
+
{
|
|
1381
|
+
"name": "plan",
|
|
1382
|
+
"path": [
|
|
1383
|
+
"localtask",
|
|
1384
|
+
"plan"
|
|
1385
|
+
],
|
|
1386
|
+
"action": {
|
|
1387
|
+
"id": "localtask.plan",
|
|
1388
|
+
"module": "localtask",
|
|
1389
|
+
"summary": "临时草稿态:plan 不进队列(get/wait 都领不到),pending 转回正常待领取;只允许 pending ↔ plan 双向切换",
|
|
1390
|
+
"usage": "localtask plan",
|
|
1391
|
+
"http": "PATCH /api/localtasks/plan"
|
|
1392
|
+
},
|
|
1393
|
+
"children": []
|
|
1394
|
+
},
|
|
1380
1395
|
{
|
|
1381
1396
|
"name": "presence",
|
|
1382
1397
|
"path": [
|
|
@@ -1508,6 +1523,21 @@
|
|
|
1508
1523
|
}
|
|
1509
1524
|
]
|
|
1510
1525
|
},
|
|
1526
|
+
{
|
|
1527
|
+
"name": "tasks",
|
|
1528
|
+
"path": [
|
|
1529
|
+
"localtask",
|
|
1530
|
+
"tasks"
|
|
1531
|
+
],
|
|
1532
|
+
"action": {
|
|
1533
|
+
"id": "localtask.tasks",
|
|
1534
|
+
"module": "localtask",
|
|
1535
|
+
"summary": "看一个主题的任务清单(按 --key 或 --cwd 定位):只回列表需要的字段(标题/状态/轮次/可领),不含正文",
|
|
1536
|
+
"usage": "localtask tasks",
|
|
1537
|
+
"http": "GET /api/localtasks/tasks"
|
|
1538
|
+
},
|
|
1539
|
+
"children": []
|
|
1540
|
+
},
|
|
1511
1541
|
{
|
|
1512
1542
|
"name": "timegoal-log",
|
|
1513
1543
|
"path": [
|
|
@@ -56,6 +56,7 @@ import type {
|
|
|
56
56
|
LocaltaskForkAction,
|
|
57
57
|
LocaltaskGetAction,
|
|
58
58
|
LocaltaskListAction,
|
|
59
|
+
LocaltaskPlanAction,
|
|
59
60
|
LocaltaskPresenceAction,
|
|
60
61
|
LocaltaskPreviewAction,
|
|
61
62
|
LocaltaskPruneAction,
|
|
@@ -64,6 +65,7 @@ import type {
|
|
|
64
65
|
LocaltaskReopenAction,
|
|
65
66
|
LocaltaskReorderAction,
|
|
66
67
|
LocaltaskTaskRestoreAction,
|
|
68
|
+
LocaltaskTasksAction,
|
|
67
69
|
LocaltaskTimegoalLogAction,
|
|
68
70
|
LocaltaskTopicAddAction,
|
|
69
71
|
LocaltaskTopicRemoveAction,
|
|
@@ -312,6 +314,8 @@ export interface ApiClient {
|
|
|
312
314
|
localtaskGet(input: z.input<InstanceType<typeof LocaltaskGetAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskGetAction>['run']>>>;
|
|
313
315
|
/** 总览全部主题(工作目录、现状、是否等待中、待领取数) */
|
|
314
316
|
localtaskList(): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskListAction>['run']>>>;
|
|
317
|
+
/** 临时草稿态:plan 不进队列(get/wait 都领不到),pending 转回正常待领取;只允许 pending ↔ plan 双向切换 */
|
|
318
|
+
plan(input: z.input<InstanceType<typeof LocaltaskPlanAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskPlanAction>['run']>>>;
|
|
315
319
|
/** 探测主面板上当前打开的「实时任务」标签数(活动 SSE 连接数;用于 wait 不重复开页) */
|
|
316
320
|
presence(): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskPresenceAction>['run']>>>;
|
|
317
321
|
/** 预览一条任务在 get/wait 时的交付提示词(只读:不领取、不写盘、不启动计时、不为附件发网);草稿用 --text 直接预览 */
|
|
@@ -328,6 +332,8 @@ export interface ApiClient {
|
|
|
328
332
|
reorder(input: z.input<InstanceType<typeof LocaltaskReorderAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskReorderAction>['run']>>>;
|
|
329
333
|
/** 恢复一条被删除(软删除)的任务(撤销删除) */
|
|
330
334
|
restore(input: z.input<InstanceType<typeof LocaltaskTaskRestoreAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskTaskRestoreAction>['run']>>>;
|
|
335
|
+
/** 看一个主题的任务清单(按 --key 或 --cwd 定位):只回列表需要的字段(标题/状态/轮次/可领),不含正文 */
|
|
336
|
+
tasks(input?: z.input<InstanceType<typeof LocaltaskTasksAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskTasksAction>['run']>>>;
|
|
331
337
|
/** 查看任务级时间目标的每轮 check 记录(时间、已用/剩余、是否到点、当轮总结) */
|
|
332
338
|
timegoalLog(input: z.input<InstanceType<typeof LocaltaskTimegoalLogAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskTimegoalLogAction>['run']>>>;
|
|
333
339
|
/** 登记一个工作目录:空目录也常驻(prune 不清);--summary 顺带写「现状摘要」(面板顶栏摘要的编辑入口) */
|
|
@@ -1005,6 +1011,13 @@ export function createApiClient(transport: Transport): ApiClient {
|
|
|
1005
1011
|
const path = `/api/localtasks`;
|
|
1006
1012
|
return (await transport.request("GET", path)) as Awaited<ReturnType<InstanceType<typeof LocaltaskListAction>['run']>>;
|
|
1007
1013
|
},
|
|
1014
|
+
// action: localtask.plan
|
|
1015
|
+
async plan(input: z.input<InstanceType<typeof LocaltaskPlanAction>['_input']>) {
|
|
1016
|
+
const inp = input ?? ({} as z.input<InstanceType<typeof LocaltaskPlanAction>['_input']>);
|
|
1017
|
+
const path = `/api/localtasks/plan`;
|
|
1018
|
+
const body = { "id": inp["id"], "to": inp["to"], "cwd": inp["cwd"], "key": inp["key"] };
|
|
1019
|
+
return (await transport.request("PATCH", path, body)) as Awaited<ReturnType<InstanceType<typeof LocaltaskPlanAction>['run']>>;
|
|
1020
|
+
},
|
|
1008
1021
|
// action: localtask.presence
|
|
1009
1022
|
async presence() {
|
|
1010
1023
|
const path = `/api/localtasks/presence`;
|
|
@@ -1059,6 +1072,18 @@ export function createApiClient(transport: Transport): ApiClient {
|
|
|
1059
1072
|
const body = { "id": inp["id"], "cwd": inp["cwd"], "key": inp["key"] };
|
|
1060
1073
|
return (await transport.request("POST", path, body)) as Awaited<ReturnType<InstanceType<typeof LocaltaskTaskRestoreAction>['run']>>;
|
|
1061
1074
|
},
|
|
1075
|
+
// action: localtask.tasks
|
|
1076
|
+
async tasks(input?: z.input<InstanceType<typeof LocaltaskTasksAction>['_input']>) {
|
|
1077
|
+
const inp = input ?? ({} as z.input<InstanceType<typeof LocaltaskTasksAction>['_input']>);
|
|
1078
|
+
let path = `/api/localtasks/tasks`;
|
|
1079
|
+
const q = new URLSearchParams();
|
|
1080
|
+
if (inp["key"] !== undefined) q.set("key", String(inp["key"]));
|
|
1081
|
+
if (inp["cwd"] !== undefined) q.set("cwd", String(inp["cwd"]));
|
|
1082
|
+
if (inp["status"] !== undefined) q.set("status", String(inp["status"]));
|
|
1083
|
+
const query = q.toString();
|
|
1084
|
+
if (query) path += path.includes('?') ? '&' + query : '?' + query;
|
|
1085
|
+
return (await transport.request("GET", path)) as Awaited<ReturnType<InstanceType<typeof LocaltaskTasksAction>['run']>>;
|
|
1086
|
+
},
|
|
1062
1087
|
// action: localtask.timegoalLog
|
|
1063
1088
|
async timegoalLog(input: z.input<InstanceType<typeof LocaltaskTimegoalLogAction>['_input']>) {
|
|
1064
1089
|
const inp = input ?? ({} as z.input<InstanceType<typeof LocaltaskTimegoalLogAction>['_input']>);
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
isClaimed,
|
|
15
15
|
isDone,
|
|
16
16
|
isCancelled,
|
|
17
|
+
isPlan,
|
|
17
18
|
STATUS_TAG,
|
|
18
19
|
} from '../../../../shared/task-status.js';
|
|
19
20
|
import type { TaskRowLike } from '../../../../shared/task-status.js';
|
|
@@ -22,7 +23,7 @@ import type { TaskRowLike } from '../../../../shared/task-status.js';
|
|
|
22
23
|
export type StatusRow = TaskRowLike;
|
|
23
24
|
|
|
24
25
|
/** 四种语义色调(CSS 类后缀 tstat-<tone> 同名)。 */
|
|
25
|
-
export type StatusTone = 'gone' | 'done' | 'doing' | 'pending';
|
|
26
|
+
export type StatusTone = 'gone' | 'done' | 'doing' | 'pending' | 'plan';
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* 四种语义色调。不认识的 status 给中性灰(pending 色),文案由 statusLabel
|
|
@@ -34,6 +35,7 @@ export function statusTone(t: StatusRow | null | undefined): StatusTone {
|
|
|
34
35
|
if (isDone(t)) return 'done';
|
|
35
36
|
if (isClaimed(t)) return 'doing';
|
|
36
37
|
if (isCancelled(t)) return 'gone';
|
|
38
|
+
if (isPlan(t)) return 'plan';
|
|
37
39
|
return 'pending';
|
|
38
40
|
}
|
|
39
41
|
|
|
@@ -50,7 +52,7 @@ export function statusLabel(t: StatusRow | null | undefined): string {
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
/** 单字徽标(侧栏 / 队列表等窄处):等 / 跑 / 完 / 档——随色调一起统一。 */
|
|
53
|
-
const TONE_SHORT: Record<StatusTone, string> = { pending: '等', doing: '跑', done: '完', gone: '档' };
|
|
55
|
+
const TONE_SHORT: Record<StatusTone, string> = { pending: '等', doing: '跑', done: '完', gone: '档', plan: '草' };
|
|
54
56
|
|
|
55
57
|
/**
|
|
56
58
|
* 单字徽标文案(窄处显示不下全称时用)。
|
|
@@ -32,6 +32,8 @@ export const DIR_MODULES: ToolModule[] = [
|
|
|
32
32
|
{ id: 'import', label: '导入', section: 'bar' },
|
|
33
33
|
{ id: 'progress', label: '进程', section: 'bar' },
|
|
34
34
|
{ id: 'orch', label: '编排', section: 'bar' },
|
|
35
|
+
// #126:草稿开关作用于选中的任务(没选中时给提示),默认在工具栏可见
|
|
36
|
+
{ id: 'plan', label: '草稿', section: 'bar' },
|
|
35
37
|
{ id: 'more', label: '更多', section: 'bar', noHide: true },
|
|
36
38
|
{ id: 'refs', label: '查看列表', section: 'more' },
|
|
37
39
|
];
|
|
@@ -84,6 +84,14 @@ export function addTask(body: AddTaskBody): Promise<any> {
|
|
|
84
84
|
return api('/api/localtasks', { method: 'POST', body });
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
/**
|
|
88
|
+
* #126:在 pending ↔ plan 之间切换一条任务(PATCH /api/localtasks/plan)。
|
|
89
|
+
* plan 是不进队列的临时草稿,get/wait 都领不到;转回 pending 才重新排队。
|
|
90
|
+
*/
|
|
91
|
+
export function setPlanStatus(body: TaskScope & { id: number; to: 'plan' | 'pending' }): Promise<any> {
|
|
92
|
+
return api('/api/localtasks/plan', { method: 'PATCH', body });
|
|
93
|
+
}
|
|
94
|
+
|
|
87
95
|
/** 重开 / 追加反馈(POST /api/localtasks/reopen;kind=reopen|comment)。 */
|
|
88
96
|
export function postReopen(body: Record<string, unknown>): Promise<TaskMutationResult> {
|
|
89
97
|
return api('/api/localtasks/reopen', { method: 'POST', body });
|
|
@@ -18,6 +18,9 @@ import TaskPanel from '../../components/task-panel/index.jsx';
|
|
|
18
18
|
import TaskPanelLayoutRaw from '../../components/task-panel/layout.jsx';
|
|
19
19
|
import TaskRow from '../../components/task-panel/task-row.jsx';
|
|
20
20
|
import type { LocalTask, LocalTopic, RepoRow } from '../../types.js';
|
|
21
|
+
import { useApp } from '../../app-context.jsx';
|
|
22
|
+
import { useToast } from '../../components/toast/index.jsx';
|
|
23
|
+
import { setPlanStatus } from './api.js';
|
|
21
24
|
|
|
22
25
|
/** 拖动落点:行上半 = 之前,下半 = 之后。 */
|
|
23
26
|
type DropZone = 'before' | 'after';
|
|
@@ -197,6 +200,28 @@ export default function Landing({
|
|
|
197
200
|
const ok = await fn(ids);
|
|
198
201
|
if (ok) setPicked(new Set());
|
|
199
202
|
};
|
|
203
|
+
|
|
204
|
+
// #126:草稿态切换。plan 的任务照样存在库里,但因为不是 pending,
|
|
205
|
+
// get/wait/队列/闸门都看不到它;转回 pending 才重新进入待领取队列。
|
|
206
|
+
const app = useApp();
|
|
207
|
+
const toast = useToast();
|
|
208
|
+
const scope = topic?.key ? { key: topic.key } : {};
|
|
209
|
+
const pickedRows = pickedTasks;
|
|
210
|
+
const toPlan = pickedRows.filter((t) => t.status === 'pending');
|
|
211
|
+
const toPending = pickedRows.filter((t) => t.status === 'plan');
|
|
212
|
+
const switchPlan = async (rows: LocalTask[], to: 'plan' | 'pending') => {
|
|
213
|
+
if (!rows.length) return;
|
|
214
|
+
try {
|
|
215
|
+
for (const t of rows) await setPlanStatus({ ...scope, id: Number(t.id), to });
|
|
216
|
+
toast(to === 'plan' ? `已把 ${rows.length} 条任务转为草稿(不进队列)` : `已把 ${rows.length} 条草稿转回待领取`);
|
|
217
|
+
setPicked(new Set());
|
|
218
|
+
app.refreshLocal?.();
|
|
219
|
+
} catch (e) {
|
|
220
|
+
toast(String((e as Error).message || e));
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const planTargets = toPlan.length ? toPlan : toPending;
|
|
224
|
+
const planTo: 'plan' | 'pending' = toPlan.length ? 'plan' : 'pending';
|
|
200
225
|
// 只有待领取行能拖动调序(已领取/已完成/已取消都是固定历史)
|
|
201
226
|
const movable = (t: LocalTask) => t.status === 'pending' && !t.migratedTo && !t.deletedAt;
|
|
202
227
|
const zoneOf = (e: ReactDragEvent<HTMLElement>, tr: HTMLElement): DropZone => {
|
|
@@ -349,6 +374,12 @@ export default function Landing({
|
|
|
349
374
|
不再在行尾铺一排图标(反馈 + 删除原来占两个最右位,行尾过挤)。 */
|
|
350
375
|
<RowMenu
|
|
351
376
|
items={[
|
|
377
|
+
t.status === 'pending' || t.status === 'plan'
|
|
378
|
+
? {
|
|
379
|
+
label: t.status === 'pending' ? '转为草稿(不进队列)' : '转回待领取',
|
|
380
|
+
onPick: () => void switchPlan([t], t.status === 'pending' ? 'plan' : 'pending'),
|
|
381
|
+
}
|
|
382
|
+
: null,
|
|
352
383
|
movableRow && onOpenDag
|
|
353
384
|
? { label: '编排依赖…', onPick: () => onOpenDag(t) }
|
|
354
385
|
: null,
|
|
@@ -411,6 +442,9 @@ export default function Landing({
|
|
|
411
442
|
kind="dir"
|
|
412
443
|
labels={{
|
|
413
444
|
more: '更多',
|
|
445
|
+
plan: pickedRows.length
|
|
446
|
+
? planTo === 'plan' ? `转草稿 (${toPlan.length})` : `转回待领取 (${toPending.length})`
|
|
447
|
+
: '草稿',
|
|
414
448
|
}}
|
|
415
449
|
titles={{
|
|
416
450
|
new: '按默认模板新建一页(▾ 选模板)',
|
|
@@ -418,6 +452,7 @@ export default function Landing({
|
|
|
418
452
|
progress: '打开这个目录的进程面板',
|
|
419
453
|
more: '更多操作',
|
|
420
454
|
refs: '查看文档 / reference 列表',
|
|
455
|
+
plan: '选中任务后:待领取 ↔ 草稿(草稿不进 get/wait 队列;行尾 ⋯ 菜单也能单条切换)',
|
|
421
456
|
}}
|
|
422
457
|
renderers={{
|
|
423
458
|
// #161 新建按钮拆两级(视觉一颗按钮、命中区两层):
|
|
@@ -462,6 +497,13 @@ export default function Landing({
|
|
|
462
497
|
progress: onProg,
|
|
463
498
|
orch: onOpenFlow,
|
|
464
499
|
refs: onRefs,
|
|
500
|
+
plan: () => {
|
|
501
|
+
if (!planTargets.length) {
|
|
502
|
+
toast('先勾选任务:待领取可转草稿,草稿可转回待领取(行尾 ⋯ 菜单也能单条切换)');
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
void switchPlan(planTargets, planTo);
|
|
506
|
+
},
|
|
465
507
|
}}
|
|
466
508
|
/>
|
|
467
509
|
</>
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
.tstat.tstat-doing { color: var(--doing, #2f5fb5); background: var(--doing-bg, #edf2fc); border-color: var(--doing-line, #c9d6f0); }
|
|
19
19
|
.tstat.tstat-done { color: var(--live); background: rgba(31, 122, 77, 0.08); border-color: rgba(31, 122, 77, 0.28); }
|
|
20
20
|
.tstat.tstat-gone { color: var(--faint); border-style: dashed; }
|
|
21
|
+
/* #126 草稿:与待领取区分开,金褐色文字 + 虚线边框,不占「进行中/已完成」语义色 */
|
|
22
|
+
.tstat.tstat-plan { color: var(--warn); background: var(--soft); border-color: var(--soft-2); border-style: dashed; }
|
|
21
23
|
|
|
22
24
|
/* ---------- 表格:细线分隔,不画网格 ---------- */
|
|
23
25
|
table { width: 100%; border-collapse: collapse; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,b as t}from"./frontmatter-DEIM0yF2.js";var n=e(t(),1),r=(0,n.createContext)({});function i(){return(0,n.useContext)(r)}export{i as n,r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C as e,b as t,y as n}from"./frontmatter-DEIM0yF2.js";import{w as r}from"./workspace-C0PPPfA1.js";import{c as i,d as a,l as o,s,u as c}from"./use-rail-drag-BeDwWqzF.js";var l=e(t(),1),u=r(),d=n();function f({kind:e,renderers:t={},actions:n={},titles:r={},disabled:f={},labels:p={},className:m=``}){let{layout:h,setLayout:g}=i(e),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),C=(0,l.useRef)(null),w=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(!_)return;let e=e=>{let t=e.target;C.current?.contains(t)||w.current?.contains(t)||v(!1)},t=e=>{e.key===`Escape`&&v(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[_]);let T=h.filter(t=>a(e,t)),E=h.filter(t=>o(e,t)),D=t=>p[t]||c(e,t).label||t,O=(e,t={})=>(0,d.jsx)(`button`,{type:`button`,className:t.primary?`btn small primary`:`btn small ghost`,title:r[e]||D(e),disabled:!!f[e],onClick:()=>n[e]&&n[e](),children:D(e)},e),k=n=>{if(n===`more`)return(0,d.jsxs)(`button`,{ref:C,type:`button`,className:`btn small ghost`+(_?` is-open`:``),title:r.more||`更多操作`,"aria-haspopup":`menu`,"aria-expanded":_,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();b({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)}),v(e=>!e)},children:[D(`more`),` ▾`]},`more`);let i=t[n];return i?(0,d.jsx)(`span`,{className:`ta-slot`,children:i({open:_})},n):O(n,{primary:c(e,n).section===`primary`})};return(0,d.jsxs)(`div`,{className:`ta-bar`+(m?` ${m}`:``),children:[T.map(e=>k(e.id)),_&&y&&(0,u.createPortal)((0,d.jsxs)(`div`,{ref:w,className:`ta-more-menu`,role:`menu`,style:{top:y.top,right:y.right},children:[E.length===0&&(0,d.jsx)(`div`,{className:`ta-more-empty`,children:`没有收纳的工具——可在编排里把按钮收入更多`}),E.map(e=>(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it`,disabled:!!f[e.id],title:r[e.id]||D(e.id),onClick:()=>{v(!1);let t=n[e.id];t&&t()},children:D(e.id)},e.id)),(0,d.jsx)(`div`,{className:`ta-more-sep`}),(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it ta-more-cfg`,onClick:()=>{v(!1),S(!0)},children:`自定义工具栏…`})]}),document.body),x&&(0,u.createPortal)((0,d.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>S(!1),children:(0,d.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,d.jsx)(s,{kind:e,layout:h,setLayout:g,onClose:()=>S(!1)})})}),document.body)]})}export{f as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./frontmatter-
|
|
1
|
+
import{c as e}from"./frontmatter-DEIM0yF2.js";var t=`__GLOBAL__`;function n(e=[]){let t=Array.isArray(e)?e:[];return{pending:t.filter(e=>e.status===`pending`&&!e.deletedAt&&!e.migratedTo),claimed:t.filter(e=>e.status===`claimed`&&!e.deletedAt).slice().reverse(),done:t.filter(e=>e.status===`done`&&!e.deletedAt).slice().reverse(),cancelled:t.filter(e=>e.status===`cancelled`&&!e.deletedAt).slice().reverse(),deleted:t.filter(e=>!!e.deletedAt).slice().reverse(),migrated:t.filter(e=>!!e.migratedTo&&!e.deletedAt)}}function r(e=[]){let t=Array.isArray(e)?e:[],n=[],r=[],i=[],a=[],o=[],s=[];for(let e of t)e.deletedAt?s.push(e):e.status===`claimed`?r.push(e):e.status===`done`?i.push(e):e.status===`cancelled`?a.push(e):e.migratedTo?o.push(e):n.push(e);return[...n,...r.reverse(),...o,...i.reverse(),...a.reverse(),...s.reverse()]}function i(e){return!!(e&&e.boardMark)}function a(t){return e(t)}function o(e=[]){return(Array.isArray(e)?e:[]).filter(e=>!e.deletedAt&&!i(e))}function s(e=[]){return o(e).filter(a).length}function c(e){return[e&&e.id,e&&e.key,e&&e.name].filter(Boolean).map(String)}function l(e,t){return!i(e)||!e?!1:(Array.isArray(t)?t:c(t)).includes(String(e.boardMark))}function u(e=[],t=[],n,r){let i=(t||[]).find(e=>e&&(e.id===n||e.key===n||e.name===n))||null,a={board:i,topic:null,taskRow:null};if(!i||r==null||String(r)===``)return a;let o=new Set((i.repos||[]).map(e=>e&&(e.key||e.id)).filter(Boolean)),s=e=>{let t=e&&e.repo;return[t&&t.key,t&&t.id,e&&e.key].filter(Boolean)},l=c(i);for(let t of e||[]){if(!t||t.isGlobal||o.size&&!s(t).some(e=>o.has(e)))continue;let e=(t.tasks||[]).find(e=>e&&!e.deletedAt&&String(e.id)===String(r));if(e&&(a.topic||(a.topic=t,a.taskRow=e),l.includes(String(e.boardMark||``)))){a.topic=t,a.taskRow=e;break}}return a}export{s as a,l as c,a as i,u as n,r as o,i as r,n as s,t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{m as e,y as t}from"./frontmatter-DEIM0yF2.js";import{c as n,r}from"./workspace-C0PPPfA1.js";import{g as i}from"./md-history-DUv-eEJZ.js";var a=t();function o({attachments:t,onRemove:n}){return t?.length?(0,a.jsxs)(`div`,{className:`mdw-attach`,children:[(0,a.jsx)(`div`,{className:`lab`,children:`附件 / 图片`}),(0,a.jsx)(`div`,{className:`list`,children:t.map(t=>(0,a.jsxs)(`div`,{className:`att`,children:[t.type===`image`&&t.url?(0,a.jsx)(`img`,{src:t.url,alt:``}):(0,a.jsx)(`div`,{className:`ico`,children:(0,a.jsx)(e,{name:`list`,size:14,title:void 0})}),(0,a.jsxs)(`div`,{className:`meta`,children:[(0,a.jsx)(`div`,{className:`n`,children:t.name}),(0,a.jsx)(`div`,{className:`s`,children:t.size})]}),(0,a.jsx)(`button`,{type:`button`,className:`x`,"aria-label":`移除`,onClick:()=>n(t.id),children:`×`})]},t.id))})]}):null}var s=`nx-kv-md-attachments-v1`;function c(){try{return JSON.parse(localStorage.getItem(s)||`{}`)||{}}catch{return{}}}function l(e){try{localStorage.setItem(s,JSON.stringify(e))}catch{}}function u(e,t){let n=c();n[e]=t,l(n)}function d(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function f(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result??``)),r.onerror=n,r.readAsDataURL(e)})}async function p(e){let t=[],n=[];for(let r of[...e]){let e=`a`+Date.now()+Math.random().toString(16).slice(2,6),i=/^image\//.test(r.type),a={id:e,name:r.name,type:i?`image`:`file`,size:d(r.size)};i&&(a.url=await f(r),n.push(`\n\n`)),t.push(a)}return{items:t,imageInserts:n,fileInserts:[]}}async function m(e){let t=[...e||[]];if(!t.length)return{items:[],imageInserts:[],fileInserts:[]};try{let e=await i(t),n=[],r=[],a=[];for(let t of e){let e=t.fileId||t.id,i=!!t.isImage;n.push({id:e,name:t.name,type:i?`image`:`file`,size:d(Number(t.size)||0),url:`/api/file/content/${e}`});let o=t.markdown||{},s=i?o.image||``:o.file||`[${t.name}](${e})`;(i?r:a).push(`\n${s}\n`)}return{items:n,imageInserts:r,fileInserts:a}}catch{return p(e||[])}}var h=new Map;function g(e,t={}){if(!e)return null;let{mode:i=`comment`,quote:a=``,prevQuote:o=``,taskLabel:s=``,taskTitle:c=``,src:l=null,onSubmit:u=null,onFiles:d=null}=t,f=`cmp`+Date.now().toString(36)+Math.random().toString(36).slice(2,8),p=n(e);return h.set(f,{onSubmit:u,onFiles:d,prev:p}),r(e,{component:`compose`,name:i===`feedback`?`反馈`:`评论`,config:{token:f,mode:i,quote:a,prevQuote:o,taskLabel:s,taskTitle:c,src:l},location:`center`}),f}function _(e,t){let i=h.get(t);if(h.delete(t),!i||!i.prev||!e)return null;let a=n(e);return a&&a.component!==`compose`?null:r(e,i.prev)}function v(e){return h.get(e)||null}export{u as a,m as i,g as n,o,_ as r,v as t};
|