nx-kv 0.44.2 → 0.45.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 +40 -0
- package/assets/kv-get/references/wait-workflow.md +14 -4
- package/assets/kv-get/references/waitloop.md +7 -1
- package/package.json +1 -1
- package/src/core/db/driver.js +221 -96
- package/src/core/instruction-template.js +187 -0
- package/src/modules/localtask/action-lifecycle.js +6 -2
- package/src/modules/localtask/task-lifecycle.js +41 -1
- package/src/shared/prompt-blocks.js +36 -7
- package/src/web/frontend/page/settings/prompt-template-params.js +36 -0
- package/src/web/public/assets/{Introduction-DhwPj5cV.js → Introduction-EHroxF1H.js} +1 -1
- package/src/web/public/assets/{bar-Asff3O_q.js → bar-BvS_Jfi4.js} +1 -1
- package/src/web/public/assets/{cloud-B4teh9iW.js → cloud-DlWk0wnP.js} +1 -1
- package/src/web/public/assets/{composer-panel-DdJnqWyB.js → composer-panel-D3w-CjhN.js} +1 -1
- package/src/web/public/assets/{deleted-panel-Du_QekTw.js → deleted-panel-BMJEEBWD.js} +1 -1
- package/src/web/public/assets/{dir-Bm8iRhk_.js → dir-BtjHgH4Q.js} +1 -1
- package/src/web/public/assets/{group-DWUqMR0V.js → group-Bxq8JamU.js} +1 -1
- package/src/web/public/assets/{index-D2fKyD1k.js → index-ChlZPTea.js} +2 -2
- package/src/web/public/assets/{md-history-CfpJ9GT6.js → md-history-CBqcR086.js} +1 -1
- package/src/web/public/assets/{overview-B8afcbd6.js → overview-BP5sB1WX.js} +1 -1
- package/src/web/public/assets/{refs-OOuAfThN.js → refs-Dt7DQIOo.js} +1 -1
- package/src/web/public/assets/{repos-C8HvsdC7.js → repos-Zl1_SfPX.js} +1 -1
- package/src/web/public/assets/{route-crumb-CvrRU1gp.js → route-crumb-PqhQSVWL.js} +1 -1
- package/src/web/public/assets/settings-CXWFvvvv.js +8 -0
- package/src/web/public/assets/{status-tag-BhZgdBJz.js → status-tag-BK-45ld2.js} +1 -1
- package/src/web/public/assets/{task-Bq8Rd03M.js → task-COFIPegR.js} +1 -1
- package/src/web/public/assets/{templates-C9VpC4gA.js → templates-CIxgTTt-.js} +1 -1
- package/src/web/public/assets/{tool-bar-D5yvblnb.js → tool-bar-TIqYxsQl.js} +1 -1
- package/src/web/public/index.html +1 -1
- package/src/web/public/assets/settings-jom_vACN.js +0 -7
|
@@ -50,6 +50,193 @@ const COMPILE_OPTS = { noEscape: true, strict: false };
|
|
|
50
50
|
const CACHE_MAX = 256;
|
|
51
51
|
const cache = new Map();
|
|
52
52
|
|
|
53
|
+
// ---- 模板 helper(#90)----------------------------------------------------------
|
|
54
|
+
//
|
|
55
|
+
// 为什么自带一套而不是引 handlebars-helpers:那套 100+ helper 拖一堆依赖(还带
|
|
56
|
+
// lodash),而这里只需要「比较 / 逻辑 / 数值 / 串 / 时间」五小类;命名仍沿用社区
|
|
57
|
+
// 习惯(eq/ne/gt/gte/lt/lte/between、and/or/not、add/sub/mul/div/mod、round/
|
|
58
|
+
// floor/ceil、clamp、includes/length/default),写模板的人不用记新方言。
|
|
59
|
+
//
|
|
60
|
+
// 三条边界约定(写进 docs/glossary.md):
|
|
61
|
+
// 1. **绝不抛错**——任何 helper 出问题都只影响它自己那一小段输出,不拖垮整份渲染;
|
|
62
|
+
// 2. **数值失败可见**——数值类拿不到有限数时输出 `NaN`(模板里一眼能看见),
|
|
63
|
+
// 比较类拿不到数一律 `false`(条件分支安全地走 else);
|
|
64
|
+
// 3. **零值语义照 JS**——除零得 `Infinity` / `-Infinity` / `NaN`,`mod` 负数照 JS。
|
|
65
|
+
//
|
|
66
|
+
// 用法:`{{gte goal.elapsedSec 1800}}`、`{{#if (and goal.check (lt goal.remainingSec 300))}}`、
|
|
67
|
+
// `{{percent goal.elapsedSec goal.durationSec}}`(0 位小数)、`{{percent a b 1}}`(1 位)。
|
|
68
|
+
|
|
69
|
+
/** 数字归一:有限数 → 数;否则 null(区分「0」与「拿不到」)。 */
|
|
70
|
+
function toNum(v) {
|
|
71
|
+
if (typeof v === 'number') return Number.isFinite(v) ? v : null;
|
|
72
|
+
if (typeof v === 'boolean') return v ? 1 : 0;
|
|
73
|
+
const s = String(v ?? '').trim();
|
|
74
|
+
if (!s) return null;
|
|
75
|
+
const n = Number(s);
|
|
76
|
+
return Number.isFinite(n) ? n : null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** 数值输出:有限数原样字符串(-0 归一成 0);Infinity 照 JS 语义;拿不到数 → 可见的 `NaN`。 */
|
|
80
|
+
function numOut(n) {
|
|
81
|
+
if (Number.isNaN(n)) return 'NaN';
|
|
82
|
+
if (!Number.isFinite(n)) return n > 0 ? 'Infinity' : '-Infinity';
|
|
83
|
+
return String(Object.is(n, -0) ? 0 : n);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** 可预测的相等:两边都能当数就按数比,否则按字符串比。 */
|
|
87
|
+
function looseEq(a, b) {
|
|
88
|
+
if (a === b) return true;
|
|
89
|
+
if (a == null || b == null) return false;
|
|
90
|
+
const na = toNum(a);
|
|
91
|
+
const nb = toNum(b);
|
|
92
|
+
if (na !== null && nb !== null) return na === nb;
|
|
93
|
+
return String(a) === String(b);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** 折叠末尾多余的 0:1.50 → 1.5、2.00 → 2。 */
|
|
97
|
+
function fixed(n, digits) {
|
|
98
|
+
const d = Math.max(0, Math.min(20, Math.trunc(toNum(digits) ?? 0)));
|
|
99
|
+
const s = n.toFixed(d);
|
|
100
|
+
return d > 0 ? String(Number(s)) : s;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const HELPER_DEFS = {
|
|
104
|
+
// —— 比较(返回布尔;拿不到数 → false,保证 {{#if}} 走 else)——
|
|
105
|
+
eq: (a, b) => looseEq(a, b),
|
|
106
|
+
ne: (a, b) => !looseEq(a, b),
|
|
107
|
+
gt: (a, b) => {
|
|
108
|
+
const [x, y] = [toNum(a), toNum(b)];
|
|
109
|
+
return x !== null && y !== null && x > y;
|
|
110
|
+
},
|
|
111
|
+
gte: (a, b) => {
|
|
112
|
+
const [x, y] = [toNum(a), toNum(b)];
|
|
113
|
+
return x !== null && y !== null && x >= y;
|
|
114
|
+
},
|
|
115
|
+
lt: (a, b) => {
|
|
116
|
+
const [x, y] = [toNum(a), toNum(b)];
|
|
117
|
+
return x !== null && y !== null && x < y;
|
|
118
|
+
},
|
|
119
|
+
lte: (a, b) => {
|
|
120
|
+
const [x, y] = [toNum(a), toNum(b)];
|
|
121
|
+
return x !== null && y !== null && x <= y;
|
|
122
|
+
},
|
|
123
|
+
// 闭区间:min ≤ v ≤ max(min > max 时恒 false,不自动翻转)
|
|
124
|
+
between: (v, min, max) => {
|
|
125
|
+
const [x, lo, hi] = [toNum(v), toNum(min), toNum(max)];
|
|
126
|
+
return x !== null && lo !== null && hi !== null && x >= lo && x <= hi;
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
// —— 逻辑(参数由 wrapper 剥掉 options 后原样传入,对象也按真值参与)——
|
|
130
|
+
and: (...args) => args.every(Boolean),
|
|
131
|
+
or: (...args) => args.some(Boolean),
|
|
132
|
+
not: (v) => !v,
|
|
133
|
+
|
|
134
|
+
// —— 数值(失败 → 可见的 NaN)——
|
|
135
|
+
add: (...args) => {
|
|
136
|
+
const nums = args.map(toNum);
|
|
137
|
+
if (nums.some((n) => n === null)) return 'NaN';
|
|
138
|
+
return numOut(nums.reduce((s, n) => s + n, 0));
|
|
139
|
+
},
|
|
140
|
+
sub: (a, ...rest) => {
|
|
141
|
+
const nums = [a, ...rest].map(toNum);
|
|
142
|
+
if (nums.some((n) => n === null)) return 'NaN';
|
|
143
|
+
return numOut(nums.slice(1).reduce((s, n) => s - n, nums[0]));
|
|
144
|
+
},
|
|
145
|
+
mul: (...args) => {
|
|
146
|
+
const nums = args.map(toNum);
|
|
147
|
+
if (nums.some((n) => n === null)) return 'NaN';
|
|
148
|
+
return numOut(nums.reduce((s, n) => s * n, 1));
|
|
149
|
+
},
|
|
150
|
+
// 除零照 JS:x/0 → Infinity / -Infinity;0/0 → NaN
|
|
151
|
+
div: (a, b) => {
|
|
152
|
+
const [x, y] = [toNum(a), toNum(b)];
|
|
153
|
+
if (x === null || y === null) return 'NaN';
|
|
154
|
+
return numOut(x / y);
|
|
155
|
+
},
|
|
156
|
+
mod: (a, b) => {
|
|
157
|
+
const [x, y] = [toNum(a), toNum(b)];
|
|
158
|
+
if (x === null || y === null) return 'NaN';
|
|
159
|
+
return numOut(x % y);
|
|
160
|
+
},
|
|
161
|
+
round: (v, digits = 0) => {
|
|
162
|
+
const n = toNum(v);
|
|
163
|
+
if (n === null) return 'NaN';
|
|
164
|
+
const d = Math.max(0, Math.min(20, Math.trunc(toNum(digits) ?? 0)));
|
|
165
|
+
const f = 10 ** d;
|
|
166
|
+
return numOut(Math.round(n * f) / f);
|
|
167
|
+
},
|
|
168
|
+
floor: (v) => {
|
|
169
|
+
const n = toNum(v);
|
|
170
|
+
return n === null ? 'NaN' : numOut(Math.floor(n));
|
|
171
|
+
},
|
|
172
|
+
ceil: (v) => {
|
|
173
|
+
const n = toNum(v);
|
|
174
|
+
return n === null ? 'NaN' : numOut(Math.ceil(n));
|
|
175
|
+
},
|
|
176
|
+
// percent(part, total, digits=0):part 占总量的百分比;total 为 0 / 非数 → NaN
|
|
177
|
+
// (百分比里的「∞%」没有意义,这里刻意不走 JS 的除零语义,输出可见的 NaN)
|
|
178
|
+
percent: (part, total, digits = 0) => {
|
|
179
|
+
const [p, t] = [toNum(part), toNum(total)];
|
|
180
|
+
if (p === null || t === null || t === 0) return 'NaN';
|
|
181
|
+
return fixed((p / t) * 100, digits);
|
|
182
|
+
},
|
|
183
|
+
// ratio(part, total, digits=2):比例(不做 ×100);total 为 0 → NaN(与 percent 同口径)
|
|
184
|
+
ratio: (part, total, digits = 2) => {
|
|
185
|
+
const [p, t] = [toNum(part), toNum(total)];
|
|
186
|
+
if (p === null || t === null || t === 0) return 'NaN';
|
|
187
|
+
return fixed(p / t, digits);
|
|
188
|
+
},
|
|
189
|
+
// clamp(v, min, max):把 v 夹进 [min, max];非数 → NaN
|
|
190
|
+
clamp: (v, min, max) => {
|
|
191
|
+
const [x, lo, hi] = [toNum(v), toNum(min), toNum(max)];
|
|
192
|
+
if (x === null || lo === null || hi === null) return 'NaN';
|
|
193
|
+
return numOut(Math.min(Math.max(x, lo), hi));
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
// —— 字符串 ——
|
|
197
|
+
includes: (haystack, needle) => {
|
|
198
|
+
if (haystack == null) return false;
|
|
199
|
+
const h = Array.isArray(haystack) ? haystack : String(haystack);
|
|
200
|
+
return Array.isArray(h) ? h.some((x) => looseEq(x, needle)) : h.includes(String(needle ?? ''));
|
|
201
|
+
},
|
|
202
|
+
// 字符串 / 数组的长度;null / 数字等拿不到长度 → 0(模板里可直接当数比)
|
|
203
|
+
length: (v) => {
|
|
204
|
+
if (v == null) return 0;
|
|
205
|
+
if (typeof v === 'string' || Array.isArray(v)) return v.length;
|
|
206
|
+
return String(v).length;
|
|
207
|
+
},
|
|
208
|
+
// default(v, fallback):v 为空(null / undefined / 空串 / 空数组)时给兜底文本
|
|
209
|
+
default: (v, fallback = '') => {
|
|
210
|
+
if (v == null) return fallback;
|
|
211
|
+
if (typeof v === 'string' && !v.trim()) return fallback;
|
|
212
|
+
if (Array.isArray(v) && v.length === 0) return fallback;
|
|
213
|
+
return v;
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
// —— 时间 ——
|
|
217
|
+
// 秒 → 人话(与交付文本里的「剩余 / 已过」同一套措辞)
|
|
218
|
+
formatDuration: (sec) => formatDuration(sec),
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
/** 已注册的 helper 名(文档 / 测试 / 设置页速查共用)。 */
|
|
222
|
+
export const TEMPLATE_HELPERS = Object.keys(HELPER_DEFS);
|
|
223
|
+
|
|
224
|
+
// 统一包一层 try/catch:任何 helper 自身异常都退化成可见兜底,不拖垮整份渲染(#90 约束)
|
|
225
|
+
for (const [name, fn] of Object.entries(HELPER_DEFS)) {
|
|
226
|
+
HB.registerHelper(name, (...args) => {
|
|
227
|
+
try {
|
|
228
|
+
// Handlebars 会把 options 对象塞在最后一个参数里
|
|
229
|
+
const plain = args.length && typeof args[args.length - 1] === 'object' && args[args.length - 1] !== null
|
|
230
|
+
? args.slice(0, -1)
|
|
231
|
+
: args;
|
|
232
|
+
return fn(...plain);
|
|
233
|
+
} catch {
|
|
234
|
+
return 'NaN';
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
|
|
53
240
|
// 旧语法识别(不兼容、不迁移):
|
|
54
241
|
// - 旧闸门 `{{#repo}}` / `{{#group}}` / `{{#attachSync}}` / `{{#goalCheck}}` 等:
|
|
55
242
|
// 只允许 `{{#if}}` / `{{#each}}` 两种块。
|
|
@@ -170,8 +170,12 @@ export const lifecycleActions = [
|
|
|
170
170
|
service.completeTask({ id: ctx.id, cwd: ctx.cwd, key: ctx.key, summary: ctx.summary }),
|
|
171
171
|
render: (d) => {
|
|
172
172
|
if (d.status === 'blocked') {
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
// #90:未到点的拦截文案来自可配置的 doneguard 模板(d.guard);模板空/渲染失败
|
|
174
|
+
// 才退回内置 hint 的一行式兜底。
|
|
175
|
+
if (d.reason === 'not_claimed') return `[blocked] 任务 #${d.id} 暂不能标完成:${d.hint}`;
|
|
176
|
+
const head = `时间未到(剩 ${d.remainingHuman || Math.round((d.remainingSec || 0) / 60) + ' 分钟'},截止 ${d.deadline})`;
|
|
177
|
+
if (d.guard) return `[blocked] 任务 #${d.id} 暂不能标完成。\n${d.guard}\n(${head})`;
|
|
178
|
+
return `[blocked] 任务 #${d.id} 暂不能标完成:${head}——${d.hint}`;
|
|
175
179
|
}
|
|
176
180
|
if (d.already) return `任务 #${d.id} 之前已完成(${d.completedAt}),无需重复标记。`;
|
|
177
181
|
const goal = d.goal && d.goal.recorded ? '(最终 check 已记录)' : '';
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
// 跳过被依赖/闸门挡住的 pending)、completeTask(完成门禁:timegoal 未到点返回 blocked
|
|
3
3
|
// 业务值而不是抛错)、reopenTask(用户修改反馈 → **就地重开原任务**,历史进 history 链)。
|
|
4
4
|
import { badInput, notFound } from '../../core/errors.js';
|
|
5
|
-
import { formatDuration } from '../../core/instruction-template.js';
|
|
5
|
+
import { formatDuration, renderInstruction } from '../../core/instruction-template.js';
|
|
6
|
+
import { resolveBlockTemplates } from '../../shared/prompt-blocks.js';
|
|
7
|
+
import { getLtSettings } from './repo/settings.js';
|
|
8
|
+
import { taskGoalTemplateCtx } from '../tasktool/plugins/goal-template.js';
|
|
6
9
|
import { preserveFrontmatter } from '../../shared/frontmatter.js';
|
|
7
10
|
import {
|
|
8
11
|
FEEDBACK_HEADING,
|
|
@@ -23,6 +26,34 @@ import {
|
|
|
23
26
|
txw as tx,
|
|
24
27
|
} from './repo/index.js';
|
|
25
28
|
|
|
29
|
+
/**
|
|
30
|
+
* 「未到点就想 done」的拦截提示(#90):模板来自设置 lt.blockTemplates.doneguard,
|
|
31
|
+
* 与其余系统段同一套 Handlebars 引擎与 ctx;渲染失败退回 '',调用方仍用内置 hint,
|
|
32
|
+
* 门禁本身的业务结果不受模板影响。
|
|
33
|
+
*/
|
|
34
|
+
function renderDoneGuard({ taskId, taskText, goalKey, st }) {
|
|
35
|
+
try {
|
|
36
|
+
const s = getLtSettings();
|
|
37
|
+
const tpl = resolveBlockTemplates(s && s.blockTemplates).doneguard.template;
|
|
38
|
+
const goal = st.goal || {};
|
|
39
|
+
const ctx = taskGoalTemplateCtx({
|
|
40
|
+
taskId,
|
|
41
|
+
taskText: taskText || '',
|
|
42
|
+
goalKey,
|
|
43
|
+
durationSec: Number(goal.durationSec) || 0,
|
|
44
|
+
extra: '',
|
|
45
|
+
startedAt: goal.startedAt,
|
|
46
|
+
deadline: goal.deadline,
|
|
47
|
+
nowMs: Date.now(),
|
|
48
|
+
});
|
|
49
|
+
// 只在这一条路径上置真:正常交付渲染时没有这个变量,doneguard 段整段省略
|
|
50
|
+
ctx.goal.blocked = true;
|
|
51
|
+
return String(renderInstruction(tpl, ctx) || '').trim();
|
|
52
|
+
} catch {
|
|
53
|
+
return '';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
26
57
|
/**
|
|
27
58
|
* 解析 supersededBy:本地是数字(同主题 seq),跨队列搬家后写的是 "key:seq"。
|
|
28
59
|
* 主题 key 本身不含 ':'(见 core/topic-key.js),所以最后一个 ':' 就是分隔符。
|
|
@@ -311,6 +342,14 @@ export async function completeTask({ cwd: rawCwd, key: rawKey, id, summary: rawS
|
|
|
311
342
|
const { taskGoalState, recordTaskCheck } = await import('../tasktool/taskgoal.js');
|
|
312
343
|
const st = await taskGoalState({ topicKey: key, taskId: want });
|
|
313
344
|
if (st.hasGoal && !st.reached) {
|
|
345
|
+
// 「未到点就想 done」的拦截提示可配(#90):模板与其它区块同源,落
|
|
346
|
+
// lt.blockTemplates.doneguard;渲染失败退回内置 hint,不挡业务结果。
|
|
347
|
+
const guard = renderDoneGuard({
|
|
348
|
+
taskId: want,
|
|
349
|
+
taskText: task.text,
|
|
350
|
+
goalKey: st.key,
|
|
351
|
+
st,
|
|
352
|
+
});
|
|
314
353
|
return {
|
|
315
354
|
status: 'blocked',
|
|
316
355
|
reason: 'goal_not_reached',
|
|
@@ -322,6 +361,7 @@ export async function completeTask({ cwd: rawCwd, key: rawKey, id, summary: rawS
|
|
|
322
361
|
remainingSec: st.remainingSec,
|
|
323
362
|
remainingHuman: formatDuration(st.remainingSec),
|
|
324
363
|
hint: '时间未到,不能标记完成——请派出 sub agent 重新提出新的需求;到点后(timegoal check 返回 reached:true)再来标完成',
|
|
364
|
+
guard,
|
|
325
365
|
};
|
|
326
366
|
}
|
|
327
367
|
if (st.hasGoal) {
|
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
// - 整个渲染领域只有一个 ctx(见 delivery-template.js 的 buildDeliveryCtx):
|
|
5
5
|
// `{ task, repo, group, attach, goal, getloop, source, summary, cwd, name, params }`。
|
|
6
6
|
// 所有区块模板都从这同一份数据取值——不存在「某模块自带一套变量域」。
|
|
7
|
-
// - 每个区块(context / attachment / timecheck / ack /
|
|
8
|
-
//
|
|
7
|
+
// - 每个区块(context / attachment / timecheck / goalhint / doneguard / ext / ack /
|
|
8
|
+
// getloop)各自有一份独立的模板列表:
|
|
9
|
+
// `blockTemplates[id] = { active, list: [{ id, name, template, builtin }] }`。
|
|
9
10
|
// 旧 rule 区块已合并进 ack(done 指令与收尾要求只留这一个出口)。
|
|
10
11
|
// 列表里可以新建、编辑、复制、删除,并由 `active` 指定该区块当前生效的模板。
|
|
11
12
|
// - 每个区块**始终至少有一个系统内置模板**(id 固定 `builtin`):不可删除,
|
|
12
13
|
// 内容固定为该区块的默认模板;用户模板删光后 active 自动回落到它。
|
|
13
14
|
// - 模板由 core/instruction-template.js(Handlebars 4.x)渲染;列表变量是结构化数组,
|
|
14
|
-
// 用 `{{#each}}` 展开;有无用 `{{#if}}`
|
|
15
|
+
// 用 `{{#each}}` 展开;有无用 `{{#if}}` 判断。另有一组内置 helper(比较 / 逻辑 /
|
|
16
|
+
// 数值 / 字符串 / 时间,见该文件的 HELPER_DEFS),失败输出可见的 NaN / false,不抛错。
|
|
15
17
|
// - 旧语法(`{{#repo}}…{{/repo}}` 闸门、`{{group.peers}}` 这类纯文本占位符、
|
|
16
18
|
// `{{attach.sync}}` 旧别名)**不再兼容**;保存校验会直接拒绝并提示改用新语法。
|
|
17
19
|
//
|
|
@@ -143,16 +145,36 @@ export const DEFAULT_TIMECHECK_TEMPLATE = [
|
|
|
143
145
|
].join('\n');
|
|
144
146
|
|
|
145
147
|
/**
|
|
146
|
-
* 默认「特殊功能提示」段(任务 #87
|
|
147
|
-
*
|
|
148
|
+
* 默认「特殊功能提示」段(任务 #87,文案在 #90 里补全):只在任务带时间目标时出现,
|
|
149
|
+
* 给 agent 一份**可运算的**时间上下文(持续 / 已过 / 剩余 / 是否到点)与任务号,
|
|
150
|
+
* 并按进度给阶段口径(过半提醒、2/3 收尾、到点收口)。
|
|
148
151
|
*
|
|
149
152
|
* 这一栏存在的意义是「占位符的可见入口」:goal.* 与 task.* 都是每轮 check 同源
|
|
150
153
|
* 渲染的同一份 ctx(check 返回对象走同一套模板),用户在这里改文案即可定制提示,
|
|
151
|
-
* 不必改代码。默认文案刻意不复述 check 指令(那在 timecheck
|
|
154
|
+
* 不必改代码。默认文案刻意不复述 check 指令(那在 timecheck 段里),只补状态与阶段。
|
|
155
|
+
* 进度用内置 helper 现算(percent / gte),不新增 ctx 字段。
|
|
152
156
|
*/
|
|
153
157
|
export const DEFAULT_GOALHINT_TEMPLATE = [
|
|
154
158
|
'{{#if goal.check}}',
|
|
155
|
-
'〔特殊功能提示 · 时间目标〕任务 #{{task.id}} 正在计时:持续 {{goal.durationHuman}}
|
|
159
|
+
'〔特殊功能提示 · 时间目标〕任务 #{{task.id}} 正在计时:持续 {{goal.durationHuman}},已过 {{goal.elapsedHuman}}({{percent goal.elapsedSec goal.durationSec}}%),{{#if goal.reached}}已到点(超时 {{formatDuration goal.overtimeSec}}){{else}}剩余 {{goal.remainingHuman}}{{/if}}。',
|
|
160
|
+
'{{#if goal.reached}}——时间已到:可以收口,把改动收敛成可交付状态,补验证与说明后按 ack 段 done。',
|
|
161
|
+
'{{else}}{{#if (gte (percent goal.elapsedSec goal.durationSec) 67)}}——已过 2/3:进入收尾整理(收敛改动 / 补验证 / 写清遗留),别开新战线。',
|
|
162
|
+
'{{else}}{{#if (gte (percent goal.elapsedSec goal.durationSec) 50)}}——已过半:先确认主线走到哪,剩余时间只做收尾必需项。',
|
|
163
|
+
'{{else}}——时间尚足:先做主线,再补细节。{{/if}}{{/if}}{{/if}}',
|
|
164
|
+
'{{/if}}',
|
|
165
|
+
].join('\n');
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 默认「完成门禁提示」段(#90):agent 未到点就想 `localtask done` 时**代替**原来那句
|
|
169
|
+
* 固定 hint 出现在 blocked 返回里。与其它区块同源:模板可改、变量是 goal.* / task.*,
|
|
170
|
+
* 并能用 helper 按进度给不同口径。`goal.blocked` 只在这条路径上为真,交付渲染时整段省略。
|
|
171
|
+
*/
|
|
172
|
+
export const DEFAULT_DONEGUARD_TEMPLATE = [
|
|
173
|
+
'{{#if goal.blocked}}',
|
|
174
|
+
'〔完成门禁 · 时间未到〕任务 #{{task.id}} 还不能 done:持续 {{goal.durationHuman}},已过 {{goal.elapsedHuman}}({{percent goal.elapsedSec goal.durationSec}}%),剩余 {{goal.remainingHuman}}。',
|
|
175
|
+
'- 现在可做:{{#if (gte (percent goal.elapsedSec goal.durationSec) 67)}}收尾整理(收敛改动 / 补验证 / 写清遗留),或派 sub agent 提出新的需求继续推进{{else}}继续推进主线,并派 sub agent 重新提出新的需求{{/if}}。',
|
|
176
|
+
'- 每轮推进先跑:nx-kv timegoal check --task {{goal.goalKey}} --summary "<本轮现状>" --progress "<进展/下一步>"',
|
|
177
|
+
'- 到点后再:nx-kv localtask done --id {{task.id}} --summary "<完成总结>"',
|
|
156
178
|
'{{/if}}',
|
|
157
179
|
].join('\n');
|
|
158
180
|
|
|
@@ -215,6 +237,13 @@ export const BLOCK_DEFS = Object.freeze([
|
|
|
215
237
|
desc: '任务带时间目标时出现:可直接用 goal.* 时间变量与 task 全文占位;每轮 check 同源渲染',
|
|
216
238
|
defaultTemplate: DEFAULT_GOALHINT_TEMPLATE,
|
|
217
239
|
},
|
|
240
|
+
{
|
|
241
|
+
id: 'doneguard',
|
|
242
|
+
tag: 'nx-kv.doneguard',
|
|
243
|
+
label: '完成门禁提示(timegoal)',
|
|
244
|
+
desc: 'agent 未到点就想 done 时出现(blocked 返回的 guard):说明剩余时间与可做事项,可用 helper 按进度分档',
|
|
245
|
+
defaultTemplate: DEFAULT_DONEGUARD_TEMPLATE,
|
|
246
|
+
},
|
|
218
247
|
{
|
|
219
248
|
id: 'ext',
|
|
220
249
|
tag: 'nx-kv.ext',
|
|
@@ -206,6 +206,42 @@ export const BLOCK_PARAMS = {
|
|
|
206
206
|
],
|
|
207
207
|
},
|
|
208
208
|
],
|
|
209
|
+
// #90:未到点就 done 的拦截文案(blocked 返回里的 guard 字段)
|
|
210
|
+
doneguard: [
|
|
211
|
+
{
|
|
212
|
+
label: '时间目标上下文(任务级)',
|
|
213
|
+
items: [
|
|
214
|
+
['goal.blocked', '恒为 true(只在这条拦截路径上出现,交付渲染时整段省略)'],
|
|
215
|
+
['goal.goalKey', '任务级目标 key(check --task 用)'],
|
|
216
|
+
['goal.durationHuman', '持续时长(人话)'],
|
|
217
|
+
['goal.durationSec', '持续秒数'],
|
|
218
|
+
['goal.startedAt', '开始计时时间'],
|
|
219
|
+
['goal.deadline', '截止时间'],
|
|
220
|
+
['goal.remainingHuman', '剩余时长(人话)'],
|
|
221
|
+
['goal.remainingSec', '剩余秒数'],
|
|
222
|
+
['goal.elapsedHuman', '已过时长(人话)'],
|
|
223
|
+
['goal.elapsedSec', '已过秒数'],
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
label: '任务',
|
|
228
|
+
items: [
|
|
229
|
+
['task.id', '任务号'],
|
|
230
|
+
['task.text', '任务实时原文'],
|
|
231
|
+
],
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
label: '可用的 helper(与所有区块同一套)',
|
|
235
|
+
items: [
|
|
236
|
+
['percent goal.elapsedSec goal.durationSec', '已用百分比(0 位小数;可加第三参控制小数位)'],
|
|
237
|
+
['gte a b / gt / lt / lte / eq / ne / between v min max', '比较,返回布尔,可直接进 {{#if}}'],
|
|
238
|
+
['and / or / not', '逻辑'],
|
|
239
|
+
['add / sub / mul / div / mod / round / floor / ceil / ratio / clamp', '数值计算(坏输入输出 NaN,不抛错)'],
|
|
240
|
+
['includes / length / default', '字符串'],
|
|
241
|
+
['formatDuration', '秒数转人话'],
|
|
242
|
+
],
|
|
243
|
+
},
|
|
244
|
+
],
|
|
209
245
|
ext: [
|
|
210
246
|
{
|
|
211
247
|
label: '队列',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as e,h as t,l as n,m as r,o as i,p as a,v as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,v as l,w as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{_ as f,a as p,i as m,n as h,p as g,r as _,t as v,u as y,v as b,y as x}from"./md-history-
|
|
1
|
+
import{g as e,h as t,l as n,m as r,o as i,p as a,v as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,v as l,w as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{_ as f,a as p,i as m,n as h,p as g,r as _,t as v,u as y,v as b,y as x}from"./md-history-CBqcR086.js";import{a as S,i as C}from"./upload-BIMbGcCB.js";import{r as ee}from"./md-parse-awNLHAzO.js";import{t as w}from"./route-crumb-PqhQSVWL.js";import{a as T,c as E,i as D,l as O,o as te,r as k,s as A,t as j,u as ne}from"./tool-bar-TIqYxsQl.js";var M=s(e(),1),N=u(),P=t(),F=`doc`,I=[{id:`edit`,label:`编辑`},{id:`doc`,label:`文档`},{id:`view`,label:`查看`}];function re({crumb:e=null,title:t,pathLabel:n=``,dirty:r=!1,writable:i=!1,onSave:a=null,onSaveLabel:o=`保存`,menuGroups:s=[],saving:c=!1,external:l=!1,afterTitle:u=null}){let d=D(),{layout:f,setLayout:p}=te(F),[m,h]=(0,M.useState)(!1),g={};for(let e of s||[])for(let t of e?.items||[])t&&t.id&&(g[t.id]=t);g.save=a&&{id:`save`,label:c?`保存中…`:o,run:a,primary:!0,disabled:c||!r};let _=e=>e===`more`||!!g[e],v=f.filter(e=>O(F,e)&&_(e.id)),y=f.filter(e=>A(F,e)&&_(e.id)),b=e=>{g[e]?.run?.(),d.setOpen(!1)},x=e=>{if(e===`more`)return(0,P.jsx)(`div`,{className:`docp-more`,ref:d.ref,children:(0,P.jsx)(`button`,{type:`button`,className:`btn ghost sm${d.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":d.open,onClick:e=>k(d,e,`right`),children:`更多`})},`more`);let t=g[e];return t?(0,P.jsx)(`button`,{type:`button`,className:t.primary||e===`save`?`btn sm primary docp-save`:`btn ghost sm`,disabled:!!t.disabled,onClick:()=>b(e),children:t.label||E(F,e).label||e},e):null},S=I.map(e=>({...e,items:y.filter(t=>E(F,t.id).menuGroup===e.id)})).filter(e=>e.items.length),C=y.filter(e=>!E(F,e.id).menuGroup);return i?(0,P.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,P.jsxs)(`div`,{className:`mdw-head`,children:[(0,P.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,P.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,P.jsx)(`span`,{className:`grow`}),u,(0,P.jsxs)(`div`,{className:`docp-actions`,children:[v.map(e=>x(e.id)),(0,P.jsxs)(j,{menu:d,className:`mdw-act-menu`,children:[S.map(e=>(0,P.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,P.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=g[e.id],n=t?.danger||E(F,e.id).danger;return(0,P.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>b(e.id),children:[t?.label||E(F,e.id).label||e.id,t?.hint?(0,P.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),C.map(e=>{let t=g[e.id];return(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||E(F,e.id).danger?` danger`:``),onClick:()=>b(e.id),children:t?.label||E(F,e.id).label||e.id},e.id)}),(0,P.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{d.setOpen(!1),h(!0)},children:`自定义工具栏…`})]})]})]}),m&&(0,N.createPortal)((0,P.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>h(!1),children:(0,P.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,P.jsx)(T,{kind:F,layout:f,setLayout:p,onClose:()=>h(!1)})})}),document.body)]}):(0,P.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,P.jsxs)(`div`,{className:`mdw-head`,children:[(0,P.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,P.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,P.jsx)(`span`,{className:`grow`}),u,(0,P.jsx)(`div`,{className:`docp-actions`,children:(0,P.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function L(e,t,n){return{id:e,label:t,items:n.filter(Boolean)}}function R(e){let t=String(e??``).replace(/^/,``).replace(/\r\n/g,`
|
|
2
2
|
`),n=t.match(/^---\n([\s\S]*?)\n---\n?/),r=n?t.slice(n[0].length):t;for(let e of r.split(`
|
|
3
3
|
`)){let t=e.trim();if(t)return t}return``}function z(e){let t=R(e).match(/^#\s+(.+)$/);return t?t[1].trim():``}function ie(e,t){let n=String(e??``),r=String(t||``).trim()||`未命名文档`,i=n.replace(/\r\n/g,`
|
|
4
4
|
`),a=i.match(/^---\n([\s\S]*?)\n---\n?/),o=a?i.slice(0,a[0].length):``,s=(a?i.slice(a[0].length):i).split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,h as t,y as n}from"./task-status-BnymQMTw.js";import{w as r}from"./workspace-C_5X2gIr.js";import{a as i,c as a,l as o,o as s,s as c}from"./tool-bar-
|
|
1
|
+
import{g as e,h as t,y as n}from"./task-status-BnymQMTw.js";import{w as r}from"./workspace-C_5X2gIr.js";import{a as i,c as a,l as o,o as s,s as c}from"./tool-bar-TIqYxsQl.js";var l=n(e(),1),u=r(),d=t();function f({kind:e,renderers:t={},actions:n={},titles:r={},disabled:f={},labels:p={},className:m=``}){let{layout:h,setLayout:g}=s(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=>{C.current?.contains(e.target)||w.current?.contains(e.target)||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=>o(e,t)),E=h.filter(t=>c(e,t)),D=t=>p[t]||a(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=>n===`more`?(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`):t[n]?(0,d.jsx)(`span`,{className:`ta-slot`,children:t[n]({open:_})},n):O(n,{primary:a(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),n[e.id]&&n[e.id]()},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)(i,{kind:e,layout:h,setLayout:g,onClose:()=>S(!1)})})}),document.body)]})}export{f as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{c as e,f as t,g as n,h as r,l as i,m as a,o,p as s,y as c}from"./task-status-BnymQMTw.js";import{a as l,i as u,l as d,n as f,t as p}from"./upload-BIMbGcCB.js";import{S as m,x as h}from"./index-D2fKyD1k.js";import{t as g}from"./route-crumb-CvrRU1gp.js";var _=c(n(),1),v=r(),y=e=>`/api/file/content/${encodeURIComponent(e)}`;function b({text:e,compact:t=!1,className:n=``}){let r=d(e);return r.some(e=>e.type!==`text`)?(0,v.jsx)(`span`,{className:n?`mdtext ${n}`:`mdtext`,children:r.map((e,n)=>{if(e.type===`text`)return(0,v.jsx)(`span`,{className:`mdtext-plain`,children:e.value},n);let r=y(e.id);return e.type===`image`?(0,v.jsx)(`a`,{className:`embed-image`+(t?` compact`:``),href:r,target:`_blank`,rel:`noreferrer`,title:e.alt?`${e.alt}(点击看原图)`:e.id,children:(0,v.jsx)(`img`,{src:r,alt:e.alt||e.id,loading:`lazy`})},n):(0,v.jsx)(`a`,{className:`embed-file`,href:r,target:`_blank`,rel:`noreferrer`,title:e.id,children:e.alt||e.id},n)})}):(0,v.jsx)(`span`,{className:n,children:e})}function x({task:e,pick:t,group:n,onSaved:r,onCancel:i}){let o=s(),[c,d]=(0,_.useState)(e.text||``),[m,h]=(0,_.useState)(e.note||``),[g,y]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(!1),T=(0,_.useRef)(null),E=(0,_.useRef)(null),D=(0,_.useRef)(c),O=e=>{D.current=e,d(e)};(0,_.useEffect)(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[]);let k=e=>{if(!e)return;let t=T.current,n=D.current,r=t&&t.selectionStart!==null?t.selectionStart:n.length,i=t&&t.selectionEnd!==null?t.selectionEnd:r,a=n.slice(0,r),o=n.slice(i),s=a&&!/\s$/.test(a)?` `:``,c=`${a}${s}${e}${o&&!/^\s/.test(o)?` `:``}${o}`;O(c);let l=a.length+s.length+e.length;requestAnimationFrame(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(l,l))})},A=async e=>{let t=Array.from(e||[]).filter(e=>e&&e.size>0);if(t.length&&!x){S({done:0,total:t.length});try{let e=await l(t,{group:n,onProgress:(e,t)=>S({done:e,total:t})});k(u(e));let r=e.filter(e=>e.isImage).length;o(e.length===1?`已插入 ${e[0].name}`:`已插入 ${e.length} 个附件${r?`(图片 ${r} 个)`:``}`)}catch(e){o(String(e&&e.message||e))}finally{S(null)}}},j=e=>{let t=p(e);t.length&&(e.preventDefault(),A(t))},M=(0,_.useRef)(null);M.current=e=>A(f(e)),(0,_.useEffect)(()=>{let e=e=>Array.from(e.dataTransfer&&e.dataTransfer.types||[]).includes(`Files`),t=t=>{e(t)&&(t.preventDefault(),w(!0))},n=e=>{e.relatedTarget||w(!1)},r=t=>{e(t)&&(t.preventDefault(),w(!1),M.current&&M.current(t))};return window.addEventListener(`dragover`,t),window.addEventListener(`dragleave`,n),window.addEventListener(`drop`,r),()=>{window.removeEventListener(`dragover`,t),window.removeEventListener(`dragleave`,n),window.removeEventListener(`drop`,r)}},[]);let N=()=>{if(g)return;if(!String(D.current).trim()){o(`正文不能为空`);return}let i={group:n,ref:e.text,pick:t,matchTopic:e.topic,text:D.current};m!==(e.note||``)&&(i.note=m),y(!0),a(`/api/todo/item`,{method:`PATCH`,body:i}).then(()=>{o(`已保存`),r()}).catch(e=>o(String(e&&e.message||e))).finally(()=>y(!1))},P=e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),N())},F=x?`上传中 ${x.done}/${x.total}…`:`选择文件上传`,I=!String(c).trim();return(0,v.jsxs)(`div`,{className:`editor`+(C?` drag`:``),children:[(0,v.jsxs)(`div`,{className:`ed-tip`,children:[`粘贴(`,(0,v.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,v.jsx)(`kbd`,{children:`V`}),` 截图)、拖文件进来,或`,(0,v.jsx)(`button`,{type:`button`,className:`ed-link`,onClick:()=>E.current&&E.current.click(),disabled:!!x,children:`选择文件`}),`—— 会自动上传并插到光标处。`,(0,v.jsx)(`input`,{ref:E,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,A(t)}})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`正文`}),(0,v.jsx)(`textarea`,{ref:T,className:`ed-textarea`,rows:4,value:c,spellCheck:`false`,placeholder:`要做什么… 图片写 ,其他文件写 [文件名](fileId)`,onChange:e=>O(e.target.value),onPaste:j,onKeyDown:P}),(0,v.jsxs)(`div`,{className:`ed-meta`,children:[(0,v.jsxs)(`span`,{className:`ed-acts`,children:[(0,v.jsx)(`button`,{type:`button`,className:`btn small`,onClick:()=>E.current&&E.current.click(),disabled:!!x,children:F}),(0,v.jsxs)(`span`,{className:`hint`,children:[`图片 `,(0,v.jsx)(`code`,{children:``}),` 文件 `,(0,v.jsx)(`code`,{children:`[文件名](id)`})]})]}),(0,v.jsxs)(`span`,{className:`hint`,children:[c.length,` 字符`]})]})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`预览`}),(0,v.jsx)(`div`,{className:`preview`+(I?` empty`:``),children:I?(0,v.jsx)(`span`,{className:`muted`,children:`(暂无内容)`}):(0,v.jsx)(b,{text:c})})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`备注`}),(0,v.jsx)(`textarea`,{className:`ed-textarea`,rows:2,value:m,spellCheck:`false`,placeholder:`可选:完成结果、上下文补充`,onChange:e=>h(e.target.value)})]}),(0,v.jsxs)(`div`,{className:`ed-foot`,children:[(0,v.jsxs)(`span`,{className:`hint`,children:[(0,v.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,v.jsx)(`kbd`,{children:`Enter`}),` 保存`]}),(0,v.jsxs)(`span`,{className:`ed-acts`,children:[(0,v.jsx)(`button`,{className:`btn ghost`,onClick:i,disabled:g,children:`取消`}),(0,v.jsx)(`button`,{className:`btn`,onClick:N,disabled:g||!!x,children:g?`保存中…`:`保存`})]})]})]})}function S({onClose:e}){let{boot:n,refreshBoot:r}=m(),c=s(),l=t(),{dialog:u,node:d}=i(),[f,p]=(0,_.useState)([]),[g,y]=(0,_.useState)(``),[b,x]=(0,_.useState)({name:``,description:``}),[S,C]=(0,_.useState)(null),w=(0,_.useCallback)(async()=>{try{let e=await a(`/api/groups`);p(e.groups||[]),y(``)}catch(e){y(e.message||String(e))}},[]);(0,_.useEffect)(()=>{w()},[w]);let T=n?.groupId??0,E=e=>l(async()=>{let t=await a(`/api/group`,{method:`POST`,body:{locator:e}});c(t.id===0?`已切回默认组`:`已切换到 ${t.name}`),await r(),await w()}),D=()=>l(async()=>{let e=b.name.trim();if(!e){c(`请填名称`);return}let t=await a(`/api/groups`,{method:`POST`,body:{name:e,description:b.description.trim()}});x({name:``,description:``}),c(`已新建工作空间 ${t.name}(id=${t.id})`),await r(),await w()}),O=e=>l(async()=>{let t=await u({title:`重命名「${e.name}」`,input:!0,value:e.name});t!==null&&t.trim()&&(await a(`/api/groups/${e.id}`,{method:`PATCH`,body:{name:t.trim()}}),c(`已更新名称`),await r(),await w())}),k=e=>l(async()=>{await u({message:`解散工作空间「${e.name}」(id=${e.id})?\n\n后端要求组内已无 KV 数据,否则会拒绝。此操作不可撤销。`,danger:!0})&&(await a(`/api/groups/${e.id}`,{method:`DELETE`}),c(`已解散 ${e.name}`),await r(),await w())}),A=e=>l(async()=>{let t=await a(`/api/groups/${e.id}/members`);C({group:t.group,list:t.members||[]})});return n?.loggedIn?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(o,{title:`工作空间`,onClose:e,children:[(0,v.jsx)(`div`,{className:`muted`,style:{marginBottom:8},children:`清单按工作空间隔离读写。切换只改本机配置,不动服务端数据。`}),g?(0,v.jsx)(`div`,{className:`row muted`,children:g}):null,(0,v.jsxs)(`div`,{className:`list`,children:[(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(`span`,{className:`name`,children:`默认组`}),(0,v.jsx)(`span`,{className:`desc`,children:`不传 groupId,由后端回落`}),(0,v.jsx)(`span`,{className:`acts`,children:T===0?(0,v.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,v.jsx)(`button`,{className:`btn small`,onClick:()=>E(`default`),children:`切到这里`})})]}),f.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(h,{className:`name`,text:e.name,title:`点击复制名称`,children:e.name}),(0,v.jsx)(`span`,{className:`tag`,children:e.myRole||`member`}),e.description?(0,v.jsx)(`span`,{className:`desc`,children:e.description}):null,(0,v.jsxs)(`span`,{className:`muted mono`,children:[`id=`,e.id]}),(0,v.jsxs)(`span`,{className:`muted`,children:[e.memberCount,` 人`]}),(0,v.jsxs)(`span`,{className:`acts`,children:[e.id===T?(0,v.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,v.jsx)(`button`,{className:`btn small`,onClick:()=>E(String(e.id)),children:`切到这里`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>A(e),children:`成员`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>O(e),children:`改名`}),(0,v.jsx)(`button`,{className:`btn small ghost danger`,onClick:()=>k(e),children:`解散`})]})]},e.id)),!g&&!f.length?(0,v.jsx)(`div`,{className:`row muted`,children:`(没有其他工作空间)`}):null]}),(0,v.jsxs)(`div`,{className:`toolbar`,style:{marginTop:10},children:[(0,v.jsx)(`input`,{placeholder:`新工作空间名称`,size:`16`,value:b.name,onChange:e=>x({...b,name:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&D()}}),(0,v.jsx)(`input`,{placeholder:`描述(可选)`,size:`20`,value:b.description,onChange:e=>x({...b,description:e.target.value})}),(0,v.jsx)(`button`,{className:`btn`,onClick:D,children:`新建`}),(0,v.jsx)(`button`,{className:`btn ghost`,onClick:()=>l(w),children:`刷新`})]})]}),S?(0,v.jsx)(o,{title:`成员 · ${S.group.name}`,onClose:()=>C(null),children:(0,v.jsx)(`div`,{className:`list`,children:S.list.length?S.list.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(h,{className:`name`,text:e.email,title:`点击复制邮箱`,children:e.email}),(0,v.jsx)(`span`,{className:`tag`,children:e.role||`member`}),(0,v.jsx)(`span`,{className:`muted`,children:e.nickname})]},e.userId)):(0,v.jsx)(`div`,{className:`row muted`,children:`(没有成员)`})})}):null,d]}):(0,v.jsx)(o,{title:`工作空间`,onClose:e,children:(0,v.jsx)(`div`,{className:`muted`,children:`工作空间需要登录后才能列出。`})})}var C=[[`open`,`待办`],[`done`,`已完成`],[`freeze`,`冻结`]],w=e=>e?String(e).slice(0,16).replace(`T`,` `):``,T=15,E=(e,t)=>`${e}:${t.id}:${t.text}`;function D({bucket:t,task:n,dupCount:r,onAct:i}){let a=t===`done`,o=t===`freeze`,s=a?n.doneAt:o?n.frozenAt:n.createdAt;return(0,v.jsxs)(`div`,{className:`row cloud-row`,children:[(0,v.jsxs)(`div`,{className:`row-main`,children:[(0,v.jsxs)(`span`,{className:`tid`,children:[`#`,n.id]}),(0,v.jsx)(h,{className:`topic`,text:n.topic,title:`点击复制主题`,children:n.topic}),(0,v.jsx)(`span`,{className:`text`,title:n.text,children:(0,v.jsx)(b,{text:n.text,compact:!0})}),r>1?(0,v.jsxs)(`span`,{className:`tag`,title:`同内容有 ${r} 条,操作时需要消歧`,children:[`同内容×`,r]}):null,(0,v.jsx)(`span`,{className:`muted time`,children:w(s)}),(0,v.jsxs)(`span`,{className:`acts`,children:[t===`open`?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`done`,n),children:`完成`}):null,o?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`unfreeze`,n),children:`解冻`}):null,(0,v.jsx)(e,{items:[t===`open`&&{label:`冻结`,onPick:()=>i(`freeze`,n)},{label:`编辑`,onPick:()=>i(`edit`,n,t)},{label:`删除`,danger:!0,onPick:()=>i(`remove`,n,t)}]})]})]}),n.note?(0,v.jsx)(`div`,{className:`note`,children:n.note}):null]})}function O(){let{boot:e,ui:n,patchUi:r,refreshBoot:c}=m(),d=s(),f=t(),{dialog:y,node:b}=i(),[O,k]=(0,_.useState)(null),[A,j]=(0,_.useState)(``),[M,N]=(0,_.useState)(!1),[P,F]=(0,_.useState)({topic:``,text:``}),[I,L]=(0,_.useState)(null),[R,z]=(0,_.useState)(!1),[B,ee]=(0,_.useState)({}),[V,H]=(0,_.useState)(null),[U,W]=(0,_.useState)(null),G=e?.groupId??0,te=(e?.groups||[]).find(e=>e.id===G)?.name||(G?`#${G}`:`默认组`),[K,q]=(0,_.useState)({email:e?.email||``,password:``,busy:!1,open:!1}),J=()=>f(async()=>{if(!K.email.trim()){d(`请填邮箱`);return}if(!K.password){d(`请填密码`);return}q(e=>({...e,busy:!0}));try{let e=await a(`/api/auth/login`,{method:`POST`,body:{email:K.email.trim(),password:K.password}});q(e=>({...e,password:``})),d(`已登录: ${e.email}`),await c()}finally{q(e=>({...e,busy:!1}))}}),ne=()=>f(async()=>{await a(`/api/auth/logout`,{method:`POST`}),d(`已登出`),await c()}),Y=(0,_.useCallback)(async()=>{if(e?.loggedIn)try{k(await a(`/api/todo`)),j(``)}catch(e){j(String(e.message||e))}},[e?.loggedIn]);(0,_.useEffect)(()=>{Y()},[Y,G]),(0,_.useEffect)(()=>{a(`/api/setting`).then(W).catch(()=>{})},[]);let X=!!U?.autoSyncAttachments,re=()=>f(async()=>{let e=!X,t=await a(`/api/setting`,{method:`POST`,body:{autoSyncAttachments:e}});W(t),d(e?`已开启:读任务时自动下载附件到本地`:`已关闭自动下载附件`)}),Z=(0,_.useCallback)(async()=>{N(!0);try{await Y()}finally{N(!1)}},[Y]),ie=(0,_.useMemo)(()=>{let e=new Map;if(!O)return e;for(let[t]of C)for(let n of O[t]||[])e.set(n.text,(e.get(n.text)||0)+1);return e},[O]),Q=(0,_.useMemo)(()=>{if(!O)return null;let e=n.topic,t=t=>t?e?t.filter(t=>t.topic===e):t:null;return{open:t(O.open),done:t(O.done),freeze:t(O.freeze)}},[O,n.topic]);if(!e?.loggedIn)return(0,v.jsxs)(`div`,{className:`cloud-page`,children:[(0,v.jsx)(g,{}),(0,v.jsxs)(`div`,{className:`card`,style:{padding:16,maxWidth:640},children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:`登录云端`}),(0,v.jsx)(`span`,{className:`tag bad`,children:`未登录`})]}),(0,v.jsxs)(`div`,{className:`row-inline`,style:{padding:12},children:[(0,v.jsx)(`input`,{placeholder:`邮箱`,size:`24`,spellCheck:`false`,value:K.email,onChange:e=>q(t=>({...t,email:e.target.value}))}),(0,v.jsx)(`input`,{placeholder:`密码`,type:`password`,size:`18`,value:K.password,onChange:e=>q(t=>({...t,password:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&J()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:J,disabled:K.busy,children:K.busy?`登录中…`:`登录`})]}),(0,v.jsxs)(`div`,{className:`muted`,style:{padding:`0 12px 12px`,fontSize:12},children:[`密码只用于本次请求,不写入本机配置;配置里只保存 token。 也可以用 CLI:`,(0,v.jsx)(`code`,{children:`nx-kv auth login <email>`}),`。`]})]})]});let ae=async(e,t)=>{let n=[];for(let[t]of C)for(let r of O[t]||[])r.text===e.text&&n.push({bucket:t,task:r});if(n.length<=1)return{bucket:t,task:e,pick:void 0};let r=n.findIndex(n=>n.bucket===t&&n.task.createdAt===e.createdAt),i=await y({title:`「${e.text.slice(0,30)}」有 ${n.length} 条,选哪一条?`,message:n.map((e,t)=>`[${t}] ${e.bucket} ${w(e.task.createdAt)} #${e.task.id}`).join(`
|
|
1
|
+
import{c as e,f as t,g as n,h as r,l as i,m as a,o,p as s,y as c}from"./task-status-BnymQMTw.js";import{a as l,i as u,l as d,n as f,t as p}from"./upload-BIMbGcCB.js";import{S as m,x as h}from"./index-ChlZPTea.js";import{t as g}from"./route-crumb-PqhQSVWL.js";var _=c(n(),1),v=r(),y=e=>`/api/file/content/${encodeURIComponent(e)}`;function b({text:e,compact:t=!1,className:n=``}){let r=d(e);return r.some(e=>e.type!==`text`)?(0,v.jsx)(`span`,{className:n?`mdtext ${n}`:`mdtext`,children:r.map((e,n)=>{if(e.type===`text`)return(0,v.jsx)(`span`,{className:`mdtext-plain`,children:e.value},n);let r=y(e.id);return e.type===`image`?(0,v.jsx)(`a`,{className:`embed-image`+(t?` compact`:``),href:r,target:`_blank`,rel:`noreferrer`,title:e.alt?`${e.alt}(点击看原图)`:e.id,children:(0,v.jsx)(`img`,{src:r,alt:e.alt||e.id,loading:`lazy`})},n):(0,v.jsx)(`a`,{className:`embed-file`,href:r,target:`_blank`,rel:`noreferrer`,title:e.id,children:e.alt||e.id},n)})}):(0,v.jsx)(`span`,{className:n,children:e})}function x({task:e,pick:t,group:n,onSaved:r,onCancel:i}){let o=s(),[c,d]=(0,_.useState)(e.text||``),[m,h]=(0,_.useState)(e.note||``),[g,y]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(!1),T=(0,_.useRef)(null),E=(0,_.useRef)(null),D=(0,_.useRef)(c),O=e=>{D.current=e,d(e)};(0,_.useEffect)(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[]);let k=e=>{if(!e)return;let t=T.current,n=D.current,r=t&&t.selectionStart!==null?t.selectionStart:n.length,i=t&&t.selectionEnd!==null?t.selectionEnd:r,a=n.slice(0,r),o=n.slice(i),s=a&&!/\s$/.test(a)?` `:``,c=`${a}${s}${e}${o&&!/^\s/.test(o)?` `:``}${o}`;O(c);let l=a.length+s.length+e.length;requestAnimationFrame(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(l,l))})},A=async e=>{let t=Array.from(e||[]).filter(e=>e&&e.size>0);if(t.length&&!x){S({done:0,total:t.length});try{let e=await l(t,{group:n,onProgress:(e,t)=>S({done:e,total:t})});k(u(e));let r=e.filter(e=>e.isImage).length;o(e.length===1?`已插入 ${e[0].name}`:`已插入 ${e.length} 个附件${r?`(图片 ${r} 个)`:``}`)}catch(e){o(String(e&&e.message||e))}finally{S(null)}}},j=e=>{let t=p(e);t.length&&(e.preventDefault(),A(t))},M=(0,_.useRef)(null);M.current=e=>A(f(e)),(0,_.useEffect)(()=>{let e=e=>Array.from(e.dataTransfer&&e.dataTransfer.types||[]).includes(`Files`),t=t=>{e(t)&&(t.preventDefault(),w(!0))},n=e=>{e.relatedTarget||w(!1)},r=t=>{e(t)&&(t.preventDefault(),w(!1),M.current&&M.current(t))};return window.addEventListener(`dragover`,t),window.addEventListener(`dragleave`,n),window.addEventListener(`drop`,r),()=>{window.removeEventListener(`dragover`,t),window.removeEventListener(`dragleave`,n),window.removeEventListener(`drop`,r)}},[]);let N=()=>{if(g)return;if(!String(D.current).trim()){o(`正文不能为空`);return}let i={group:n,ref:e.text,pick:t,matchTopic:e.topic,text:D.current};m!==(e.note||``)&&(i.note=m),y(!0),a(`/api/todo/item`,{method:`PATCH`,body:i}).then(()=>{o(`已保存`),r()}).catch(e=>o(String(e&&e.message||e))).finally(()=>y(!1))},P=e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),N())},F=x?`上传中 ${x.done}/${x.total}…`:`选择文件上传`,I=!String(c).trim();return(0,v.jsxs)(`div`,{className:`editor`+(C?` drag`:``),children:[(0,v.jsxs)(`div`,{className:`ed-tip`,children:[`粘贴(`,(0,v.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,v.jsx)(`kbd`,{children:`V`}),` 截图)、拖文件进来,或`,(0,v.jsx)(`button`,{type:`button`,className:`ed-link`,onClick:()=>E.current&&E.current.click(),disabled:!!x,children:`选择文件`}),`—— 会自动上传并插到光标处。`,(0,v.jsx)(`input`,{ref:E,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,A(t)}})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`正文`}),(0,v.jsx)(`textarea`,{ref:T,className:`ed-textarea`,rows:4,value:c,spellCheck:`false`,placeholder:`要做什么… 图片写 ,其他文件写 [文件名](fileId)`,onChange:e=>O(e.target.value),onPaste:j,onKeyDown:P}),(0,v.jsxs)(`div`,{className:`ed-meta`,children:[(0,v.jsxs)(`span`,{className:`ed-acts`,children:[(0,v.jsx)(`button`,{type:`button`,className:`btn small`,onClick:()=>E.current&&E.current.click(),disabled:!!x,children:F}),(0,v.jsxs)(`span`,{className:`hint`,children:[`图片 `,(0,v.jsx)(`code`,{children:``}),` 文件 `,(0,v.jsx)(`code`,{children:`[文件名](id)`})]})]}),(0,v.jsxs)(`span`,{className:`hint`,children:[c.length,` 字符`]})]})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`预览`}),(0,v.jsx)(`div`,{className:`preview`+(I?` empty`:``),children:I?(0,v.jsx)(`span`,{className:`muted`,children:`(暂无内容)`}):(0,v.jsx)(b,{text:c})})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`备注`}),(0,v.jsx)(`textarea`,{className:`ed-textarea`,rows:2,value:m,spellCheck:`false`,placeholder:`可选:完成结果、上下文补充`,onChange:e=>h(e.target.value)})]}),(0,v.jsxs)(`div`,{className:`ed-foot`,children:[(0,v.jsxs)(`span`,{className:`hint`,children:[(0,v.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,v.jsx)(`kbd`,{children:`Enter`}),` 保存`]}),(0,v.jsxs)(`span`,{className:`ed-acts`,children:[(0,v.jsx)(`button`,{className:`btn ghost`,onClick:i,disabled:g,children:`取消`}),(0,v.jsx)(`button`,{className:`btn`,onClick:N,disabled:g||!!x,children:g?`保存中…`:`保存`})]})]})]})}function S({onClose:e}){let{boot:n,refreshBoot:r}=m(),c=s(),l=t(),{dialog:u,node:d}=i(),[f,p]=(0,_.useState)([]),[g,y]=(0,_.useState)(``),[b,x]=(0,_.useState)({name:``,description:``}),[S,C]=(0,_.useState)(null),w=(0,_.useCallback)(async()=>{try{let e=await a(`/api/groups`);p(e.groups||[]),y(``)}catch(e){y(e.message||String(e))}},[]);(0,_.useEffect)(()=>{w()},[w]);let T=n?.groupId??0,E=e=>l(async()=>{let t=await a(`/api/group`,{method:`POST`,body:{locator:e}});c(t.id===0?`已切回默认组`:`已切换到 ${t.name}`),await r(),await w()}),D=()=>l(async()=>{let e=b.name.trim();if(!e){c(`请填名称`);return}let t=await a(`/api/groups`,{method:`POST`,body:{name:e,description:b.description.trim()}});x({name:``,description:``}),c(`已新建工作空间 ${t.name}(id=${t.id})`),await r(),await w()}),O=e=>l(async()=>{let t=await u({title:`重命名「${e.name}」`,input:!0,value:e.name});t!==null&&t.trim()&&(await a(`/api/groups/${e.id}`,{method:`PATCH`,body:{name:t.trim()}}),c(`已更新名称`),await r(),await w())}),k=e=>l(async()=>{await u({message:`解散工作空间「${e.name}」(id=${e.id})?\n\n后端要求组内已无 KV 数据,否则会拒绝。此操作不可撤销。`,danger:!0})&&(await a(`/api/groups/${e.id}`,{method:`DELETE`}),c(`已解散 ${e.name}`),await r(),await w())}),A=e=>l(async()=>{let t=await a(`/api/groups/${e.id}/members`);C({group:t.group,list:t.members||[]})});return n?.loggedIn?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(o,{title:`工作空间`,onClose:e,children:[(0,v.jsx)(`div`,{className:`muted`,style:{marginBottom:8},children:`清单按工作空间隔离读写。切换只改本机配置,不动服务端数据。`}),g?(0,v.jsx)(`div`,{className:`row muted`,children:g}):null,(0,v.jsxs)(`div`,{className:`list`,children:[(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(`span`,{className:`name`,children:`默认组`}),(0,v.jsx)(`span`,{className:`desc`,children:`不传 groupId,由后端回落`}),(0,v.jsx)(`span`,{className:`acts`,children:T===0?(0,v.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,v.jsx)(`button`,{className:`btn small`,onClick:()=>E(`default`),children:`切到这里`})})]}),f.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(h,{className:`name`,text:e.name,title:`点击复制名称`,children:e.name}),(0,v.jsx)(`span`,{className:`tag`,children:e.myRole||`member`}),e.description?(0,v.jsx)(`span`,{className:`desc`,children:e.description}):null,(0,v.jsxs)(`span`,{className:`muted mono`,children:[`id=`,e.id]}),(0,v.jsxs)(`span`,{className:`muted`,children:[e.memberCount,` 人`]}),(0,v.jsxs)(`span`,{className:`acts`,children:[e.id===T?(0,v.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,v.jsx)(`button`,{className:`btn small`,onClick:()=>E(String(e.id)),children:`切到这里`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>A(e),children:`成员`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>O(e),children:`改名`}),(0,v.jsx)(`button`,{className:`btn small ghost danger`,onClick:()=>k(e),children:`解散`})]})]},e.id)),!g&&!f.length?(0,v.jsx)(`div`,{className:`row muted`,children:`(没有其他工作空间)`}):null]}),(0,v.jsxs)(`div`,{className:`toolbar`,style:{marginTop:10},children:[(0,v.jsx)(`input`,{placeholder:`新工作空间名称`,size:`16`,value:b.name,onChange:e=>x({...b,name:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&D()}}),(0,v.jsx)(`input`,{placeholder:`描述(可选)`,size:`20`,value:b.description,onChange:e=>x({...b,description:e.target.value})}),(0,v.jsx)(`button`,{className:`btn`,onClick:D,children:`新建`}),(0,v.jsx)(`button`,{className:`btn ghost`,onClick:()=>l(w),children:`刷新`})]})]}),S?(0,v.jsx)(o,{title:`成员 · ${S.group.name}`,onClose:()=>C(null),children:(0,v.jsx)(`div`,{className:`list`,children:S.list.length?S.list.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(h,{className:`name`,text:e.email,title:`点击复制邮箱`,children:e.email}),(0,v.jsx)(`span`,{className:`tag`,children:e.role||`member`}),(0,v.jsx)(`span`,{className:`muted`,children:e.nickname})]},e.userId)):(0,v.jsx)(`div`,{className:`row muted`,children:`(没有成员)`})})}):null,d]}):(0,v.jsx)(o,{title:`工作空间`,onClose:e,children:(0,v.jsx)(`div`,{className:`muted`,children:`工作空间需要登录后才能列出。`})})}var C=[[`open`,`待办`],[`done`,`已完成`],[`freeze`,`冻结`]],w=e=>e?String(e).slice(0,16).replace(`T`,` `):``,T=15,E=(e,t)=>`${e}:${t.id}:${t.text}`;function D({bucket:t,task:n,dupCount:r,onAct:i}){let a=t===`done`,o=t===`freeze`,s=a?n.doneAt:o?n.frozenAt:n.createdAt;return(0,v.jsxs)(`div`,{className:`row cloud-row`,children:[(0,v.jsxs)(`div`,{className:`row-main`,children:[(0,v.jsxs)(`span`,{className:`tid`,children:[`#`,n.id]}),(0,v.jsx)(h,{className:`topic`,text:n.topic,title:`点击复制主题`,children:n.topic}),(0,v.jsx)(`span`,{className:`text`,title:n.text,children:(0,v.jsx)(b,{text:n.text,compact:!0})}),r>1?(0,v.jsxs)(`span`,{className:`tag`,title:`同内容有 ${r} 条,操作时需要消歧`,children:[`同内容×`,r]}):null,(0,v.jsx)(`span`,{className:`muted time`,children:w(s)}),(0,v.jsxs)(`span`,{className:`acts`,children:[t===`open`?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`done`,n),children:`完成`}):null,o?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`unfreeze`,n),children:`解冻`}):null,(0,v.jsx)(e,{items:[t===`open`&&{label:`冻结`,onPick:()=>i(`freeze`,n)},{label:`编辑`,onPick:()=>i(`edit`,n,t)},{label:`删除`,danger:!0,onPick:()=>i(`remove`,n,t)}]})]})]}),n.note?(0,v.jsx)(`div`,{className:`note`,children:n.note}):null]})}function O(){let{boot:e,ui:n,patchUi:r,refreshBoot:c}=m(),d=s(),f=t(),{dialog:y,node:b}=i(),[O,k]=(0,_.useState)(null),[A,j]=(0,_.useState)(``),[M,N]=(0,_.useState)(!1),[P,F]=(0,_.useState)({topic:``,text:``}),[I,L]=(0,_.useState)(null),[R,z]=(0,_.useState)(!1),[B,ee]=(0,_.useState)({}),[V,H]=(0,_.useState)(null),[U,W]=(0,_.useState)(null),G=e?.groupId??0,te=(e?.groups||[]).find(e=>e.id===G)?.name||(G?`#${G}`:`默认组`),[K,q]=(0,_.useState)({email:e?.email||``,password:``,busy:!1,open:!1}),J=()=>f(async()=>{if(!K.email.trim()){d(`请填邮箱`);return}if(!K.password){d(`请填密码`);return}q(e=>({...e,busy:!0}));try{let e=await a(`/api/auth/login`,{method:`POST`,body:{email:K.email.trim(),password:K.password}});q(e=>({...e,password:``})),d(`已登录: ${e.email}`),await c()}finally{q(e=>({...e,busy:!1}))}}),ne=()=>f(async()=>{await a(`/api/auth/logout`,{method:`POST`}),d(`已登出`),await c()}),Y=(0,_.useCallback)(async()=>{if(e?.loggedIn)try{k(await a(`/api/todo`)),j(``)}catch(e){j(String(e.message||e))}},[e?.loggedIn]);(0,_.useEffect)(()=>{Y()},[Y,G]),(0,_.useEffect)(()=>{a(`/api/setting`).then(W).catch(()=>{})},[]);let X=!!U?.autoSyncAttachments,re=()=>f(async()=>{let e=!X,t=await a(`/api/setting`,{method:`POST`,body:{autoSyncAttachments:e}});W(t),d(e?`已开启:读任务时自动下载附件到本地`:`已关闭自动下载附件`)}),Z=(0,_.useCallback)(async()=>{N(!0);try{await Y()}finally{N(!1)}},[Y]),ie=(0,_.useMemo)(()=>{let e=new Map;if(!O)return e;for(let[t]of C)for(let n of O[t]||[])e.set(n.text,(e.get(n.text)||0)+1);return e},[O]),Q=(0,_.useMemo)(()=>{if(!O)return null;let e=n.topic,t=t=>t?e?t.filter(t=>t.topic===e):t:null;return{open:t(O.open),done:t(O.done),freeze:t(O.freeze)}},[O,n.topic]);if(!e?.loggedIn)return(0,v.jsxs)(`div`,{className:`cloud-page`,children:[(0,v.jsx)(g,{}),(0,v.jsxs)(`div`,{className:`card`,style:{padding:16,maxWidth:640},children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:`登录云端`}),(0,v.jsx)(`span`,{className:`tag bad`,children:`未登录`})]}),(0,v.jsxs)(`div`,{className:`row-inline`,style:{padding:12},children:[(0,v.jsx)(`input`,{placeholder:`邮箱`,size:`24`,spellCheck:`false`,value:K.email,onChange:e=>q(t=>({...t,email:e.target.value}))}),(0,v.jsx)(`input`,{placeholder:`密码`,type:`password`,size:`18`,value:K.password,onChange:e=>q(t=>({...t,password:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&J()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:J,disabled:K.busy,children:K.busy?`登录中…`:`登录`})]}),(0,v.jsxs)(`div`,{className:`muted`,style:{padding:`0 12px 12px`,fontSize:12},children:[`密码只用于本次请求,不写入本机配置;配置里只保存 token。 也可以用 CLI:`,(0,v.jsx)(`code`,{children:`nx-kv auth login <email>`}),`。`]})]})]});let ae=async(e,t)=>{let n=[];for(let[t]of C)for(let r of O[t]||[])r.text===e.text&&n.push({bucket:t,task:r});if(n.length<=1)return{bucket:t,task:e,pick:void 0};let r=n.findIndex(n=>n.bucket===t&&n.task.createdAt===e.createdAt),i=await y({title:`「${e.text.slice(0,30)}」有 ${n.length} 条,选哪一条?`,message:n.map((e,t)=>`[${t}] ${e.bucket} ${w(e.task.createdAt)} #${e.task.id}`).join(`
|
|
2
2
|
`),input:!0,placeholder:`输入 0..${n.length-1}`,value:String(r>=0?r:0)});if(i===null)return null;let a=Number(i);return!Number.isInteger(a)||!n[a]?(d(`请输入 0..${n.length-1}`),null):{...n[a],pick:a}},oe=(e,t,n)=>f(async()=>{let r=e===`remove`||e===`edit`?await ae(t,n):{bucket:n,task:t,pick:void 0};if(!r)return;let i={group:G,ref:r.task.text,pick:r.pick};if(e===`done`){let e=await y({title:`完成结果`,message:`完成「${t.text.slice(0,40)}」`,input:!0,placeholder:`可选:写一句完成结果`});if(e===null)return;await a(`/api/todo/done`,{method:`POST`,body:{...i,result:e||void 0}}),d(`已完成`)}else if(e===`freeze`)await a(`/api/todo/freeze`,{method:`POST`,body:i}),d(`已冻结`);else if(e===`unfreeze`)await a(`/api/todo/unfreeze`,{method:`POST`,body:i}),d(`已解冻`);else if(e===`remove`){if(!await y({message:`删除「${t.text.slice(0,40)}」?`,danger:!0}))return;await a(`/api/todo/item`,{method:`DELETE`,body:i}),d(`已删除`)}else if(e===`edit`){H({task:r.task,pick:r.pick});return}await Z(),await c()}),se=()=>f(async()=>{let e=await y({title:`归档已完成的旧记录`,message:`把「完成时间早于该日期」的记录移到冷 key(默认 30 天前)。留空用默认值。`,input:!0,placeholder:`YYYY-MM-DD,留空 = 30 天前`});if(e===null)return;let t=await a(`/api/todo/archive`,{method:`POST`,body:{before:e.trim()||void 0,group:G}});d(t.moved?`已归档 ${t.moved} 条 → ${t.coldKey}`:`没有需要归档的记录`),await Z()}),ce=async e=>{let t=p(e);if(t.length){e.preventDefault();try{let e=await l(t,{group:G}),n=u(e);F(e=>({...e,text:[e.text,n].filter(Boolean).join(` `)})),d(e.length===1?`已上传 ${e[0].name} 并附到内容里`:`已上传 ${e.length} 个附件并附到内容里`)}catch(e){d(String(e&&e.message||e))}}},$=()=>f(async()=>{let e=P.topic.trim(),t=P.text.trim();if(!e){d(`请填主题`);return}if(!t){d(`请填内容`);return}let n=await a(`/api/todo`,{method:`POST`,body:{topic:e,text:t,group:G}});F({topic:e,text:``}),d(`已加入待办${n.topicAdded?`(新主题 ${e})`:``}`),await Z()}),le=(e,t)=>B[e]?t:t.slice(0,T),ue=O?.topics||[];return(0,v.jsxs)(`div`,{className:`cloud-page`,children:[(0,v.jsxs)(`div`,{className:`cloud-toolbar`,children:[(0,v.jsxs)(`button`,{className:`pill on rp-ws-trigger`,title:`切换工作空间 / 管理(清单按工作空间隔离)`,onClick:()=>z(!0),children:[te,` `,(0,v.jsx)(`span`,{className:`rp-caret`,children:`▾`})]}),(0,v.jsx)(`span`,{className:`sep`}),(0,v.jsx)(`label`,{children:`主题`}),(0,v.jsxs)(`select`,{value:n.topic,onChange:e=>r({topic:e.target.value}),children:[(0,v.jsx)(`option`,{value:``,children:`全部`}),ue.map(e=>(0,v.jsx)(`option`,{value:e,children:e},e))]}),(0,v.jsx)(`span`,{className:`grow`}),(0,v.jsxs)(`label`,{className:`toggle`+(X?` on`:``),title:`开启后,读取任务时会把正文引用的附件下载到本地,并把本地绝对路径一并返回给 agent。
|
|
3
3
|
当前目录:${U?U.resolvedDir:`(读取中…)`}`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:X,onChange:re}),(0,v.jsx)(`span`,{className:`dot`}),`附件自动下载`]}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:Z,disabled:M,children:M?`刷新中…`:`刷新`}),(0,v.jsx)(`button`,{className:`pill`+(K.open?` on`:``),title:`账号 ${e.email||``}(点击展开登录态 / 登出)`,onClick:()=>q(e=>({...e,open:!e.open})),children:e.email||`已登录`})]}),K.open?(0,v.jsxs)(`div`,{className:`card`,style:{padding:16,marginBottom:12},children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:`登录态`}),(0,v.jsx)(`button`,{className:`btn small ghost danger`,onClick:ne,children:`登出`})]}),(0,v.jsxs)(`div`,{className:`settings`,children:[(0,v.jsx)(`dt`,{children:`账号`}),(0,v.jsx)(`dd`,{children:e?.email}),(0,v.jsx)(`dt`,{children:`userId`}),(0,v.jsx)(`dd`,{children:e?.userId||`-`}),(0,v.jsx)(`dt`,{children:`后端`}),(0,v.jsx)(`dd`,{className:`mono`,children:(0,v.jsx)(h,{text:e?.baseUrl,children:e?.baseUrl})}),(0,v.jsx)(`dt`,{children:`本机配置`}),(0,v.jsx)(`dd`,{className:`mono`,children:(0,v.jsx)(h,{text:e?.configPath,children:e?.configPath})})]}),(0,v.jsxs)(`div`,{className:`row-inline`,style:{padding:`10px 0 0`},children:[(0,v.jsx)(`input`,{placeholder:`切换账号:邮箱`,size:`24`,spellCheck:`false`,value:K.email,onChange:e=>q(t=>({...t,email:e.target.value}))}),(0,v.jsx)(`input`,{placeholder:`密码`,type:`password`,size:`18`,value:K.password,onChange:e=>q(t=>({...t,password:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&J()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:J,disabled:K.busy,children:K.busy?`登录中…`:`登录`})]})]}):null,(0,v.jsxs)(`div`,{className:`cloud-compose`,children:[(0,v.jsx)(`input`,{className:`cloud-compose-topic`,placeholder:`主题`,"aria-label":`新任务主题`,value:P.topic,onChange:e=>F({...P,topic:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&$()}}),(0,v.jsx)(`input`,{className:`cloud-compose-text`,placeholder:`要做什么…(可 Ctrl+V 粘贴图片)`,"aria-label":`新任务内容`,value:P.text,title:`可以直接 Ctrl+V 粘贴截图:会自动上传为附件并附在内容里`,onChange:e=>F({...P,text:e.target.value}),onPaste:ce,onKeyDown:e=>{e.key===`Enter`&&$()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:$,children:`加入待办`})]}),A?(0,v.jsxs)(`div`,{className:`cloud-error`,children:[(0,v.jsxs)(`span`,{children:[`清单读取失败:`,A]}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:Z,children:`重试`})]}):null,!O&&!A?(0,v.jsx)(`div`,{className:`cloud-loading muted`,children:`读取中…`}):null,O?(0,v.jsx)(`div`,{className:`cols`,children:C.map(([e,t])=>(0,v.jsxs)(`div`,{className:`col col-`+e,children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:t}),(0,v.jsx)(`span`,{className:`cnt`,children:(Q?.[e]||[]).length}),e===`done`&&(Q?.done||[]).length?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`span`,{className:`grow`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:se,title:`把较旧的完成记录移到冷 key`,children:`归档旧记录`})]}):null]}),(0,v.jsxs)(`div`,{className:`card list`,children:[(Q?.[e]||[]).length?le(e,Q[e]).map(t=>(0,v.jsx)(D,{bucket:e,task:t,dupCount:ie.get(t.text)||1,onAct:oe},E(e,t))):(0,v.jsx)(`div`,{className:`cloud-empty`,children:e===`open`?(0,v.jsxs)(v.Fragment,{children:[`还没有待办`,(0,v.jsx)(`br`,{}),`在上方投递条输入,`,(0,v.jsx)(`kbd`,{children:`Enter`}),` 直达`]}):e===`done`?`还没有完成记录`:`没有冻结的任务`}),(Q?.[e]||[]).length>T?(0,v.jsx)(`div`,{className:`row muted`,style:{cursor:`pointer`,justifyContent:`center`},onClick:()=>ee(t=>({...t,[e]:!t[e]})),children:B[e]?`收起`:`还有 ${Q[e].length-T} 条,点击展开`}):null]})]},e))}):null,R?(0,v.jsx)(S,{onClose:()=>z(!1)}):null,V?(0,v.jsx)(o,{title:`编辑任务`,onClose:()=>H(null),children:(0,v.jsx)(x,{task:V.task,pick:V.pick,group:G,onCancel:()=>H(null),onSaved:async()=>{H(null),await Z(),await c()}})}):null,I?(0,v.jsx)(o,{title:I.title,size:`lg`,onClose:()=>L(null),children:I.node}):null,b]})}export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,h as t,p as n,u as r,y as i}from"./task-status-BnymQMTw.js";import{t as a}from"./workspace-C_5X2gIr.js";import{n as o}from"./app-context-D7HAx67n.js";import{a as s,i as c,n as l,p as u,r as d,t as f}from"./md-history-
|
|
1
|
+
import{g as e,h as t,p as n,u as r,y as i}from"./task-status-BnymQMTw.js";import{t as a}from"./workspace-C_5X2gIr.js";import{n as o}from"./app-context-D7HAx67n.js";import{a as s,i as c,n as l,p as u,r as d,t as f}from"./md-history-CBqcR086.js";import"./index-ChlZPTea.js";import{i as p,o as m,r as ee,t as h}from"./composer-launch-Bf4rXhLs.js";var g=i(e(),1),_=t(),v=96;function y({token:e,mode:t=`comment`,quote:i=``,prevQuote:y=``,taskLabel:b=``,taskTitle:x=``,src:S=null}){let C=o()||{},w=n(),[T,E]=(0,g.useState)(``),[D,O]=(0,g.useState)([]),[k,A]=(0,g.useState)(!1),j=(0,g.useRef)(null),M=t===`feedback`,N=(0,g.useRef)(new Map),P=`compose-`+e,F=()=>{f(N.current,P),ee(C.model,e)},I=(e,t=`op`)=>{l(N.current,P,{title:``,body:T},t),E(e)},L=()=>{let e=c(N.current,P,{title:``,body:T});e&&E(e.body)},R=()=>{let e=d(N.current,P,{title:``,body:T});e&&E(e.body)},z=async()=>{let t=String(T||``).trim();if(!t&&!D.length){w(M?`写一下要改的地方`:`写一下要提的问题`);return}let n=h(e);if(!n||!n.onSubmit){w(`提交入口已失效(来源页面已关闭)`);return}A(!0);try{await n.onSubmit({text:t,attachments:D,inserts:``}),F()}catch(e){w(String(e.message||e))}finally{A(!1)}},B=async e=>{if(!e||!e.length)return;let{items:t,imageInserts:n,fileInserts:r}=await p(e),i=[...n,...r].join(``);i&&E(e=>u(e,i,{}).body),t.length&&O(e=>[...e,...t])},V=(0,g.useRef)(null),[H,U]=(0,g.useState)(()=>localStorage.getItem(`nxkv.cmpDockOpen`)!==`0`),[W,G]=(0,g.useState)(()=>{let e=Number(localStorage.getItem(`nxkv.cmpDockH`));return Number.isFinite(e)&&e>=v?e:176}),K=(0,g.useRef)(W);K.current=W;let[q,J]=(0,g.useState)(!1),Y=(0,g.useRef)(176);(0,g.useEffect)(()=>{localStorage.setItem(`nxkv.cmpDockOpen`,H?`1`:`0`)},[H]);let X=()=>{if(q){G(Y.current),J(!1);return}Y.current=W;let e=document.querySelector(`.cmp`)?.clientHeight||window.innerHeight;G(Math.max(v,Math.round(e*.62))),J(!0)},Z=e=>{if(!H)return;e.preventDefault(),J(!1);let t=e.clientY,n=K.current,r=e=>Math.max(v,Math.min(Math.round(e),Math.round((document.querySelector(`.cmp`)?.clientHeight||window.innerHeight)*.62))),i=e=>{K.current=r(n-(e.clientY-t)),G(K.current)},a=()=>{window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(`nxkv.cmpDockH`,String(K.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)},Q=()=>{let e=C.model;e&&S&&S.task&&a(e,{component:`page`,name:S.name||`原文`,config:{dirKey:S.dirKey,task:String(S.task)}})},$=!!(S&&S.task);return(0,_.jsxs)(`div`,{className:`cmp`,children:[(0,_.jsxs)(`div`,{className:`cmp-head`,children:[(0,_.jsx)(`span`,{className:`cmp-tag`+(M?` is-fb`:``),children:M?`反馈`:`评论`}),(0,_.jsx)(`div`,{className:`cmp-ctx`,children:M?(0,_.jsxs)(`span`,{className:`cmp-ctx-line`,title:x||``,children:[`反馈 `,b||``,` 的任务`,x?` · ${x}`:``]}):(0,_.jsx)(`span`,{className:`cmp-ctx-line`,children:`对本任务提出问题`})}),(0,_.jsx)(`span`,{className:`grow`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:F,disabled:k,children:`关闭`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:z,disabled:k,children:M?`提交反馈`:`提交评论`})]}),M?(0,_.jsxs)(`div`,{className:`cmp-quote-wrap`,children:[(0,_.jsxs)(`div`,{className:`cmp-quote-cap`,children:[`之前的引用`,$&&(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote-cmp`,onClick:Q,title:`在右侧并排显示原文,方便对照`,children:`对照原文 ↗`})]}),$?(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote`,onClick:Q,title:`点击在右侧并排显示原文,方便对照`,children:y||`(这条任务还没有可引用的上轮总结)`}):(0,_.jsx)(`div`,{className:`cmp-quote`,children:y||`(这条任务还没有可引用的上轮总结)`})]}):i?(0,_.jsxs)(`div`,{className:`cmp-quote-wrap`,children:[(0,_.jsxs)(`div`,{className:`cmp-quote-cap`,children:[`引用`,$&&(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote-cmp`,onClick:Q,title:`在右侧并排显示原文,方便对照`,children:`对照原文 ↗`})]}),$?(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote`,onClick:Q,title:`点击在右侧并排显示原文,方便对照`,children:i}):(0,_.jsx)(`div`,{className:`cmp-quote`,children:i})]}):null,(0,_.jsx)(`div`,{className:`cmp-body`,children:(0,_.jsx)(s,{mode:`split`,title:``,body:T,onTitle:()=>{},onBody:I,attachments:D,docKey:`compose-`+e,editorApiRef:j,onFiles:B,onSave:z,onUndo:L,onRedo:R,hideTitle:!0})}),H&&(0,_.jsxs)(`div`,{className:`mdw-dock`,style:{height:`${W}px`},children:[(0,_.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:Z,onDoubleClick:X}),(0,_.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,_.jsx)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:(0,_.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":`true`,className:`mdw-dock-tab is-on`,onClick:()=>U(!0),children:[`附件`,D.length?(0,_.jsx)(`span`,{className:`mdw-dock-tab-num`,children:D.length}):null]})}),(0,_.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,title:`添加附件`,"aria-label":`添加附件`,onClick:()=>V.current?.click(),children:(0,_.jsx)(r,{name:`plus`})}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:X,title:q?`还原面板高度`:`最大化面板高度`,"aria-label":q?`还原面板高度`:`最大化面板高度`,children:(0,_.jsx)(r,{name:q?`collapse`:`expand`})}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>U(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,_.jsx)(r,{name:`x`})})]})]}),(0,_.jsx)(`div`,{className:`mdw-dock-body`,children:D.length?(0,_.jsx)(m,{attachments:D,onRemove:e=>O(t=>t.filter(t=>t.id!==e))}):(0,_.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有附件——粘贴 / 拖图片进正文即附件,或点右上「+」添加文件。`})})]}),(0,_.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${H?` is-on`:``}`,onClick:()=>U(e=>!e),title:`附件(点击展开/收起信息面板)`,children:[(0,_.jsx)(r,{name:`list`}),(0,_.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`}),D.length?(0,_.jsx)(`span`,{className:`mdw-sbar-num`,children:D.length}):null]}),(0,_.jsx)(`span`,{className:`mdw-sbar-grow`}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${H?` is-open`:``}`,onClick:()=>U(e=>!e),title:H?`收起信息面板`:`展开信息面板`,"aria-expanded":H,"aria-label":H?`收起信息面板`:`展开信息面板`,children:(0,_.jsx)(r,{name:`chevron`})})]}),(0,_.jsx)(`input`,{ref:V,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&B(t)}})]})}export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,o as t,u as n}from"./task-status-BnymQMTw.js";import{a as r}from"./md-parse-awNLHAzO.js";import{n as i}from"./model-DzdWfp14.js";import{t as a}from"./status-tag-
|
|
1
|
+
import{h as e,o as t,u as n}from"./task-status-BnymQMTw.js";import{a as r}from"./md-parse-awNLHAzO.js";import{n as i}from"./model-DzdWfp14.js";import{t as a}from"./status-tag-BK-45ld2.js";var o=e();function s({icon:e=`list`,title:t,pendingCount:r=0,headerExtra:i=null,children:a=null,emptyText:s=``}){return(0,o.jsxs)(`div`,{className:`rp-tasks`,children:[(0,o.jsxs)(`div`,{className:`rp-tasks-h`,children:[(0,o.jsx)(n,{name:e,size:13}),` `,t,r>0&&(0,o.jsxs)(`span`,{className:`rp-chip-count`,children:[`待领取 `,r]}),i]}),a,!a&&s?(0,o.jsx)(`div`,{className:`rp-proj-none muted`,children:s}):null]})}function c({name:e,counts:t=[],icon:r=`folder`,actions:i=null,intro:a=null,batch:s=null,list:c=null,footer:l=null,extra:u=null}){return(0,o.jsxs)(`div`,{className:`rp-page`,children:[(0,o.jsxs)(`div`,{className:`rp-group-head`,children:[(0,o.jsxs)(`h2`,{children:[(0,o.jsx)(n,{name:r,size:15}),` `,e,t.map((e,t)=>{let n=typeof e==`string`?e:e&&e.text||``;return n?(0,o.jsx)(`span`,{className:`rp-chip-count`,children:n},t):null})]}),i?(0,o.jsx)(`div`,{className:`rp-group-acts`,children:i}):null]}),a,s,c,l,u]})}function l(e){let t=String(e||``).trim();if(!t)return`—`;let n=t.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/);return n?`${n[1].slice(5)} ${n[2]}`:t.slice(0,16)}function u({t:e,projectTag:t=``,projectTitle:r=``,selectable:s=!1,picked:c=!1,onTogglePick:u,draggable:d=!1,dragHandlers:f=null,dragVisual:p,onOpen:m,showTimes:h=!1,downs:g=[],history:_=!1,ops:v=null}){let y=`rp-proj-row`+(p?.dragging?` dragging`:``)+(p?.drop?` drop-`+p.drop:``),b=e.status===`pending`&&e.ready===!1;return(0,o.jsxs)(`div`,{className:y,...f?{onDragOver:f.onDragOver,onDragLeave:f.onDragLeave,onDrop:f.onDrop}:{},children:[d?(0,o.jsx)(`span`,{className:`rp-drag-handle`,draggable:!0,title:`拖动调整队列内顺序`,"aria-label":`拖动排序`,onDragStart:f?.onDragStart,onDragEnd:f?.onDragEnd,onClick:e=>e.stopPropagation(),children:(0,o.jsx)(n,{name:`grip`,size:12})}):(0,o.jsx)(`span`,{className:`rp-drag-handle off`,"aria-hidden":`true`}),s?(0,o.jsx)(`span`,{className:`rp-proj-pick`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,o.jsx)(`input`,{type:`checkbox`,checked:c,onChange:()=>u?.(e.id),"aria-label":`选择任务 #${e.id}`})}):null,(0,o.jsxs)(`div`,{className:`rp-proj-task`+(_?` done`:``),role:`button`,tabIndex:0,title:`打开这条任务`,onClick:()=>m?.(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),m?.(e))},children:[(0,o.jsxs)(`span`,{className:`mono`,children:[`#`,e.id]}),t?(0,o.jsx)(`span`,{className:`rp-ptag`,title:`归属项目:${r||t}`,children:t}):null,(0,o.jsx)(`span`,{className:`rp-proj-task-tx`,children:i(e)}),e.timegoal&&(0,o.jsxs)(`span`,{className:`rp-proj-goal`,title:`时间目标 ${e.timegoal.duration}:领取即计时,未到点不许标完成`,children:[(0,o.jsx)(n,{name:`clock`,size:11}),` `,e.timegoal.duration]}),e.blocksFollowing&&(0,o.jsxs)(`span`,{className:`rp-tgate`,title:g.length?`闸门:未完成前挡住 ${g.length} 个后续任务(#${g.join(`, #`)})`:`闸门:未完成前挡住队列里排在后面的待领取任务`,children:[`闸门`,g.length?`×${g.length}`:``]}),b&&(0,o.jsx)(`span`,{className:`rp-tlock`,title:e.blockBy?.length?`等待依赖完成:#${e.blockBy.join(`, #`)}`:`被前方闸门挡住`,children:`锁定`}),h&&(0,o.jsxs)(`span`,{className:`rp-proj-times mono`,title:`创建 ${e.createdAt||`—`}${e.consumedAt?` · 领取 ${e.consumedAt}`:``}`,children:[l(e.createdAt),e.consumedAt?` → ${l(e.consumedAt)}`:``]}),(0,o.jsx)(a,{t:e}),v?(0,o.jsx)(`span`,{className:`rp-proj-ops`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:v}):null]})]})}function d(e){let t=String(e||``).trim();if(!t)return`—`;let n=t.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/);return n?`${n[1].slice(5)} ${n[2]}`:t.slice(0,16)}function f({tasks:e=[],onClose:n,onRestore:i,onPurge:a}){return(0,o.jsx)(t,{title:`已删除任务(${e.length})`,onClose:n,children:e.length===0?(0,o.jsx)(`div`,{className:`mdw-del-empty`,children:`这个目录没有已删除的任务。`}):(0,o.jsx)(`table`,{className:`mdw-del-list`,children:(0,o.jsx)(`tbody`,{children:e.map(e=>(0,o.jsxs)(`tr`,{children:[(0,o.jsxs)(`td`,{className:`mdw-del-id mono`,children:[`#`,e.id]}),(0,o.jsx)(`td`,{className:`mdw-del-title`,title:r(e.text),children:r(e.text)||`—`}),(0,o.jsx)(`td`,{className:`mdw-del-time mono`,children:d(e.deletedAt)}),(0,o.jsxs)(`td`,{className:`mdw-del-ops`,children:[(0,o.jsx)(`button`,{type:`button`,className:`btn sm ghost`,title:`恢复到队列原位置`,onClick:()=>i?.(e),children:`恢复`}),(0,o.jsx)(`button`,{type:`button`,className:`btn sm danger`,title:`彻底删除(不可恢复)`,onClick:()=>a?.(e),children:`彻底删除`})]})]},e.id))})})})}export{s as i,u as n,c as r,f as t};
|