nx-kv 0.48.1 → 0.48.2

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.
Files changed (241) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.json +1 -1
  3. package/src/modules/auth/actions/auth-login.ts +11 -4
  4. package/src/modules/auth/actions/auth-logout.ts +9 -4
  5. package/src/modules/auth/actions/auth-me.ts +9 -4
  6. package/src/modules/auth/actions/auth-status.ts +9 -4
  7. package/src/modules/bundled/actions/bundled-get.ts +12 -4
  8. package/src/modules/bundled/actions/bundled-groups.ts +9 -4
  9. package/src/modules/bundled/actions/bundled-install.ts +13 -4
  10. package/src/modules/bundled/actions/bundled-list.ts +9 -4
  11. package/src/modules/db/actions/db-backup.ts +10 -4
  12. package/src/modules/db/actions/db-migrate.ts +10 -4
  13. package/src/modules/db/actions/db-status.ts +9 -4
  14. package/src/modules/db/actions/db-verify.ts +9 -4
  15. package/src/modules/docs/actions/doc-add.ts +12 -4
  16. package/src/modules/docs/actions/doc-attach-note.ts +11 -4
  17. package/src/modules/docs/actions/doc-attach.ts +18 -4
  18. package/src/modules/docs/actions/doc-attachments.ts +9 -4
  19. package/src/modules/docs/actions/doc-detach.ts +11 -4
  20. package/src/modules/docs/actions/doc-get.ts +9 -4
  21. package/src/modules/docs/actions/doc-list.ts +9 -4
  22. package/src/modules/docs/actions/doc-remove.ts +9 -4
  23. package/src/modules/docs/actions/doc-update.ts +12 -4
  24. package/src/modules/docs/actions/docs-bind.ts +13 -4
  25. package/src/modules/docs/actions/docs-index.ts +9 -4
  26. package/src/modules/docs/actions/docs-link.ts +14 -4
  27. package/src/modules/docs/actions/docs-notebind.ts +13 -4
  28. package/src/modules/docs/actions/docs-seed.ts +9 -4
  29. package/src/modules/file/actions/file-content.ts +10 -4
  30. package/src/modules/file/actions/file-get.ts +10 -4
  31. package/src/modules/file/actions/file-list.ts +11 -4
  32. package/src/modules/file/actions/file-orphans.ts +9 -4
  33. package/src/modules/file/actions/file-prune.ts +10 -4
  34. package/src/modules/file/actions/file-remove.ts +10 -4
  35. package/src/modules/file/actions/file-sync.ts +13 -4
  36. package/src/modules/file/actions/file-upload.ts +15 -4
  37. package/src/modules/localtask/actions/localtask-add.ts +24 -4
  38. package/src/modules/localtask/actions/localtask-attach-note.ts +13 -4
  39. package/src/modules/localtask/actions/localtask-attach.ts +22 -4
  40. package/src/modules/localtask/actions/localtask-attachments.ts +11 -4
  41. package/src/modules/localtask/actions/localtask-cancel.ts +10 -4
  42. package/src/modules/localtask/actions/localtask-cancelMany.ts +11 -4
  43. package/src/modules/localtask/actions/localtask-chain.ts +11 -4
  44. package/src/modules/localtask/actions/localtask-claim.ts +12 -4
  45. package/src/modules/localtask/actions/localtask-clone.ts +11 -4
  46. package/src/modules/localtask/actions/localtask-closeMany.ts +13 -4
  47. package/src/modules/localtask/actions/localtask-config.ts +19 -4
  48. package/src/modules/localtask/actions/localtask-detach.ts +13 -4
  49. package/src/modules/localtask/actions/localtask-done.ts +12 -4
  50. package/src/modules/localtask/actions/localtask-events.ts +12 -4
  51. package/src/modules/localtask/actions/localtask-fork.ts +11 -4
  52. package/src/modules/localtask/actions/localtask-get.ts +11 -4
  53. package/src/modules/localtask/actions/localtask-importRemote.ts +13 -4
  54. package/src/modules/localtask/actions/localtask-list.ts +9 -4
  55. package/src/modules/localtask/actions/localtask-presence.ts +9 -4
  56. package/src/modules/localtask/actions/localtask-preview.ts +13 -4
  57. package/src/modules/localtask/actions/localtask-prune.ts +10 -4
  58. package/src/modules/localtask/actions/localtask-remove.ts +12 -4
  59. package/src/modules/localtask/actions/localtask-removeMany.ts +12 -4
  60. package/src/modules/localtask/actions/localtask-reopen.ts +17 -4
  61. package/src/modules/localtask/actions/localtask-reorder.ts +15 -4
  62. package/src/modules/localtask/actions/localtask-task-restore.ts +11 -4
  63. package/src/modules/localtask/actions/localtask-timegoalLog.ts +11 -4
  64. package/src/modules/localtask/actions/localtask-topic-add.ts +10 -4
  65. package/src/modules/localtask/actions/localtask-topic-remove.ts +11 -4
  66. package/src/modules/localtask/actions/localtask-topic-removeMany.ts +12 -4
  67. package/src/modules/localtask/actions/localtask-update.ts +22 -4
  68. package/src/modules/localtask/actions/localtask-wait.ts +13 -4
  69. package/src/modules/localtask/actions/task-move.ts +21 -4
  70. package/src/modules/repos/actions/board-add.ts +10 -4
  71. package/src/modules/repos/actions/board-assign.ts +12 -4
  72. package/src/modules/repos/actions/board-export.ts +9 -4
  73. package/src/modules/repos/actions/board-get.ts +9 -4
  74. package/src/modules/repos/actions/board-import.ts +9 -4
  75. package/src/modules/repos/actions/board-list.ts +9 -4
  76. package/src/modules/repos/actions/board-note.ts +11 -4
  77. package/src/modules/repos/actions/board-prefix.ts +10 -4
  78. package/src/modules/repos/actions/board-prune.ts +11 -4
  79. package/src/modules/repos/actions/board-rekey.ts +11 -4
  80. package/src/modules/repos/actions/board-remove.ts +9 -4
  81. package/src/modules/repos/actions/board-update.ts +11 -4
  82. package/src/modules/repos/actions/repo-add.ts +17 -4
  83. package/src/modules/repos/actions/repo-bind-topics.ts +10 -4
  84. package/src/modules/repos/actions/repo-bind.ts +12 -4
  85. package/src/modules/repos/actions/repo-clone.ts +14 -4
  86. package/src/modules/repos/actions/repo-detect.ts +9 -4
  87. package/src/modules/repos/actions/repo-doc-add.ts +15 -4
  88. package/src/modules/repos/actions/repo-doc-list.ts +9 -4
  89. package/src/modules/repos/actions/repo-doc-remove.ts +10 -4
  90. package/src/modules/repos/actions/repo-export.ts +12 -4
  91. package/src/modules/repos/actions/repo-get.ts +9 -4
  92. package/src/modules/repos/actions/repo-import-diff.ts +10 -4
  93. package/src/modules/repos/actions/repo-import.ts +14 -4
  94. package/src/modules/repos/actions/repo-key-migrate.ts +9 -4
  95. package/src/modules/repos/actions/repo-key-refresh.ts +11 -4
  96. package/src/modules/repos/actions/repo-key-set.ts +11 -4
  97. package/src/modules/repos/actions/repo-knowledge.ts +10 -4
  98. package/src/modules/repos/actions/repo-list.ts +9 -4
  99. package/src/modules/repos/actions/repo-open.ts +9 -4
  100. package/src/modules/repos/actions/repo-ref-add.ts +13 -4
  101. package/src/modules/repos/actions/repo-ref-backfill.ts +10 -4
  102. package/src/modules/repos/actions/repo-ref-check.ts +9 -4
  103. package/src/modules/repos/actions/repo-ref-clone.ts +16 -4
  104. package/src/modules/repos/actions/repo-ref-note.ts +12 -4
  105. package/src/modules/repos/actions/repo-ref-of.ts +9 -4
  106. package/src/modules/repos/actions/repo-ref-sync.ts +10 -4
  107. package/src/modules/repos/actions/repo-remote-check.ts +10 -4
  108. package/src/modules/repos/actions/repo-remote-list.ts +9 -4
  109. package/src/modules/repos/actions/repo-remote-pick.ts +10 -4
  110. package/src/modules/repos/actions/repo-remote.ts +11 -4
  111. package/src/modules/repos/actions/repo-remove.ts +9 -4
  112. package/src/modules/repos/actions/repo-scan.ts +11 -4
  113. package/src/modules/repos/actions/repo-update.ts +21 -4
  114. package/src/modules/setting/actions/setting-get.ts +9 -4
  115. package/src/modules/setting/actions/setting-set.ts +12 -4
  116. package/src/modules/system/actions/bootstrap.ts +7 -4
  117. package/src/modules/system/actions/health.ts +6 -3
  118. package/src/modules/system/actions/routes.ts +11 -3
  119. package/src/modules/system/routes.ts +1 -1
  120. package/src/modules/tasktool/actions/timegoal-check.ts +11 -4
  121. package/src/modules/tasktool/actions/timegoal-clear.ts +9 -4
  122. package/src/modules/tasktool/actions/timegoal-list.ts +9 -4
  123. package/src/modules/tasktool/actions/timegoal-log.ts +9 -4
  124. package/src/modules/tasktool/actions/timegoal-prune.ts +9 -4
  125. package/src/modules/tasktool/actions/timegoal-set.ts +11 -4
  126. package/src/modules/tasktool/actions/timegoal-show.ts +10 -4
  127. package/src/modules/tasktool/actions/timegoal-update.ts +11 -4
  128. package/src/modules/templates/actions/templates-add.ts +17 -4
  129. package/src/modules/templates/actions/templates-default.ts +13 -4
  130. package/src/modules/templates/actions/templates-list.ts +11 -4
  131. package/src/modules/templates/actions/templates-remove.ts +9 -4
  132. package/src/modules/templates/actions/templates-update.ts +15 -4
  133. package/src/modules/todo/actions/group-add.ts +10 -4
  134. package/src/modules/todo/actions/group-current.ts +9 -4
  135. package/src/modules/todo/actions/group-get.ts +9 -4
  136. package/src/modules/todo/actions/group-list.ts +9 -4
  137. package/src/modules/todo/actions/group-members.ts +9 -4
  138. package/src/modules/todo/actions/group-remove.ts +9 -4
  139. package/src/modules/todo/actions/group-update.ts +11 -4
  140. package/src/modules/todo/actions/group-use.ts +9 -4
  141. package/src/modules/todo/actions/prompt-get.ts +10 -4
  142. package/src/modules/todo/actions/prompt-remove.ts +10 -4
  143. package/src/modules/todo/actions/prompt-set.ts +11 -4
  144. package/src/modules/todo/actions/todo-add.ts +11 -4
  145. package/src/modules/todo/actions/todo-archive.ts +10 -4
  146. package/src/modules/todo/actions/todo-attach.ts +17 -4
  147. package/src/modules/todo/actions/todo-attachments.ts +12 -4
  148. package/src/modules/todo/actions/todo-done.ts +13 -4
  149. package/src/modules/todo/actions/todo-freeze.ts +12 -4
  150. package/src/modules/todo/actions/todo-get.ts +12 -4
  151. package/src/modules/todo/actions/todo-list.ts +11 -4
  152. package/src/modules/todo/actions/todo-remove.ts +12 -4
  153. package/src/modules/todo/actions/todo-unfreeze.ts +12 -4
  154. package/src/modules/todo/actions/todo-update.ts +15 -4
  155. package/src/modules/todo/actions/topic-add.ts +10 -4
  156. package/src/modules/todo/actions/topic-list.ts +9 -4
  157. package/src/modules/todo/actions/topic-remove.ts +10 -4
  158. package/src/runtime/action-decorator.ts +2 -2
  159. package/src/runtime/codegen.ts +26 -41
  160. package/src/runtime/registry.ts +2 -2
  161. package/src/web/frontend/api/client.generated.ts +384 -532
  162. package/src/web/frontend/page/cloud/api.ts +99 -0
  163. package/src/web/frontend/page/cloud/index.tsx +13 -32
  164. package/src/web/frontend/page/dag/api.ts +20 -0
  165. package/src/web/frontend/page/dag/index.tsx +2 -5
  166. package/src/web/frontend/page/dir/api.ts +135 -0
  167. package/src/web/frontend/page/dir/index.tsx +37 -57
  168. package/src/web/frontend/page/dir/task-actions.ts +39 -59
  169. package/src/web/frontend/page/dir/task-chain.ts +2 -2
  170. package/src/web/frontend/page/dir/task-feedback.ts +19 -23
  171. package/src/web/frontend/page/dir/task-goal.ts +3 -3
  172. package/src/web/frontend/page/dir/task.tsx +3 -3
  173. package/src/web/frontend/page/doc/api.ts +82 -0
  174. package/src/web/frontend/page/doc/index.tsx +29 -32
  175. package/src/web/frontend/page/group/api.ts +24 -0
  176. package/src/web/frontend/page/group/index.tsx +7 -16
  177. package/src/web/frontend/page/overview/api.ts +16 -0
  178. package/src/web/frontend/page/overview/index.tsx +2 -2
  179. package/src/web/frontend/page/progress/api.ts +20 -0
  180. package/src/web/frontend/page/progress/index.tsx +3 -6
  181. package/src/web/frontend/page/refs/api.ts +14 -0
  182. package/src/web/frontend/page/refs/index.tsx +2 -4
  183. package/src/web/frontend/page/repos/api.ts +197 -0
  184. package/src/web/frontend/page/repos/bind-modals.tsx +4 -7
  185. package/src/web/frontend/page/repos/board-admin.tsx +6 -6
  186. package/src/web/frontend/page/repos/doc-search-modal.tsx +4 -4
  187. package/src/web/frontend/page/repos/index.tsx +10 -14
  188. package/src/web/frontend/page/repos/pending-section.tsx +7 -13
  189. package/src/web/frontend/page/repos/ref-panel.tsx +9 -14
  190. package/src/web/frontend/page/repos/remote-modal.tsx +4 -28
  191. package/src/web/frontend/page/repos/repo-form-modal.tsx +4 -4
  192. package/src/web/frontend/page/settings/api.ts +29 -0
  193. package/src/web/frontend/page/settings/index.tsx +3 -3
  194. package/src/web/frontend/page/settings/prompt-templates-section.tsx +4 -4
  195. package/src/web/frontend/page/settings/sidebar-section.tsx +2 -2
  196. package/src/web/public/assets/Introduction-Du_dycft.js +6 -0
  197. package/src/web/public/assets/{bar-B9WWmCpt.js → bar-B52NTf_v.js} +1 -1
  198. package/src/web/public/assets/cloud-Droja_aT.js +3 -0
  199. package/src/web/public/assets/{composer-panel-ByezS8Xv.js → composer-panel-DpiU2h50.js} +1 -1
  200. package/src/web/public/assets/dag-Ca-wjIxQ.js +1 -0
  201. package/src/web/public/assets/{deleted-panel-BcbtctNF.js → deleted-panel-K9GgfR8t.js} +1 -1
  202. package/src/web/public/assets/dir-DacRpcBt.js +5 -0
  203. package/src/web/public/assets/group-TPuU-QVc.js +2 -0
  204. package/src/web/public/assets/{index-D8MvtVAm.js → index-BkLkooKe.js} +2 -2
  205. package/src/web/public/assets/{md-history-BqZvzWiD.js → md-history-0GBWw4qr.js} +1 -1
  206. package/src/web/public/assets/overview-B3kHI66i.js +1 -0
  207. package/src/web/public/assets/progress-CdhFz0Lz.js +3 -0
  208. package/src/web/public/assets/refs-BDxfuH6R.js +1 -0
  209. package/src/web/public/assets/repos-C8jRM7wS.js +15 -0
  210. package/src/web/public/assets/{route-crumb-CWVu80du.js → route-crumb-QvahotvN.js} +1 -1
  211. package/src/web/public/assets/settings-BBcdGLTc.js +1 -0
  212. package/src/web/public/assets/{status-tag-DRl9E2Os.js → status-tag-BheHByek.js} +1 -1
  213. package/src/web/public/assets/task-CUkQaLBZ.js +11 -0
  214. package/src/web/public/assets/task-utils-_JAWRAz6.js +12 -0
  215. package/src/web/public/assets/{templates-Df__0k-F.js → templates-CbRyW3PJ.js} +1 -1
  216. package/src/web/public/assets/{tool-bar-Cv7f6p4v.js → tool-bar-BAmT-BI-.js} +1 -1
  217. package/src/web/public/index.html +1 -1
  218. package/src/modules/auth/schemas.ts +0 -27
  219. package/src/modules/bundled/schemas.ts +0 -32
  220. package/src/modules/db/schemas.ts +0 -27
  221. package/src/modules/docs/schemas.ts +0 -107
  222. package/src/modules/file/schemas.ts +0 -61
  223. package/src/modules/localtask/schemas.ts +0 -310
  224. package/src/modules/repos/schemas.ts +0 -310
  225. package/src/modules/setting/schemas.ts +0 -18
  226. package/src/modules/system/schemas.ts +0 -30
  227. package/src/modules/tasktool/schemas.ts +0 -52
  228. package/src/modules/templates/schemas.ts +0 -50
  229. package/src/modules/todo/schemas.ts +0 -177
  230. package/src/web/public/assets/Introduction-aQCeCLrV.js +0 -6
  231. package/src/web/public/assets/cloud-C4b8SU7C.js +0 -3
  232. package/src/web/public/assets/dag-jvrjx4i7.js +0 -1
  233. package/src/web/public/assets/dir-B82XBb1J.js +0 -5
  234. package/src/web/public/assets/group-BPUOO_QM.js +0 -2
  235. package/src/web/public/assets/overview-DMihuyzh.js +0 -1
  236. package/src/web/public/assets/progress-D-rMgz3w.js +0 -3
  237. package/src/web/public/assets/refs-D21jmrn6.js +0 -1
  238. package/src/web/public/assets/repos-B94tMDGs.js +0 -15
  239. package/src/web/public/assets/settings-DgTt4JG5.js +0 -1
  240. package/src/web/public/assets/task-B2x5GoV3.js +0 -11
  241. package/src/web/public/assets/task-utils-By8gLpHY.js +0 -12
