nx-kv 0.36.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/package.json +1 -1
- package/src/web/frontend/components/md/attach-modal.jsx +3 -2
- package/src/web/frontend/components/md/composer-panel.jsx +164 -1
- package/src/web/frontend/page/dir/task.jsx +3 -2
- package/src/web/public/assets/{Introduction-EDM3eqXe.js → Introduction-ChO8BjCo.js} +1 -1
- package/src/web/public/assets/{bar-P_ky_qA9.js → bar-DIcUTKGF.js} +1 -1
- package/src/web/public/assets/{cloud-Bl7EJoQ_.js → cloud-B_Zurubz.js} +1 -1
- package/src/web/public/assets/composer-launch-DFD4_RlG.js +1 -0
- package/src/web/public/assets/composer-panel-C_TqQ6UQ.js +1 -0
- package/src/web/public/assets/{dag-NSMkkWrt.js → dag-cynQzBs4.js} +1 -1
- package/src/web/public/assets/{dir-ClkYDLql.js → dir-BZ_B_vda.js} +1 -1
- package/src/web/public/assets/{group-DqBGGAEA.js → group-plgfiTpl.js} +1 -1
- package/src/web/public/assets/{index-CLsU9Lad.js → index-BmANFdAR.js} +2 -2
- package/src/web/public/assets/{md-panes-DMs3KANu.js → md-panes-sRhT7DNc.js} +2 -2
- package/src/web/public/assets/{overview-CFGcpG_m.js → overview-BMItQoK-.js} +1 -1
- package/src/web/public/assets/{progress-B0fipz7a.js → progress-BJaEAKUn.js} +1 -1
- package/src/web/public/assets/{refs-DLThlN46.js → refs-_aYVi9zo.js} +1 -1
- package/src/web/public/assets/{repos-BygXrPSp.js → repos-_KRfq-H_.js} +1 -1
- package/src/web/public/assets/{route-crumb-Cyesq6KK.js → route-crumb-DHYbpsO8.js} +1 -1
- package/src/web/public/assets/{settings-KHM4F3Sy.js → settings-3UzVUmIA.js} +1 -1
- package/src/web/public/assets/{status-tag-Bts7p2cp.js → status-tag-CdoKlRNG.js} +1 -1
- package/src/web/public/assets/{task-BoJGRYpA.js → task-DoX0agEw.js} +7 -7
- package/src/web/public/assets/{templates-CdPNcDxd.js → templates-MVbMU84b.js} +1 -1
- package/src/web/public/assets/{tool-bar-Bh3XH8MU.js → tool-bar-BwMNTrR1.js} +1 -1
- package/src/web/public/index.html +1 -1
- package/src/web/public/assets/composer-launch-DOB0Hm0B.js +0 -1
- package/src/web/public/assets/composer-panel-DCV7JGNt.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
本文件记录对外可见的变更。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)。
|
|
4
4
|
|
|
5
|
+
## [0.37.0] - 2026-11-09 反馈/评论编辑页附件 dock
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **反馈 / 评论编辑页底部附件框(#155)**:composer 页补上与任务页同款的
|
|
10
|
+
`mdw-dock` 信息面板——「附件」tab(计数徽标 + AttachBar 列表 + 「+」添加
|
|
11
|
+
文件 + 拖高/最大化/关闭)+ 底部状态栏开关,高度与开关独立存
|
|
12
|
+
(`nxkv.cmpDock*`);附件随提交走原通道(新任务/回写正文)。
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- **隐藏文件输入的 FileList 清空 bug(随 #155 发现)**:`e.target.value = ''`
|
|
17
|
+
会清空活的 FileList(先拿引用再清 → `length` 归零,一个文件都拿不到)——
|
|
18
|
+
反馈/评论页「+」、任务页「添加附件」、附件弹窗三处改为先拷贝再清。
|
|
19
|
+
|
|
5
20
|
## [0.36.0] - 2026-11-09 仓库表操作列钉宽
|
|
6
21
|
|
|
7
22
|
### Fixed
|
package/package.json
CHANGED
|
@@ -275,9 +275,10 @@ export default function AttachModal({
|
|
|
275
275
|
multiple
|
|
276
276
|
hidden
|
|
277
277
|
onChange={(e) => {
|
|
278
|
-
|
|
278
|
+
// ⚠️ 先拷贝再清 value:FileList 是活引用,`value = ''` 会把它清空
|
|
279
|
+
const files = Array.from(e.target.files || []);
|
|
279
280
|
e.target.value = '';
|
|
280
|
-
addFiles(
|
|
281
|
+
addFiles(files);
|
|
281
282
|
}}
|
|
282
283
|
/>
|
|
283
284
|
</div>
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
// 底部:提交(评论 = 回写本任务;反馈 = 新开一条任务)。
|
|
6
6
|
//
|
|
7
7
|
// 提交逻辑在任务页那边(带会话状态),这里按 token 取回回调——见 composer-launch.js。
|
|
8
|
-
import { useRef, useState } from 'react';
|
|
8
|
+
import { useEffect, useRef, useState } from 'react';
|
|
9
9
|
import { MdPanes } from './md-panes.jsx';
|
|
10
|
+
import AttachBar from './attach-bar.jsx';
|
|
11
|
+
import { Icon } from '../icons.jsx';
|
|
10
12
|
import { filesToAttachments } from './attachments.js';
|
|
11
13
|
import { insertAttachmentSnippet } from '../../modules/md/md-parse.js';
|
|
12
14
|
import { composerOf, restoreComposerSource } from './composer-launch.js';
|
|
@@ -15,6 +17,10 @@ import { useToast } from '../toast/index.jsx';
|
|
|
15
17
|
import { openBesideMain } from '../../workspace.js';
|
|
16
18
|
import '../../modules/md/style.css';
|
|
17
19
|
|
|
20
|
+
// 底部附件 dock(#155):与任务页 mdw-dock 同一套视觉;高度/开关单独存
|
|
21
|
+
// (nxkv.cmpDock*,不与任务页的 nxkv.taskDock* 串台)。
|
|
22
|
+
const DOCK_MIN = 96;
|
|
23
|
+
|
|
18
24
|
export default function ComposePanel({
|
|
19
25
|
token,
|
|
20
26
|
mode = 'comment',
|
|
@@ -69,6 +75,55 @@ export default function ComposePanel({
|
|
|
69
75
|
if (items.length) setAttachments((a) => [...a, ...items]);
|
|
70
76
|
};
|
|
71
77
|
|
|
78
|
+
// ─── 底部附件 dock(#155):任务页同款信息面板,附件收进去不再占编辑区 ───
|
|
79
|
+
const fileRef = useRef(null);
|
|
80
|
+
const [dockOpen, setDockOpen] = useState(() => localStorage.getItem('nxkv.cmpDockOpen') !== '0');
|
|
81
|
+
const [dockH, setDockH] = useState(() => {
|
|
82
|
+
const v = Number(localStorage.getItem('nxkv.cmpDockH'));
|
|
83
|
+
return Number.isFinite(v) && v >= DOCK_MIN ? v : 176;
|
|
84
|
+
});
|
|
85
|
+
const dockHRef = useRef(dockH);
|
|
86
|
+
dockHRef.current = dockH;
|
|
87
|
+
const [dockMax, setDockMax] = useState(false);
|
|
88
|
+
const dockPrevHRef = useRef(176);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
localStorage.setItem('nxkv.cmpDockOpen', dockOpen ? '1' : '0');
|
|
91
|
+
}, [dockOpen]);
|
|
92
|
+
const toggleDockMax = () => {
|
|
93
|
+
if (dockMax) {
|
|
94
|
+
setDockH(dockPrevHRef.current);
|
|
95
|
+
setDockMax(false);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
dockPrevHRef.current = dockH;
|
|
99
|
+
const hostH = document.querySelector('.cmp')?.clientHeight || window.innerHeight;
|
|
100
|
+
setDockH(Math.max(DOCK_MIN, Math.round(hostH * 0.62)));
|
|
101
|
+
setDockMax(true);
|
|
102
|
+
};
|
|
103
|
+
const onDockDragStart = (e) => {
|
|
104
|
+
if (!dockOpen) return;
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
setDockMax(false);
|
|
107
|
+
const startY = e.clientY;
|
|
108
|
+
const startH = dockHRef.current;
|
|
109
|
+
const clamp = (h) => Math.max(DOCK_MIN, Math.min(Math.round(h), Math.round((document.querySelector('.cmp')?.clientHeight || window.innerHeight) * 0.62)));
|
|
110
|
+
const move = (ev) => {
|
|
111
|
+
dockHRef.current = clamp(startH - (ev.clientY - startY));
|
|
112
|
+
setDockH(dockHRef.current);
|
|
113
|
+
};
|
|
114
|
+
const up = () => {
|
|
115
|
+
window.removeEventListener('mousemove', move);
|
|
116
|
+
window.removeEventListener('mouseup', up);
|
|
117
|
+
document.body.style.userSelect = '';
|
|
118
|
+
document.body.style.cursor = '';
|
|
119
|
+
localStorage.setItem('nxkv.cmpDockH', String(dockHRef.current));
|
|
120
|
+
};
|
|
121
|
+
document.body.style.userSelect = 'none';
|
|
122
|
+
document.body.style.cursor = 'row-resize';
|
|
123
|
+
window.addEventListener('mousemove', move);
|
|
124
|
+
window.addEventListener('mouseup', up);
|
|
125
|
+
};
|
|
126
|
+
|
|
72
127
|
// 点引用区 → 主区右侧并排打开**原文**(旁路原文面板),方便对照(#107)
|
|
73
128
|
const openOriginal = () => {
|
|
74
129
|
const m = app.model;
|
|
@@ -162,6 +217,114 @@ export default function ComposePanel({
|
|
|
162
217
|
hideTitle
|
|
163
218
|
/>
|
|
164
219
|
</div>
|
|
220
|
+
|
|
221
|
+
{/* ─── 底部附件 dock(#155):反馈/评论页与任务页同款信息面板 ─── */}
|
|
222
|
+
{dockOpen && (
|
|
223
|
+
<div className="mdw-dock" style={{ height: `${dockH}px` }}>
|
|
224
|
+
<div
|
|
225
|
+
className="mdw-dock-drag"
|
|
226
|
+
role="separator"
|
|
227
|
+
aria-orientation="horizontal"
|
|
228
|
+
title="上下拖动调整信息面板高度(双击最大化 / 还原)"
|
|
229
|
+
onMouseDown={onDockDragStart}
|
|
230
|
+
onDoubleClick={toggleDockMax}
|
|
231
|
+
/>
|
|
232
|
+
<div className="mdw-dock-head">
|
|
233
|
+
<div className="mdw-dock-tabs" role="tablist" aria-label="信息面板">
|
|
234
|
+
<button
|
|
235
|
+
type="button"
|
|
236
|
+
role="tab"
|
|
237
|
+
aria-selected="true"
|
|
238
|
+
className="mdw-dock-tab is-on"
|
|
239
|
+
onClick={() => setDockOpen(true)}
|
|
240
|
+
>
|
|
241
|
+
附件
|
|
242
|
+
{attachments.length ? <span className="mdw-dock-tab-num">{attachments.length}</span> : null}
|
|
243
|
+
</button>
|
|
244
|
+
</div>
|
|
245
|
+
<div className="mdw-dock-acts">
|
|
246
|
+
<button
|
|
247
|
+
type="button"
|
|
248
|
+
className="mdw-dock-act"
|
|
249
|
+
title="添加附件"
|
|
250
|
+
aria-label="添加附件"
|
|
251
|
+
onClick={() => fileRef.current?.click()}
|
|
252
|
+
>
|
|
253
|
+
<Icon name="plus" />
|
|
254
|
+
</button>
|
|
255
|
+
<button
|
|
256
|
+
type="button"
|
|
257
|
+
className="mdw-dock-act"
|
|
258
|
+
onClick={toggleDockMax}
|
|
259
|
+
title={dockMax ? '还原面板高度' : '最大化面板高度'}
|
|
260
|
+
aria-label={dockMax ? '还原面板高度' : '最大化面板高度'}
|
|
261
|
+
>
|
|
262
|
+
<Icon name={dockMax ? 'collapse' : 'expand'} />
|
|
263
|
+
</button>
|
|
264
|
+
<button
|
|
265
|
+
type="button"
|
|
266
|
+
className="mdw-dock-act"
|
|
267
|
+
onClick={() => setDockOpen(false)}
|
|
268
|
+
title="关闭面板(底部状态栏仍保留入口)"
|
|
269
|
+
aria-label="关闭面板"
|
|
270
|
+
>
|
|
271
|
+
<Icon name="x" />
|
|
272
|
+
</button>
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
<div className="mdw-dock-body">
|
|
276
|
+
{attachments.length ? (
|
|
277
|
+
<AttachBar
|
|
278
|
+
attachments={attachments}
|
|
279
|
+
onRemove={(aid) => setAttachments((a) => a.filter((x) => x.id !== aid))}
|
|
280
|
+
/>
|
|
281
|
+
) : (
|
|
282
|
+
<div className="mdw-dock-empty">
|
|
283
|
+
还没有附件——粘贴 / 拖图片进正文即附件,或点右上「+」添加文件。
|
|
284
|
+
</div>
|
|
285
|
+
)}
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
)}
|
|
289
|
+
|
|
290
|
+
{/* ─── 底部状态栏:附件入口 + 面板开关(dock 关了仍能从这打开) ─── */}
|
|
291
|
+
<div className="mdw-sbar">
|
|
292
|
+
<button
|
|
293
|
+
type="button"
|
|
294
|
+
className={`mdw-sbar-item${dockOpen ? ' is-on' : ''}`}
|
|
295
|
+
onClick={() => setDockOpen((v) => !v)}
|
|
296
|
+
title="附件(点击展开/收起信息面板)"
|
|
297
|
+
>
|
|
298
|
+
<Icon name="list" />
|
|
299
|
+
<span className="mdw-sbar-lab">附件</span>
|
|
300
|
+
{attachments.length ? <span className="mdw-sbar-num">{attachments.length}</span> : null}
|
|
301
|
+
</button>
|
|
302
|
+
<span className="mdw-sbar-grow" />
|
|
303
|
+
<button
|
|
304
|
+
type="button"
|
|
305
|
+
className={`mdw-sbar-chev${dockOpen ? ' is-open' : ''}`}
|
|
306
|
+
onClick={() => setDockOpen((v) => !v)}
|
|
307
|
+
title={dockOpen ? '收起信息面板' : '展开信息面板'}
|
|
308
|
+
aria-expanded={dockOpen}
|
|
309
|
+
aria-label={dockOpen ? '收起信息面板' : '展开信息面板'}
|
|
310
|
+
>
|
|
311
|
+
<Icon name="chevron" />
|
|
312
|
+
</button>
|
|
313
|
+
</div>
|
|
314
|
+
|
|
315
|
+
<input
|
|
316
|
+
ref={fileRef}
|
|
317
|
+
type="file"
|
|
318
|
+
multiple
|
|
319
|
+
hidden
|
|
320
|
+
onChange={(e) => {
|
|
321
|
+
// ⚠️ 先拷贝再清 value:`e.target.files` 是活的 FileList,`value = ''`
|
|
322
|
+
// 会把它清空(引用还在、length 归零)——先清后读就一个文件都拿不到。
|
|
323
|
+
const files = Array.from(e.target.files || []);
|
|
324
|
+
e.target.value = '';
|
|
325
|
+
if (files.length) onFiles(files);
|
|
326
|
+
}}
|
|
327
|
+
/>
|
|
165
328
|
</div>
|
|
166
329
|
);
|
|
167
330
|
}
|
|
@@ -1826,9 +1826,10 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
1826
1826
|
multiple
|
|
1827
1827
|
hidden
|
|
1828
1828
|
onChange={(e) => {
|
|
1829
|
-
|
|
1829
|
+
// ⚠️ 先拷贝再清 value:FileList 是活引用,`value = ''` 会把它清空
|
|
1830
|
+
const files = Array.from(e.target.files || []);
|
|
1830
1831
|
e.target.value = '';
|
|
1831
|
-
if (
|
|
1832
|
+
if (files.length) addFiles(files);
|
|
1832
1833
|
}}
|
|
1833
1834
|
/>
|
|
1834
1835
|
<input
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,_ as t,f as n,g as r,l as i,v as a,x as o,y as s}from"./task-status-BP6y8MVu.js";import{d as c,h as l,i as u,r as d,u as f,y as p}from"./md-parse-C2bDc3IZ.js";import{M as m,N as h,O as g,k as _}from"./index-CLsU9Lad.js";import{o as v,t as y}from"./md-panes-DMs3KANu.js";import{a as b,i as x}from"./upload-L1g-pfvZ.js";import{t as S}from"./route-crumb-Cyesq6KK.js";import{a as C,c as w,i as T,l as E,o as D,r as O,s as k,t as A,u as j}from"./tool-bar-Bh3XH8MU.js";import{i as ee,n as M,r as te,t as ne}from"./md-history-Uo6U7hYS.js";var N=e(s(),1),P=h(),F=a(),I=`doc`,L=[{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=T(),{layout:f,setLayout:p}=D(I),[m,h]=(0,N.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=>E(I,e)&&_(e.id)),y=f.filter(e=>k(I,e)&&_(e.id)),b=e=>{g[e]?.run?.(),d.setOpen(!1)},x=e=>{if(e===`more`)return(0,F.jsx)(`div`,{className:`docp-more`,ref:d.ref,children:(0,F.jsx)(`button`,{type:`button`,className:`btn ghost sm${d.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":d.open,onClick:e=>O(d,e,`right`),children:`更多`})},`more`);let t=g[e];return t?(0,F.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||w(I,e).label||e},e):null},S=L.map(e=>({...e,items:y.filter(t=>w(I,t.id).menuGroup===e.id)})).filter(e=>e.items.length),j=y.filter(e=>!w(I,e.id).menuGroup);return i?(0,F.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,F.jsxs)(`div`,{className:`mdw-head`,children:[(0,F.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,F.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,F.jsx)(`span`,{className:`grow`}),u,(0,F.jsxs)(`div`,{className:`docp-actions`,children:[v.map(e=>x(e.id)),(0,F.jsxs)(A,{menu:d,className:`mdw-act-menu`,children:[S.map(e=>(0,F.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,F.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=g[e.id],n=t?.danger||w(I,e.id).danger;return(0,F.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>b(e.id),children:[t?.label||w(I,e.id).label||e.id,t?.hint?(0,F.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),j.map(e=>{let t=g[e.id];return(0,F.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||w(I,e.id).danger?` danger`:``),onClick:()=>b(e.id),children:t?.label||w(I,e.id).label||e.id},e.id)}),(0,F.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,F.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{d.setOpen(!1),h(!0)},children:`自定义工具栏…`})]})]})]}),m&&(0,P.createPortal)((0,F.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>h(!1),children:(0,F.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,F.jsx)(C,{kind:I,layout:f,setLayout:p,onClose:()=>h(!1)})})}),document.body)]}):(0,F.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,F.jsxs)(`div`,{className:`mdw-head`,children:[(0,F.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,F.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,F.jsx)(`span`,{className:`grow`}),u,(0,F.jsx)(`div`,{className:`docp-actions`,children:(0,F.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function R(e,t,n){return{id:e,label:t,items:n.filter(Boolean)}}var z=o({default:()=>V,useWikiNav:()=>B});function B(e){let n=_()||{},i=r(),a=e||n.model,o=(0,N.useRef)(null),s=(0,N.useCallback)(async()=>{if(!o.current)try{o.current=(await t(`/api/docs/index`)).index||[]}catch{o.current=[]}return o.current},[]),c=(0,N.useCallback)(async(e,t,n={})=>{let r=(t||await s()).find(t=>t.docId===e);g(a,{component:`doc`,name:r?r.name:e,config:{docId:e,...n.repoKey?{repoKey:n.repoKey}:{},...n.boardKey?{boardKey:n.boardKey,boardName:n.boardName||``}:{}},location:`center`})},[a,s]),l=(0,N.useCallback)(async e=>{let t=await s(),n=p(e,t);if(n&&n.docId)return c(n.docId,t);if(n&&n.candidates)return i(`「${e}」同名文档多份:${n.candidates.join(`、`)}`);i(`未找到「${e}」——可用 nx-kv docs add <rel> 创建`)},[s,c,i]);return{nav:l,onClick:(0,N.useCallback)(e=>{let t=e.target.closest(`[data-wl]`);t&&(e.preventDefault(),l(t.getAttribute(`data-wl`)))},[l]),ensureIndex:s,openByDocId:c}}function V({docId:e,repoKey:i,boardKey:a,boardName:o,model:s,tabId:p}){let h=r(),{dialog:_,node:C}=n(),w=(0,N.useRef)(new Map),T=(0,N.useRef)(null),E=(0,N.useRef)(null),{onClick:D,openByDocId:O}=B(s),k=i?`repo`:a?`board`:``,A=i||a||``,P=(0,N.useMemo)(()=>i?{repoKey:i}:a?{boardKey:a,boardName:o||``}:{},[i,a,o]),[I,L]=(0,N.useState)(null),[z,V]=(0,N.useState)(``),[ie,U]=(0,N.useState)(!1),[W,G]=(0,N.useState)(`split`),[K,q]=(0,N.useState)([]),[ae,J]=(0,N.useState)(null),Y=(0,N.useRef)(null);(0,N.useEffect)(()=>{Y.current=I},[I]);let X=(0,N.useCallback)(async()=>{V(``);try{let n=await t(`/api/docs/item?ref=`+encodeURIComponent(e||``));L(n),U(!1)}catch(e){V(String(e.message||e)),L(null)}},[e]);(0,N.useEffect)(()=>{L(null),X()},[X]);let Z=(0,N.useCallback)(()=>{if(!A){q([]);return}if(k===`repo`){t(`/api/repos/docs?id=`+encodeURIComponent(A)).then(t=>{let n=[],r=(e,t)=>{if(!e)return;let r=e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``;r&&n.push({docId:r,label:e.rel||e.path||(t?`主篇`:`补充`),note:e.note||``,main:t})};r(t.main||{rel:`repo/${A}.md`},!0);for(let e of t.links||[])r(e,!1);e&&!n.some(t=>t.docId===e)&&n.push({docId:e,label:`当前`,note:``,main:!0}),q(n)}).catch(()=>q(e?[{docId:e,label:`当前`,note:``,main:!0}]:[]));return}t(`/api/boards`).then(t=>{let n=(t&&t.boards||(Array.isArray(t)?t:[])).find(e=>e.id===A||e.key===A),r=[];e&&r.push({docId:e,label:`当前`,note:``,main:!0});for(let e of n&&n.docLinks||[]){let t=e.rel?`rel:${e.rel}`:e.path?`path:${e.path}`:``;t&&!r.some(e=>e.docId===t)&&r.push({docId:t,label:e.rel||e.path||`补充`,note:e.note||``,main:!1})}q(r)}).catch(()=>q(e?[{docId:e,label:`当前`,note:``,main:!0}]:[]))},[A,k,e]);(0,N.useEffect)(()=>{Z()},[Z]);let[se,ce]=(0,N.useState)(null);(0,N.useEffect)(()=>{t(`/api/docs/index`).then(e=>{let t=new Set;for(let n of e.index||[])t.add(n.name),n.rel&&t.add(String(n.rel).toLowerCase()),n.path&&t.add(String(n.path).replace(/\\/g,`/`).toLowerCase());ce(t)}).catch(()=>{})},[]);let Q=!!(I&&I.writable),le=(0,N.useMemo)(()=>I?f(I.body,[],Q?se:null):``,[I,se,Q]),ue=(0,N.useMemo)(()=>I?d(I.body):[],[I]);(0,N.useEffect)(()=>{let e=E.current;if(!e)return;let t=()=>e.querySelector(`.mdw-preview, .mdw-lp`)||null;J(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>J(t())):null;return n&&n.observe(e,{childList:!0,subtree:!0}),()=>{n&&n.disconnect()}},[I,W,le]);let $=e=>e().catch(e=>h(String(e.message||e))),de=(0,N.useCallback)(e=>O(e,null,P),[O,P]),fe=(0,N.useCallback)(()=>{let e=s;e&&A&&g(e,{component:`refs`,name:`文档列表`,config:i?{repoKey:i}:{boardKey:a,boardName:o||``},location:`right`})},[s,A,i,a,o]),pe=()=>{A&&$(async()=>{let n=await _({title:`补充介绍文档`,input:!0,placeholder:`文档名(如 architecture / api-notes)`});if(n===null)return;let r=c(String(n).trim()||`note`).replace(/\.md$/i,``),i=`${String(e||``).startsWith(`rel:`)?H(e):k===`repo`?`repo/${A}`:`board/${o||A}`}/reference/${r}.md`;await t(`/api/docs/item`,{method:`POST`,body:{rel:i,body:`# ${String(n).trim()||r}\n\n(待补)\n`}});try{k===`repo`?await t(`/api/repos/docs`,{method:`POST`,body:{id:A,rel:i}}):await t(`/api/docs/link`,{method:`POST`,body:{board:A,doc:i}})}catch{}h(`已补充:${i}`),Z(),O(`rel:`+i,null,P)})},me=()=>$(async()=>{if(!I||!Q)return;let n=await t(`/api/docs/item`,{method:`PATCH`,body:{ref:e,body:I.body}});L(e=>({...e,body:I.body,summary:n.summary})),U(!1),ne(w.current,e),h(n.summary?`已保存,摘要已回写`:`已保存`)}),he=(t,n=`op`)=>{I&&(M(w.current,e,{body:I.body},n),U(!0),L(e=>({...e,body:t,title:l(t,e.title)})))},ge=(t,n=`typing`)=>{if(!I)return;M(w.current,e,{body:I.body},n),U(!0);let r=/^#\s+/m.test(I.body)?I.body.replace(/^#\s+.+$/m,`# ${t||`未命名文档`}`):`# ${t||`未命名文档`}\n\n${I.body}`;L(e=>({...e,body:r,title:t}))},_e=()=>{if(!I)return;let t=ee(w.current,e,{body:I.body});t&&(L(e=>({...e,body:t.body,title:l(t.body,e.title)})),U(!0),requestAnimationFrame(()=>T.current?.caretFromDiff?.(I.body,t.body)))},ve=()=>{if(!I)return;let t=te(w.current,e,{body:I.body});t&&(L(e=>({...e,body:t.body,title:l(t.body,e.title)})),U(!0),requestAnimationFrame(()=>T.current?.caretFromDiff?.(I.body,t.body)))},ye=async(t,n={})=>{if(!Q)return;let r=[...t||[]];if(r.length)try{let t=await b(r,{local:!0,onProgress:(e,t,n)=>h(`正在上传 ${e}/${t}:${n.name}`)}),i=x(t);if(!i)return;let a=Y.current||I;if(!a)return;let o=u(a.body,i,n);M(w.current,e,{body:a.body}),U(!0),L(e=>e&&{...e,body:o.body,title:l(o.body,e.title)}),h(`已插入 ${t.length} 个附件`)}catch(e){h(`附件上传失败:${String(e.message||e)}`)}},be=()=>{I&&I.rel&&$(async()=>{let n=await _({title:`重命名文档`,input:!0,value:I.rel,placeholder:`新路径(相对 docs 根,以 .md 结尾)`});if(n===null)return;let r=String(n).trim();if(r&&r!==I.rel){if(!/\.md$/i.test(r))return h(`文档路径必须以 .md 结尾`);try{await t(`/api/docs/item`,{method:`POST`,body:{rel:r,body:I.body}})}catch(e){h(`重命名失败:${String(e.message||e)}`);return}await t(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),ne(w.current,e),h(`已重命名为:${r}`),O(`rel:`+r,null,P)}})},xe=()=>{I&&$(async()=>{await _({title:`删除文档「${I.title||I.rel||e}」`,message:`磁盘上的 ${I.rel||e} 会被一并删除,不可恢复。`,danger:!0,okText:`删除`})&&(await t(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),h(`已删除:${I.rel||e}`),s&&p&&s.doAction(m.deleteTab(p)))})},Se=()=>$(async()=>{let n=String(e||``).startsWith(`rel:`)?e.slice(4):String(e||``).startsWith(`path:`)?``:String(e||``);if(!n)return;let r=n.replace(/\.md$/i,``).split(`/`).pop()||`未命名文档`;await t(`/api/docs/item`,{method:`POST`,body:{rel:n,body:`# ${r}\n\n(待补)\n`}}),h(`已创建:${n}`),await X()});if(I&&I.dir)return(0,F.jsxs)(`div`,{className:`mdw docp`,children:[(0,F.jsxs)(`div`,{className:`docp-head`,children:[(0,F.jsx)(`span`,{className:`docp-path mono`,children:I.path}),(0,F.jsx)(`span`,{className:`docp-tag ext`,children:`外部目录 · 只读`})]}),(0,F.jsxs)(`div`,{className:`docp-files`,children:[I.files.map(e=>(0,F.jsx)(`button`,{className:`docp-file`,onClick:()=>O(`path:`+e,null),children:e},e)),!I.files.length&&(0,F.jsx)(`div`,{className:`muted pad`,children:`(目录里还没有 .md 文档)`})]})]});if(z)return(0,F.jsx)(`div`,{className:`mdw docp`,children:(0,F.jsxs)(`div`,{className:`pad stack`,children:[(0,F.jsx)(`div`,{children:(0,F.jsx)(`strong`,{children:`文档打开失败`})}),(0,F.jsx)(`div`,{className:`hint`,children:z})]})});if(!I)return(0,F.jsx)(`div`,{className:`mdw`,children:(0,F.jsx)(`div`,{className:`pad muted`,children:`载入中…`})});if(I.missing){let t=String(e||``).startsWith(`rel:`)||!String(e||``).startsWith(`path:`);return(0,F.jsxs)(`div`,{className:`mdw docp`,children:[(0,F.jsx)(`div`,{className:`docp-head`,children:(0,F.jsx)(`span`,{className:`docp-path mono`,children:I.rel||I.path||e})}),(0,F.jsxs)(`div`,{className:`pad stack`,children:[(0,F.jsx)(`div`,{children:(0,F.jsx)(`strong`,{children:`文档还没有落盘`})}),(0,F.jsx)(`div`,{className:`hint`,children:`描述内容的权威是磁盘上的 .md 文件——对应的字符串字段会在读取时播种,也可以直接创建骨架。`}),t&&(0,F.jsx)(`div`,{children:(0,F.jsx)(`button`,{className:`btn sm`,onClick:Se,children:`创建骨架`})})]})]})}let Ce=Q?W:`read`;return(0,F.jsxs)(`div`,{className:`mdw docp`,"data-mode":Ce,onClick:D,ref:E,children:[(0,F.jsxs)(`div`,{className:`mdw-main`,children:[(0,F.jsx)(re,{crumb:(0,F.jsx)(S,{}),title:I.title||I.rel||I.path||`文档`,pathLabel:I.rel||I.path||``,dirty:ie,writable:Q,external:!!I.external,menuGroups:[R(`edit`,`编辑`,[{id:`mode`,label:W===`edit`?`返回实时预览`:`源码模式`,hint:W===`edit`?`当前`:``,run:()=>G(W===`edit`?`split`:`edit`)}]),R(`doc`,`文档`,[{id:`rename`,label:`重命名`,run:be},{id:`delete`,label:`删除`,run:xe,danger:!0}]),R(`view`,`查看`,[A&&{id:`list`,label:`文字列表`,hint:`右侧边栏`,run:fe}])],onSave:me}),I.summary&&Q&&(0,F.jsxs)(`div`,{className:`docp-summary`,children:[`摘要(回写 desc):`,I.summary]}),(0,F.jsx)(y,{mode:Ce,title:I.title,body:I.body,previewHtml:le,onTitle:Q?ge:null,onBody:Q?he:null,onFiles:Q?ye:null,attachments:[],docKey:e,editorApiRef:T,onSave:Q?me:null,onUndo:Q?_e:null,onRedo:Q?ve:null}),(0,F.jsx)(j,{host:`ref`,refId:e,allow:{file:!0,url:!0,task:!1,ref:!0},disabled:!Q,disabledText:`只读文档不能添加附件。`,onOpenDoc:e=>{let t=v(e);t&&O(t,null,P)}}),(0,F.jsx)(`div`,{className:`docp-hint`,children:`双链 [[]] 点击跳转 · Ctrl+S 保存 · 文档即磁盘文件(~/.nx-kv/docs/)`})]}),(0,F.jsx)(oe,{headings:ue,scrollRoot:ae,links:K,activeDocId:e,onOpenDoc:A?de:null,onAddRef:A?pe:null}),C]})}function H(e){let t=String(e||``).startsWith(`rel:`)?String(e).slice(4):``;return t?/\/index\.md$/i.test(t)?t.replace(/\/index\.md$/i,``):/\.md$/i.test(t)?t.replace(/\.md$/i,``):t.replace(/\/+$/,``):``}function ie(e,t){return e?e.doc&&e.doc.path?`path:`+e.doc.path:e.doc&&e.doc.rel?`rel:`+e.doc.rel:e.docPath?`path:`+e.docPath:e.docRel?`rel:`+e.docRel:t===`repo`&&e.key?`rel:repo/`+e.key+`.md`:``:``}function U(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function W({kind:e,owner:n,model:r}){let{openByDocId:i}=B(r),a=e===`board`?`组介绍`:`项目介绍`,o=e===`board`?n&&(n.id||n.key):n&&n.key,s=n&&n.name,l=(0,N.useMemo)(()=>ie(n,e),[n,e]),[u,d]=(0,N.useState)([]),[f,p]=(0,N.useState)(``),[m,h]=(0,N.useState)(0),g=(0,N.useCallback)(()=>h(e=>e+1),[]);(0,N.useEffect)(()=>{let r=!0;if(!o){d([]);return}if(e===`repo`)t(`/api/repos/docs?id=`+encodeURIComponent(o)).then(e=>{if(!r)return;let t=[],n=U(e.main);p(n||l),n&&t.push({docId:n,label:e.main.rel||e.main.path||`主篇`,note:e.main.note||``,tag:e.main.tag||``,main:!0,ref:e.main.ref||``});for(let n of e.extras||[]){let e=U(n);e&&t.push({docId:e,label:n.name||n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}for(let n of e.links||[]){let e=U(n);e&&t.push({docId:e,label:n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}d(t)}).catch(()=>{r&&(d([]),p(l))});else{let e=()=>{let e=[];l&&e.push({docId:l,label:`主篇`,note:``,tag:``,main:!0,ref:``});for(let t of n?.docLinks||[]){let n=U(t);n&&e.push({docId:n,label:t.rel||t.path||`补充`,note:t.note||``,tag:t.tag||``,main:!1,ref:t.ref||``})}return e};t(`/api/boards/`+encodeURIComponent(String(o))).then(t=>{if(!r)return;let n=Array.isArray(t&&t.docLinks)?t.docLinks:null;if(!n){d(e()),p(l);return}let i=[],a=U(t&&t.introMain)||l;p(a),a&&i.push({docId:a,label:`主篇`,note:``,tag:``,main:!0,ref:``});for(let e of t&&t.introExtras||[]){let t=U(e);t&&i.push({docId:t,label:e.name||e.rel||e.path||`补充`,note:e.note||``,tag:e.tag||``,main:!1,ref:e.ref||``})}for(let e of n){let t=U(e);t&&i.push({docId:t,label:e.rel||e.path||`补充`,note:e.note||``,tag:e.tag||``,main:!1,ref:e.ref||``})}d(i)}).catch(()=>{r&&(d(e()),p(l))})}return()=>{r=!1}},[e,o,n,l,m]);let _=(0,N.useMemo)(()=>e===`repo`&&o?{repoKey:o}:e===`board`&&o?{boardKey:o,boardName:s||``}:{},[e,o,s]);return{kind:e,label:a,ownerKey:o,docRef:l,mainDocId:f,links:u,openMain:(0,N.useCallback)(()=>{let e=f||l;e&&i(e,null,_)},[f,l,i,_]),openDoc:(0,N.useCallback)(e=>i(e,null,_),[i,_]),addRef:(0,N.useCallback)(async(n,r)=>{if(!o||!l.startsWith(`rel:`))return r&&r(`当前简介无法补充(需要自有树路径)`),null;let a=await n({title:`补充介绍文档`,input:!0,tagInput:!0,placeholder:`文档名(如 architecture / api-notes)`,tagPlaceholder:`标签(可选,如 qa)`});if(a===null)return null;let u=typeof a==`string`?a:a&&a.value||``,d=typeof a==`object`&&a&&a.tag||``,f=c(String(u).trim()||`note`).replace(/\.md$/i,``),p=`${H(l)||(e===`repo`?`repo/${o}`:`board/${s||o}`)}/reference/${f}.md`;await t(`/api/docs/item`,{method:`POST`,body:{rel:p,body:`# ${String(u).trim()||f}\n\n(待补)\n`}});try{e===`repo`?await t(`/api/repos/docs`,{method:`POST`,body:{id:o,rel:p,tag:d||void 0}}):await t(`/api/docs/link`,{method:`POST`,body:{board:o,doc:p,tag:d||void 0}})}catch{}return r&&r(`已补充:${p}${d?` [${d}]`:``}`),g(),i(`rel:`+p,null,_),p},[o,l,e,s,i,_,g]),setLinkTag:(0,N.useCallback)(async(n,r,i)=>{if(!o)throw Error(`缺少归属`);let a=String(n||``).startsWith(`path:`)?{path:String(n).slice(5)}:{rel:String(n||``).startsWith(`rel:`)?String(n).slice(4):String(n||``)},s=i&&i.note||``;e===`repo`?await t(`/api/repos/docs`,{method:`POST`,body:{id:o,...a,note:s||void 0,tag:r||void 0}}):await t(`/api/docs/link`,{method:`POST`,body:{board:o,doc:a.path||a.rel,note:s||void 0,tag:r||void 0}}),g()},[o,e,g]),reload:g,canEdit:!!l}}function G(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function K(e){let t=e.rel||e.path||``;return String(t).replace(/[\\/]+$/,``).split(/[\\/]/).pop()||t||`未命名`}function q(e,t,n){let r=[],i=e&&(e.main||e.introMain);i&&r.push({id:G(i),kind:`main`,label:`主篇`,sub:i.rel||i.path||``,tag:``,note:``,docId:G(i),removable:n===`repo`&&!!(t&&t.doc),removeTip:`摘除主篇自定义绑定(回退约定路径,文档不删)`,taggable:!1});for(let t of e&&(e.extras||e.introExtras)||[]){let e=G(t);e&&r.push({id:e,kind:`extra`,label:K(t),sub:t.rel||t.path||``,tag:``,note:``,docId:e,removable:!1,taggable:String(e).startsWith(`rel:`)})}(e&&(e.links||e.docLinks)||[]).forEach((e,t)=>{let i=G(e);i&&r.push({id:i,kind:`link`,label:K(e),sub:e.rel||e.path||``,tag:e.tag||``,note:e.note||``,docId:i,removeIndex:n===`repo`?t+2:t+1,removable:!0,taggable:!0})});for(let e of n===`repo`&&t&&t.boards||[]){let t=e.noteDocPath||``,n=e.noteDocRel||``,i=t?`path:`+t:n?`rel:`+n:``;i&&r.push({id:i,kind:`scoped`,label:`${e.name} · 组内描述`,sub:t||n,tag:``,note:e.note||``,docId:i,removable:!1,taggable:!1})}return r.filter(e=>e.docId)}var ae={main:`● `,scoped:`◇ `,extra:`○ `,link:`○ `};function J({kind:e,owner:a,model:o,onClose:s,onChanged:l}){let u=r(),{dialog:d,node:f}=n(),p=_()||{},m=o||p.model,h=W({kind:e,owner:a,model:m}),v=h.ownerKey,y=a&&a.name,[b,x]=(0,N.useState)([]),[S,C]=(0,N.useState)(!0),[w,T]=(0,N.useState)(``),E=(0,N.useCallback)(async()=>{if(!v){x([]),C(!1);return}C(!0);try{let n=e===`repo`?await t(`/api/repos/docs?id=`+encodeURIComponent(v)):await t(`/api/boards/`+encodeURIComponent(String(v)));x(q(n,a,e)),T(``)}catch(e){x([]),T(String(e.message||e))}finally{C(!1)}},[e,v,a]);(0,N.useEffect)(()=>{E()},[E]);let D=t=>{if(!t)return;let n=m;if(!n){u(`工作区不可用,无法打开文档`);return}g(n,{component:`doc`,name:t.label||t.sub||t.docId,config:{docId:t.docId,...e===`repo`?{repoKey:v}:{boardKey:v,boardName:y||``}},location:`center`}),s()},O=e=>e().catch(e=>u(String(e.message||e))),k=n=>O(async()=>{await d({message:`摘除「${n.label}」?${n.kind===`main`?`(只拆绑定,文档不删)`:`(文档不删,仅移出列表)`}`,danger:!0})&&(e===`repo`?await t(`/api/repos/docs`,{method:`DELETE`,body:{id:v,index:n.removeIndex}}):await t(`/api/docs/link`,{method:`POST`,body:{board:v,remove:n.removeIndex}}),u(`已摘除`),E(),l&&l())}),A=e=>O(async()=>{let t=await d({title:`标签 · ${e.label}`,input:!0,placeholder:`标签(如 qa;留空 = 清掉)`,value:e.tag||``,okText:`保存标签`});if(t===null)return;let n=typeof t==`string`?t:t&&t.tag||``;await h.setLinkTag(e.docId,n,e),u(n?`标签已设为 [${n}]`:`标签已清除`),E(),l&&l()}),j=()=>O(async()=>{if(!v||!String(h.docRef||``).startsWith(`rel:`)){u(`当前简介无法补充(需要自有树路径)`);return}let n=await d({title:`补充介绍文档`,input:!0,tagInput:!0,placeholder:`文档名(如 architecture / api-notes)`,tagPlaceholder:`标签(可选,如 qa)`});if(n===null)return;let r=typeof n==`string`?n:n&&n.value||``,i=typeof n==`object`&&n&&n.tag||``,a=c(String(r).trim()||`note`).replace(/\.md$/i,``),o=`${H(h.docRef)||(e===`repo`?`repo/${v}`:`board/${y||v}`)}/reference/${a}.md`;await t(`/api/docs/item`,{method:`POST`,body:{rel:o,body:`# ${String(r).trim()||a}\n\n(待补)\n`}});try{e===`repo`?await t(`/api/repos/docs`,{method:`POST`,body:{id:v,rel:o,tag:i||void 0}}):await t(`/api/docs/link`,{method:`POST`,body:{board:v,doc:o,tag:i||void 0}})}catch{}u(`已补充:${o}${i?` [${i}]`:``}`),await E(),l&&l(),D({docId:`rel:`+o,label:String(r).trim()||a,sub:o})}),ee=!!String(h.docRef||``).startsWith(`rel:`)&&v,M=b.length,te=`文档列表 · ${y||``}${e===`board`?`(项目组)`:``}`;return(0,F.jsxs)(i,{size:`md`,title:te,onClose:s,children:[(0,F.jsxs)(`div`,{className:`nx-dl`,children:[(0,F.jsxs)(`div`,{className:`nx-dl-head`,children:[(0,F.jsx)(`span`,{className:`nx-dl-count`,children:M?`${M} 篇`:`还没有文档`}),(0,F.jsx)(`span`,{className:`nx-dl-hint`,children:`点标题在主内容区打开`}),(0,F.jsx)(`span`,{className:`grow`}),ee&&(0,F.jsx)(`button`,{type:`button`,className:`btn ghost sm nx-dl-add`,title:`补充一篇介绍文档(reference)`,onClick:j,children:`+ 补充`})]}),w?(0,F.jsx)(`div`,{className:`rpd-err`,children:w}):null,!w&&S&&M===0?(0,F.jsx)(`div`,{className:`rpd-empty`,children:`载入中…`}):null,!w&&!S&&M===0?(0,F.jsx)(`div`,{className:`rpd-none`,children:`还没有文档 —— 点「+ 补充」写第一篇`}):null,(0,F.jsx)(`div`,{className:`nx-dl-list`,children:b.map(e=>(0,F.jsxs)(`div`,{className:`nx-dl-row-wrap`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`nx-dl-row`,title:`${e.sub||e.label}\n点击在主内容区打开(可编辑)`,onClick:()=>D(e),children:[(0,F.jsxs)(`span`,{className:`nx-dl-row-title`,children:[ae[e.kind]||`○ `,e.label]}),e.tag?(0,F.jsx)(`span`,{className:`rpd-badge`,children:e.tag}):null]}),(0,F.jsxs)(`span`,{className:`nx-docs-modal-item-acts`,children:[e.taggable&&(0,F.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini`,title:e.tag?`改标签(当前:${e.tag})`:`加标签`,onClick:()=>A(e),children:`#`}),e.removable&&(0,F.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini danger`,title:e.removeTip||`摘除「${e.label}」(文档不删)`,onClick:()=>k(e),children:`×`})]})]},e.id))})]}),f]})}function Y(e){return e<=1?18:e===2?12:8}function oe({headings:e=[],scrollRoot:t=null,links:n=[],activeDocId:r=``,onOpenDoc:i=null,onAddRef:a=null}){let[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)(``),u=(0,N.useMemo)(()=>e||[],[e]),d=(0,N.useMemo)(()=>n||[],[n]);(0,N.useEffect)(()=>{let e=t;if(!e||!u.length)return;let n=()=>u.map(t=>{let n=e.querySelector(`#${CSS.escape(t.id)}`);if(!n)return null;let r=n.getBoundingClientRect(),i=e.getBoundingClientRect();return{id:t.id,y:r.top-i.top}}).filter(Boolean),r=()=>{let e=n();if(!e.length)return;let t=e[0].id;for(let n of e)n.y<=28&&(t=n.id);l(t)};return r(),e.addEventListener(`scroll`,r,{passive:!0}),()=>e.removeEventListener(`scroll`,r)},[t,u]);let f=(0,N.useCallback)(e=>{let n=t;if(!n)return;let r=n.querySelector(`#${CSS.escape(e)}`);if(!r){n.scrollTo({top:0,behavior:`smooth`}),l(e);return}r.scrollIntoView({behavior:`smooth`,block:`start`}),l(e)},[t]);return!u.length&&!d.length&&!a?null:(0,F.jsxs)(`aside`,{className:`doc-rail`+(o?` open`:``),"aria-label":`文档目录`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:o?`收起目录`:`展开目录`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[(0,F.jsx)(`span`,{}),(0,F.jsx)(`span`,{}),(0,F.jsx)(`span`,{})]}),(0,F.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`章节`,children:u.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(c===e.id?` on`:``),style:{"--tw":`${Y(e.level)}px`},title:e.text,"aria-current":c===e.id?`true`:void 0,onClick:()=>f(e.id)},e.id))}),o&&(0,F.jsxs)(`div`,{className:`doc-rail-panel`,children:[u.length>0&&(0,F.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,F.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`本章`}),u.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`doc-rail-row`+(c===e.id?` on`:``),"data-lv":e.level,onClick:()=>f(e.id),children:e.text},e.id))]}),(d.length>0||a)&&(0,F.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,F.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`介绍文档`}),d.map(e=>(0,F.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(e.docId===r?` on`:``),title:e.note||e.label,disabled:!i,onClick:()=>i&&i(e.docId),children:[e.main?`● `:`○ `,e.label]},e.docId)),a&&(0,F.jsx)(`button`,{type:`button`,className:`doc-rail-add`,onClick:a,children:`+ 补充文档`})]})]})]})}function X({kind:e,owner:t,model:n}){let{label:r,docRef:i,links:a,openMain:o}=W({kind:e,owner:t,model:n}),[s,c]=(0,N.useState)(!1);if(!t||!i)return null;let l=a.find(e=>e.main),u=l?l.docId:i,d=u.startsWith(`rel:`)?u.slice(4):u,f=a.filter(e=>!e.main).length;return(0,F.jsxs)(`div`,{className:`nx-intro`,children:[(0,F.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,F.jsx)(`button`,{type:`button`,className:`nx-intro-link-main`,title:`打开${r}(在主内容区阅读 / 编辑)`,onClick:o,children:r}),(0,F.jsx)(`span`,{className:`nx-intro-path mono`,children:d}),(0,F.jsx)(`span`,{className:`nx-intro-spacer`}),(0,F.jsxs)(`button`,{type:`button`,className:`nx-intro-btn`,title:`查看${r}的全部文章(点标题在主内容区打开,可编辑)`,onClick:()=>c(!0),children:[`查看详情`,f>0?` ${f}`:``]})]}),s&&(0,F.jsx)(J,{kind:e,owner:t,model:n,onClose:()=>c(!1)})]})}export{B as i,J as n,z as r,X as t};
|
|
1
|
+
import{S as e,_ as t,f as n,g as r,l as i,v as a,x as o,y as s}from"./task-status-BP6y8MVu.js";import{d as c,h as l,i as u,r as d,u as f,y as p}from"./md-parse-C2bDc3IZ.js";import{M as m,N as h,O as g,k as _}from"./index-BmANFdAR.js";import{o as v,t as y}from"./md-panes-sRhT7DNc.js";import{a as b,i as x}from"./upload-L1g-pfvZ.js";import{t as S}from"./route-crumb-DHYbpsO8.js";import{a as C,c as w,i as T,l as E,o as D,r as O,s as k,t as A,u as j}from"./tool-bar-BwMNTrR1.js";import{i as ee,n as M,r as te,t as ne}from"./md-history-Uo6U7hYS.js";var N=e(s(),1),P=h(),F=a(),I=`doc`,L=[{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=T(),{layout:f,setLayout:p}=D(I),[m,h]=(0,N.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=>E(I,e)&&_(e.id)),y=f.filter(e=>k(I,e)&&_(e.id)),b=e=>{g[e]?.run?.(),d.setOpen(!1)},x=e=>{if(e===`more`)return(0,F.jsx)(`div`,{className:`docp-more`,ref:d.ref,children:(0,F.jsx)(`button`,{type:`button`,className:`btn ghost sm${d.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":d.open,onClick:e=>O(d,e,`right`),children:`更多`})},`more`);let t=g[e];return t?(0,F.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||w(I,e).label||e},e):null},S=L.map(e=>({...e,items:y.filter(t=>w(I,t.id).menuGroup===e.id)})).filter(e=>e.items.length),j=y.filter(e=>!w(I,e.id).menuGroup);return i?(0,F.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,F.jsxs)(`div`,{className:`mdw-head`,children:[(0,F.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,F.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,F.jsx)(`span`,{className:`grow`}),u,(0,F.jsxs)(`div`,{className:`docp-actions`,children:[v.map(e=>x(e.id)),(0,F.jsxs)(A,{menu:d,className:`mdw-act-menu`,children:[S.map(e=>(0,F.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,F.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=g[e.id],n=t?.danger||w(I,e.id).danger;return(0,F.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>b(e.id),children:[t?.label||w(I,e.id).label||e.id,t?.hint?(0,F.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),j.map(e=>{let t=g[e.id];return(0,F.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||w(I,e.id).danger?` danger`:``),onClick:()=>b(e.id),children:t?.label||w(I,e.id).label||e.id},e.id)}),(0,F.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,F.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{d.setOpen(!1),h(!0)},children:`自定义工具栏…`})]})]})]}),m&&(0,P.createPortal)((0,F.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>h(!1),children:(0,F.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,F.jsx)(C,{kind:I,layout:f,setLayout:p,onClose:()=>h(!1)})})}),document.body)]}):(0,F.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,F.jsxs)(`div`,{className:`mdw-head`,children:[(0,F.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,F.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,F.jsx)(`span`,{className:`grow`}),u,(0,F.jsx)(`div`,{className:`docp-actions`,children:(0,F.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function R(e,t,n){return{id:e,label:t,items:n.filter(Boolean)}}var z=o({default:()=>V,useWikiNav:()=>B});function B(e){let n=_()||{},i=r(),a=e||n.model,o=(0,N.useRef)(null),s=(0,N.useCallback)(async()=>{if(!o.current)try{o.current=(await t(`/api/docs/index`)).index||[]}catch{o.current=[]}return o.current},[]),c=(0,N.useCallback)(async(e,t,n={})=>{let r=(t||await s()).find(t=>t.docId===e);g(a,{component:`doc`,name:r?r.name:e,config:{docId:e,...n.repoKey?{repoKey:n.repoKey}:{},...n.boardKey?{boardKey:n.boardKey,boardName:n.boardName||``}:{}},location:`center`})},[a,s]),l=(0,N.useCallback)(async e=>{let t=await s(),n=p(e,t);if(n&&n.docId)return c(n.docId,t);if(n&&n.candidates)return i(`「${e}」同名文档多份:${n.candidates.join(`、`)}`);i(`未找到「${e}」——可用 nx-kv docs add <rel> 创建`)},[s,c,i]);return{nav:l,onClick:(0,N.useCallback)(e=>{let t=e.target.closest(`[data-wl]`);t&&(e.preventDefault(),l(t.getAttribute(`data-wl`)))},[l]),ensureIndex:s,openByDocId:c}}function V({docId:e,repoKey:i,boardKey:a,boardName:o,model:s,tabId:p}){let h=r(),{dialog:_,node:C}=n(),w=(0,N.useRef)(new Map),T=(0,N.useRef)(null),E=(0,N.useRef)(null),{onClick:D,openByDocId:O}=B(s),k=i?`repo`:a?`board`:``,A=i||a||``,P=(0,N.useMemo)(()=>i?{repoKey:i}:a?{boardKey:a,boardName:o||``}:{},[i,a,o]),[I,L]=(0,N.useState)(null),[z,V]=(0,N.useState)(``),[ie,U]=(0,N.useState)(!1),[W,G]=(0,N.useState)(`split`),[K,q]=(0,N.useState)([]),[ae,J]=(0,N.useState)(null),Y=(0,N.useRef)(null);(0,N.useEffect)(()=>{Y.current=I},[I]);let X=(0,N.useCallback)(async()=>{V(``);try{let n=await t(`/api/docs/item?ref=`+encodeURIComponent(e||``));L(n),U(!1)}catch(e){V(String(e.message||e)),L(null)}},[e]);(0,N.useEffect)(()=>{L(null),X()},[X]);let Z=(0,N.useCallback)(()=>{if(!A){q([]);return}if(k===`repo`){t(`/api/repos/docs?id=`+encodeURIComponent(A)).then(t=>{let n=[],r=(e,t)=>{if(!e)return;let r=e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``;r&&n.push({docId:r,label:e.rel||e.path||(t?`主篇`:`补充`),note:e.note||``,main:t})};r(t.main||{rel:`repo/${A}.md`},!0);for(let e of t.links||[])r(e,!1);e&&!n.some(t=>t.docId===e)&&n.push({docId:e,label:`当前`,note:``,main:!0}),q(n)}).catch(()=>q(e?[{docId:e,label:`当前`,note:``,main:!0}]:[]));return}t(`/api/boards`).then(t=>{let n=(t&&t.boards||(Array.isArray(t)?t:[])).find(e=>e.id===A||e.key===A),r=[];e&&r.push({docId:e,label:`当前`,note:``,main:!0});for(let e of n&&n.docLinks||[]){let t=e.rel?`rel:${e.rel}`:e.path?`path:${e.path}`:``;t&&!r.some(e=>e.docId===t)&&r.push({docId:t,label:e.rel||e.path||`补充`,note:e.note||``,main:!1})}q(r)}).catch(()=>q(e?[{docId:e,label:`当前`,note:``,main:!0}]:[]))},[A,k,e]);(0,N.useEffect)(()=>{Z()},[Z]);let[se,ce]=(0,N.useState)(null);(0,N.useEffect)(()=>{t(`/api/docs/index`).then(e=>{let t=new Set;for(let n of e.index||[])t.add(n.name),n.rel&&t.add(String(n.rel).toLowerCase()),n.path&&t.add(String(n.path).replace(/\\/g,`/`).toLowerCase());ce(t)}).catch(()=>{})},[]);let Q=!!(I&&I.writable),le=(0,N.useMemo)(()=>I?f(I.body,[],Q?se:null):``,[I,se,Q]),ue=(0,N.useMemo)(()=>I?d(I.body):[],[I]);(0,N.useEffect)(()=>{let e=E.current;if(!e)return;let t=()=>e.querySelector(`.mdw-preview, .mdw-lp`)||null;J(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>J(t())):null;return n&&n.observe(e,{childList:!0,subtree:!0}),()=>{n&&n.disconnect()}},[I,W,le]);let $=e=>e().catch(e=>h(String(e.message||e))),de=(0,N.useCallback)(e=>O(e,null,P),[O,P]),fe=(0,N.useCallback)(()=>{let e=s;e&&A&&g(e,{component:`refs`,name:`文档列表`,config:i?{repoKey:i}:{boardKey:a,boardName:o||``},location:`right`})},[s,A,i,a,o]),pe=()=>{A&&$(async()=>{let n=await _({title:`补充介绍文档`,input:!0,placeholder:`文档名(如 architecture / api-notes)`});if(n===null)return;let r=c(String(n).trim()||`note`).replace(/\.md$/i,``),i=`${String(e||``).startsWith(`rel:`)?H(e):k===`repo`?`repo/${A}`:`board/${o||A}`}/reference/${r}.md`;await t(`/api/docs/item`,{method:`POST`,body:{rel:i,body:`# ${String(n).trim()||r}\n\n(待补)\n`}});try{k===`repo`?await t(`/api/repos/docs`,{method:`POST`,body:{id:A,rel:i}}):await t(`/api/docs/link`,{method:`POST`,body:{board:A,doc:i}})}catch{}h(`已补充:${i}`),Z(),O(`rel:`+i,null,P)})},me=()=>$(async()=>{if(!I||!Q)return;let n=await t(`/api/docs/item`,{method:`PATCH`,body:{ref:e,body:I.body}});L(e=>({...e,body:I.body,summary:n.summary})),U(!1),ne(w.current,e),h(n.summary?`已保存,摘要已回写`:`已保存`)}),he=(t,n=`op`)=>{I&&(M(w.current,e,{body:I.body},n),U(!0),L(e=>({...e,body:t,title:l(t,e.title)})))},ge=(t,n=`typing`)=>{if(!I)return;M(w.current,e,{body:I.body},n),U(!0);let r=/^#\s+/m.test(I.body)?I.body.replace(/^#\s+.+$/m,`# ${t||`未命名文档`}`):`# ${t||`未命名文档`}\n\n${I.body}`;L(e=>({...e,body:r,title:t}))},_e=()=>{if(!I)return;let t=ee(w.current,e,{body:I.body});t&&(L(e=>({...e,body:t.body,title:l(t.body,e.title)})),U(!0),requestAnimationFrame(()=>T.current?.caretFromDiff?.(I.body,t.body)))},ve=()=>{if(!I)return;let t=te(w.current,e,{body:I.body});t&&(L(e=>({...e,body:t.body,title:l(t.body,e.title)})),U(!0),requestAnimationFrame(()=>T.current?.caretFromDiff?.(I.body,t.body)))},ye=async(t,n={})=>{if(!Q)return;let r=[...t||[]];if(r.length)try{let t=await b(r,{local:!0,onProgress:(e,t,n)=>h(`正在上传 ${e}/${t}:${n.name}`)}),i=x(t);if(!i)return;let a=Y.current||I;if(!a)return;let o=u(a.body,i,n);M(w.current,e,{body:a.body}),U(!0),L(e=>e&&{...e,body:o.body,title:l(o.body,e.title)}),h(`已插入 ${t.length} 个附件`)}catch(e){h(`附件上传失败:${String(e.message||e)}`)}},be=()=>{I&&I.rel&&$(async()=>{let n=await _({title:`重命名文档`,input:!0,value:I.rel,placeholder:`新路径(相对 docs 根,以 .md 结尾)`});if(n===null)return;let r=String(n).trim();if(r&&r!==I.rel){if(!/\.md$/i.test(r))return h(`文档路径必须以 .md 结尾`);try{await t(`/api/docs/item`,{method:`POST`,body:{rel:r,body:I.body}})}catch(e){h(`重命名失败:${String(e.message||e)}`);return}await t(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),ne(w.current,e),h(`已重命名为:${r}`),O(`rel:`+r,null,P)}})},xe=()=>{I&&$(async()=>{await _({title:`删除文档「${I.title||I.rel||e}」`,message:`磁盘上的 ${I.rel||e} 会被一并删除,不可恢复。`,danger:!0,okText:`删除`})&&(await t(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),h(`已删除:${I.rel||e}`),s&&p&&s.doAction(m.deleteTab(p)))})},Se=()=>$(async()=>{let n=String(e||``).startsWith(`rel:`)?e.slice(4):String(e||``).startsWith(`path:`)?``:String(e||``);if(!n)return;let r=n.replace(/\.md$/i,``).split(`/`).pop()||`未命名文档`;await t(`/api/docs/item`,{method:`POST`,body:{rel:n,body:`# ${r}\n\n(待补)\n`}}),h(`已创建:${n}`),await X()});if(I&&I.dir)return(0,F.jsxs)(`div`,{className:`mdw docp`,children:[(0,F.jsxs)(`div`,{className:`docp-head`,children:[(0,F.jsx)(`span`,{className:`docp-path mono`,children:I.path}),(0,F.jsx)(`span`,{className:`docp-tag ext`,children:`外部目录 · 只读`})]}),(0,F.jsxs)(`div`,{className:`docp-files`,children:[I.files.map(e=>(0,F.jsx)(`button`,{className:`docp-file`,onClick:()=>O(`path:`+e,null),children:e},e)),!I.files.length&&(0,F.jsx)(`div`,{className:`muted pad`,children:`(目录里还没有 .md 文档)`})]})]});if(z)return(0,F.jsx)(`div`,{className:`mdw docp`,children:(0,F.jsxs)(`div`,{className:`pad stack`,children:[(0,F.jsx)(`div`,{children:(0,F.jsx)(`strong`,{children:`文档打开失败`})}),(0,F.jsx)(`div`,{className:`hint`,children:z})]})});if(!I)return(0,F.jsx)(`div`,{className:`mdw`,children:(0,F.jsx)(`div`,{className:`pad muted`,children:`载入中…`})});if(I.missing){let t=String(e||``).startsWith(`rel:`)||!String(e||``).startsWith(`path:`);return(0,F.jsxs)(`div`,{className:`mdw docp`,children:[(0,F.jsx)(`div`,{className:`docp-head`,children:(0,F.jsx)(`span`,{className:`docp-path mono`,children:I.rel||I.path||e})}),(0,F.jsxs)(`div`,{className:`pad stack`,children:[(0,F.jsx)(`div`,{children:(0,F.jsx)(`strong`,{children:`文档还没有落盘`})}),(0,F.jsx)(`div`,{className:`hint`,children:`描述内容的权威是磁盘上的 .md 文件——对应的字符串字段会在读取时播种,也可以直接创建骨架。`}),t&&(0,F.jsx)(`div`,{children:(0,F.jsx)(`button`,{className:`btn sm`,onClick:Se,children:`创建骨架`})})]})]})}let Ce=Q?W:`read`;return(0,F.jsxs)(`div`,{className:`mdw docp`,"data-mode":Ce,onClick:D,ref:E,children:[(0,F.jsxs)(`div`,{className:`mdw-main`,children:[(0,F.jsx)(re,{crumb:(0,F.jsx)(S,{}),title:I.title||I.rel||I.path||`文档`,pathLabel:I.rel||I.path||``,dirty:ie,writable:Q,external:!!I.external,menuGroups:[R(`edit`,`编辑`,[{id:`mode`,label:W===`edit`?`返回实时预览`:`源码模式`,hint:W===`edit`?`当前`:``,run:()=>G(W===`edit`?`split`:`edit`)}]),R(`doc`,`文档`,[{id:`rename`,label:`重命名`,run:be},{id:`delete`,label:`删除`,run:xe,danger:!0}]),R(`view`,`查看`,[A&&{id:`list`,label:`文字列表`,hint:`右侧边栏`,run:fe}])],onSave:me}),I.summary&&Q&&(0,F.jsxs)(`div`,{className:`docp-summary`,children:[`摘要(回写 desc):`,I.summary]}),(0,F.jsx)(y,{mode:Ce,title:I.title,body:I.body,previewHtml:le,onTitle:Q?ge:null,onBody:Q?he:null,onFiles:Q?ye:null,attachments:[],docKey:e,editorApiRef:T,onSave:Q?me:null,onUndo:Q?_e:null,onRedo:Q?ve:null}),(0,F.jsx)(j,{host:`ref`,refId:e,allow:{file:!0,url:!0,task:!1,ref:!0},disabled:!Q,disabledText:`只读文档不能添加附件。`,onOpenDoc:e=>{let t=v(e);t&&O(t,null,P)}}),(0,F.jsx)(`div`,{className:`docp-hint`,children:`双链 [[]] 点击跳转 · Ctrl+S 保存 · 文档即磁盘文件(~/.nx-kv/docs/)`})]}),(0,F.jsx)(oe,{headings:ue,scrollRoot:ae,links:K,activeDocId:e,onOpenDoc:A?de:null,onAddRef:A?pe:null}),C]})}function H(e){let t=String(e||``).startsWith(`rel:`)?String(e).slice(4):``;return t?/\/index\.md$/i.test(t)?t.replace(/\/index\.md$/i,``):/\.md$/i.test(t)?t.replace(/\.md$/i,``):t.replace(/\/+$/,``):``}function ie(e,t){return e?e.doc&&e.doc.path?`path:`+e.doc.path:e.doc&&e.doc.rel?`rel:`+e.doc.rel:e.docPath?`path:`+e.docPath:e.docRel?`rel:`+e.docRel:t===`repo`&&e.key?`rel:repo/`+e.key+`.md`:``:``}function U(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function W({kind:e,owner:n,model:r}){let{openByDocId:i}=B(r),a=e===`board`?`组介绍`:`项目介绍`,o=e===`board`?n&&(n.id||n.key):n&&n.key,s=n&&n.name,l=(0,N.useMemo)(()=>ie(n,e),[n,e]),[u,d]=(0,N.useState)([]),[f,p]=(0,N.useState)(``),[m,h]=(0,N.useState)(0),g=(0,N.useCallback)(()=>h(e=>e+1),[]);(0,N.useEffect)(()=>{let r=!0;if(!o){d([]);return}if(e===`repo`)t(`/api/repos/docs?id=`+encodeURIComponent(o)).then(e=>{if(!r)return;let t=[],n=U(e.main);p(n||l),n&&t.push({docId:n,label:e.main.rel||e.main.path||`主篇`,note:e.main.note||``,tag:e.main.tag||``,main:!0,ref:e.main.ref||``});for(let n of e.extras||[]){let e=U(n);e&&t.push({docId:e,label:n.name||n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}for(let n of e.links||[]){let e=U(n);e&&t.push({docId:e,label:n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}d(t)}).catch(()=>{r&&(d([]),p(l))});else{let e=()=>{let e=[];l&&e.push({docId:l,label:`主篇`,note:``,tag:``,main:!0,ref:``});for(let t of n?.docLinks||[]){let n=U(t);n&&e.push({docId:n,label:t.rel||t.path||`补充`,note:t.note||``,tag:t.tag||``,main:!1,ref:t.ref||``})}return e};t(`/api/boards/`+encodeURIComponent(String(o))).then(t=>{if(!r)return;let n=Array.isArray(t&&t.docLinks)?t.docLinks:null;if(!n){d(e()),p(l);return}let i=[],a=U(t&&t.introMain)||l;p(a),a&&i.push({docId:a,label:`主篇`,note:``,tag:``,main:!0,ref:``});for(let e of t&&t.introExtras||[]){let t=U(e);t&&i.push({docId:t,label:e.name||e.rel||e.path||`补充`,note:e.note||``,tag:e.tag||``,main:!1,ref:e.ref||``})}for(let e of n){let t=U(e);t&&i.push({docId:t,label:e.rel||e.path||`补充`,note:e.note||``,tag:e.tag||``,main:!1,ref:e.ref||``})}d(i)}).catch(()=>{r&&(d(e()),p(l))})}return()=>{r=!1}},[e,o,n,l,m]);let _=(0,N.useMemo)(()=>e===`repo`&&o?{repoKey:o}:e===`board`&&o?{boardKey:o,boardName:s||``}:{},[e,o,s]);return{kind:e,label:a,ownerKey:o,docRef:l,mainDocId:f,links:u,openMain:(0,N.useCallback)(()=>{let e=f||l;e&&i(e,null,_)},[f,l,i,_]),openDoc:(0,N.useCallback)(e=>i(e,null,_),[i,_]),addRef:(0,N.useCallback)(async(n,r)=>{if(!o||!l.startsWith(`rel:`))return r&&r(`当前简介无法补充(需要自有树路径)`),null;let a=await n({title:`补充介绍文档`,input:!0,tagInput:!0,placeholder:`文档名(如 architecture / api-notes)`,tagPlaceholder:`标签(可选,如 qa)`});if(a===null)return null;let u=typeof a==`string`?a:a&&a.value||``,d=typeof a==`object`&&a&&a.tag||``,f=c(String(u).trim()||`note`).replace(/\.md$/i,``),p=`${H(l)||(e===`repo`?`repo/${o}`:`board/${s||o}`)}/reference/${f}.md`;await t(`/api/docs/item`,{method:`POST`,body:{rel:p,body:`# ${String(u).trim()||f}\n\n(待补)\n`}});try{e===`repo`?await t(`/api/repos/docs`,{method:`POST`,body:{id:o,rel:p,tag:d||void 0}}):await t(`/api/docs/link`,{method:`POST`,body:{board:o,doc:p,tag:d||void 0}})}catch{}return r&&r(`已补充:${p}${d?` [${d}]`:``}`),g(),i(`rel:`+p,null,_),p},[o,l,e,s,i,_,g]),setLinkTag:(0,N.useCallback)(async(n,r,i)=>{if(!o)throw Error(`缺少归属`);let a=String(n||``).startsWith(`path:`)?{path:String(n).slice(5)}:{rel:String(n||``).startsWith(`rel:`)?String(n).slice(4):String(n||``)},s=i&&i.note||``;e===`repo`?await t(`/api/repos/docs`,{method:`POST`,body:{id:o,...a,note:s||void 0,tag:r||void 0}}):await t(`/api/docs/link`,{method:`POST`,body:{board:o,doc:a.path||a.rel,note:s||void 0,tag:r||void 0}}),g()},[o,e,g]),reload:g,canEdit:!!l}}function G(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function K(e){let t=e.rel||e.path||``;return String(t).replace(/[\\/]+$/,``).split(/[\\/]/).pop()||t||`未命名`}function q(e,t,n){let r=[],i=e&&(e.main||e.introMain);i&&r.push({id:G(i),kind:`main`,label:`主篇`,sub:i.rel||i.path||``,tag:``,note:``,docId:G(i),removable:n===`repo`&&!!(t&&t.doc),removeTip:`摘除主篇自定义绑定(回退约定路径,文档不删)`,taggable:!1});for(let t of e&&(e.extras||e.introExtras)||[]){let e=G(t);e&&r.push({id:e,kind:`extra`,label:K(t),sub:t.rel||t.path||``,tag:``,note:``,docId:e,removable:!1,taggable:String(e).startsWith(`rel:`)})}(e&&(e.links||e.docLinks)||[]).forEach((e,t)=>{let i=G(e);i&&r.push({id:i,kind:`link`,label:K(e),sub:e.rel||e.path||``,tag:e.tag||``,note:e.note||``,docId:i,removeIndex:n===`repo`?t+2:t+1,removable:!0,taggable:!0})});for(let e of n===`repo`&&t&&t.boards||[]){let t=e.noteDocPath||``,n=e.noteDocRel||``,i=t?`path:`+t:n?`rel:`+n:``;i&&r.push({id:i,kind:`scoped`,label:`${e.name} · 组内描述`,sub:t||n,tag:``,note:e.note||``,docId:i,removable:!1,taggable:!1})}return r.filter(e=>e.docId)}var ae={main:`● `,scoped:`◇ `,extra:`○ `,link:`○ `};function J({kind:e,owner:a,model:o,onClose:s,onChanged:l}){let u=r(),{dialog:d,node:f}=n(),p=_()||{},m=o||p.model,h=W({kind:e,owner:a,model:m}),v=h.ownerKey,y=a&&a.name,[b,x]=(0,N.useState)([]),[S,C]=(0,N.useState)(!0),[w,T]=(0,N.useState)(``),E=(0,N.useCallback)(async()=>{if(!v){x([]),C(!1);return}C(!0);try{let n=e===`repo`?await t(`/api/repos/docs?id=`+encodeURIComponent(v)):await t(`/api/boards/`+encodeURIComponent(String(v)));x(q(n,a,e)),T(``)}catch(e){x([]),T(String(e.message||e))}finally{C(!1)}},[e,v,a]);(0,N.useEffect)(()=>{E()},[E]);let D=t=>{if(!t)return;let n=m;if(!n){u(`工作区不可用,无法打开文档`);return}g(n,{component:`doc`,name:t.label||t.sub||t.docId,config:{docId:t.docId,...e===`repo`?{repoKey:v}:{boardKey:v,boardName:y||``}},location:`center`}),s()},O=e=>e().catch(e=>u(String(e.message||e))),k=n=>O(async()=>{await d({message:`摘除「${n.label}」?${n.kind===`main`?`(只拆绑定,文档不删)`:`(文档不删,仅移出列表)`}`,danger:!0})&&(e===`repo`?await t(`/api/repos/docs`,{method:`DELETE`,body:{id:v,index:n.removeIndex}}):await t(`/api/docs/link`,{method:`POST`,body:{board:v,remove:n.removeIndex}}),u(`已摘除`),E(),l&&l())}),A=e=>O(async()=>{let t=await d({title:`标签 · ${e.label}`,input:!0,placeholder:`标签(如 qa;留空 = 清掉)`,value:e.tag||``,okText:`保存标签`});if(t===null)return;let n=typeof t==`string`?t:t&&t.tag||``;await h.setLinkTag(e.docId,n,e),u(n?`标签已设为 [${n}]`:`标签已清除`),E(),l&&l()}),j=()=>O(async()=>{if(!v||!String(h.docRef||``).startsWith(`rel:`)){u(`当前简介无法补充(需要自有树路径)`);return}let n=await d({title:`补充介绍文档`,input:!0,tagInput:!0,placeholder:`文档名(如 architecture / api-notes)`,tagPlaceholder:`标签(可选,如 qa)`});if(n===null)return;let r=typeof n==`string`?n:n&&n.value||``,i=typeof n==`object`&&n&&n.tag||``,a=c(String(r).trim()||`note`).replace(/\.md$/i,``),o=`${H(h.docRef)||(e===`repo`?`repo/${v}`:`board/${y||v}`)}/reference/${a}.md`;await t(`/api/docs/item`,{method:`POST`,body:{rel:o,body:`# ${String(r).trim()||a}\n\n(待补)\n`}});try{e===`repo`?await t(`/api/repos/docs`,{method:`POST`,body:{id:v,rel:o,tag:i||void 0}}):await t(`/api/docs/link`,{method:`POST`,body:{board:v,doc:o,tag:i||void 0}})}catch{}u(`已补充:${o}${i?` [${i}]`:``}`),await E(),l&&l(),D({docId:`rel:`+o,label:String(r).trim()||a,sub:o})}),ee=!!String(h.docRef||``).startsWith(`rel:`)&&v,M=b.length,te=`文档列表 · ${y||``}${e===`board`?`(项目组)`:``}`;return(0,F.jsxs)(i,{size:`md`,title:te,onClose:s,children:[(0,F.jsxs)(`div`,{className:`nx-dl`,children:[(0,F.jsxs)(`div`,{className:`nx-dl-head`,children:[(0,F.jsx)(`span`,{className:`nx-dl-count`,children:M?`${M} 篇`:`还没有文档`}),(0,F.jsx)(`span`,{className:`nx-dl-hint`,children:`点标题在主内容区打开`}),(0,F.jsx)(`span`,{className:`grow`}),ee&&(0,F.jsx)(`button`,{type:`button`,className:`btn ghost sm nx-dl-add`,title:`补充一篇介绍文档(reference)`,onClick:j,children:`+ 补充`})]}),w?(0,F.jsx)(`div`,{className:`rpd-err`,children:w}):null,!w&&S&&M===0?(0,F.jsx)(`div`,{className:`rpd-empty`,children:`载入中…`}):null,!w&&!S&&M===0?(0,F.jsx)(`div`,{className:`rpd-none`,children:`还没有文档 —— 点「+ 补充」写第一篇`}):null,(0,F.jsx)(`div`,{className:`nx-dl-list`,children:b.map(e=>(0,F.jsxs)(`div`,{className:`nx-dl-row-wrap`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`nx-dl-row`,title:`${e.sub||e.label}\n点击在主内容区打开(可编辑)`,onClick:()=>D(e),children:[(0,F.jsxs)(`span`,{className:`nx-dl-row-title`,children:[ae[e.kind]||`○ `,e.label]}),e.tag?(0,F.jsx)(`span`,{className:`rpd-badge`,children:e.tag}):null]}),(0,F.jsxs)(`span`,{className:`nx-docs-modal-item-acts`,children:[e.taggable&&(0,F.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini`,title:e.tag?`改标签(当前:${e.tag})`:`加标签`,onClick:()=>A(e),children:`#`}),e.removable&&(0,F.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini danger`,title:e.removeTip||`摘除「${e.label}」(文档不删)`,onClick:()=>k(e),children:`×`})]})]},e.id))})]}),f]})}function Y(e){return e<=1?18:e===2?12:8}function oe({headings:e=[],scrollRoot:t=null,links:n=[],activeDocId:r=``,onOpenDoc:i=null,onAddRef:a=null}){let[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)(``),u=(0,N.useMemo)(()=>e||[],[e]),d=(0,N.useMemo)(()=>n||[],[n]);(0,N.useEffect)(()=>{let e=t;if(!e||!u.length)return;let n=()=>u.map(t=>{let n=e.querySelector(`#${CSS.escape(t.id)}`);if(!n)return null;let r=n.getBoundingClientRect(),i=e.getBoundingClientRect();return{id:t.id,y:r.top-i.top}}).filter(Boolean),r=()=>{let e=n();if(!e.length)return;let t=e[0].id;for(let n of e)n.y<=28&&(t=n.id);l(t)};return r(),e.addEventListener(`scroll`,r,{passive:!0}),()=>e.removeEventListener(`scroll`,r)},[t,u]);let f=(0,N.useCallback)(e=>{let n=t;if(!n)return;let r=n.querySelector(`#${CSS.escape(e)}`);if(!r){n.scrollTo({top:0,behavior:`smooth`}),l(e);return}r.scrollIntoView({behavior:`smooth`,block:`start`}),l(e)},[t]);return!u.length&&!d.length&&!a?null:(0,F.jsxs)(`aside`,{className:`doc-rail`+(o?` open`:``),"aria-label":`文档目录`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:o?`收起目录`:`展开目录`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[(0,F.jsx)(`span`,{}),(0,F.jsx)(`span`,{}),(0,F.jsx)(`span`,{})]}),(0,F.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`章节`,children:u.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(c===e.id?` on`:``),style:{"--tw":`${Y(e.level)}px`},title:e.text,"aria-current":c===e.id?`true`:void 0,onClick:()=>f(e.id)},e.id))}),o&&(0,F.jsxs)(`div`,{className:`doc-rail-panel`,children:[u.length>0&&(0,F.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,F.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`本章`}),u.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`doc-rail-row`+(c===e.id?` on`:``),"data-lv":e.level,onClick:()=>f(e.id),children:e.text},e.id))]}),(d.length>0||a)&&(0,F.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,F.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`介绍文档`}),d.map(e=>(0,F.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(e.docId===r?` on`:``),title:e.note||e.label,disabled:!i,onClick:()=>i&&i(e.docId),children:[e.main?`● `:`○ `,e.label]},e.docId)),a&&(0,F.jsx)(`button`,{type:`button`,className:`doc-rail-add`,onClick:a,children:`+ 补充文档`})]})]})]})}function X({kind:e,owner:t,model:n}){let{label:r,docRef:i,links:a,openMain:o}=W({kind:e,owner:t,model:n}),[s,c]=(0,N.useState)(!1);if(!t||!i)return null;let l=a.find(e=>e.main),u=l?l.docId:i,d=u.startsWith(`rel:`)?u.slice(4):u,f=a.filter(e=>!e.main).length;return(0,F.jsxs)(`div`,{className:`nx-intro`,children:[(0,F.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,F.jsx)(`button`,{type:`button`,className:`nx-intro-link-main`,title:`打开${r}(在主内容区阅读 / 编辑)`,onClick:o,children:r}),(0,F.jsx)(`span`,{className:`nx-intro-path mono`,children:d}),(0,F.jsx)(`span`,{className:`nx-intro-spacer`}),(0,F.jsxs)(`button`,{type:`button`,className:`nx-intro-btn`,title:`查看${r}的全部文章(点标题在主内容区打开,可编辑)`,onClick:()=>c(!0),children:[`查看详情`,f>0?` ${f}`:``]})]}),s&&(0,F.jsx)(J,{kind:e,owner:t,model:n,onClose:()=>c(!1)})]})}export{B as i,J as n,z as r,X as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,v as t,y as n}from"./task-status-BP6y8MVu.js";import{N as r}from"./index-
|
|
1
|
+
import{S as e,v as t,y as n}from"./task-status-BP6y8MVu.js";import{N as r}from"./index-BmANFdAR.js";import{a as i,c as a,l as o,o as s,s as c}from"./tool-bar-BwMNTrR1.js";var l=e(n(),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{S as e,_ as t,c as n,d as r,f as i,g as a,h as o,l as s,v as c,y as l}from"./task-status-BP6y8MVu.js";import{A as u,j as d}from"./index-CLsU9Lad.js";import{a as f,i as p,n as m,t as h}from"./upload-L1g-pfvZ.js";import{t as g}from"./route-crumb-Cyesq6KK.js";var _=e(l(),1),v=c(),y=e=>`/api/file/content/${encodeURIComponent(e)}`;function b({text:e,compact:t=!1,className:r=``}){let i=n(e);return i.some(e=>e.type!==`text`)?(0,v.jsx)(`span`,{className:r?`mdtext ${r}`:`mdtext`,children:i.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:r,children:e})}function x({task:e,pick:n,group:r,onSaved:i,onCancel:o}){let s=a(),[c,l]=(0,_.useState)(e.text||``),[u,d]=(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,l(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 f(t,{group:r,onProgress:(e,t)=>S({done:e,total:t})});k(p(e));let n=e.filter(e=>e.isImage).length;s(e.length===1?`已插入 ${e[0].name}`:`已插入 ${e.length} 个附件${n?`(图片 ${n} 个)`:``}`)}catch(e){s(String(e&&e.message||e))}finally{S(null)}}},j=e=>{let t=h(e);t.length&&(e.preventDefault(),A(t))},M=(0,_.useRef)(null);M.current=e=>A(m(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()){s(`正文不能为空`);return}let a={group:r,ref:e.text,pick:n,matchTopic:e.topic,text:D.current};u!==(e.note||``)&&(a.note=u),y(!0),t(`/api/todo/item`,{method:`PATCH`,body:a}).then(()=>{s(`已保存`),i()}).catch(e=>s(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:u,spellCheck:`false`,placeholder:`可选:完成结果、上下文补充`,onChange:e=>d(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:o,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}=d(),c=a(),l=o(),{dialog:f,node:p}=i(),[m,h]=(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 t(`/api/groups`);h(e.groups||[]),y(``)}catch(e){y(e.message||String(e))}},[]);(0,_.useEffect)(()=>{w()},[w]);let T=n?.groupId??0,E=e=>l(async()=>{let n=await t(`/api/group`,{method:`POST`,body:{locator:e}});c(n.id===0?`已切回默认组`:`已切换到 ${n.name}`),await r(),await w()}),D=()=>l(async()=>{let e=b.name.trim();if(!e){c(`请填名称`);return}let n=await t(`/api/groups`,{method:`POST`,body:{name:e,description:b.description.trim()}});x({name:``,description:``}),c(`已新建工作空间 ${n.name}(id=${n.id})`),await r(),await w()}),O=e=>l(async()=>{let n=await f({title:`重命名「${e.name}」`,input:!0,value:e.name});n!==null&&n.trim()&&(await t(`/api/groups/${e.id}`,{method:`PATCH`,body:{name:n.trim()}}),c(`已更新名称`),await r(),await w())}),k=e=>l(async()=>{await f({message:`解散工作空间「${e.name}」(id=${e.id})?\n\n后端要求组内已无 KV 数据,否则会拒绝。此操作不可撤销。`,danger:!0})&&(await t(`/api/groups/${e.id}`,{method:`DELETE`}),c(`已解散 ${e.name}`),await r(),await w())}),A=e=>l(async()=>{let n=await t(`/api/groups/${e.id}/members`);C({group:n.group,list:n.members||[]})});return n?.loggedIn?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(s,{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:`切到这里`})})]}),m.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(u,{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&&!m.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)(s,{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)(u,{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,p]}):(0,v.jsx)(s,{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:e,task:t,dupCount:n,onAct:i}){let a=e===`done`,o=e===`freeze`,s=a?t.doneAt:o?t.frozenAt:t.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:[`#`,t.id]}),(0,v.jsx)(u,{className:`topic`,text:t.topic,title:`点击复制主题`,children:t.topic}),(0,v.jsx)(`span`,{className:`text`,title:t.text,children:(0,v.jsx)(b,{text:t.text,compact:!0})}),n>1?(0,v.jsxs)(`span`,{className:`tag`,title:`同内容有 ${n} 条,操作时需要消歧`,children:[`同内容×`,n]}):null,(0,v.jsx)(`span`,{className:`muted time`,children:w(s)}),(0,v.jsxs)(`span`,{className:`acts`,children:[e===`open`?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`done`,t),children:`完成`}):null,o?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`unfreeze`,t),children:`解冻`}):null,(0,v.jsx)(r,{items:[e===`open`&&{label:`冻结`,onPick:()=>i(`freeze`,t)},{label:`编辑`,onPick:()=>i(`edit`,t,e)},{label:`删除`,danger:!0,onPick:()=>i(`remove`,t,e)}]})]})]}),t.note?(0,v.jsx)(`div`,{className:`note`,children:t.note}):null]})}function O(){let{boot:e,ui:n,patchUi:r,refreshBoot:c}=d(),l=a(),m=o(),{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=()=>m(async()=>{if(!K.email.trim()){l(`请填邮箱`);return}if(!K.password){l(`请填密码`);return}q(e=>({...e,busy:!0}));try{let e=await t(`/api/auth/login`,{method:`POST`,body:{email:K.email.trim(),password:K.password}});q(e=>({...e,password:``})),l(`已登录: ${e.email}`),await c()}finally{q(e=>({...e,busy:!1}))}}),ne=()=>m(async()=>{await t(`/api/auth/logout`,{method:`POST`}),l(`已登出`),await c()}),Y=(0,_.useCallback)(async()=>{if(e?.loggedIn)try{k(await t(`/api/todo`)),j(``)}catch(e){j(String(e.message||e))}},[e?.loggedIn]);(0,_.useEffect)(()=>{Y()},[Y,G]),(0,_.useEffect)(()=>{t(`/api/setting`).then(W).catch(()=>{})},[]);let X=!!U?.autoSyncAttachments,re=()=>m(async()=>{let e=!X,n=await t(`/api/setting`,{method:`POST`,body:{autoSyncAttachments:e}});W(n),l(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{S as e,_ as t,c as n,d as r,f as i,g as a,h as o,l as s,v as c,y as l}from"./task-status-BP6y8MVu.js";import{A as u,j as d}from"./index-BmANFdAR.js";import{a as f,i as p,n as m,t as h}from"./upload-L1g-pfvZ.js";import{t as g}from"./route-crumb-DHYbpsO8.js";var _=e(l(),1),v=c(),y=e=>`/api/file/content/${encodeURIComponent(e)}`;function b({text:e,compact:t=!1,className:r=``}){let i=n(e);return i.some(e=>e.type!==`text`)?(0,v.jsx)(`span`,{className:r?`mdtext ${r}`:`mdtext`,children:i.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:r,children:e})}function x({task:e,pick:n,group:r,onSaved:i,onCancel:o}){let s=a(),[c,l]=(0,_.useState)(e.text||``),[u,d]=(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,l(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 f(t,{group:r,onProgress:(e,t)=>S({done:e,total:t})});k(p(e));let n=e.filter(e=>e.isImage).length;s(e.length===1?`已插入 ${e[0].name}`:`已插入 ${e.length} 个附件${n?`(图片 ${n} 个)`:``}`)}catch(e){s(String(e&&e.message||e))}finally{S(null)}}},j=e=>{let t=h(e);t.length&&(e.preventDefault(),A(t))},M=(0,_.useRef)(null);M.current=e=>A(m(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()){s(`正文不能为空`);return}let a={group:r,ref:e.text,pick:n,matchTopic:e.topic,text:D.current};u!==(e.note||``)&&(a.note=u),y(!0),t(`/api/todo/item`,{method:`PATCH`,body:a}).then(()=>{s(`已保存`),i()}).catch(e=>s(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:u,spellCheck:`false`,placeholder:`可选:完成结果、上下文补充`,onChange:e=>d(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:o,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}=d(),c=a(),l=o(),{dialog:f,node:p}=i(),[m,h]=(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 t(`/api/groups`);h(e.groups||[]),y(``)}catch(e){y(e.message||String(e))}},[]);(0,_.useEffect)(()=>{w()},[w]);let T=n?.groupId??0,E=e=>l(async()=>{let n=await t(`/api/group`,{method:`POST`,body:{locator:e}});c(n.id===0?`已切回默认组`:`已切换到 ${n.name}`),await r(),await w()}),D=()=>l(async()=>{let e=b.name.trim();if(!e){c(`请填名称`);return}let n=await t(`/api/groups`,{method:`POST`,body:{name:e,description:b.description.trim()}});x({name:``,description:``}),c(`已新建工作空间 ${n.name}(id=${n.id})`),await r(),await w()}),O=e=>l(async()=>{let n=await f({title:`重命名「${e.name}」`,input:!0,value:e.name});n!==null&&n.trim()&&(await t(`/api/groups/${e.id}`,{method:`PATCH`,body:{name:n.trim()}}),c(`已更新名称`),await r(),await w())}),k=e=>l(async()=>{await f({message:`解散工作空间「${e.name}」(id=${e.id})?\n\n后端要求组内已无 KV 数据,否则会拒绝。此操作不可撤销。`,danger:!0})&&(await t(`/api/groups/${e.id}`,{method:`DELETE`}),c(`已解散 ${e.name}`),await r(),await w())}),A=e=>l(async()=>{let n=await t(`/api/groups/${e.id}/members`);C({group:n.group,list:n.members||[]})});return n?.loggedIn?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(s,{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:`切到这里`})})]}),m.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(u,{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&&!m.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)(s,{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)(u,{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,p]}):(0,v.jsx)(s,{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:e,task:t,dupCount:n,onAct:i}){let a=e===`done`,o=e===`freeze`,s=a?t.doneAt:o?t.frozenAt:t.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:[`#`,t.id]}),(0,v.jsx)(u,{className:`topic`,text:t.topic,title:`点击复制主题`,children:t.topic}),(0,v.jsx)(`span`,{className:`text`,title:t.text,children:(0,v.jsx)(b,{text:t.text,compact:!0})}),n>1?(0,v.jsxs)(`span`,{className:`tag`,title:`同内容有 ${n} 条,操作时需要消歧`,children:[`同内容×`,n]}):null,(0,v.jsx)(`span`,{className:`muted time`,children:w(s)}),(0,v.jsxs)(`span`,{className:`acts`,children:[e===`open`?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`done`,t),children:`完成`}):null,o?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`unfreeze`,t),children:`解冻`}):null,(0,v.jsx)(r,{items:[e===`open`&&{label:`冻结`,onPick:()=>i(`freeze`,t)},{label:`编辑`,onPick:()=>i(`edit`,t,e)},{label:`删除`,danger:!0,onPick:()=>i(`remove`,t,e)}]})]})]}),t.note?(0,v.jsx)(`div`,{className:`note`,children:t.note}):null]})}function O(){let{boot:e,ui:n,patchUi:r,refreshBoot:c}=d(),l=a(),m=o(),{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=()=>m(async()=>{if(!K.email.trim()){l(`请填邮箱`);return}if(!K.password){l(`请填密码`);return}q(e=>({...e,busy:!0}));try{let e=await t(`/api/auth/login`,{method:`POST`,body:{email:K.email.trim(),password:K.password}});q(e=>({...e,password:``})),l(`已登录: ${e.email}`),await c()}finally{q(e=>({...e,busy:!1}))}}),ne=()=>m(async()=>{await t(`/api/auth/logout`,{method:`POST`}),l(`已登出`),await c()}),Y=(0,_.useCallback)(async()=>{if(e?.loggedIn)try{k(await t(`/api/todo`)),j(``)}catch(e){j(String(e.message||e))}},[e?.loggedIn]);(0,_.useEffect)(()=>{Y()},[Y,G]),(0,_.useEffect)(()=>{t(`/api/setting`).then(W).catch(()=>{})},[]);let X=!!U?.autoSyncAttachments,re=()=>m(async()=>{let e=!X,n=await t(`/api/setting`,{method:`POST`,body:{autoSyncAttachments:e}});W(n),l(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]?(l(`请输入 0..${n.length-1}`),null):{...n[a],pick:a}},oe=(e,n,r)=>m(async()=>{let i=e===`remove`||e===`edit`?await ae(n,r):{bucket:r,task:n,pick:void 0};if(!i)return;let a={group:G,ref:i.task.text,pick:i.pick};if(e===`done`){let e=await y({title:`完成结果`,message:`完成「${n.text.slice(0,40)}」`,input:!0,placeholder:`可选:写一句完成结果`});if(e===null)return;await t(`/api/todo/done`,{method:`POST`,body:{...a,result:e||void 0}}),l(`已完成`)}else if(e===`freeze`)await t(`/api/todo/freeze`,{method:`POST`,body:a}),l(`已冻结`);else if(e===`unfreeze`)await t(`/api/todo/unfreeze`,{method:`POST`,body:a}),l(`已解冻`);else if(e===`remove`){if(!await y({message:`删除「${n.text.slice(0,40)}」?`,danger:!0}))return;await t(`/api/todo/item`,{method:`DELETE`,body:a}),l(`已删除`)}else if(e===`edit`){H({task:i.task,pick:i.pick});return}await Z(),await c()}),se=()=>m(async()=>{let e=await y({title:`归档已完成的旧记录`,message:`把「完成时间早于该日期」的记录移到冷 key(默认 30 天前)。留空用默认值。`,input:!0,placeholder:`YYYY-MM-DD,留空 = 30 天前`});if(e===null)return;let n=await t(`/api/todo/archive`,{method:`POST`,body:{before:e.trim()||void 0,group:G}});l(n.moved?`已归档 ${n.moved} 条 → ${n.coldKey}`:`没有需要归档的记录`),await Z()}),ce=async e=>{let t=h(e);if(t.length){e.preventDefault();try{let e=await f(t,{group:G}),n=p(e);F(e=>({...e,text:[e.text,n].filter(Boolean).join(` `)})),l(e.length===1?`已上传 ${e[0].name} 并附到内容里`:`已上传 ${e.length} 个附件并附到内容里`)}catch(e){l(String(e&&e.message||e))}}},$=()=>m(async()=>{let e=P.topic.trim(),n=P.text.trim();if(!e){l(`请填主题`);return}if(!n){l(`请填内容`);return}let r=await t(`/api/todo`,{method:`POST`,body:{topic:e,text:n,group:G}});F({topic:e,text:``}),l(`已加入待办${r.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)(u,{text:e?.baseUrl,children:e?.baseUrl})}),(0,v.jsx)(`dt`,{children:`本机配置`}),(0,v.jsx)(`dd`,{className:`mono`,children:(0,v.jsx)(u,{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)(s,{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)(s,{title:I.title,size:`lg`,onClose:()=>L(null),children:I.node}):null,b]})}export{O as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as e,v as t}from"./task-status-BP6y8MVu.js";import{O as n,w as r}from"./index-BmANFdAR.js";import{a as i}from"./upload-L1g-pfvZ.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})}),(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(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,t={}){let n=[...e||[]];if(!n.length)return{items:[],imageInserts:[],fileInserts:[]};try{let e=await i(n,{...t.group?{group:t.group}:{},local:!0}),r=[],a=[],o=[];for(let t of e){let e=t.fileId||t.id,n=!!t.isImage;r.push({id:e,name:t.name,type:n?`image`:`file`,size:d(Number(t.size)||0),url:`/api/file/content/${e}`});let i=t.markdown||{},s=n?i.image||``:i.file||`[${t.name}](${e})`;(n?a:o).push(`\n${s}\n`)}return{items:r,imageInserts:a,fileInserts:o}}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=r(e);return h.set(f,{onSubmit:u,onFiles:d,prev:p}),n(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=r(e);return a&&a.component!==`compose`?null:n(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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,g as t,p as n,v as r,y as i}from"./task-status-BP6y8MVu.js";import{i as a}from"./md-parse-C2bDc3IZ.js";import{E as o,k as s}from"./index-BmANFdAR.js";import{t as c}from"./md-panes-sRhT7DNc.js";import{i as l,o as u,r as d,t as f}from"./composer-launch-DFD4_RlG.js";var p=e(i(),1),m=r(),h=96;function g({token:e,mode:r=`comment`,quote:i=``,prevQuote:g=``,taskLabel:_=``,taskTitle:v=``,src:y=null}){let b=s()||{},x=t(),[S,C]=(0,p.useState)(``),[w,T]=(0,p.useState)([]),[E,D]=(0,p.useState)(!1),O=(0,p.useRef)(null),k=r===`feedback`,A=()=>{d(b.model,e)},j=async()=>{let t=String(S||``).trim();if(!t&&!w.length){x(k?`写一下要改的地方`:`写一下要提的问题`);return}let n=f(e);if(!n||!n.onSubmit){x(`提交入口已失效(来源页面已关闭)`);return}D(!0);try{await n.onSubmit({text:t,attachments:w,inserts:``}),A()}catch(e){x(String(e.message||e))}finally{D(!1)}},M=async e=>{if(!e||!e.length)return;let{items:t,imageInserts:n,fileInserts:r}=await l(e),i=[...n,...r].join(``);i&&C(e=>a(e,i,{}).body),t.length&&T(e=>[...e,...t])},N=(0,p.useRef)(null),[P,F]=(0,p.useState)(()=>localStorage.getItem(`nxkv.cmpDockOpen`)!==`0`),[I,L]=(0,p.useState)(()=>{let e=Number(localStorage.getItem(`nxkv.cmpDockH`));return Number.isFinite(e)&&e>=h?e:176}),R=(0,p.useRef)(I);R.current=I;let[z,B]=(0,p.useState)(!1),V=(0,p.useRef)(176);(0,p.useEffect)(()=>{localStorage.setItem(`nxkv.cmpDockOpen`,P?`1`:`0`)},[P]);let H=()=>{if(z){L(V.current),B(!1);return}V.current=I;let e=document.querySelector(`.cmp`)?.clientHeight||window.innerHeight;L(Math.max(h,Math.round(e*.62))),B(!0)},U=e=>{if(!P)return;e.preventDefault(),B(!1);let t=e.clientY,n=R.current,r=e=>Math.max(h,Math.min(Math.round(e),Math.round((document.querySelector(`.cmp`)?.clientHeight||window.innerHeight)*.62))),i=e=>{R.current=r(n-(e.clientY-t)),L(R.current)},a=()=>{window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(`nxkv.cmpDockH`,String(R.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)},W=()=>{let e=b.model;e&&y&&y.task&&o(e,{component:`page`,name:y.name||`原文`,config:{dirKey:y.dirKey,task:String(y.task)}})},G=!!(y&&y.task);return(0,m.jsxs)(`div`,{className:`cmp`,children:[(0,m.jsxs)(`div`,{className:`cmp-head`,children:[(0,m.jsx)(`span`,{className:`cmp-tag`+(k?` is-fb`:``),children:k?`反馈`:`评论`}),(0,m.jsx)(`div`,{className:`cmp-ctx`,children:k?(0,m.jsxs)(`span`,{className:`cmp-ctx-line`,title:v||``,children:[`反馈 `,_||``,` 的任务`,v?` · ${v}`:``]}):(0,m.jsx)(`span`,{className:`cmp-ctx-line`,children:`对本任务提出问题`})}),(0,m.jsx)(`span`,{className:`grow`}),(0,m.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:A,disabled:E,children:`关闭`}),(0,m.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:j,disabled:E,children:k?`提交反馈`:`提交评论`})]}),k?(0,m.jsxs)(`div`,{className:`cmp-quote-wrap`,children:[(0,m.jsxs)(`div`,{className:`cmp-quote-cap`,children:[`之前的引用`,G&&(0,m.jsx)(`button`,{type:`button`,className:`cmp-quote-cmp`,onClick:W,title:`在右侧并排显示原文,方便对照`,children:`对照原文 ↗`})]}),G?(0,m.jsx)(`button`,{type:`button`,className:`cmp-quote`,onClick:W,title:`点击在右侧并排显示原文,方便对照`,children:g||`(这条任务还没有可引用的上轮总结)`}):(0,m.jsx)(`div`,{className:`cmp-quote`,children:g||`(这条任务还没有可引用的上轮总结)`})]}):i?(0,m.jsxs)(`div`,{className:`cmp-quote-wrap`,children:[(0,m.jsxs)(`div`,{className:`cmp-quote-cap`,children:[`引用`,G&&(0,m.jsx)(`button`,{type:`button`,className:`cmp-quote-cmp`,onClick:W,title:`在右侧并排显示原文,方便对照`,children:`对照原文 ↗`})]}),G?(0,m.jsx)(`button`,{type:`button`,className:`cmp-quote`,onClick:W,title:`点击在右侧并排显示原文,方便对照`,children:i}):(0,m.jsx)(`div`,{className:`cmp-quote`,children:i})]}):null,(0,m.jsx)(`div`,{className:`cmp-body`,children:(0,m.jsx)(c,{mode:`split`,title:``,body:S,onTitle:()=>{},onBody:C,attachments:w,docKey:`compose-`+e,editorApiRef:O,onFiles:M,onSave:j,hideTitle:!0})}),P&&(0,m.jsxs)(`div`,{className:`mdw-dock`,style:{height:`${I}px`},children:[(0,m.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:U,onDoubleClick:H}),(0,m.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,m.jsx)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:(0,m.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":`true`,className:`mdw-dock-tab is-on`,onClick:()=>F(!0),children:[`附件`,w.length?(0,m.jsx)(`span`,{className:`mdw-dock-tab-num`,children:w.length}):null]})}),(0,m.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,m.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,title:`添加附件`,"aria-label":`添加附件`,onClick:()=>N.current?.click(),children:(0,m.jsx)(n,{name:`plus`})}),(0,m.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:H,title:z?`还原面板高度`:`最大化面板高度`,"aria-label":z?`还原面板高度`:`最大化面板高度`,children:(0,m.jsx)(n,{name:z?`collapse`:`expand`})}),(0,m.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>F(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,m.jsx)(n,{name:`x`})})]})]}),(0,m.jsx)(`div`,{className:`mdw-dock-body`,children:w.length?(0,m.jsx)(u,{attachments:w,onRemove:e=>T(t=>t.filter(t=>t.id!==e))}):(0,m.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有附件——粘贴 / 拖图片进正文即附件,或点右上「+」添加文件。`})})]}),(0,m.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,m.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${P?` is-on`:``}`,onClick:()=>F(e=>!e),title:`附件(点击展开/收起信息面板)`,children:[(0,m.jsx)(n,{name:`list`}),(0,m.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`}),w.length?(0,m.jsx)(`span`,{className:`mdw-sbar-num`,children:w.length}):null]}),(0,m.jsx)(`span`,{className:`mdw-sbar-grow`}),(0,m.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${P?` is-open`:``}`,onClick:()=>F(e=>!e),title:P?`收起信息面板`:`展开信息面板`,"aria-expanded":P,"aria-label":P?`收起信息面板`:`展开信息面板`,children:(0,m.jsx)(n,{name:`chevron`})})]}),(0,m.jsx)(`input`,{ref:N,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&M(t)}})]})}export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,_ as t,f as n,g as r,p as i,u as a,v as o,y as s}from"./task-status-BP6y8MVu.js";import{g as c,h as l}from"./md-parse-C2bDc3IZ.js";import{r as ee}from"./board-view-t8CKtq17.js";import{k as te,x as ne}from"./index-CLsU9Lad.js";import{t as re}from"./graph-DM-zDRdL.js";var u=e(s(),1),d=o(),f=280,ie=94,p=56,m=28,ae=320,oe=6,h=``;function g(e){return e&&!e.deletedAt&&!e.migratedTo}function _(e){return g(e)&&e.status===`pending`}function se(e){return l(e.text)||ne(e)||`#${e.id}`}function v(e,t){return`${e}:${Number(t)}`}function y(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return{kind:`local`,id:Math.trunc(e)};let t=String(e??``).trim();if(!t)return null;let n=/^([A-Za-z0-9_-]+):(\d+)$/.exec(t);if(n)return{kind:`foreign`,key:n[1],id:Number(n[2])};if(/^\d+$/.test(t)){let e=Number(t);if(e>0)return{kind:`local`,id:e}}return null}function b(e,t){let n=y(e);return n?n.kind===`foreign`?v(n.key,n.id):v(t,n.id):null}function ce(e,t){return e.topicKey===t?Number(e.id):v(e.topicKey,e.id)}function le(e,t={}){let n=Math.max(3,Number(t.perCol)||8),r=new Map;for(let t of e)r.has(t.topicKey)||r.set(t.topicKey,[]),r.get(t.topicKey).push(t);let i=new Map,a=0;for(let[,e]of r)e.forEach((e,t)=>{let r=a+Math.floor(t/n),o=t%n;i.set(e.nodeKey,{x:p+r*ae,y:m+o*ie})}),a+=Math.ceil(e.length/n);return i}var x=e=>`nx-kv-dag-pos:${e}`;function ue(e){try{let t=JSON.parse(localStorage.getItem(x(e))||`{}`),n=new Map;for(let[e,r]of Object.entries(t||{}))Array.isArray(r)&&Number.isFinite(r[0])&&Number.isFinite(r[1])&&n.set(e,{x:r[0],y:r[1]});return n}catch{return new Map}}function de(e,t){try{let n={};for(let[e,r]of t)r&&Number.isFinite(r.x)&&Number.isFinite(r.y)&&(n[e]=[Math.round(r.x),Math.round(r.y)]);return localStorage.setItem(x(e),JSON.stringify(n)),!0}catch{return!1}}function fe(e,t,n,r){let i=Math.max(48,Math.abs(n-e)*.5);return`M ${e} ${t} C ${e+i} ${t}, ${n-i} ${r}, ${n} ${r}`}function S(e,t,n){let r=e.getBoundingClientRect();return{x:t-r.left+e.scrollLeft,y:n-r.top+e.scrollTop}}function C({dirKey:e,groupId:o}){let s=te()||{},l=r(),{dialog:ne,node:ae}=n(),g=s.rows||[],C=s.refreshLocal,w=(0,u.useId)().replace(/:/g,``),pe=s.repoData&&s.repoData.boards||[],T=(0,u.useMemo)(()=>pe.find(e=>e.id===o||e.key===o)||null,[pe,o]),E=!!T,D=(0,u.useMemo)(()=>{if(!T)return[];let e=[];for(let t of T.repos||[]){let n=g.find(e=>e.repo&&e.repo.key===t.key);if(!n)continue;let r=[T.id,T.key,T.name].filter(Boolean),i=(n.tasks||[]).filter(e=>{if(!_(e))return!1;let t=c(e.text);return t.board&&r.includes(t.board)});i.length&&e.push({key:n.key,name:t.name||t.key,cwd:n.cwd,isGlobal:!!n.isGlobal,count:i.length,total:i.length})}return e},[T,g]),[O,k]=(0,u.useState)(h);(0,u.useEffect)(()=>{E||k(h)},[E,o]);let A=(0,u.useMemo)(()=>E?null:g.find(t=>t.key===e)||null,[E,g,e]),j=(0,u.useMemo)(()=>{if(E){let e=[T.id,T.key,T.name].filter(Boolean),t=[];for(let n of T.repos||[]){let r=g.find(e=>e.repo&&e.repo.key===n.key);if(r&&!(O&&r.key!==O))for(let i of r.tasks||[]){if(!_(i))continue;let a=c(i.text);a.board&&e.includes(a.board)&&t.push({...i,topicKey:r.key,topicCwd:r.cwd,topicIsGlobal:!!r.isGlobal,projectName:n.name||n.key,nodeKey:v(r.key,i.id)})}}return t}return A?(A.tasks||[]).filter(e=>_(e)&&!ee(e)).map(e=>({...e,topicKey:A.key,topicCwd:A.cwd,topicIsGlobal:!!A.isGlobal,projectName:A.name||A.key,nodeKey:v(A.key,e.id)})):[]},[E,T,g,O,A]),M=(0,u.useMemo)(()=>new Map(j.map(e=>[e.nodeKey,e])),[j]),N=(0,u.useRef)(M);N.current=M;let me=(0,u.useRef)(j);me.current=j;let P=(0,u.useRef)(null),[F,I]=(0,u.useState)(()=>new Map),L=(0,u.useRef)(F);L.current=F;let[he,ge]=(0,u.useState)(0);(0,u.useEffect)(()=>{let e=P.current;if(!e)return;let t=()=>ge(e.clientHeight||0);t();let n=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[]);let R=Math.max(3,Math.floor(((he||720)-56)/ie)||8),z=E?`g:${T?.id||o||``}`:`d:${e||``}`,B=(0,u.useRef)(z);B.current=z;let _e=(0,u.useMemo)(()=>ue(z),[z]),ve=(0,u.useRef)(z),V=(0,u.useRef)(new Set);(0,u.useEffect)(()=>{let e=ve.current!==z;ve.current=z,I(t=>{let n=new Map,r=le(j,{perCol:R});for(let i of j){let a=_e.get(i.nodeKey)||(!e&&V.current.has(i.nodeKey)?t.get(i.nodeKey):null)||r.get(i.nodeKey)||{x:p,y:m};n.set(i.nodeKey,a)}return n})},[j,R,_e,z]);let H=(0,u.useRef)(null),[U,ye]=(0,u.useState)(null),[W,G]=(0,u.useState)(null),[K,be]=(0,u.useState)(null),[xe,Se]=(0,u.useState)(!1),q=(0,u.useRef)(!1);q.current=xe;let J=(0,u.useRef)(async()=>!1),Y=(0,u.useRef)(l);Y.current=l;let X=async(e,n,r)=>{Se(!0);try{let i={...n};Array.isArray(i.blockBy)&&(i.blockBy=i.blockBy.join(`,`));let a=e.topicIsGlobal?{key:e.topicKey}:{cwd:e.topicCwd};await t(`/api/localtasks/item`,{method:`PATCH`,body:{...a,id:Number(e.id),...i}}),r&&l(r),C&&await C()}catch(e){l(String(e.message||e))}finally{Se(!1)}},Ce=(e,t)=>{let n=P.current;if(!n)return null;let{x:r,y:i}=S(n,e,t),a=me.current;for(let e=a.length-1;e>=0;e--){let t=a[e].nodeKey,o=L.current.get(t);if(!o)continue;let s=n.querySelector(`[data-node-id="${CSS.escape(t)}"]`),c=s?s.offsetHeight:64;if(r>=o.x-10&&r<=o.x+f+28&&i>=o.y-6&&i<=o.y+c+6)return t}return null},we=e=>{let t=P.current,n=L.current.get(e)||{x:0,y:0},r=t?.querySelector(`[data-node-id="${CSS.escape(e)}"]`),i=r?r.offsetHeight:64;return{x:n.x+f,y:n.y+i/2}},Te=e=>{if(!e||e.kind!==`link`){G(null);return}G({sourceId:e.sourceId,x:e.x1,y:e.y1,cx:e.cx,cy:e.cy,overId:e.overId,dragged:!!e.dragged})},Z=()=>{H.current=null,ye(null),G(null)};J.current=async(e,t)=>{if(!t||t===e)return!1;let n=N.current.get(e),r=N.current.get(t);if(!n||!r||!_(r))return Y.current(`只能连到待领取任务`),!1;if(r.blocksFollowing)return Y.current(`#${r.id} 是闸门,不能声明上游`),!1;let i=ce(n,r.topicKey),a=[...r.blockBy||[]];if(a.some(e=>{let t=y(e),n=y(i);return!t||!n||t.kind!==n.kind?!1:(t.kind===`local`||t.key===n.key)&&t.id===n.id}))return Y.current(`已有该有向边`),!1;if(re(e=>{let t=N.current.get(e);if(!t)return[];let n=[];for(let e of t.blockBy||[]){let r=b(e,t.topicKey);r&&N.current.has(r)&&n.push(r)}return n},e,t))return Y.current(`会形成环,已取消`),!1;let o=n.topicKey!==r.topicKey;return await X(r,{blockBy:[...a,i]},o?`#${n.id}@${n.projectName} → #${r.id}@${r.projectName}`:`#${n.id} → #${r.id}`),!0},(0,u.useEffect)(()=>{let e=e=>{let t=H.current;if(!t)return;let n=P.current;if(!n)return;let r=S(n,e.clientX,e.clientY);if(t.kind===`drag`){let e=Math.max(8,r.x-t.ox),n=Math.max(8,r.y-t.oy);I(r=>{let i=new Map(r);return i.set(t.id,{x:e,y:n}),i});return}if(t.kind===`link`){let n=Ce(e.clientX,e.clientY),i=n&&n!==t.sourceId?n:null,a=Math.hypot(r.x-t.sx,r.y-t.sy),o=t.dragged||a>=oe,s={...t,cx:r.x,cy:r.y,overId:i,dragged:o};H.current=s,Te(s)}},t=async e=>{let t=H.current;if(t){if(t.kind===`drag`){V.current.add(t.id),de(B.current,L.current),Z();return}if(t.kind===`link`){let n=t.overId||Ce(e.clientX,e.clientY),r=t.sourceId;if(n&&n!==r){Z(),await J.current(r,n);return}if(t.dragged){Z();return}let i=N.current.get(r);Y.current(`已选 #${i?.id??r},再点目标画出有向边`)}}},n=e=>{e.key===`Escape`&&Z()};return window.addEventListener(`pointermove`,e),window.addEventListener(`mousemove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`mouseup`,t),window.addEventListener(`pointercancel`,Z),window.addEventListener(`keydown`,n),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`mousemove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`mouseup`,t),window.removeEventListener(`pointercancel`,Z),window.removeEventListener(`keydown`,n)}},[]);let Ee=(e,t)=>{if(q.current||e.button!==0||e.target.closest(`.dagp-port, .dagp-ops, .dagp-chip, button, a`))return;let n=H.current;if(n&&n.kind===`link`){if(e.preventDefault(),e.stopPropagation(),t.nodeKey===n.sourceId){Z();return}if(!_(t)){Y.current(`只能连到待领取任务`);return}let r=n.sourceId;Z(),J.current(r,t.nodeKey);return}if(H.current||!_(t))return;e.preventDefault();let r=P.current;if(!r)return;let i=L.current.get(t.nodeKey)||{x:0,y:0},a=S(r,e.clientX,e.clientY);H.current={kind:`drag`,id:t.nodeKey,ox:a.x-i.x,oy:a.y-i.y},ye(t.nodeKey)},De=(e,t)=>{if(q.current||!_(t)||e.button!==0)return;if(e.preventDefault(),e.stopPropagation(),H.current?.kind===`link`&&H.current.sourceId===t.nodeKey){Z();return}let n=we(t.nodeKey),r=P.current,i=r?S(r,e.clientX,e.clientY):{x:n.x,y:n.y},a={kind:`link`,sourceId:t.nodeKey,x1:n.x,y1:n.y,cx:i.x,cy:i.y,overId:null,dragged:!1,sx:i.x,sy:i.y};H.current=a,Te(a)},Oe=e=>{H.current&&H.current.kind===`link`&&(e.target.closest(`.dagp-node`)||Z())},ke=async(e,t)=>{let n=[...e.blockBy||[]].filter(e=>{let n=y(e),r=y(t);return!n||!r?String(e)!==String(t):n.kind===r.kind?n.kind===`local`?n.id!==r.id:n.key!==r.key||n.id!==r.id:!0});await X(e,{blockBy:n},`已解除依赖 → #${e.id}`)},Ae=e=>X(e,{gate:!e.blocksFollowing},e.blocksFollowing?`#${e.id} 取消闸门`:`#${e.id} 设为闸门`),je=async e=>{let t=await ne({title:`时间目标 · #${e.id}`,input:!0,placeholder:`如 2h / 90m`,value:e.timegoal?.duration||``});if(t==null)return;let n=String(t).trim();if(!n){await X(e,{clearGoal:!0},`#${e.id} 已清除时间目标`);return}await X(e,{duration:n},`#${e.id} 时间目标 ${n}`)},Me=e=>{s.openPage&&(o?s.openPage({groupId:o,task:String(e.id),name:`#${e.id}`}):s.openPage({dirKey:e.topicKey,task:String(e.id),name:`#${e.id}`}))},Ne=(0,u.useMemo)(()=>{let e=[];for(let t of j){let n=F.get(t.nodeKey);if(!n)continue;let r=P.current?.querySelector(`[data-node-id="${CSS.escape(t.nodeKey)}"]`),i=r?r.offsetHeight:64;for(let r of t.blockBy||[]){let a=b(r,t.topicKey);if(!a||!M.has(a))continue;let o=F.get(a);if(!o)continue;let s=P.current?.querySelector(`[data-node-id="${CSS.escape(a)}"]`),c=s?s.offsetHeight:64,l=n.x>o.x+f-8;e.push({from:a,to:t.nodeKey,x1:l?o.x+f:o.x,y1:o.y+c/2,x2:l?n.x:n.x+f,y2:n.y+i/2})}}return e},[j,F,M,U,W]),Q=(0,u.useMemo)(()=>{let e=480,t=240;for(let n of j){let r=F.get(n.nodeKey);r&&(e=Math.max(e,r.x+f+100),t=Math.max(t,r.y+140))}return W&&(e=Math.max(e,W.cx+40),t=Math.max(t,W.cy+40)),{w:e,h:t}},[j,F,W]),Pe=E?T?.name||`组编排`:A?.name||e||`编排`,Fe=()=>{try{localStorage.removeItem(x(B.current))}catch{}V.current.clear(),I(le(j,{perCol:R})),l(`已恢复默认布局`)},$=!!W,Ie=W?M.get(W.sourceId)?.id??W.sourceId:``;return(0,d.jsxs)(`div`,{className:`dagp`+($?` is-linking`:``)+(U==null?``:` is-dragging`),children:[(0,d.jsxs)(`div`,{className:`dagp-head`,children:[(0,d.jsx)(`span`,{className:`dagp-title`,children:Pe}),(0,d.jsxs)(`span`,{className:`dagp-count`,children:[j.length,` 个待领取节点`]}),(0,d.jsx)(`span`,{className:`dagp-hint`,children:$?`连线中:再点目标完成 #${Ie} → 目标(Esc 取消)`:E?`组内全量任务;跨项目连线对 get 生效;未连线走各队列默认序`:`点右侧 ● 再点目标 = 有向顺序;未连线 = 无先后、走默认序`}),E&&D.length>0&&(0,d.jsxs)(`span`,{className:`dagp-queues`,children:[(0,d.jsxs)(`button`,{type:`button`,className:`dagp-queue`+(O===h?` on`:``),onClick:()=>k(h),children:[`全部`,(0,d.jsx)(`i`,{children:D.reduce((e,t)=>e+t.total,0)})]}),D.map(e=>(0,d.jsxs)(`button`,{type:`button`,className:`dagp-queue`+(e.key===O?` on`:``),title:`${e.name} · ${e.count}/${e.total}`,onClick:()=>k(e.key),children:[e.name,(0,d.jsx)(`i`,{children:e.count})]},e.key))]}),(0,d.jsx)(`button`,{type:`button`,className:`dagp-reset`,onClick:Fe,title:`清掉记住的摆位,按默认分栏重排`,children:`恢复默认布局`})]}),(0,d.jsxs)(`div`,{className:`dagp-canvas`,ref:P,onPointerDown:Oe,children:[(0,d.jsxs)(`svg`,{className:`dagp-edges`,width:Q.w,height:Q.h,style:{width:Q.w,height:Q.h},"aria-hidden":`true`,children:[(0,d.jsx)(`defs`,{children:(0,d.jsx)(`marker`,{id:`dagp-arrow-${w}`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,d.jsx)(`path`,{d:`M0 0 L10 5 L0 10 z`,fill:`var(--mdw-accent, #2F6F5E)`})})}),Ne.map(e=>(0,d.jsx)(`path`,{className:`dagp-edge`,d:fe(e.x1,e.y1,e.x2,e.y2),markerEnd:`url(#dagp-arrow-${w})`},`${e.from}->${e.to}`)),W&&(0,d.jsx)(`path`,{className:`dagp-edge preview`,d:fe(W.x,W.y,W.cx,W.cy),markerEnd:`url(#dagp-arrow-${w})`})]}),(0,d.jsx)(`div`,{className:`dagp-nodes`,style:{width:Q.w,height:Q.h},children:j.map(e=>{let t=F.get(e.nodeKey)||{x:p,y:m},n=(e.blockBy||[]).map(t=>({token:t,key:b(t,e.topicKey)})).filter(e=>e.key&&M.has(e.key)),r=W&&W.overId===e.nodeKey,a=W&&W.sourceId===e.nodeKey;return(0,d.jsxs)(`div`,{"data-node-id":e.nodeKey,className:`dagp-node`+(U===e.nodeKey?` dragging`:``)+(r?` over`:``)+(a?` linking-src`:``)+(e.blocksFollowing?` gate`:``)+($&&!a?` link-target`:``),style:{transform:`translate(${t.x}px, ${t.y}px)`,width:f},onPointerDown:t=>Ee(t,e),children:[(0,d.jsx)(`span`,{className:`dagp-port in`,title:`入:箭头指向我 = 我等对方`,"aria-hidden":`true`}),(0,d.jsxs)(`div`,{className:`dagp-body`,children:[(0,d.jsxs)(`div`,{className:`dagp-top`,children:[(0,d.jsxs)(`span`,{className:`dagp-no mono`,children:[`#`,e.id]}),E&&(0,d.jsx)(`span`,{className:`dagp-chip proj`,children:e.projectName}),e.blocksFollowing&&(0,d.jsx)(`span`,{className:`dagp-chip gate`,children:`闸门`}),e.ready===!1&&(0,d.jsx)(`span`,{className:`dagp-chip lock`,children:`锁定`}),e.timegoal?.duration&&(0,d.jsxs)(`span`,{className:`dagp-chip goal`,children:[`⏱ `,e.timegoal.duration]}),(0,d.jsx)(`button`,{type:`button`,className:`dagp-ops`,title:`节点操作`,"aria-label":`节点操作`,onClick:t=>{t.stopPropagation();let n=[{label:`打开任务`,onClick:()=>Me(e)},{label:e.blocksFollowing?`取消闸门`:`设为闸门(挡住后续)`,onClick:()=>Ae(e)},{label:e.timegoal?.duration?`改时间目标`:`加时间目标(timegoal)`,onClick:()=>je(e)}],r=t.currentTarget.getBoundingClientRect();be({x:r.left,y:r.bottom,items:n})},children:(0,d.jsx)(i,{name:`dots`,size:13})})]}),(0,d.jsx)(`div`,{className:`dagp-name`,title:e.text,onDoubleClick:t=>{t.stopPropagation(),Me(e)},children:se(e)}),n.length>0&&(0,d.jsx)(`div`,{className:`dagp-deps`,children:n.map(({token:t,key:n})=>{let r=M.get(n),i=r&&r.topicKey!==e.topicKey;return(0,d.jsxs)(`span`,{className:`dagp-chip dep`,title:i?`跨项目 #${r.id}@${r.projectName} → #${e.id}`:`#${r?.id} → #${e.id}`,children:[`← #`,r?.id,i?`@${r.projectName}`:``,(0,d.jsx)(`i`,{role:`button`,"aria-label":`解除依赖`,onClick:n=>{n.stopPropagation(),ke(e,t)},children:`×`})]},String(t))})})]}),(0,d.jsx)(`button`,{type:`button`,className:`dagp-port out`,title:`点一下再点目标,或按住拖到目标 = 有向顺序(可跨项目)`,"aria-label":`从 #${e.id} 开始连线`,onPointerDown:t=>De(t,e)})]},e.nodeKey)})}),!j.length&&(0,d.jsx)(`div`,{className:`dagp-empty`,children:E?`本组还没有带 board 归属的任务。连线可跨项目,对 get 生效。`:`这个队列没有任务。连线是编排里唯一的顺序关系;不连就保持默认序。`})]}),K&&(0,d.jsx)(a,{x:K.x,y:K.y,items:K.items,onClose:()=>be(null)}),ae]})}export{C as default};
|
|
1
|
+
import{S as e,_ as t,f as n,g as r,p as i,u as a,v as o,y as s}from"./task-status-BP6y8MVu.js";import{g as c,h as l}from"./md-parse-C2bDc3IZ.js";import{r as ee}from"./board-view-t8CKtq17.js";import{k as te,x as ne}from"./index-BmANFdAR.js";import{t as re}from"./graph-DM-zDRdL.js";var u=e(s(),1),d=o(),f=280,ie=94,p=56,m=28,ae=320,oe=6,h=``;function g(e){return e&&!e.deletedAt&&!e.migratedTo}function _(e){return g(e)&&e.status===`pending`}function se(e){return l(e.text)||ne(e)||`#${e.id}`}function v(e,t){return`${e}:${Number(t)}`}function y(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return{kind:`local`,id:Math.trunc(e)};let t=String(e??``).trim();if(!t)return null;let n=/^([A-Za-z0-9_-]+):(\d+)$/.exec(t);if(n)return{kind:`foreign`,key:n[1],id:Number(n[2])};if(/^\d+$/.test(t)){let e=Number(t);if(e>0)return{kind:`local`,id:e}}return null}function b(e,t){let n=y(e);return n?n.kind===`foreign`?v(n.key,n.id):v(t,n.id):null}function ce(e,t){return e.topicKey===t?Number(e.id):v(e.topicKey,e.id)}function le(e,t={}){let n=Math.max(3,Number(t.perCol)||8),r=new Map;for(let t of e)r.has(t.topicKey)||r.set(t.topicKey,[]),r.get(t.topicKey).push(t);let i=new Map,a=0;for(let[,e]of r)e.forEach((e,t)=>{let r=a+Math.floor(t/n),o=t%n;i.set(e.nodeKey,{x:p+r*ae,y:m+o*ie})}),a+=Math.ceil(e.length/n);return i}var x=e=>`nx-kv-dag-pos:${e}`;function ue(e){try{let t=JSON.parse(localStorage.getItem(x(e))||`{}`),n=new Map;for(let[e,r]of Object.entries(t||{}))Array.isArray(r)&&Number.isFinite(r[0])&&Number.isFinite(r[1])&&n.set(e,{x:r[0],y:r[1]});return n}catch{return new Map}}function de(e,t){try{let n={};for(let[e,r]of t)r&&Number.isFinite(r.x)&&Number.isFinite(r.y)&&(n[e]=[Math.round(r.x),Math.round(r.y)]);return localStorage.setItem(x(e),JSON.stringify(n)),!0}catch{return!1}}function fe(e,t,n,r){let i=Math.max(48,Math.abs(n-e)*.5);return`M ${e} ${t} C ${e+i} ${t}, ${n-i} ${r}, ${n} ${r}`}function S(e,t,n){let r=e.getBoundingClientRect();return{x:t-r.left+e.scrollLeft,y:n-r.top+e.scrollTop}}function C({dirKey:e,groupId:o}){let s=te()||{},l=r(),{dialog:ne,node:ae}=n(),g=s.rows||[],C=s.refreshLocal,w=(0,u.useId)().replace(/:/g,``),pe=s.repoData&&s.repoData.boards||[],T=(0,u.useMemo)(()=>pe.find(e=>e.id===o||e.key===o)||null,[pe,o]),E=!!T,D=(0,u.useMemo)(()=>{if(!T)return[];let e=[];for(let t of T.repos||[]){let n=g.find(e=>e.repo&&e.repo.key===t.key);if(!n)continue;let r=[T.id,T.key,T.name].filter(Boolean),i=(n.tasks||[]).filter(e=>{if(!_(e))return!1;let t=c(e.text);return t.board&&r.includes(t.board)});i.length&&e.push({key:n.key,name:t.name||t.key,cwd:n.cwd,isGlobal:!!n.isGlobal,count:i.length,total:i.length})}return e},[T,g]),[O,k]=(0,u.useState)(h);(0,u.useEffect)(()=>{E||k(h)},[E,o]);let A=(0,u.useMemo)(()=>E?null:g.find(t=>t.key===e)||null,[E,g,e]),j=(0,u.useMemo)(()=>{if(E){let e=[T.id,T.key,T.name].filter(Boolean),t=[];for(let n of T.repos||[]){let r=g.find(e=>e.repo&&e.repo.key===n.key);if(r&&!(O&&r.key!==O))for(let i of r.tasks||[]){if(!_(i))continue;let a=c(i.text);a.board&&e.includes(a.board)&&t.push({...i,topicKey:r.key,topicCwd:r.cwd,topicIsGlobal:!!r.isGlobal,projectName:n.name||n.key,nodeKey:v(r.key,i.id)})}}return t}return A?(A.tasks||[]).filter(e=>_(e)&&!ee(e)).map(e=>({...e,topicKey:A.key,topicCwd:A.cwd,topicIsGlobal:!!A.isGlobal,projectName:A.name||A.key,nodeKey:v(A.key,e.id)})):[]},[E,T,g,O,A]),M=(0,u.useMemo)(()=>new Map(j.map(e=>[e.nodeKey,e])),[j]),N=(0,u.useRef)(M);N.current=M;let me=(0,u.useRef)(j);me.current=j;let P=(0,u.useRef)(null),[F,I]=(0,u.useState)(()=>new Map),L=(0,u.useRef)(F);L.current=F;let[he,ge]=(0,u.useState)(0);(0,u.useEffect)(()=>{let e=P.current;if(!e)return;let t=()=>ge(e.clientHeight||0);t();let n=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[]);let R=Math.max(3,Math.floor(((he||720)-56)/ie)||8),z=E?`g:${T?.id||o||``}`:`d:${e||``}`,B=(0,u.useRef)(z);B.current=z;let _e=(0,u.useMemo)(()=>ue(z),[z]),ve=(0,u.useRef)(z),V=(0,u.useRef)(new Set);(0,u.useEffect)(()=>{let e=ve.current!==z;ve.current=z,I(t=>{let n=new Map,r=le(j,{perCol:R});for(let i of j){let a=_e.get(i.nodeKey)||(!e&&V.current.has(i.nodeKey)?t.get(i.nodeKey):null)||r.get(i.nodeKey)||{x:p,y:m};n.set(i.nodeKey,a)}return n})},[j,R,_e,z]);let H=(0,u.useRef)(null),[U,ye]=(0,u.useState)(null),[W,G]=(0,u.useState)(null),[K,be]=(0,u.useState)(null),[xe,Se]=(0,u.useState)(!1),q=(0,u.useRef)(!1);q.current=xe;let J=(0,u.useRef)(async()=>!1),Y=(0,u.useRef)(l);Y.current=l;let X=async(e,n,r)=>{Se(!0);try{let i={...n};Array.isArray(i.blockBy)&&(i.blockBy=i.blockBy.join(`,`));let a=e.topicIsGlobal?{key:e.topicKey}:{cwd:e.topicCwd};await t(`/api/localtasks/item`,{method:`PATCH`,body:{...a,id:Number(e.id),...i}}),r&&l(r),C&&await C()}catch(e){l(String(e.message||e))}finally{Se(!1)}},Ce=(e,t)=>{let n=P.current;if(!n)return null;let{x:r,y:i}=S(n,e,t),a=me.current;for(let e=a.length-1;e>=0;e--){let t=a[e].nodeKey,o=L.current.get(t);if(!o)continue;let s=n.querySelector(`[data-node-id="${CSS.escape(t)}"]`),c=s?s.offsetHeight:64;if(r>=o.x-10&&r<=o.x+f+28&&i>=o.y-6&&i<=o.y+c+6)return t}return null},we=e=>{let t=P.current,n=L.current.get(e)||{x:0,y:0},r=t?.querySelector(`[data-node-id="${CSS.escape(e)}"]`),i=r?r.offsetHeight:64;return{x:n.x+f,y:n.y+i/2}},Te=e=>{if(!e||e.kind!==`link`){G(null);return}G({sourceId:e.sourceId,x:e.x1,y:e.y1,cx:e.cx,cy:e.cy,overId:e.overId,dragged:!!e.dragged})},Z=()=>{H.current=null,ye(null),G(null)};J.current=async(e,t)=>{if(!t||t===e)return!1;let n=N.current.get(e),r=N.current.get(t);if(!n||!r||!_(r))return Y.current(`只能连到待领取任务`),!1;if(r.blocksFollowing)return Y.current(`#${r.id} 是闸门,不能声明上游`),!1;let i=ce(n,r.topicKey),a=[...r.blockBy||[]];if(a.some(e=>{let t=y(e),n=y(i);return!t||!n||t.kind!==n.kind?!1:(t.kind===`local`||t.key===n.key)&&t.id===n.id}))return Y.current(`已有该有向边`),!1;if(re(e=>{let t=N.current.get(e);if(!t)return[];let n=[];for(let e of t.blockBy||[]){let r=b(e,t.topicKey);r&&N.current.has(r)&&n.push(r)}return n},e,t))return Y.current(`会形成环,已取消`),!1;let o=n.topicKey!==r.topicKey;return await X(r,{blockBy:[...a,i]},o?`#${n.id}@${n.projectName} → #${r.id}@${r.projectName}`:`#${n.id} → #${r.id}`),!0},(0,u.useEffect)(()=>{let e=e=>{let t=H.current;if(!t)return;let n=P.current;if(!n)return;let r=S(n,e.clientX,e.clientY);if(t.kind===`drag`){let e=Math.max(8,r.x-t.ox),n=Math.max(8,r.y-t.oy);I(r=>{let i=new Map(r);return i.set(t.id,{x:e,y:n}),i});return}if(t.kind===`link`){let n=Ce(e.clientX,e.clientY),i=n&&n!==t.sourceId?n:null,a=Math.hypot(r.x-t.sx,r.y-t.sy),o=t.dragged||a>=oe,s={...t,cx:r.x,cy:r.y,overId:i,dragged:o};H.current=s,Te(s)}},t=async e=>{let t=H.current;if(t){if(t.kind===`drag`){V.current.add(t.id),de(B.current,L.current),Z();return}if(t.kind===`link`){let n=t.overId||Ce(e.clientX,e.clientY),r=t.sourceId;if(n&&n!==r){Z(),await J.current(r,n);return}if(t.dragged){Z();return}let i=N.current.get(r);Y.current(`已选 #${i?.id??r},再点目标画出有向边`)}}},n=e=>{e.key===`Escape`&&Z()};return window.addEventListener(`pointermove`,e),window.addEventListener(`mousemove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`mouseup`,t),window.addEventListener(`pointercancel`,Z),window.addEventListener(`keydown`,n),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`mousemove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`mouseup`,t),window.removeEventListener(`pointercancel`,Z),window.removeEventListener(`keydown`,n)}},[]);let Ee=(e,t)=>{if(q.current||e.button!==0||e.target.closest(`.dagp-port, .dagp-ops, .dagp-chip, button, a`))return;let n=H.current;if(n&&n.kind===`link`){if(e.preventDefault(),e.stopPropagation(),t.nodeKey===n.sourceId){Z();return}if(!_(t)){Y.current(`只能连到待领取任务`);return}let r=n.sourceId;Z(),J.current(r,t.nodeKey);return}if(H.current||!_(t))return;e.preventDefault();let r=P.current;if(!r)return;let i=L.current.get(t.nodeKey)||{x:0,y:0},a=S(r,e.clientX,e.clientY);H.current={kind:`drag`,id:t.nodeKey,ox:a.x-i.x,oy:a.y-i.y},ye(t.nodeKey)},De=(e,t)=>{if(q.current||!_(t)||e.button!==0)return;if(e.preventDefault(),e.stopPropagation(),H.current?.kind===`link`&&H.current.sourceId===t.nodeKey){Z();return}let n=we(t.nodeKey),r=P.current,i=r?S(r,e.clientX,e.clientY):{x:n.x,y:n.y},a={kind:`link`,sourceId:t.nodeKey,x1:n.x,y1:n.y,cx:i.x,cy:i.y,overId:null,dragged:!1,sx:i.x,sy:i.y};H.current=a,Te(a)},Oe=e=>{H.current&&H.current.kind===`link`&&(e.target.closest(`.dagp-node`)||Z())},ke=async(e,t)=>{let n=[...e.blockBy||[]].filter(e=>{let n=y(e),r=y(t);return!n||!r?String(e)!==String(t):n.kind===r.kind?n.kind===`local`?n.id!==r.id:n.key!==r.key||n.id!==r.id:!0});await X(e,{blockBy:n},`已解除依赖 → #${e.id}`)},Ae=e=>X(e,{gate:!e.blocksFollowing},e.blocksFollowing?`#${e.id} 取消闸门`:`#${e.id} 设为闸门`),je=async e=>{let t=await ne({title:`时间目标 · #${e.id}`,input:!0,placeholder:`如 2h / 90m`,value:e.timegoal?.duration||``});if(t==null)return;let n=String(t).trim();if(!n){await X(e,{clearGoal:!0},`#${e.id} 已清除时间目标`);return}await X(e,{duration:n},`#${e.id} 时间目标 ${n}`)},Me=e=>{s.openPage&&(o?s.openPage({groupId:o,task:String(e.id),name:`#${e.id}`}):s.openPage({dirKey:e.topicKey,task:String(e.id),name:`#${e.id}`}))},Ne=(0,u.useMemo)(()=>{let e=[];for(let t of j){let n=F.get(t.nodeKey);if(!n)continue;let r=P.current?.querySelector(`[data-node-id="${CSS.escape(t.nodeKey)}"]`),i=r?r.offsetHeight:64;for(let r of t.blockBy||[]){let a=b(r,t.topicKey);if(!a||!M.has(a))continue;let o=F.get(a);if(!o)continue;let s=P.current?.querySelector(`[data-node-id="${CSS.escape(a)}"]`),c=s?s.offsetHeight:64,l=n.x>o.x+f-8;e.push({from:a,to:t.nodeKey,x1:l?o.x+f:o.x,y1:o.y+c/2,x2:l?n.x:n.x+f,y2:n.y+i/2})}}return e},[j,F,M,U,W]),Q=(0,u.useMemo)(()=>{let e=480,t=240;for(let n of j){let r=F.get(n.nodeKey);r&&(e=Math.max(e,r.x+f+100),t=Math.max(t,r.y+140))}return W&&(e=Math.max(e,W.cx+40),t=Math.max(t,W.cy+40)),{w:e,h:t}},[j,F,W]),Pe=E?T?.name||`组编排`:A?.name||e||`编排`,Fe=()=>{try{localStorage.removeItem(x(B.current))}catch{}V.current.clear(),I(le(j,{perCol:R})),l(`已恢复默认布局`)},$=!!W,Ie=W?M.get(W.sourceId)?.id??W.sourceId:``;return(0,d.jsxs)(`div`,{className:`dagp`+($?` is-linking`:``)+(U==null?``:` is-dragging`),children:[(0,d.jsxs)(`div`,{className:`dagp-head`,children:[(0,d.jsx)(`span`,{className:`dagp-title`,children:Pe}),(0,d.jsxs)(`span`,{className:`dagp-count`,children:[j.length,` 个待领取节点`]}),(0,d.jsx)(`span`,{className:`dagp-hint`,children:$?`连线中:再点目标完成 #${Ie} → 目标(Esc 取消)`:E?`组内全量任务;跨项目连线对 get 生效;未连线走各队列默认序`:`点右侧 ● 再点目标 = 有向顺序;未连线 = 无先后、走默认序`}),E&&D.length>0&&(0,d.jsxs)(`span`,{className:`dagp-queues`,children:[(0,d.jsxs)(`button`,{type:`button`,className:`dagp-queue`+(O===h?` on`:``),onClick:()=>k(h),children:[`全部`,(0,d.jsx)(`i`,{children:D.reduce((e,t)=>e+t.total,0)})]}),D.map(e=>(0,d.jsxs)(`button`,{type:`button`,className:`dagp-queue`+(e.key===O?` on`:``),title:`${e.name} · ${e.count}/${e.total}`,onClick:()=>k(e.key),children:[e.name,(0,d.jsx)(`i`,{children:e.count})]},e.key))]}),(0,d.jsx)(`button`,{type:`button`,className:`dagp-reset`,onClick:Fe,title:`清掉记住的摆位,按默认分栏重排`,children:`恢复默认布局`})]}),(0,d.jsxs)(`div`,{className:`dagp-canvas`,ref:P,onPointerDown:Oe,children:[(0,d.jsxs)(`svg`,{className:`dagp-edges`,width:Q.w,height:Q.h,style:{width:Q.w,height:Q.h},"aria-hidden":`true`,children:[(0,d.jsx)(`defs`,{children:(0,d.jsx)(`marker`,{id:`dagp-arrow-${w}`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,d.jsx)(`path`,{d:`M0 0 L10 5 L0 10 z`,fill:`var(--mdw-accent, #2F6F5E)`})})}),Ne.map(e=>(0,d.jsx)(`path`,{className:`dagp-edge`,d:fe(e.x1,e.y1,e.x2,e.y2),markerEnd:`url(#dagp-arrow-${w})`},`${e.from}->${e.to}`)),W&&(0,d.jsx)(`path`,{className:`dagp-edge preview`,d:fe(W.x,W.y,W.cx,W.cy),markerEnd:`url(#dagp-arrow-${w})`})]}),(0,d.jsx)(`div`,{className:`dagp-nodes`,style:{width:Q.w,height:Q.h},children:j.map(e=>{let t=F.get(e.nodeKey)||{x:p,y:m},n=(e.blockBy||[]).map(t=>({token:t,key:b(t,e.topicKey)})).filter(e=>e.key&&M.has(e.key)),r=W&&W.overId===e.nodeKey,a=W&&W.sourceId===e.nodeKey;return(0,d.jsxs)(`div`,{"data-node-id":e.nodeKey,className:`dagp-node`+(U===e.nodeKey?` dragging`:``)+(r?` over`:``)+(a?` linking-src`:``)+(e.blocksFollowing?` gate`:``)+($&&!a?` link-target`:``),style:{transform:`translate(${t.x}px, ${t.y}px)`,width:f},onPointerDown:t=>Ee(t,e),children:[(0,d.jsx)(`span`,{className:`dagp-port in`,title:`入:箭头指向我 = 我等对方`,"aria-hidden":`true`}),(0,d.jsxs)(`div`,{className:`dagp-body`,children:[(0,d.jsxs)(`div`,{className:`dagp-top`,children:[(0,d.jsxs)(`span`,{className:`dagp-no mono`,children:[`#`,e.id]}),E&&(0,d.jsx)(`span`,{className:`dagp-chip proj`,children:e.projectName}),e.blocksFollowing&&(0,d.jsx)(`span`,{className:`dagp-chip gate`,children:`闸门`}),e.ready===!1&&(0,d.jsx)(`span`,{className:`dagp-chip lock`,children:`锁定`}),e.timegoal?.duration&&(0,d.jsxs)(`span`,{className:`dagp-chip goal`,children:[`⏱ `,e.timegoal.duration]}),(0,d.jsx)(`button`,{type:`button`,className:`dagp-ops`,title:`节点操作`,"aria-label":`节点操作`,onClick:t=>{t.stopPropagation();let n=[{label:`打开任务`,onClick:()=>Me(e)},{label:e.blocksFollowing?`取消闸门`:`设为闸门(挡住后续)`,onClick:()=>Ae(e)},{label:e.timegoal?.duration?`改时间目标`:`加时间目标(timegoal)`,onClick:()=>je(e)}],r=t.currentTarget.getBoundingClientRect();be({x:r.left,y:r.bottom,items:n})},children:(0,d.jsx)(i,{name:`dots`,size:13})})]}),(0,d.jsx)(`div`,{className:`dagp-name`,title:e.text,onDoubleClick:t=>{t.stopPropagation(),Me(e)},children:se(e)}),n.length>0&&(0,d.jsx)(`div`,{className:`dagp-deps`,children:n.map(({token:t,key:n})=>{let r=M.get(n),i=r&&r.topicKey!==e.topicKey;return(0,d.jsxs)(`span`,{className:`dagp-chip dep`,title:i?`跨项目 #${r.id}@${r.projectName} → #${e.id}`:`#${r?.id} → #${e.id}`,children:[`← #`,r?.id,i?`@${r.projectName}`:``,(0,d.jsx)(`i`,{role:`button`,"aria-label":`解除依赖`,onClick:n=>{n.stopPropagation(),ke(e,t)},children:`×`})]},String(t))})})]}),(0,d.jsx)(`button`,{type:`button`,className:`dagp-port out`,title:`点一下再点目标,或按住拖到目标 = 有向顺序(可跨项目)`,"aria-label":`从 #${e.id} 开始连线`,onPointerDown:t=>De(t,e)})]},e.nodeKey)})}),!j.length&&(0,d.jsx)(`div`,{className:`dagp-empty`,children:E?`本组还没有带 board 归属的任务。连线可跨项目,对 get 生效。`:`这个队列没有任务。连线是编排里唯一的顺序关系;不连就保持默认序。`})]}),K&&(0,d.jsx)(a,{x:K.x,y:K.y,items:K.items,onClose:()=>be(null)}),ae]})}export{C as default};
|