nx-kv 0.40.0 → 0.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/package.json +1 -1
- package/src/web/frontend/components/tool-acts/modules.js +0 -1
- package/src/web/frontend/page/dir/landing.jsx +35 -12
- package/src/web/frontend/page/group/index.jsx +38 -12
- package/src/web/public/assets/{Introduction-Dz6JUjs7.js → Introduction-DKqRmABL.js} +1 -1
- package/src/web/public/assets/{bar-C95bXkAE.js → bar-B8QJ4EnF.js} +1 -1
- package/src/web/public/assets/{cloud-B5EObOPY.js → cloud-C2O_1vT5.js} +1 -1
- package/src/web/public/assets/{composer-launch-D0MUtp6u.js → composer-launch-BgMj0T3Y.js} +1 -1
- package/src/web/public/assets/{composer-panel-BpW1BVuK.js → composer-panel-C5XUApWJ.js} +1 -1
- package/src/web/public/assets/{dag-CHvtd_PQ.js → dag-CWAWk_gt.js} +1 -1
- package/src/web/public/assets/dir-Cu5B5z6J.js +5 -0
- package/src/web/public/assets/group-YA-FgKS3.js +1 -0
- package/src/web/public/assets/{index-BeGocDOb.js → index-DxX-ZzRP.js} +2 -2
- package/src/web/public/assets/{md-history-D5mjpcvB.js → md-history-4sXoj4RH.js} +1 -1
- package/src/web/public/assets/{overview-C4kvGxQr.js → overview-B788GcJE.js} +1 -1
- package/src/web/public/assets/{progress-BqRr4gHs.js → progress-CfzFVSDu.js} +1 -1
- package/src/web/public/assets/{refs-BdYuMEC9.js → refs-qtxw66hp.js} +1 -1
- package/src/web/public/assets/{repos-B7vMLk-r.js → repos-CpVuGaP2.js} +1 -1
- package/src/web/public/assets/{route-crumb-BvdNu1Cv.js → route-crumb-B8oEN8BB.js} +1 -1
- package/src/web/public/assets/{settings-CKV-GJz-.js → settings-BmWNBqcv.js} +1 -1
- package/src/web/public/assets/{status-tag-BwvnpOcq.js → status-tag-BPbfa4zt.js} +1 -1
- package/src/web/public/assets/{task-rkRFb-i7.js → task-DsFCNaOJ.js} +1 -1
- package/src/web/public/assets/{templates-BLUGen5v.js → templates-4Xaj2m9L.js} +1 -1
- package/src/web/public/assets/tool-bar-CfBWzhpV.js +1 -0
- package/src/web/public/index.html +1 -1
- package/src/web/public/assets/dir-CpoSQtqr.js +0 -5
- package/src/web/public/assets/group-BUvNFFF7.js +0 -1
- package/src/web/public/assets/tool-bar-BsIIjB5L.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -32,6 +32,16 @@
|
|
|
32
32
|
- 存储版本 v3 → v4:新增 `group_refs` 表,存量 ext_linked 绑定迁移到组级。
|
|
33
33
|
旧库自动迁移,无需手工操作。
|
|
34
34
|
|
|
35
|
+
## [0.40.1] - 2026-11-10 新建任务按钮拆两级命中区
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
|
|
39
|
+
- **新建按钮拆成两级(#161)**:group / dir 的「新建任务」按钮**视觉上仍是一颗**,
|
|
40
|
+
但命中区分两层——主区点击 = **按默认模板直接新建**;按钮内嵌箭头区 = 模板下拉
|
|
41
|
+
(选模板新建)。组页此前整颗钮点击只开下拉,目录页则是「新建页」+ 独立「模板 ▾」
|
|
42
|
+
两颗钮——现统一为拆分钮(目录页的独立模板钮移除,其下拉内容并入箭头区)。
|
|
43
|
+
工具区模块表随之移除 `tpl` 项(旧布局里存过的 id 由 normalizeLayout 丢弃)。
|
|
44
|
+
|
|
35
45
|
## [0.39.1] - 2026-11-09 验证确认版
|
|
36
46
|
|
|
37
47
|
- 零代码变更:0.39.0 的交付上下文「倒序聚焦 + 历史精简」经现场验证确认生效
|
package/package.json
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
export const DIR_MODULES = [
|
|
8
8
|
{ id: 'new', label: '+ 新建页', section: 'primary', noHide: true },
|
|
9
|
-
{ id: 'tpl', label: '模板', section: 'bar' },
|
|
10
9
|
{ id: 'import', label: '导入', section: 'bar' },
|
|
11
10
|
{ id: 'progress', label: '进程', section: 'bar' },
|
|
12
11
|
{ id: 'orch', label: '编排', section: 'bar' },
|
|
@@ -166,25 +166,48 @@ export default function Landing({
|
|
|
166
166
|
deleted: deletedCount > 0 ? `已删除任务(${deletedCount})` : '已删除任务',
|
|
167
167
|
}}
|
|
168
168
|
titles={{
|
|
169
|
-
|
|
169
|
+
new: '按默认模板新建一页(▾ 选模板)',
|
|
170
170
|
import: '把一个 .md 文件导入成任务',
|
|
171
171
|
progress: '打开这个目录的进程面板',
|
|
172
|
-
orch: '打开可视化编排面板',
|
|
173
172
|
more: deletedCount > 0 ? `更多操作(含 ${deletedCount} 条已删除任务)` : '更多操作',
|
|
174
173
|
deleted: '查看并恢复已删除任务',
|
|
175
174
|
refs: '查看文档 / reference 列表',
|
|
176
175
|
}}
|
|
177
176
|
renderers={{
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
177
|
+
// #161 新建按钮拆两级(视觉一颗按钮、命中区两层):
|
|
178
|
+
// 主区点击 = 按默认模板直接新建;内嵌箭头 = 模板下拉(tplMenuItems)
|
|
179
|
+
new: () => (
|
|
180
|
+
<span className="rp-newtask">
|
|
181
|
+
<button
|
|
182
|
+
type="button"
|
|
183
|
+
className="btn small primary"
|
|
184
|
+
title="按默认模板新建一页(▾ 选模板)"
|
|
185
|
+
onClick={() => onNew()}
|
|
186
|
+
>
|
|
187
|
+
+ 新建页
|
|
188
|
+
<span
|
|
189
|
+
role="button"
|
|
190
|
+
tabIndex={0}
|
|
191
|
+
aria-label="选择模板新建一页"
|
|
192
|
+
aria-haspopup="menu"
|
|
193
|
+
className="rp-newtask-caret"
|
|
194
|
+
title="选择模板新建一页"
|
|
195
|
+
onClick={(e) => {
|
|
196
|
+
e.stopPropagation();
|
|
197
|
+
onTplMenu?.(e);
|
|
198
|
+
}}
|
|
199
|
+
onKeyDown={(e) => {
|
|
200
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
e.stopPropagation();
|
|
203
|
+
onTplMenu?.(e);
|
|
204
|
+
}
|
|
205
|
+
}}
|
|
206
|
+
>
|
|
207
|
+
<Icon name="chevron" size={11} />
|
|
208
|
+
</span>
|
|
209
|
+
</button>
|
|
210
|
+
</span>
|
|
188
211
|
),
|
|
189
212
|
}}
|
|
190
213
|
actions={{
|
|
@@ -310,24 +310,50 @@ export default function GroupView({ dirKey, rows, repoData, model }) {
|
|
|
310
310
|
renderers={{
|
|
311
311
|
new: () => (
|
|
312
312
|
<div className="rp-newtask" ref={newtaskRef}>
|
|
313
|
+
{/* #161 拆两级命中区(视觉一颗按钮):主区点击 = 按默认模板直接
|
|
314
|
+
新建;内嵌箭头 = 模板下拉(选择模板新建) */}
|
|
313
315
|
<button
|
|
314
316
|
type="button"
|
|
315
317
|
className={'btn small' + (tplFlyOpen ? ' is-open' : '')}
|
|
316
|
-
|
|
317
|
-
aria-expanded={tplFlyOpen}
|
|
318
|
-
title="选择模板新建任务(携带本组语义;MD 编辑页里可选归属项目)"
|
|
318
|
+
title="按默认模板新建任务(▾ 选模板;携带本组语义)"
|
|
319
319
|
disabled={!sel}
|
|
320
|
-
onClick={(
|
|
321
|
-
const r = e.currentTarget.getBoundingClientRect();
|
|
322
|
-
setTplFlyPos({
|
|
323
|
-
top: r.bottom + 6,
|
|
324
|
-
right: Math.max(8, window.innerWidth - r.right),
|
|
325
|
-
});
|
|
326
|
-
setTplFlyOpen((v) => !v);
|
|
327
|
-
}}
|
|
320
|
+
onClick={() => createTask('')}
|
|
328
321
|
>
|
|
329
322
|
+ 新增任务
|
|
330
|
-
<
|
|
323
|
+
<span
|
|
324
|
+
role="button"
|
|
325
|
+
tabIndex={sel ? 0 : undefined}
|
|
326
|
+
aria-label="选择模板新建任务"
|
|
327
|
+
aria-haspopup="menu"
|
|
328
|
+
aria-expanded={tplFlyOpen}
|
|
329
|
+
className={'rp-newtask-caret' + (tplFlyOpen ? ' rot' : '')}
|
|
330
|
+
title="选择模板新建任务"
|
|
331
|
+
onClick={(e) => {
|
|
332
|
+
e.stopPropagation();
|
|
333
|
+
const host = e.currentTarget.closest('.rp-newtask');
|
|
334
|
+
const r = (host || e.currentTarget).getBoundingClientRect();
|
|
335
|
+
setTplFlyPos({
|
|
336
|
+
top: r.bottom + 6,
|
|
337
|
+
right: Math.max(8, window.innerWidth - r.right),
|
|
338
|
+
});
|
|
339
|
+
setTplFlyOpen((v) => !v);
|
|
340
|
+
}}
|
|
341
|
+
onKeyDown={(e) => {
|
|
342
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
343
|
+
e.preventDefault();
|
|
344
|
+
e.stopPropagation();
|
|
345
|
+
const host = e.currentTarget.closest('.rp-newtask');
|
|
346
|
+
const r = (host || e.currentTarget).getBoundingClientRect();
|
|
347
|
+
setTplFlyPos({
|
|
348
|
+
top: r.bottom + 6,
|
|
349
|
+
right: Math.max(8, window.innerWidth - r.right),
|
|
350
|
+
});
|
|
351
|
+
setTplFlyOpen((v) => !v);
|
|
352
|
+
}
|
|
353
|
+
}}
|
|
354
|
+
>
|
|
355
|
+
<Icon name="chevron" size={11} />
|
|
356
|
+
</span>
|
|
331
357
|
</button>
|
|
332
358
|
{tplFlyOpen &&
|
|
333
359
|
sel &&
|
|
@@ -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-BeGocDOb.js";import{a as v,i as y,n as b,r as x,t as S,u as C}from"./md-history-D5mjpcvB.js";import{a as w,i as ee}from"./upload-L1g-pfvZ.js";import{t as T}from"./route-crumb-BvdNu1Cv.js";import{a as E,c as D,i as O,l as k,o as A,r as j,s as M,t as N,u as te}from"./tool-bar-BsIIjB5L.js";var P=e(s(),1),F=h(),I=a(),L=`doc`,R=[{id:`edit`,label:`编辑`},{id:`doc`,label:`文档`},{id:`view`,label:`查看`}];function ne({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=O(),{layout:f,setLayout:p}=A(L),[m,h]=(0,P.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=>k(L,e)&&_(e.id)),y=f.filter(e=>M(L,e)&&_(e.id)),b=e=>{g[e]?.run?.(),d.setOpen(!1)},x=e=>{if(e===`more`)return(0,I.jsx)(`div`,{className:`docp-more`,ref:d.ref,children:(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm${d.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":d.open,onClick:e=>j(d,e,`right`),children:`更多`})},`more`);let t=g[e];return t?(0,I.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||D(L,e).label||e},e):null},S=R.map(e=>({...e,items:y.filter(t=>D(L,t.id).menuGroup===e.id)})).filter(e=>e.items.length),C=y.filter(e=>!D(L,e.id).menuGroup);return i?(0,I.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,I.jsxs)(`div`,{className:`mdw-head`,children:[(0,I.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,I.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,I.jsx)(`span`,{className:`grow`}),u,(0,I.jsxs)(`div`,{className:`docp-actions`,children:[v.map(e=>x(e.id)),(0,I.jsxs)(N,{menu:d,className:`mdw-act-menu`,children:[S.map(e=>(0,I.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,I.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=g[e.id],n=t?.danger||D(L,e.id).danger;return(0,I.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>b(e.id),children:[t?.label||D(L,e.id).label||e.id,t?.hint?(0,I.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),C.map(e=>{let t=g[e.id];return(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||D(L,e.id).danger?` danger`:``),onClick:()=>b(e.id),children:t?.label||D(L,e.id).label||e.id},e.id)}),(0,I.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{d.setOpen(!1),h(!0)},children:`自定义工具栏…`})]})]})]}),m&&(0,F.createPortal)((0,I.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>h(!1),children:(0,I.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,I.jsx)(E,{kind:L,layout:f,setLayout:p,onClose:()=>h(!1)})})}),document.body)]}):(0,I.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,I.jsxs)(`div`,{className:`mdw-head`,children:[(0,I.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,I.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,I.jsx)(`span`,{className:`grow`}),u,(0,I.jsx)(`div`,{className:`docp-actions`,children:(0,I.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function re(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,P.useRef)(null),s=(0,P.useCallback)(async()=>{if(!o.current)try{o.current=(await t(`/api/docs/index`)).index||[]}catch{o.current=[]}return o.current},[]),c=(0,P.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,P.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,P.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:E}=n(),D=(0,P.useRef)(new Map),O=(0,P.useRef)(null),k=(0,P.useRef)(null),{onClick:A,openByDocId:j}=B(s),M=i?`repo`:a?`board`:``,N=i||a||``,F=(0,P.useMemo)(()=>i?{repoKey:i}:a?{boardKey:a,boardName:o||``}:{},[i,a,o]),[L,R]=(0,P.useState)(null),[z,V]=(0,P.useState)(``),[ie,U]=(0,P.useState)(!1),[W,G]=(0,P.useState)(`split`),[K,q]=(0,P.useState)([]),[ae,J]=(0,P.useState)(null),Y=(0,P.useRef)(null);(0,P.useEffect)(()=>{Y.current=L},[L]);let X=(0,P.useCallback)(async()=>{V(``);try{let n=await t(`/api/docs/item?ref=`+encodeURIComponent(e||``));R(n),U(!1)}catch(e){V(String(e.message||e)),R(null)}},[e]);(0,P.useEffect)(()=>{R(null),X()},[X]);let Z=(0,P.useCallback)(()=>{if(!N){q([]);return}if(M===`repo`){t(`/api/repos/docs?id=`+encodeURIComponent(N)).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/${N}.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===N||e.key===N),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}]:[]))},[N,M,e]);(0,P.useEffect)(()=>{Z()},[Z]);let[se,ce]=(0,P.useState)(null);(0,P.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=!!(L&&L.writable),le=(0,P.useMemo)(()=>L?f(L.body,[],Q?se:null):``,[L,se,Q]),ue=(0,P.useMemo)(()=>L?d(L.body):[],[L]);(0,P.useEffect)(()=>{let e=k.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()}},[L,W,le]);let $=e=>e().catch(e=>h(String(e.message||e))),de=(0,P.useCallback)(e=>j(e,null,F),[j,F]),fe=(0,P.useCallback)(()=>{let e=s;e&&N&&g(e,{component:`refs`,name:`文档列表`,config:i?{repoKey:i}:{boardKey:a,boardName:o||``},location:`right`})},[s,N,i,a,o]),pe=()=>{N&&$(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):M===`repo`?`repo/${N}`:`board/${o||N}`}/reference/${r}.md`;await t(`/api/docs/item`,{method:`POST`,body:{rel:i,body:`# ${String(n).trim()||r}\n\n(待补)\n`}});try{M===`repo`?await t(`/api/repos/docs`,{method:`POST`,body:{id:N,rel:i}}):await t(`/api/docs/link`,{method:`POST`,body:{board:N,doc:i}})}catch{}h(`已补充:${i}`),Z(),j(`rel:`+i,null,F)})},me=()=>$(async()=>{if(!L||!Q)return;let n=await t(`/api/docs/item`,{method:`PATCH`,body:{ref:e,body:L.body}});R(e=>({...e,body:L.body,summary:n.summary})),U(!1),S(D.current,e),h(n.summary?`已保存,摘要已回写`:`已保存`)}),he=(t,n=`op`)=>{L&&(b(D.current,e,{body:L.body},n),U(!0),R(e=>({...e,body:t,title:l(t,e.title)})))},ge=(t,n=`typing`)=>{if(!L)return;b(D.current,e,{body:L.body},n),U(!0);let r=/^#\s+/m.test(L.body)?L.body.replace(/^#\s+.+$/m,`# ${t||`未命名文档`}`):`# ${t||`未命名文档`}\n\n${L.body}`;R(e=>({...e,body:r,title:t}))},_e=()=>{if(!L)return;let t=y(D.current,e,{body:L.body});t&&(R(e=>({...e,body:t.body,title:l(t.body,e.title)})),U(!0),requestAnimationFrame(()=>O.current?.caretFromDiff?.(L.body,t.body)))},ve=()=>{if(!L)return;let t=x(D.current,e,{body:L.body});t&&(R(e=>({...e,body:t.body,title:l(t.body,e.title)})),U(!0),requestAnimationFrame(()=>O.current?.caretFromDiff?.(L.body,t.body)))},ye=async(t,n={})=>{if(!Q)return;let r=[...t||[]];if(r.length)try{let t=await w(r,{local:!0,onProgress:(e,t,n)=>h(`正在上传 ${e}/${t}:${n.name}`)}),i=ee(t);if(!i)return;let a=Y.current||L;if(!a)return;let o=u(a.body,i,n);b(D.current,e,{body:a.body}),U(!0),R(e=>e&&{...e,body:o.body,title:l(o.body,e.title)}),h(`已插入 ${t.length} 个附件`)}catch(e){h(`附件上传失败:${String(e.message||e)}`)}},be=()=>{L&&L.rel&&$(async()=>{let n=await _({title:`重命名文档`,input:!0,value:L.rel,placeholder:`新路径(相对 docs 根,以 .md 结尾)`});if(n===null)return;let r=String(n).trim();if(r&&r!==L.rel){if(!/\.md$/i.test(r))return h(`文档路径必须以 .md 结尾`);try{await t(`/api/docs/item`,{method:`POST`,body:{rel:r,body:L.body}})}catch(e){h(`重命名失败:${String(e.message||e)}`);return}await t(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),S(D.current,e),h(`已重命名为:${r}`),j(`rel:`+r,null,F)}})},xe=()=>{L&&$(async()=>{await _({title:`删除文档「${L.title||L.rel||e}」`,message:`磁盘上的 ${L.rel||e} 会被一并删除,不可恢复。`,danger:!0,okText:`删除`})&&(await t(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),h(`已删除:${L.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(L&&L.dir)return(0,I.jsxs)(`div`,{className:`mdw docp`,children:[(0,I.jsxs)(`div`,{className:`docp-head`,children:[(0,I.jsx)(`span`,{className:`docp-path mono`,children:L.path}),(0,I.jsx)(`span`,{className:`docp-tag ext`,children:`外部目录 · 只读`})]}),(0,I.jsxs)(`div`,{className:`docp-files`,children:[L.files.map(e=>(0,I.jsx)(`button`,{className:`docp-file`,onClick:()=>j(`path:`+e,null),children:e},e)),!L.files.length&&(0,I.jsx)(`div`,{className:`muted pad`,children:`(目录里还没有 .md 文档)`})]})]});if(z)return(0,I.jsx)(`div`,{className:`mdw docp`,children:(0,I.jsxs)(`div`,{className:`pad stack`,children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`strong`,{children:`文档打开失败`})}),(0,I.jsx)(`div`,{className:`hint`,children:z})]})});if(!L)return(0,I.jsx)(`div`,{className:`mdw`,children:(0,I.jsx)(`div`,{className:`pad muted`,children:`载入中…`})});if(L.missing){let t=String(e||``).startsWith(`rel:`)||!String(e||``).startsWith(`path:`);return(0,I.jsxs)(`div`,{className:`mdw docp`,children:[(0,I.jsx)(`div`,{className:`docp-head`,children:(0,I.jsx)(`span`,{className:`docp-path mono`,children:L.rel||L.path||e})}),(0,I.jsxs)(`div`,{className:`pad stack`,children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`strong`,{children:`文档还没有落盘`})}),(0,I.jsx)(`div`,{className:`hint`,children:`描述内容的权威是磁盘上的 .md 文件——对应的字符串字段会在读取时播种,也可以直接创建骨架。`}),t&&(0,I.jsx)(`div`,{children:(0,I.jsx)(`button`,{className:`btn sm`,onClick:Se,children:`创建骨架`})})]})]})}let Ce=Q?W:`read`;return(0,I.jsxs)(`div`,{className:`mdw docp`,"data-mode":Ce,onClick:A,ref:k,children:[(0,I.jsxs)(`div`,{className:`mdw-main`,children:[(0,I.jsx)(ne,{crumb:(0,I.jsx)(T,{}),title:L.title||L.rel||L.path||`文档`,pathLabel:L.rel||L.path||``,dirty:ie,writable:Q,external:!!L.external,menuGroups:[re(`edit`,`编辑`,[{id:`mode`,label:W===`edit`?`返回实时预览`:`源码模式`,hint:W===`edit`?`当前`:``,run:()=>G(W===`edit`?`split`:`edit`)}]),re(`doc`,`文档`,[{id:`rename`,label:`重命名`,run:be},{id:`delete`,label:`删除`,run:xe,danger:!0}]),re(`view`,`查看`,[N&&{id:`list`,label:`文字列表`,hint:`右侧边栏`,run:fe}])],onSave:me}),L.summary&&Q&&(0,I.jsxs)(`div`,{className:`docp-summary`,children:[`摘要(回写 desc):`,L.summary]}),(0,I.jsx)(v,{mode:Ce,title:L.title,body:L.body,previewHtml:le,onTitle:Q?ge:null,onBody:Q?he:null,onFiles:Q?ye:null,attachments:[],docKey:e,editorApiRef:O,onSave:Q?me:null,onUndo:Q?_e:null,onRedo:Q?ve:null}),(0,I.jsx)(te,{host:`ref`,refId:e,allow:{file:!0,url:!0,task:!1,ref:!0},disabled:!Q,disabledText:`只读文档不能添加附件。`,onOpenDoc:e=>{let t=C(e);t&&j(t,null,F)}}),(0,I.jsx)(`div`,{className:`docp-hint`,children:`双链 [[]] 点击跳转 · Ctrl+S 保存 · 文档即磁盘文件(~/.nx-kv/docs/)`})]}),(0,I.jsx)(oe,{headings:ue,scrollRoot:ae,links:K,activeDocId:e,onOpenDoc:N?de:null,onAddRef:N?pe:null}),E]})}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,P.useMemo)(()=>ie(n,e),[n,e]),[u,d]=(0,P.useState)([]),[f,p]=(0,P.useState)(``),[m,h]=(0,P.useState)(0),g=(0,P.useCallback)(()=>h(e=>e+1),[]);(0,P.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,P.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,P.useCallback)(()=>{let e=f||l;e&&i(e,null,_)},[f,l,i,_]),openDoc:(0,P.useCallback)(e=>i(e,null,_),[i,_]),addRef:(0,P.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,P.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,P.useState)([]),[S,C]=(0,P.useState)(!0),[w,ee]=(0,P.useState)(``),T=(0,P.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)),ee(``)}catch(e){x([]),ee(String(e.message||e))}finally{C(!1)}},[e,v,a]);(0,P.useEffect)(()=>{T()},[T]);let E=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()},D=e=>e().catch(e=>u(String(e.message||e))),O=n=>D(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(`已摘除`),T(),l&&l())}),k=e=>D(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}]`:`标签已清除`),T(),l&&l()}),A=()=>D(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 T(),l&&l(),E({docId:`rel:`+o,label:String(r).trim()||a,sub:o})}),j=!!String(h.docRef||``).startsWith(`rel:`)&&v,M=b.length,N=`文档列表 · ${y||``}${e===`board`?`(项目组)`:``}`;return(0,I.jsxs)(i,{size:`md`,title:N,onClose:s,children:[(0,I.jsxs)(`div`,{className:`nx-dl`,children:[(0,I.jsxs)(`div`,{className:`nx-dl-head`,children:[(0,I.jsx)(`span`,{className:`nx-dl-count`,children:M?`${M} 篇`:`还没有文档`}),(0,I.jsx)(`span`,{className:`nx-dl-hint`,children:`点标题在主内容区打开`}),(0,I.jsx)(`span`,{className:`grow`}),j&&(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm nx-dl-add`,title:`补充一篇介绍文档(reference)`,onClick:A,children:`+ 补充`})]}),w?(0,I.jsx)(`div`,{className:`rpd-err`,children:w}):null,!w&&S&&M===0?(0,I.jsx)(`div`,{className:`rpd-empty`,children:`载入中…`}):null,!w&&!S&&M===0?(0,I.jsx)(`div`,{className:`rpd-none`,children:`还没有文档 —— 点「+ 补充」写第一篇`}):null,(0,I.jsx)(`div`,{className:`nx-dl-list`,children:b.map(e=>(0,I.jsxs)(`div`,{className:`nx-dl-row-wrap`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`nx-dl-row`,title:`${e.sub||e.label}\n点击在主内容区打开(可编辑)`,onClick:()=>E(e),children:[(0,I.jsxs)(`span`,{className:`nx-dl-row-title`,children:[ae[e.kind]||`○ `,e.label]}),e.tag?(0,I.jsx)(`span`,{className:`rpd-badge`,children:e.tag}):null]}),(0,I.jsxs)(`span`,{className:`nx-docs-modal-item-acts`,children:[e.taggable&&(0,I.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini`,title:e.tag?`改标签(当前:${e.tag})`:`加标签`,onClick:()=>k(e),children:`#`}),e.removable&&(0,I.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini danger`,title:e.removeTip||`摘除「${e.label}」(文档不删)`,onClick:()=>O(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,P.useState)(!1),[c,l]=(0,P.useState)(``),u=(0,P.useMemo)(()=>e||[],[e]),d=(0,P.useMemo)(()=>n||[],[n]);(0,P.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,P.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,I.jsxs)(`aside`,{className:`doc-rail`+(o?` open`:``),"aria-label":`文档目录`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:o?`收起目录`:`展开目录`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[(0,I.jsx)(`span`,{}),(0,I.jsx)(`span`,{}),(0,I.jsx)(`span`,{})]}),(0,I.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`章节`,children:u.map(e=>(0,I.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,I.jsxs)(`div`,{className:`doc-rail-panel`,children:[u.length>0&&(0,I.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,I.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`本章`}),u.map(e=>(0,I.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,I.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,I.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`介绍文档`}),d.map(e=>(0,I.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,I.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,P.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,I.jsxs)(`div`,{className:`nx-intro`,children:[(0,I.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,I.jsx)(`button`,{type:`button`,className:`nx-intro-link-main`,title:`打开${r}(在主内容区阅读 / 编辑)`,onClick:o,children:r}),(0,I.jsx)(`span`,{className:`nx-intro-path mono`,children:d}),(0,I.jsx)(`span`,{className:`nx-intro-spacer`}),(0,I.jsxs)(`button`,{type:`button`,className:`nx-intro-btn`,title:`查看${r}的全部文章(点标题在主内容区打开,可编辑)`,onClick:()=>c(!0),children:[`查看详情`,f>0?` ${f}`:``]})]}),s&&(0,I.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-DxX-ZzRP.js";import{a as v,i as y,n as b,r as x,t as S,u as C}from"./md-history-4sXoj4RH.js";import{a as w,i as ee}from"./upload-L1g-pfvZ.js";import{t as T}from"./route-crumb-B8oEN8BB.js";import{a as E,c as D,i as O,l as k,o as A,r as j,s as M,t as N,u as te}from"./tool-bar-CfBWzhpV.js";var P=e(s(),1),F=h(),I=a(),L=`doc`,R=[{id:`edit`,label:`编辑`},{id:`doc`,label:`文档`},{id:`view`,label:`查看`}];function ne({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=O(),{layout:f,setLayout:p}=A(L),[m,h]=(0,P.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=>k(L,e)&&_(e.id)),y=f.filter(e=>M(L,e)&&_(e.id)),b=e=>{g[e]?.run?.(),d.setOpen(!1)},x=e=>{if(e===`more`)return(0,I.jsx)(`div`,{className:`docp-more`,ref:d.ref,children:(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm${d.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":d.open,onClick:e=>j(d,e,`right`),children:`更多`})},`more`);let t=g[e];return t?(0,I.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||D(L,e).label||e},e):null},S=R.map(e=>({...e,items:y.filter(t=>D(L,t.id).menuGroup===e.id)})).filter(e=>e.items.length),C=y.filter(e=>!D(L,e.id).menuGroup);return i?(0,I.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,I.jsxs)(`div`,{className:`mdw-head`,children:[(0,I.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,I.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,I.jsx)(`span`,{className:`grow`}),u,(0,I.jsxs)(`div`,{className:`docp-actions`,children:[v.map(e=>x(e.id)),(0,I.jsxs)(N,{menu:d,className:`mdw-act-menu`,children:[S.map(e=>(0,I.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,I.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=g[e.id],n=t?.danger||D(L,e.id).danger;return(0,I.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>b(e.id),children:[t?.label||D(L,e.id).label||e.id,t?.hint?(0,I.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),C.map(e=>{let t=g[e.id];return(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||D(L,e.id).danger?` danger`:``),onClick:()=>b(e.id),children:t?.label||D(L,e.id).label||e.id},e.id)}),(0,I.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{d.setOpen(!1),h(!0)},children:`自定义工具栏…`})]})]})]}),m&&(0,F.createPortal)((0,I.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>h(!1),children:(0,I.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,I.jsx)(E,{kind:L,layout:f,setLayout:p,onClose:()=>h(!1)})})}),document.body)]}):(0,I.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,I.jsxs)(`div`,{className:`mdw-head`,children:[(0,I.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,I.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,I.jsx)(`span`,{className:`grow`}),u,(0,I.jsx)(`div`,{className:`docp-actions`,children:(0,I.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function re(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,P.useRef)(null),s=(0,P.useCallback)(async()=>{if(!o.current)try{o.current=(await t(`/api/docs/index`)).index||[]}catch{o.current=[]}return o.current},[]),c=(0,P.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,P.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,P.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:E}=n(),D=(0,P.useRef)(new Map),O=(0,P.useRef)(null),k=(0,P.useRef)(null),{onClick:A,openByDocId:j}=B(s),M=i?`repo`:a?`board`:``,N=i||a||``,F=(0,P.useMemo)(()=>i?{repoKey:i}:a?{boardKey:a,boardName:o||``}:{},[i,a,o]),[L,R]=(0,P.useState)(null),[z,V]=(0,P.useState)(``),[ie,U]=(0,P.useState)(!1),[W,G]=(0,P.useState)(`split`),[K,q]=(0,P.useState)([]),[ae,J]=(0,P.useState)(null),Y=(0,P.useRef)(null);(0,P.useEffect)(()=>{Y.current=L},[L]);let X=(0,P.useCallback)(async()=>{V(``);try{let n=await t(`/api/docs/item?ref=`+encodeURIComponent(e||``));R(n),U(!1)}catch(e){V(String(e.message||e)),R(null)}},[e]);(0,P.useEffect)(()=>{R(null),X()},[X]);let Z=(0,P.useCallback)(()=>{if(!N){q([]);return}if(M===`repo`){t(`/api/repos/docs?id=`+encodeURIComponent(N)).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/${N}.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===N||e.key===N),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}]:[]))},[N,M,e]);(0,P.useEffect)(()=>{Z()},[Z]);let[se,ce]=(0,P.useState)(null);(0,P.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=!!(L&&L.writable),le=(0,P.useMemo)(()=>L?f(L.body,[],Q?se:null):``,[L,se,Q]),ue=(0,P.useMemo)(()=>L?d(L.body):[],[L]);(0,P.useEffect)(()=>{let e=k.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()}},[L,W,le]);let $=e=>e().catch(e=>h(String(e.message||e))),de=(0,P.useCallback)(e=>j(e,null,F),[j,F]),fe=(0,P.useCallback)(()=>{let e=s;e&&N&&g(e,{component:`refs`,name:`文档列表`,config:i?{repoKey:i}:{boardKey:a,boardName:o||``},location:`right`})},[s,N,i,a,o]),pe=()=>{N&&$(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):M===`repo`?`repo/${N}`:`board/${o||N}`}/reference/${r}.md`;await t(`/api/docs/item`,{method:`POST`,body:{rel:i,body:`# ${String(n).trim()||r}\n\n(待补)\n`}});try{M===`repo`?await t(`/api/repos/docs`,{method:`POST`,body:{id:N,rel:i}}):await t(`/api/docs/link`,{method:`POST`,body:{board:N,doc:i}})}catch{}h(`已补充:${i}`),Z(),j(`rel:`+i,null,F)})},me=()=>$(async()=>{if(!L||!Q)return;let n=await t(`/api/docs/item`,{method:`PATCH`,body:{ref:e,body:L.body}});R(e=>({...e,body:L.body,summary:n.summary})),U(!1),S(D.current,e),h(n.summary?`已保存,摘要已回写`:`已保存`)}),he=(t,n=`op`)=>{L&&(b(D.current,e,{body:L.body},n),U(!0),R(e=>({...e,body:t,title:l(t,e.title)})))},ge=(t,n=`typing`)=>{if(!L)return;b(D.current,e,{body:L.body},n),U(!0);let r=/^#\s+/m.test(L.body)?L.body.replace(/^#\s+.+$/m,`# ${t||`未命名文档`}`):`# ${t||`未命名文档`}\n\n${L.body}`;R(e=>({...e,body:r,title:t}))},_e=()=>{if(!L)return;let t=y(D.current,e,{body:L.body});t&&(R(e=>({...e,body:t.body,title:l(t.body,e.title)})),U(!0),requestAnimationFrame(()=>O.current?.caretFromDiff?.(L.body,t.body)))},ve=()=>{if(!L)return;let t=x(D.current,e,{body:L.body});t&&(R(e=>({...e,body:t.body,title:l(t.body,e.title)})),U(!0),requestAnimationFrame(()=>O.current?.caretFromDiff?.(L.body,t.body)))},ye=async(t,n={})=>{if(!Q)return;let r=[...t||[]];if(r.length)try{let t=await w(r,{local:!0,onProgress:(e,t,n)=>h(`正在上传 ${e}/${t}:${n.name}`)}),i=ee(t);if(!i)return;let a=Y.current||L;if(!a)return;let o=u(a.body,i,n);b(D.current,e,{body:a.body}),U(!0),R(e=>e&&{...e,body:o.body,title:l(o.body,e.title)}),h(`已插入 ${t.length} 个附件`)}catch(e){h(`附件上传失败:${String(e.message||e)}`)}},be=()=>{L&&L.rel&&$(async()=>{let n=await _({title:`重命名文档`,input:!0,value:L.rel,placeholder:`新路径(相对 docs 根,以 .md 结尾)`});if(n===null)return;let r=String(n).trim();if(r&&r!==L.rel){if(!/\.md$/i.test(r))return h(`文档路径必须以 .md 结尾`);try{await t(`/api/docs/item`,{method:`POST`,body:{rel:r,body:L.body}})}catch(e){h(`重命名失败:${String(e.message||e)}`);return}await t(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),S(D.current,e),h(`已重命名为:${r}`),j(`rel:`+r,null,F)}})},xe=()=>{L&&$(async()=>{await _({title:`删除文档「${L.title||L.rel||e}」`,message:`磁盘上的 ${L.rel||e} 会被一并删除,不可恢复。`,danger:!0,okText:`删除`})&&(await t(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),h(`已删除:${L.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(L&&L.dir)return(0,I.jsxs)(`div`,{className:`mdw docp`,children:[(0,I.jsxs)(`div`,{className:`docp-head`,children:[(0,I.jsx)(`span`,{className:`docp-path mono`,children:L.path}),(0,I.jsx)(`span`,{className:`docp-tag ext`,children:`外部目录 · 只读`})]}),(0,I.jsxs)(`div`,{className:`docp-files`,children:[L.files.map(e=>(0,I.jsx)(`button`,{className:`docp-file`,onClick:()=>j(`path:`+e,null),children:e},e)),!L.files.length&&(0,I.jsx)(`div`,{className:`muted pad`,children:`(目录里还没有 .md 文档)`})]})]});if(z)return(0,I.jsx)(`div`,{className:`mdw docp`,children:(0,I.jsxs)(`div`,{className:`pad stack`,children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`strong`,{children:`文档打开失败`})}),(0,I.jsx)(`div`,{className:`hint`,children:z})]})});if(!L)return(0,I.jsx)(`div`,{className:`mdw`,children:(0,I.jsx)(`div`,{className:`pad muted`,children:`载入中…`})});if(L.missing){let t=String(e||``).startsWith(`rel:`)||!String(e||``).startsWith(`path:`);return(0,I.jsxs)(`div`,{className:`mdw docp`,children:[(0,I.jsx)(`div`,{className:`docp-head`,children:(0,I.jsx)(`span`,{className:`docp-path mono`,children:L.rel||L.path||e})}),(0,I.jsxs)(`div`,{className:`pad stack`,children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`strong`,{children:`文档还没有落盘`})}),(0,I.jsx)(`div`,{className:`hint`,children:`描述内容的权威是磁盘上的 .md 文件——对应的字符串字段会在读取时播种,也可以直接创建骨架。`}),t&&(0,I.jsx)(`div`,{children:(0,I.jsx)(`button`,{className:`btn sm`,onClick:Se,children:`创建骨架`})})]})]})}let Ce=Q?W:`read`;return(0,I.jsxs)(`div`,{className:`mdw docp`,"data-mode":Ce,onClick:A,ref:k,children:[(0,I.jsxs)(`div`,{className:`mdw-main`,children:[(0,I.jsx)(ne,{crumb:(0,I.jsx)(T,{}),title:L.title||L.rel||L.path||`文档`,pathLabel:L.rel||L.path||``,dirty:ie,writable:Q,external:!!L.external,menuGroups:[re(`edit`,`编辑`,[{id:`mode`,label:W===`edit`?`返回实时预览`:`源码模式`,hint:W===`edit`?`当前`:``,run:()=>G(W===`edit`?`split`:`edit`)}]),re(`doc`,`文档`,[{id:`rename`,label:`重命名`,run:be},{id:`delete`,label:`删除`,run:xe,danger:!0}]),re(`view`,`查看`,[N&&{id:`list`,label:`文字列表`,hint:`右侧边栏`,run:fe}])],onSave:me}),L.summary&&Q&&(0,I.jsxs)(`div`,{className:`docp-summary`,children:[`摘要(回写 desc):`,L.summary]}),(0,I.jsx)(v,{mode:Ce,title:L.title,body:L.body,previewHtml:le,onTitle:Q?ge:null,onBody:Q?he:null,onFiles:Q?ye:null,attachments:[],docKey:e,editorApiRef:O,onSave:Q?me:null,onUndo:Q?_e:null,onRedo:Q?ve:null}),(0,I.jsx)(te,{host:`ref`,refId:e,allow:{file:!0,url:!0,task:!1,ref:!0},disabled:!Q,disabledText:`只读文档不能添加附件。`,onOpenDoc:e=>{let t=C(e);t&&j(t,null,F)}}),(0,I.jsx)(`div`,{className:`docp-hint`,children:`双链 [[]] 点击跳转 · Ctrl+S 保存 · 文档即磁盘文件(~/.nx-kv/docs/)`})]}),(0,I.jsx)(oe,{headings:ue,scrollRoot:ae,links:K,activeDocId:e,onOpenDoc:N?de:null,onAddRef:N?pe:null}),E]})}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,P.useMemo)(()=>ie(n,e),[n,e]),[u,d]=(0,P.useState)([]),[f,p]=(0,P.useState)(``),[m,h]=(0,P.useState)(0),g=(0,P.useCallback)(()=>h(e=>e+1),[]);(0,P.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,P.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,P.useCallback)(()=>{let e=f||l;e&&i(e,null,_)},[f,l,i,_]),openDoc:(0,P.useCallback)(e=>i(e,null,_),[i,_]),addRef:(0,P.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,P.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,P.useState)([]),[S,C]=(0,P.useState)(!0),[w,ee]=(0,P.useState)(``),T=(0,P.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)),ee(``)}catch(e){x([]),ee(String(e.message||e))}finally{C(!1)}},[e,v,a]);(0,P.useEffect)(()=>{T()},[T]);let E=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()},D=e=>e().catch(e=>u(String(e.message||e))),O=n=>D(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(`已摘除`),T(),l&&l())}),k=e=>D(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}]`:`标签已清除`),T(),l&&l()}),A=()=>D(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 T(),l&&l(),E({docId:`rel:`+o,label:String(r).trim()||a,sub:o})}),j=!!String(h.docRef||``).startsWith(`rel:`)&&v,M=b.length,N=`文档列表 · ${y||``}${e===`board`?`(项目组)`:``}`;return(0,I.jsxs)(i,{size:`md`,title:N,onClose:s,children:[(0,I.jsxs)(`div`,{className:`nx-dl`,children:[(0,I.jsxs)(`div`,{className:`nx-dl-head`,children:[(0,I.jsx)(`span`,{className:`nx-dl-count`,children:M?`${M} 篇`:`还没有文档`}),(0,I.jsx)(`span`,{className:`nx-dl-hint`,children:`点标题在主内容区打开`}),(0,I.jsx)(`span`,{className:`grow`}),j&&(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm nx-dl-add`,title:`补充一篇介绍文档(reference)`,onClick:A,children:`+ 补充`})]}),w?(0,I.jsx)(`div`,{className:`rpd-err`,children:w}):null,!w&&S&&M===0?(0,I.jsx)(`div`,{className:`rpd-empty`,children:`载入中…`}):null,!w&&!S&&M===0?(0,I.jsx)(`div`,{className:`rpd-none`,children:`还没有文档 —— 点「+ 补充」写第一篇`}):null,(0,I.jsx)(`div`,{className:`nx-dl-list`,children:b.map(e=>(0,I.jsxs)(`div`,{className:`nx-dl-row-wrap`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`nx-dl-row`,title:`${e.sub||e.label}\n点击在主内容区打开(可编辑)`,onClick:()=>E(e),children:[(0,I.jsxs)(`span`,{className:`nx-dl-row-title`,children:[ae[e.kind]||`○ `,e.label]}),e.tag?(0,I.jsx)(`span`,{className:`rpd-badge`,children:e.tag}):null]}),(0,I.jsxs)(`span`,{className:`nx-docs-modal-item-acts`,children:[e.taggable&&(0,I.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini`,title:e.tag?`改标签(当前:${e.tag})`:`加标签`,onClick:()=>k(e),children:`#`}),e.removable&&(0,I.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini danger`,title:e.removeTip||`摘除「${e.label}」(文档不删)`,onClick:()=>O(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,P.useState)(!1),[c,l]=(0,P.useState)(``),u=(0,P.useMemo)(()=>e||[],[e]),d=(0,P.useMemo)(()=>n||[],[n]);(0,P.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,P.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,I.jsxs)(`aside`,{className:`doc-rail`+(o?` open`:``),"aria-label":`文档目录`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:o?`收起目录`:`展开目录`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[(0,I.jsx)(`span`,{}),(0,I.jsx)(`span`,{}),(0,I.jsx)(`span`,{})]}),(0,I.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`章节`,children:u.map(e=>(0,I.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,I.jsxs)(`div`,{className:`doc-rail-panel`,children:[u.length>0&&(0,I.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,I.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`本章`}),u.map(e=>(0,I.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,I.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,I.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`介绍文档`}),d.map(e=>(0,I.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,I.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,P.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,I.jsxs)(`div`,{className:`nx-intro`,children:[(0,I.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,I.jsx)(`button`,{type:`button`,className:`nx-intro-link-main`,title:`打开${r}(在主内容区阅读 / 编辑)`,onClick:o,children:r}),(0,I.jsx)(`span`,{className:`nx-intro-path mono`,children:d}),(0,I.jsx)(`span`,{className:`nx-intro-spacer`}),(0,I.jsxs)(`button`,{type:`button`,className:`nx-intro-btn`,title:`查看${r}的全部文章(点标题在主内容区打开,可编辑)`,onClick:()=>c(!0),children:[`查看详情`,f>0?` ${f}`:``]})]}),s&&(0,I.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-DxX-ZzRP.js";import{a as i,c as a,l as o,o as s,s as c}from"./tool-bar-CfBWzhpV.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-BeGocDOb.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-BvdNu1Cv.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-DxX-ZzRP.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-B8oEN8BB.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,v as t}from"./task-status-BP6y8MVu.js";import{O as n,w as r}from"./index-
|
|
1
|
+
import{p as e,v as t}from"./task-status-BP6y8MVu.js";import{O as n,w as r}from"./index-DxX-ZzRP.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};
|
|
@@ -1 +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-
|
|
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-DxX-ZzRP.js";import{a as c,i as l,n as u,r as d,t as f}from"./md-history-4sXoj4RH.js";import{i as p,o as m,r as ee,t as h}from"./composer-launch-BgMj0T3Y.js";var g=e(i(),1),_=r(),v=96;function y({token:e,mode:r=`comment`,quote:i=``,prevQuote:y=``,taskLabel:b=``,taskTitle:x=``,src:S=null}){let C=s()||{},w=t(),[T,E]=(0,g.useState)(``),[D,O]=(0,g.useState)([]),[k,A]=(0,g.useState)(!1),j=(0,g.useRef)(null),M=r===`feedback`,N=(0,g.useRef)(new Map),P=`compose-`+e,F=()=>{f(N.current,P),ee(C.model,e)},I=(e,t=`op`)=>{u(N.current,P,{title:``,body:T},t),E(e)},L=()=>{let e=l(N.current,P,{title:``,body:T});e&&E(e.body)},R=()=>{let e=d(N.current,P,{title:``,body:T});e&&E(e.body)},z=async()=>{let t=String(T||``).trim();if(!t&&!D.length){w(M?`写一下要改的地方`:`写一下要提的问题`);return}let n=h(e);if(!n||!n.onSubmit){w(`提交入口已失效(来源页面已关闭)`);return}A(!0);try{await n.onSubmit({text:t,attachments:D,inserts:``}),F()}catch(e){w(String(e.message||e))}finally{A(!1)}},B=async e=>{if(!e||!e.length)return;let{items:t,imageInserts:n,fileInserts:r}=await p(e),i=[...n,...r].join(``);i&&E(e=>a(e,i,{}).body),t.length&&O(e=>[...e,...t])},V=(0,g.useRef)(null),[H,U]=(0,g.useState)(()=>localStorage.getItem(`nxkv.cmpDockOpen`)!==`0`),[W,G]=(0,g.useState)(()=>{let e=Number(localStorage.getItem(`nxkv.cmpDockH`));return Number.isFinite(e)&&e>=v?e:176}),K=(0,g.useRef)(W);K.current=W;let[q,J]=(0,g.useState)(!1),Y=(0,g.useRef)(176);(0,g.useEffect)(()=>{localStorage.setItem(`nxkv.cmpDockOpen`,H?`1`:`0`)},[H]);let X=()=>{if(q){G(Y.current),J(!1);return}Y.current=W;let e=document.querySelector(`.cmp`)?.clientHeight||window.innerHeight;G(Math.max(v,Math.round(e*.62))),J(!0)},Z=e=>{if(!H)return;e.preventDefault(),J(!1);let t=e.clientY,n=K.current,r=e=>Math.max(v,Math.min(Math.round(e),Math.round((document.querySelector(`.cmp`)?.clientHeight||window.innerHeight)*.62))),i=e=>{K.current=r(n-(e.clientY-t)),G(K.current)},a=()=>{window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(`nxkv.cmpDockH`,String(K.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)},Q=()=>{let e=C.model;e&&S&&S.task&&o(e,{component:`page`,name:S.name||`原文`,config:{dirKey:S.dirKey,task:String(S.task)}})},$=!!(S&&S.task);return(0,_.jsxs)(`div`,{className:`cmp`,children:[(0,_.jsxs)(`div`,{className:`cmp-head`,children:[(0,_.jsx)(`span`,{className:`cmp-tag`+(M?` is-fb`:``),children:M?`反馈`:`评论`}),(0,_.jsx)(`div`,{className:`cmp-ctx`,children:M?(0,_.jsxs)(`span`,{className:`cmp-ctx-line`,title:x||``,children:[`反馈 `,b||``,` 的任务`,x?` · ${x}`:``]}):(0,_.jsx)(`span`,{className:`cmp-ctx-line`,children:`对本任务提出问题`})}),(0,_.jsx)(`span`,{className:`grow`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:F,disabled:k,children:`关闭`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:z,disabled:k,children:M?`提交反馈`:`提交评论`})]}),M?(0,_.jsxs)(`div`,{className:`cmp-quote-wrap`,children:[(0,_.jsxs)(`div`,{className:`cmp-quote-cap`,children:[`之前的引用`,$&&(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote-cmp`,onClick:Q,title:`在右侧并排显示原文,方便对照`,children:`对照原文 ↗`})]}),$?(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote`,onClick:Q,title:`点击在右侧并排显示原文,方便对照`,children:y||`(这条任务还没有可引用的上轮总结)`}):(0,_.jsx)(`div`,{className:`cmp-quote`,children:y||`(这条任务还没有可引用的上轮总结)`})]}):i?(0,_.jsxs)(`div`,{className:`cmp-quote-wrap`,children:[(0,_.jsxs)(`div`,{className:`cmp-quote-cap`,children:[`引用`,$&&(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote-cmp`,onClick:Q,title:`在右侧并排显示原文,方便对照`,children:`对照原文 ↗`})]}),$?(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote`,onClick:Q,title:`点击在右侧并排显示原文,方便对照`,children:i}):(0,_.jsx)(`div`,{className:`cmp-quote`,children:i})]}):null,(0,_.jsx)(`div`,{className:`cmp-body`,children:(0,_.jsx)(c,{mode:`split`,title:``,body:T,onTitle:()=>{},onBody:I,attachments:D,docKey:`compose-`+e,editorApiRef:j,onFiles:B,onSave:z,onUndo:L,onRedo:R,hideTitle:!0})}),H&&(0,_.jsxs)(`div`,{className:`mdw-dock`,style:{height:`${W}px`},children:[(0,_.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:Z,onDoubleClick:X}),(0,_.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,_.jsx)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:(0,_.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":`true`,className:`mdw-dock-tab is-on`,onClick:()=>U(!0),children:[`附件`,D.length?(0,_.jsx)(`span`,{className:`mdw-dock-tab-num`,children:D.length}):null]})}),(0,_.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,title:`添加附件`,"aria-label":`添加附件`,onClick:()=>V.current?.click(),children:(0,_.jsx)(n,{name:`plus`})}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:X,title:q?`还原面板高度`:`最大化面板高度`,"aria-label":q?`还原面板高度`:`最大化面板高度`,children:(0,_.jsx)(n,{name:q?`collapse`:`expand`})}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>U(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,_.jsx)(n,{name:`x`})})]})]}),(0,_.jsx)(`div`,{className:`mdw-dock-body`,children:D.length?(0,_.jsx)(m,{attachments:D,onRemove:e=>O(t=>t.filter(t=>t.id!==e))}):(0,_.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有附件——粘贴 / 拖图片进正文即附件,或点右上「+」添加文件。`})})]}),(0,_.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${H?` is-on`:``}`,onClick:()=>U(e=>!e),title:`附件(点击展开/收起信息面板)`,children:[(0,_.jsx)(n,{name:`list`}),(0,_.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`}),D.length?(0,_.jsx)(`span`,{className:`mdw-sbar-num`,children:D.length}):null]}),(0,_.jsx)(`span`,{className:`mdw-sbar-grow`}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${H?` is-open`:``}`,onClick:()=>U(e=>!e),title:H?`收起信息面板`:`展开信息面板`,"aria-expanded":H,"aria-label":H?`收起信息面板`:`展开信息面板`,children:(0,_.jsx)(n,{name:`chevron`})})]}),(0,_.jsx)(`input`,{ref:V,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&B(t)}})]})}export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{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-BeGocDOb.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-DxX-ZzRP.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};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{S as e,_ as t,d as n,f as r,g as i,l as a,p as o,u as s,v as c,y as l}from"./task-status-BP6y8MVu.js";import{h as u,n as d}from"./md-parse-C2bDc3IZ.js";import{o as f,r as p,t as m}from"./board-view-t8CKtq17.js";import{O as h,T as g,_,a as v,b as y,g as b,i as x,k as S,m as C,o as w,p as T,r as E,s as D,u as O,y as k}from"./index-DxX-ZzRP.js";import{t as A}from"./route-crumb-B8oEN8BB.js";import{t as j}from"./graph-DM-zDRdL.js";import{n as ee,r as te,t as M}from"./reopen-text-BylkngqC.js";import{t as N}from"./Introduction-DKqRmABL.js";import{t as ne}from"./bar-B8QJ4EnF.js";var P=e(l(),1),F=c();function I(e){let t=String(e||``).trim();if(!t)return`—`;let n=t.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/);return n?`${n[1].slice(5)} ${n[2]}`:t.slice(0,16)}function re({isGlobal:e,topic:t,repo:r=null,model:i=null,tasks:a=[],taskCount:s=0,pendingCount:c=0,page:l=0,pageCount:d=1,onPage:f,onNew:p,onOpenTask:m,onDeleteTask:h,onDeleteTasks:g,onCancelTasks:_,onCompleteTasks:v,onReopenTask:x,onTplMenu:S,onImport:C,onProg:w,onMoveTask:T,onOpenDag:E,onOpenFlow:D,onToggleGate:O,downstreamOf:j,onDeleted:ee,onRefs:te,deletedCount:M=0}){let re=e?`全局池`:t?.name||`目录`,L=e?`共享池(无固定目录)`:t?.cwd||`—`,R=String(t?.summary||``).trim(),z=(0,P.useRef)(null),[ie,B]=(0,P.useState)(null),[V,H]=(0,P.useState)(null),[U,W]=(0,P.useState)(()=>new Set);(0,P.useEffect)(()=>{W(new Set)},[l]);let G=a.map(e=>Number(e.id)),K=G.length>0&&G.every(e=>U.has(e)),q=a.filter(e=>U.has(Number(e.id))),J=q.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),ae=e=>{let t=Number(e);W(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},oe=()=>{W(e=>{let t=new Set(e);return K?G.forEach(e=>t.delete(e)):G.forEach(e=>t.add(e)),t})},Y=async e=>{let t=[...U],n=e===`cancel`?_:e===`complete`?v:g;t.length&&n&&await n(t)&&W(new Set)},X=e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt,Z=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},se=(e,t)=>{z.current={id:Number(t.id)},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.id),B(Number(t.id))},Q=(e,t)=>{z.current&&X(t)&&Number(t.id)!==z.current.id&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,H({id:Number(t.id),zone:Z(e,e.currentTarget)}))},ce=e=>{e.currentTarget.contains(e.relatedTarget)||H(null)},le=(e,t)=>{e.preventDefault();let n=Z(e,e.currentTarget),r=z.current;z.current=null,B(null),H(null),r&&X(t)&&Number(t.id)!==r.id&&T&&T({id:r.id},t.id,n)},$=()=>{z.current=null,B(null),H(null)};return(0,F.jsxs)(`div`,{className:`mdw-land`,children:[(0,F.jsx)(A,{}),(0,F.jsxs)(`div`,{className:`mdw-land-head`,children:[(0,F.jsx)(`div`,{className:`mdw-land-name`,children:re}),(0,F.jsx)(`div`,{className:`mdw-land-path mono`,title:L,children:L}),R?(0,F.jsxs)(`div`,{className:`mdw-land-status-line`,title:R,children:[(0,F.jsx)(`span`,{className:`mdw-land-lab`,children:`现状`}),(0,F.jsx)(`span`,{className:`mdw-land-status`,children:R})]}):null]}),!e&&r?(0,F.jsx)(N,{kind:`repo`,owner:r,model:i}):null,(0,F.jsxs)(`div`,{className:`mdw-land-acts`,children:[(0,F.jsx)(ne,{kind:`dir`,className:`mdw-land-ta`,labels:{more:M>0?`更多 (${M})`:`更多`,deleted:M>0?`已删除任务(${M})`:`已删除任务`},titles:{new:`按默认模板新建一页(▾ 选模板)`,import:`把一个 .md 文件导入成任务`,progress:`打开这个目录的进程面板`,more:M>0?`更多操作(含 ${M} 条已删除任务)`:`更多操作`,deleted:`查看并恢复已删除任务`,refs:`查看文档 / reference 列表`},renderers:{new:()=>(0,F.jsx)(`span`,{className:`rp-newtask`,children:(0,F.jsxs)(`button`,{type:`button`,className:`btn small primary`,title:`按默认模板新建一页(▾ 选模板)`,onClick:()=>p(),children:[`+ 新建页`,(0,F.jsx)(`span`,{role:`button`,tabIndex:0,"aria-label":`选择模板新建一页`,"aria-haspopup":`menu`,className:`rp-newtask-caret`,title:`选择模板新建一页`,onClick:e=>{e.stopPropagation(),S?.(e)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),S?.(e))},children:(0,F.jsx)(o,{name:`chevron`,size:11})})]})})},actions:{new:p,import:C,progress:w,orch:D,deleted:ee,refs:te}}),(0,F.jsxs)(`span`,{className:`mdw-land-count`,children:[c>0&&(0,F.jsxs)(`b`,{className:`mdw-land-pending`,children:[c,` 待领取`]}),` `,s,` 个任务`]})]}),q.length>0&&(0,F.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,F.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,q.length,` 条`]}),v&&(0,F.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!J.length,title:J.length?`把选中的待领取任务标为已完成(补一条完成记录,原文留档)`:`只有待领取任务可以直接标为完成`,onClick:()=>Y(`complete`),children:[`标为完成选中`,J.length?` (${J.length})`:``]}),_&&(0,F.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!J.length,title:J.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消`,onClick:()=>Y(`cancel`),children:[`取消选中`,J.length?` (${J.length})`:``]}),g&&(0,F.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>Y(`delete`),children:[`删除选中 (`,q.length,`)`]}),(0,F.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>W(new Set),children:`清空`})]}),(0,F.jsx)(`div`,{className:`mdw-land-table-wrap`,children:(0,F.jsxs)(`table`,{className:`mdw-land-table`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{scope:`col`,className:`pick`,children:(0,F.jsx)(`input`,{type:`checkbox`,checked:K,onChange:oe,"aria-label":`全选当前页任务`,title:`全选/取消全选当前页`})}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`56px`},children:`#`}),(0,F.jsx)(`th`,{scope:`col`,children:`任务`}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`74px`},children:`状态`}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`116px`},children:`创建`}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`116px`},children:`领取`}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`56px`}})]})}),(0,F.jsxs)(`tbody`,{children:[a.map(e=>{let t=X(e),r=j&&j[e.id]||[];return(0,F.jsxs)(`tr`,{className:`mdw-land-tr`+(U.has(Number(e.id))?` picked`:``)+(ie===Number(e.id)?` dragging`:``)+(V&&V.id===Number(e.id)?` drop-`+V.zone:``),draggable:t,onDragStart:n=>t&&se(n,e),onDragOver:t=>Q(t,e),onDragLeave:ce,onDrop:t=>le(t,e),onDragEnd:$,onClick:()=>m(e.id),children:[(0,F.jsx)(`td`,{className:`pick`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,F.jsx)(`input`,{type:`checkbox`,checked:U.has(Number(e.id)),onChange:()=>ae(e.id),"aria-label":`选择任务 #${e.id}`})}),(0,F.jsxs)(`td`,{className:`mono faint`,title:t?`拖动整行可调整队列顺序`:void 0,children:[`#`,e.id]}),(0,F.jsx)(`td`,{className:`tx`,children:(0,F.jsxs)(`div`,{className:`mdw-tg-row`,children:[(0,F.jsx)(`span`,{className:`mdw-tg-title`,children:u(e.text)}),e.timegoal?.duration?(0,F.jsxs)(`span`,{className:`mdw-tg`,title:`时间目标 ${e.timegoal.duration}(领取即计时,未到点不许标完成)${e.timegoal.prompt?`\n附加要求:${e.timegoal.prompt}`:``}`,children:[`⏱ `,e.timegoal.duration]}):null,e.blocksFollowing?(0,F.jsxs)(`span`,{className:`mdw-tg`,title:r.length?`闸门:未完成前挡住 ${r.length} 个后续任务(#${r.join(`, #`)})`:`闸门:未完成前挡住队列里排在后面的待领取任务`,children:[`闸门`,r.length?`×${r.length}`:``]}):null,e.status===`pending`&&e.ready===!1?(0,F.jsx)(`span`,{className:`mdw-tg`,title:e.blockBy?.length?`等待依赖完成:#${e.blockBy.join(`, #`)}`:`被前方闸门挡住`,children:`锁定`}):null]})}),(0,F.jsx)(`td`,{children:(0,F.jsx)(`span`,{className:`st `+y(e),title:e.status===`cancelled`?`已取消:被新任务取代或明确作废,原文留档`:e.status===`done`?`已交付`:``,children:k(e)})}),(0,F.jsx)(`td`,{className:`mono faint`,children:I(e.createdAt)}),(0,F.jsx)(`td`,{className:`mono faint`,children:e.consumedAt?I(e.consumedAt):`—`}),(0,F.jsx)(`td`,{className:`act`,children:(0,F.jsxs)(`span`,{className:`act-ops`,children:[t&&(E||O)&&(0,F.jsx)(`span`,{onClick:e=>e.stopPropagation(),children:(0,F.jsx)(n,{items:[{label:`编排依赖…`,onPick:()=>E&&E(e)},{label:e.blocksFollowing?`取消闸门(不再挡后续)`:`设为闸门(挡住后续)`,onPick:()=>O&&O(e)}]})}),x&&e.status!==`cancelled`&&!e.childCount&&(e.status===`claimed`||e.status===`done`||e.completedAt)&&(0,F.jsx)(`span`,{className:`op`,role:`button`,tabIndex:-1,title:e.completedAt?`反馈:新开一条任务(原任务不动)`:`反馈修改:回写本任务并记入任务链`,"aria-label":`反馈 ${u(e.text)}`,onClick:t=>{t.stopPropagation(),x(e)},children:(0,F.jsx)(o,{name:`refresh`,size:12})}),h&&(0,F.jsx)(`span`,{className:`op danger`,role:`button`,tabIndex:-1,title:`删除此任务(软删除,CLI 可恢复)`,"aria-label":`删除 ${u(e.text)}`,onClick:t=>{t.stopPropagation(),h(e)},children:(0,F.jsx)(o,{name:`x`,size:12})})]})})]},e.id)}),!a.length&&(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:`7`,children:(0,F.jsxs)(`div`,{className:`mdw-land-empty`,children:[`还没有页面:点「+ 新建页」写第一篇,或让 agent 往`,e?`全局池`:`这个目录`,`投递任务。`]})})})]})]})}),s>0&&(0,F.jsx)(`div`,{className:`mdw-land-pager`,children:(0,F.jsx)(b,{page:l,pageCount:d,total:s,onPage:f,unit:`个任务`})})]})}var L=(e,t,n)=>j(e=>n.get(e)||[],e,t);function R({task:e,tasks:t,onClose:n,onSave:r}){let i=e=>Number(e.id),o=i(e),s=t.filter(e=>i(e)!==o),[c,l]=(0,P.useState)(!!e.blocksFollowing),[d,f]=(0,P.useState)(()=>new Set((e.blockBy||[]).map(Number))),[p,m]=(0,P.useState)(()=>new Set(s.filter(e=>(e.blockBy||[]).map(Number).includes(o)).map(i))),[h,g]=(0,P.useState)(!1),_=t.findIndex(e=>i(e)===o),v=t.slice(_+1).map(i),y=new Map(t.map(e=>[i(e),i(e)===o?[...d]:(e.blockBy||[]).map(Number)])),b=e=>c||!d.has(i(e))&&L(i(e),o,y),x=e=>!p.has(i(e))&&L(o,i(e),y),S=e=>t=>e(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}),C=()=>l(e=>(e||f(new Set),!e)),w=async()=>{g(!0);try{let e=[{id:o,gate:c,blockBy:[...d]}];if(!c)for(let t of s){let n=i(t),r=p.has(n),a=(t.blockBy||[]).map(Number);r!==a.includes(o)&&e.push({id:n,blockBy:r?[...a,o]:a.filter(e=>e!==o)})}await r(e),n()}catch{}finally{g(!1)}},T=(e,t,n,r)=>{let a=u(e.text)||`#${i(e)}`;return(0,F.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!h?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:t,disabled:h||n,onChange:()=>r(i(e))}),(0,F.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,F.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,F.jsx)(a,{title:`编排 · #${o} ${u(e.text)||``}`,onClose:n,busy:h,size:`md`,footer:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:h,onClick:n,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:h,onClick:w,children:h?`保存中…`:`保存编排`})]}),children:(0,F.jsxs)(`div`,{className:`mdw-dag`,children:[(0,F.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:c,disabled:h,onChange:C}),(0,F.jsx)(`b`,{children:`闸门`}),(0,F.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),c?(0,F.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,v.length,` 个后续任务`,v.length?`:${v.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,F.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,c?(0,F.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,F.jsx)(`div`,{className:`mdw-dag-list`+(c?` dim`:``),children:s.length?s.map(e=>T(e,d.has(i(e)),b(e),S(f))):(0,F.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,F.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,c?(0,F.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,F.jsx)(`div`,{className:`mdw-dag-list`+(c?` dim`:``),children:s.length?s.map(e=>T(e,p.has(i(e)),c||x(e),S(m))):(0,F.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,F.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}function z(e){let t=String(e||``).trim();if(!t)return`—`;let n=t.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/);return n?`${n[1].slice(5)} ${n[2]}`:t.slice(0,16)}function ie({tasks:e=[],onClose:t,onRestore:n,onPurge:r}){return(0,F.jsx)(a,{title:`已删除任务(${e.length})`,onClose:t,children:e.length===0?(0,F.jsx)(`div`,{className:`mdw-del-empty`,children:`这个目录没有已删除的任务。`}):(0,F.jsx)(`table`,{className:`mdw-del-list`,children:(0,F.jsx)(`tbody`,{children:e.map(e=>(0,F.jsxs)(`tr`,{children:[(0,F.jsxs)(`td`,{className:`mdw-del-id mono`,children:[`#`,e.id]}),(0,F.jsx)(`td`,{className:`mdw-del-title`,title:u(e.text),children:u(e.text)||`—`}),(0,F.jsx)(`td`,{className:`mdw-del-time mono`,children:z(e.deletedAt)}),(0,F.jsxs)(`td`,{className:`mdw-del-ops`,children:[(0,F.jsx)(`button`,{type:`button`,className:`btn sm ghost`,title:`恢复到队列原位置`,onClick:()=>n?.(e),children:`恢复`}),(0,F.jsx)(`button`,{type:`button`,className:`btn sm danger`,title:`彻底删除(不可恢复)`,onClick:()=>r?.(e),children:`彻底删除`})]})]},e.id))})})})}var B=20;function V({dirKey:e}){let{dialog:n,node:a}=r(),o=S()||{},c=i(),l=o.rows||[],u=o.refreshLocal,y=o.tpl,b=o.model,k=o.repoData&&o.repoData.repos||[],A=!e||e===`__GLOBAL__`,[j,N]=(0,P.useState)(null),[ne,I]=(0,P.useState)(!1),[L,z]=(0,P.useState)(null),V=(0,P.useRef)(null),H=(0,P.useMemo)(()=>A?l.find(e=>e.isGlobal)||null:l.find(t=>t.key===e)||null,[l,e,A]),U=(0,P.useMemo)(()=>{if(!H||A)return null;let e=H.repo&&H.repo.key;if(e){let t=k.find(t=>t.key===e);if(t)return t}let t=String(H.cwd||``).replace(/\\/g,`/`).toLowerCase();return t&&k.find(e=>String(e.path||``).replace(/\\/g,`/`).toLowerCase()===t)||null},[H,k,A]),W=(0,P.useMemo)(()=>f((H?.tasks||[]).filter(e=>!e.deletedAt&&!p(e))),[H]),G=_(W,B),K=(0,P.useMemo)(()=>W.filter(e=>e.status===`pending`&&!e.migratedTo).length,[W]),q=e=>e().catch(e=>c(String(e.message||e))),J=()=>A?{key:m}:{cwd:H.cwd},ae=(e,n,r)=>{q(async()=>{await t(`/api/localtasks/reorder`,{method:`PATCH`,body:{...J(),id:e.id,...r===`before`?{beforeId:n}:{afterId:n}}}),u()})},oe=e=>{q(async()=>{await t(`/api/localtasks/item`,{method:`PATCH`,body:{...J(),id:e.id,gate:!e.blocksFollowing}}),c(e.blocksFollowing?`#${e.id} 闸门已取消`:`#${e.id} 已设为闸门——挡住所有后续待领取任务`),u()})},Y=async e=>{try{for(let n of e)await t(`/api/localtasks/item`,{method:`PATCH`,body:{...J(),...n}});c(`编排已保存`),u()}catch(e){throw c(String(e.message||e)),e}},X=(0,P.useMemo)(()=>{let e={},t=W.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt);return t.forEach((n,r)=>{n.blocksFollowing&&(e[n.id]=t.slice(r+1).map(e=>e.id))}),e},[W]),Z=(0,P.useMemo)(()=>W.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),[W]),se=t=>{o.openPage&&o.openPage({dirKey:e,task:String(t),name:`#${t}`})},Q=t=>{let n=O();T(D(C(e),n),{title:``,body:t}),o.openPage&&o.openPage({dirKey:e,task:n,name:`新任务`})},ce=()=>{b&&v(b)},le=()=>{b&&h(b,{component:`progress`,name:`进程`,config:{dirKey:e||`__GLOBAL__`},location:`right`})},$=A?m:e,ue=E($).templates||y&&y.templates||[],de=()=>{if(!b){c(`工作区未就绪`);return}w(b,{mode:`new`,topic:$,scope:A?[]:[`topic:${$}`],name:``})},fe=[...ue.length?ue.map(e=>({label:(e.id===y?.defaultId?`✓ `:``)+e.name,icon:`list`,onClick:()=>Q(x(e.body,{...d,...e.values||{}}))})):[{label:`按默认模板新建一页`,icon:`list`,onClick:()=>Q(y?y.defaultBody():``)}],`sep`,{label:`为本${A?`全局池`:`目录`}新建模板…`,icon:`plus`,onClick:de},{label:`管理模板…`,icon:`gear`,onClick:ce}],pe=async e=>{if(e==null)return null;let n=A?`key=${encodeURIComponent(m)}&id=${Number(e.id)}`:`cwd=${encodeURIComponent(H?.cwd||``)}&id=${Number(e.id)}`;return t(`/api/localtasks/item?${n}`).catch(()=>null)},me=r=>{if(!r)return;let i=(r.text||``).split(`
|
|
2
|
+
`).find(e=>e.trim())||`#${r.id}`;q(async()=>{let a=!!r.completedAt,o=await n({title:a?`反馈 · #${r.id}`:`反馈修改 · #${r.id}`,input:!0,placeholder:a?`写下反馈(将新开一条任务,原任务不动)`:`写下要改的地方(留空 = 只重开,不改正文)`});if(o==null)return;let s=String(o).trim(),l=await pe(r),d=String(l?.text??``).trim()||String(r.text||``).trim(),f=a&&(l?.roundSummary||r.roundSummary)||``;if(!s&&!a&&!d){c(`拿不到任务当前正文,已取消(防止丢内容)`);return}if(a){let n=s?M({base:d,feedback:s,ackSummary:f,feedbackHeading:ee,bold:!0}):``;if(!n){c(`写一下反馈`);return}let a=await t(`/api/localtasks`,{method:`POST`,body:A?{global:!0,text:n,forkOf:String(r.id),forkKind:`reopen`}:{cwd:H.cwd,text:n,forkOf:String(r.id),forkKind:`reopen`}}),o=String(a?.task?.id??a?.id??``),l=a?.key||e;o&&T(D(C(l),o),{body:n}),c(`已反馈「${i.replace(/^#\s*/,``)}」→ 新任务 #${o||`?`}`),u();return}let p=await t(`/api/localtasks/reopen`,{method:`POST`,body:{...J(),id:r.id,kind:`reopen`,...s?{feedback:s,feedbackHeading:te,feedbackBold:!1}:{}}}),m=p?.key||e,h=String(p?.task?.id??r.id),g=String(p?.task?.text??``);g&&T(D(C(m),h),{body:g}),c(`已回写「${i.replace(/^#\s*/,``)}」#${h}`+(p?.moved&&p.name?`;归属迁到「${p.name}」`:``)),u()})},he=async r=>{if(!r)return;let i=(r.text||``).split(`
|
|
3
|
+
`).find(e=>e.trim())||`#${r.id}`;await n({title:`删除任务「${i.replace(/^#\s*/,``)}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&q(async()=>{if(await t(`/api/localtasks/item`,{method:`DELETE`,body:A?{key:m,id:r.id}:{cwd:H.cwd,id:r.id}}),c(`已删除「${i.replace(/^#\s*/,``)}」`),b){let t=g(b,`page`,{dirKey:e,task:String(r.id)});t&&o.closePanel&&o.closePanel(t.getId())}u()})},ge=async e=>{let r=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!r.length||!await n({title:`删除选中的 ${r.length} 条任务`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})?!1:q(async()=>{let e=await t(`/api/localtasks/items`,{method:`DELETE`,body:{...J(),ids:r}});return c(`已删除 ${e?.count??r.length} 条任务`),u(),!0})},_e=async e=>{let r=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!r.length||!await n({title:`取消选中的 ${r.length} 条待领取任务`,message:`只处理待领取任务;已领取/已交付/已取消会跳过。取消为终态,原文留档。`,okText:`取消任务`})?!1:q(async()=>{let e=await t(`/api/localtasks/items/cancel`,{method:`POST`,body:{...J(),ids:r}}),n=e?.skipped?.length||0;return c(`已取消 ${e?.count??0} 条任务${n?`,跳过 ${n} 条`:``}`),u(),!0})},ve=async e=>{let r=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!r.length||!await n({title:`把选中的 ${r.length} 条待领取任务标为完成`,message:`只处理待领取任务;已领取/已交付/已取消会跳过。完成会补一条完成记录,原文留档。`,okText:`标为完成`})?!1:q(async()=>{let e=await t(`/api/localtasks/items/close`,{method:`POST`,body:{...J(),ids:r,status:`done`}}),n=e?.skipped?.length||0;return c(`已标为完成 ${e?.count??0} 条任务${n?`,跳过 ${n} 条`:``}`),u(),!0})},ye=(0,P.useMemo)(()=>(H?.tasks||[]).filter(e=>e.deletedAt).slice().reverse(),[H]),be=e=>{e&&q(async()=>{await t(`/api/localtasks/tasks/restore`,{method:`POST`,body:A?{key:m,id:e.id}:{cwd:H.cwd,id:e.id}}),c(`已恢复 #${e.id}「${(e.text||``).split(`
|
|
4
|
+
`).find(e=>e.trim())?.replace(/^#\s*/,``)||``}」`),u()})},xe=async e=>{if(!e)return;let r=(e.text||``).split(`
|
|
5
|
+
`).find(e=>e.trim())||`#${e.id}`;await n({title:`彻底删除「${r.replace(/^#\s*/,``)}」`,message:`彻底删除后不可恢复(行从队列里真正摘除)。`,danger:!0,okText:`彻底删除`})&&q(async()=>{await t(`/api/localtasks/item`,{method:`DELETE`,body:{...A?{key:m}:{cwd:H.cwd},id:e.id,purge:!0}}),c(`已彻底删除 #${e.id}`),u()})},Se=()=>I(!0),Ce=()=>{if(A||!U){c(`全局池没有项目文档列表`);return}if(!b)return;let e=U.key||H.repo&&H.repo.key||``;if(!e){c(`这个项目还没有仓库标识(key),无法定位文档列表`);return}h(b,{component:`refs`,name:`文档列表`,config:{repoKey:e},location:`right`})},we=async e=>{let n=await e.text(),r=e.name.replace(/\.md$/i,``);await q(async()=>{let i=n.startsWith(`#`)?n:`# ${r}\n\n${n}`,a=await t(`/api/localtasks`,{method:`POST`,body:A?{global:!0,text:i}:{cwd:H.cwd,text:i}});c(`已导入:${e.name}`),u();let o=a?.task?.id??a?.id;o!=null&&se(o)})};return!H&&!A?(0,F.jsx)(`div`,{className:`mdw`,children:(0,F.jsx)(`div`,{className:`mdw-main`,children:(0,F.jsx)(`div`,{className:`mdw-top`,children:(0,F.jsxs)(`div`,{className:`mdw-head`,children:[(0,F.jsx)(`div`,{className:`mdw-title`,children:`目录不存在`}),(0,F.jsx)(`div`,{className:`mdw-path`,children:`—`})]})})})}):(0,F.jsxs)(`div`,{className:`mdw`,children:[(0,F.jsx)(`div`,{className:`mdw-main`,children:(0,F.jsx)(re,{isGlobal:A,topic:H,repo:U,model:b,tasks:G.items,taskCount:G.total,pendingCount:K,page:G.page,pageCount:G.pageCount,onPage:G.setPage,onNew:()=>Q(y?y.defaultBody():``),onOpenTask:se,onDeleteTask:he,onDeleteTasks:ge,onCancelTasks:_e,onCompleteTasks:ve,onReopenTask:me,onTplMenu:e=>N({x:e.clientX,y:e.clientY}),onImport:()=>V.current?.click(),onProg:le,onMoveTask:ae,onOpenDag:z,onOpenFlow:()=>b&&h(b,{component:`dag`,name:`编排`,config:{dirKey:e}}),onToggleGate:oe,downstreamOf:X,onDeleted:Se,onRefs:Ce,deletedCount:ye.length})}),L&&(0,F.jsx)(R,{task:L,tasks:Z,onClose:()=>z(null),onSave:Y}),ne&&(0,F.jsx)(ie,{tasks:ye,onClose:()=>I(!1),onRestore:be,onPurge:xe}),j&&(0,F.jsx)(s,{x:j.x,y:j.y,items:fe,onClose:()=>N(null)}),(0,F.jsx)(`input`,{ref:V,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&we(t)}}),a]})}export{V as default};
|