@@ -1,6 +0,0 @@
1
- import{g as e,h as t,l as n,m as r,o as i,p as a,v as o,y as s}from"./task-status-DSrx0i66.js";import{r as c,v as l,w as u}from"./workspace-4tw7trV7.js";import{n as d}from"./app-context-BASCGAA-.js";import{_ as f,a as p,i as m,n as h,p as g,r as _,t as v,u as y,v as b,y as x}from"./md-history-BqZvzWiD.js";import{a as S,i as C}from"./upload-BcMhRsMn.js";import{r as ee}from"./md-parse-b6GY5eBl.js";import{t as te}from"./route-crumb-CWVu80du.js";import{a as w,c as T,i as E,l as D,o as O,r as k,s as A,t as j,u as ne}from"./tool-bar-Cv7f6p4v.js";var M=s(e(),1),N=u(),P=t(),F=`doc`,I=[{id:`edit`,label:`编辑`},{id:`doc`,label:`文档`},{id:`view`,label:`查看`}];function re({crumb:e=null,title:t,pathLabel:n=``,dirty:r=!1,writable:i=!1,onSave:a=null,onSaveLabel:o=`保存`,menuGroups:s=[],saving:c=!1,external:l=!1,afterTitle:u=null}){let d=E(),{layout:f,setLayout:p}=O(F),[m,h]=(0,M.useState)(!1),g={};for(let e of s||[])for(let t of e?.items||[])t&&t.id&&(g[t.id]=t);g.save=a&&{id:`save`,label:c?`保存中…`:o,run:a,primary:!0,disabled:c||!r};let _=e=>e===`more`||!!g[e],v=f.filter(e=>D(F,e)&&_(e.id)),y=f.filter(e=>A(F,e)&&_(e.id)),b=e=>{let t=g[e];t&&t.run?.(),d.setOpen(!1)},x=e=>{if(e===`more`)return(0,P.jsx)(`div`,{className:`docp-more`,ref:d.ref,children:(0,P.jsx)(`button`,{type:`button`,className:`btn ghost sm${d.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":d.open,onClick:e=>k(d,e,`right`),children:`更多`})},`more`);let t=g[e];return t?(0,P.jsx)(`button`,{type:`button`,className:t.primary||e===`save`?`btn sm primary docp-save`:`btn ghost sm`,disabled:!!t.disabled,onClick:()=>b(e),children:t.label||T(F,e).label||e},e):null},S=I.map(e=>({...e,items:y.filter(t=>T(F,t.id).menuGroup===e.id)})).filter(e=>e.items.length),C=y.filter(e=>!T(F,e.id).menuGroup);return i?(0,P.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,P.jsxs)(`div`,{className:`mdw-head`,children:[(0,P.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,P.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,P.jsx)(`span`,{className:`grow`}),u,(0,P.jsxs)(`div`,{className:`docp-actions`,children:[v.map(e=>x(e.id)),(0,P.jsxs)(j,{menu:d,className:`mdw-act-menu`,children:[S.map(e=>(0,P.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,P.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=g[e.id],n=t?.danger||T(F,e.id).danger;return(0,P.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>b(e.id),children:[t?.label||T(F,e.id).label||e.id,t?.hint?(0,P.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),C.map(e=>{let t=g[e.id];return(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||T(F,e.id).danger?` danger`:``),onClick:()=>b(e.id),children:t?.label||T(F,e.id).label||e.id},e.id)}),(0,P.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{d.setOpen(!1),h(!0)},children:`自定义工具栏…`})]})]})]}),m&&(0,N.createPortal)((0,P.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>h(!1),children:(0,P.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,P.jsx)(w,{kind:F,layout:f,setLayout:p,onClose:()=>h(!1)})})}),document.body)]}):(0,P.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,P.jsxs)(`div`,{className:`mdw-head`,children:[(0,P.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,P.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,P.jsx)(`span`,{className:`grow`}),u,(0,P.jsx)(`div`,{className:`docp-actions`,children:(0,P.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function L(e,t,n){return{id:e,label:t,items:n.filter(Boolean)}}function R(e){let t=String(e??``).replace(/^/,``).replace(/\r\n/g,`
2
- `),n=t.match(/^---\n([\s\S]*?)\n---\n?/),r=n?t.slice(n[0].length):t;for(let e of r.split(`
3
- `)){let t=e.trim();if(t)return t}return``}function z(e){let t=R(e).match(/^#\s+(.+)$/);return t?(t[1]??``).trim():``}function ie(e,t){let n=String(e??``),r=String(t||``).trim()||`未命名文档`,i=n.replace(/\r\n/g,`
4
- `),a=i.match(/^---\n([\s\S]*?)\n---\n?/),o=a?i.slice(0,a[0].length):``,s=(a?i.slice(a[0].length):i).split(`
5
- `),c=s.findIndex(e=>e.trim());if(c<0)return`${o}# ${r}\n`;let l=s[c]??``;return/^#\s+/.test(l.trim())?s[c]=`# ${r}`:s.splice(c,0,`# ${r}`),`${o}${s.join(`
6
- `)}`}var ae=o({default:()=>V,useWikiNav:()=>B}),oe=b;function B(e){let t=d(),n=a(),i=e||t.model,o=(0,M.useRef)(null),s=(0,M.useCallback)(async()=>{if(!o.current)try{o.current=(await r(`/api/docs/index`)).index||[]}catch{o.current=[]}return o.current??[]},[]),l=(0,M.useCallback)(async(e,t,n={})=>{let r=(t||await s()).find(t=>t.docId===e);c(i,{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`})},[i,s]),u=(0,M.useCallback)(async e=>{let t=await s(),r=x(e,t);if(r&&`docId`in r)return l(r.docId,t);if(r&&`candidates`in r)return n(`「${e}」同名文档多份:${r.candidates.join(`、`)}`);n(`未找到「${e}」——可用 nx-kv docs add <rel> 创建`)},[s,l,n]);return{nav:u,onClick:(0,M.useCallback)(e=>{let t=e.target.closest(`[data-wl]`);t&&(e.preventDefault(),u(t.getAttribute(`data-wl`)))},[u]),ensureIndex:s,openByDocId:l}}function V({docId:e,repoKey:t,boardKey:i,boardName:o,model:s,tabId:u}){let d=a(),{dialog:b,node:x}=n(),w=(0,M.useRef)(new Map),T=(0,M.useRef)(null),E=(0,M.useRef)(null),{onClick:D,openByDocId:O}=B(s),k=t?`repo`:i?`board`:``,A=t||i||``,j=(0,M.useMemo)(()=>t?{repoKey:t}:i?{boardKey:i,boardName:o||``}:{},[t,i,o]),[N,F]=(0,M.useState)(null),[I,R]=(0,M.useState)(``),[ae,V]=(0,M.useState)(!1),[U,W]=(0,M.useState)(`split`),[G,K]=(0,M.useState)([]),[q,J]=(0,M.useState)(null),Y=(0,M.useRef)(null);(0,M.useEffect)(()=>{Y.current=N},[N]);let X=(0,M.useCallback)(async()=>{R(``);try{let t=await r(`/api/docs/item?ref=`+encodeURIComponent(e||``));F(t),V(!1)}catch(e){R(String(e.message||e)),F(null)}},[e]);(0,M.useEffect)(()=>{F(null),X()},[X]);let Z=(0,M.useCallback)(()=>{if(!A){K([]);return}if(k===`repo`){r(`/api/repos/docs?id=`+encodeURIComponent(A)).then(t=>{let n=[],r=(e,t)=>{if(!e)return;let r=e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``;r&&n.push({docId:r,label:e.rel||e.path||(t?`主篇`:`补充`),note:e.note||``,main:t})};r(t.main||{rel:`repo/${A}.md`},!0);for(let e of t.links||[])r(e,!1);e&&!n.some(t=>t.docId===e)&&n.push({docId:e,label:`当前`,note:``,main:!0}),K(n)}).catch(()=>K(e?[{docId:e,label:`当前`,note:``,main:!0}]:[]));return}r(`/api/boards`).then(t=>{let n=(t&&t.boards||(Array.isArray(t)?t:[])).find(e=>e.id===A||e.key===A),r=[];e&&r.push({docId:e,label:`当前`,note:``,main:!0});for(let e of n&&n.docLinks||[]){let t=e.rel?`rel:${e.rel}`:e.path?`path:${e.path}`:``;t&&!r.some(e=>e.docId===t)&&r.push({docId:t,label:e.rel||e.path||`补充`,note:e.note||``,main:!1})}K(r)}).catch(()=>K(e?[{docId:e,label:`当前`,note:``,main:!0}]:[]))},[A,k,e]);(0,M.useEffect)(()=>{Z()},[Z]);let[ce,le]=(0,M.useState)(null);(0,M.useEffect)(()=>{r(`/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());le(t)}).catch(()=>{})},[]);let Q=!!(N&&N.writable),[ue,de]=(0,M.useState)([]);(0,M.useEffect)(()=>{let t=!0;if(e)return r(`/api/docs/attachments?ref=${encodeURIComponent(e)}`).then(e=>{t&&de(e&&(e.attachments||e.data?.attachments)||[])}).catch(()=>{t&&de([])}),()=>{t=!1}},[e]);let fe=(0,M.useMemo)(()=>N?oe(N.body,ue,Q?ce:null):``,[N,ce,Q,ue]),pe=(0,M.useMemo)(()=>N?f(N.body):[],[N]);(0,M.useEffect)(()=>{let e=E.current;if(!e)return;let t=()=>e.querySelector(`.mdw-preview, .mdw-lp`)||null;J(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>J(t())):null;return n&&n.observe(e,{childList:!0,subtree:!0}),()=>{n&&n.disconnect()}},[N,U,fe]);let $=e=>e().catch(e=>d(String(e.message||e))),me=(0,M.useCallback)(e=>O(e,null,j),[O,j]),he=(0,M.useCallback)(()=>{let e=s;e&&A&&c(e,{component:`refs`,name:`文档列表`,config:t?{repoKey:t}:{boardKey:i,boardName:o||``},location:`right`})},[s,A,t,i,o]),ge=()=>{A&&$(async()=>{let t=await b({title:`补充介绍文档`,input:!0,placeholder:`文档名(如 architecture / api-notes)`});if(t===null)return;let n=ee(String(t).trim()||`note`).replace(/\.md$/i,``),i=`${String(e||``).startsWith(`rel:`)?H(e):k===`repo`?`repo/${A}`:`board/${o||A}`}/reference/${n}.md`;await r(`/api/docs/item`,{method:`POST`,body:{rel:i,body:`# ${String(t).trim()||n}\n\n(待补)\n`}});try{k===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:A,rel:i}}):await r(`/api/docs/link`,{method:`POST`,body:{board:A,doc:i}})}catch{}d(`已补充:${i}`),Z(),O(`rel:`+i,null,j)})},_e=()=>$(async()=>{if(!N||!Q)return;let t=N.body,n=await r(`/api/docs/item`,{method:`PATCH`,body:{ref:e,body:t}});F(e=>e&&{...e,body:t,summary:n.summary}),V(!1),v(w.current,e),d(n.summary?`已保存,摘要已回写`:`已保存`)}),ve=(t,n=`op`)=>{N&&(h(w.current,e,{body:N.body},n),V(!0),F(e=>e&&{...e,body:t,title:z(t)||e.title}))},ye=(t,n=`typing`)=>{if(!N)return;h(w.current,e,{body:N.body},n),V(!0);let r=ie(N.body,t);F(e=>e&&{...e,body:r,title:t})},be=()=>{if(!N)return;let t=m(w.current,e,{body:N.body});t&&(F(e=>e&&{...e,body:t.body,title:z(t.body)||e.title}),V(!0),requestAnimationFrame(()=>T.current?.caretFromDiff?.(N.body||``,t.body)))},xe=()=>{if(!N)return;let t=_(w.current,e,{body:N.body});t&&(F(e=>e&&{...e,body:t.body,title:z(t.body)||e.title}),V(!0),requestAnimationFrame(()=>T.current?.caretFromDiff?.(N.body||``,t.body)))},Se=async(t,n={})=>{if(!Q)return;let r=[...t||[]];if(r.length)try{let t=await S(r,{local:!0,onProgress:(e,t,n)=>d(`正在上传 ${e}/${t}:${n.name}`)}),i=C(t);if(!i)return;let a=Y.current||N;if(!a)return;let o=g(a.body,i,n);h(w.current,e,{body:a.body}),V(!0),F(e=>e&&{...e,body:o.body,title:z(o.body)||e.title}),d(`已插入 ${t.length} 个附件`)}catch(e){d(`附件上传失败:${String(e.message||e)}`)}},Ce=()=>{if(!N||!N.rel)return;let t=N.rel,n=N.body;$(async()=>{let i=await b({title:`重命名文档`,input:!0,value:t,placeholder:`新路径(相对 docs 根,以 .md 结尾)`});if(i===null)return;let a=String(i).trim();if(a&&a!==t){if(!/\.md$/i.test(a))return d(`文档路径必须以 .md 结尾`);try{await r(`/api/docs/item`,{method:`POST`,body:{rel:a,body:n}})}catch(e){d(`重命名失败:${String(e.message||e)}`);return}await r(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),v(w.current,e),d(`已重命名为:${a}`),O(`rel:`+a,null,j)}})},we=()=>{if(!N)return;let t=N.title,n=N.rel;$(async()=>{await b({title:`删除文档「${t||n||e}」`,message:`磁盘上的 ${n||e} 会被一并删除,不可恢复。`,danger:!0,okText:`删除`})&&(await r(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),d(`已删除:${n||e}`),s&&u&&s.doAction(l.deleteTab(u)))})},Te=()=>$(async()=>{let t=String(e||``).startsWith(`rel:`)?String(e||``).slice(4):String(e||``).startsWith(`path:`)?``:String(e||``);if(!t)return;let n=t.replace(/\.md$/i,``).split(`/`).pop()||`未命名文档`;await r(`/api/docs/item`,{method:`POST`,body:{rel:t,body:`# ${n}\n\n(待补)\n`}}),d(`已创建:${t}`),await X()});if(N&&N.dir)return(0,P.jsxs)(`div`,{className:`mdw docp`,children:[(0,P.jsxs)(`div`,{className:`docp-head`,children:[(0,P.jsx)(`span`,{className:`docp-path mono`,children:N.path}),(0,P.jsx)(`span`,{className:`docp-tag ext`,children:`外部目录 · 只读`})]}),(0,P.jsxs)(`div`,{className:`docp-files`,children:[(N.files||[]).map(e=>(0,P.jsx)(`button`,{className:`docp-file`,onClick:()=>O(`path:`+e,null),children:e},e)),!(N.files||[]).length&&(0,P.jsx)(`div`,{className:`muted pad`,children:`(目录里还没有 .md 文档)`})]})]});if(I)return(0,P.jsx)(`div`,{className:`mdw docp`,children:(0,P.jsxs)(`div`,{className:`pad stack`,children:[(0,P.jsx)(`div`,{children:(0,P.jsx)(`strong`,{children:`文档打开失败`})}),(0,P.jsx)(`div`,{className:`hint`,children:I})]})});if(!N)return(0,P.jsx)(`div`,{className:`mdw`,children:(0,P.jsx)(`div`,{className:`pad muted`,children:`载入中…`})});if(N.missing){let t=String(e||``).startsWith(`rel:`)||!String(e||``).startsWith(`path:`);return(0,P.jsxs)(`div`,{className:`mdw docp`,children:[(0,P.jsx)(`div`,{className:`docp-head`,children:(0,P.jsx)(`span`,{className:`docp-path mono`,children:N.rel||N.path||e})}),(0,P.jsxs)(`div`,{className:`pad stack`,children:[(0,P.jsx)(`div`,{children:(0,P.jsx)(`strong`,{children:`文档还没有落盘`})}),(0,P.jsx)(`div`,{className:`hint`,children:`描述内容的权威是磁盘上的 .md 文件——对应的字符串字段会在读取时播种,也可以直接创建骨架。`}),t&&(0,P.jsx)(`div`,{children:(0,P.jsx)(`button`,{className:`btn sm`,onClick:Te,children:`创建骨架`})})]})]})}let Ee=Q?U:`read`;return(0,P.jsxs)(`div`,{className:`mdw docp`,"data-mode":Ee,onClick:D,ref:E,children:[(0,P.jsxs)(`div`,{className:`mdw-main`,children:[(0,P.jsx)(re,{crumb:(0,P.jsx)(te,{}),title:N.title||N.rel||N.path||`文档`,pathLabel:N.rel||N.path||``,dirty:ae,writable:Q,external:!!N.external,menuGroups:[L(`edit`,`编辑`,[{id:`mode`,label:U===`edit`?`返回实时预览`:`源码模式`,hint:U===`edit`?`当前`:``,run:()=>W(U===`edit`?`split`:`edit`)}]),L(`doc`,`文档`,[{id:`rename`,label:`重命名`,run:Ce},{id:`delete`,label:`删除`,run:we,danger:!0}]),L(`view`,`查看`,[A&&{id:`list`,label:`文字列表`,hint:`右侧边栏`,run:he}])],onSave:_e}),N.summary&&Q&&(0,P.jsxs)(`div`,{className:`docp-summary`,children:[`摘要(回写 desc):`,N.summary]}),(0,P.jsx)(p,{mode:Ee,title:N.title,body:N.body,previewHtml:fe,onTitle:Q?ye:void 0,onBody:Q?ve:void 0,onFiles:Q?Se:null,attachments:ue,docKey:e,editorApiRef:T,onSave:Q?_e:null,onUndo:Q?be:null,onRedo:Q?xe:null}),(0,P.jsx)(ne,{host:`ref`,refId:e,allow:{file:!0,url:!0,task:!1,ref:!0},disabled:!Q,disabledText:`只读文档不能添加附件。`,onOpenDoc:e=>{let t=y(e);t&&O(t,null,j)}}),(0,P.jsx)(`div`,{className:`docp-hint`,children:`双链 [[]] 点击跳转 · Ctrl+S 保存 · 文档即磁盘文件(~/.nx-kv/docs/)`})]}),(0,P.jsx)(se,{headings:pe,scrollRoot:q,links:G,activeDocId:e,onOpenDoc:A?me:null,onAddRef:A?ge:null}),x]})}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 U(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 W(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function G({kind:e,owner:t,model:n}){let{openByDocId:i}=B(n),a=e===`board`?`组介绍`:`项目介绍`,o=e===`board`&&t?.id||t?.key||``,s=t?.name,c=(0,M.useMemo)(()=>U(t,e),[t,e]),[l,u]=(0,M.useState)([]),[d,f]=(0,M.useState)(``),[p,m]=(0,M.useState)(0),h=(0,M.useCallback)(()=>m(e=>e+1),[]);(0,M.useEffect)(()=>{let n=!0;if(!o){u([]);return}if(e===`repo`)r(`/api/repos/docs?id=`+encodeURIComponent(o)).then(e=>{if(!n)return;let t=[],r=e?.main||null,i=W(r);f(i||c),i&&r&&t.push({docId:i,label:r.rel||r.path||`主篇`,note:r.note||``,tag:r.tag||``,main:!0,ref:r.ref||``});for(let n of e?.extras||[]){let e=W(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=W(n);e&&t.push({docId:e,label:n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}u(t)}).catch(()=>{n&&(u([]),f(c))});else{let e=()=>{let e=[];c&&e.push({docId:c,label:`主篇`,note:``,tag:``,main:!0,ref:``});for(let n of t?.docLinks||[]){let t=W(n);t&&e.push({docId:t,label:n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}return e};r(`/api/boards/`+encodeURIComponent(String(o))).then(t=>{if(!n)return;let r=Array.isArray(t&&t.docLinks)?t.docLinks:null;if(!r){u(e()),f(c);return}let i=[],a=W(t?.introMain)||c;f(a),a&&i.push({docId:a,label:`主篇`,note:``,tag:``,main:!0,ref:``});for(let e of t?.introExtras||[]){let t=W(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 r){let t=W(e);t&&i.push({docId:t,label:e.rel||e.path||`补充`,note:e.note||``,tag:e.tag||``,main:!1,ref:e.ref||``})}u(i)}).catch(()=>{n&&(u(e()),f(c))})}return()=>{n=!1}},[e,o,t,c,p]);let g=(0,M.useMemo)(()=>e===`repo`&&o?{repoKey:o}:e===`board`&&o?{boardKey:o,boardName:s||``}:{},[e,o,s]);return{kind:e,label:a,ownerKey:o,docRef:c,mainDocId:d,links:l,openMain:(0,M.useCallback)(()=>{let e=d||c;e&&i(e,null,g)},[d,c,i,g]),openDoc:(0,M.useCallback)(e=>i(e,null,g),[i,g]),addRef:(0,M.useCallback)(async(t,n)=>{if(!o||!c.startsWith(`rel:`))return n&&n(`当前简介无法补充(需要自有树路径)`),null;let a=await t({title:`补充介绍文档`,input:!0,tagInput:!0,placeholder:`文档名(如 architecture / api-notes)`,tagPlaceholder:`标签(可选,如 qa)`});if(a===null)return null;let l=typeof a==`string`?a:a&&a.value||``,u=typeof a==`object`&&a&&a.tag||``,d=ee(String(l).trim()||`note`).replace(/\.md$/i,``),f=`${H(c)||(e===`repo`?`repo/${o}`:`board/${s||o}`)}/reference/${d}.md`;await r(`/api/docs/item`,{method:`POST`,body:{rel:f,body:`# ${String(l).trim()||d}\n\n(待补)\n`}});try{e===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:o,rel:f,tag:u||void 0}}):await r(`/api/docs/link`,{method:`POST`,body:{board:o,doc:f,tag:u||void 0}})}catch{}return n&&n(`已补充:${f}${u?` [${u}]`:``}`),h(),i(`rel:`+f,null,g),f},[o,c,e,s,i,g,h]),setLinkTag:(0,M.useCallback)(async(t,n,i)=>{if(!o)throw Error(`缺少归属`);let a=String(t||``).startsWith(`path:`)?{path:String(t).slice(5)}:{rel:String(t||``).startsWith(`rel:`)?String(t).slice(4):String(t||``)},s=i&&i.note||``;e===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:o,...a,note:s||void 0,tag:n||void 0}}):await r(`/api/docs/link`,{method:`POST`,body:{board:o,doc:a.path||a.rel,note:s||void 0,tag:n||void 0}}),h()},[o,e,h]),reload:h,canEdit:!!c}}function K(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function q(e){let t=e.rel||e.path||``;return String(t).replace(/[\\/]+$/,``).split(/[\\/]/).pop()||t||`未命名`}function J(e,t,n){let r=[],i=e&&(e.main||e.introMain);i&&r.push({id:K(i),kind:`main`,label:`主篇`,sub:i.rel||i.path||``,tag:``,note:``,docId:K(i),removable:n===`repo`&&!!(t&&t.doc),removeTip:`摘除主篇自定义绑定(回退约定路径,文档不删)`,taggable:!1});for(let t of e&&(e.extras||e.introExtras)||[]){let e=K(t);e&&r.push({id:e,kind:`extra`,label:q(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=K(e);i&&r.push({id:i,kind:`link`,label:q(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 Y={main:`● `,scoped:`◇ `,extra:`○ `,link:`○ `};function X({kind:e,owner:t,model:o,onClose:s,onChanged:l}){let u=a(),{dialog:f,node:p}=n(),m=d(),h=o||m.model,g=G({kind:e,owner:t,model:h}),_=g.ownerKey,v=t&&t.name,[y,b]=(0,M.useState)([]),[x,S]=(0,M.useState)(!0),[C,te]=(0,M.useState)(``),w=(0,M.useCallback)(async()=>{if(!_){b([]),S(!1);return}S(!0);try{let n=e===`repo`?await r(`/api/repos/docs?id=`+encodeURIComponent(_)):await r(`/api/boards/`+encodeURIComponent(String(_)));b(J(n,t,e)),te(``)}catch(e){b([]),te(String(e.message||e))}finally{S(!1)}},[e,_,t]);(0,M.useEffect)(()=>{w()},[w]);let T=t=>{if(!t)return;let n=h;if(!n){u(`工作区不可用,无法打开文档`);return}c(n,{component:`doc`,name:t.label||t.sub||t.docId,config:{docId:t.docId,...e===`repo`?{repoKey:_}:{boardKey:_,boardName:v||``}},location:`center`}),s()},E=e=>e().catch(e=>u(String(e.message||e))),D=t=>E(async()=>{await f({message:`摘除「${t.label}」?${t.kind===`main`?`(只拆绑定,文档不删)`:`(文档不删,仅移出列表)`}`,danger:!0})&&(e===`repo`?await r(`/api/repos/docs`,{method:`DELETE`,body:{id:_,index:t.removeIndex}}):await r(`/api/docs/link`,{method:`POST`,body:{board:_,remove:t.removeIndex}}),u(`已摘除`),w(),l&&l())}),O=e=>E(async()=>{let t=await f({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 g.setLinkTag(e.docId,n,e),u(n?`标签已设为 [${n}]`:`标签已清除`),w(),l&&l()}),k=()=>E(async()=>{if(!_||!String(g.docRef||``).startsWith(`rel:`)){u(`当前简介无法补充(需要自有树路径)`);return}let t=await f({title:`补充介绍文档`,input:!0,tagInput:!0,placeholder:`文档名(如 architecture / api-notes)`,tagPlaceholder:`标签(可选,如 qa)`});if(t===null)return;let n=typeof t==`string`?t:t&&t.value||``,i=typeof t==`object`&&t&&t.tag||``,a=ee(String(n).trim()||`note`).replace(/\.md$/i,``),o=`${H(g.docRef)||(e===`repo`?`repo/${_}`:`board/${v||_}`)}/reference/${a}.md`;await r(`/api/docs/item`,{method:`POST`,body:{rel:o,body:`# ${String(n).trim()||a}\n\n(待补)\n`}});try{e===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:_,rel:o,tag:i||void 0}}):await r(`/api/docs/link`,{method:`POST`,body:{board:_,doc:o,tag:i||void 0}})}catch{}u(`已补充:${o}${i?` [${i}]`:``}`),await w(),l&&l(),T({docId:`rel:`+o,label:String(n).trim()||a,sub:o})}),A=!!String(g.docRef||``).startsWith(`rel:`)&&_,j=y.length,ne=`文档列表 · ${v||``}${e===`board`?`(项目组)`:``}`;return(0,P.jsxs)(i,{size:`md`,title:ne,onClose:s,children:[(0,P.jsxs)(`div`,{className:`nx-dl`,children:[(0,P.jsxs)(`div`,{className:`nx-dl-head`,children:[(0,P.jsx)(`span`,{className:`nx-dl-count`,children:j?`${j} 篇`:`还没有文档`}),(0,P.jsx)(`span`,{className:`nx-dl-hint`,children:`点标题在主内容区打开`}),(0,P.jsx)(`span`,{className:`grow`}),A&&(0,P.jsx)(`button`,{type:`button`,className:`btn ghost sm nx-dl-add`,title:`补充一篇介绍文档(reference)`,onClick:k,children:`+ 补充`})]}),C?(0,P.jsx)(`div`,{className:`rpd-err`,children:C}):null,!C&&x&&j===0?(0,P.jsx)(`div`,{className:`rpd-empty`,children:`载入中…`}):null,!C&&!x&&j===0?(0,P.jsx)(`div`,{className:`rpd-none`,children:`还没有文档 —— 点「+ 补充」写第一篇`}):null,(0,P.jsx)(`div`,{className:`nx-dl-list`,children:y.map(e=>(0,P.jsxs)(`div`,{className:`nx-dl-row-wrap`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`nx-dl-row`,title:`${e.sub||e.label}\n点击在主内容区打开(可编辑)`,onClick:()=>T(e),children:[(0,P.jsxs)(`span`,{className:`nx-dl-row-title`,children:[Y[e.kind]||`○ `,e.label]}),e.tag?(0,P.jsx)(`span`,{className:`rpd-badge`,children:e.tag}):null]}),(0,P.jsxs)(`span`,{className:`nx-docs-modal-item-acts`,children:[e.taggable&&(0,P.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini`,title:e.tag?`改标签(当前:${e.tag})`:`加标签`,onClick:()=>O(e),children:`#`}),e.removable&&(0,P.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini danger`,title:e.removeTip||`摘除「${e.label}」(文档不删)`,onClick:()=>D(e),children:`×`})]})]},e.id))})]}),p]})}function Z(e){return e<=1?18:e===2?12:8}function se({headings:e=[],scrollRoot:t=null,links:n=[],activeDocId:r=``,onOpenDoc:i=null,onAddRef:a=null}){let[o,s]=(0,M.useState)(!1),[c,l]=(0,M.useState)(``),u=(0,M.useMemo)(()=>e||[],[e]),d=(0,M.useMemo)(()=>n||[],[n]);(0,M.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(e=>!!e),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,M.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,P.jsxs)(`aside`,{className:`doc-rail`+(o?` open`:``),"aria-label":`文档目录`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:o?`收起目录`:`展开目录`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[(0,P.jsx)(`span`,{}),(0,P.jsx)(`span`,{}),(0,P.jsx)(`span`,{})]}),(0,P.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`章节`,children:u.map(e=>(0,P.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(c===e.id?` on`:``),style:{"--tw":`${Z(e.level)}px`},title:e.text,"aria-current":c===e.id?`true`:void 0,onClick:()=>f(e.id)},e.id))}),o&&(0,P.jsxs)(`div`,{className:`doc-rail-panel`,children:[u.length>0&&(0,P.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,P.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`本章`}),u.map(e=>(0,P.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,P.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,P.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`介绍文档`}),d.map(e=>(0,P.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,P.jsx)(`button`,{type:`button`,className:`doc-rail-add`,onClick:a,children:`+ 补充文档`})]})]})]})}function ce({kind:e,owner:t,model:n}){let{label:r,docRef:i,links:a,openMain:o}=G({kind:e,owner:t,model:n}),[s,c]=(0,M.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,P.jsxs)(`div`,{className:`nx-intro`,children:[(0,P.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,P.jsx)(`button`,{type:`button`,className:`nx-intro-link-main`,title:`打开${r}(在主内容区阅读 / 编辑)`,onClick:o,children:r}),(0,P.jsx)(`span`,{className:`nx-intro-path mono`,children:d}),(0,P.jsx)(`span`,{className:`nx-intro-spacer`}),(0,P.jsxs)(`button`,{type:`button`,className:`nx-intro-btn`,title:`查看${r}的全部文章(点标题在主内容区打开,可编辑)`,onClick:()=>c(!0),children:[`查看详情`,f>0?` ${f}`:``]})]}),s&&(0,P.jsx)(X,{kind:e,owner:t,model:n,onClose:()=>c(!1)})]})}export{B as i,X as n,ae as r,ce as t};
@@ -1,3 +0,0 @@
1
- import{c as e,f as t,g as n,h as r,l as i,m as a,o,p as s,y as c}from"./task-status-DSrx0i66.js";import{a as l,i as u,l as d,n as f,t as p}from"./upload-BcMhRsMn.js";import{S as m,x as h}from"./index-D8MvtVAm.js";import{t as g}from"./route-crumb-CWVu80du.js";var _=c(n(),1),v=r(),y=e=>`/api/file/content/${encodeURIComponent(e)}`;function b({text:e,compact:t=!1,className:n=``}){let r=d(e);return r.some(e=>e.type!==`text`)?(0,v.jsx)(`span`,{className:n?`mdtext ${n}`:`mdtext`,children:r.map((e,n)=>{if(e.type===`text`)return(0,v.jsx)(`span`,{className:`mdtext-plain`,children:e.value},n);let r=y(e.id);return e.type===`image`?(0,v.jsx)(`a`,{className:`embed-image`+(t?` compact`:``),href:r,target:`_blank`,rel:`noreferrer`,title:e.alt?`${e.alt}(点击看原图)`:e.id,children:(0,v.jsx)(`img`,{src:r,alt:e.alt||e.id,loading:`lazy`})},n):(0,v.jsx)(`a`,{className:`embed-file`,href:r,target:`_blank`,rel:`noreferrer`,title:e.id,children:e.alt||e.id},n)})}):(0,v.jsx)(`span`,{className:n,children:e})}function x({task:e,pick:t,group:n,onSaved:r,onCancel:i}){let o=s(),[c,d]=(0,_.useState)(e.text||``),[m,h]=(0,_.useState)(e.note||``),[g,y]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(!1),T=(0,_.useRef)(null),E=(0,_.useRef)(null),D=(0,_.useRef)(c),O=e=>{D.current=e,d(e)};(0,_.useEffect)(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[]);let k=e=>{if(!e)return;let t=T.current,n=D.current,r=t?t.selectionStart:n.length,i=t?t.selectionEnd:r,a=n.slice(0,r),o=n.slice(i),s=a&&!/\s$/.test(a)?` `:``,c=`${a}${s}${e}${o&&!/^\s/.test(o)?` `:``}${o}`;O(c);let l=a.length+s.length+e.length;requestAnimationFrame(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(l,l))})},A=async e=>{let t=Array.from(e||[]).filter(e=>e&&e.size>0);if(t.length&&!x){S({done:0,total:t.length});try{let e=await l(t,{group:n,onProgress:(e,t)=>S({done:e,total:t})});k(u(e));let r=e.filter(e=>e.isImage).length;o(e.length===1?`已插入 ${e[0].name}`:`已插入 ${e.length} 个附件${r?`(图片 ${r} 个)`:``}`)}catch(e){o(String(e.message||e))}finally{S(null)}}},j=e=>{let t=p(e);t.length&&(e.preventDefault(),A(t))},M=(0,_.useRef)(null);M.current=e=>A(f(e)),(0,_.useEffect)(()=>{let e=e=>Array.from(e.dataTransfer&&e.dataTransfer.types||[]).includes(`Files`),t=t=>{e(t)&&(t.preventDefault(),w(!0))},n=e=>{e.relatedTarget||w(!1)},r=t=>{e(t)&&(t.preventDefault(),w(!1),M.current&&M.current(t))};return window.addEventListener(`dragover`,t),window.addEventListener(`dragleave`,n),window.addEventListener(`drop`,r),()=>{window.removeEventListener(`dragover`,t),window.removeEventListener(`dragleave`,n),window.removeEventListener(`drop`,r)}},[]);let N=()=>{if(g)return;if(!String(D.current).trim()){o(`正文不能为空`);return}let i={group:n,ref:e.text,pick:t,matchTopic:e.topic,text:D.current};m!==(e.note||``)&&(i.note=m),y(!0),a(`/api/todo/item`,{method:`PATCH`,body:i}).then(()=>{o(`已保存`),r()}).catch(e=>o(String(e&&e.message||e))).finally(()=>y(!1))},P=e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),N())},F=x?`上传中 ${x.done}/${x.total}…`:`选择文件上传`,I=!String(c).trim();return(0,v.jsxs)(`div`,{className:`editor`+(C?` drag`:``),children:[(0,v.jsxs)(`div`,{className:`ed-tip`,children:[`粘贴(`,(0,v.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,v.jsx)(`kbd`,{children:`V`}),` 截图)、拖文件进来,或`,(0,v.jsx)(`button`,{type:`button`,className:`ed-link`,onClick:()=>E.current&&E.current.click(),disabled:!!x,children:`选择文件`}),`—— 会自动上传并插到光标处。`,(0,v.jsx)(`input`,{ref:E,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,A(t)}})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`正文`}),(0,v.jsx)(`textarea`,{ref:T,className:`ed-textarea`,rows:4,value:c,spellCheck:`false`,placeholder:`要做什么… 图片写 ![说明](fileId),其他文件写 [文件名](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:`![说明](id)`}),` 文件 `,(0,v.jsx)(`code`,{children:`[文件名](id)`})]})]}),(0,v.jsxs)(`span`,{className:`hint`,children:[c.length,` 字符`]})]})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`预览`}),(0,v.jsx)(`div`,{className:`preview`+(I?` empty`:``),children:I?(0,v.jsx)(`span`,{className:`muted`,children:`(暂无内容)`}):(0,v.jsx)(b,{text:c})})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`备注`}),(0,v.jsx)(`textarea`,{className:`ed-textarea`,rows:2,value:m,spellCheck:`false`,placeholder:`可选:完成结果、上下文补充`,onChange:e=>h(e.target.value)})]}),(0,v.jsxs)(`div`,{className:`ed-foot`,children:[(0,v.jsxs)(`span`,{className:`hint`,children:[(0,v.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,v.jsx)(`kbd`,{children:`Enter`}),` 保存`]}),(0,v.jsxs)(`span`,{className:`ed-acts`,children:[(0,v.jsx)(`button`,{className:`btn ghost`,onClick:i,disabled:g,children:`取消`}),(0,v.jsx)(`button`,{className:`btn`,onClick:N,disabled:g||!!x,children:g?`保存中…`:`保存`})]})]})]})}function S({onClose:e}){let{boot:n,refreshBoot:r}=m(),c=s(),l=t(),{dialog:u,node:d}=i(),[f,p]=(0,_.useState)([]),[g,y]=(0,_.useState)(``),[b,x]=(0,_.useState)({name:``,description:``}),[S,C]=(0,_.useState)(null),w=(0,_.useCallback)(async()=>{try{let e=await a(`/api/groups`);p(e.groups||[]),y(``)}catch(e){y(e.message||String(e))}},[]);(0,_.useEffect)(()=>{w()},[w]);let T=n?.groupId??0,E=e=>l(async()=>{let t=await a(`/api/group`,{method:`POST`,body:{locator:e}});c(t.id===0?`已切回默认组`:`已切换到 ${t.name}`),await r(),await w()}),D=()=>l(async()=>{let e=b.name.trim();if(!e){c(`请填名称`);return}let t=await a(`/api/groups`,{method:`POST`,body:{name:e,description:b.description.trim()}});x({name:``,description:``}),c(`已新建工作空间 ${t.name}(id=${t.id})`),await r(),await w()}),O=e=>l(async()=>{let t=await u({title:`重命名「${e.name}」`,input:!0,value:e.name});if(t==null)return;let n=String(t).trim();n&&(await a(`/api/groups/${e.id}`,{method:`PATCH`,body:{name:n}}),c(`已更新名称`),await r(),await w())}),k=e=>l(async()=>{await u({message:`解散工作空间「${e.name}」(id=${e.id})?\n\n后端要求组内已无 KV 数据,否则会拒绝。此操作不可撤销。`,danger:!0})&&(await a(`/api/groups/${e.id}`,{method:`DELETE`}),c(`已解散 ${e.name}`),await r(),await w())}),A=e=>l(async()=>{let t=await a(`/api/groups/${e.id}/members`);C({group:t.group,list:t.members||[]})});return n?.loggedIn?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(o,{title:`工作空间`,onClose:e,children:[(0,v.jsx)(`div`,{className:`muted`,style:{marginBottom:8},children:`清单按工作空间隔离读写。切换只改本机配置,不动服务端数据。`}),g?(0,v.jsx)(`div`,{className:`row muted`,children:g}):null,(0,v.jsxs)(`div`,{className:`list`,children:[(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(`span`,{className:`name`,children:`默认组`}),(0,v.jsx)(`span`,{className:`desc`,children:`不传 groupId,由后端回落`}),(0,v.jsx)(`span`,{className:`acts`,children:T===0?(0,v.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,v.jsx)(`button`,{className:`btn small`,onClick:()=>E(`default`),children:`切到这里`})})]}),f.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(h,{className:`name`,text:e.name,title:`点击复制名称`,children:e.name}),(0,v.jsx)(`span`,{className:`tag`,children:e.myRole||`member`}),e.description?(0,v.jsx)(`span`,{className:`desc`,children:e.description}):null,(0,v.jsxs)(`span`,{className:`muted mono`,children:[`id=`,e.id]}),(0,v.jsxs)(`span`,{className:`muted`,children:[e.memberCount,` 人`]}),(0,v.jsxs)(`span`,{className:`acts`,children:[e.id===T?(0,v.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,v.jsx)(`button`,{className:`btn small`,onClick:()=>E(String(e.id)),children:`切到这里`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>A(e),children:`成员`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>O(e),children:`改名`}),(0,v.jsx)(`button`,{className:`btn small ghost danger`,onClick:()=>k(e),children:`解散`})]})]},e.id)),!g&&!f.length?(0,v.jsx)(`div`,{className:`row muted`,children:`(没有其他工作空间)`}):null]}),(0,v.jsxs)(`div`,{className:`toolbar`,style:{marginTop:10},children:[(0,v.jsx)(`input`,{placeholder:`新工作空间名称`,size:16,value:b.name,onChange:e=>x({...b,name:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&D()}}),(0,v.jsx)(`input`,{placeholder:`描述(可选)`,size:20,value:b.description,onChange:e=>x({...b,description:e.target.value})}),(0,v.jsx)(`button`,{className:`btn`,onClick:D,children:`新建`}),(0,v.jsx)(`button`,{className:`btn ghost`,onClick:()=>l(w),children:`刷新`})]})]}),S?(0,v.jsx)(o,{title:`成员 · ${S.group.name}`,onClose:()=>C(null),children:(0,v.jsx)(`div`,{className:`list`,children:S.list.length?S.list.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(h,{className:`name`,text:e.email,title:`点击复制邮箱`,children:e.email}),(0,v.jsx)(`span`,{className:`tag`,children:e.role||`member`}),(0,v.jsx)(`span`,{className:`muted`,children:e.nickname})]},e.userId)):(0,v.jsx)(`div`,{className:`row muted`,children:`(没有成员)`})})}):null,d]}):(0,v.jsx)(o,{title:`工作空间`,onClose:e,children:(0,v.jsx)(`div`,{className:`muted`,children:`工作空间需要登录后才能列出。`})})}var C=[[`open`,`待办`],[`done`,`已完成`],[`freeze`,`冻结`]],w=e=>e?String(e).slice(0,16).replace(`T`,` `):``,T=15,E=(e,t)=>`${e}:${t.id}:${t.text}`;function D({bucket:t,task:n,dupCount:r,onAct:i}){let a=t===`done`,o=t===`freeze`,s=a?n.doneAt:o?n.frozenAt:n.createdAt;return(0,v.jsxs)(`div`,{className:`row cloud-row`,children:[(0,v.jsxs)(`div`,{className:`row-main`,children:[(0,v.jsxs)(`span`,{className:`tid`,children:[`#`,n.id]}),(0,v.jsx)(h,{className:`topic`,text:n.topic,title:`点击复制主题`,children:n.topic}),(0,v.jsx)(`span`,{className:`text`,title:n.text,children:(0,v.jsx)(b,{text:n.text,compact:!0})}),r>1?(0,v.jsxs)(`span`,{className:`tag`,title:`同内容有 ${r} 条,操作时需要消歧`,children:[`同内容×`,r]}):null,(0,v.jsx)(`span`,{className:`muted time`,children:w(s)}),(0,v.jsxs)(`span`,{className:`acts`,children:[t===`open`?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`done`,n),children:`完成`}):null,o?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`unfreeze`,n),children:`解冻`}):null,(0,v.jsx)(e,{items:[t===`open`&&{label:`冻结`,onPick:()=>i(`freeze`,n)},{label:`编辑`,onPick:()=>i(`edit`,n,t)},{label:`删除`,danger:!0,onPick:()=>i(`remove`,n,t)}]})]})]}),n.note?(0,v.jsx)(`div`,{className:`note`,children:n.note}):null]})}function O(){let{boot:e,ui:n,patchUi:r,refreshBoot:c}=m(),d=s(),f=t(),{dialog:y,node:b}=i(),[O,k]=(0,_.useState)(null),[A,j]=(0,_.useState)(``),[M,N]=(0,_.useState)(!1),[P,F]=(0,_.useState)({topic:``,text:``}),[I,L]=(0,_.useState)(null),[R,z]=(0,_.useState)(!1),[B,ee]=(0,_.useState)({}),[V,H]=(0,_.useState)(null),[U,W]=(0,_.useState)(null),G=e?.groupId??0,te=(e?.groups||[]).find(e=>e.id===G)?.name||(G?`#${G}`:`默认组`),[K,q]=(0,_.useState)({email:e?.email||``,password:``,busy:!1,open:!1}),J=()=>f(async()=>{if(!K.email.trim()){d(`请填邮箱`);return}if(!K.password){d(`请填密码`);return}q(e=>({...e,busy:!0}));try{let e=await a(`/api/auth/login`,{method:`POST`,body:{email:K.email.trim(),password:K.password}});q(e=>({...e,password:``})),d(`已登录: ${e.email}`),await c()}finally{q(e=>({...e,busy:!1}))}}),ne=()=>f(async()=>{await a(`/api/auth/logout`,{method:`POST`}),d(`已登出`),await c()}),Y=(0,_.useCallback)(async()=>{if(e?.loggedIn)try{k(await a(`/api/todo`)),j(``)}catch(e){j(String(e.message||e))}},[e?.loggedIn]);(0,_.useEffect)(()=>{Y()},[Y,G]),(0,_.useEffect)(()=>{a(`/api/setting`).then(W).catch(()=>{})},[]);let X=!!U?.autoSyncAttachments,re=()=>f(async()=>{let e=!X,t=await a(`/api/setting`,{method:`POST`,body:{autoSyncAttachments:e}});W(t),d(e?`已开启:读任务时自动下载附件到本地`:`已关闭自动下载附件`)}),Z=(0,_.useCallback)(async()=>{N(!0);try{await Y()}finally{N(!1)}},[Y]),ie=(0,_.useMemo)(()=>{let e=new Map;if(!O)return e;for(let[t]of C)for(let n of O[t]||[])e.set(n.text,(e.get(n.text)||0)+1);return e},[O]),Q=(0,_.useMemo)(()=>{if(!O)return null;let e=n.topic,t=t=>t?e?t.filter(t=>t.topic===e):t:null;return{open:t(O.open),done:t(O.done),freeze:t(O.freeze)}},[O,n.topic]);if(!e?.loggedIn)return(0,v.jsxs)(`div`,{className:`cloud-page`,children:[(0,v.jsx)(g,{}),(0,v.jsxs)(`div`,{className:`card`,style:{padding:16,maxWidth:640},children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:`登录云端`}),(0,v.jsx)(`span`,{className:`tag bad`,children:`未登录`})]}),(0,v.jsxs)(`div`,{className:`row-inline`,style:{padding:12},children:[(0,v.jsx)(`input`,{placeholder:`邮箱`,size:24,spellCheck:`false`,value:K.email,onChange:e=>q(t=>({...t,email:e.target.value}))}),(0,v.jsx)(`input`,{placeholder:`密码`,type:`password`,size:18,value:K.password,onChange:e=>q(t=>({...t,password:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&J()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:J,disabled:K.busy,children:K.busy?`登录中…`:`登录`})]}),(0,v.jsxs)(`div`,{className:`muted`,style:{padding:`0 12px 12px`,fontSize:12},children:[`密码只用于本次请求,不写入本机配置;配置里只保存 token。 也可以用 CLI:`,(0,v.jsx)(`code`,{children:`nx-kv auth login <email>`}),`。`]})]})]});let ae=async(e,t)=>{if(!O)return null;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
- `),input:!0,placeholder:`输入 0..${n.length-1}`,value:String(r>=0?r:0)});if(i===null)return null;let a=Number(i),o=n[a];return!Number.isInteger(a)||!o?(d(`请输入 0..${n.length-1}`),null):{...o,pick:a}},oe=(e,t,n)=>f(async()=>{let r=e===`remove`||e===`edit`?await ae(t,n):{bucket:n,task:t,pick:void 0};if(!r)return;let i={group:G,ref:r.task.text,pick:r.pick};if(e===`done`){let e=await y({title:`完成结果`,message:`完成「${t.text.slice(0,40)}」`,input:!0,placeholder:`可选:写一句完成结果`});if(e===null)return;await a(`/api/todo/done`,{method:`POST`,body:{...i,result:e||void 0}}),d(`已完成`)}else if(e===`freeze`)await a(`/api/todo/freeze`,{method:`POST`,body:i}),d(`已冻结`);else if(e===`unfreeze`)await a(`/api/todo/unfreeze`,{method:`POST`,body:i}),d(`已解冻`);else if(e===`remove`){if(!await y({message:`删除「${t.text.slice(0,40)}」?`,danger:!0}))return;await a(`/api/todo/item`,{method:`DELETE`,body:i}),d(`已删除`)}else if(e===`edit`){H({task:r.task,pick:r.pick});return}await Z(),await c()}),se=()=>f(async()=>{let e=await y({title:`归档已完成的旧记录`,message:`把「完成时间早于该日期」的记录移到冷 key(默认 30 天前)。留空用默认值。`,input:!0,placeholder:`YYYY-MM-DD,留空 = 30 天前`});if(e===null)return;let t=await a(`/api/todo/archive`,{method:`POST`,body:{before:String(e).trim()||void 0,group:G}});d(t.moved?`已归档 ${t.moved} 条 → ${t.coldKey}`:`没有需要归档的记录`),await Z()}),ce=async e=>{let t=p(e);if(t.length){e.preventDefault();try{let e=await l(t,{group:G}),n=u(e);F(e=>({...e,text:[e.text,n].filter(Boolean).join(` `)})),d(e.length===1?`已上传 ${e[0].name} 并附到内容里`:`已上传 ${e.length} 个附件并附到内容里`)}catch(e){d(String(e.message||e))}}},$=()=>f(async()=>{let e=P.topic.trim(),t=P.text.trim();if(!e){d(`请填主题`);return}if(!t){d(`请填内容`);return}let n=await a(`/api/todo`,{method:`POST`,body:{topic:e,text:t,group:G}});F({topic:e,text:``}),d(`已加入待办${n.topicAdded?`(新主题 ${e})`:``}`),await Z()}),le=(e,t)=>B[e]?t:t.slice(0,T),ue=O?.topics||[];return(0,v.jsxs)(`div`,{className:`cloud-page`,children:[(0,v.jsxs)(`div`,{className:`cloud-toolbar`,children:[(0,v.jsxs)(`button`,{className:`pill on rp-ws-trigger`,title:`切换工作空间 / 管理(清单按工作空间隔离)`,onClick:()=>z(!0),children:[te,` `,(0,v.jsx)(`span`,{className:`rp-caret`,children:`▾`})]}),(0,v.jsx)(`span`,{className:`sep`}),(0,v.jsx)(`label`,{children:`主题`}),(0,v.jsxs)(`select`,{value:n.topic,onChange:e=>r({topic:e.target.value}),children:[(0,v.jsx)(`option`,{value:``,children:`全部`}),ue.map(e=>(0,v.jsx)(`option`,{value:e,children:e},e))]}),(0,v.jsx)(`span`,{className:`grow`}),(0,v.jsxs)(`label`,{className:`toggle`+(X?` on`:``),title:`开启后,读取任务时会把正文引用的附件下载到本地,并把本地绝对路径一并返回给 agent。
3
- 当前目录:${U?U.resolvedDir:`(读取中…)`}`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:X,onChange:re}),(0,v.jsx)(`span`,{className:`dot`}),`附件自动下载`]}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:Z,disabled:M,children:M?`刷新中…`:`刷新`}),(0,v.jsx)(`button`,{className:`pill`+(K.open?` on`:``),title:`账号 ${e.email||``}(点击展开登录态 / 登出)`,onClick:()=>q(e=>({...e,open:!e.open})),children:e.email||`已登录`})]}),K.open?(0,v.jsxs)(`div`,{className:`card`,style:{padding:16,marginBottom:12},children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:`登录态`}),(0,v.jsx)(`button`,{className:`btn small ghost danger`,onClick:ne,children:`登出`})]}),(0,v.jsxs)(`div`,{className:`settings`,children:[(0,v.jsx)(`dt`,{children:`账号`}),(0,v.jsx)(`dd`,{children:e?.email}),(0,v.jsx)(`dt`,{children:`userId`}),(0,v.jsx)(`dd`,{children:e?.userId||`-`}),(0,v.jsx)(`dt`,{children:`后端`}),(0,v.jsx)(`dd`,{className:`mono`,children:(0,v.jsx)(h,{text:e?.baseUrl,title:void 0,children:e?.baseUrl})}),(0,v.jsx)(`dt`,{children:`本机配置`}),(0,v.jsx)(`dd`,{className:`mono`,children:(0,v.jsx)(h,{text:e?.configPath,title:void 0,children:e?.configPath})})]}),(0,v.jsxs)(`div`,{className:`row-inline`,style:{padding:`10px 0 0`},children:[(0,v.jsx)(`input`,{placeholder:`切换账号:邮箱`,size:24,spellCheck:`false`,value:K.email,onChange:e=>q(t=>({...t,email:e.target.value}))}),(0,v.jsx)(`input`,{placeholder:`密码`,type:`password`,size:18,value:K.password,onChange:e=>q(t=>({...t,password:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&J()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:J,disabled:K.busy,children:K.busy?`登录中…`:`登录`})]})]}):null,(0,v.jsxs)(`div`,{className:`cloud-compose`,children:[(0,v.jsx)(`input`,{className:`cloud-compose-topic`,placeholder:`主题`,"aria-label":`新任务主题`,value:P.topic,onChange:e=>F({...P,topic:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&$()}}),(0,v.jsx)(`input`,{className:`cloud-compose-text`,placeholder:`要做什么…(可 Ctrl+V 粘贴图片)`,"aria-label":`新任务内容`,value:P.text,title:`可以直接 Ctrl+V 粘贴截图:会自动上传为附件并附在内容里`,onChange:e=>F({...P,text:e.target.value}),onPaste:ce,onKeyDown:e=>{e.key===`Enter`&&$()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:$,children:`加入待办`})]}),A?(0,v.jsxs)(`div`,{className:`cloud-error`,children:[(0,v.jsxs)(`span`,{children:[`清单读取失败:`,A]}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:Z,children:`重试`})]}):null,!O&&!A?(0,v.jsx)(`div`,{className:`cloud-loading muted`,children:`读取中…`}):null,O?(0,v.jsx)(`div`,{className:`cols`,children:C.map(([e,t])=>(0,v.jsxs)(`div`,{className:`col col-`+e,children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:t}),(0,v.jsx)(`span`,{className:`cnt`,children:(Q?.[e]||[]).length}),e===`done`&&(Q?.done||[]).length?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`span`,{className:`grow`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:se,title:`把较旧的完成记录移到冷 key`,children:`归档旧记录`})]}):null]}),(0,v.jsxs)(`div`,{className:`card list`,children:[(Q?.[e]||[]).length?le(e,Q?.[e]||[]).map(t=>(0,v.jsx)(D,{bucket:e,task:t,dupCount:ie.get(t.text)||1,onAct:oe},E(e,t))):(0,v.jsx)(`div`,{className:`cloud-empty`,children:e===`open`?(0,v.jsxs)(v.Fragment,{children:[`还没有待办`,(0,v.jsx)(`br`,{}),`在上方投递条输入,`,(0,v.jsx)(`kbd`,{children:`Enter`}),` 直达`]}):e===`done`?`还没有完成记录`:`没有冻结的任务`}),(Q?.[e]||[]).length>T?(0,v.jsx)(`div`,{className:`row muted`,style:{cursor:`pointer`,justifyContent:`center`},onClick:()=>ee(t=>({...t,[e]:!t[e]})),children:B[e]?`收起`:`还有 ${(Q?.[e]||[]).length-T} 条,点击展开`}):null]})]},e))}):null,R?(0,v.jsx)(S,{onClose:()=>z(!1)}):null,V?(0,v.jsx)(o,{title:`编辑任务`,onClose:()=>H(null),children:(0,v.jsx)(x,{task:V.task,pick:V.pick,group:G,onCancel:()=>H(null),onSaved:async()=>{H(null),await Z(),await c()}})}):null,I?(0,v.jsx)(o,{title:I.title,size:`lg`,onClose:()=>L(null),children:I.node}):null,b]})}export{O as default};
@@ -1 +0,0 @@
1
- import{g as e,h as t,l as n,m as r,p as i,s as a,u as o,y as s}from"./task-status-DSrx0i66.js";import{n as c}from"./app-context-BASCGAA-.js";import{t as l}from"./frontmatter-CLLxCmTv.js";import{a as u}from"./md-parse-b6GY5eBl.js";import{r as d}from"./board-view-DABoVkaA.js";import{n as f}from"./model-Bn2fG6CC.js";import{t as p}from"./graph-BTEfvFz6.js";var m=s(e(),1);function h(e){return!(!e||e.deletedAt||e.migratedTo)}function g(e){return h(e)&&e?.status===`pending`}function _(e){return u(e.text)||f(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),r=n?.[1],i=n?.[2];if(r&&i)return{kind:`foreign`,key:r,id:Number(i)};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 ee(e,t){return e.topicKey===t?Number(e.id):v(e.topicKey,e.id)}function te(e,t={}){let n=Math.max(3,Number(t.perCol)||8),r=new Map;for(let t of e){let e=r.get(t.topicKey);e?e.push(t):r.set(t.topicKey,[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:56+r*320,y:28+o*94})}),a+=Math.ceil(e.length/n);return i}var x=e=>`nx-kv-dag-pos:${e}`;function ne(e){try{let t=JSON.parse(localStorage.getItem(x(e))||`{}`),n=new Map;for(let[e,r]of Object.entries(t||{}))if(Array.isArray(r)&&Number.isFinite(r[0])&&Number.isFinite(r[1])){let t=Number(r[0]),i=Number(r[1]);n.set(e,{x:t,y:i})}return n}catch{return new Map}}function re(e){try{localStorage.removeItem(x(e))}catch{}}function S(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 C(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 w(e,t,n){let r=e.getBoundingClientRect();return{x:t-r.left+e.scrollLeft,y:n-r.top+e.scrollTop}}function ie(e,t,n,r){let i=t.get(n)||{x:0,y:0};return{x:i.x+280,y:i.y+r(n)/2}}function ae(e,t,n,r){let i=[];for(let a of e){let e=t.get(a.nodeKey);if(!e)continue;let o=r(a.nodeKey);for(let s of a.blockBy||[]){let c=b(s,a.topicKey);if(!c||!n.has(c))continue;let l=t.get(c);if(!l)continue;let u=r(c),d=e.x>l.x+280-8;i.push({from:c,to:a.nodeKey,x1:d?l.x+280:l.x,y1:l.y+u/2,x2:d?e.x:e.x+280,y2:e.y+o/2})}}return i}function oe({canvasRef:e,modeRef:t,posRef:n,nodesRef:r,byNodeKeyRef:i,scopeKeyRef:a,userMovedRef:o,commitRef:s,toastRef:c,setPos:l,setDragId:u,setLinking:d}){let f=(t,i)=>{let a=e.current;if(!a)return null;let{x:o,y:s}=w(a,t,i),c=r.current;for(let e=c.length-1;e>=0;e--){let t=c[e];if(!t)continue;let r=t.nodeKey,i=n.current.get(r);if(!i)continue;let l=a.querySelector(`[data-node-id="${CSS.escape(r)}"]`),u=l instanceof HTMLElement?l.offsetHeight:64;if(o>=i.x-10&&o<=i.x+280+28&&s>=i.y-6&&s<=i.y+u+6)return r}return null},p=e=>{if(!e||e.kind!==`link`){d(null);return}d({sourceId:e.sourceId,x:e.x1,y:e.y1,cx:e.cx,cy:e.cy,overId:e.overId,dragged:!!e.dragged})},h=()=>{t.current=null,u(null),d(null)};return(0,m.useEffect)(()=>{let r=n=>{let r=t.current;if(!r)return;let i=e.current;if(!i)return;let a=w(i,n.clientX,n.clientY);if(r.kind===`drag`){let e=Math.max(8,a.x-r.ox),t=Math.max(8,a.y-r.oy);l(n=>{let i=new Map(n);return i.set(r.id,{x:e,y:t}),i});return}if(r.kind===`link`){let e=f(n.clientX,n.clientY),i=e&&e!==r.sourceId?e:null,o=Math.hypot(a.x-r.sx,a.y-r.sy),s=r.dragged||o>=6,c={...r,cx:a.x,cy:a.y,overId:i,dragged:s};t.current=c,p(c)}},u=async e=>{let r=t.current;if(r){if(r.kind===`drag`){o.current.add(r.id),S(a.current,n.current),h();return}if(r.kind===`link`){let t=r.overId||f(e.clientX,e.clientY),n=r.sourceId;if(t&&t!==n){h(),await s.current(n,t);return}if(r.dragged){h();return}let a=i.current.get(n);c.current(`已选 #${a?.id??n},再点目标画出有向边`)}}},d=e=>{e.key===`Escape`&&h()};return window.addEventListener(`pointermove`,r),window.addEventListener(`mousemove`,r),window.addEventListener(`pointerup`,u),window.addEventListener(`mouseup`,u),window.addEventListener(`pointercancel`,h),window.addEventListener(`keydown`,d),()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`mousemove`,r),window.removeEventListener(`pointerup`,u),window.removeEventListener(`mouseup`,u),window.removeEventListener(`pointercancel`,h),window.removeEventListener(`keydown`,d)}},[]),{publishLink:p,clearMode:h}}var T=t();function se({title:e,count:t,linkArmed:n,srcLabel:r,groupMode:i,queues:a,filterKey:o,onFilter:s,onReset:c}){return(0,T.jsxs)(`div`,{className:`dagp-head`,children:[(0,T.jsx)(`span`,{className:`dagp-title`,children:e}),(0,T.jsxs)(`span`,{className:`dagp-count`,children:[t,` 个待领取节点`]}),(0,T.jsx)(`span`,{className:`dagp-hint`,children:n?`连线中:再点目标完成 #${r} → 目标(Esc 取消)`:i?`组内全量任务;跨项目连线对 get 生效;未连线走各队列默认序`:`点右侧 ● 再点目标 = 有向顺序;未连线 = 无先后、走默认序`}),i&&a.length>0&&(0,T.jsxs)(`span`,{className:`dagp-queues`,children:[(0,T.jsxs)(`button`,{type:`button`,className:`dagp-queue`+(o===``?` on`:``),onClick:()=>s(``),children:[`全部`,(0,T.jsx)(`i`,{children:a.reduce((e,t)=>e+t.total,0)})]}),a.map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`dagp-queue`+(e.key===o?` on`:``),title:`${e.name} · ${e.count}/${e.total}`,onClick:()=>s(e.key),children:[e.name,(0,T.jsx)(`i`,{children:e.count})]},e.key))]}),(0,T.jsx)(`button`,{type:`button`,className:`dagp-reset`,onClick:c,title:`清掉记住的摆位,按默认分栏重排`,children:`恢复默认布局`})]})}function ce({n:e,p:t,byNodeKey:n,groupMode:r,dragId:i,linking:a,linkArmed:s,onStartDrag:c,onStartLink:l,onOpenTask:u,onToggleGate:d,onAddTimegoal:f,onRemoveDep:p,onOpsMenu:m}){let h=(e.blockBy||[]).map(t=>({token:t,key:b(t,e.topicKey)})).filter(e=>e.key&&n.has(e.key)),g=a&&a.overId===e.nodeKey,v=a&&a.sourceId===e.nodeKey;return(0,T.jsxs)(`div`,{"data-node-id":e.nodeKey,className:`dagp-node`+(i===e.nodeKey?` dragging`:``)+(g?` over`:``)+(v?` linking-src`:``)+(e.blocksFollowing?` gate`:``)+(s&&!v?` link-target`:``),style:{transform:`translate(${t.x}px, ${t.y}px)`,width:280},onPointerDown:t=>c(t,e),children:[(0,T.jsx)(`span`,{className:`dagp-port in`,title:`入:箭头指向我 = 我等对方`,"aria-hidden":`true`}),(0,T.jsxs)(`div`,{className:`dagp-body`,children:[(0,T.jsxs)(`div`,{className:`dagp-top`,children:[(0,T.jsxs)(`span`,{className:`dagp-no mono`,children:[`#`,e.id]}),r&&(0,T.jsx)(`span`,{className:`dagp-chip proj`,children:e.projectName}),e.blocksFollowing&&(0,T.jsx)(`span`,{className:`dagp-chip gate`,children:`闸门`}),e.ready===!1&&(0,T.jsx)(`span`,{className:`dagp-chip lock`,children:`锁定`}),e.timegoal?.duration&&(0,T.jsxs)(`span`,{className:`dagp-chip goal`,children:[`⏱ `,e.timegoal.duration]}),(0,T.jsx)(`button`,{type:`button`,className:`dagp-ops`,title:`节点操作`,"aria-label":`节点操作`,onClick:t=>{t.stopPropagation();let n=[{label:`打开任务`,onClick:()=>u(e)},{label:e.blocksFollowing?`取消闸门`:`设为闸门(挡住后续)`,onClick:()=>d(e)},{label:e.timegoal?.duration?`改时间目标`:`加时间目标(timegoal)`,onClick:()=>f(e)}],r=t.currentTarget.getBoundingClientRect();m({x:r.left,y:r.bottom,items:n})},children:(0,T.jsx)(o,{name:`dots`,size:13,title:void 0})})]}),(0,T.jsx)(`div`,{className:`dagp-name`,title:e.text,onDoubleClick:t=>{t.stopPropagation(),u(e)},children:_(e)}),h.length>0&&(0,T.jsx)(`div`,{className:`dagp-deps`,children:h.map(({token:t,key:r})=>{let i=r?n.get(r):void 0,a=!!i&&i.topicKey!==e.topicKey;return(0,T.jsxs)(`span`,{className:`dagp-chip dep`,title:a&&i?`跨项目 #${i.id}@${i.projectName} → #${e.id}`:`#${i?.id} → #${e.id}`,children:[`← #`,i?.id,a?`@${i.projectName}`:``,(0,T.jsx)(`i`,{role:`button`,"aria-label":`解除依赖`,onClick:n=>{n.stopPropagation(),p(e,t)},children:`×`})]},String(t))})})]}),(0,T.jsx)(`button`,{type:`button`,className:`dagp-port out`,title:`点一下再点目标,或按住拖到目标 = 有向顺序(可跨项目)`,"aria-label":`从 #${e.id} 开始连线`,onPointerDown:t=>l(t,e)})]})}function E({dirKey:e,groupId:t}){let o=c(),s=i(),{dialog:u,node:f}=n(),h=o.rows||[],_=o.refreshLocal,x=(0,m.useId)().replace(/:/g,``),S=o.repoData&&o.repoData.boards||[],E=(0,m.useMemo)(()=>S.find(e=>e.id===t||e.key===t)||null,[S,t]),D=!!E,le=(0,m.useMemo)(()=>{if(!E)return[];let e=[];for(let t of E.repos||[]){let n=h.find(e=>e.repo&&e.repo.key===t.key);if(!n)continue;let r=[E.id,E.key,E.name].filter(Boolean),i=(n.tasks||[]).filter(e=>{if(!g(e))return!1;let t=l(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},[E,h]),[O,ue]=(0,m.useState)(``);(0,m.useEffect)(()=>{D||ue(``)},[D,t]);let k=(0,m.useMemo)(()=>D?null:h.find(t=>t.key===e)||null,[D,h,e]),A=(0,m.useMemo)(()=>{if(D&&E){let e=[E.id,E.key,E.name].filter(Boolean),t=[];for(let n of E.repos||[]){let r=h.find(e=>e.repo&&e.repo.key===n.key);if(r&&!(O&&r.key!==O))for(let i of r.tasks||[]){if(!g(i))continue;let a=l(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 k?(k.tasks||[]).filter(e=>g(e)&&!d(e)).map(e=>({...e,topicKey:k.key,topicCwd:k.cwd,topicIsGlobal:!!k.isGlobal,projectName:k.name||k.key,nodeKey:v(k.key,e.id)})):[]},[D,E,h,O,k]),j=(0,m.useMemo)(()=>new Map(A.map(e=>[e.nodeKey,e])),[A]),M=(0,m.useRef)(j);M.current=j;let N=(0,m.useRef)(A);N.current=A;let P=(0,m.useRef)(null),[F,I]=(0,m.useState)(()=>new Map),L=(0,m.useRef)(F);L.current=F;let[de,fe]=(0,m.useState)(0);(0,m.useEffect)(()=>{let e=P.current;if(!e)return;let t=()=>fe(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(((de||720)-56)/94)||8),z=D?`g:${E?.id||t||``}`:`d:${e||``}`,B=(0,m.useRef)(z);B.current=z;let V=(0,m.useMemo)(()=>ne(z),[z]),pe=(0,m.useRef)(z),H=(0,m.useRef)(new Set);(0,m.useEffect)(()=>{let e=pe.current!==z;pe.current=z,I(t=>{let n=new Map,r=te(A,{perCol:R});for(let i of A){let a=V.get(i.nodeKey)||(!e&&H.current.has(i.nodeKey)?t.get(i.nodeKey):null)||r.get(i.nodeKey)||{x:56,y:28};n.set(i.nodeKey,a)}return n})},[A,R,V,z]);let U=(0,m.useRef)(null),[W,me]=(0,m.useState)(null),[G,he]=(0,m.useState)(null),[K,ge]=(0,m.useState)(null),[_e,ve]=(0,m.useState)(!1),q=(0,m.useRef)(!1);q.current=_e;let J=(0,m.useRef)(async()=>!1),Y=(0,m.useRef)(s);Y.current=s;let X=async(e,t,n)=>{ve(!0);try{let i={...t};Array.isArray(i.blockBy)&&(i.blockBy=i.blockBy.join(`,`));let a=e.topicIsGlobal?{key:e.topicKey}:{cwd:e.topicCwd};await r(`/api/localtasks/item`,{method:`PATCH`,body:{...a,id:Number(e.id),...i}}),n&&s(n),_&&await _()}catch(e){s(String(e.message||e))}finally{ve(!1)}},{publishLink:ye,clearMode:Z}=oe({canvasRef:P,modeRef:U,posRef:L,nodesRef:N,byNodeKeyRef:M,scopeKeyRef:B,userMovedRef:H,commitRef:J,toastRef:Y,setPos:I,setDragId:me,setLinking:he});J.current=async(e,t)=>{if(!t||t===e)return!1;let n=M.current.get(e),r=M.current.get(t);if(!n||!r||!g(r))return Y.current(`只能连到待领取任务`),!1;if(r.blocksFollowing)return Y.current(`#${r.id} 是闸门,不能声明上游`),!1;let i=ee(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`&&n.kind===`local`||t.kind===`foreign`&&n.kind===`foreign`&&t.key===n.key)&&t.id===n.id}))return Y.current(`已有该有向边`),!1;if(p(e=>{let t=M.current.get(String(e));if(!t)return[];let n=[];for(let e of t.blockBy||[]){let r=b(e,t.topicKey);r&&M.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};let be=(e,t)=>{if(q.current||e.button!==0||e.target instanceof Element&&e.target.closest(`.dagp-port, .dagp-ops, .dagp-chip, button, a`))return;let n=U.current;if(n&&n.kind===`link`){if(e.preventDefault(),e.stopPropagation(),t.nodeKey===n.sourceId){Z();return}if(!g(t)){Y.current(`只能连到待领取任务`);return}let r=n.sourceId;Z(),J.current(r,t.nodeKey);return}if(U.current||!g(t))return;e.preventDefault();let r=P.current;if(!r)return;let i=L.current.get(t.nodeKey)||{x:0,y:0},a=w(r,e.clientX,e.clientY);U.current={kind:`drag`,id:t.nodeKey,ox:a.x-i.x,oy:a.y-i.y},me(t.nodeKey)},xe=(e,t)=>{if(q.current||!g(t)||e.button!==0)return;if(e.preventDefault(),e.stopPropagation(),U.current?.kind===`link`&&U.current.sourceId===t.nodeKey){Z();return}let n=ie(P.current,L.current,t.nodeKey,De),r=P.current,i=r?w(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};U.current=a,ye(a)},Se=e=>{U.current&&U.current.kind===`link`&&(e.target instanceof Element&&e.target.closest(`.dagp-node`)||Z())},Ce=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`&&r.kind===`local`?n.id!==r.id:n.kind===`foreign`&&r.kind===`foreign`?n.key!==r.key||n.id!==r.id:!0:!0});await X(e,{blockBy:n},`已解除依赖 → #${e.id}`)},we=e=>X(e,{gate:!e.blocksFollowing},e.blocksFollowing?`#${e.id} 取消闸门`:`#${e.id} 设为闸门`),Te=async e=>{let t=await u({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}`)},Ee=e=>{o.openPage&&(t?o.openPage({groupId:t,task:String(e.id),name:`#${e.id}`}):o.openPage({dirKey:e.topicKey,task:String(e.id),name:`#${e.id}`}))},De=e=>{let t=P.current?.querySelector(`[data-node-id="${CSS.escape(e)}"]`);return t instanceof HTMLElement?t.offsetHeight:64},Oe=(0,m.useMemo)(()=>ae(A,F,j,De),[A,F,j,W,G]),Q=(0,m.useMemo)(()=>{let e=480,t=240;for(let n of A){let r=F.get(n.nodeKey);r&&(e=Math.max(e,r.x+280+100),t=Math.max(t,r.y+140))}return G&&(e=Math.max(e,G.cx+40),t=Math.max(t,G.cy+40)),{w:e,h:t}},[A,F,G]),ke=D?E?.name||`组编排`:k?.name||e||`编排`,Ae=()=>{re(B.current),H.current.clear(),I(te(A,{perCol:R})),s(`已恢复默认布局`)},$=!!G,je=G?j.get(G.sourceId)?.id??G.sourceId:``;return(0,T.jsxs)(`div`,{className:`dagp`+($?` is-linking`:``)+(W==null?``:` is-dragging`),children:[(0,T.jsx)(se,{title:ke,count:A.length,linkArmed:$,srcLabel:je,groupMode:D,queues:le,filterKey:O,onFilter:ue,onReset:Ae}),(0,T.jsxs)(`div`,{className:`dagp-canvas`,ref:P,onPointerDown:Se,children:[(0,T.jsxs)(`svg`,{className:`dagp-edges`,width:Q.w,height:Q.h,style:{width:Q.w,height:Q.h},"aria-hidden":`true`,children:[(0,T.jsx)(`defs`,{children:(0,T.jsx)(`marker`,{id:`dagp-arrow-${x}`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,T.jsx)(`path`,{d:`M0 0 L10 5 L0 10 z`,fill:`var(--mdw-accent, #2F6F5E)`})})}),Oe.map(e=>(0,T.jsx)(`path`,{className:`dagp-edge`,d:C(e.x1,e.y1,e.x2,e.y2),markerEnd:`url(#dagp-arrow-${x})`},`${e.from}->${e.to}`)),G&&(0,T.jsx)(`path`,{className:`dagp-edge preview`,d:C(G.x,G.y,G.cx,G.cy),markerEnd:`url(#dagp-arrow-${x})`})]}),(0,T.jsx)(`div`,{className:`dagp-nodes`,style:{width:Q.w,height:Q.h},children:A.map(e=>(0,T.jsx)(ce,{n:e,p:F.get(e.nodeKey)||{x:56,y:28},byNodeKey:j,groupMode:D,dragId:W,linking:G,linkArmed:$,onStartDrag:be,onStartLink:xe,onOpenTask:Ee,onToggleGate:we,onAddTimegoal:Te,onRemoveDep:Ce,onOpsMenu:ge},e.nodeKey))}),!A.length&&(0,T.jsx)(`div`,{className:`dagp-empty`,children:D?`本组还没有带 board 归属的任务。连线可跨项目,对 get 生效。`:`这个队列没有任务。连线是编排里唯一的顺序关系;不连就保持默认序。`})]}),K&&(0,T.jsx)(a,{x:K.x,y:K.y,items:K.items,onClose:()=>ge(null)}),f]})}export{E as default};
@@ -1,5 +0,0 @@
1
- import{c as e,g as t,h as n,l as r,m as i,o as a,p as o,s,u as c,y as l}from"./task-status-DSrx0i66.js";import{r as u,u as d}from"./workspace-4tw7trV7.js";import{n as f}from"./app-context-BASCGAA-.js";import{a as p,n as m}from"./md-parse-b6GY5eBl.js";import{r as h,t as g}from"./board-view-DABoVkaA.js";import{n as _}from"./model-Bn2fG6CC.js";import{_ as v,a as y,g as b,i as x,m as S,o as ee,p as C,r as w,s as T,u as E}from"./index-D8MvtVAm.js";import{t as D}from"./graph-BTEfvFz6.js";import{a as te,i as ne,o as O,s as re}from"./task-utils-By8gLpHY.js";import{t as k}from"./Introduction-aQCeCLrV.js";import{t as A}from"./bar-B9WWmCpt.js";import{i as j,n as M,r as N,t as P}from"./deleted-panel-BcbtctNF.js";var F=l(t(),1),I=n(),L=N,R=j,z=M;function B({isGlobal:t,topic:n,repo:r=null,model:i=null,tasks:a=[],taskCount:o=0,pendingCount:s=0,page:l=0,pageCount:u=1,onPage:d,onNew:f,onOpenTask:p,onDeleteTask:m,onDeleteTasks:h,onCancelTasks:g,onCompleteTasks:v,onReopenTask:y,onTplMenu:x,onImport:S,onProg:ee,onMoveTask:C,onOpenDag:w,onOpenFlow:T,onToggleGate:E,downstreamOf:D,onDeleted:te,onRefs:ne,deletedCount:O=0}){let re=t?`全局池`:n?.name||`目录`,j=(0,F.useRef)(null),[M,N]=(0,F.useState)(null),[P,B]=(0,F.useState)(null),[V,H]=(0,F.useState)(()=>new Set);(0,F.useEffect)(()=>{H(new Set)},[l]);let U=a.map(e=>Number(e.id)),W=U.length>0&&U.every(e=>V.has(e)),G=a.filter(e=>V.has(Number(e.id))),K=G.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),ie=e=>{let t=Number(e);H(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},q=()=>{H(e=>{let t=new Set(e);return W?U.forEach(e=>t.delete(e)):U.forEach(e=>t.add(e)),t})},J=async e=>{let t=[...V],n=e===`cancel`?g:e===`complete`?v:h;t.length&&n&&await n(t)&&H(new Set)},Y=e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt,X=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},ae=(e,t)=>{j.current={id:Number(t.id)},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.id),N(Number(t.id))},oe=(e,t)=>{j.current&&Y(t)&&Number(t.id)!==j.current.id&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,B({id:Number(t.id),zone:X(e,e.currentTarget)}))},se=e=>{e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget)||B(null)},Z=(e,t)=>{e.preventDefault();let n=X(e,e.currentTarget),r=j.current;j.current=null,N(null),B(null),r&&Y(t)&&Number(t.id)!==r.id&&C&&C({id:r.id},t.id,n)},Q=()=>{j.current=null,N(null),B(null)},ce=G.length>0?(0,I.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,I.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,G.length,` 条`]}),v&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!K.length,title:K.length?`把选中的待领取任务标为已完成(补一条完成记录,原文留档)`:`只有待领取任务可以直接标为完成`,onClick:()=>J(`complete`),children:[`标为完成选中`,K.length?` (${K.length})`:``]}),g&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!K.length,title:K.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消`,onClick:()=>J(`cancel`),children:[`取消选中`,K.length?` (${K.length})`:``]}),h&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>J(`delete`),children:[`删除选中 (`,G.length,`)`]}),(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>H(new Set),children:`清空`})]}):null,le=(0,I.jsx)(R,{title:t?`全局池任务`:`任务`,pendingCount:s,headerExtra:a.length?(0,I.jsxs)(`label`,{className:`rp-proj-pickall`,title:`全选/取消全选当前页`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:W,onChange:q,"aria-label":`全选当前页任务`}),`全选本页`]}):null,emptyText:`还没有页面:点「+ 新建页」写第一篇,或让 agent 往${t?`全局池`:`这个目录`}投递任务。`,children:a.map(t=>{let n=Y(t),r=D&&D[t.id]||[];return(0,I.jsx)(z,{t,selectable:!0,picked:V.has(Number(t.id)),onTogglePick:ie,draggable:n,dragHandlers:n?{onDragStart:e=>ae(e,t),onDragOver:e=>oe(e,t),onDragLeave:se,onDrop:e=>Z(e,t),onDragEnd:Q}:null,dragVisual:{dragging:M===Number(t.id),drop:P&&P.id===Number(t.id)?P.zone:null},showTimes:!0,downs:r,onOpen:e=>p(e.id),ops:(0,I.jsxs)(I.Fragment,{children:[n&&(w||E)&&(0,I.jsx)(e,{items:[{label:`编排依赖…`,onPick:()=>w&&w(t)},{label:t.blocksFollowing?`取消闸门(不再挡后续)`:`设为闸门(挡住后续)`,onPick:()=>E&&E(t)}]}),y&&t.status!==`cancelled`&&!t.childCount&&(t.status===`claimed`||t.status===`done`||t.completedAt)&&(0,I.jsx)(`span`,{className:`op`,role:`button`,tabIndex:-1,title:t.completedAt?`反馈:新开一条任务(原任务不动)`:`反馈修改:回写本任务并记入任务链`,"aria-label":`反馈 ${_(t)}`,onClick:()=>y(t),children:(0,I.jsx)(c,{name:`refresh`,size:12,title:void 0})}),m&&(0,I.jsx)(`span`,{className:`op danger`,role:`button`,tabIndex:-1,title:`删除此任务(软删除,CLI 可恢复)`,"aria-label":`删除 ${_(t)}`,onClick:()=>m(t),children:(0,I.jsx)(c,{name:`x`,size:12,title:void 0})})]})},t.id)})}),$=o>0?(0,I.jsx)(`div`,{className:`mdw-land-pager`,children:(0,I.jsx)(b,{page:l,pageCount:u,total:o,onPage:d,unit:`个任务`})}):null;return(0,I.jsx)(L,{name:re,counts:[`${o} 个任务`,...s>0?[`待领取 ${s}`]:[]],intro:!t&&r?(0,I.jsx)(k,{kind:`repo`,owner:r,model:i}):null,batch:ce,list:le,footer:$,actions:(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(A,{kind:`dir`,labels:{more:O>0?`更多 (${O})`:`更多`,deleted:O>0?`已删除任务(${O})`:`已删除任务`},titles:{new:`按默认模板新建一页(▾ 选模板)`,import:`把一个 .md 文件导入成任务`,progress:`打开这个目录的进程面板`,more:O>0?`更多操作(含 ${O} 条已删除任务)`:`更多操作`,deleted:`查看并恢复已删除任务`,refs:`查看文档 / reference 列表`},renderers:{new:()=>(0,I.jsx)(`span`,{className:`rp-newtask`,children:(0,I.jsxs)(`button`,{type:`button`,className:`btn small primary`,title:`按默认模板新建一页(▾ 选模板)`,onClick:()=>f(),children:[`+ 新建页`,(0,I.jsx)(`span`,{role:`button`,tabIndex:0,"aria-label":`选择模板新建一页`,"aria-haspopup":`menu`,className:`rp-newtask-caret`,title:`选择模板新建一页`,onClick:e=>{e.stopPropagation(),x?.(e)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),x?.(e))},children:(0,I.jsx)(c,{name:`chevron`,size:11,title:void 0})})]})})},actions:{new:f,import:S,progress:ee,orch:T,deleted:te,refs:ne}})})})}var V=a,H=(e,t,n)=>D(e=>n.get(Number(e))||[],e,t);function U({task:e,tasks:t,onClose:n,onSave:r}){let i=e=>Number(e.id),a=i(e),o=t.filter(e=>i(e)!==a),[s,c]=(0,F.useState)(!!e.blocksFollowing),[l,u]=(0,F.useState)(()=>new Set((e.blockBy||[]).map(Number))),[d,f]=(0,F.useState)(()=>new Set(o.filter(e=>(e.blockBy||[]).map(Number).includes(a)).map(i))),[m,h]=(0,F.useState)(!1),g=t.findIndex(e=>i(e)===a),_=t.slice(g+1).map(i),v=new Map(t.map(e=>[i(e),i(e)===a?[...l]:(e.blockBy||[]).map(Number)])),y=e=>s||!l.has(i(e))&&H(i(e),a,v),b=e=>!d.has(i(e))&&H(a,i(e),v),x=e=>t=>e(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}),S=()=>c(e=>(e||u(new Set),!e)),ee=async()=>{h(!0);try{let e=[{id:a,gate:s,blockBy:[...l]}];if(!s)for(let t of o){let n=i(t),r=d.has(n),o=(t.blockBy||[]).map(Number);r!==o.includes(a)&&e.push({id:n,blockBy:r?[...o,a]:o.filter(e=>e!==a)})}await r(e),n()}catch{}finally{h(!1)}},C=(e,t,n,r)=>{let a=p(e.text)||`#${i(e)}`;return(0,I.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!m?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:t,disabled:m||n,onChange:()=>r(i(e))}),(0,I.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,I.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,I.jsx)(V,{title:`编排 · #${a} ${p(e.text)||``}`,onClose:n,busy:m,size:`md`,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:m,onClick:n,children:`取消`}),(0,I.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:m,onClick:ee,children:m?`保存中…`:`保存编排`})]}),children:(0,I.jsxs)(`div`,{className:`mdw-dag`,children:[(0,I.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:s,disabled:m,onChange:S}),(0,I.jsx)(`b`,{children:`闸门`}),(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),s?(0,I.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,_.length,` 个后续任务`,_.length?`:${_.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,I.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,s?(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,I.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>C(e,l.has(i(e)),y(e),x(u))):(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,I.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,s?(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,I.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>C(e,d.has(i(e)),s||b(e),x(f))):(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}var W=20;function G({dirKey:e}){let{dialog:t,node:n}=r(),a=f(),c=o(),l=a.rows||[],p=a.refreshLocal,_=a.tpl,b=a.model,D=a.repoData&&a.repoData.repos||[],k=!e||e===`__GLOBAL__`,[A,j]=(0,F.useState)(null),[M,N]=(0,F.useState)(!1),[L,R]=(0,F.useState)(null),z=(0,F.useRef)(null),V=(0,F.useMemo)(()=>k?l.find(e=>e.isGlobal)||null:l.find(t=>t.key===e)||null,[l,e,k]),H=(0,F.useMemo)(()=>{if(!V||k)return null;let e=V.repo&&V.repo.key;if(e){let t=D.find(t=>t.key===e);if(t)return t}let t=String(V.cwd||``).replace(/\\/g,`/`).toLowerCase();return t&&D.find(e=>String(e.path||``).replace(/\\/g,`/`).toLowerCase()===t)||null},[V,D,k]),G=(0,F.useMemo)(()=>ne((V?.tasks||[]).filter(e=>!e.deletedAt&&!h(e))),[V]),K=v(G,W),ie=(0,F.useMemo)(()=>G.filter(e=>e.status===`pending`&&!e.migratedTo).length,[G]),q=e=>e().catch(e=>c(String(e.message||e))),J=()=>k?{key:g}:{cwd:V?.cwd},Y=(e,t,n)=>{q(async()=>{await i(`/api/localtasks/reorder`,{method:`PATCH`,body:{...J(),id:e.id,...n===`before`?{beforeId:t}:{afterId:t}}}),p?.()})},X=e=>{q(async()=>{await i(`/api/localtasks/item`,{method:`PATCH`,body:{...J(),id:e.id,gate:!e.blocksFollowing}}),c(e.blocksFollowing?`#${e.id} 闸门已取消`:`#${e.id} 已设为闸门——挡住所有后续待领取任务`),p?.()})},ae=async e=>{try{for(let t of e)await i(`/api/localtasks/item`,{method:`PATCH`,body:{...J(),...t}});c(`编排已保存`),p?.()}catch(e){throw c(String(e.message||e)),e}},oe=(0,F.useMemo)(()=>{let e={},t=G.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},[G]),se=(0,F.useMemo)(()=>G.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),[G]),Z=t=>{a.openPage&&a.openPage({dirKey:e,task:String(t),name:`#${t}`})},Q=t=>{let n=E();C(T(S(e),n),{title:``,body:t}),a.openPage&&a.openPage({dirKey:e,task:n,name:`新任务`})},ce=()=>{b&&y(b)},le=()=>{b&&u(b,{component:`progress`,name:`进程`,config:{dirKey:e||`__GLOBAL__`},location:`right`})},$=k?g:e||`__GLOBAL__`,ue=w($).templates||_&&_.templates||[],de=()=>{if(!b){c(`工作区未就绪`);return}ee(b,{mode:`new`,topic:$,scope:k?[]:[`topic:${$}`],name:``})},fe=[...ue.length?ue.map(e=>({label:(e.id===_?.defaultId?`✓ `:``)+e.name,icon:`list`,onClick:()=>Q(x(e.body,{...m,...e.values||{}}))})):[{label:`按默认模板新建一页`,icon:`list`,onClick:()=>Q(_?_.defaultBody():``)}],`sep`,{label:`为本${k?`全局池`:`目录`}新建模板…`,icon:`plus`,onClick:de},{label:`管理模板…`,icon:`gear`,onClick:ce}],pe=async e=>{if(e==null)return null;let t=k?`key=${encodeURIComponent(g)}&id=${Number(e.id)}`:`cwd=${encodeURIComponent(V?.cwd||``)}&id=${Number(e.id)}`;return i(`/api/localtasks/item?${t}`).catch(()=>null)},me=n=>{if(!n)return;let r=(n.text||``).split(`
2
- `).find(e=>e.trim())||`#${n.id}`;q(async()=>{let a=!!n.completedAt,o=await t({title:a?`反馈 · #${n.id}`:`反馈修改 · #${n.id}`,input:!0,placeholder:a?`写下反馈(将新开一条任务,原任务不动)`:`写下要改的地方(留空 = 只重开,不改正文)`});if(o==null)return;let s=String(o).trim(),l=await pe(n),u=String(l?.text??``).trim()||String(n.text||``).trim(),d=a&&(l?.roundSummary||n.roundSummary)||``;if(!s&&!a&&!u){c(`拿不到任务当前正文,已取消(防止丢内容)`);return}if(a){let t=s?te({base:u,feedback:s,ackSummary:d,feedbackHeading:O,bold:!0}):``;if(!t){c(`写一下反馈`);return}let a=await i(`/api/localtasks`,{method:`POST`,body:k?{global:!0,text:t,forkOf:String(n.id),forkKind:`reopen`}:{cwd:V?.cwd,text:t,forkOf:String(n.id),forkKind:`reopen`}}),o=String(a?.task?.id??a?.id??``),l=a?.key||e;o&&C(T(S(l),o),{body:t}),c(`已反馈「${r.replace(/^#\s*/,``)}」→ 新任务 #${o||`?`}`),p?.();return}let f=await i(`/api/localtasks/reopen`,{method:`POST`,body:{...J(),id:n.id,kind:`reopen`,...s?{feedback:s,feedbackHeading:re,feedbackBold:!1}:{}}}),m=f?.key||e,h=String(f?.task?.id??n.id),g=String(f?.task?.text??``);g&&C(T(S(m),h),{body:g}),c(`已回写「${r.replace(/^#\s*/,``)}」#${h}`+(f?.moved&&f.name?`;归属迁到「${f.name}」`:``)),p?.()})},he=async n=>{if(!n)return;let r=(n.text||``).split(`
3
- `).find(e=>e.trim())||`#${n.id}`;await t({title:`删除任务「${r.replace(/^#\s*/,``)}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&q(async()=>{if(await i(`/api/localtasks/item`,{method:`DELETE`,body:k?{key:g,id:n.id}:{cwd:V?.cwd,id:n.id}}),c(`已删除「${r.replace(/^#\s*/,``)}」`),b){let t=d(b,`page`,{dirKey:e,task:String(n.id)});t&&a.closePanel&&a.closePanel(t.getId())}p?.()})},ge=async e=>{let n=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!n.length||!await t({title:`删除选中的 ${n.length} 条任务`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})?!1:q(async()=>{let e=await i(`/api/localtasks/items`,{method:`DELETE`,body:{...J(),ids:n}});return c(`已删除 ${e?.count??n.length} 条任务`),p?.(),!0})},_e=async e=>{let n=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!n.length||!await t({title:`取消选中的 ${n.length} 条待领取任务`,message:`只处理待领取任务;已领取/已交付/已取消会跳过。取消为终态,原文留档。`,okText:`取消任务`})?!1:q(async()=>{let e=await i(`/api/localtasks/items/cancel`,{method:`POST`,body:{...J(),ids:n}}),t=e?.skipped?.length||0;return c(`已取消 ${e?.count??0} 条任务${t?`,跳过 ${t} 条`:``}`),p?.(),!0})},ve=async e=>{let n=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!n.length||!await t({title:`把选中的 ${n.length} 条待领取任务标为完成`,message:`只处理待领取任务;已领取/已交付/已取消会跳过。完成会补一条完成记录,原文留档。`,okText:`标为完成`})?!1:q(async()=>{let e=await i(`/api/localtasks/items/close`,{method:`POST`,body:{...J(),ids:n,status:`done`}}),t=e?.skipped?.length||0;return c(`已标为完成 ${e?.count??0} 条任务${t?`,跳过 ${t} 条`:``}`),p?.(),!0})},ye=(0,F.useMemo)(()=>(V?.tasks||[]).filter(e=>e.deletedAt).slice().reverse(),[V]),be=e=>{e&&q(async()=>{await i(`/api/localtasks/tasks/restore`,{method:`POST`,body:k?{key:g,id:e.id}:{cwd:V?.cwd,id:e.id}}),c(`已恢复 #${e.id}「${(e.text||``).split(`
4
- `).find(e=>e.trim())?.replace(/^#\s*/,``)||``}」`),p?.()})},xe=async e=>{if(!e)return;let n=(e.text||``).split(`
5
- `).find(e=>e.trim())||`#${e.id}`;await t({title:`彻底删除「${n.replace(/^#\s*/,``)}」`,message:`彻底删除后不可恢复(行从队列里真正摘除)。`,danger:!0,okText:`彻底删除`})&&q(async()=>{await i(`/api/localtasks/item`,{method:`DELETE`,body:{...k?{key:g}:{cwd:V?.cwd},id:e.id,purge:!0}}),c(`已彻底删除 #${e.id}`),p?.()})},Se=()=>N(!0),Ce=()=>{if(k||!H){c(`全局池没有项目文档列表`);return}if(!b)return;let e=H.key||V?.repo&&V.repo.key||``;if(!e){c(`这个项目还没有仓库标识(key),无法定位文档列表`);return}u(b,{component:`refs`,name:`文档列表`,config:{repoKey:e},location:`right`})},we=async e=>{let t=await e.text(),n=e.name.replace(/\.md$/i,``);await q(async()=>{let r=t.startsWith(`#`)?t:`# ${n}\n\n${t}`,a=await i(`/api/localtasks`,{method:`POST`,body:k?{global:!0,text:r}:{cwd:V?.cwd,text:r}});c(`已导入:${e.name}`),p?.();let o=a?.task?.id??a?.id;o!=null&&Z(o)})};return!V&&!k?(0,I.jsx)(`div`,{className:`mdw`,children:(0,I.jsx)(`div`,{className:`mdw-main`,children:(0,I.jsx)(`div`,{className:`mdw-top`,children:(0,I.jsxs)(`div`,{className:`mdw-head`,children:[(0,I.jsx)(`div`,{className:`mdw-title`,children:`目录不存在`}),(0,I.jsx)(`div`,{className:`mdw-path`,children:`—`})]})})})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(B,{isGlobal:k,topic:V,repo:H,model:b,tasks:K.items,taskCount:K.total,pendingCount:ie,page:K.page,pageCount:K.pageCount,onPage:K.setPage,onNew:()=>Q(_?_.defaultBody():``),onOpenTask:Z,onDeleteTask:he,onDeleteTasks:ge,onCancelTasks:_e,onCompleteTasks:ve,onReopenTask:me,onTplMenu:e=>j({x:e.clientX,y:e.clientY}),onImport:()=>z.current?.click(),onProg:le,onMoveTask:Y,onOpenDag:R,onOpenFlow:()=>b&&u(b,{component:`dag`,name:`编排`,config:{dirKey:e}}),onToggleGate:X,downstreamOf:oe,onDeleted:Se,onRefs:Ce,deletedCount:ye.length}),L&&(0,I.jsx)(U,{task:L,tasks:se,onClose:()=>R(null),onSave:ae}),M&&(0,I.jsx)(P,{tasks:ye,onClose:()=>N(!1),onRestore:be,onPurge:xe}),A&&(0,I.jsx)(s,{x:A.x,y:A.y,items:fe,onClose:()=>j(null)}),(0,I.jsx)(`input`,{ref:z,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&we(t)}}),n]})}export{G as default};
@@ -1,2 +0,0 @@
1
- import{g as e,h as t,l as n,m as r,p as i,u as a,y as o}from"./task-status-DSrx0i66.js";import{r as s,w as c}from"./workspace-4tw7trV7.js";import{n as l}from"./app-context-BASCGAA-.js";import{r as u,t as d}from"./frontmatter-CLLxCmTv.js";import{n as ee}from"./md-parse-b6GY5eBl.js";import{_ as f,g as p,i as m,m as h,n as te,o as ne,p as re,r as ie,s as ae,u as oe}from"./index-D8MvtVAm.js";import{t as se}from"./route-crumb-CWVu80du.js";import{t as ce}from"./Introduction-aQCeCLrV.js";import{t as le}from"./bar-B9WWmCpt.js";import{i as ue,n as de,r as g,t as fe}from"./deleted-panel-BcbtctNF.js";import{t as _}from"./member-picker-B5I7KuOR.js";var v=o(e(),1),y=c(),b=t(),x=g,S=20;function C({dirKey:e,rows:t,repoData:o,model:c}){let g=i(),{dialog:C,node:pe}=n(),w=l(),T=te(),E=o&&o.boards||[],D=o&&o.repos||[],O=t||[],[me,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(!1),[M,N]=(0,v.useState)(!1),[P,F]=(0,v.useState)(null),I=(0,v.useRef)(null),L=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!M)return;let e=e=>{I.current?.contains(e.target)||L.current?.contains(e.target)||N(!1)},t=e=>{e.key===`Escape`&&N(!1)},n=()=>{let e=I.current?.querySelector(`button`);if(!e)return;let t=e.getBoundingClientRect(),n=L.current?.offsetHeight||240,r=window.innerHeight-t.bottom-6,i=r>=n||r>=t.top?t.bottom+6:Math.max(8,t.top-6-n);F({top:i,right:Math.max(8,window.innerWidth-t.right)})};n();let r=requestAnimationFrame(n);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),window.addEventListener(`resize`,n),window.addEventListener(`scroll`,n,!0),()=>{cancelAnimationFrame(r),document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),window.removeEventListener(`resize`,n),window.removeEventListener(`scroll`,n,!0)}},[M]);let R=(0,v.useMemo)(()=>E.find(t=>t.id===e)||E.find(t=>t.key===e)||null,[E,e]),z=(0,v.useMemo)(()=>{if(!R)return[];let e=new Map(D.map(e=>[e.key,e])),t=new Map;for(let e of O)!e.isGlobal&&e.repo&&e.repo.key&&(t.has(e.repo.key)||t.set(e.repo.key,e));return(R.repos||[]).map(n=>{let r=e.get(n.key)||null,i=t.get(n.key)||null;return{key:n.key,name:n.name||r&&r.name||n.key,path:n.path||r&&r.path||``,cwd:i&&i.cwd||n.path||r&&r.path||``,desc:n.note||r&&r.desc||``,pending:i&&i.pending||0,waiting:!!(i&&i.waiting),topicKey:i?i.key:``,summary:i&&i.summary||``,tasks:i&&i.tasks||[],present:n.present!==!1,noteDocId:n.noteDocPath?`path:`+n.noteDocPath:`rel:`+(n.noteDocRel||``)}})},[R,D,O]);if(!R)return(0,b.jsxs)(`div`,{className:`rp-page`,children:[(0,b.jsx)(se,{}),(0,b.jsx)(`div`,{className:`rp-empty`,children:`项目组不存在(看板可能被删了)`})]});let B=z.reduce((e,t)=>e+t.pending,0),he=(0,v.useMemo)(()=>{let e=new Map;for(let t of O){if(!t.key||t.isGlobal)continue;let n=(t.tasks||[]).filter(e=>e&&!e.deletedAt&&!e.migratedTo&&e.status===`pending`),r={};n.forEach((e,t)=>{e.blocksFollowing&&(r[e.id]=n.slice(t+1).map(e=>e.id))}),e.set(t.key,{tasks:n,downstream:r})}return e},[O]),V=z.find(e=>e.pending>0)||z[0]||null,H=(0,v.useMemo)(()=>{let e=R?[R.id,R.key,R.name].filter(Boolean):[],t=[],n=[];for(let r of z)for(let i of r.tasks||[]){if(i.deletedAt)continue;let a=d(i.text);a.board&&e.includes(a.board)&&(i.status===`pending`?t:n).push({member:r,task:i,project:a.project||``})}return n.sort((e,t)=>String(t.task.consumedAt||``).localeCompare(String(e.task.consumedAt||``))),[...t,...n]},[R,z]),U=(0,v.useMemo)(()=>{let e=R?[R.id,R.key,R.name].filter(Boolean):[],t=[];for(let n of z)for(let r of n.tasks||[]){if(!r.deletedAt)continue;let i=d(r.text);i.board&&e.includes(i.board)&&t.push({...r,memberName:n.name,memberCwd:n.cwd})}return t.reverse()},[R,z]),ge=async e=>{if(e)try{await r(`/api/localtasks/tasks/restore`,{method:`POST`,body:{cwd:e.memberCwd,id:e.id}}),g(`已恢复 #${e.id}`),w.refreshLocal&&await w.refreshLocal()}catch(e){g(`恢复失败:${e.message||e}`)}},_e=async e=>{if(!e)return;let t=(e.text||``).split(`
2
- `).find(e=>e.trim())||`#${e.id}`;if(await C({title:`彻底删除「${t.replace(/^#\s*/,``)}」`,message:`彻底删除后不可恢复(行从队列里真正摘除)。`,danger:!0,okText:`彻底删除`}))try{await r(`/api/localtasks/item`,{method:`DELETE`,body:{cwd:e.memberCwd,id:e.id,purge:!0}}),g(`已彻底删除 #${e.id}`),w.refreshLocal&&await w.refreshLocal()}catch(e){g(`删除失败:${e.message||e}`)}},ve=(0,v.useMemo)(()=>H.filter(e=>e.task.status===`pending`).length,[H]),W=f(H,S),G=(0,v.useRef)(null),[ye,K]=(0,v.useState)(null),[q,J]=(0,v.useState)(null),Y=(e,t)=>e.key+`:`+t.id,X=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},Z=(e,t,n)=>{G.current={id:Number(n.id),topicKey:t.topicKey,cwd:t.cwd||t.path||``,row:Y(t,n)},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+n.id),K(Y(t,n))},be=(e,t,n)=>{let r=G.current;r&&r.row!==Y(t,n)&&(e.preventDefault(),e.dataTransfer.dropEffect=r.topicKey===t.topicKey?`move`:`none`,J({key:Y(t,n),zone:X(e,e.currentTarget)}))},xe=e=>{e.currentTarget.contains(e.relatedTarget)||J(null)},Se=async(e,t,n)=>{e.preventDefault();let i=X(e,e.currentTarget),a=G.current;if(G.current=null,K(null),J(null),!a||a.row===Y(t,n))return;if(a.topicKey!==t.topicKey){g(`只能在同一项目队列内排序(跨项目请用编排连线)`);return}let o=t.cwd||t.path;if(!t.topicKey||!o){g(`该成员还没有本地队列,无法排序`);return}try{await r(`/api/localtasks/reorder`,{method:`PATCH`,body:{cwd:o,id:a.id,...i===`before`?{beforeId:Number(n.id)}:{afterId:Number(n.id)}}}),w.refreshLocal&&await w.refreshLocal()}catch(e){g(String(e.message||e))}},Ce=()=>{G.current=null,K(null),J(null)},Q=e=>{if(!R)return;if(!V)return g(`这个组还没有成员——先「添加成员」,再建任务`);let t=oe(),n=ae(h(R.id),t);re(n,{title:``,body:u(e||T.defaultBody(),{board:R.id,project:V.key})}),w.openPage?.({groupId:R.id,task:t,name:`新任务`})},$=ie({topic:V?V.topicKey:``,group:R?R.key:``,repo:V?V.key:``}).templates||T.templates||[],we=()=>{R&&c&&ne(c,{mode:`new`,scope:[`group:${R.key}`],name:``})},Te=(0,b.jsx)(ce,{kind:`board`,owner:R,model:c}),Ee=(0,b.jsx)(ue,{title:`本组任务`,pendingCount:ve,emptyText:`本组还没有任务——点「+ 新增任务」创建;只有在本组创建的任务(携带本组语义)才会出现在这里。`,children:W.items.map(({member:e,task:t})=>{let n=t.status===`pending`,r=he.get(e.topicKey),i=r&&r.downstream[t.id]||[],a=Y(e,t);return(0,b.jsx)(de,{t,projectTag:e.name,history:!n,draggable:n&&!!e.topicKey,dragHandlers:n&&e.topicKey?{onDragStart:n=>Z(n,e,t),onDragOver:n=>be(n,e,t),onDragLeave:xe,onDrop:n=>Se(n,e,t),onDragEnd:Ce}:null,dragVisual:{dragging:ye===a,drop:q&&q.key===a?q.zone:null},downs:i,onTogglePick:void 0,onOpen:()=>w.openPage&&w.openPage({groupId:R.id,task:String(t.id),name:`#${t.id}`})},a)})}),De=(0,b.jsx)(`div`,{className:`mdw-land-pager`,children:(0,b.jsx)(p,{page:W.page,pageCount:W.pageCount,total:W.total,onPage:W.setPage,unit:`个任务`})});return(0,b.jsxs)(x,{name:R.name,counts:[`${z.length} 个目录`,...B>0?[`待领取 ${B}`]:[]],intro:Te,list:Ee,footer:De,actions:(0,b.jsx)(b.Fragment,{children:(0,b.jsx)(le,{kind:`group`,titles:{progress:`打开本组的任务进程面板`,addMember:`挑项目加进这个组`,orch:`打开可视化编排面板`,deleted:`查看本组已删除的任务(可恢复)`,refs:`查看文档 / reference 列表`},labels:{more:U.length?`更多 (${U.length})`:`更多`,deleted:U.length?`已删除任务(${U.length})`:`已删除任务`},disabled:{new:!V},renderers:{new:()=>(0,b.jsxs)(`div`,{className:`rp-newtask`,ref:I,children:[(0,b.jsxs)(`button`,{type:`button`,className:`btn small`+(M?` is-open`:``),title:`按默认模板新建任务(▾ 选模板;携带本组语义)`,disabled:!V,onClick:()=>Q(``),children:[`+ 新增任务`,(0,b.jsx)(`span`,{role:`button`,tabIndex:V?0:void 0,"aria-label":`选择模板新建任务`,"aria-haspopup":`menu`,"aria-expanded":M,className:`rp-newtask-caret`+(M?` rot`:``),title:`选择模板新建任务`,onClick:e=>{e.stopPropagation();let t=(e.currentTarget.closest(`.rp-newtask`)||e.currentTarget).getBoundingClientRect();F({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)}),N(e=>!e)},onKeyDown:e=>{if(e.key===`Enter`||e.key===` `){e.preventDefault(),e.stopPropagation();let t=(e.currentTarget.closest(`.rp-newtask`)||e.currentTarget).getBoundingClientRect();F({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)}),N(e=>!e)}},children:(0,b.jsx)(a,{name:`chevron`,size:11,title:void 0})})]}),M&&V&&P&&(0,y.createPortal)((0,b.jsxs)(`div`,{ref:L,className:`rp-tpl-fly rp-tpl-fly-portal`,role:`menu`,"aria-label":`选择模板新建任务`,style:{top:P.top,right:P.right},children:[(0,b.jsxs)(`div`,{className:`rp-tpl-fly-h`,children:[R.name,` · 可用模板`]}),(0,b.jsx)(`div`,{className:`rp-tpl-fly-list`,children:($.length?$:[{id:`__fallback__`,name:`按默认模板新建`,fallback:!0}]).map(e=>(0,b.jsx)(`button`,{type:`button`,className:`rp-tpl-fly-it`,role:`menuitem`,onClick:()=>{N(!1),Q(e.fallback?``:m(e.body,{...ee,...e.values||{}}))},children:(e.id===T.defaultId&&!e.fallback?`✓ `:``)+e.name},e.id))}),(0,b.jsx)(`div`,{className:`rp-tpl-fly-foot`,children:(0,b.jsx)(`button`,{type:`button`,className:`rp-tpl-fly-new`,onClick:()=>{N(!1),we()},children:`+ 新增模板…`})})]}),document.body)]})},actions:{progress:()=>{c&&s(c,{component:`progress`,name:`进程`,config:{groupKey:e},location:`right`})},addMember:()=>k(!0),orch:()=>{c&&s(c,{component:`dag`,name:`编排`,config:{dirKey:V&&V.topicKey||``,groupId:R&&R.id}})},refs:()=>{c&&R&&s(c,{component:`refs`,name:`文档列表`,config:{boardKey:e,boardName:R.name},location:`right`})},deleted:()=>j(!0)}})}),children:[pe,me&&R?(0,b.jsx)(_,{board:R,boards:E,repos:D,onClose:()=>k(!1),onChanged:()=>w.refreshRepos&&w.refreshRepos()}):null,A&&(0,b.jsx)(fe,{tasks:U,onClose:()=>j(!1),onRestore:ge,onPurge:_e})]})}export{C as default};
@@ -1 +0,0 @@
1
- import{g as e,h as t,l as n,m as r,p as i,y as a}from"./task-status-DSrx0i66.js";import{a as o}from"./md-parse-b6GY5eBl.js";import{s,t as c}from"./board-view-DABoVkaA.js";import{t as l}from"./status-tag-DRl9E2Os.js";import{t as u}from"./route-crumb-CWVu80du.js";var d=a(e(),1),f=t(),p=s;function m({rows:e,onNavigate:t,refreshLocal:a}){let o=i(),{dialog:s,node:l}=n(),[m,g]=(0,d.useState)(()=>new Set),[_,v]=(0,d.useState)(``),y=(0,d.useMemo)(()=>{let t=[];for(let n of e||[]){let e=p(n.tasks||[]),r=n.isGlobal?`#/global`:`#/dir/`+encodeURIComponent(n.key);for(let i of[...e.pending,...e.claimed])t.push({t:i,secKey:n.isGlobal?c:n.key,proj:n.isGlobal?`全局`:n.name||n.key,cwd:n.cwd||``,waiting:!!n.waiting,base:r})}return t},[e]),b=(0,d.useMemo)(()=>(e||[]).filter(e=>e.waiting).length,[e]),x=(0,d.useMemo)(()=>{let e=[],t=new Map;for(let n of y)t.has(n.proj)||(t.set(n.proj,0),e.push(n.proj)),t.set(n.proj,(t.get(n.proj)||0)+1);return e.map(e=>({proj:e,count:t.get(e)||0}))},[y]),S=x.some(e=>e.proj===_)?_:``,C=(0,d.useMemo)(()=>S?y.filter(e=>e.proj===S):y,[y,S]),w=(0,d.useMemo)(()=>C.filter(e=>e.t.status!==`claimed`).length,[C]),T=(0,d.useMemo)(()=>{let e=new Set(C.map(e=>Number(e.t.id)));return[...m].filter(t=>e.has(t))},[m,C]),E=T.length,D=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},O=e=>{g(e?new Set:new Set(C.map(e=>Number(e.t.id))))},k=C.length>0&&T.length===C.length,A=async()=>{let e=new Set(T),t=[];for(let n of y){if(!e.has(Number(n.t.id)))continue;let r=t.find(e=>e.key===n.secKey);r||(r={key:n.secKey,name:n.proj,ids:[]},t.push(r)),r.ids.push(Number(n.t.id))}let n=t.reduce((e,t)=>e+t.ids.length,0);if(!n)return;let i=t.length>1?`(跨 ${t.length} 个目录)`:``;if(!await s({title:`删除 ${n} 条任务${i}`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`}))return;let c=0,l=0,u=[];for(let e of t)try{let t=await r(`/api/localtasks/items`,{method:`DELETE`,body:{key:e.key,ids:e.ids}});c+=Number(t?.count??0),l+=(t?.missing||[]).length}catch(t){let n=String(t.message||t);if(/接口不存在/.test(n)){o(`本机面板服务较旧,重启面板后再试(批量删除接口未上线)`);return}u.push(`${e.name}: ${n}`)}u.length?o(`已删除 ${c} 条;${u.length} 个目录失败:${u[0]}${u.length>1?` 等 ${u.length} 项`:``}`):o(`已删除 ${c} 条${l?`(${l} 条未找到,可能已被删除)`:``}`),g(new Set),a?.()},j=(e,n)=>{let r=e.t.boardMark?`#/group/${encodeURIComponent(e.t.boardMark)}?task=${encodeURIComponent(n)}`:`${e.base}?task=${encodeURIComponent(n)}`;t?.(r)};return(0,f.jsxs)(`div`,{className:`ov-wrap`,children:[(0,f.jsx)(u,{}),l,(0,f.jsxs)(`div`,{className:`ov-head`,children:[(0,f.jsx)(`h2`,{children:`全部目录总览`}),(0,f.jsxs)(`span`,{className:`muted`,children:[C.length,` 个未完成任务(待领取 `,w,`)`,b?` · ${b} 个目录等待回填`:``]}),C.length>0&&(0,f.jsxs)(`label`,{className:`ov-all`,children:[(0,f.jsx)(`input`,{type:`checkbox`,checked:k,ref:e=>{e&&(e.indeterminate=!k&&E>0)},onChange:()=>O(k),"aria-label":`全选未完成任务`}),`全选`]})]}),x.length>1&&(0,f.jsxs)(`div`,{className:`ov-tabs`,role:`tablist`,"aria-label":`按项目筛选`,children:[(0,f.jsxs)(`button`,{type:`button`,className:`ov-tab`+(S?``:` on`),onClick:()=>v(``),children:[`全部 `,y.length]}),x.map(e=>(0,f.jsxs)(`button`,{type:`button`,className:`ov-tab`+(S===e.proj?` on`:``),onClick:()=>v(e.proj),children:[e.proj,` `,e.count]},e.proj))]}),C.length?(0,f.jsx)(`div`,{className:`ov-list`,children:C.map(e=>(0,f.jsx)(h,{t:e.t,proj:e.proj,waiting:e.waiting,checked:m.has(Number(e.t.id)),onToggle:D,onOpenTask:t=>j(e,t),meta:e.t.status===`claimed`&&e.t.consumedAt?String(e.t.consumedAt).slice(5,16):``},`${e.secKey}-${e.t.id}`))}):(0,f.jsx)(`div`,{className:`ov-task muted`,children:`没有未完成的任务——当前队列都清空了。在侧边栏点 + 添加目录,或让 agent 在任意目录提交任务。`}),E>0&&(0,f.jsxs)(`div`,{className:`ov-bar`,role:`toolbar`,"aria-label":`批量删除操作条`,children:[(0,f.jsxs)(`span`,{className:`ov-bar-n`,children:[`已选 `,(0,f.jsx)(`b`,{children:E}),` 条任务`]}),(0,f.jsx)(`span`,{className:`grow`}),(0,f.jsx)(`button`,{type:`button`,className:`mini`,onClick:()=>g(new Set),children:`取消选择`}),(0,f.jsxs)(`button`,{type:`button`,className:`btn small danger`,onClick:A,children:[`删除选中 `,E]})]})]})}function h({t:e,proj:t,waiting:n,checked:r,onToggle:i,onOpenTask:a,meta:s=``}){return(0,f.jsxs)(`div`,{className:`ov-task link`,role:`button`,tabIndex:0,title:`打开任务详情`,onClick:()=>a(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e.id))},children:[(0,f.jsx)(`label`,{className:`ov-ck`,onClick:e=>e.stopPropagation(),children:(0,f.jsx)(`input`,{type:`checkbox`,checked:r,onChange:()=>i(Number(e.id)),"aria-label":`选择 #${e.id}`})}),(0,f.jsxs)(`span`,{className:`mono faint`,children:[`#`,e.id]}),(0,f.jsx)(`span`,{className:`tx`,title:e.text,children:o(e.text,e.text||`未命名任务`)}),e.boardMark?(0,f.jsx)(`span`,{className:`tag t-board`,title:`项目组任务:详情在组页打开`,children:`组`}):null,t?(0,f.jsxs)(`span`,{className:`tag t-proj`,title:`所属项目`,children:[t,n?(0,f.jsx)(`span`,{className:`wdot`}):null]}):null,e.from===`cloud`&&(0,f.jsx)(`span`,{className:`tag t-cloud`,children:`云端`}),s?(0,f.jsx)(`span`,{className:`m mono`,children:s}):null,(0,f.jsx)(l,{t:e,title:void 0})]})}export{m as default};
@@ -1,3 +0,0 @@
1
- import{g as e,h as t,l as n,m as r,p as i,u as a,y as o}from"./task-status-DSrx0i66.js";import{o as s,u as c}from"./workspace-4tw7trV7.js";import{t as ee}from"./frontmatter-CLLxCmTv.js";import{i as l}from"./md-parse-b6GY5eBl.js";import{r as u,t as d}from"./board-view-DABoVkaA.js";var f=o(e(),1);function p(e){return!Number(e&&e.childRoundCount)}function m(e){let t=[],n=[];for(let r of e||[])(p(r)?t:n).push(r);return{tips:t,folded:n}}function h(e){let t=e&&e.taskId!==void 0&&e.taskId!==null?e.taskId:e&&e.id;return String(t??``)}function g(e,t){let n=String(e??``).toLowerCase(),r=(t||[]).map(e=>String(e).toLowerCase()).filter(Boolean);if(!r.length)return!0;let i=0;for(let e of r){let t=n.indexOf(e,i);if(t<0)return!1;i=t+e.length}return!0}function _(e,t){let n=String(e??``).toLowerCase(),r=String(t??``).toLowerCase().split(``),i=0;for(let e of r){let t=n.indexOf(e,i);if(t<0)return!1;i=t+1}return!0}function v(e,t){let n=String(t??``).trim().toLowerCase();if(!n)return!0;let r=n.startsWith(`#`)?n.slice(1).trim():n;if(!r)return!0;let i=h(e),a=String(e&&e.title||``).toLowerCase();if(r.includes(`*`)){let e=r.split(`*`).filter(Boolean);return g(a,e)?!0:g(i,e)}return/^\d+$/.test(r)?i===r||i.startsWith(r)?!0:_(a,r):a.includes(r)}function te(e,t){let n=String(t??``).trim().toLowerCase(),r=n.startsWith(`#`)?n.slice(1).trim():n;return!r||!/^\d+$/.test(r)?!1:h(e)===r}var y=t();function b(e){if(e==null||e<0||Number.isNaN(e))return`—`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%60/60),i=t%60;return n?`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`:`${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`}function x(e,t){if(e.status!==`run`)return`—`;let n=e.receivedAt?Date.parse(e.receivedAt):NaN;return Number.isFinite(n)?b(t-n):`—`}function S({dirKey:e,task:t,rows:o=[],refreshLocal:h,model:g,onOpenTask:_,onClosePage:b,group:S=null}){let C=i(),{dialog:ne,node:re}=n(),w=!e||e===`__GLOBAL__`,T=o||[],E=(0,f.useMemo)(()=>w?T.find(e=>e.isGlobal)||null:T.find(t=>t.key===e)||null,[T,e,w]),D=(0,f.useMemo)(()=>(E?.tasks||[]).filter(e=>!e.deletedAt&&!u(e)),[E]),{tips:O,folded:k}=(0,f.useMemo)(()=>m(D),[D]),[A,j]=(0,f.useState)(Date.now()),[M,N]=(0,f.useState)(()=>new Set),[P,F]=(0,f.useState)(!1);(0,f.useEffect)(()=>{let e=setInterval(()=>j(Date.now()),1e3);return()=>clearInterval(e)},[]);let{cards:I,folded:L}=(0,f.useMemo)(()=>{if(!S)return{cards:[],folded:[]};let e=[S.id,S.key,S.name].filter(Boolean),t=S.repos||[],n=new Map;for(let e of t)e&&e.key&&n.set(e.key,e);let r=(e,n)=>{let r=t.find(t=>t&&(t.key===e||t.name===e||t.path&&t.path===e));return r&&r.name?r.name:e?String(e).split(`/`).pop()||String(e):n&&n.name||``},i=[],a=[];for(let t of T){if(!t||t.isGlobal||!Array.isArray(t.tasks))continue;let o=t.repo&&t.repo.key,s=o&&n.get(o)||null,c=!!s;for(let n of t.tasks){if(!n||n.deletedAt)continue;let o={};try{o=ee(n.text||``)}catch{o={}}if(!c&&(!o.board||!e.includes(o.board)))continue;let u={...l(n),key:`${t.key}:${n.id}`,taskId:n.id,topicKey:t.key,topicCwd:t.cwd||``,project:o.project||``,projectName:c&&s&&s.name||r(o.project,t)};p(n)?i.push(u):a.push({...u,folded:!0})}}let o={run:0,wait:1,done:2};return{cards:i.sort((e,t)=>(o[e.status]??9)-(o[t.status]??9)||(e.projectName||``).localeCompare(t.projectName||``)||Number(e.taskId)-Number(t.taskId)),folded:a}},[S,T]),[R,z]=(0,f.useState)(``),[B,V]=(0,f.useState)(``),H=(0,f.useMemo)(()=>{let e=new Map;for(let t of I)t.projectName&&!e.has(t.projectName)&&e.set(t.projectName,!0);return[...e.keys()]},[I]),U=(0,f.useMemo)(()=>{let e={run:0,wait:1,done:2},t=S?(t,n)=>(e[t.status]??9)-(e[n.status]??9)||(t.projectName||``).localeCompare(n.projectName||``)||Number(t.taskId)-Number(n.taskId):(t,n)=>(e[t.status]??9)-(e[n.status]??9),n=S?(()=>{let e=R&&H.includes(R)?R:``;return I.filter(t=>!e||t.projectName===e)})():O.map(e=>l(e)).sort(t),r=B.trim().toLowerCase();if(!r)return n;let i=n.filter(e=>v(e,r)),a=(S?L:k.map(e=>({...l(e),folded:!0}))).filter(e=>te(e,r));return a.length?[...i,...a].sort(t):i},[S,I,L,R,H,O,k,B]),W=e=>S?e.key:e.id;(0,f.useEffect)(()=>{N(e=>{if(!e.size)return e;let t=new Set(U.map(W)),n=new Set([...e].filter(e=>t.has(e)));return n.size===e.size?e:n})},[U,S]);let G=U.filter(e=>e.status===`run`).length,K=U.filter(e=>e.status===`wait`).length,q=U.filter(e=>e.status===`done`).length,J=U.length?Math.round(q*100/U.length):0,Y=U.length>0&&M.size===U.length,X=U.filter(e=>M.has(W(e))),ie=e=>{N(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Z=()=>{N(Y?new Set:new Set(U.map(W)))},ae=async()=>{if(P||!X.length)return;let t=X.map(e=>`#${e.taskId??e.id} ${e.title}`),n=t.length<=6?t.join(`
2
- `):`${t.slice(0,6).join(`
3
- `)}… 共 ${t.length} 条`;if(await ne({title:`删除选中的 ${X.length} 条任务`,message:`${n}\n\n软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})){F(!0);try{let t=0,n=0;if(S){let e=new Map;for(let t of X){let n=t.topicKey||``;e.has(n)||e.set(n,{cwd:t.topicCwd,ids:[]});let r=e.get(n);r&&r.ids.push(t.taskId)}for(let{cwd:i,ids:a}of e.values()){let e=await r(`/api/localtasks/items`,{method:`DELETE`,body:{cwd:i,ids:a}});t+=e?.count??a.length,n+=e?.missing?.length||0}}else{let e=X.map(e=>e.id),i=await r(`/api/localtasks/items`,{method:`DELETE`,body:{...w?{key:d}:{cwd:E?.cwd},ids:e}});t=i?.count??e.length,n=i?.missing?.length||0}let i=n?`(${n} 条已不存在)`:``;if(g)for(let t of X){let n=S?t.topicKey:e,r=S?t.taskId:t.id,i=c(g,`page`,{dirKey:n,task:String(r)});i&&b&&b(i.getId())}N(new Set),h?.(),C(`已删除 ${t} 条任务${i}`)}catch(e){C(`删除失败: `+(e.message||e))}finally{F(!1)}}},oe=e=>{_&&(S?_(e.taskId,e.topicKey):_(e.id))},Q=t!=null&&String(t)!==``?String(t):``,$=S?L.length:k.length;return(0,y.jsxs)(`div`,{className:`mdw-prog-host`,children:[re,(0,y.jsxs)(`div`,{className:`mdw-prog-h`,children:[(0,y.jsx)(`span`,{className:`t`,children:S?`${S.name} · 任务进程`:E?.name||(w?`全局任务池`:`任务进程`)}),U.length>0&&(0,y.jsx)(`button`,{type:`button`,className:`mdw-prog-all`,onClick:Z,title:Y?`取消全选`:`全选任务`,children:Y?`取消全选`:`全选`}),g&&(0,y.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭进程面板`,"aria-label":`关闭进程面板`,onClick:()=>s(g),children:(0,y.jsx)(a,{name:`x`,size:14,title:void 0})})]}),(S?I.length>0:O.length>0)&&(0,y.jsxs)(`div`,{className:`mdw-prog-search`,children:[(0,y.jsx)(a,{name:`search`,size:13,title:void 0}),(0,y.jsx)(`input`,{value:B,onChange:e=>V(e.target.value),placeholder:`搜索编号或标题(如 12 → #12、#120-129;1*2 通配)`,spellCheck:`false`,"aria-label":`按编号或标题搜索任务`}),B&&(0,y.jsx)(`button`,{type:`button`,className:`mdw-prog-qclear`,"aria-label":`清空搜索`,title:`清空搜索`,onClick:()=>V(``),children:(0,y.jsx)(a,{name:`x`,size:11,title:void 0})})]}),S&&H.length>1&&(0,y.jsxs)(`div`,{className:`mdw-prog-filters`,role:`tablist`,"aria-label":`按项目筛选进程卡`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`mdw-prog-fchip`+(!R||!H.includes(R)?` on`:``),onClick:()=>z(``),children:[`全部 `,(0,y.jsx)(`b`,{children:I.length})]}),H.map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`mdw-prog-fchip`+(R===e?` on`:``),onClick:()=>z(R===e?``:e),children:[e,` `,(0,y.jsx)(`b`,{children:I.filter(t=>t.projectName===e).length})]},e))]}),(0,y.jsxs)(`div`,{className:`mdw-prog-sum`,children:[(0,y.jsxs)(`div`,{className:`counts`,children:[(0,y.jsxs)(`span`,{className:`run`,children:[`进行中 `,(0,y.jsx)(`b`,{children:G})]}),(0,y.jsxs)(`span`,{className:`wait`,children:[`等待 `,(0,y.jsx)(`b`,{children:K})]}),(0,y.jsxs)(`span`,{className:`done`,children:[`已完成 `,(0,y.jsx)(`b`,{children:q})]})]}),(0,y.jsx)(`div`,{className:`bar`,title:`已完成 ${q} / 共 ${U.length}`,children:(0,y.jsx)(`i`,{style:{width:`${J}%`}})})]}),M.size>0&&(0,y.jsxs)(`div`,{className:`mdw-prog-sel`,children:[(0,y.jsxs)(`span`,{className:`n`,children:[`已选 `,(0,y.jsx)(`b`,{children:M.size}),` / `,U.length]}),(0,y.jsx)(`button`,{type:`button`,className:`mdw-prog-clear`,onClick:()=>N(new Set),children:`清除`}),(0,y.jsxs)(`button`,{type:`button`,className:`mdw-prog-del`,onClick:ae,disabled:P,children:[(0,y.jsx)(a,{name:`trash`,size:12,title:void 0}),`删除所选`]})]}),(0,y.jsxs)(`div`,{className:`mdw-prog-list`,children:[!U.length&&(0,y.jsxs)(`div`,{className:`mdw-prog-empty`,children:[B.trim()?(0,y.jsxs)(y.Fragment,{children:[`没有匹配的卡片`,(0,y.jsx)(`br`,{}),`试试编号(如 127)或标题关键词`]}):S?(0,y.jsxs)(y.Fragment,{children:[`本组成员项目还没有任务`,(0,y.jsx)(`br`,{}),`任务会随成员队列自动聚到这里`]}):(0,y.jsxs)(y.Fragment,{children:[`此目录还没有 MD 任务`,(0,y.jsx)(`br`,{}),`写 MD 提交或导入`]}),$>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`br`,{}),`另有 `,$,` 条反馈链旧轮次已折叠(搜编号可点名召回)`]})]}),U.map(e=>{let t=W(e),n=M.has(t),r=Q!==``&&String(e.taskId??e.id)===Q;return(0,y.jsxs)(`div`,{className:`mdw-tcard-row${n?` on`:``}`,children:[(0,y.jsx)(`input`,{type:`checkbox`,className:`mdw-tcard-pick`,checked:n,onChange:()=>ie(t),"aria-label":`选择任务 #${e.taskId??e.id} ${e.title}`,title:`选择此任务(可多选后批量删除)`}),(0,y.jsx)(`button`,{type:`button`,className:`mdw-tcard ${e.status}${r?` focus`:``}`,onClick:()=>oe(e),children:(0,y.jsxs)(`div`,{className:`mdw-tcard-h`,children:[(0,y.jsx)(`span`,{className:`st ${e.status}`}),(0,y.jsxs)(`div`,{className:`titles`,children:[(0,y.jsxs)(`div`,{className:`n`,children:[e.title,S&&e.projectName&&(0,y.jsx)(`span`,{className:`rp-ptag mdw-tcard-proj`,title:`归属项目:${e.projectName}`,children:e.projectName}),e.folded&&(0,y.jsx)(`span`,{className:`rp-ptag mdw-tcard-old`,title:`反馈链上的旧轮次:默认折叠,在任务页「更多 → 任务链」里看全部历史`,children:`旧轮次`})]}),(0,y.jsx)(`div`,{className:`sub`,children:e.detail})]}),(0,y.jsxs)(`span`,{className:`mdw-tcard-num`,title:`任务编号 #${e.taskId??e.id}`,children:[`#`,e.taskId??e.id]}),(0,y.jsx)(`span`,{className:`el ${e.status}`,title:`从领取时刻起计;待领取与已完成回填不计时间`,children:x(e,A)})]})})]},t)})]}),(0,y.jsxs)(`div`,{className:`mdw-prog-note`,children:[S?`组内各项目的任务聚在这里;可按项目筛选,勾选后批量删除。`:`本目录的任务;点卡打开,勾选后批量删除。`,$>0&&(0,y.jsxs)(y.Fragment,{children:[` 反馈链只显示最新一轮,已折叠 `,$,` 条旧轮次(旧轮次在任务页「更多 → 任务链」里看)。`]})]})]})}export{S as default};
@@ -1 +0,0 @@
1
- import{g as e,h as t,m as n,u as r,y as i}from"./task-status-DSrx0i66.js";import{a}from"./workspace-4tw7trV7.js";import{i as o}from"./Introduction-aQCeCLrV.js";var s=i(e(),1),c=t();function l(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function u(e){let t=e.rel||e.path||``;return String(t).replace(/[\\/]+$/,``).split(/[\\/]/).pop()||t||`未命名`}function d(e){let t=[],n=e&&(e.main||e.introMain);n&&t.push({...n,docId:l(n),main:!0,label:e.repo?e.repo.name:`主篇`});for(let n of e&&(e.extras||e.introExtras)||[]){let e=l(n);e&&t.push({...n,docId:e,main:!1,label:u(n)})}for(let n of e&&(e.links||e.docLinks)||[]){let e=l(n);e&&t.push({...n,docId:e,main:!1,label:u(n)})}return t.filter(e=>e.docId)}function f({repoKey:e,boardKey:t,boardName:i,model:l}){let{openByDocId:u}=o(l),[f,p]=(0,s.useState)(null),[m,h]=(0,s.useState)(``),[g,_]=(0,s.useState)(0),v=(0,s.useCallback)(()=>_(e=>e+1),[]);(0,s.useEffect)(()=>{let r=!0;return h(``),(async()=>{try{let i=e?await n(`/api/repos/docs?id=`+encodeURIComponent(e)):await n(`/api/boards/`+encodeURIComponent(String(t)));r&&p(i)}catch(e){r&&(p(null),h(String(e.message||e)))}})(),()=>{r=!1}},[e,t,g]);let y=d(f),b=f?f.repo?f.repo.name:f.name||i||`项目组`:i||`文档列表`,x=e?{repoKey:e}:{boardKey:t,boardName:i};return(0,c.jsxs)(`div`,{className:`nx-refs`,children:[(0,c.jsxs)(`div`,{className:`nx-refs-h`,children:[(0,c.jsxs)(`span`,{className:`t`,title:b,children:[b,` · 文档列表`]}),(0,c.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`刷新`,"aria-label":`刷新文档列表`,onClick:v,children:(0,c.jsx)(r,{name:`refresh`,size:13,title:void 0})}),l&&(0,c.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭文档列表面板`,"aria-label":`关闭文档列表面板`,onClick:()=>a(l,`refs`),children:(0,c.jsx)(r,{name:`x`,size:14,title:void 0})})]}),(0,c.jsxs)(`div`,{className:`nx-refs-list`,children:[m?(0,c.jsx)(`div`,{className:`nx-refs-empty`,children:m}):null,!m&&!f?(0,c.jsx)(`div`,{className:`nx-refs-empty`,children:`读取中…`}):null,!m&&f&&!y.length?(0,c.jsxs)(`div`,{className:`nx-refs-empty`,children:[`还没有文档`,(0,c.jsx)(`br`,{}),e?`在目录页「查看详情」里点「+ 补充」开始写`:`在项目组页「查看详情」里点「+ 补充」开始写`]}):null,y.map(e=>(0,c.jsxs)(`button`,{type:`button`,className:`nx-refs-row`+(e.main?` main`:``),title:`${e.rel||e.path||``}${e.note?`\n${e.note}`:``}`,onClick:()=>u(e.docId,null,x),children:[(0,c.jsxs)(`span`,{className:`nx-refs-row-label`,children:[e.main?`● `:`○ `,e.label]}),e.tag?(0,c.jsx)(`span`,{className:`nx-refs-row-tag`,children:e.tag}):null,(0,c.jsx)(`span`,{className:`nx-refs-row-sub mono`,children:e.rel||e.path||``})]},e.docId))]}),(0,c.jsx)(`div`,{className:`nx-refs-note`,children:`点一行在工作区打开文档页签;完整管理与就地编辑走「查看详情」。`})]})}export{f as default};
@@ -1,15 +0,0 @@
1
- import{f as e,g as t,h as n,l as r,m as i,o as a,p as o,y as s}from"./task-status-DSrx0i66.js";import{n as c}from"./app-context-BASCGAA-.js";import{x as l}from"./index-D8MvtVAm.js";import{t as u}from"./route-crumb-CWVu80du.js";import{i as d,n as f}from"./Introduction-aQCeCLrV.js";import{t as p}from"./bar-B9WWmCpt.js";import{t as m}from"./member-picker-B5I7KuOR.js";import{a as h,n as g,o as _,s as v}from"./prompt-blocks-BovFd039.js";var y=s(t(),1),b=n(),x={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function S({onClose:t,onChanged:n,repos:r,boards:a}){let s=e(),c=o(),[l,u]=(0,y.useState)(`import`),[d,f]=(0,y.useState)({}),[p,m]=(0,y.useState)({}),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(``),[S,C]=(0,y.useState)(``),[w,T]=(0,y.useState)(null),[E,D]=(0,y.useState)({}),[O,k]=(0,y.useState)({}),[A,j]=(0,y.useState)(`ours`),[M,N]=(0,y.useState)(`none`),[P,F]=(0,y.useState)(``),[I,L]=(0,y.useState)(null),[R,z]=(0,y.useState)(!1),B=(0,y.useMemo)(()=>r||[],[r]),V=(0,y.useMemo)(()=>B.map(e=>e.key),[B]),H=(0,y.useMemo)(()=>(a||[]).map(e=>e.name),[a]),U=e=>{let t={};for(let n of V)t[n]=e;f(t)},W=e=>{let t={};for(let n of H)t[n]=e;m(t)},ee=()=>{let e={};for(let t of V)e[t]=!d[t];f(e)},te=()=>s(async()=>{let e=Object.keys(d).filter(e=>d[e]),t=Object.keys(p).filter(e=>p[e]),n={repos:e.length&&e.length!==V.length?e:void 0,boards:t.length&&t.length!==H.length?t.map(e=>`board/${e}`):void 0,noUnassigned:h},r=new URLSearchParams;n.repos?.length&&r.set(`repos`,n.repos.join(`,`)),n.boards?.length&&r.set(`boards`,n.boards.join(`,`)),h&&r.set(`no-unassigned`,`1`);let a=await i(`/api/repos/export`+(r.toString()?`?`+r:``));v(JSON.stringify(a,null,2)),c(`已生成布局:${a.repos.length} 个仓库 / ${a.boards.length} 个看板`)}),G=()=>{if(!_)return;let e=new Blob([_],{type:`application/json`}),t=document.createElement(`a`);t.href=URL.createObjectURL(e),t.download=`nx-kv-layout-${new Date().toISOString().slice(0,10)}.json`,t.click(),URL.revokeObjectURL(t.href)},K=async e=>{let t=e.target.files?.[0];t&&(C(await t.text()),T(null),L(null))},ne=()=>s(async()=>{if(S.trim()){z(!0);try{let e=await i(`/api/repos/import/diff`,{method:`POST`,body:{json:S}});T(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;D(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;k(n),L(null),c(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{z(!1)}}}),q=()=>s(async()=>{let e=Object.keys(E).filter(e=>E[e]),t=Object.keys(O).filter(e=>O[e]);z(!0);try{let r=await i(`/api/repos/import`,{method:`POST`,body:{json:S,strategy:A,clone:M,selection:e.length?e:void 0,boards:t.length?t:void 0}});L(r),c(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await J(),n&&await n()}finally{z(!1)}}),J=(0,y.useCallback)(async()=>{try{let e=await i(`/api/repos/import/diff`,{method:`POST`,body:{json:S}});T(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;D(t)}catch{}},[S]),re=(0,y.useMemo)(()=>w?P?w.repos.filter(e=>e.status===P):w.repos:[],[w,P]),ie=(e,t)=>s(async()=>{if(t){z(!0);try{await i(`/api/repos/clone`,{method:`POST`,body:{remote:t,key:e,type:`ref`,depth:1}}),c(`已克隆: ${e}`),await J(),n&&await n()}finally{z(!1)}}}),ae=e=>{let t={...E};for(let n of re)t[n.key]=e;D(t)};(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopImmediatePropagation(),t())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]);let oe=(0,y.useMemo)(()=>{let e={new:0,changed:0,same:0};if(!w)return e;for(let t of w.repos)e[t.status]=(e[t.status]||0)+1;return e},[w]);return(0,b.jsx)(`div`,{className:`rp-full`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,b.jsxs)(`div`,{className:`rp-full-box`,children:[(0,b.jsxs)(`div`,{className:`rp-full-head`,children:[(0,b.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,b.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,b.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,b.jsx)(`button`,{className:`rp-tab`+(l===`import`?` on`:``),onClick:()=>u(`import`),children:`导入`}),(0,b.jsx)(`button`,{className:`rp-tab`+(l===`export`?` on`:``),onClick:()=>u(`export`),children:`导出`})]}),(0,b.jsx)(`button`,{className:`btn small ghost`,onClick:t,children:`关闭`})]}),l===`export`?(0,b.jsxs)(`div`,{className:`rp-full-body`,children:[(0,b.jsxs)(`div`,{className:`rp-full-col`,children:[(0,b.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,b.jsx)(`span`,{children:`导出范围`}),(0,b.jsxs)(`span`,{className:`acts`,children:[(0,b.jsx)(`button`,{className:`btn small ghost`,onClick:()=>U(!0),children:`全选仓库`}),(0,b.jsx)(`button`,{className:`btn small ghost`,onClick:()=>U(!1),children:`全不选`}),(0,b.jsx)(`button`,{className:`btn small ghost`,onClick:ee,children:`反选`})]})]}),(0,b.jsxs)(`div`,{className:`rp-full-sel`,children:[B.map(e=>(0,b.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:!!d[e.key],onChange:t=>f(n=>({...n,[e.key]:t.target.checked}))}),(0,b.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,b.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),B.length?null:(0,b.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,b.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,b.jsx)(`span`,{children:`看板`}),(0,b.jsxs)(`span`,{className:`acts`,children:[(0,b.jsx)(`button`,{className:`btn small ghost`,onClick:()=>W(!0),children:`全选`}),(0,b.jsx)(`button`,{className:`btn small ghost`,onClick:()=>W(!1),children:`全不选`})]})]}),(0,b.jsxs)(`div`,{className:`rp-full-sel`,children:[(a||[]).map(e=>(0,b.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:!!p[e.name],onChange:t=>m(n=>({...n,[e.name]:t.target.checked}))}),(0,b.jsx)(`span`,{children:e.name})]},e.name)),a?.length?null:(0,b.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,b.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),(0,b.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,b.jsxs)(`div`,{className:`form-acts`,children:[(0,b.jsx)(`button`,{className:`btn`,onClick:te,children:`生成布局`}),(0,b.jsx)(`button`,{className:`btn ghost`,disabled:!_,onClick:G,children:`下载 JSON`})]})]}),(0,b.jsxs)(`div`,{className:`rp-full-col`,children:[(0,b.jsx)(`div`,{className:`rp-full-colhead`,children:(0,b.jsx)(`span`,{children:`导出结果`})}),(0,b.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:_,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,b.jsxs)(`div`,{className:`rp-full-body`,children:[(0,b.jsxs)(`div`,{className:`rp-full-col`,children:[(0,b.jsx)(`div`,{className:`rp-full-colhead`,children:(0,b.jsx)(`span`,{children:`导入来源`})}),(0,b.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:K}),(0,b.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:S,onChange:e=>{C(e.target.value),T(null)}}),(0,b.jsx)(`div`,{className:`form-hint`,children:`每个仓库的 key 必须有:文件里已写 key 就直接用;只写了远程地址就按 host/owner/repo 归一化; 两样都没有会在差异检查阶段直接报错(不会按名字猜 key)。要改 key 就改上面的 JSON 再检查。`}),(0,b.jsx)(`div`,{className:`form-acts`,children:(0,b.jsx)(`button`,{className:`btn`,disabled:!S.trim()||R,onClick:ne,children:`差异检查`})}),w?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,b.jsx)(`span`,{children:`冲突方案`})}),(0,b.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,b.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,b.jsx)(`input`,{type:`radio`,name:`strategy`,checked:A===e,onChange:()=>j(e)}),(0,b.jsx)(`span`,{children:t})]},e))}),(0,b.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,b.jsx)(`span`,{children:`克隆`})}),(0,b.jsxs)(`select`,{value:M,onChange:e=>N(e.target.value),children:[(0,b.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,b.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,b.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,b.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,b.jsx)(`div`,{className:`form-acts`,children:(0,b.jsxs)(`button`,{className:`btn`,disabled:R,onClick:q,children:[`执行导入(已选 `,Object.values(E).filter(Boolean).length,`)`]})})]}):null,I?(0,b.jsxs)(`div`,{className:`rp-import-result`,children:[(0,b.jsxs)(`div`,{children:[`新建 `,I.created.length,` · 覆盖 `,I.updated.length,` · 另存 `,I.duplicated.length,` · 跳过 `,I.skipped.length]}),(0,b.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,I.boardsCreated,` / 合并 `,I.boardsMerged,` · 参考关系 `,I.links]}),I.cloned.length?(0,b.jsxs)(`div`,{children:[`克隆 `,I.cloned.length,` 个`]}):null,I.unmatched.length?(0,b.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,I.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,b.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:w?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,b.jsxs)(`span`,{children:[`差异(新增 `,oe.new,` · 有差异 `,oe.changed,` · 一致 `,oe.same,w.summary.missing?` · 本地未拥有 ${w.summary.missing}`:``,`)`]}),(0,b.jsxs)(`span`,{className:`acts`,children:[(0,b.jsx)(`button`,{className:`rp-chip`+(P===``?` on`:``),onClick:()=>F(``),children:`全部`}),(0,b.jsx)(`button`,{className:`rp-chip`+(P===`new`?` on`:``),onClick:()=>F(`new`),children:`新增`}),(0,b.jsx)(`button`,{className:`rp-chip`+(P===`changed`?` on`:``),onClick:()=>F(`changed`),children:`有差异`}),(0,b.jsx)(`button`,{className:`rp-chip`+(P===`same`?` on`:``),onClick:()=>F(`same`),children:`一致`}),(0,b.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ae(!0),children:`全选`}),(0,b.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ae(!1),children:`全不选`})]})]}),(0,b.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,b.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{style:{width:`32px`}}),(0,b.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,b.jsx)(`th`,{children:`仓库 key`}),(0,b.jsx)(`th`,{children:`差异字段`})]})}),(0,b.jsxs)(`tbody`,{children:[re.map(e=>(0,b.jsxs)(`tr`,{className:`rp-diff-row `+(x[e.status]?.cls??``),children:[(0,b.jsx)(`td`,{children:(0,b.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!E[e.key],onChange:t=>D(n=>({...n,[e.key]:t.target.checked}))})}),(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`rp-status `+(x[e.status]?.cls??``),children:x[e.status]?.label})}),(0,b.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,b.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,b.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:R,onClick:()=>ie(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,b.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`b`,{children:e.field}),`: `,(0,b.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,b.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,b.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),w.missing.map(e=>(0,b.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,b.jsx)(`td`,{}),(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,b.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,b.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),w.boards.length?(0,b.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,b.jsx)(`div`,{className:`rp-full-colhead`,children:(0,b.jsx)(`span`,{children:`看板`})}),w.boards.map(e=>(0,b.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:!!O[e.key],onChange:t=>k(n=>({...n,[e.key]:t.target.checked}))}),(0,b.jsx)(`span`,{className:`rp-status `+(x[e.status]?.cls??``),children:x[e.status]?.label}),(0,b.jsx)(`span`,{children:e.key}),(0,b.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers?.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),w.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,b.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,b.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,b.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,b.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,b.jsx)(`button`,{className:`btn small`,disabled:R,onClick:()=>ie(e.key,e.remote),children:`克隆到本地`}):(0,b.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,b.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}function C(e){let t=String(e??``);return t.trim()?t.replace(/\{\{#[^}]*\}\}/g,``).replace(/\{\{\/[^}]*\}\}/g,``).replace(/\{\{[^}]*\}\}/g,``).replace(/「\s*」/g,``).replace(/〔\s*〕/g,``).replace(/\s+/g,` `).trim()||t.replace(/\s+/g,` `).trim():``}function w({value:e,onChange:t,placeholder:n,rows:r=3,hint:i=``}){return(0,b.jsxs)(`div`,{className:`pp-field`,children:[(0,b.jsx)(`textarea`,{className:`pp-field-ta mono`,rows:r,value:e,placeholder:n,spellCheck:!1,onChange:e=>t(e.target.value)}),i?(0,b.jsx)(`div`,{className:`pp-field-hint`,children:i}):null]})}function T({items:e,onChange:t,disabled:n=!1,placeholder:r,rows:i=3,accordion:a=!1,openIndex:o,onOpenChange:s}){let[c,l]=(0,y.useState)(-1),u=o===void 0?c:o,d=e=>{l(e),s&&typeof e==`number`&&s(e)},f=(n,r)=>t(e.map((e,t)=>t===n?r:e)),p=n=>{t(e.filter((e,t)=>t!==n)),d(e=>e===n?-1:e>n?e-1:e)};return a?(0,b.jsx)(`div`,{className:`pp-items`,children:e.map((e,t)=>{let a=u===t,o=C(e.split(`
2
- `)[0]);return(0,b.jsx)(`div`,{className:`pp-items-item`,children:a?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,b.jsx)(`div`,{className:`pp-items-body`,children:(0,b.jsx)(w,{value:e,onChange:e=>f(t,e),placeholder:r,rows:i})}),(0,b.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>p(t),title:`删除第 ${t+1} 条`,children:`删除`})]}):(0,b.jsxs)(`button`,{type:`button`,className:`pp-items-row`,disabled:n,title:`点击展开编辑`,onClick:()=>d(t),children:[(0,b.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,b.jsx)(`span`,{className:`pp-items-title`,children:o||`(空)`}),(0,b.jsxs)(`span`,{className:`pp-items-len`,children:[String(e).length,` 字`]})]})},t)})}):(0,b.jsx)(b.Fragment,{children:e.map((e,t)=>(0,b.jsxs)(`div`,{className:`pp-items-item`,children:[(0,b.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,b.jsx)(`div`,{className:`pp-items-body`,children:(0,b.jsx)(w,{value:e,onChange:e=>f(t,e),placeholder:r,rows:i})}),(0,b.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>p(t),title:`删除第 ${t+1} 条`,children:`删除`})]},t))})}var E=10,D=2e3,O=h.replaceAll(`{{task.id}}`,`%s`);function k({repo:e,onClose:t,onSaved:n}){let r=c(),s=o(),l=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[u,d]=(0,y.useState)(!!(l&&l.enabled)),[f,p]=(0,y.useState)(String(l&&l.waitMinutes||10)),[m,h]=(0,y.useState)(()=>{let e=l&&l.template;return(Array.isArray(e)?e:e==null?[]:[e]).map(e=>String(e??``).trim()).filter(Boolean).map(e=>e.replaceAll(`{{task.id}}`,`%s`))}),[x,S]=(0,y.useState)(-1),[C,w]=(0,y.useState)(``),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)(null),[N,P]=(0,y.useState)(!1),F=async()=>{P(!0);try{let e=await i(`/api/localtasks`),t=_(e&&e.settings&&e.settings.blockTemplates),n=g.map(e=>{let n=(t[e.id]?.list||[]).map(e=>({id:e.id,name:e.name,template:e.template,builtin:!!e.builtin}));return{id:e.id,label:e.label,items:n}}).filter(e=>e.items.length);M({blocks:n})}catch(e){s(String(e.message||e))}finally{P(!1)}},I=e=>{let t=String(e.template||``).replaceAll(`{{task.id}}`,`%s`);w(t.slice(0,D)),M(null)},L=async t=>{A(!0);try{let a=t&&t.enabled!==void 0?t.enabled:u,o=m.map(e=>String(e??``).trim().replaceAll(`%s`,`{{task.id}}`)).filter(Boolean).slice(0,E);await i(`/api/repos/`+encodeURIComponent(e.id),{method:`PATCH`,body:{getLoop:{enabled:a,...a?{waitMinutes:Number(f)||10,template:o}:{}}}}),s(a?`已保存「${e.name}」的持续 get 设置(模板 ${o.length} 条)`:`已关闭「${e.name}」的持续 get`),r.refreshRepos&&r.refreshRepos(),n&&n()}catch(e){s(String(e.message||e))}finally{A(!1)}},R=async e=>{d(e),await L({enabled:e})},z=()=>{let e=C.trim();!e||m.length>=E||(h([...m,e.slice(0,D)]),S(m.length),w(``))};return(0,b.jsx)(a,{title:`持续 get · ${e.name}`,onClose:t,size:`md`,children:(0,b.jsxs)(`div`,{className:`rp-gl`,children:[(0,b.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,b.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,b.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,b.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,b.jsxs)(`button`,{className:`toggle`+(u?` on`:``),onClick:()=>R(!u),disabled:k,children:[(0,b.jsx)(`span`,{className:`dot`}),u?`开`:`关`]})]}),u&&(0,b.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,b.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,b.jsx)(`span`,{children:`阻塞窗口`}),(0,b.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,b.jsx)(`input`,{className:`rp-gl-min`,value:f,onChange:e=>p(e.target.value),inputMode:`numeric`}),`分钟`]})]}),(0,b.jsxs)(`div`,{className:`rp-gl-tpl`,children:[(0,b.jsx)(`div`,{className:`rp-gl-h`,children:`收尾模板`}),(0,b.jsxs)(`div`,{className:`rp-gl-oneline`,children:[(0,b.jsx)(v,{variant:`secondary`,title:`填入内置默认(继续 get 直到 timeout)`,onClick:()=>w(O),children:`填入内置默认`}),(0,b.jsx)(v,{variant:`secondary`,title:`从设置 → 提示词模板里挑一条复用(免得同一段话两处各写一遍)`,onClick:F,disabled:k||N,children:N?`读取中…`:`从设置中的提示词模板选…`}),(0,b.jsx)(`input`,{className:`rp-gl-oneline-input`,value:C,placeholder:`一句话(%s = 任务编号)`,onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`Enter`&&z()}}),(0,b.jsx)(v,{variant:`secondary`,disabled:k||!C.trim(),onClick:z,children:`添加`})]}),j&&(0,b.jsxs)(`div`,{className:`rp-gl-lib`,children:[(0,b.jsx)(`div`,{className:`rp-gl-h`,children:`设置里的提示词模板(点击填入输入行,可再改后添加)`}),j.blocks.map(e=>(0,b.jsxs)(`div`,{className:`rp-gl-lib-block`,children:[(0,b.jsx)(`span`,{className:`rp-gl-lib-label`,children:e.label}),e.id===`getloop`?(0,b.jsx)(`span`,{className:`rp-gl-note`,children:`持续 get 区块是**外壳**(决定这段话出现在交付的哪个位置), 在设置 → 提示词模板 → 持续 get 里编辑;这里配置的是它的内文。`}):e.items.map(e=>(0,b.jsxs)(`button`,{className:`rp-gl-lib-item`,title:e.template,onClick:()=>I(e),children:[e.name,e.builtin?`(内置)`:``]},e.id))]},e.id)),(0,b.jsx)(v,{variant:`secondary`,onClick:()=>M(null),children:`收起`})]}),m.length?(0,b.jsx)(T,{items:m,onChange:h,disabled:k,placeholder:`一句话(%s = 任务编号)`,accordion:!0,openIndex:x,onOpenChange:S}):(0,b.jsx)(`div`,{className:`rp-gl-note`,children:`未配置模板 —— 用默认「完成后续调 localtask get;没活时每轮最多阻塞 {{getloop.waitMinutes}} 分钟,直到 timeout」。`})]}),(0,b.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,b.jsx)(v,{variant:`secondary`,disabled:k||m.length>=E,title:m.length>=E?`最多 ${E} 条`:`新增一条「继续 get」指令`,onClick:()=>{h([...m,``]),S(m.length)},children:`添加一条…`}),(0,b.jsx)(`span`,{className:`spacer`}),(0,b.jsx)(v,{variant:`primary`,disabled:k,onClick:()=>L(),children:`保存持续 get 设置`})]})]})]})})}function A({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,b.jsx)(l,{text:t,title:void 0,children:t}):(0,b.jsxs)(l,{text:t,title:`点击复制完整路径`,children:[(0,b.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function j({docs:e,onOpen:t}){let n=e&&e.main,r=e&&e.links||[],i=+!!n+r.length,a=n&&n.exists?[n.title,n.summary&&`摘要:${n.summary}`].filter(Boolean).join(`
3
- `):`查看完整文档列表(主篇 / 补充 / reference / 组内),可就地编辑`;return(0,b.jsxs)(`button`,{type:`button`,className:`rp-docs-entry`,title:a,onClick:t,children:[(0,b.jsx)(`span`,{className:`rp-docs-entry-main`+(n&&n.exists?``:` ghost`),children:n&&n.exists?n.title||n.summary||`未命名`:`+ 写项目介绍`}),(0,b.jsx)(`span`,{className:`rp-docs-entry-n`,children:i>0?`${i} 篇 · 查看详情`:`查看详情`})]})}function M({chips:e,boardId:t,acts:n}){let[r,i]=(0,y.useState)(!1),a=r?e:e.slice(0,4);return(0,b.jsxs)(b.Fragment,{children:[a.map(e=>(0,b.jsx)(`span`,{className:`rp-link-chip rp-link-chip-`+(e.source===`group`?`group`:`repo`),children:(0,b.jsxs)(`button`,{className:`rp-link-chip-main`,title:e.source===`group`?[`组「${e.groupName}」共享的参考仓库`,e.note].filter(Boolean).join(`
4
- `):[`本仓库直接绑定的参考仓库`,e.note,`点击跳到这个参考仓库`].filter(Boolean).join(`
5
- `),onClick:()=>e.source===`group`?n.keepFilter(t):n.gotoRefRepo(e.key),children:[(0,b.jsx)(`b`,{children:e.source===`group`?`组`:`自`}),(0,b.jsx)(`span`,{className:`rp-link-chip-name`,children:e.name})]})},e.source+`:`+e.key)),e.length>4?(0,b.jsx)(`button`,{className:`rp-bind-more`,title:`展开本行全部参考仓库`,onClick:()=>i(e=>!e),children:r?`收起`:`+${e.length-4}`}):null]})}function N({r:e,filterBoard:t,groupRefRepoCounts:n,refRepoChipsByRepo:r,acts:i}){let a=n.get(e.key)||[],o=t?r.get(e.key)||[]:null,s=t?t.id:null;return(0,b.jsxs)(`tr`,{id:`rp-row-`+e.key,children:[(0,b.jsxs)(`td`,{className:`rp-name`,children:[(0,b.jsxs)(`strong`,{children:[e.icon?(0,b.jsx)(`span`,{className:`rp-icon`,"aria-hidden":!0,children:e.icon}):null,e.name,e.getLoop&&e.getLoop.enabled?(0,b.jsx)(`span`,{className:`rp-gl-dot`,title:`持续 get 已开启(${Number(e.getLoop.waitMinutes)||10} 分钟阻塞窗口)`,"aria-label":`持续 get 已开启`}):null]}),(0,b.jsx)(`span`,{className:`mono rp-name-path`,children:(0,b.jsx)(A,{path:e.path})})]}),(0,b.jsx)(`td`,{className:`rp-cell-docs`,children:(0,b.jsx)(j,{docs:e.descDocs,onOpen:()=>i.docs(e)})}),(0,b.jsxs)(`td`,{className:`rp-refs`,children:[t?o&&o.length?(0,b.jsx)(M,{chips:o,boardId:t.id,acts:i}):(0,b.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`}):a.length?a.map(e=>(0,b.jsxs)(`button`,{className:`rp-group-chip`+(s===e.id?` on`:``),title:`组「${e.name}」绑定 ${e.count} 个参考仓库(组内共享)\n点击只看这个组`,onClick:()=>i.filter(e.id),children:[e.name,` `,(0,b.jsx)(`b`,{children:e.count})]},e.id)):(0,b.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`}),(0,b.jsx)(v,{small:!0,className:`rp-ref-bind`,title:`管理这个仓库所属组的参考仓库`,onClick:()=>i.bind(e),children:`绑定`})]}),(0,b.jsx)(`td`,{className:`rp-cell-groups`,children:(e.boards||[]).length?(e.boards||[]).map(e=>(0,b.jsx)(`button`,{className:`rp-group-chip`+(t?.id===e.id?` on`:``),title:`只看「${e.name}」${e.note?`\n组内描述:${e.note}`:``}`,onClick:()=>i.filter(e.id),children:e.name},e.id)):(0,b.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`})}),(0,b.jsx)(`td`,{className:`rp-acts`,children:(0,b.jsx)(p,{kind:`repos-row`,renderers:{edit:()=>(0,b.jsx)(v,{small:!0,onClick:()=>i.edit(e),children:`编辑`}),open:()=>(0,b.jsx)(v,{small:!0,title:`在文件管理器中打开`,onClick:()=>i.open(e),children:`打开`}),del:()=>(0,b.jsx)(v,{small:!0,danger:!0,onClick:()=>i.del(e),children:`删除`}),getloop:()=>(0,b.jsx)(v,{small:!0,title:`持续 get(waitgoal)配置`,onClick:()=>i.getloop(e),children:(0,b.jsxs)(`span`,{className:`rp-gl-menu-it`,children:[e.getLoop&&e.getLoop.enabled?(0,b.jsx)(`span`,{className:`rp-gl-dot`,"aria-hidden":!0}):null,`持续 get…`]})}),remote:()=>(0,b.jsx)(v,{small:!0,onClick:()=>i.remote(e),children:`对齐 remote`})},actions:{edit:()=>i.edit(e),open:()=>i.open(e),del:()=>i.del(e),getloop:()=>i.getloop(e),remote:()=>i.remote(e)},titles:{getloop:`持续 get(waitgoal)配置`,remote:`key 与远程 git 地址对齐`,del:`删除仓库登记(磁盘文件不受影响)`}})})]})}function P({shown:e,devRepos:t,filterBoard:n,groupRefRepoCounts:r,refRepoChipsByRepo:i,acts:a,onAddMember:o}){return(0,b.jsx)(`div`,{className:`rp-table-wrap`,id:`rp-repos`,children:(0,b.jsxs)(`table`,{className:`rp-table`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{scope:`col`,style:{width:`16%`},children:`仓库`}),(0,b.jsxs)(`th`,{scope:`col`,style:{width:`36%`},children:[`文档`,(0,b.jsx)(`span`,{className:`rp-th-hint`,children:`主篇标题 · 查看详情打开完整文档列表`})]}),(0,b.jsx)(`th`,{scope:`col`,style:{width:`18%`},children:`参考仓库`}),(0,b.jsx)(`th`,{scope:`col`,style:{width:`14%`},children:`分组`}),(0,b.jsx)(`th`,{scope:`col`,style:{width:`250px`},children:`操作`})]})}),(0,b.jsxs)(`tbody`,{children:[e.map(e=>(0,b.jsx)(N,{r:e,filterBoard:n,groupRefRepoCounts:r,refRepoChipsByRepo:i,acts:a},e.id)),e.length?null:(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:5,className:`muted rp-empty`,children:t.length?(0,b.jsxs)(b.Fragment,{children:[`这个分组还没有成员`,` `,n?(0,b.jsx)(v,{small:!0,onClick:()=>o(n.id),children:`添加成员`}):null]}):`还没有登记开发仓库 —— 点右上「登记仓库」加一条。`})})]})]})})}function F({boards:e,filter:t,onFilter:n,devCount:r,shownCount:i,q:a,onQ:o,onOpenDocs:s}){return(0,b.jsxs)(`div`,{className:`rp-filters`,"data-testid":`rp-filters`,children:[(0,b.jsxs)(`div`,{className:`rp-filters-main`,children:[(0,b.jsxs)(`button`,{className:`rp-chip`+(t?``:` on`),onClick:()=>n(``),title:`显示全部开发仓库`,children:[`全部 `,(0,b.jsx)(`b`,{children:r})]}),e.map(e=>(0,b.jsxs)(`button`,{className:`rp-chip`+(t===e.id?` on`:``),onClick:()=>n(t===e.id?``:e.id),title:`只看「${e.name}」里的仓库(${(e.repos||[]).length} 个)`,children:[e.name,` `,(0,b.jsx)(`b`,{children:(e.repos||[]).length})]},e.id))]}),(0,b.jsxs)(`div`,{className:`rp-filters-side`,children:[(0,b.jsx)(`input`,{className:`rp-search`,type:`search`,value:a,onChange:e=>o(e.target.value),placeholder:`搜仓库 / 路径 / 分组 / 文档…`,"aria-label":`检索仓库与文档`}),a?(0,b.jsx)(v,{small:!0,onClick:()=>o(``),children:`清空`}):null,(0,b.jsxs)(`span`,{className:`muted rp-search-count`,children:[i,` / `,r]}),(0,b.jsx)(v,{small:!0,title:`按仓库 / 组内 / 分组三档检索文档`,onClick:s,children:`文档检索`})]})]})}function I({filterBoard:e,refRepos:t,checkOf:n,onOpenDoc:r,onAddMember:i,onSync:a,onOpen:o,onLinkNote:s,onUnbind:c}){let u=(0,y.useMemo)(()=>{if(!e)return[];let n=new Map(t.map(e=>[e.key,e]));return(e.refs||[]).map(e=>{let t=n.get(e.id);return t?{...t,boardNote:e.note||``}:null}).filter(e=>e!==null)},[t,e]),[d,f]=(0,y.useState)(null);(0,y.useEffect)(()=>{f(null)},[e?e.id:null]);let p=d===null?u.length<=8:d;return e?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`rp-context`,"data-testid":`rp-context`,children:[(0,b.jsx)(`span`,{className:`rp-context-name`,children:e.name}),e.desc?(0,b.jsx)(`span`,{className:`rp-context-desc`,title:e.desc,children:e.desc}):(0,b.jsx)(`span`,{className:`muted rp-context-desc`,children:`还没有领域描述 —— 点「组介绍文档」补一段:侧重什么、谁配合谁、关键路径与搜索关键词在哪。`}),(0,b.jsxs)(`span`,{className:`acts`,children:[(0,b.jsx)(v,{small:!0,title:`打开这个分组的组介绍文档`,onClick:()=>r(e),children:`组介绍文档 ✎`}),(0,b.jsx)(`a`,{className:`btn small ghost`,href:`#/group/`+encodeURIComponent(e.id),title:`组页里看这个组的成员与任务`,children:`组页 ↗`}),(0,b.jsx)(v,{small:!0,onClick:()=>i(e.id),children:`添加成员`})]})]}),(0,b.jsxs)(`div`,{className:`rp-ref-mounted`,"data-testid":`rp-board-refs`,children:[(0,b.jsxs)(`div`,{className:`rp-ref-mounted-head`,children:[(0,b.jsxs)(`span`,{className:`rp-ref-mounted-label`,children:[`「`,e.name,`」的参考仓库 `,(0,b.jsx)(`b`,{children:u.length})]}),(0,b.jsx)(`span`,{className:`muted`,children:`绑定在组上:组内所有仓库共享,不区分来源仓库`}),u.length?(0,b.jsx)(v,{small:!0,className:`rp-ref-mounted-toggle`,title:p?`收起这个组的参考仓库清单`:`展开这个组的参考仓库清单`,onClick:()=>f(!p),children:p?`收起`:`展开 ${u.length}`}):null]}),u.length?p?u.map(t=>{let r=n.get(t.id);return(0,b.jsxs)(`div`,{className:`rp-ref-mounted-item`,children:[(0,b.jsx)(`span`,{className:`rp-ref-dot`+(r?r.ok?` ok`:` bad`:``),title:r?r.ok?`检查通过`:(r.issues||[]).join(`
6
- `):`尚未检查`}),(0,b.jsx)(l,{text:t.remote||t.name,title:`点击复制远程地址`,className:`rp-ref-mounted-name`,children:t.name}),t.desc?(0,b.jsx)(`span`,{className:`muted rp-ref-mounted-desc`,title:t.desc,children:t.desc}):null,t.boardNote?(0,b.jsx)(`button`,{className:`rp-ref-note-chip`,title:`${t.boardNote}\n点击编辑这条组级描述`,onClick:()=>s(t,e.id,e.name,t.boardNote),children:t.boardNote.split(`
7
- `)[0]}):(0,b.jsx)(v,{small:!0,title:`写「${t.name}」在这个组里参考什么(组级描述)`,onClick:()=>s(t,e.id,e.name,``),children:`写描述`}),(0,b.jsxs)(`span`,{className:`acts`,children:[(0,b.jsx)(v,{small:!0,onClick:()=>a(t),children:`同步`}),(0,b.jsx)(v,{small:!0,onClick:()=>o(t),children:`打开`}),(0,b.jsx)(v,{small:!0,danger:!0,title:`只从本组摘除(不影响其它组)`,onClick:()=>c(t,e.id),children:`移出本组`})]})]},t.id)}):null:(0,b.jsx)(`div`,{className:`muted rp-refs-none`,children:`这个组还没有绑定的参考仓库 —— 在下方参考仓库面板里点「绑定」勾选本组。`})]})]}):null}function L({boards:t,devRepos:n,refRepos:a,reload:s}){let c=e(),l=o(),{dialog:u,node:d}=r(),f=(0,y.useMemo)(()=>{let e=new Map;for(let t of[...n,...a]){let n=String(t.path||``).split(/[\\/]/).filter(Boolean).pop()||``;for(let r of[t.name,n]){let n=String(r||``).toLowerCase();n&&!e.has(n)&&e.set(n,t)}}let r=[];for(let n of t&&t.boards||[])for(let t of n.repos||[]){if(t.present!==!1)continue;let i=String(t.key||``).split(`/`).filter(Boolean).pop()||``,a=e.get(String(t.name||``).toLowerCase())||e.get(i.toLowerCase())||null;r.push({...t,board:n.name,boardId:n.id,match:a})}return r},[t,n,a]),p=e=>c(async()=>{await i(`/api/repos/clone`,{method:`POST`,body:{remote:e.remote,key:e.key,name:e.name||void 0,type:`dev`}}),l(`已克隆并登记:${e.name||e.key}`),s.repos(),s.boards()}),m=(e,t)=>c(async()=>{await i(`/api/boards/rekey`,{method:`POST`,body:{from:e.key,to:t}}),l(`已把「${e.name||e.key}」这个位置接到本机仓库`),s.repos(),s.boards()}),h=e=>c(async()=>{let t=await u({title:`把「${e.name||e.key}」接到哪个本机仓库?`,input:!0,placeholder:`本机仓库:id / key / 名称 / 绝对路径`});t&&(await i(`/api/boards/rekey`,{method:`POST`,body:{from:e.key,to:t}}),l(`已重绑——这个位置现在指向本机仓库`),s.repos(),s.boards())}),g=e=>c(async()=>{confirm(`把「${e.name||e.key}」从组「${e.board}」里移除?\n\n只摘这个组里的位置:本机仓库与看板本身都不动。`)&&(await i(`/api/boards/assign`,{method:`POST`,body:{key:e.key,board:e.boardId,remove:!0}}),l(`已从组「${e.board}」移除`),s.boards())});return f.length?(0,b.jsxs)(`section`,{className:`rp-pending`,"data-testid":`rp-pending-init`,children:[(0,b.jsxs)(`header`,{className:`rp-pending-head`,children:[(0,b.jsxs)(`div`,{className:`rp-pending-head-main`,children:[(0,b.jsxs)(`h3`,{children:[`待初始化`,(0,b.jsx)(`span`,{className:`rp-pending-count`,children:f.length})]}),(0,b.jsx)(`p`,{children:`组里有位置、本机没有登记。接到本机仓库、克隆下来,或者直接移除。`})]}),(0,b.jsx)(v,{small:!0,onClick:()=>c(async()=>{let e=await i(`/api/boards/prune`,{method:`POST`,body:{apply:!1}});if(!e?.total){l(`没有可清理的占位(有远程地址的那些留着等 clone)`);return}let t=e.items.map(e=>`· ${e.name}(组 ${e.board})`).join(`
8
- `);confirm(`清理 ${e.total} 个无来源占位?\n\n${t}\n\n它们没有远程地址,克隆不回来,只能删。`)&&(await i(`/api/boards/prune`,{method:`POST`,body:{apply:!0}}),l(`已清理 ${e.total} 个占位`),s.boards())}),children:`清理无来源占位`})]}),(0,b.jsx)(`div`,{className:`rp-pending-list`,children:f.map(e=>(0,b.jsxs)(`article`,{className:`rp-pending-card`,children:[(0,b.jsxs)(`div`,{className:`rp-pending-info`,children:[(0,b.jsxs)(`div`,{className:`rp-pending-title`,children:[(0,b.jsx)(`strong`,{children:e.name||e.key}),(0,b.jsxs)(`span`,{className:`rp-pending-board`,children:[`组 · `,e.board]}),e.remote?null:(0,b.jsx)(`span`,{className:`rp-pending-tag`,children:`无远程地址`})]}),(0,b.jsx)(`code`,{className:`rp-pending-key`,children:e.key}),e.desc?(0,b.jsx)(`p`,{className:`rp-pending-desc`,children:e.desc}):null]}),(0,b.jsxs)(`div`,{className:`rp-pending-acts`,children:[e.match?(0,b.jsxs)(v,{small:!0,title:`把组里这个位置指向本机仓库「${e.match.name}」(仓库身份不变)`,onClick:()=>e.match&&m(e,e.match.id),children:[`绑定到「`,e.match.name,`」`]}):null,e.remote?(0,b.jsx)(v,{small:!0,onClick:()=>p(e),children:`克隆到本地`}):null,(0,b.jsx)(v,{small:!0,onClick:()=>h(e),children:`选本机仓库`}),(0,b.jsx)(v,{small:!0,danger:!0,title:`只从组里摘掉这个位置,本机仓库与看板都不动`,onClick:()=>g(e),children:`移除`})]})]},e.key+`@`+e.boardId))}),d]}):null}function R({refRepos:t,devRepos:n,boardList:r,checkOf:s,refRepoBackLinks:c,refBindOpen:u,onRefBindOpen:d,onClose:f,onSyncOne:p,onUnbind:m,onUnbindRepo:h,onLinkNote:g,onGoBind:_,onDocs:x,onRowAct:S,reload:C}){let w=e(),T=o(),[E,D]=(0,y.useState)(null),[O,k]=(0,y.useState)(!1),[A,M]=(0,y.useState)({gitRepoRoot:``,gitDevRoot:``}),[N,P]=(0,y.useState)(!1),[F,I]=(0,y.useState)({url:``,name:``,desc:``,depth:`1`}),[L,R]=(0,y.useState)({}),[z,B]=(0,y.useState)(null),[V,H]=(0,y.useState)({}),U=(0,y.useCallback)(async()=>{D(await i(`/api/setting`).catch(()=>null))},[]);(0,y.useEffect)(()=>{U()},[U]);let W=()=>w(async()=>{let e={};A.gitRepoRoot.trim()&&(e.gitRepoRoot=A.gitRepoRoot.trim()),A.gitDevRoot.trim()&&(e.gitDevRoot=A.gitDevRoot.trim()),Object.keys(e).length&&(D(await i(`/api/setting`,{method:`POST`,body:e})),k(!1),T(`已保存存储根目录`))}),ee=()=>w(async()=>{let e=F.url.trim();if(!e)return;let t={url:e,name:F.name.trim()||void 0,desc:F.desc.trim()||void 0,depth:parseInt(F.depth,10)||1,"no-bind":!0},a=n.filter(e=>L[`repo:`+e.id]).map(e=>e.id),o=r.filter(e=>L[`board:`+e.id]).map(e=>e.id);a.length&&(t.bind=a),o.length&&(t.board=o);let s=await i(`/api/repos/ref/clone`,{method:`POST`,body:t});P(!1),I({url:``,name:``,desc:``,depth:`1`}),R({}),T(`已克隆: ${s.name} → ${s.dest||s.path}`),await C.all()}),te=()=>w(async()=>{let e=await i(`/api/repos/ref/sync`,{method:`POST`,body:{all:!0}}),t=e.results.filter(e=>e.status!==`updated`&&e.status!==`upToDate`);T(`同步 ${e.synced} 个${t.length?`,${t.length} 个有问题(见检查结果)`:`,全部完成`}`),await C.refCheck()}),G=e=>e.key||`board/${e.name}`,K=e=>{let t={};for(let n of r)(n.refs||[]).some(t=>t.id===e.key)&&(t[`board:`+G(n)]=!0);for(let r of n)(r.linked||[]).some(t=>t&&t.kind===`ref`&&String(t.id)===e.key)&&(t[`repo:`+r.key]=!0);H(t),B(e)};return(0,b.jsxs)(a,{size:`wide`,title:`参考仓库 · ${t.length}`,onClose:f,children:[(0,b.jsx)(`div`,{className:`rp-modal-bar`,children:(0,b.jsxs)(`span`,{className:`acts`,children:[(0,b.jsx)(v,{small:!0,onClick:()=>{R({}),P(!0)},children:`克隆参考仓库`}),(0,b.jsx)(v,{small:!0,onClick:te,children:`同步全部`}),(0,b.jsx)(v,{small:!0,onClick:C.refCheck,children:`检查`}),(0,b.jsx)(v,{small:!0,onClick:()=>{M({gitRepoRoot:E?.gitRepoRoot||``,gitDevRoot:E?.gitDevRoot||``}),k(!0)},children:`存储根`})]})}),E?.gitRepoRoot?null:(0,b.jsx)(`div`,{className:`rp-ref-warn`,children:`存储根未设置 —— 克隆会被拒绝。点「存储根」设一个非 C 盘目录(参考仓库体积不小,别放系统盘)。`}),(0,b.jsx)(`div`,{className:`rp-ref-table-wrap`,children:(0,b.jsxs)(`table`,{className:`rp-ref-table`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{scope:`col`,style:{width:`30px`}}),(0,b.jsx)(`th`,{scope:`col`,style:{width:`17%`},children:`参考仓库`}),(0,b.jsx)(`th`,{scope:`col`,style:{width:`22%`},children:`远程地址`}),(0,b.jsx)(`th`,{scope:`col`,children:`绑定对象(仓库组 / 单独仓库 · 点击跳转)`}),(0,b.jsx)(`th`,{scope:`col`,style:{width:`220px`},children:`操作`})]})}),(0,b.jsxs)(`tbody`,{children:[t.map(e=>{let t=s.get(e.id),n=r.map(t=>{let n=(t.refs||[]).find(t=>t.id===e.key);return n?{board:t,note:n.note||``}:null}).filter(e=>e!==null);return(0,b.jsxs)(`tr`,{id:`rp-refrepo-row-`+e.key,children:[(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`rp-ref-dot`+(t?t.ok?` ok`:` bad`:``),title:t?t.ok?`检查通过`:(t.issues||[]).join(`
9
- `):`尚未检查`})}),(0,b.jsxs)(`td`,{className:`rp-ref-cell-name`,children:[(0,b.jsx)(`strong`,{children:e.name}),(0,b.jsx)(j,{docs:e.descDocs,onOpen:()=>x(e)})]}),(0,b.jsx)(`td`,{className:`mono rp-ref-cell-remote`,children:(0,b.jsx)(l,{text:e.remote||``,title:`点击复制远程地址`,children:e.remote||`(无)`})}),(0,b.jsx)(`td`,{className:`rp-ref-cell-links`,children:(()=>{let t=n,r=c.get(e.key)||[];if(!t.length&&!r.length)return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{className:`muted rp-refs-none`,children:`未绑定`}),(0,b.jsx)(v,{small:!0,className:`rp-ref-bind`,onClick:()=>K(e),children:`绑定…`})]});let i=!!u[e.id],a=i?t:t.slice(0,4),o=i?r:r.slice(0,4),s=t.length>4||r.length>4;return(0,b.jsxs)(b.Fragment,{children:[t.length?(0,b.jsxs)(`div`,{className:`rp-bind-row`,children:[(0,b.jsx)(`span`,{className:`rp-bind-label`,children:`仓库组`}),a.map(t=>(0,b.jsxs)(`span`,{className:`rp-link-chip rp-link-chip-group`,children:[(0,b.jsxs)(`button`,{className:`rp-link-chip-main`,title:[t.note||`点击跳到这个组`,`组级绑定(组内共享)`].join(`
10
- `),onClick:()=>_(`board`,t.board.id),children:[(0,b.jsx)(`b`,{children:`组`}),(0,b.jsx)(`span`,{className:`rp-link-chip-name`,children:t.board.name})]}),(0,b.jsx)(`button`,{className:`rp-link-chip-note-btn`,title:t.note?`编辑组级描述:${t.note}`:`写这条组级描述(这个组里参考什么)`,onClick:()=>g(e,t.board.id,t.board.name,t.note),children:t.note?t.note.split(`
11
- `)[0]:`+`}),(0,b.jsx)(`button`,{className:`rp-link-chip-x`,title:`从本组摘除(不影响其它组、也不动仓库级绑定)`,onClick:()=>m(e,t.board.id),children:`×`})]},`board:`+t.board.id)),!i&&t.length>4?(0,b.jsxs)(`button`,{className:`rp-bind-more`,title:`展开本行全部绑定`,onClick:()=>d(t=>({...t,[e.id]:!0})),children:[`+`,t.length-4]}):null]}):null,r.length?(0,b.jsxs)(`div`,{className:`rp-bind-row`,children:[(0,b.jsx)(`span`,{className:`rp-bind-label`,children:`仓库`}),o.map(t=>(0,b.jsxs)(`span`,{className:`rp-link-chip rp-link-chip-repo`,children:[(0,b.jsxs)(`button`,{className:`rp-link-chip-main`,title:[t.note||`直接绑定到这个仓库(不经过组)`,`仓库 key: ${t.repo.key}`,`点击定位到仓库行`].join(`
12
- `),onClick:()=>_(`repo`,t.repo.key),children:[(0,b.jsx)(`b`,{children:`仓`}),(0,b.jsx)(`span`,{className:`rp-link-chip-name`,children:t.repo.name}),(0,b.jsx)(`span`,{className:`mono rp-link-chip-key`,children:t.repo.key})]}),t.note?(0,b.jsx)(`i`,{className:`rp-link-chip-note`,title:t.note,children:t.note.split(`
13
- `)[0]}):null,(0,b.jsx)(`button`,{className:`rp-link-chip-x`,title:`从这个仓库摘除(不影响组级绑定)`,onClick:()=>h(e,t.repo.key),children:`×`})]},`repo:`+t.repo.key)),!i&&r.length>4?(0,b.jsxs)(`button`,{className:`rp-bind-more`,title:`展开本行全部绑定`,onClick:()=>d(t=>({...t,[e.id]:!0})),children:[`+`,r.length-4]}):null]}):null,s?(0,b.jsx)(`button`,{className:`rp-bind-toggle`,onClick:()=>d(t=>({...t,[e.id]:!i})),children:i?`收起`:`展开全部 ${t.length+r.length}`}):null,(0,b.jsx)(v,{small:!0,className:`rp-ref-bind`,onClick:()=>K(e),children:`绑定…`})]})})()}),(0,b.jsxs)(`td`,{className:`rp-acts`,children:[(0,b.jsx)(v,{small:!0,onClick:()=>p(e),children:`同步`}),(0,b.jsx)(v,{small:!0,onClick:()=>S(`open`,e),children:`打开`}),(0,b.jsx)(v,{small:!0,onClick:()=>S(`edit`,e),children:`编辑`}),(0,b.jsx)(v,{small:!0,danger:!0,onClick:()=>S(`del`,e),children:`删除`})]})]},e.id)}),t.length?null:(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:5,className:`muted rp-empty`,children:`还没有参考仓库 —— 点「克隆参考仓库」抓一个远程仓库下来(或用 CLI: nx-kv repo ref clone <url>)。`})})]})]})}),N?(0,b.jsx)(a,{title:`克隆参考仓库`,onClose:()=>{P(!1),R({})},children:(0,b.jsxs)(`div`,{className:`form-grid`,children:[(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`ref-url`,children:`远程 git 地址 *`}),(0,b.jsx)(`input`,{id:`ref-url`,spellCheck:`false`,placeholder:`git@github.com:lib/x.git 或 https://github.com/lib/x`,value:F.url,onChange:e=>I(t=>({...t,url:e.target.value}))})]}),(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`ref-name`,children:`名称`}),(0,b.jsx)(`input`,{id:`ref-name`,placeholder:`留空则用 URL 末段`,value:F.name,onChange:e=>I(t=>({...t,name:e.target.value}))})]}),(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`ref-desc`,children:`它参考什么`}),(0,b.jsx)(`input`,{id:`ref-desc`,spellCheck:`false`,placeholder:`如:liquid glass 的官方实现参考`,value:F.desc,onChange:e=>I(t=>({...t,desc:e.target.value}))})]}),(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{children:`克隆后绑定到(可多选)`}),(0,b.jsxs)(`div`,{className:`rp-pick-list`,children:[(0,b.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,b.jsx)(`span`,{className:`rp-pick-group-label`,children:`开发仓库`}),n.map(e=>(0,b.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:!!L[`repo:`+e.id],onChange:t=>R(n=>({...n,[`repo:`+e.id]:t.target.checked}))}),(0,b.jsx)(`span`,{title:e.path,children:e.name})]},e.id)),n.length?null:(0,b.jsx)(`span`,{className:`muted`,children:`(还没有开发仓库)`})]}),(0,b.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,b.jsx)(`span`,{className:`rp-pick-group-label`,children:`看板(项目组)`}),r.map(e=>(0,b.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:!!L[`board:`+e.id],onChange:t=>R(n=>({...n,[`board:`+e.id]:t.target.checked}))}),(0,b.jsx)(`span`,{title:e.desc||``,children:e.name})]},e.id)),r.length?null:(0,b.jsx)(`span`,{className:`muted`,children:`(还没有看板)`})]})]}),(0,b.jsx)(`div`,{className:`form-hint`,children:`一个参考可同时服务多个仓库/组;之后随时在「绑定…」里增删。`})]}),(0,b.jsxs)(`div`,{className:`form-acts`,children:[(0,b.jsx)(v,{onClick:()=>{P(!1),R({})},children:`取消`}),(0,b.jsx)(v,{disabled:!F.url.trim()||!E?.gitRepoRoot,title:E?.gitRepoRoot?`克隆到 ${E.gitRepoRoot}`:`先在「存储根」设置 gitRepoRoot`,onClick:ee,children:`克隆`})]})]})}):null,z?(0,b.jsx)(a,{title:`绑定 · ${z.name}`,onClose:()=>B(null),children:(0,b.jsxs)(`div`,{className:`form-grid`,children:[(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`div`,{className:`form-hint`,children:`两类绑定并存、互不折算:勾「仓库组」= 组内共享(group_refs);勾「开发仓库」= 只绑这一个仓库(仓库级)。 取消勾选 = 摘除该维度(保存时对比差异)。`}),(0,b.jsxs)(`div`,{className:`rp-pick-list`,children:[(0,b.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,b.jsx)(`span`,{className:`rp-pick-group-label`,children:`仓库组`}),r.map(e=>{let t=G(e);return(0,b.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:!!V[`board:`+t],onChange:e=>H(n=>({...n,[`board:`+t]:e.target.checked}))}),(0,b.jsx)(`span`,{title:e.desc||``,children:e.name})]},e.id)}),r.length?null:(0,b.jsx)(`span`,{className:`muted`,children:`(还没有看板)`})]}),(0,b.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,b.jsx)(`span`,{className:`rp-pick-group-label`,children:`开发仓库(单独绑定)`}),n.map(e=>(0,b.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:!!V[`repo:`+e.key],onChange:t=>H(n=>({...n,[`repo:`+e.key]:t.target.checked}))}),(0,b.jsx)(`span`,{title:e.path,children:e.name}),(0,b.jsx)(`span`,{className:`muted mono rp-pick-desc`,children:e.key})]},e.id)),n.length?null:(0,b.jsx)(`span`,{className:`muted`,children:`(还没有开发仓库)`})]})]})]}),(0,b.jsxs)(`div`,{className:`form-acts`,children:[(0,b.jsx)(v,{onClick:()=>B(null),children:`取消`}),(0,b.jsx)(v,{onClick:()=>w(async()=>{if(!z)return;let e=e=>r.find(t=>G(t)===e.slice(6)),t=new Set([...r.filter(e=>(e.refs||[]).some(e=>e.id===z.key)).map(e=>`board:`+G(e)),...n.filter(e=>(e.linked||[]).some(e=>e&&e.kind===`ref`&&String(e.id)===z.key)).map(e=>`repo:`+e.key)]),a=new Set(Object.keys(V).filter(e=>V[e]));for(let n of a)if(!t.has(n)){if(n.startsWith(`board:`)){let t=e(n);if(!t)continue;await i(`/api/repos/bind`,{method:`POST`,body:{id:z.key,board:[t.id]}})}else await i(`/api/repos/bind`,{method:`POST`,body:{id:z.key,repo:[n.slice(5)]}})}for(let n of t)if(!a.has(n)){if(n.startsWith(`board:`)){let t=e(n);if(!t)continue;await i(`/api/repos/bind`,{method:`POST`,body:{id:z.key,board:[t.id],remove:!0}})}else await i(`/api/repos/bind`,{method:`POST`,body:{id:z.key,repo:[n.slice(5)],remove:!0}})}B(null),await Promise.all([C.repos(),C.boards(),C.refCheck()])}),children:`保存绑定`})]})]})}):null,O?(0,b.jsx)(a,{title:`参考仓库存储根`,onClose:()=>k(!1),children:(0,b.jsxs)(`div`,{className:`form-grid`,children:[(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`roots-ref`,children:`参考仓库存储根(gitRepoRoot)`}),(0,b.jsx)(`input`,{id:`roots-ref`,spellCheck:`false`,placeholder:`如 D:/gitrepo-ref(非 C 盘)`,value:A.gitRepoRoot,onChange:e=>M(t=>({...t,gitRepoRoot:e.target.value}))}),(0,b.jsx)(`div`,{className:`form-hint`,children:`repo ref clone 的落盘位置。不设 = 克隆被拒绝。`})]}),(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`roots-dev`,children:`开发仓库克隆根(gitDevRoot,可选)`}),(0,b.jsx)(`input`,{id:`roots-dev`,spellCheck:`false`,placeholder:`导入布局时开发仓库克隆到哪里`,value:A.gitDevRoot,onChange:e=>M(t=>({...t,gitDevRoot:e.target.value}))})]}),(0,b.jsxs)(`div`,{className:`form-acts`,children:[(0,b.jsx)(v,{onClick:()=>k(!1),children:`取消`}),(0,b.jsx)(v,{onClick:W,children:`保存`})]})]})}):null]})}function z({repos:t,boardList:n,onClose:s,onFilter:c,reload:l}){let u=e(),f=o(),{dialog:p,node:m}=r(),{openByDocId:h}=d(),[g,_]=(0,y.useState)([]),[x,S]=(0,y.useState)(`all`),[C,w]=(0,y.useState)(``),T=(0,y.useCallback)(async()=>{let e=await i(`/api/docs`).catch(()=>null);_(e&&e.docs||[])},[]);(0,y.useEffect)(()=>{T()},[T]);let E=(0,y.useMemo)(()=>{let e=new Map,r=(t,n,r,i,a)=>{if(!t)return;e.has(t)||e.set(t,[]);let o=e.get(t);o&&(o.some(e=>e.label===r)||o.push({key:t+`|`+r,kind:n,label:r,tip:i||r,target:a}))};for(let e of t){let t=e.descDocs&&e.descDocs.main;t&&t.rel&&r(t.rel,`repo`,`仓:${e.name}`,`「${e.name}」的项目介绍主篇`,e.key);for(let t of e.descDocs&&e.descDocs.links||[])r(String(t.docId||``).startsWith(`rel:`)?String(t.docId).slice(4):``,`repo`,`仓:${e.name}`,`「${e.name}」的补充文档${t.tag?`(${t.tag})`:``}`,e.key);for(let t of e.boards||[])r(t.noteDocRel,`scoped`,`组内:${t.name} / ${e.name}`,`「${e.name}」在组「${t.name}」里的组内描述`,t.id)}for(let e of n){e.docRel&&r(e.docRel,`board`,`组:${e.name}`,`组「${e.name}」的介绍文档`,e.id);for(let t of e.docLinks||[])r(t.rel,`board`,`组:${e.name}`,`组「${e.name}」的补充文档`,e.id);for(let t of e.repos||[])r(t.noteDocRel,`scoped`,`组内:${e.name} / ${t.name||t.key}`,`组「${e.name}」里的组内描述`,e.id)}return e},[t,n]),D=(0,y.useMemo)(()=>{let e=C.trim().toLowerCase(),t=g.map(e=>({d:e,hosts:E.get(e.rel||``)||[]})).filter(t=>!e||[t.d.title,t.d.name,t.d.rel].some(t=>t&&String(t).toLowerCase().includes(e))||t.hosts.some(t=>t.label.toLowerCase().includes(e)));return x===`orphan`?t.filter(e=>!e.hosts.length):x===`all`?t:t.filter(e=>e.hosts.some(e=>e.kind===x))},[g,E,x,C]),O=(0,y.useMemo)(()=>{let e={all:g.length,repo:0,board:0,scoped:0,orphan:0};for(let t of g){let n=E.get(t.rel||``)||[];n.length||(e.orphan+=1);for(let t of[`repo`,`board`,`scoped`])n.some(e=>e.kind===t)&&(e[t]+=1)}return e},[g,E]),k=(e,t=`start`)=>{if(!e)return;let n=e.parentElement;for(;n;){let e=getComputedStyle(n);if((e.overflowY===`auto`||e.overflowY===`scroll`)&&n.scrollHeight>n.clientHeight)break;n=n.parentElement}n||=document.scrollingElement||document.documentElement;let r=n.getBoundingClientRect?n.getBoundingClientRect().top:0,i=e.getBoundingClientRect().top-r,a=t===`center`?(n.clientHeight-e.offsetHeight)/2:12;n.scrollTop=Math.max(0,n.scrollTop+i-a)},A=e=>k(document.getElementById(e)),j=e=>{if(!e||!e.target)return;if(e.kind===`board`){c(e.target),A(`rp-repos`);return}c(``);let t=document.getElementById(`rp-row-`+e.target);if(!t){A(`rp-repos`);return}k(t,`center`),t.classList.add(`rp-row-flash`),setTimeout(()=>t.classList.remove(`rp-row-flash`),1400)},M=e=>{let t=new Set((g||[]).map(e=>String(e.rel||``).toLowerCase())),n=`${e}.md`;if(!t.has(n.toLowerCase()))return n;for(let r=2;;r+=1)if(n=`${e}-${r}.md`,!t.has(n.toLowerCase()))return n},N=()=>u(async()=>{let e=M(`note/untitled`);await i(`/api/docs/item`,{method:`POST`,body:{rel:e,body:``}}).catch(()=>{}),s(),h(`rel:`+e),await T()}),P=e=>u(async()=>{let t=E.get(e.rel||``)||[];await p({message:`删除文档「${e.title||e.rel}」?磁盘文件会被删除。`+(t.length?`它正被 ${t.length} 处引用(${t.map(e=>e.label).join(`、`)})。`:``),danger:!0})&&(await i(`/api/docs/item`,{method:`DELETE`,body:{ref:e.docId}}),f(`已删除:${e.rel}`),await Promise.all([T(),l.repos(),l.boards()]))});return(0,b.jsxs)(a,{size:`wide`,title:`文档检索 · ${g.length}`,onClose:s,children:[(0,b.jsxs)(`div`,{className:`rp-modal-bar rp-doc-bar`,children:[(0,b.jsx)(`input`,{className:`rp-search`,type:`search`,value:C,onChange:e=>w(e.target.value),placeholder:`搜标题 / 路径 / 组名 / 仓库名…`,"aria-label":`检索文档`}),C?(0,b.jsx)(v,{small:!0,onClick:()=>w(``),children:`清空`}):null,(0,b.jsx)(`span`,{className:`acts`,children:(0,b.jsx)(v,{small:!0,onClick:N,children:`新建文档`})})]}),g.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`rp-doc-scopes`,children:[[`all`,`全部`,O.all],[`repo`,`仓库文档`,O.repo],[`scoped`,`组内文档`,O.scoped],[`board`,`分组文档`,O.board],[`orphan`,`未绑定`,O.orphan]].map(([e,t,n])=>(0,b.jsxs)(`button`,{className:`rp-chip`+(x===e?` on`:``),onClick:()=>S(e),children:[t,` `,(0,b.jsx)(`b`,{children:n})]},e))}),(0,b.jsxs)(`div`,{className:`rp-doc-rows rp-doc-rows-modal`,children:[D.map(({d:e,hosts:t})=>(0,b.jsxs)(`div`,{className:`rp-doc-row`,children:[(0,b.jsx)(`button`,{type:`button`,className:`rp-doc-row-title`,title:`打开「${e.title||e.rel}」`,onClick:()=>h(e.docId),children:e.title||e.name||e.rel}),(0,b.jsx)(`code`,{className:`rp-doc-row-rel`,title:e.rel,children:e.rel}),(0,b.jsx)(`span`,{className:`rp-doc-row-hosts`,children:t.length?t.map(e=>(0,b.jsx)(`button`,{type:`button`,className:`rp-bind-chip `+e.kind,title:`${e.tip}\n点击跳到这个宿主`,onClick:()=>{j(e),s()},children:e.label},e.key)):(0,b.jsx)(`span`,{className:`rp-bind-chip none`,children:`未绑定`})}),(0,b.jsxs)(`span`,{className:`rp-doc-row-acts`,children:[(0,b.jsx)(v,{small:!0,onClick:()=>h(e.docId),children:`打开编辑`}),(0,b.jsx)(v,{small:!0,danger:!0,onClick:()=>P(e),children:`删除`})]})]},e.docId)),D.length?null:(0,b.jsx)(`div`,{className:`rp-board-empty muted`,children:`这一档没有匹配的文档。`})]})]}):(0,b.jsx)(`div`,{className:`rp-board-empty muted`,children:`还没有文档 —— 点「新建文档」给一个相对路径(如 note/inbox.md)就开写; 或在仓库行上点「+ 写项目介绍」。`}),m]})}function B({boardList:t,unassigned:n,onClose:s,onFilter:c,onMembers:l,onOpenDoc:u,reload:f}){let p=e(),m=o(),{dialog:h,node:g}=r(),{openByDocId:_}=d(),[x,S]=(0,y.useState)(null),[C,w]=(0,y.useState)(!1),[T,E]=(0,y.useState)(``),[D,O]=(0,y.useState)(null),k=()=>p(async()=>{if(!x)return;let e={name:x.name.trim()};e.name&&(x.id||(e.desc=x.desc.trim()||void 0),x.id?await i(`/api/boards/${encodeURIComponent(x.id)}`,{method:`PATCH`,body:e}):await i(`/api/boards`,{method:`POST`,body:e}),S(null),await f.boards())}),A=e=>p(async()=>{await h({message:`删看板「${e.name}」?它里面的 ${(e.repos||[]).length} 个仓库**仍留在中心清单里**(只是少了一份归属)。`,danger:!0})&&(await i(`/api/boards/${encodeURIComponent(e.id)}`,{method:`DELETE`,body:{}}),await Promise.all([f.repos(),f.boards()]))});return(0,b.jsxs)(a,{size:`wide`,title:`分组管理 · ${t.length}`,onClose:s,children:[(0,b.jsxs)(`div`,{className:`rp-modal-bar`,children:[(0,b.jsxs)(`span`,{className:`acts`,children:[(0,b.jsx)(v,{small:!0,onClick:()=>S({id:null,name:``,desc:``}),children:`新建分组`}),(0,b.jsx)(v,{small:!0,title:`粘贴/选择看板 JSON`,onClick:()=>w(!0),children:`导入`}),(0,b.jsx)(v,{small:!0,title:`导出全部看板为 JSON`,onClick:()=>p(async()=>{let e=await i(`/api/boards/export`);O(JSON.stringify(e,null,2))}),children:`导出`})]}),(0,b.jsx)(`span`,{className:`muted`,children:`一个分组 = 一个主题;同一个仓库可以同时在多个分组里。`})]}),t.length?(0,b.jsxs)(`div`,{className:`rp-board-admin`,children:[(0,b.jsxs)(`div`,{className:`rp-board-admin-head`,children:[(0,b.jsx)(`span`,{children:`分组`}),(0,b.jsx)(`span`,{children:`成员`}),(0,b.jsx)(`span`,{children:`组介绍`}),(0,b.jsx)(`span`,{children:`操作`})]}),t.map(e=>{let t=(e.repos||[]).filter(e=>e.present!==!1),n=(e.repos||[]).filter(e=>e.present===!1);return(0,b.jsxs)(`div`,{className:`rp-board-admin-row`,children:[(0,b.jsxs)(`span`,{className:`rp-board-admin-name`,children:[e.name,(0,b.jsx)(`button`,{className:`rp-mini-link`,title:`只看「${e.name}」里的仓库`,onClick:()=>{c(e.id),s()},children:`筛选`})]}),(0,b.jsxs)(`span`,{className:`rp-board-admin-members`,children:[t.slice(0,4).map(e=>(0,b.jsx)(`span`,{className:`rp-board-mchip`,title:e.note||e.key,children:e.name||e.key},e.key)),t.length>4?(0,b.jsxs)(`span`,{className:`rp-board-more`,children:[`+`,t.length-4]}):null,n.length?(0,b.jsxs)(`span`,{className:`rp-board-missing`,children:[n.length,` 待初始化`]}):null,(e.repos||[]).length?null:(0,b.jsx)(`span`,{className:`muted`,children:`—`})]}),(0,b.jsxs)(`span`,{className:`rp-board-admin-doc`,children:[(0,b.jsx)(v,{small:!0,title:`打开组介绍文档`,onClick:()=>u(e),children:`组介绍 ✎`}),e.docLinks&&e.docLinks.length?(0,b.jsxs)(`span`,{className:`muted`,children:[`+`,e.docLinks.length]}):null]}),(0,b.jsxs)(`span`,{className:`rp-board-admin-acts`,children:[(0,b.jsx)(`a`,{className:`btn small ghost`,href:`#/group/`+encodeURIComponent(e.id),title:`组页:成员与任务`,children:`组页 ↗`}),(0,b.jsx)(v,{small:!0,onClick:()=>l(e.id),children:`成员`}),(0,b.jsx)(v,{small:!0,onClick:()=>S({id:e.id,name:e.name,desc:e.desc||``}),children:`编辑`}),(0,b.jsx)(v,{small:!0,danger:!0,onClick:()=>A(e),children:`删除`})]})]},e.id)}),n?.length?(0,b.jsxs)(`div`,{className:`rp-boards-unassigned`,children:[`未分组 `,(0,b.jsx)(`b`,{children:n.length}),` 个 —— 不属于任何分组,只在「全部」里可见。`]}):null]}):(0,b.jsx)(`div`,{className:`rp-board-empty muted`,children:`还没有分组 —— 点「新建分组」建一个当主题用(如「前端」「AI 工具」),再把仓库点选进去。`}),x?(0,b.jsx)(a,{title:x.id?`编辑看板`:`新建看板`,onClose:()=>S(null),children:(0,b.jsxs)(`div`,{className:`form-grid`,children:[(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`bd-name`,children:`看板名称 *`}),(0,b.jsx)(`input`,{id:`bd-name`,placeholder:`如 前端 / AI 工具`,value:x.name,onChange:e=>S(t=>t&&{...t,name:e.target.value})})]}),x.id?(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{children:`领域描述(文档)`}),(0,b.jsx)(`div`,{className:`rp-docpick`,children:(0,b.jsx)(`button`,{type:`button`,className:`rp-doc`+(x.desc?``:` ghost`),title:`打开组介绍文档`,onClick:()=>{let e=t.find(e=>e.id===x?.id);S(null);let n=e&&(e.docRel||e.doc&&e.doc.rel);e&&n&&_(`rel:`+n)},children:x.desc||`未写`})})]}):(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`bd-desc`,children:`初始描述`}),(0,b.jsx)(`textarea`,{id:`bd-desc`,rows:3,spellCheck:`false`,placeholder:`新建时给的介绍正文(之后以 board/<组>.md 文档为准)。
14
- 如:这组仓库在这个环境里的侧重、配合关系、关键路径与搜索关键词。`,value:x.desc,onChange:e=>S(t=>t&&{...t,desc:e.target.value})})]}),(0,b.jsxs)(`div`,{className:`form-acts`,children:[(0,b.jsx)(v,{onClick:()=>S(null),children:`取消`}),(0,b.jsx)(v,{disabled:!x.name.trim(),onClick:k,children:x.id?`保存`:`新建看板`})]})]})}):null,C?(0,b.jsx)(a,{title:`导入看板 JSON`,size:`lg`,onClose:()=>{w(!1),E(``)},children:(0,b.jsxs)(`div`,{className:`form-grid`,children:[(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`bd-imp`,children:`看板 JSON`}),(0,b.jsxs)(`div`,{className:`form-hint`,children:[`结构 `,`{ boards:[{ name, repos:[{ path|name }] }] }`,` —— 按 path 或 name 匹配已登记仓库,匹配不上的会如实报告`]}),(0,b.jsx)(`input`,{id:`bd-imp-file`,type:`file`,accept:`.json,application/json`,onChange:async e=>{let t=e.target.files?.[0];t&&E(await t.text())}}),(0,b.jsx)(`textarea`,{id:`bd-imp`,rows:10,spellCheck:`false`,placeholder:`{"boards":[{"name":"前端","repos":[{"path":"D:/code/a_js/proj/nx-ft"}]}]}`,value:T,onChange:e=>E(e.target.value)})]}),(0,b.jsxs)(`div`,{className:`form-acts`,children:[(0,b.jsx)(v,{onClick:()=>{w(!1),E(``)},children:`取消`}),(0,b.jsx)(v,{disabled:!T.trim(),onClick:()=>p(async()=>{if(!T.trim())return;let e=await i(`/api/boards/import`,{method:`POST`,body:{json:T}});w(!1),E(``),m(`已导入:新建 ${e.created} 个看板、合并 ${e.merged} 个、匹配仓库 ${e.matched} 个`+(e.unmatched.length?`;未匹配 ${e.unmatched.length} 条(见 CLI board import 输出)`:``)),await Promise.all([f.repos(),f.boards()])}),children:`导入`})]})]})}):null,D?(0,b.jsx)(a,{title:`看板 JSON(可回灌给导入)`,size:`lg`,onClose:()=>O(null),children:(0,b.jsx)(`textarea`,{className:`bd-exp`,rows:14,readOnly:!0,value:D,spellCheck:`false`})}):null,g]})}function V(e){return String(e||``).trim().replace(/\s+/g,`-`).replace(/[<>:"\\|?*\x00-\x1f]/g,`-`).replace(/\.git$/i,``).replace(/\/{2,}/g,`/`).replace(/^\/+|\/+$/g,``).slice(0,160).toLowerCase()}function H(e){let t=String(e||``).trim();if(!t)return``;t=t.replace(/\/+$/,``);let n=/^git@([^:/]+):(.+)$/i.exec(t);n?t=`${n[1]??``}/${n[2]??``}`:/^[a-z][a-z0-9+.-]*:\/\//i.test(t)&&(t=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``),t=t.replace(/^[^/]*@/,``),t=t.replace(/^([^/]+?):\d+(\/|$)/,`$1$2`),t=t.replace(/^([a-z]):/i,`$1`)),t=t.replace(/\.git$/i,``),t=t.replace(/\/{2,}/g,`/`);let r={"ssh.github.com":`github.com`,"www.github.com":`github.com`},i=t.indexOf(`/`);if(i>0){let e=t.slice(0,i).toLowerCase();t=(r[e]||e)+t.slice(i)}return t=t.replace(/^\/+|\/+$/g,``),t.toLowerCase()}var U={path:``,name:``,desc:``,notes:``,type:`dev`,remote:``,key:``,icon:``};function W({editing:t,repos:n,onClose:s,onSaved:c}){let l=e(),u=o(),{dialog:f,node:p}=r(),{openByDocId:m}=d(),h=(0,y.useMemo)(()=>t&&n.find(e=>e.id===t)||null,[t,n]),[g,_]=(0,y.useState)(()=>h?{path:h.path||``,name:h.name||``,desc:h.desc||``,type:h.type||`dev`,remote:h.remote||``,notes:h.notes||``,key:h.key||``,icon:h.icon||``}:U),[x,S]=(0,y.useState)(()=>h?h.keyCustom===!0:!1),[C,w]=(0,y.useState)(null),[T,E]=(0,y.useState)(()=>!!h);(0,y.useEffect)(()=>{let e=g.path.trim();if(!e){w(null);return}let t=!0,n=setTimeout(async()=>{w({loading:!0});try{let n=await i(`/api/repos/detect`,{method:`POST`,body:{path:e}});if(!t)return;w({loading:!1,...n}),n.recommended&&!T&&_(e=>({...e,remote:n.recommended,key:x?e.key:n.key||e.key}))}catch(e){t&&w({loading:!1,error:e.message})}},400);return()=>{t=!1,clearTimeout(n)}},[g.path,T,x]);let D=e=>t=>_(n=>({...n,[e]:t.target.value})),O=e=>{let t=e.target.value;E(!0),w(null),_(e=>({...e,remote:t,key:x?e.key:H(t)}))},k=e=>{S(!0),_(t=>({...t,key:e.target.value}))},A=h&&h.descDocs||null;return(0,b.jsxs)(a,{title:t?`编辑仓库 · ${t}`:`添加仓库`,onClose:s,children:[(0,b.jsxs)(`div`,{className:`form-grid`,children:[(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`repo-path`,children:`仓库绝对路径 *`}),(0,b.jsx)(`input`,{id:`repo-path`,placeholder:`D:/code/my-project`,spellCheck:`false`,value:g.path,onChange:D(`path`)})]}),(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`repo-name`,children:`名称`}),(0,b.jsx)(`input`,{id:`repo-name`,placeholder:`留空则用目录末段`,value:g.name,onChange:D(`name`)})]}),(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`repo-icon`,children:`图标`}),(0,b.jsx)(`input`,{id:`repo-icon`,maxLength:8,placeholder:`emoji 或单字符(留空 = 默认文件夹图标)`,value:g.icon,onChange:D(`icon`)})]}),A?(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{children:`项目描述(文档)`}),(0,b.jsxs)(`div`,{className:`rp-docpick`,children:[(0,b.jsxs)(`button`,{type:`button`,className:`rp-doc`,onClick:()=>{s(),m(A.main?.docId)},children:[A.main?.title,A.main?.exists?null:(0,b.jsx)(`span`,{className:`rp-doc-todo`,children:`未写`})]}),(A.links||[]).length?(0,b.jsxs)(`span`,{className:`muted`,children:[`另有 `,(A.links||[]).length,` 篇补充文档`]}):null]})]}):null,(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`repo-type`,children:`类型`}),(0,b.jsxs)(`select`,{id:`repo-type`,value:g.type,onChange:D(`type`),children:[(0,b.jsx)(`option`,{value:`dev`,children:`开发仓库(本机开发的)`}),(0,b.jsx)(`option`,{value:`ref`,children:`参考仓库(远程 clone 下来的)`})]})]}),(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`repo-remote`,children:`远程 git 地址`}),(0,b.jsx)(`input`,{id:`repo-remote`,spellCheck:`false`,placeholder:`https://github.com/me/x.git(导出时导它,不含本地路径)`,value:g.remote,onChange:O}),C?(0,b.jsx)(`div`,{className:`form-hint`,children:C.loading?`正在从目录读取 git remote…`:C.error?`读取 git remote 失败:${C.error}`:C.recommended?`已按目录 git remote 自动填入${(C.remotes||[]).length>1?`(另有 ${(C.remotes||[]).length-1} 条候选)`:``}`:C.exists===!1?`该路径不存在 —— 请检查后重填`:C.isGit?`目录是 git 仓库,但没有配置 remote —— 请手工填写`:`目录不是 git 仓库 —— 请手工填写`}):null,(0,b.jsx)(`div`,{className:`form-hint`,children:`有远程地址时,下面的 key 会按它自动归一化:ssh / https / 带 .git / 带 user 的写法 都归一成 host/owner/repo(如 github.com/on-devplan/nx-kv)。`})]}),(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`repo-key`,children:`仓库 key *(全局唯一身份)`}),(0,b.jsx)(`input`,{id:`repo-key`,spellCheck:`false`,placeholder:`github.com/on-devplan/nx-kv`,value:g.key,onChange:k}),(0,b.jsx)(`div`,{className:`form-hint`,children:`没有远程地址时必须手工填写;已有仓库可查看,改 key 会波及引用它的队列 / 看板 / 关系。`})]}),(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{htmlFor:`repo-notes`,children:`备注`}),(0,b.jsx)(`textarea`,{id:`repo-notes`,placeholder:`补充信息(可选)`,value:g.notes,onChange:D(`notes`)})]}),(0,b.jsxs)(`div`,{className:`form-acts`,children:[(0,b.jsx)(v,{onClick:s,children:`取消`}),(0,b.jsx)(v,{disabled:!g.path.trim()||!g.key.trim()&&!g.remote.trim(),onClick:()=>l(async()=>{if(!g.path.trim())return;let e=g.remote.trim(),n=g.key.trim(),r=n?V(n):H(e);if(!r){u(`仓库 key 必填:没有远程 git 地址时必须手工填写 key(不会再自动生成 local/<目录名>)`);return}let a={path:g.path.trim(),name:g.name.trim()||void 0,notes:g.notes,type:g.type===`ref`?`ref`:`dev`,remote:e||void 0,icon:g.icon.trim()};if(t){let t=h&&h.key||``;if(x&&n===``){if(!e){u(`清空自定义 key 需要仓库有远程地址(否则 key 必填)`);return}a.key=``,a.keyCustom=!1}else if(x&&r!==t){if(!await f({title:`修改仓库 key`,message:`key 是仓库身份,改掉会连锁影响:\n\n「${t||`(空)`}」→「${r}」\n\n队列/看板/参考关系会跟随新 key 级联更新;docs/ 下按旧 key 生成的文档路径不会自动迁移,需要手动处理。确认修改?`,danger:!0}))return;a.key=r,a.keyCustom=!0}}else a.key=r,x&&(a.keyCustom=!0);t?await i(`/api/repos/${encodeURIComponent(t)}`,{method:`PATCH`,body:a}):await i(`/api/repos`,{method:`POST`,body:a}),s(),await c()}),children:t?`保存修改`:`添加仓库`})]})]}),p]})}function ee({repo:t,refRepos:n,boardList:r,currentRefs:s,onClose:c,onSaved:l}){let u=e(),d=o(),f=r.filter(e=>(e.repos||[]).some(e=>e.key===t.key)),[p,m]=(0,y.useState)(()=>{let e={};for(let t of s||[])e[t.key]=!0;return e});return(0,b.jsx)(a,{title:`「${t.name}」的参考仓库`,onClose:c,children:(0,b.jsxs)(`div`,{className:`form-grid`,children:[(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsxs)(`div`,{className:`form-hint`,children:[`参考仓库绑定在组上,勾选 = 绑到「`,t.name,`」所属的组,组内所有仓库共享。仓库不属于任何组时请先把它加入组。`]}),(0,b.jsx)(`div`,{className:`rp-pick-list`,children:(0,b.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,b.jsx)(`span`,{className:`rp-pick-group-label`,children:`参考仓库`}),n.map(e=>(0,b.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:!!p[e.key],onChange:t=>m(n=>({...n,[e.key]:t.target.checked}))}),(0,b.jsx)(`span`,{title:e.remote||``,children:e.name}),e.desc?(0,b.jsx)(`span`,{className:`muted rp-pick-desc`,children:e.desc}):null]},e.key)),n.length?null:(0,b.jsx)(`span`,{className:`muted`,children:`(还没有参考仓库 —— 先在参考面板里克隆)`})]})}),f.length?(0,b.jsxs)(`div`,{className:`form-hint`,children:[`将写入:`,f.map(e=>e.name).join(`、`)]}):(0,b.jsx)(`div`,{className:`form-hint rp-ref-warn`,children:`这个仓库不属于任何组,保存会被拒绝 —— 先把它加入组。`})]}),(0,b.jsxs)(`div`,{className:`form-acts`,children:[(0,b.jsx)(v,{onClick:c,children:`取消`}),(0,b.jsx)(v,{onClick:()=>u(async()=>{if(!f.length){d(`这个仓库不属于任何组 —— 参考绑定挂在组上;先把它加入组`);return}let e=new Set((s||[]).map(e=>e.key)),t=new Set(Object.keys(p).filter(e=>p[e]));for(let n of t)if(!e.has(n))for(let e of f)await i(`/api/repos/bind`,{method:`POST`,body:{id:n,board:[e.id]}});for(let n of e)if(!t.has(n))for(let e of f)await i(`/api/repos/bind`,{method:`POST`,body:{id:n,board:[e.id],remove:!0}});c(),await l()}),children:`保存绑定`})]})]})})}function te({linkNoteFor:t,onClose:n,onSaved:r}){let s=e(),c=o(),{ref:l,groupId:u,groupName:d,note:f}=t,[p,m]=(0,y.useState)(()=>f||``);return(0,b.jsx)(a,{title:`组级绑定描述 · ${l.name} @ 「${d}」`,onClose:n,children:(0,b.jsxs)(`div`,{className:`form-grid`,children:[(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsxs)(`label`,{htmlFor:`link-note`,children:[`「`,l.name,`」在这个组里参考什么`]}),(0,b.jsx)(`div`,{className:`form-hint`,children:`写这条参考在此处的角色与用法(可多行、可含关键路径/搜索词)。留空保存 = 清除。`}),(0,b.jsx)(`textarea`,{id:`link-note`,rows:5,spellCheck:`false`,placeholder:`如:project-graph 画布交互的实现参考;
15
- 看 src/extensions/ 的注册方式,搜 registerExtension。`,value:p,onChange:e=>m(e.target.value)})]}),(0,b.jsxs)(`div`,{className:`form-acts`,children:[(0,b.jsx)(v,{onClick:n,children:`取消`}),(0,b.jsx)(v,{onClick:()=>s(async()=>{await i(`/api/repos/ref/note`,{method:`POST`,body:{id:l.key,board:u,note:p}}),n(),await r(),c(`已保存组级绑定描述`)}),children:`保存`})]})]})})}function G({repo:t,onClose:n,onSaved:r}){let s=e(),c=o(),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),p=(0,y.useCallback)(async()=>{try{let e=await i(`/api/repos/remote/list?id=`+encodeURIComponent(t.key));if(!e||!Array.isArray(e.remotes))throw Error(`远程地址读取失败`);u(e)}catch(e){c(String(e.message||e)),n()}},[t.key,c,n]);(0,y.useEffect)(()=>{p()},[p]);let m=e=>s(async()=>{l&&(await i(`/api/repos/remote/pick`,{method:`POST`,body:{id:l.key,url:e}}),n(),c(`已对齐 remote`),await r())}),h=async e=>{let t=l?l.key:``;if(!t){f({url:``,status:`unreachable`,detail:`没有仓库标识`});return}f({url:e||l?.current||``,status:`checking`,detail:`检查中…`});try{let n=await i(`/api/repos/remote/check?id=`+encodeURIComponent(t)+(e?`&url=`+encodeURIComponent(e):``));f(n)}catch(t){f({url:e||l?.current||``,status:`unreachable`,detail:String(t.message||t)})}};return l?(0,b.jsx)(a,{title:`对齐 remote · ${l.name}`,onClose:n,children:(0,b.jsxs)(`div`,{className:`form-grid`,"data-testid":`rp-remote-modal`,children:[(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsxs)(`div`,{className:`form-hint`,children:[`当前采纳:`,(0,b.jsx)(`b`,{children:l.current||`(无)`}),`。换一条即对齐(key 随之重算;自定义 key 不动)。`]}),(0,b.jsxs)(`div`,{className:`rp-remote-list`,children:[l.remotes.map(e=>(0,b.jsxs)(`div`,{className:`rp-remote-item`,children:[(0,b.jsx)(`span`,{className:`rp-remote-name`,children:e.name}),(0,b.jsx)(`span`,{className:`mono rp-remote-url`,children:e.url}),(0,b.jsx)(`span`,{className:`rp-remote-kind`,children:e.kind}),e.current?(0,b.jsx)(`span`,{className:`rp-remote-on`,children:`当前`}):null,(0,b.jsxs)(`span`,{className:`acts`,children:[e.current?null:(0,b.jsx)(v,{small:!0,onClick:()=>m(e.url),children:`对齐这条`}),(0,b.jsx)(v,{small:!0,onClick:()=>h(e.url),children:`检查`})]})]},e.name+`|`+e.url)),l.remotes.length?null:(0,b.jsx)(`div`,{className:`muted`,children:`这个仓库没有配置 remote —— 先在 git 里 git remote add`})]})]}),d?(0,b.jsxs)(`div`,{className:`form-field`,children:[(0,b.jsx)(`label`,{children:`存在性检查`}),(0,b.jsxs)(`div`,{className:`rp-remote-check`,children:[(0,b.jsx)(`span`,{className:`rp-status `+(d.status===`exists`?`same`:d.status===`missing`?`new`:d.status===`checking`?`checking`:`missing`),children:d.status===`exists`?`存在`:d.status===`missing`?`不存在`:d.status===`checking`?`检查中`:`不可达`}),(0,b.jsx)(`span`,{className:`mono rp-remote-url`,children:d.url}),(0,b.jsx)(`span`,{className:`muted`,children:d.detail})]})]}):null,(0,b.jsxs)(`div`,{className:`form-acts`,children:[(0,b.jsx)(v,{onClick:n,children:`关闭`}),(0,b.jsx)(v,{onClick:()=>h(``),children:`检查当前 remote`})]})]})}):null}function K(){let t=e(),n=o(),{dialog:a,node:s}=r(),l=c(),{openByDocId:h}=d(),[g,_]=(0,y.useState)([]),[v,x]=(0,y.useState)(null),[C,w]=(0,y.useState)(null),T=(0,y.useCallback)(async()=>{_(await i(`/api/repos`).catch(()=>[])||[])},[]),E=(0,y.useCallback)(async()=>{x(await i(`/api/boards`).catch(()=>null))},[]),D=(0,y.useCallback)(async()=>{w(await i(`/api/repos/ref/check`).catch(()=>null))},[]);(0,y.useEffect)(()=>{T(),E(),D()},[T,E,D]);let O=(0,y.useMemo)(()=>({repos:T,boards:E,refCheck:D,all:async()=>{await Promise.all([T(),E(),D()])}}),[T,E,D]),[A,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(``),[V,H]=(0,y.useState)(void 0),[U,K]=(0,y.useState)(!1),[ne,q]=(0,y.useState)(!1),[J,re]=(0,y.useState)(``),[ie,ae]=(0,y.useState)({}),[oe,se]=(0,y.useState)(!1),[ce,Y]=(0,y.useState)(null),[le,ue]=(0,y.useState)(!1),[de,fe]=(0,y.useState)(null),[pe,me]=(0,y.useState)(null),[he,ge]=(0,y.useState)(null),[_e,ve]=(0,y.useState)(null),[ye,be]=(0,y.useState)(null);(0,y.useEffect)(()=>{let e=()=>{let e=location.hash.split(`?`)[1]||``;if(!e)return;let t=new URLSearchParams(e),n=t.get(`board`);n&&(j(n),t.get(`add`)&&Y(n))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let X=(0,y.useMemo)(()=>v&&v.boards||[],[v]),Z=(0,y.useMemo)(()=>g.filter(e=>(e.type||`dev`)!==`ref`),[g]),Q=(0,y.useMemo)(()=>g.filter(e=>e.type===`ref`),[g]),xe=(0,y.useMemo)(()=>{let e=Z;A&&(e=e.filter(e=>(e.boards||[]).some(e=>e.id===A)));let t=M.trim().toLowerCase();if(!t)return e;let n=e=>{let n=e.descDocs&&e.descDocs.main;return n&&[n.title,n.summary,n.rel].some(e=>e&&String(e).toLowerCase().includes(t))?!0:(e.descDocs&&e.descDocs.links||[]).some(e=>[e.title,e.tag,e.note,e.rel].some(e=>e&&String(e).toLowerCase().includes(t)))};return e.filter(e=>[e.name,e.key,e.path,e.desc].some(e=>e&&String(e).toLowerCase().includes(t))||(e.boards||[]).some(e=>String(e.name||``).toLowerCase().includes(t))||n(e))},[Z,A,M]),$=(0,y.useMemo)(()=>X.find(e=>e.id===A)||null,[X,A]),Se=(0,y.useMemo)(()=>X.find(e=>e.id===ce)||null,[X,ce]),Ce=(0,y.useMemo)(()=>{let e=new Map;return(C?.refRepos||[]).forEach(t=>e.set(t.id,t)),e},[C]),we=(0,y.useMemo)(()=>{let e=new Map,t=new Map(Q.map(e=>[e.key,e]));for(let n of X){let r=n.key||`board/${n.name}`;for(let i of(n.repos||[]).map(e=>e.key))for(let a of n.refs||[]){let o=t.get(a.id);if(!o)continue;e.has(i)||e.set(i,[]);let s=e.get(i);if(!s)continue;let c=s.find(e=>e.key===o.key);if(c){c.group&&c.group.name!==n.name&&(c.alsoIn=[...c.alsoIn||[],n.name]);continue}s.push({key:o.key,id:o.id,name:o.name,remote:o.remote||``,note:a.note||``,group:{id:n.id,key:r,name:n.name}})}}return e},[X,Q]),Te=(0,y.useMemo)(()=>{let e=new Map;for(let t of X){let n=(t.refs||[]).length;if(n)for(let r of t.repos||[]){if(!r||!r.key)continue;e.has(r.key)||e.set(r.key,[]);let i=e.get(r.key);i&&i.push({id:t.id,name:t.name,count:n})}}return e},[X]),Ee=(0,y.useMemo)(()=>{let e=new Map;if(!$)return e;let t=new Map(Q.map(e=>[e.key,e])),n=($.refs||[]).map(e=>{let n=t.get(e.id);return n?{key:n.key,name:n.name,note:e.note||``,source:`group`,groupName:$.name}:null}).filter(e=>e!==null);for(let r of Z){let i=(r.linked||[]).filter(e=>e&&e.kind===`ref`).map(e=>{let n=t.get(e.id);return n?{key:n.key,name:n.name,note:e.note||``,source:`repo`}:null}).filter(e=>e!==null),a=new Set(i.map(e=>e.key));e.set(r.key,[...i,...n.filter(e=>!a.has(e.key))])}return e},[$,Z,Q]),De=(0,y.useMemo)(()=>{let e=new Map;for(let t of Z)for(let n of t.linked||[]){if(!n||n.kind!==`ref`)continue;e.has(n.id)||e.set(n.id,[]);let r=e.get(n.id);r&&r.push({repo:t,note:n.note||``})}return e},[Z]);(0,y.useEffect)(()=>{if(!ne||!J)return;let e=null,t=0,n=requestAnimationFrame(()=>{e=document.getElementById(`rp-refrepo-row-`+J),e&&(e.scrollIntoView({block:`center`}),e.classList.add(`rp-row-flash`),t=window.setTimeout(()=>e?.classList.remove(`rp-row-flash`),1600))});return()=>{cancelAnimationFrame(n),clearTimeout(t),e&&e.classList.remove(`rp-row-flash`)}},[ne,J]);let Oe=e=>t(async()=>{let t=await i(`/api/repos/ref/sync`,{method:`POST`,body:{id:e.id}});n(t.status===`updated`?`已更新: ${t.name}`:t.status===`upToDate`?`${t.name} 已是最新`:`${t.name}: ${t.status} ${t.output||``}`)}),ke=(e,n)=>t(async()=>{await i(`/api/repos/bind`,{method:`POST`,body:{id:e.key,board:[n],remove:!0}}),await Promise.all([T(),E(),D()])}),Ae=(e,n)=>t(async()=>{await i(`/api/repos/bind`,{method:`POST`,body:{id:e.key,repo:[n],remove:!0}}),await Promise.all([T(),E(),D()])}),je=(e,t,n,r)=>{be({ref:e,groupId:t,groupName:n,note:r||``})},Me=(e,n)=>t(async()=>{if(e===`open`)await i(`/api/repos/open`,{method:`POST`,body:{id:n.id}});else if(e===`del`){if(!await a({message:`删除仓库登记「${n.name}」?(仅移除登记,磁盘文件不受影响;各看板里的归属同步摘除)`,danger:!0}))return;await i(`/api/repos/${encodeURIComponent(n.id)}`,{method:`DELETE`}),await O.all()}}),Ne=(e,n)=>t(async()=>{e&&(await i(`/api/docs/item`,{method:`POST`,body:{rel:e,body:`# ${n||e}\n\n`}}).catch(()=>{}),h(`rel:`+e),T())}),Pe=e=>e.docPath?h(`path:`+e.docPath):Ne(e.docRel,`${e.name} · 组介绍`),Fe=(e,t=`start`)=>{if(!e)return;let n=e.parentElement;for(;n;){let e=getComputedStyle(n);if((e.overflowY===`auto`||e.overflowY===`scroll`)&&n.scrollHeight>n.clientHeight)break;n=n.parentElement}n||=document.scrollingElement||document.documentElement;let r=n.getBoundingClientRect?n.getBoundingClientRect().top:0,i=e.getBoundingClientRect().top-r,a=t===`center`?(n.clientHeight-e.offsetHeight)/2:12;n.scrollTop=Math.max(0,n.scrollTop+i-a)},Ie=e=>Fe(document.getElementById(e)),Le=e=>{if(!e||!e.target)return;if(e.kind===`board`){j(e.target),Ie(`rp-repos`);return}j(``);let t=document.getElementById(`rp-row-`+e.target);if(!t){Ie(`rp-repos`);return}Fe(t,`center`),t.classList.add(`rp-row-flash`),setTimeout(()=>t.classList.remove(`rp-row-flash`),1400)},Re=(e,t)=>{q(!1),N(``),setTimeout(()=>Le({kind:e,target:t}),60)},ze={open:e=>Me(`open`,e),edit:e=>H(e.id),del:e=>Me(`del`,e),remote:e=>{if(!e.key){n(`这个仓库还没有 key —— 先 nx-kv repo key set <id> <key>`);return}ge(e)},getloop:e=>fe(e),docs:e=>me({kind:`repo`,owner:e}),filter:e=>j(t=>t===e?``:e),keepFilter:e=>j(e),gotoRefRepo:e=>{re(e),q(!0)},bind:e=>ve(e)};return v===null?(0,b.jsxs)(`div`,{className:`rp-page`,children:[(0,b.jsx)(u,{}),(0,b.jsx)(`div`,{className:`muted`,style:{padding:20},children:`读取中…`}),s]}):(0,b.jsxs)(`div`,{className:`rp-page`,children:[(0,b.jsxs)(`div`,{className:`page-head`,children:[(0,b.jsx)(`div`,{className:`title-block`,children:(0,b.jsx)(`h2`,{children:`仓库管理`})}),(0,b.jsx)(`div`,{className:`acts`,children:(0,b.jsx)(p,{kind:`repos`,titles:{add:`登记本机开发仓库`,boards:`分组管理:建组 / 成员 / 组介绍文档`,refs:`参考仓库面板:克隆 / 绑定 / 同步 / 检查 / 存储根`,transfer:`布局与仓库的导入导出(逐条选择 / 冲突方案 / 差异检查)`},actions:{add:()=>H(null),boards:()=>K(!0),refs:()=>q(!0),transfer:()=>ue(!0)}})})]}),(0,b.jsx)(L,{boards:v,devRepos:Z,refRepos:Q,reload:O}),(0,b.jsx)(F,{boards:X,filter:A,onFilter:j,devCount:Z.length,shownCount:xe.length,q:M,onQ:N,onOpenDocs:()=>se(!0)}),(0,b.jsx)(I,{filterBoard:$,refRepos:Q,checkOf:Ce,onOpenDoc:Pe,onAddMember:Y,onSync:Oe,onOpen:e=>Me(`open`,e),onLinkNote:je,onUnbind:ke}),(0,b.jsx)(P,{shown:xe,devRepos:Z,filterBoard:$,groupRefRepoCounts:Te,refRepoChipsByRepo:Ee,acts:ze,onAddMember:Y}),ne?(0,b.jsx)(R,{refRepos:Q,devRepos:Z,boardList:X,checkOf:Ce,refRepoBackLinks:De,refBindOpen:ie,onRefBindOpen:ae,onClose:()=>q(!1),onSyncOne:Oe,onUnbind:ke,onUnbindRepo:Ae,onLinkNote:je,onGoBind:Re,onDocs:ze.docs,onRowAct:Me,reload:O}):null,oe?(0,b.jsx)(z,{repos:g,boardList:X,onClose:()=>se(!1),onFilter:j,reload:O}):null,U?(0,b.jsx)(B,{boardList:X,unassigned:v.unassigned,onClose:()=>K(!1),onFilter:j,onMembers:Y,onOpenDoc:Pe,reload:O}):null,V===void 0?null:(0,b.jsx)(W,{editing:V,repos:g,onClose:()=>H(void 0),onSaved:O.all}),Se?(0,b.jsx)(m,{board:Se,boards:X,repos:g,onClose:()=>Y(null),onChanged:async()=>{await Promise.all([T(),E()])}}):null,_e?(0,b.jsx)(ee,{repo:_e,refRepos:Q,boardList:X,currentRefs:we.get(_e.key)||[],onClose:()=>ve(null),onSaved:O.all}):null,ye?(0,b.jsx)(te,{linkNoteFor:ye,onClose:()=>be(null),onSaved:O.all}):null,le?(0,b.jsx)(S,{onClose:()=>ue(!1),onChanged:O.all,repos:g,boards:X}):null,de?(0,b.jsx)(k,{repo:g.find(e=>e.id===de.id)||de,onClose:()=>fe(null),onSaved:T}):null,he?(0,b.jsx)(G,{repo:he,onClose:()=>ge(null),onSaved:async()=>{await Promise.all([T(),D()])}}):null,pe?(0,b.jsx)(f,{kind:pe.kind,owner:pe.owner,model:l.model,onClose:()=>me(null),onChanged:T}):null,s]})}export{K as default};
@@ -1 +0,0 @@
1
- import{g as e,h as t,l as n,m as r,p as i,u as a,y as o}from"./task-status-DSrx0i66.js";import{n as s}from"./app-context-BASCGAA-.js";import{n as c,o as l}from"./index-D8MvtVAm.js";import{n as u,o as d,r as f,s as p,t as m}from"./prompt-blocks-BovFd039.js";var h=o(e(),1),g={context:[{label:`项目`,items:[[`repo.name`,`项目名`],[`repo.intro`,`项目介绍正文`],[`repo.introPath`,`介绍全文路径`],[`repo.docs`,`补充文档(可循环 path/tag/note)`],[`repo.docCount`,`补充文档数`],[`repo.refRepos`,`本仓库直接绑定的参考仓库(repos 中 type=ref,不是文档库 refs;可循环 name/path/note)`],[`repo.refRepoCount`,`本仓库直接绑定的参考仓库数`]]},{label:`组`,items:[[`group.name`,`组名`],[`group.desc`,`组定位`],[`group.intro`,`组介绍正文`],[`group.note`,`本项目在组里的位置`],[`group.peers`,`组内成员(可循环 name/note)`],[`group.docs`,`组绑定参考文件(可循环)`],[`group.refRepos`,`本组绑定的参考仓库(repos 中 type=ref,不是文档库 refs;可循环 name/path/note)`],[`group.refRepoCount`,`本组绑定的参考仓库数`],[`groups`,`其余组(可循环 name/desc/path)`]]},{label:`参考仓库`,items:[[`refRepos.list`,`直接绑定 ∪ 组级绑定的去重并集(repos 中 type=ref,不是文档库 refs;可循环 name/path/note)`],[`refRepos.count`,`去重并集的条目数(无绑定时为 0,整段不出现)`]]},{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文`],[`params`,`外部参数(k=v)`]]}],attachment:[{label:`统计`,items:[[`attach.count`,`附件总数`],[`attach.inlineCount`,`正文内嵌数量`],[`attach.areaCount`,`附件区数量`],[`attach.hasInline`,`是否有正文内嵌`],[`attach.hasArea`,`是否有附件区条目`],[`attach.needsSyncCount`,`需要同步到本地的文件数`]]},{label:`附件条目(通用,attach.list 内循环)`,items:[[`kind`,`类型:file / url / task / ref`],[`kindLabel`,`类型显示名:附件/图片/链接/任务/文档`],[`name`,`展示名(任务型为实时标题,不是正文)`],[`size`,`字节数`],[`sizeText`,`可读大小(1.2 MB)`],[`mime`,`MIME 类型`],[`storage`,`存储来源:local / cloud / url / internal`],[`role`,`关系角色:inline / reference / doc / attach`],[`origin`,`来源:inline(正文内嵌)/ area(附件区)`],[`originLabel`,`来源显示名`],[`usage`,`取用说明(按类型生成,含确切命令)`],[`cmd`,`取用命令(file 未同步 / task / ref;url 为空)`],[`locator`,`简短定位串(路径 / 链接 / #seq 标题 / 文档路径)`],[`isImage`,`是否图片(kind=file 的子类型)`],[`needsSync`,`该条是否需要先同步到本地`]]},{label:`文件型(kind=file)· file 子对象`,items:[[`file.localPath`,`本地绝对路径(已同步时才有值)`],[`file.fileId`,`资源 id(未同步时用它拉取)`],[`file.exists`,`本机盘上是否已有副本`],[`file.syncCmd`,`未同步时的命令:nx-kv file sync --ids <fileId>`],[`localPath`,`file.localPath 的平铺别名(旧模板兼容)`],[`fileId`,`file.fileId 的平铺别名`]]},{label:`链接型(kind=url)· url 子对象`,items:[[`url.href`,`可访问的完整链接,可直接抓取`],[`url.host`,`链接域名(host)`],[`href`,`url.href 的平铺别名`],[`host`,`url.host 的平铺别名`],[`urlText`,`链接字符串别名`]]},{label:`任务型(kind=task)· task 子对象`,items:[[`task.taskId`,`本机 tasks.id(join 用;任务被清理后为 0)`],[`task.topicKey`,`任务所在 topic key`],[`task.topicName`,`任务所在 topic 名`],[`task.seq`,`topic 内编号(对外显示的任务号)`],[`task.title`,`实时标题(正文首行,不是正文)`],[`task.status`,`实时状态:pending/claimed/done/cancelled`],[`task.statusLabel`,`状态显示名`],[`task.address`,`地址 topicKey:seq`],[`task.storedAddress`,`附件行里存的旧地址(搬家前)`],[`task.addressDrift`,`地址是否已漂移(任务搬过 topic)`],[`task.resolved`,`正文当前是否可读`],[`task.purged`,`目标任务是否已被清理`],[`task.deleted`,`目标任务是否已软删`],[`task.showCmd`,`取正文命令:nx-kv localtask show --id <seq> --key <topicKey>`],[`seq`,`task.seq 的平铺别名`],[`title`,`task.title 的平铺别名`],[`showCmd`,`task.showCmd 的平铺别名`]]},{label:`文档型(kind=ref)· ref 子对象`,items:[[`ref.refId`,`refs 表 id`],[`ref.title`,`文档标题`],[`ref.relPath`,`文档相对路径 / 外部 md 绝对路径`],[`ref.readCmd`,`读取命令:nx-kv docs get rel:<路径>(或 path:<绝对路径>)`],[`refId`,`ref.refId 的平铺别名`],[`relPath`,`ref.relPath 的平铺别名`],[`readCmd`,`ref.readCmd 的平铺别名`]]},{label:`同步汇总`,items:[[`attach.syncSummary.text`,`本次批量同步的一行汇总`],[`attach.syncSummary.dir`,`同步目录`],[`attach.syncSummary.downloaded`,`已下载数`],[`attach.syncSummary.skipped`,`跳过数`],[`attach.syncSummary.failureCount`,`失败数`]]},{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文(交付模板等处仍在用)`]]}],timecheck:[{label:`时间目标`,items:[[`goal.check`,`时间检查指令(任务级;每轮 check 按当下模板渲染)`],[`goal.statusLine`,`目录级目标状态行`],[`goal.name`,`目标名`],[`goal.goalKey`,`任务级目标 key(check --task 用)`],[`goal.durationHuman`,`持续时长(人话,如 2 小时)`],[`goal.durationSec`,`持续秒数`],[`goal.deadline`,`截止时间`],[`goal.remainingSec`,`剩余秒数`],[`goal.remainingHuman`,`剩余时长(人话)`],[`goal.remainingMin`,`剩余分钟(向上取整)`],[`goal.elapsedHuman`,`已过时长(人话)`],[`goal.elapsedSec`,`已过秒数`],[`goal.overtimeSec`,`超时秒数`],[`goal.reached`,`是否到点`],[`goal.extra`,`发布方附加要求(领取后可动态改)`]]},{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务实时原文`]]}],goalhint:[{label:`时间目标上下文(任务级)`,items:[[`goal.goalKey`,`任务级目标 key(check --task 用)`],[`goal.durationHuman`,`持续时长(人话)`],[`goal.durationSec`,`持续秒数`],[`goal.startedAt`,`开始计时时间`],[`goal.deadline`,`截止时间`],[`goal.remainingHuman`,`剩余时长(人话)`],[`goal.remainingSec`,`剩余秒数`],[`goal.elapsedHuman`,`已过时长(人话)`],[`goal.elapsedSec`,`已过秒数`],[`goal.overtimeSec`,`超时秒数`],[`goal.reached`,`是否到点`],[`goal.extra`,`发布方附加要求(领取后可动态改)`]]},{label:`任务`,items:[[`task.id`,`任务号`],[`task.text`,`任务实时原文(check 返回对象同样可用)`]]}],doneguard:[{label:`时间目标上下文(任务级)`,items:[[`goal.blocked`,`恒为 true(只在这条拦截路径上出现,交付渲染时整段省略)`],[`goal.goalKey`,`任务级目标 key(check --task 用)`],[`goal.durationHuman`,`持续时长(人话)`],[`goal.durationSec`,`持续秒数`],[`goal.startedAt`,`开始计时时间`],[`goal.deadline`,`截止时间`],[`goal.remainingHuman`,`剩余时长(人话)`],[`goal.remainingSec`,`剩余秒数`],[`goal.elapsedHuman`,`已过时长(人话)`],[`goal.elapsedSec`,`已过秒数`]]},{label:`任务`,items:[[`task.id`,`任务号`],[`task.text`,`任务实时原文`]]},{label:`可用的 helper(与所有区块同一套)`,items:[[`percent goal.elapsedSec goal.durationSec`,`已用百分比(0 位小数;可加第三参控制小数位)`],[`gte a b / gt / lt / lte / eq / ne / between v min max`,`比较,返回布尔,可直接进 {{#if}}`],[`and / or / not`,`逻辑`],[`add / sub / mul / div / mod / round / floor / ceil / ratio / clamp`,`数值计算(坏输入输出 NaN,不抛错)`],[`includes / length / default`,`字符串`],[`formatDuration`,`秒数转人话`]]}],ext:[{label:`队列`,items:[[`ext.topic`,`主题 / 队列名`],[`ext.count`,`待领取任务数`],[`ext.list`,`待领取清单(可循环 id/title/topic)`]]},{label:`通用`,items:[[`task.id`,`任务号`]]}],ack:[{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文`],[`source`,`任务来源(local/global)`],[`summary`,`领取方现状`],[`name`,`领取方名字`],[`cwd`,`领取方目录`],[`params`,`外部参数(k=v)`]]}],getloop:[{label:`持续 get`,items:[[`getloop.text`,`持续 get 指令正文`],[`getloop.waitMinutes`,`单轮等待分钟数`]]},{label:`通用`,items:[[`task.id`,`任务号`]]}]},_=t();function v({blockId:e}){let t=g[e]||[];return t.length?(0,_.jsxs)(`div`,{className:`setp-params`,"aria-label":`可使用参数`,children:[(0,_.jsx)(`div`,{className:`setp-params-head`,children:`可使用参数`}),t.map(e=>(0,_.jsxs)(`div`,{className:`setp-params-row`,children:[(0,_.jsx)(`span`,{className:`setp-params-label`,children:e.label}),(0,_.jsx)(`div`,{className:`setp-params-items`,children:e.items.map(([e,t])=>(0,_.jsxs)(`span`,{className:`setp-param`,children:[(0,_.jsx)(`code`,{children:e}),(0,_.jsx)(`span`,{children:t})]},e))})]},e.label))]}):null}function y(){return`bt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function b(e){return u.find(t=>t.id===e)||u[0]}function x(e,t){return e[t]}function S(e,t,n){let r=x(e,t);return r.list.find(e=>e.id===n)||r.list.find(e=>e.id===r.active)||r.list[0]}function C(){let e=i(),{dialog:t,node:a}=n(),[o,s]=(0,h.useState)(null),[c,l]=(0,h.useState)(u[0].id),[g,C]=(0,h.useState)(null),[w,T]=(0,h.useState)(!1),E=(e,t=null)=>{s(t=>({lists:e,appendMode:t?.appendMode??`xml`}));let n=t||(g&&g.blockId===c?g:null),r=n?.blockId||c,i=S(e,r,n?.id||x(e,r).active);C({blockId:r,id:i.id,name:i.name,template:i.template})},D=()=>{r(`/api/localtasks`).then(e=>{let t=e?.settings||{},n=d(t.blockTemplates),r=t.appendMode===`plain`?`plain`:`xml`;s({lists:n,appendMode:r});let i=u[0],a=S(n,i.id,x(n,i.id).active);l(i.id),C({blockId:i.id,id:a.id,name:a.name,template:a.template})}).catch(t=>e(`读取失败:`+(t.message||t)))};if((0,h.useEffect)(D,[]),!o)return(0,_.jsx)(`div`,{className:`setp-note`,children:`读取提示词模板…`});let O=b(c),k=m.find(e=>e.id===o.appendMode)||m[0],A=x(o.lists,c),j=g?.id===f,M=async(t,n,i=null)=>{if(!w){T(!0);try{let a=await r(`/api/localtasks/setting`,{method:`PATCH`,body:{blockTemplates:t}});E(d(a?.blockTemplates),i),e(n)}catch(t){e(String(t.message||t))}finally{T(!1)}}},N=()=>JSON.parse(JSON.stringify(o.lists)),P=e=>{if(w)return;l(e);let t=S(o.lists,e,x(o.lists,e).active);C({blockId:e,id:t.id,name:t.name,template:t.template})},F=e=>{let t=S(o.lists,c,e);C({blockId:c,id:t.id,name:t.name,template:t.template})},I=e=>C(t=>t&&{...t,...e}),L=()=>{if(!g)return;if(j){e(`系统内置模板不可编辑;请先「复制」一份再改`);return}let t=String(g.name||``).trim().slice(0,60)||`未命名模板`,n=String(g.template??``),r=N(),i=x(r,c),a=i.list.findIndex(e=>e.id===g.id),o={id:g.id,name:t,template:n,builtin:!1};a>=0?i.list[a]=o:i.list.push(o),M(r,`已保存模板(当前生效项保存后立即生效)`,{blockId:c,id:g.id})},R=()=>{if(w)return;let e=N(),t={id:y(),name:`新模板`,template:``,builtin:!1};x(e,c).list.push(t),M(e,`已新建模板,填写后保存,再点「启用」`,{blockId:c,id:t.id})},z=e=>{if(w)return;let t=typeof e==`string`?e:``,n=S(o.lists,c,t),r=N(),i={id:y(),name:`${n.name||`模板`} 副本`.slice(0,60),template:n.template||``,builtin:!1};x(r,c).list.push(i),M(r,`已复制模板`,{blockId:c,id:i.id})},B=()=>{if(w||j||!g)return;let e=String(g.name||``).trim().slice(0,60)||`未命名模板`,t=N(),n=x(t,c),r=n.list.findIndex(e=>e.id===g.id),i={id:g.id,name:e,template:String(g.template??``),builtin:!1};r>=0?n.list[r]=i:n.list.push(i),n.active=g.id,M(t,`已保存并启用「${e}」`,{blockId:c,id:g.id})},V=e=>{if(w||e===A.active)return;let t=N();x(t,c).active=e,M(t,`已启用「${S(o.lists,c,e).name}」`,{blockId:c,id:e})},H=async n=>{if(w)return;if(n===`builtin`){e(`系统内置模板不可删除`);return}let r=S(o.lists,c,n);if(!await t({title:`删除模板?`,message:`将删除「${r.name}」,保存后不可恢复。该区块的系统内置模板会保留。`,okText:`删除`,danger:!0}))return;let i=N(),a=x(i,c);a.list=a.list.filter(e=>e.id!==n),a.active===n&&(a.active=f),M(i,`已删除模板,当前生效项已回落到系统内置`)},U=()=>{if(w||A.active===`builtin`)return;let e=N();x(e,c).active=f,M(e,`已恢复系统内置模板`,{blockId:c,id:f})},W=async t=>{if(!(w||t===o.appendMode)){T(!0);try{let n=await r(`/api/localtasks/setting`,{method:`PATCH`,body:{appendMode:t}});s(e=>e&&{...e,appendMode:n?.appendMode===`plain`?`plain`:`xml`}),e(`已保存追加模式(全局生效)`)}catch(t){e(String(t.message||t))}finally{T(!1)}}};return(0,_.jsxs)(`div`,{className:`setp-tpl-editor`,children:[(0,_.jsxs)(`div`,{className:`setp-tpl-head`,children:[(0,_.jsx)(`span`,{className:`setp-tpl-head-label`,children:`系统提示词追加方式`}),(0,_.jsx)(`div`,{className:`setp-seg`,role:`group`,"aria-label":`系统提示词追加方式`,children:m.map(e=>(0,_.jsx)(`button`,{type:`button`,className:`setp-seg-btn`+(o.appendMode===e.id?` is-on`:``),"aria-pressed":o.appendMode===e.id,title:e.desc,disabled:w,onClick:()=>W(e.id),children:e.label},e.id))}),(0,_.jsx)(`span`,{className:`setp-note`,children:k.desc})]}),(0,_.jsx)(`nav`,{className:`setp-block-tabs`,"aria-label":`提示词区块`,children:u.map(e=>{let t=S(o.lists,e.id,x(o.lists,e.id).active);return(0,_.jsxs)(`button`,{type:`button`,className:`setp-block-tab`+(e.id===c?` is-on`:``),disabled:w,onClick:()=>P(e.id),children:[(0,_.jsx)(`span`,{children:e.label}),(0,_.jsx)(`small`,{children:t.builtin?`系统内置`:t.name})]},e.id)})}),(0,_.jsxs)(`div`,{className:`setp-block-card`,children:[(0,_.jsxs)(`div`,{className:`setp-block-card-head`,children:[(0,_.jsxs)(`div`,{className:`setp-block-card-title`,children:[(0,_.jsx)(`b`,{children:O.label}),(0,_.jsx)(`span`,{className:`setp-note`,children:O.desc})]}),(0,_.jsxs)(`div`,{className:`setp-block-card-actions`,children:[(0,_.jsx)(p,{variant:`secondary`,disabled:w,onClick:R,children:`新建模板`}),(0,_.jsx)(p,{variant:`secondary`,disabled:w||A.active===`builtin`,onClick:U,children:`恢复内置`})]})]}),(0,_.jsx)(`div`,{className:`setp-tpl-list`,role:`listbox`,"aria-label":`${O.label}模板列表`,children:A.list.map(e=>{let t=e.id===A.active,n=e.id===g?.id;return(0,_.jsxs)(`div`,{className:`setp-tpl-pick${t?` is-on`:``}${n?` is-sel`:``}`,children:[(0,_.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:`setp-tpl-name`,title:e.name,onClick:()=>F(e.id),children:[(0,_.jsx)(`span`,{className:`setp-tpl-name-text`,children:e.name}),e.builtin&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`内置`}),t&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`启用中`})]}),(0,_.jsx)(p,{variant:`secondary`,className:`setp-tpl-act`,disabled:w,title:e.builtin?`复制系统内置模板`:`复制该模板`,onClick:()=>z(e.id),children:`复制`}),(0,_.jsx)(p,{variant:`secondary`,className:`setp-tpl-act`,disabled:w||t,title:`设为该区块当前生效模板`,onClick:()=>V(e.id),children:`启用`}),(0,_.jsx)(p,{variant:`secondary`,danger:!0,className:`setp-tpl-act`,disabled:w||e.builtin,title:e.builtin?`系统内置模板不可删除`:`删除该模板`,onClick:()=>H(e.id),children:`删除`})]},e.id)})}),g&&(0,_.jsxs)(`div`,{className:`setp-tpl-editor-box`,children:[(0,_.jsxs)(`div`,{className:`setp-tpl-editor-head`,children:[(0,_.jsx)(`span`,{children:j?`系统内置`:`编辑 · ${g.name||`未命名模板`}`}),(0,_.jsx)(`span`,{className:`setp-note`,children:g.id===A.active?`当前生效,保存后立即参与领取`:`未启用;保存后可点「启用」`})]}),!j&&(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`模板名`}),(0,_.jsx)(`div`,{className:`setp-input`,children:(0,_.jsx)(`input`,{value:g.name,maxLength:60,disabled:w,onChange:e=>I({name:e.target.value})})})]}),(0,_.jsx)(`textarea`,{className:`setp-area setp-tpl-textarea`,value:g.template,readOnly:j,spellCheck:!1,disabled:w,placeholder:j?``:`在这里写该区块的模板`,onChange:e=>I({template:e.target.value})}),(0,_.jsx)(v,{blockId:c}),(0,_.jsxs)(`div`,{className:`setp-proj-a`,children:[j?(0,_.jsx)(p,{variant:`secondary`,disabled:w,onClick:z,children:`复制为我的模板`}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(p,{variant:`primary`,disabled:w,onClick:L,children:`保存`}),(0,_.jsx)(p,{variant:`secondary`,disabled:w,onClick:D,children:`撤销改动`}),g.id!==A.active&&(0,_.jsx)(p,{variant:`secondary`,disabled:w,onClick:B,children:`保存并启用`})]}),(0,_.jsx)(`span`,{className:`spacer`})]})]})]}),a]})}var w={topic:`目录`,repo:`项目`,group:`组`};function T(){let e=s(),t=e.rows||[],n=e.repoData?.repos||[],r=e.repoData?.boards||[];return(0,h.useMemo)(()=>{let e=new Map;for(let n of t)n&&n.key&&e.set(String(n.key),n.name||n.key);let i=new Map;for(let e of n)e&&e.key&&(e.type||`repo`)!==`group`&&i.set(String(e.key),e.name||e.key);let a=new Map;for(let e of n)e&&(e.type||``)===`group`&&e.key&&a.set(String(e.key),e.name||e.key);for(let e of r){let t=String(e&&(e.key||e.id)||``);t&&a.set(t,e&&e.name||t)}return{topicByKey:e,repoByKey:i,groupByKey:a,topics:t,repos:n,boards:r}},[t,n,r])}function E(e,t){if(e===`*`)return`全局`;let n=String(e).indexOf(`:`);if(n<0)return String(e);let r=String(e).slice(0,n),i=String(e).slice(n+1),a=w[r]||r,o=``;return r===`topic`?o=t.topicByKey.get(i)||``:r===`repo`?o=t.repoByKey.get(i)||``:r===`group`&&(o=t.groupByKey.get(i)||``),o?`${a} · ${o}`:`${a} ${/^[0-9a-f]{16}$/.test(i)?`${i.slice(0,6)}…`:i}`}function D({scope:e,onChange:t,originTopic:n=``,catalog:r,classPrefix:a=`setp`}){let o=i(),s=T(),c=r||s,[l,u]=(0,h.useState)(null),d=Array.isArray(e)?e:[],f=d.includes(`*`),p=d.filter(e=>e!==`*`),m=a,g=n?c.topicByKey.get(n)||(/^[0-9a-f]{16}$/.test(n)?`${n.slice(0,6)}…`:n):``,v=async e=>{try{await t(e)}catch(e){o(String(e.message||e))}},y=async e=>{if(d.includes(e)){o(`已经在可见范围里了`),u(null);return}await v([...d,e]),u(null)},b=(0,h.useMemo)(()=>{if(l===`topic`)return(c.topics||[]).filter(e=>e&&e.key).map(e=>({entry:`topic:${e.key}`,label:e.name||e.key,sub:e.cwd||``}));if(l===`repo`)return(c.repos||[]).filter(e=>e&&e.key&&(e.type||`repo`)!==`group`&&e.key!==`__unbound__`).map(e=>({entry:`repo:${e.key}`,label:e.name||e.key,sub:e.key}));if(l===`group`){let e=new Set,t=[];for(let n of c.repos||[])n&&(n.type||``)===`group`&&n.key&&!e.has(n.key)&&(e.add(n.key),t.push({entry:`group:${n.key}`,label:n.name||n.key,sub:n.key}));for(let n of c.boards||[]){let r=n&&(n.key||n.id);r&&!e.has(r)&&(e.add(r),t.push({entry:`group:${r}`,label:n&&n.name||r,sub:String(r)}))}return t}return[]},[l,c]);return(0,_.jsxs)(`div`,{className:`${m}-scope-block`,children:[(0,_.jsx)(`div`,{className:`${m}-scope`,children:d.map(e=>(0,_.jsxs)(`button`,{type:`button`,className:`${m}-scope-chip on`,title:`${e} —— 点击移除`,onClick:()=>v(d.filter(t=>t!==e)),children:[E(e,c),` ×`]},e))}),(0,_.jsxs)(`div`,{className:`${m}-scope-add`,children:[(0,_.jsx)(`span`,{className:`${m}-scope-add-label`,children:`添加`}),(0,_.jsx)(`button`,{type:`button`,className:`${m}-scope-add-btn`,disabled:f,title:f?`已绑定全局`:`加上「全局」绑定(与目录/项目/组平级)`,onClick:()=>!f&&v([`*`,...p]),children:`全局`}),[`topic`,`repo`,`group`].map(e=>(0,_.jsx)(`button`,{type:`button`,className:`${m}-scope-add-btn`+(l===e?` on`:``),onClick:()=>u(l===e?null:e),children:w[e]},e)),g?(0,_.jsxs)(`span`,{className:`${m}-scope-origin`,title:`创建于主题 ${n}`,children:[`创建于 `,g]}):null]}),l&&(0,_.jsx)(`div`,{className:`${m}-scope-pick`,role:`listbox`,"aria-label":`选择可见对象`,children:b.length?b.map(e=>(0,_.jsxs)(`button`,{type:`button`,className:`${m}-scope-pick-it`,disabled:d.includes(e.entry),title:e.sub||e.entry,onClick:()=>y(e.entry),children:[(0,_.jsx)(`span`,{className:`${m}-scope-pick-name`,children:e.label}),d.includes(e.entry)?(0,_.jsx)(`span`,{className:`${m}-scope-pick-done`,children:`已加`}):null]},e.entry)):(0,_.jsx)(`div`,{className:`${m}-scope-pick-empty`,children:`暂无可选项`})})]})}function O({openTemplateEditor:e}){let t=c(),r=i(),{dialog:a,node:o}=n(),s=t.templates||[],[l,u]=(0,h.useState)(null),[d,f]=(0,h.useState)(!1);if(t.unsupported)return(0,_.jsx)(`div`,{className:`setp-note`,children:`当前服务比面板旧——重启面板后才有模板功能。`});let m=async(e,t)=>{if(!d){f(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{f(!1)}}},g=async e=>{await a({title:`删除模板「${e.name}」`,danger:!0,okText:`删除`})&&(await m(()=>t.remove(e.id),`已删除「${e.name}」`),l===e.id&&u(null))};return(0,_.jsxs)(`div`,{className:`setp-tpl setp-tpl-cards`,children:[o,!s.length&&(0,_.jsx)(`div`,{className:`setp-note`,children:`还没有模板(内置默认模板加载中…)。`}),s.map(n=>{let r=n.id===t.defaultId,i=l===n.id;return(0,_.jsxs)(`div`,{className:`setp-tpl-card`+(r?` is-default`:``),children:[(0,_.jsxs)(`div`,{className:`setp-tpl-card-head`,children:[(0,_.jsx)(`span`,{className:`setp-tpl-card-name`,children:n.name}),r&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`默认`}),n.builtin&&(0,_.jsx)(`span`,{className:`setp-badge soft`,children:`内置`})]}),i&&(0,_.jsx)(`div`,{className:`setp-tpl-card-scope`,children:(0,_.jsx)(D,{scope:n.scope,originTopic:n.originTopic,onChange:e=>t.update(n.id,{scope:e})})}),(0,_.jsxs)(`div`,{className:`setp-tpl-card-foot`,children:[(0,_.jsx)(`span`,{className:`grow`}),(0,_.jsx)(p,{variant:`secondary`,disabled:d,onClick:()=>u(i?null:n.id),children:`可见绑定`}),(0,_.jsx)(p,{variant:`secondary`,disabled:d,onClick:()=>e?.({id:n.id,name:n.name,mode:`edit`}),children:`编辑`}),!r&&(0,_.jsx)(p,{variant:`secondary`,disabled:d,onClick:()=>m(()=>t.setDefault(n.id),`默认模板已设为「${n.name}」`),children:`设为默认`}),!n.builtin&&(0,_.jsx)(p,{variant:`secondary`,disabled:d,onClick:()=>g(n),children:`删除`})]})]},n.id)}),(0,_.jsx)(`div`,{className:`setp-tpl-card-new`,children:(0,_.jsx)(p,{variant:`secondary`,disabled:d,onClick:()=>e?.({mode:`new`,scope:[]}),children:`+ 新建模板`})})]})}function k(){let e=i(),t=s(),n=t.patchPrefs,[a,o]=(0,h.useState)([]),[c,l]=(0,h.useState)([]),[u,d]=(0,h.useState)([]),f=(0,h.useCallback)(()=>{Promise.all([r(`/api/repos`),r(`/api/boards`)]).then(([e,n])=>{o(Array.isArray(e)?e:e?.repos||[]),l(Array.isArray(n)?n:n?.boards||[]),d(t.prefs?.hidden||[])}).catch(t=>e(`读取失败:`+(t.message||t)))},[e,t.prefs]);(0,h.useEffect)(()=>{f()},[f]);let p=e=>{let r=t.prefs?.hidden||[],i=r.includes(e)?r.filter(t=>t!==e):[...r,e];n&&n({hidden:i}),d(i)},m=(e,t,n,r)=>(0,_.jsx)(`div`,{className:`setp-row`,children:(0,_.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`},children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:!u.includes(t),onChange:()=>p(t)}),(0,_.jsx)(`span`,{children:n}),r?(0,_.jsx)(`span`,{className:`mono faint`,children:r}):null]})},e+`:`+t);return(0,_.jsxs)(`div`,{className:`setp-side`,children:[(0,_.jsx)(`div`,{className:`setp-note`,children:`勾掉的项目组 / 项目不在侧边栏显示(登记与数据都留着,随时勾回来)。`}),(0,_.jsx)(`div`,{className:`setp-row`,children:(0,_.jsx)(`span`,{children:`项目组(指针)`})}),c.map(e=>m(`board`,e.key||e.id,e.name,`${(e.repos||[]).length} 个模块`)),!c.length&&(0,_.jsx)(`div`,{className:`setp-note`,children:`还没有项目组。`}),(0,_.jsx)(`div`,{className:`setp-row`,children:(0,_.jsx)(`span`,{children:`项目 / 仓库(模块)`})}),a.map(e=>m(`repo`,e.key||e.id,e.name,e.path)),!a.length&&(0,_.jsx)(`div`,{className:`setp-note`,children:`还没有登记仓库。`})]})}var A=[{id:`pref`,label:`偏好`,icon:`flow`},{id:`work`,label:`工作区`,icon:`sidebar`},{id:`cloud`,label:`云端与存储`,icon:`cloud`},{id:`taskTemplates`,label:`任务模板`,icon:`list`},{id:`prompts`,label:`提示词模板`,icon:`flow`},{id:`sidebar`,label:`侧栏显示`,icon:`sidebar`}];function j(){let e=s(),t=i(),{dialog:o,node:c}=n(),u=e.prefs,d=e.patchPrefs||(()=>{}),f=e.model,[m,g]=(0,h.useState)(`pref`),[v,y]=(0,h.useState)(null),[b,x]=(0,h.useState)(!1),S=(0,h.useCallback)(async()=>{try{y(await r(`/api/setting`))}catch(e){t(`读取设置失败:`+(e.message||e))}},[t]);(0,h.useEffect)(()=>{S()},[S]);let w=e=>e().catch(e=>t(String(e.message||e))),T=e=>w(async()=>{x(!0);try{y(await r(`/api/setting`,{method:`POST`,body:e})),t(`已保存`)}finally{x(!1)}}),E={pref:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`侧边栏默认收起`}),(0,_.jsxs)(`button`,{className:`toggle`+(u?.defaultFolded?` on`:``),onClick:()=>d({defaultFolded:!u?.defaultFolded}),children:[(0,_.jsx)(`span`,{className:`dot`}),u?.defaultFolded?`开`:`关`]})]}),(u?.hidden||[]).length>0&&(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsxs)(`span`,{children:[`隐藏仓库 `,u?.hidden?.length,` 个`]}),(0,_.jsx)(p,{variant:`secondary`,onClick:()=>d({hidden:[]}),children:`恢复显示`})]})]}),work:(0,_.jsx)(_.Fragment,{children:(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`布局`}),(0,_.jsx)(p,{variant:`secondary`,onClick:async()=>{await o({title:`重置为初始两栏`,message:`丢掉存下来的布局,回到初始的两栏(目录 + 开始)?`,okText:`重置`})&&e.shell&&e.shell.resetLayout()},children:`重置为初始两栏`})]})}),cloud:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`读任务时自动下载附件`}),(0,_.jsxs)(`button`,{className:`toggle`+(v&&v.autoSyncAttachments?` on`:``),disabled:!v||b,onClick:()=>v&&T({autoSyncAttachments:!v.autoSyncAttachments}),children:[(0,_.jsx)(`span`,{className:`dot`}),v&&v.autoSyncAttachments?`开`:`关`]})]}),(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`附件目录`}),(0,_.jsxs)(`span`,{className:`setp-input`,children:[(0,_.jsx)(`input`,{value:v&&v.attachmentsDir||``,placeholder:`(默认 ~/.nx-kv/attachments/)`,onChange:e=>y(t=>({...t||{},attachmentsDir:e.target.value}))}),(0,_.jsx)(p,{variant:`secondary`,disabled:!v||b,onClick:()=>v&&T({attachmentsDir:v.attachmentsDir}),children:`保存`})]})]}),(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`参考仓库存储根`}),(0,_.jsxs)(`span`,{className:`setp-input`,children:[(0,_.jsx)(`input`,{value:v&&v.gitRepoRoot||``,placeholder:`(未设置 —— clone 参考仓库前先设)`,onChange:e=>y(t=>({...t||{},gitRepoRoot:e.target.value}))}),(0,_.jsx)(p,{variant:`secondary`,disabled:!v||b,onClick:()=>v&&T({gitRepoRoot:v.gitRepoRoot}),children:`保存`})]})]}),(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`开发仓库克隆根`}),(0,_.jsxs)(`span`,{className:`setp-input`,children:[(0,_.jsx)(`input`,{value:v&&v.gitDevRoot||``,placeholder:`(未设置 —— 导入布局时只登记不克隆)`,onChange:e=>y(t=>({...t||{},gitDevRoot:e.target.value}))}),(0,_.jsx)(p,{variant:`secondary`,disabled:!v||b,onClick:()=>v&&T({gitDevRoot:v.gitDevRoot}),children:`保存`})]})]})]}),taskTemplates:(0,_.jsx)(O,{openTemplateEditor:e=>{f&&l(f,e||{})}}),prompts:(0,_.jsx)(C,{}),sidebar:(0,_.jsx)(k,{})};return(0,_.jsxs)(`div`,{className:`setp`,children:[(0,_.jsx)(`nav`,{className:`setp-nav`,"aria-label":`设置分区`,children:A.map(e=>(0,_.jsxs)(`button`,{className:`setp-navitem`+(m===e.id?` on`:``),"aria-current":m===e.id,onClick:()=>g(e.id),children:[(0,_.jsx)(a,{name:e.icon,size:14}),(0,_.jsx)(`span`,{children:e.label})]},e.id))}),(0,_.jsxs)(`div`,{className:`setp-body`,children:[(0,_.jsx)(`div`,{className:`setp-h`,children:A.find(e=>e.id===m)?.label}),E[m]]}),c]})}export{j as default};