nx-kv 0.24.3 → 0.24.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/web/frontend/modules/md/md-parse.js +7 -10
- package/src/web/frontend/modules/md/style.css +6 -14
- package/src/web/frontend/page/progress/index.jsx +15 -33
- package/src/web/public/assets/{Introduction-DK2deIP2.js → Introduction-BBa-4_6Z.js} +1 -1
- package/src/web/public/assets/{cloud-BoIeutoa.js → cloud-CwSnw032.js} +3 -3
- package/src/web/public/assets/dag-Bim4kjF5.js +1 -0
- package/src/web/public/assets/{dir-BbDWEJOC.js → dir-BLYJYwXR.js} +3 -3
- package/src/web/public/assets/{group-C30SuifL.js → group-CuItVQ7O.js} +1 -1
- package/src/web/public/assets/{index-DFMD9MV2.js → index-CHdHAdre.js} +3 -3
- package/src/web/public/assets/{index--c-rj9Y8.css → index-CZKjjAtp.css} +1 -1
- package/src/web/public/assets/{md-history-DBs3hhRL.js → md-history-SmO9nIjG.js} +3 -3
- package/src/web/public/assets/{member-picker-xneI-u00.js → member-picker-ALREB8wV.js} +1 -1
- package/src/web/public/assets/{overview-Ai76EDG0.js → overview-Cy57M5-L.js} +1 -1
- package/src/web/public/assets/progress-Cfoo3BaU.js +3 -0
- package/src/web/public/assets/{repos-CMmB-5Nj.js → repos-zVVQVKkN.js} +6 -6
- package/src/web/public/assets/{route-crumb-D3TTGwPj.js → route-crumb-BhxIQoEf.js} +1 -1
- package/src/web/public/assets/{settings-D81FsMru.js → settings-DWDjGIdJ.js} +3 -3
- package/src/web/public/assets/task-B7WFtHgb.js +5 -0
- package/src/web/public/assets/{template-slots-DLN_zed3.js → template-slots-BquXVLBT.js} +1 -1
- package/src/web/public/assets/{templates-DnYaTa0s.js → templates-MH2eUUKs.js} +1 -1
- package/src/web/public/assets/{upload-DAjZdYV0.js → upload-Ct2hlWdn.js} +1 -1
- package/src/web/public/index.html +2 -2
- package/src/web/public/assets/dag-DC3tN4dI.js +0 -1
- package/src/web/public/assets/progress-DRKqpuh_.js +0 -3
- package/src/web/public/assets/task-w3pgQWfV.js +0 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{d as e,f as t,h as n}from"./attach-v8BxRJ7p.js";import{
|
|
2
|
-
---`,3);e>0&&(t=t.slice(e+4).trimStart())}return/^#[ \t]+\S/.test(t)}function E(e){e&&(e.style.height=`0px`,e.style.height=`${e.scrollHeight}px`)}function D(e,t){let n=
|
|
1
|
+
import{d as e,f as t,h as n}from"./attach-v8BxRJ7p.js";import{J as r,_ as i,g as a,h as o,m as s,v as c}from"./index-CHdHAdre.js";import{a as l,c as u,d,f,g as p,h as m,i as h,l as g,m as _,n as v,o as y,p as b,r as x,s as ee,u as te}from"./md-edit-ops-Bl0Zx0aJ.js";var S=n(t(),1),ne=r(),C=e(),w={b:`bold`,i:`italic`,e:`code`,k:`link`};function T(e){let t=String(e||``).replace(/^\uFEFF/,``).trimStart();if(t.startsWith(`---`)){let e=t.indexOf(`
|
|
2
|
+
---`,3);e>0&&(t=t.slice(e+4).trimStart())}return/^#[ \t]+\S/.test(t)}function E(e){e&&(e.style.height=`0px`,e.style.height=`${e.scrollHeight}px`)}function D(e,t){let n=i(e);return n.trim()?c(n,t).replace(/<p class="mdw-empty">[\s\S]*?<\/p>/g,``):``}function re(e){let t=String(e||``);return/^---\s*$/.test(t.split(`
|
|
3
3
|
`,1)[0]||``)&&t.includes(`
|
|
4
|
-
`)?`fm`:/^#\s/m.test(t)&&!/^##/m.test(t)?`h1`:/^##\s/m.test(t)&&!/^###/m.test(t)?`h2`:/^###\s/m.test(t)?`h3`:/^[-*]\s/m.test(t)?`li`:/^>\s/m.test(t)?`quote`:`p`}function ie({index:e,text:t,focused:n,hit:r,onFocus:i,onChange:a,onBlur:c,onKeyDown:l,onPasteFiles:u,onTaReady:d,onTextSel:p,attachments:m,pendingSelRef:h,pendingFormatRef:_}){let v=(0,S.useRef)(null),y=s(t),b=D(y,m),x=re(y);return(0,S.useLayoutEffect)(()=>{if(!n||!v.current)return;let t=v.current;d?.(t),E(t);let r=h?.current;if(r&&r.index===e){h.current=null,t.focus();try{t.setSelectionRange(r.start,r.end)}catch{}let e=_?.current;if(e){_.current=null;let n=f(t,e);n&&a(n.value)}return}if(document.activeElement!==t){t.focus();let e=t.value.length;try{t.setSelectionRange(e,e)}catch{}}},[n,t,e,h,_,d,a]),n?(0,C.jsx)(`div`,{className:`mdw-lp-block is-edit kind-${x}`,"data-i":e,children:(0,C.jsx)(`textarea`,{ref:v,className:`mdw-lp-src`,value:y,rows:1,spellCheck:!1,"aria-label":`正文`,placeholder:`输入… Enter 新块 · 行首 / 命令`,onChange:e=>{a(e.target.value),E(e.target)},onBlur:c,onKeyDown:l,onPaste:e=>{let t=g(e.clipboardData);t.length&&(e.preventDefault(),u?.(t,v.current))},onMouseUp:e=>{let t=v.current;if(!t||t.selectionStart===t.selectionEnd)return;let n=t.value.slice(t.selectionStart,t.selectionEnd);n&&p?.({text:n,x:e.clientX-80,y:e.clientY-44})}})}):(0,C.jsx)(`div`,{className:`mdw-lp-block is-view kind-${x}${o(t)?` is-empty`:``}${r?` is-hit`:``}`,"data-i":e,role:`button`,tabIndex:0,onClick:()=>{let t=window.getSelection();t&&!t.isCollapsed&&String(t).trim()||i(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),i(e))},children:b?(0,C.jsx)(`div`,{className:`mdw-lp-view`,dangerouslySetInnerHTML:{__html:b}}):(0,C.jsx)(`div`,{className:`mdw-lp-gap`})})}function O(e){return i(e)}function k(e){return e.key===`ArrowDown`||e.key===`ArrowUp`||e.code===`ArrowDown`||e.code===`ArrowUp`}function A(e){if(!e?.items?.length)return 0;let t=e.active;return typeof t!=`number`||Number.isNaN(t)?0:Math.min(Math.max(0,t),e.items.length-1)}function j(e,t,{move:n,pick:r,close:i}){let a=t.current;return a?.items?.length?k(e)?(e.preventDefault(),e.stopPropagation(),n(e.key===`ArrowUp`||e.code===`ArrowUp`?-1:1),!0):e.key===`Enter`||e.key===`Tab`?(e.preventDefault(),e.stopPropagation(),r(a.items[A(a)]),!0):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i(),!0):!1}function ae({items:e,active:t,onPick:n,onHover:r,style:i}){let a=(0,S.useRef)(null),o=A({items:e,active:t});return(0,S.useEffect)(()=>{let e=a.current;e&&e.querySelector(`.mdw-slash-item.on`)?.scrollIntoView?.({block:`nearest`})},[o,e]),e.length?(0,C.jsxs)(`div`,{ref:a,className:`mdw-slash`,role:`listbox`,"aria-activedescendant":`mdw-slash-opt-${o}`,style:i,onMouseDown:e=>e.preventDefault(),children:[(0,C.jsx)(`div`,{className:`mdw-slash-cap`,children:`插入 · ↑↓ 选择 · Enter 确认`}),e.map((e,t)=>(0,C.jsxs)(`button`,{id:`mdw-slash-opt-${t}`,type:`button`,role:`option`,tabIndex:-1,"aria-selected":t===o,className:`mdw-slash-item${t===o?` on`:``}`,onMouseEnter:()=>r(t),onMouseDown:t=>{t.preventDefault(),n(e)},children:[(0,C.jsx)(`span`,{className:`lab`,children:e.label}),(0,C.jsx)(`span`,{className:`hint`,children:e.hint})]},e.id))]}):null}function oe({value:e,onTitle:t,placeholder:n,className:r,onFocus:i,onEnter:a}){let o=(0,S.useRef)(null);return(0,S.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=()=>{e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e]),(0,C.jsx)(`textarea`,{ref:o,className:r,value:e,placeholder:n,rows:1,spellCheck:!1,"aria-label":`标题`,onChange:e=>t(e.target.value,`typing`),onFocus:i,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),a?.())}})}function M({title:e,body:t,onTitle:n,onBody:r,articleRef:i,attachments:c,docKey:l,onFiles:u,editorApiRef:d,onTextSel:p,onCloseSelMenu:b}){let[x,w]=(0,S.useState)(null),[T,E]=(0,S.useState)(!1),[D,re]=(0,S.useState)(null),k=(0,S.useRef)(null),M=(0,S.useRef)(null),N=(0,S.useRef)(null),P=(0,S.useRef)(null),F=(0,S.useRef)(0),I=O(t),[L,R]=(0,S.useState)(!1),[z,B]=(0,S.useState)(``),[V,ce]=(0,S.useState)(0),H=(0,S.useRef)(null),U=(0,S.useMemo)(()=>{let e=z.trim().toLowerCase();if(!e)return[];let t=[];return I.forEach((n,r)=>{let i=String(n??``).toLowerCase(),a=i.indexOf(e);for(;a!==-1;)t.push({block:r,start:a}),a=i.indexOf(e,a+e.length)}),t},[I,z]),W=e=>{let t=U.length;if(!t)return;let n=(e%t+t)%t;ce(n);let r=U[n];(i.current?.querySelector(`.mdw-lp-block[data-i="${r.block}"]`))?.scrollIntoView?.({block:`center`})},G=U[V]?.block??-1,K=I.length===0||I.every(e=>!String(e).trim()),q=e=>{let t=typeof e==`function`?e(P.current):e;P.current=t,re(t)};(0,S.useEffect)(()=>{w(null),q(null)},[l]),(0,S.useEffect)(()=>{P.current=D},[D]);let J=(e,t=`op`)=>r(a(e),t),Y=(e,t,n=`op`)=>{let r=I.slice();r[e]=t,J(r,n)},X=(e,t)=>{t&&(k.current={index:e,start:t.start,end:t.end},Y(e,t.value))},Z=(e,t)=>{let n=_(t);if(!n){q(null);return}let r=ee(n.query);if(!r.length){q(null);return}let i=t.getBoundingClientRect(),a=Math.min(window.innerWidth-220,i.left),o=Math.min(window.innerHeight-220,i.bottom+4);q(t=>{let i=t&&t.index===e&&t.query===n.query?A({...t,items:r}):0;return{index:e,query:n.query,items:r,active:i,x:a,y:o}})},Q=e=>{q(t=>{if(!t?.items?.length)return t;let n=t.items.length,r=A(t);return{...t,active:(r+e+n)%n}})},$=e=>{let t=N.current,n=P.current?.index??x;if(!t||n==null||!e)return;let r=v(t,e);q(null),r&&X(n,r)},le=(e,t)=>{let n=N.current,r=n&&x===e?n:{value:s(I[e]??``),selectionStart:0,selectionEnd:0},i=m(r,t);i&&(X(e,i),w(e))};(0,S.useImperativeHandle)(d,()=>({format(e){let t=N.current;t&&x!=null&&(t.focus(),X(x,f(t,e)))},turn(e){le(x??0,e)},focus(){N.current?.focus()},openFind(){R(!0),requestAnimationFrame(()=>H.current?.focus())},formatSelection(e){let t=window.getSelection();if(!t||t.isCollapsed)return!1;let n=String(t.toString()||``);if(!n.trim())return!1;let r=t.anchorNode,a=(r?.nodeType===3?r.parentElement:r)?.closest?.(`.mdw-lp-block`);if(!a||!i.current?.contains(a))return!1;let o=Number(a.getAttribute(`data-i`));if(!Number.isInteger(o)||o<0||o>=I.length)return!1;let c=s(I[o]??``).indexOf(n);return c!==-1&&(k.current={index:o,start:c,end:c+n.length},M.current=e,b?.(),w(o),!0)},caretFromDiff(e,t){let n=a(O(e)),r=a(O(t)),i=y(n,r),o=0;for(let e=0;e<I.length;e+=1){let t=a(I.slice(0,e+1)).length;if(i<=t){let t=Math.max(0,Math.min(i-o,s(I[e]??``).length));if(x===e){let e=N.current;e&&(e.focus(),e.setSelectionRange(t,t))}else k.current={index:e,start:t,end:t},w(e);return}o=t+2}}}),[x,r,I]),(0,S.useEffect)(()=>{if(!D)return;let e=e=>{j(e,P,{move:Q,pick:$,close:()=>q(null)})};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[D]);let ue=(e,t)=>{let n=s(I[e]??``),r=t.target;if(N.current=r,j(t,P,{move:Q,pick:$,close:()=>q(null)}))return;if(t.key===`Escape`){t.preventDefault(),q(null),r.blur(),w(null);return}let i=t.metaKey||t.ctrlKey;if(i&&!t.altKey){let n=t.key.toLowerCase(),i={b:`bold`,i:`italic`,e:`code`,k:`link`};if(i[n]){t.preventDefault(),X(e,f(r,i[n]));return}}if(t.key===`Tab`){t.preventDefault(),X(e,te(r,t.shiftKey));return}if(t.key===`Enter`&&!t.shiftKey&&!i){let i=h(r);if(i){t.preventDefault(),X(e,i);return}t.preventDefault(),q(null);let a=r.selectionStart,o=r.selectionEnd,s=n.slice(0,a).replace(/\n+$/,``),c=n.slice(o),l=I.slice();l[e]=s,l.splice(e+1,0,c),k.current={index:e+1,start:0,end:0},J(l),w(e+1);return}if(t.key===`Backspace`&&o(n)&&I.length>1){t.preventDefault(),q(null);let n=I.slice();n.splice(e,1),J(n),w(Math.max(0,e-1));return}P.current||(t.key===`ArrowUp`&&t.target.selectionStart===0&&e>0&&(t.preventDefault(),w(e-1)),t.key===`ArrowDown`&&t.target.selectionStart===n.length&&e<I.length-1&&(t.preventDefault(),w(e+1)))},de=(e,t)=>{e?.length&&u&&u(e,{mode:`live`,focusIndex:x,caretInBlock:t?t.selectionStart:null})};return(0,C.jsxs)(`div`,{className:`mdw-lp${T?` is-drop`:``}`,onDragEnter:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),E(!0))},onDragOver:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||E(!1)},onDrop:e=>{E(!1);let t=g(e.dataTransfer);t.length&&(e.preventDefault(),de(t,null))},children:[(0,C.jsxs)(`div`,{className:`mdw-lp-sheet`,ref:i,children:[L&&(0,C.jsx)(se,{query:z,setQuery:e=>{B(e),ce(0)},index:V,total:U.length,onNext:()=>W(V+1),onPrev:()=>W(V-1),onClose:()=>R(!1),inputRef:H}),(0,C.jsx)(oe,{className:`mdw-lp-title`,value:e,placeholder:`无标题`,onTitle:n,onFocus:()=>{w(null),q(null)},onEnter:()=>{I.length&&w(0)}}),(0,C.jsx)(`div`,{className:`mdw-lp-blocks${K?` is-empty-doc`:``}`,children:I.map((e,t)=>(0,C.jsx)(ie,{index:t,text:e,focused:x===t,hit:G===t,attachments:c,pendingSelRef:k,pendingFormatRef:M,onFocus:e=>{w(e),q(null)},onTaReady:e=>{N.current=e},onChange:e=>{Y(t,e,`typing`),cancelAnimationFrame(F.current),F.current=requestAnimationFrame(()=>{let e=N.current;e&&Z(t,e)})},onBlur:()=>{requestAnimationFrame(()=>{document.activeElement?.closest?.(`.mdw-lp-block.is-edit`)||document.activeElement?.closest?.(`.mdw-slash`)||(w(null),q(null))})},onKeyDown:e=>ue(t,e),onPasteFiles:(e,t)=>de(e,t),onTextSel:p},`${l}-${t}`))}),K&&x===null?(0,C.jsx)(`button`,{type:`button`,className:`mdw-lp-add is-empty-hint`,"aria-label":`开始输入`,onClick:()=>w(0),children:(0,C.jsx)(`span`,{className:`mdw-lp-add-hint`,children:`输入正文,或键入 / 唤起命令…`})}):(0,C.jsx)(`button`,{type:`button`,className:`mdw-lp-add`,"aria-label":`继续输入`,onClick:()=>{J([...I,``]),w(I.length)}})]}),D&&(0,ne.createPortal)((0,C.jsx)(ae,{items:D.items,active:D.active,onHover:e=>q(t=>t&&{...t,active:e}),onPick:$,style:{left:D.x,top:D.y}}),document.body)]})}function se({query:e,setQuery:t,index:n,total:r,onNext:i,onPrev:a,onClose:o,inputRef:s}){return(0,C.jsxs)(`div`,{className:`mdw-find`,role:`search`,children:[(0,C.jsx)(`input`,{ref:s,className:`mdw-find-input`,value:e,placeholder:`查找…`,"aria-label":`查找`,onChange:e=>t(e.target.value),onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),o();return}e.key===`Enter`&&(e.preventDefault(),e.shiftKey?a():i()),e.key===`F3`&&(e.preventDefault(),e.shiftKey?a():i())}}),(0,C.jsx)(`span`,{className:`mdw-find-count`,children:r?`${n+1}/${r}`:`无结果`}),(0,C.jsx)(`button`,{type:`button`,className:`mdw-find-nav`,title:`上一个`,"aria-label":`上一个匹配`,onClick:a,children:`↑`}),(0,C.jsx)(`button`,{type:`button`,className:`mdw-find-nav`,title:`下一个`,"aria-label":`下一个匹配`,onClick:i,children:`↓`}),(0,C.jsx)(`button`,{type:`button`,className:`mdw-find-nav`,title:`关闭`,"aria-label":`关闭查找`,onClick:o,children:`×`})]})}function N({title:e,body:t,onTitle:n,onBody:r,editorApiRef:i,onFiles:a,onTextSel:o}){let s=(0,S.useRef)(null),c=(0,S.useRef)(null),m=(0,S.useRef)(null),w=(0,S.useRef)(null),[T,E]=(0,S.useState)(!0),[D,re]=(0,S.useState)(!0),[ie,O]=(0,S.useState)(!1),[k,M]=(0,S.useState)(!1),[N,P]=(0,S.useState)(``),[F,I]=(0,S.useState)(0),[L,R]=(0,S.useState)({line:1,col:1}),[z,B]=(0,S.useState)(!0),[V,ce]=(0,S.useState)(null),H=(0,S.useRef)(null),U=(0,S.useRef)(0),W=l(t),G=u(t,N),K=e=>{let t=typeof e==`function`?e(H.current):e;H.current=t,ce(t)};(0,S.useEffect)(()=>{H.current=V},[V]);let q=()=>{let e=s.current;e&&R(x(e.value,e.selectionStart))},J=e=>{let t=_(e);if(!t){K(null);return}let n=ee(t.query);if(!n.length){K(null);return}let r=e.getBoundingClientRect(),i=x(e.value,e.selectionStart).line,a=Math.min(window.innerWidth-220,r.left+12),o=Math.min(window.innerHeight-220,r.top+i*20-e.scrollTop+8);K(e=>{let r=e&&e.query===t.query?A({...e,items:n}):0;return{query:t.query,items:n,active:r,x:a,y:o}})},Y=e=>{K(t=>{if(!t?.items?.length)return t;let n=t.items.length,r=A(t);return{...t,active:(r+e+n)%n}})},X=e=>{e&&(w.current={start:e.start,end:e.end},r(e.value))},Z=e=>{let t=s.current;if(!t||!e)return;let n=v(t,e);K(null),n&&X(n)};(0,S.useEffect)(()=>{if(!V)return;let e=e=>{j(e,H,{move:Y,pick:Z,close:()=>K(null)})};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[V]),(0,S.useLayoutEffect)(()=>{let e=w.current,t=s.current;if(e&&t){w.current=null;try{t.setSelectionRange(e.start,e.end)}catch{}}},[t]),(0,S.useEffect)(()=>{k&&(m.current?.focus(),m.current?.select())},[k]),(0,S.useEffect)(()=>{I(0)},[N,t]);let Q=e=>{let t=s.current;if(!t||!G.length)return;let n=(e%G.length+G.length)%G.length;I(n);let r=G[n];t.focus();try{t.setSelectionRange(r.start,r.end)}catch{}b(t,r.start),requestAnimationFrame(()=>m.current?.focus())},$=()=>{M(!0);let e=s.current;if(e&&e.selectionStart!==e.selectionEnd){let t=e.value.slice(e.selectionStart,e.selectionEnd);t&&!t.includes(`
|
|
4
|
+
`)?`fm`:/^#\s/m.test(t)&&!/^##/m.test(t)?`h1`:/^##\s/m.test(t)&&!/^###/m.test(t)?`h2`:/^###\s/m.test(t)?`h3`:/^[-*]\s/m.test(t)?`li`:/^>\s/m.test(t)?`quote`:`p`}function ie({index:e,text:t,focused:n,hit:r,onFocus:a,onChange:o,onBlur:c,onKeyDown:l,onPasteFiles:u,onTaReady:d,onTextSel:p,attachments:m,pendingSelRef:h,pendingFormatRef:_}){let v=(0,S.useRef)(null),y=i(t),b=D(y,m),x=re(y);return(0,S.useLayoutEffect)(()=>{if(!n||!v.current)return;let t=v.current;d?.(t),E(t);let r=h?.current;if(r&&r.index===e){h.current=null,t.focus();try{t.setSelectionRange(r.start,r.end)}catch{}let e=_?.current;if(e){_.current=null;let n=f(t,e);n&&o(n.value)}return}if(document.activeElement!==t){t.focus();let e=t.value.length;try{t.setSelectionRange(e,e)}catch{}}},[n,t,e,h,_,d,o]),n?(0,C.jsx)(`div`,{className:`mdw-lp-block is-edit kind-${x}`,"data-i":e,children:(0,C.jsx)(`textarea`,{ref:v,className:`mdw-lp-src`,value:y,rows:1,spellCheck:!1,"aria-label":`正文`,placeholder:`输入… Enter 新块 · 行首 / 命令`,onChange:e=>{o(e.target.value),E(e.target)},onBlur:c,onKeyDown:l,onPaste:e=>{let t=g(e.clipboardData);t.length&&(e.preventDefault(),u?.(t,v.current))},onMouseUp:e=>{let t=v.current;if(!t||t.selectionStart===t.selectionEnd)return;let n=t.value.slice(t.selectionStart,t.selectionEnd);n&&p?.({text:n,x:e.clientX-80,y:e.clientY-44})}})}):(0,C.jsx)(`div`,{className:`mdw-lp-block is-view kind-${x}${s(t)?` is-empty`:``}${r?` is-hit`:``}`,"data-i":e,role:`button`,tabIndex:0,onClick:()=>{let t=window.getSelection();t&&!t.isCollapsed&&String(t).trim()||a(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e))},children:b?(0,C.jsx)(`div`,{className:`mdw-lp-view`,dangerouslySetInnerHTML:{__html:b}}):(0,C.jsx)(`div`,{className:`mdw-lp-gap`})})}function O(e){return a(e)}function k(e){return e.key===`ArrowDown`||e.key===`ArrowUp`||e.code===`ArrowDown`||e.code===`ArrowUp`}function A(e){if(!e?.items?.length)return 0;let t=e.active;return typeof t!=`number`||Number.isNaN(t)?0:Math.min(Math.max(0,t),e.items.length-1)}function j(e,t,{move:n,pick:r,close:i}){let a=t.current;return a?.items?.length?k(e)?(e.preventDefault(),e.stopPropagation(),n(e.key===`ArrowUp`||e.code===`ArrowUp`?-1:1),!0):e.key===`Enter`||e.key===`Tab`?(e.preventDefault(),e.stopPropagation(),r(a.items[A(a)]),!0):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i(),!0):!1}function ae({items:e,active:t,onPick:n,onHover:r,style:i}){let a=(0,S.useRef)(null),o=A({items:e,active:t});return(0,S.useEffect)(()=>{let e=a.current;e&&e.querySelector(`.mdw-slash-item.on`)?.scrollIntoView?.({block:`nearest`})},[o,e]),e.length?(0,C.jsxs)(`div`,{ref:a,className:`mdw-slash`,role:`listbox`,"aria-activedescendant":`mdw-slash-opt-${o}`,style:i,onMouseDown:e=>e.preventDefault(),children:[(0,C.jsx)(`div`,{className:`mdw-slash-cap`,children:`插入 · ↑↓ 选择 · Enter 确认`}),e.map((e,t)=>(0,C.jsxs)(`button`,{id:`mdw-slash-opt-${t}`,type:`button`,role:`option`,tabIndex:-1,"aria-selected":t===o,className:`mdw-slash-item${t===o?` on`:``}`,onMouseEnter:()=>r(t),onMouseDown:t=>{t.preventDefault(),n(e)},children:[(0,C.jsx)(`span`,{className:`lab`,children:e.label}),(0,C.jsx)(`span`,{className:`hint`,children:e.hint})]},e.id))]}):null}function oe({value:e,onTitle:t,placeholder:n,className:r,onFocus:i,onEnter:a}){let o=(0,S.useRef)(null);return(0,S.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=()=>{e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e]),(0,C.jsx)(`textarea`,{ref:o,className:r,value:e,placeholder:n,rows:1,spellCheck:!1,"aria-label":`标题`,onChange:e=>t(e.target.value,`typing`),onFocus:i,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),a?.())}})}function M({title:e,body:t,onTitle:n,onBody:r,articleRef:a,attachments:c,docKey:l,onFiles:u,editorApiRef:d,onTextSel:p,onCloseSelMenu:b}){let[x,w]=(0,S.useState)(null),[T,E]=(0,S.useState)(!1),[D,re]=(0,S.useState)(null),k=(0,S.useRef)(null),M=(0,S.useRef)(null),N=(0,S.useRef)(null),P=(0,S.useRef)(null),F=(0,S.useRef)(0),I=O(t),[L,R]=(0,S.useState)(!1),[z,B]=(0,S.useState)(``),[V,ce]=(0,S.useState)(0),H=(0,S.useRef)(null),U=(0,S.useMemo)(()=>{let e=z.trim().toLowerCase();if(!e)return[];let t=[];return I.forEach((n,r)=>{let i=String(n??``).toLowerCase(),a=i.indexOf(e);for(;a!==-1;)t.push({block:r,start:a}),a=i.indexOf(e,a+e.length)}),t},[I,z]),W=e=>{let t=U.length;if(!t)return;let n=(e%t+t)%t;ce(n);let r=U[n];(a.current?.querySelector(`.mdw-lp-block[data-i="${r.block}"]`))?.scrollIntoView?.({block:`center`})},G=U[V]?.block??-1,K=I.length===0||I.every(e=>!String(e).trim()),q=e=>{let t=typeof e==`function`?e(P.current):e;P.current=t,re(t)};(0,S.useEffect)(()=>{w(null),q(null)},[l]),(0,S.useEffect)(()=>{P.current=D},[D]);let J=(e,t=`op`)=>r(o(e),t),Y=(e,t,n=`op`)=>{let r=I.slice();r[e]=t,J(r,n)},X=(e,t)=>{t&&(k.current={index:e,start:t.start,end:t.end},Y(e,t.value))},Z=(e,t)=>{let n=_(t);if(!n){q(null);return}let r=ee(n.query);if(!r.length){q(null);return}let i=t.getBoundingClientRect(),a=Math.min(window.innerWidth-220,i.left),o=Math.min(window.innerHeight-220,i.bottom+4);q(t=>{let i=t&&t.index===e&&t.query===n.query?A({...t,items:r}):0;return{index:e,query:n.query,items:r,active:i,x:a,y:o}})},Q=e=>{q(t=>{if(!t?.items?.length)return t;let n=t.items.length,r=A(t);return{...t,active:(r+e+n)%n}})},$=e=>{let t=N.current,n=P.current?.index??x;if(!t||n==null||!e)return;let r=v(t,e);q(null),r&&X(n,r)},le=(e,t)=>{let n=N.current,r=n&&x===e?n:{value:i(I[e]??``),selectionStart:0,selectionEnd:0},a=m(r,t);a&&(X(e,a),w(e))};(0,S.useImperativeHandle)(d,()=>({format(e){let t=N.current;t&&x!=null&&(t.focus(),X(x,f(t,e)))},turn(e){le(x??0,e)},focus(){N.current?.focus()},openFind(){R(!0),requestAnimationFrame(()=>H.current?.focus())},formatSelection(e){let t=window.getSelection();if(!t||t.isCollapsed)return!1;let n=String(t.toString()||``);if(!n.trim())return!1;let r=t.anchorNode,o=(r?.nodeType===3?r.parentElement:r)?.closest?.(`.mdw-lp-block`);if(!o||!a.current?.contains(o))return!1;let s=Number(o.getAttribute(`data-i`));if(!Number.isInteger(s)||s<0||s>=I.length)return!1;let c=i(I[s]??``).indexOf(n);return c!==-1&&(k.current={index:s,start:c,end:c+n.length},M.current=e,b?.(),w(s),!0)},caretFromDiff(e,t){let n=o(O(e)),r=o(O(t)),a=y(n,r),s=0;for(let e=0;e<I.length;e+=1){let t=o(I.slice(0,e+1)).length;if(a<=t){let t=Math.max(0,Math.min(a-s,i(I[e]??``).length));if(x===e){let e=N.current;e&&(e.focus(),e.setSelectionRange(t,t))}else k.current={index:e,start:t,end:t},w(e);return}s=t+2}}}),[x,r,I]),(0,S.useEffect)(()=>{if(!D)return;let e=e=>{j(e,P,{move:Q,pick:$,close:()=>q(null)})};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[D]);let ue=(e,t)=>{let n=i(I[e]??``),r=t.target;if(N.current=r,j(t,P,{move:Q,pick:$,close:()=>q(null)}))return;if(t.key===`Escape`){t.preventDefault(),q(null),r.blur(),w(null);return}let a=t.metaKey||t.ctrlKey;if(a&&!t.altKey){let n=t.key.toLowerCase(),i={b:`bold`,i:`italic`,e:`code`,k:`link`};if(i[n]){t.preventDefault(),X(e,f(r,i[n]));return}}if(t.key===`Tab`){t.preventDefault(),X(e,te(r,t.shiftKey));return}if(t.key===`Enter`&&!t.shiftKey&&!a){let i=h(r);if(i){t.preventDefault(),X(e,i);return}t.preventDefault(),q(null);let a=r.selectionStart,o=r.selectionEnd,s=n.slice(0,a).replace(/\n+$/,``),c=n.slice(o),l=I.slice();l[e]=s,l.splice(e+1,0,c),k.current={index:e+1,start:0,end:0},J(l),w(e+1);return}if(t.key===`Backspace`&&s(n)&&I.length>1){t.preventDefault(),q(null);let n=I.slice();n.splice(e,1),J(n),w(Math.max(0,e-1));return}P.current||(t.key===`ArrowUp`&&t.target.selectionStart===0&&e>0&&(t.preventDefault(),w(e-1)),t.key===`ArrowDown`&&t.target.selectionStart===n.length&&e<I.length-1&&(t.preventDefault(),w(e+1)))},de=(e,t)=>{e?.length&&u&&u(e,{mode:`live`,focusIndex:x,caretInBlock:t?t.selectionStart:null})};return(0,C.jsxs)(`div`,{className:`mdw-lp${T?` is-drop`:``}`,onDragEnter:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),E(!0))},onDragOver:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||E(!1)},onDrop:e=>{E(!1);let t=g(e.dataTransfer);t.length&&(e.preventDefault(),de(t,null))},children:[(0,C.jsxs)(`div`,{className:`mdw-lp-sheet`,ref:a,children:[L&&(0,C.jsx)(se,{query:z,setQuery:e=>{B(e),ce(0)},index:V,total:U.length,onNext:()=>W(V+1),onPrev:()=>W(V-1),onClose:()=>R(!1),inputRef:H}),(0,C.jsx)(oe,{className:`mdw-lp-title`,value:e,placeholder:`无标题`,onTitle:n,onFocus:()=>{w(null),q(null)},onEnter:()=>{I.length&&w(0)}}),(0,C.jsx)(`div`,{className:`mdw-lp-blocks${K?` is-empty-doc`:``}`,children:I.map((e,t)=>(0,C.jsx)(ie,{index:t,text:e,focused:x===t,hit:G===t,attachments:c,pendingSelRef:k,pendingFormatRef:M,onFocus:e=>{w(e),q(null)},onTaReady:e=>{N.current=e},onChange:e=>{Y(t,e,`typing`),cancelAnimationFrame(F.current),F.current=requestAnimationFrame(()=>{let e=N.current;e&&Z(t,e)})},onBlur:()=>{requestAnimationFrame(()=>{document.activeElement?.closest?.(`.mdw-lp-block.is-edit`)||document.activeElement?.closest?.(`.mdw-slash`)||(w(null),q(null))})},onKeyDown:e=>ue(t,e),onPasteFiles:(e,t)=>de(e,t),onTextSel:p},`${l}-${t}`))}),K&&x===null?(0,C.jsx)(`button`,{type:`button`,className:`mdw-lp-add is-empty-hint`,"aria-label":`开始输入`,onClick:()=>w(0),children:(0,C.jsx)(`span`,{className:`mdw-lp-add-hint`,children:`输入正文,或键入 / 唤起命令…`})}):(0,C.jsx)(`button`,{type:`button`,className:`mdw-lp-add`,"aria-label":`继续输入`,onClick:()=>{J([...I,``]),w(I.length)}})]}),D&&(0,ne.createPortal)((0,C.jsx)(ae,{items:D.items,active:D.active,onHover:e=>q(t=>t&&{...t,active:e}),onPick:$,style:{left:D.x,top:D.y}}),document.body)]})}function se({query:e,setQuery:t,index:n,total:r,onNext:i,onPrev:a,onClose:o,inputRef:s}){return(0,C.jsxs)(`div`,{className:`mdw-find`,role:`search`,children:[(0,C.jsx)(`input`,{ref:s,className:`mdw-find-input`,value:e,placeholder:`查找…`,"aria-label":`查找`,onChange:e=>t(e.target.value),onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),o();return}e.key===`Enter`&&(e.preventDefault(),e.shiftKey?a():i()),e.key===`F3`&&(e.preventDefault(),e.shiftKey?a():i())}}),(0,C.jsx)(`span`,{className:`mdw-find-count`,children:r?`${n+1}/${r}`:`无结果`}),(0,C.jsx)(`button`,{type:`button`,className:`mdw-find-nav`,title:`上一个`,"aria-label":`上一个匹配`,onClick:a,children:`↑`}),(0,C.jsx)(`button`,{type:`button`,className:`mdw-find-nav`,title:`下一个`,"aria-label":`下一个匹配`,onClick:i,children:`↓`}),(0,C.jsx)(`button`,{type:`button`,className:`mdw-find-nav`,title:`关闭`,"aria-label":`关闭查找`,onClick:o,children:`×`})]})}function N({title:e,body:t,onTitle:n,onBody:r,editorApiRef:i,onFiles:a,onTextSel:o}){let s=(0,S.useRef)(null),c=(0,S.useRef)(null),m=(0,S.useRef)(null),w=(0,S.useRef)(null),[T,E]=(0,S.useState)(!0),[D,re]=(0,S.useState)(!0),[ie,O]=(0,S.useState)(!1),[k,M]=(0,S.useState)(!1),[N,P]=(0,S.useState)(``),[F,I]=(0,S.useState)(0),[L,R]=(0,S.useState)({line:1,col:1}),[z,B]=(0,S.useState)(!0),[V,ce]=(0,S.useState)(null),H=(0,S.useRef)(null),U=(0,S.useRef)(0),W=l(t),G=u(t,N),K=e=>{let t=typeof e==`function`?e(H.current):e;H.current=t,ce(t)};(0,S.useEffect)(()=>{H.current=V},[V]);let q=()=>{let e=s.current;e&&R(x(e.value,e.selectionStart))},J=e=>{let t=_(e);if(!t){K(null);return}let n=ee(t.query);if(!n.length){K(null);return}let r=e.getBoundingClientRect(),i=x(e.value,e.selectionStart).line,a=Math.min(window.innerWidth-220,r.left+12),o=Math.min(window.innerHeight-220,r.top+i*20-e.scrollTop+8);K(e=>{let r=e&&e.query===t.query?A({...e,items:n}):0;return{query:t.query,items:n,active:r,x:a,y:o}})},Y=e=>{K(t=>{if(!t?.items?.length)return t;let n=t.items.length,r=A(t);return{...t,active:(r+e+n)%n}})},X=e=>{e&&(w.current={start:e.start,end:e.end},r(e.value))},Z=e=>{let t=s.current;if(!t||!e)return;let n=v(t,e);K(null),n&&X(n)};(0,S.useEffect)(()=>{if(!V)return;let e=e=>{j(e,H,{move:Y,pick:Z,close:()=>K(null)})};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[V]),(0,S.useLayoutEffect)(()=>{let e=w.current,t=s.current;if(e&&t){w.current=null;try{t.setSelectionRange(e.start,e.end)}catch{}}},[t]),(0,S.useEffect)(()=>{k&&(m.current?.focus(),m.current?.select())},[k]),(0,S.useEffect)(()=>{I(0)},[N,t]);let Q=e=>{let t=s.current;if(!t||!G.length)return;let n=(e%G.length+G.length)%G.length;I(n);let r=G[n];t.focus();try{t.setSelectionRange(r.start,r.end)}catch{}b(t,r.start),requestAnimationFrame(()=>m.current?.focus())},$=()=>{M(!0);let e=s.current;if(e&&e.selectionStart!==e.selectionEnd){let t=e.value.slice(e.selectionStart,e.selectionEnd);t&&!t.includes(`
|
|
5
5
|
`)&&t.length<80&&P(t)}};(0,S.useImperativeHandle)(i,()=>({format(e){let t=s.current;t&&(t.focus(),X(f(t,e)))},turn(e){let t=s.current;t&&(t.focus(),X(p(t,e)))},insertAtCursor(e){let t=s.current;t&&X(d(t,e))},getCursor(){let e=s.current;return e?e.selectionStart:null},caretFromDiff(e,t){let n=s.current;if(!n)return;let r=Math.min(y(e,t),n.value.length);n.focus(),n.setSelectionRange(r,r)},toggleWrap(){E(e=>!e)},getWrap:()=>T,openFind:$,focus(){s.current?.focus()}}),[r,T]);let le=e=>{let t=s.current;if(!t||j(e,H,{move:Y,pick:Z,close:()=>K(null)}))return;let n=e.metaKey||e.ctrlKey;if(n&&!e.altKey&&e.key.toLowerCase()===`f`){e.preventDefault(),$();return}if(e.key===`F3`){e.preventDefault(),k?e.shiftKey?Q(F-1):Q(F+1):$();return}if(n&&!e.altKey){let n=e.key.toLowerCase(),r={b:`bold`,i:`italic`,e:`code`,k:`link`};if(r[n]){e.preventDefault(),X(f(t,r[n]));return}}if(e.key===`Tab`){e.preventDefault(),X(te(t,e.shiftKey));return}if(e.key===`Enter`&&!e.shiftKey&&!n){let n=h(t);n&&(e.preventDefault(),X(n)),K(null)}},ue=e=>{if(!e?.length||!a)return;let t=s.current;a(e,{insertAt:t?t.selectionStart:null,mode:`edit`})},de=()=>{c.current&&s.current&&(c.current.scrollTop=s.current.scrollTop)},fe=D?Array.from({length:Math.max(1,W.lines)},(e,t)=>t+1):null;return(0,C.jsxs)(`div`,{className:`mdw-pane mdw-pane-edit${ie?` is-drop`:``}`,onDragEnter:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),O(!0))},onDragOver:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||O(!1)},onDrop:e=>{O(!1);let t=g(e.dataTransfer);t.length&&(e.preventDefault(),ue(t))},children:[(0,C.jsx)(oe,{className:`mdw-title-input`,value:e,placeholder:`任务标题`,onTitle:n,onEnter:()=>{let e=s.current;e&&(e.focus(),e.setSelectionRange(0,0))}}),k&&(0,C.jsx)(se,{query:N,setQuery:P,index:F,total:G.length,inputRef:m,onNext:()=>Q(F+1),onPrev:()=>Q(F-1),onClose:()=>{M(!1),s.current?.focus()}}),(0,C.jsxs)(`div`,{className:`mdw-editor-row${D?` has-gutter`:``}${z?` has-ruler`:``}`,children:[D&&(0,C.jsx)(`div`,{className:`mdw-gutter`,ref:c,"aria-hidden":!0,children:fe.map(e=>(0,C.jsx)(`div`,{className:`mdw-gutter-ln`,children:e},e))}),(0,C.jsxs)(`div`,{className:`mdw-editor-stage`,children:[z&&(0,C.jsx)(`div`,{className:`mdw-ruler`,"aria-hidden":!0,title:`约 80 字符参考`}),(0,C.jsx)(`textarea`,{ref:s,className:`mdw-editor${T?` is-wrap`:` is-nowrap`}`,value:t,spellCheck:!1,wrap:T?`soft`:`off`,"aria-label":`正文源码`,placeholder:`用 Markdown 写任务——行首 / 出命令 · Ctrl/⌘F 查找 · Ctrl/⌘B 粗体`,onChange:e=>{r(e.target.value,`typing`),q(),cancelAnimationFrame(U.current),U.current=requestAnimationFrame(()=>{s.current&&J(s.current)})},onKeyDown:le,onKeyUp:q,onClick:()=>{q(),_(s.current)||K(null)},onSelect:q,onScroll:de,onPaste:e=>{let t=g(e.clipboardData);t.length&&(e.preventDefault(),ue(t))},onMouseUp:e=>{q();let t=s.current;if(!t||t.selectionStart===t.selectionEnd){o?.(null);return}let n=t.value.slice(t.selectionStart,t.selectionEnd);n&&o?.({text:n,x:e.clientX-80,y:e.clientY-44})}})]})]}),(0,C.jsxs)(`div`,{className:`mdw-editor-status`,role:`status`,children:[(0,C.jsxs)(`span`,{children:[`Ln `,L.line,`, Col `,L.col]}),(0,C.jsxs)(`span`,{children:[W.lines,` 行`]}),(0,C.jsxs)(`span`,{children:[W.words,` 词`]}),(0,C.jsxs)(`span`,{children:[W.chars,` 字`]}),(0,C.jsx)(`button`,{type:`button`,className:`mdw-wrap-toggle${D?` on`:``}`,title:`显示/隐藏行号`,onClick:()=>re(e=>!e),children:`行号`}),(0,C.jsx)(`button`,{type:`button`,className:`mdw-wrap-toggle${z?` on`:``}`,title:`80 字符参考线`,onClick:()=>B(e=>!e),children:`参考线`}),(0,C.jsx)(`button`,{type:`button`,className:`mdw-wrap-toggle${k?` on`:``}`,title:`查找 Ctrl/⌘F`,onClick:()=>k?M(!1):$(),children:`查找`}),(0,C.jsx)(`button`,{type:`button`,className:`mdw-wrap-toggle${T?` on`:``}`,title:T?`自动换行开(点击关闭)`:`自动换行关(点击开启)`,onClick:()=>E(e=>!e),children:T?`换行`:`不换行`})]}),V&&(0,ne.createPortal)((0,C.jsx)(ae,{items:V.items,active:V.active,onHover:e=>K(t=>t&&{...t,active:e}),onPick:Z,style:{left:V.x,top:V.y}}),document.body)]})}var P=(0,S.forwardRef)(function({mode:e,title:t,body:n,previewHtml:r,onTitle:i,onBody:a,attachments:o=[],docKey:s=`draft`,editorApiRef:c=null,onFiles:l=null,onTextSel:u=null,onSave:d=null,onUndo:f=null,onRedo:p=null,onCloseSelMenu:m=null},h){return(0,S.useEffect)(()=>{let t=t=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let n=t.target;if(!n||typeof n.closest!=`function`)return;let r=t.key.toLowerCase(),i=n.closest(`.mdw-editor,.mdw-lp-src,.mdw-lp-title,.mdw-title-input`);if(r===`f`&&e!==`edit`){if(!n.closest(`.mdw`))return;t.preventDefault(),c.current?.openFind?.();return}if(!i){e===`split`&&w[r]&&c.current?.formatSelection?.(w[r])&&t.preventDefault();return}if(r===`s`){t.preventDefault(),d?.();return}if(r===`z`){t.preventDefault(),t.shiftKey?p?.():f?.();return}r===`y`&&(t.preventDefault(),p?.())};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[d,f,p,e,c]),e===`split`?(0,C.jsx)(`div`,{className:`mdw-split mode-split live`,children:(0,C.jsx)(M,{title:t,body:n,onTitle:i,onBody:a,articleRef:h,attachments:o,docKey:s,onFiles:l,editorApiRef:c,onTextSel:u,onCloseSelMenu:m})}):(0,C.jsxs)(`div`,{className:`mdw-split mode-${e}`,children:[e===`edit`&&(0,C.jsx)(N,{title:t,body:n,onTitle:i,onBody:a,editorApiRef:c,onFiles:l,onTextSel:u}),e===`preview`&&(0,C.jsx)(`div`,{className:`mdw-pane mdw-preview`,children:(0,C.jsxs)(`div`,{className:`mdw-reader`,children:[t&&!T(n)?(0,C.jsx)(`h1`,{className:`mdw-reader-title`,children:t}):null,(0,C.jsx)(`article`,{ref:h,dangerouslySetInnerHTML:{__html:r}})]})})]})}),F=[{id:`split`,label:`实时预览`},{id:`edit`,label:`源码`},{id:`preview`,label:`阅读`}];function I({mode:e,onChange:t}){return(0,C.jsx)(`div`,{className:`seg`,role:`tablist`,"aria-label":`编辑模式`,children:F.map(n=>(0,C.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===n.id,className:e===n.id?`on`:``,onClick:()=>t(n.id),children:n.label},n.id))})}var L=700;function R(e,t,n,r=`op`){if(!t)return;let i=e.get(t)||{past:[],future:[],lastAt:0},a=Date.now(),o=r===`typing`;o&&a-i.lastAt<L&&i.past.length>0?i.past[i.past.length-1]=n:(i.past.push(n),i.past.length>200&&i.past.shift()),i.future=[],i.lastAt=o?a:0,e.set(t,i)}function z(e,t,n){let r=e.get(t);if(!r||!r.past.length)return null;let i=r.past.pop();return r.future.unshift(n),r.future.length>200&&r.future.pop(),r.lastAt=0,i}function B(e,t,n){let r=e.get(t);if(!r||!r.future.length)return null;let i=r.future.shift();return r.past.push(n),r.lastAt=0,i}function V(e,t){e.delete(t)}export{P as a,z as i,R as n,I as o,B as r,V as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,f as t,h as n,r,s as i,u as a}from"./attach-v8BxRJ7p.js";import{
|
|
1
|
+
import{d as e,f as t,h as n,r,s as i,u as a}from"./attach-v8BxRJ7p.js";import{K as o}from"./index-CHdHAdre.js";var s=n(t(),1),c=e(),l=(e,...t)=>!e||t.some(t=>String(t||``).toLowerCase().includes(e)),u=e=>{let t=String(e.path||``).replace(/[\\/]+$/,``);if(!t)return``;let n=t.split(/[\\/]/);return n.length>1&&n[n.length-1].toLowerCase()===String(e.name||``).toLowerCase()&&n.pop(),n.join(`/`)};function d({board:e,boards:t=[],repos:n=[],onClose:d,onChanged:f}){let p=a(),[m,h]=(0,s.useState)(``),[g,_]=(0,s.useState)({}),[v,y]=(0,s.useState)(``),b=(0,s.useMemo)(()=>e&&e.repos||[],[e]),x=(0,s.useMemo)(()=>new Set(b.map(e=>e.key)),[b]),S=e=>e in g?g[e]:x.has(e),C=(0,s.useMemo)(()=>t.filter(t=>t.id!==e.id),[t,e.id]),w=(0,s.useMemo)(()=>n.filter(e=>(e.type||`dev`)!==`ref`),[n]),T=(0,s.useMemo)(()=>b.filter(e=>e.present===!1),[b]),E=String(m||``).trim().toLowerCase(),D=(0,s.useMemo)(()=>w.filter(e=>l(E,e.name,e.path,e.desc,e.key,...(e.boards||[]).map(e=>e.name))),[w,E]),O=(0,s.useMemo)(()=>C.filter(e=>l(E,e.name,e.desc)),[C,E]),k=(0,s.useMemo)(()=>T.filter(e=>l(E,e.name,e.key,e.remote)),[T,E]),A=async(t,n)=>{_(e=>({...e,[t]:n}));try{await o(`/api/boards/assign`,{method:`POST`,body:n?{id:t,board:e.id}:{id:t,board:e.id,remove:!0}}),f&&f()}catch(e){_(e=>{let n={...e};return delete n[t],n}),p(String(e&&e.message||e))}},j=async t=>{let n=(t.repos||[]).filter(e=>e.present!==!1).map(e=>e.key).filter(e=>!S(e));if(n.length){y(t.id);try{for(let t of n)await o(`/api/boards/assign`,{method:`POST`,body:{id:t,board:e.id}});_(e=>{let t={...e};for(let e of n)t[e]=!0;return t}),p(`已并入 ${n.length} 个成员`),f&&f()}catch(e){p(String(e&&e.message||e))}finally{y(``)}}},M=async e=>{y(e.key);try{await o(`/api/repos/clone`,{method:`POST`,body:{remote:e.remote,key:e.key,type:e.type||`dev`,depth:1}}),p(`已克隆:${e.name||e.key}`),f&&f()}catch(e){p(String(e&&e.message||e))}finally{y(``)}},N=!D.length&&!O.length&&!k.length;return(0,c.jsx)(r,{title:`${e.name} · 成员`,onClose:d,size:`lg`,className:`rp-mp-box`,children:(0,c.jsxs)(`div`,{children:[(0,c.jsxs)(`div`,{className:`rp-mp-search`,children:[(0,c.jsx)(i,{name:`search`,size:13}),(0,c.jsx)(`input`,{autoFocus:!0,value:m,placeholder:`搜项目或项目组`,onChange:e=>h(e.target.value)}),(0,c.jsxs)(`span`,{className:`rp-mp-count`,children:[D.length+k.length,` 个项目 · `,O.length,` 个组`]})]}),N?(0,c.jsx)(`div`,{className:`rp-mp-empty`,children:`没有匹配项`}):null,O.length?(0,c.jsxs)(`div`,{className:`rp-mp-sec`,children:[(0,c.jsxs)(`div`,{className:`rp-mp-sec-h`,children:[`项目组 `,(0,c.jsx)(`b`,{children:O.length})]}),O.map(e=>{let t=(e.repos||[]).length,n=(e.repos||[]).filter(e=>e.present!==!1&&!S(e.key)).length;return(0,c.jsxs)(`div`,{className:`rp-mp-row`,children:[(0,c.jsx)(i,{name:`folder`,size:13}),(0,c.jsx)(`span`,{className:`rp-mp-name`,children:e.name}),(0,c.jsx)(`span`,{className:`rp-mp-sub`,children:e.desc||``}),(0,c.jsxs)(`span`,{className:`rp-mp-meta`,children:[t,` 个成员`]}),t?(0,c.jsx)(`button`,{className:`btn small`+(n?``:` ghost`),disabled:!n||v===e.id,title:n?`把「${e.name}」的 ${n} 个项目加进本组`:`这个组的项目已在本组`,onClick:()=>j(e),children:n?`并入 ${n}`:`已并入`}):(0,c.jsx)(`span`,{className:`rp-mp-meta`,children:`空组`})]},e.id)})]}):null,D.length||k.length?(0,c.jsxs)(`div`,{className:`rp-mp-sec`,children:[(0,c.jsxs)(`div`,{className:`rp-mp-sec-h`,children:[`项目 `,(0,c.jsx)(`b`,{children:D.length+k.length})]}),k.map(e=>(0,c.jsxs)(`div`,{className:`rp-mp-row rp-mp-ghost`,children:[(0,c.jsx)(i,{name:`folder`,size:13}),(0,c.jsx)(`span`,{className:`rp-mp-name`,children:e.name||e.key}),(0,c.jsx)(`span`,{className:`rp-mp-sub mono`,children:e.remote||e.key}),(0,c.jsx)(`span`,{className:`rp-mp-meta`,children:`本机未登记`}),e.clonable?(0,c.jsx)(`button`,{className:`btn small ghost`,disabled:v===e.key,title:`按这个 key 克隆到本地,补齐这个位置`,onClick:()=>M(e),children:`克隆`}):null]},`g:`+e.key)),D.map(t=>{let n=S(t.key),r=(t.boards||[]).filter(t=>t.id!==e.id);return(0,c.jsxs)(`div`,{className:`rp-mp-row`+(n?` on`:``),children:[(0,c.jsx)(i,{name:`folder`,size:13}),(0,c.jsx)(`span`,{className:`rp-mp-name`,children:t.name}),(0,c.jsx)(`span`,{className:`rp-mp-sub mono`,title:t.path,children:u(t)}),r.length?(0,c.jsx)(`span`,{className:`rp-mp-tags`,children:r.map(e=>(0,c.jsx)(`span`,{className:`rp-mp-tag`,children:e.name},e.id))}):null,(0,c.jsx)(`button`,{className:`btn small`+(n?` ghost`:``),title:n?`从「${e.name}」移出`:`加入「${e.name}」`,onClick:()=>A(t.key,!n),children:n?`移出`:`加入`})]},t.key)})]}):null]})})}export{d as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,f as t,h as n,o as r,s as i,u as a}from"./attach-v8BxRJ7p.js";import{
|
|
1
|
+
import{d as e,f as t,h as n,o as r,s as i,u as a}from"./attach-v8BxRJ7p.js";import{B as o,H as s,K as c,S as l}from"./index-CHdHAdre.js";import{t as u}from"./route-crumb-BhxIQoEf.js";var d=n(t(),1),f=e(),p=new Set;function m(e){return e.deletedAt?{label:`已删除`,cls:`t-gone`}:e.migratedTo?{label:`已迁移`,cls:`t-gone`}:e.status===`consumed`?{label:`已领取`,cls:`t-done`}:{label:`待领取`,cls:`t-pend`}}function h({rows:e,onNavigate:t,refreshLocal:n}){let l=a(),{dialog:m,node:h}=r(),[_,v]=(0,d.useState)(()=>new Map),[y,b]=(0,d.useState)(()=>new Set),[x,S]=(0,d.useState)(()=>new Set),C=(0,d.useMemo)(()=>e.filter(e=>!e.isGlobal),[e]),w=e.find(e=>e.isGlobal),T=C.reduce((e,t)=>e+(t.pending||0),0)+(w?.pending||0),E=e.filter(e=>e.waiting),D=e=>e.isGlobal?o:e.key,O=(0,d.useMemo)(()=>{let t=0;for(let n of e){let e=_.get(D(n));if(e&&e.size)for(let r of n.tasks||[])e.has(Number(r.id))&&!r.deletedAt&&(t+=1)}return t},[e,_]),k=e=>_.get(e)||p,A=(e,t)=>{let n=k(e);return n.size?t.map(e=>Number(e.id)).filter(e=>n.has(e)):[]},j=(e,t)=>{v(n=>{let r=new Map(n),i=new Set(r.get(e)||[]);return i.has(t)?i.delete(t):i.add(t),i.size?r.set(e,i):r.delete(e),r})},M=(e,t,n)=>{v(r=>{let i=new Map(r);return n?i.delete(e):i.set(e,new Set(t.map(e=>Number(e.id)))),i})},N=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},P=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},F=async()=>{let t=[];for(let n of e){let e=D(n),r=_.get(e);if(!r||!r.size)continue;let i=(n.tasks||[]).filter(e=>r.has(Number(e.id))&&!e.deletedAt).map(e=>Number(e.id));i.length&&t.push({key:e,name:n.name||e,ids:i})}let r=t.reduce((e,t)=>e+t.ids.length,0);if(!r)return;let i=t.length>1?`(跨 ${t.length} 个目录)`:``;if(!await m({title:`删除 ${r} 条任务${i}`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`}))return;let a=0,o=0,s=[];for(let e of t)try{let t=await c(`/api/localtasks/items`,{method:`DELETE`,body:{key:e.key,ids:e.ids}});a+=Number(t?.count??0),o+=(t?.missing||[]).length}catch(t){let n=String(t.message||t);if(/接口不存在/.test(n)){l(`本机面板服务较旧,重启面板后再试(批量删除接口未上线)`);return}s.push(`${e.name}: ${n}`)}s.length?l(`已删除 ${a} 条;${s.length} 个目录失败:${s[0]}${s.length>1?` 等 ${s.length} 项`:``}`):l(`已删除 ${a} 条${o?`(${o} 条未找到,可能已被删除)`:``}`),v(new Map),n?.()},I=(e,n)=>t(`${e}?task=${encodeURIComponent(n)}`),L=e=>`#/dir/`+encodeURIComponent(e),R=e=>!y.size||y.has(e);return(0,f.jsxs)(`div`,{className:`ov-wrap`,children:[(0,f.jsx)(u,{}),h,(0,f.jsxs)(`div`,{className:`ov-head`,children:[(0,f.jsx)(`h2`,{children:`全部目录总览`}),(0,f.jsxs)(`span`,{className:`muted`,children:[C.length,` 个目录 · 待领取 `,T,E.length?` · ${E.length} 个等待回填`:``]})]}),(0,f.jsxs)(`div`,{className:`ov-chips`,children:[(0,f.jsx)(`span`,{className:`ov-filter-label`,children:`筛选`}),(0,f.jsx)(`button`,{type:`button`,className:`ov-chip`+(y.size?``:` on`),onClick:()=>b(new Set),title:`显示全部目录`,children:`全部`}),w&&(0,f.jsxs)(`button`,{type:`button`,className:`ov-chip`+(y.has(`__GLOBAL__`)?` on`:``)+(w.waiting?` wait`:``),onClick:()=>N(`__GLOBAL__`),title:`筛选:只看全局任务`,children:[(0,f.jsx)(i,{name:`globe`,size:13}),` 全局任务`,(0,f.jsx)(`span`,{className:`c`,children:w.pending||0}),w.waiting&&(0,f.jsx)(`span`,{className:`wdot`})]}),C.map(e=>(0,f.jsxs)(`button`,{type:`button`,className:`ov-chip`+(y.has(e.key)?` on`:``)+(e.waiting?` wait`:``),onClick:()=>N(e.key),title:`筛选:${y.has(e.key)?`取消`:`只看`}「${e.name}」`,children:[(0,f.jsx)(i,{name:`folder`,size:13}),` `,e.name,(0,f.jsx)(`span`,{className:`c`,children:e.pending||0}),e.waiting&&(0,f.jsx)(`span`,{className:`wdot`})]},e.key)),!C.length&&!w&&(0,f.jsx)(`span`,{className:`muted`,children:`暂无目录:在侧边栏点 + 添加,或让 agent 在任意目录提交任务。`})]}),w&&R(`__GLOBAL__`)&&((w.pending||0)>0||w.waiting)&&(0,f.jsx)(g,{secKey:`__GLOBAL__`,icon:`globe`,title:`全局任务`,cwd:``,tasks:w.tasks,waiting:!!w.waiting,selected:A(`__GLOBAL__`,s(w.tasks||[]).pending),doneOpen:x.has(`__GLOBAL__`),onToggle:e=>j(`__GLOBAL__`,e),onToggleAll:(e,t)=>M(`__GLOBAL__`,t,e),onToggleDone:()=>P(`__GLOBAL__`),onOpenDir:()=>t(`#/global`),onOpenTask:e=>I(`#/global`,e)}),C.map(e=>{let n=s(e.tasks||[]);return!R(e.key)||!n.pending.length&&!e.waiting?null:(0,f.jsx)(g,{secKey:e.key,icon:`folder`,title:e.name,cwd:e.cwd,tasks:e.tasks,waiting:!!e.waiting,selected:A(e.key,n.pending),doneOpen:x.has(e.key),onToggle:t=>j(e.key,t),onToggleAll:(t,n)=>M(e.key,n,t),onToggleDone:()=>P(e.key),onOpenDir:()=>t(L(e.key)),onOpenTask:t=>I(L(e.key),t)},e.key)}),y.size>0&&!(w&&R(`__GLOBAL__`)&&((w.pending||0)>0||w.waiting)||C.some(e=>R(e.key)&&(s(e.tasks||[]).pending.length||e.waiting)))&&(0,f.jsx)(`div`,{className:`muted`,style:{padding:`12px 4px`},children:`没有匹配当前筛选的目录。`}),O>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:O}),` 条任务`]}),(0,f.jsx)(`span`,{className:`grow`}),(0,f.jsx)(`button`,{type:`button`,className:`mini`,onClick:()=>v(new Map),children:`取消选择`}),(0,f.jsxs)(`button`,{type:`button`,className:`btn small danger`,onClick:F,children:[`删除选中 `,O]})]})]})}function g({secKey:e,icon:t,title:n,cwd:r,tasks:a,waiting:o,selected:c,doneOpen:l,onToggle:u,onToggleAll:d,onToggleDone:p,onOpenDir:m,onOpenTask:h}){let g=s(a||[]),v=g.pending,y=g.consumed,b=new Set(c),x=v.length>0&&v.every(e=>b.has(Number(e.id))),S=b.size>0&&!x;return(0,f.jsxs)(`section`,{className:`ov-sec`,"data-sec":e,children:[(0,f.jsxs)(`div`,{className:`ov-sec-h`,children:[(0,f.jsx)(i,{name:t,size:13}),(0,f.jsx)(`button`,{type:`button`,className:`ov-sec-t`,onClick:m,title:`进入「${n}」`,children:n}),r?(0,f.jsx)(`span`,{className:`c mono`,children:r}):null,(0,f.jsxs)(`span`,{className:`c`,children:[v.length,` 待领取`]}),o&&(0,f.jsxs)(`span`,{className:`badge-wait`,children:[(0,f.jsx)(`span`,{className:`pulse`}),` 等待回填`]}),(0,f.jsx)(`span`,{className:`grow`}),v.length>0&&(0,f.jsxs)(`label`,{className:`ov-all`,children:[(0,f.jsx)(`input`,{type:`checkbox`,checked:x,ref:e=>{e&&(e.indeterminate=S)},onChange:()=>d(x,v),"aria-label":`全选「${n}」的待领取任务`}),`全选`]})]}),!v.length&&(0,f.jsx)(`div`,{className:`ov-task muted`,children:`(队列为空)`}),v.map(e=>(0,f.jsx)(_,{t:e,checked:b.has(Number(e.id)),onToggle:u,onOpenTask:h},e.id)),y.length>0&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`button`,{type:`button`,className:`ov-done-toggle`,onClick:p,"aria-expanded":l,children:[(0,f.jsx)(`span`,{className:`tri`+(l?` open`:``),"aria-hidden":`true`,children:`▸`}),`已领取 `,y.length]}),l&&y.map(e=>(0,f.jsx)(_,{t:e,checked:b.has(Number(e.id)),onToggle:u,onOpenTask:h,meta:e.consumedAt?String(e.consumedAt).slice(5,16):``},e.id))]})]})}function _({t:e,checked:t,onToggle:n,onOpenTask:r,meta:i=``}){let a=m(e);return(0,f.jsxs)(`div`,{className:`ov-task link`,role:`button`,tabIndex:0,title:`打开任务详情`,onClick:()=>r(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),r(e.id))},children:[(0,f.jsx)(`label`,{className:`ov-ck`,onClick:e=>e.stopPropagation(),children:(0,f.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>n(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:l(e.text,e.text||`未命名任务`)}),e.from===`cloud`&&(0,f.jsx)(`span`,{className:`tag t-cloud`,children:`云端`}),i?(0,f.jsx)(`span`,{className:`m mono`,children:i}):null,(0,f.jsx)(`span`,{className:`tag `+a.cls,children:a.label})]})}export{h as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{d as e,f as t,h as n,o as r,s as i,u as a}from"./attach-v8BxRJ7p.js";import{B as o,C as s,D as c,K as l,O as u,x as d}from"./index-CHdHAdre.js";var f=n(t(),1),p=e();function m(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 h(e,t){if(e.status!==`run`)return`—`;let n=e.receivedAt?Date.parse(e.receivedAt):NaN;return Number.isFinite(n)?m(t-n):`—`}function g({dirKey:e,task:t,rows:n=[],refreshLocal:m,model:g,onOpenTask:_,onClosePage:v,group:y=null}){let b=a(),{dialog:x,node:S}=r(),C=!e||e===`__GLOBAL__`,w=(0,f.useMemo)(()=>C?(n||[]).find(e=>e.isGlobal)||null:(n||[]).find(t=>t.key===e)||null,[n,e,C]),T=(0,f.useMemo)(()=>(w?.tasks||[]).filter(e=>!e.deletedAt),[w]),[E,D]=(0,f.useState)(Date.now()),[O,k]=(0,f.useState)(()=>new Set),[A,j]=(0,f.useState)(!1);(0,f.useEffect)(()=>{let e=setInterval(()=>D(Date.now()),1e3);return()=>clearInterval(e)},[]);let M=(0,f.useMemo)(()=>{if(!y)return[];let e=[y.id,y.key,y.name].filter(Boolean),t=y.repos||[],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=[];for(let t of n||[])if(t&&!t.isGlobal&&Array.isArray(t.tasks))for(let n of t.tasks){if(!n||n.deletedAt)continue;let a={};try{a=s(n.text||``)}catch{a={}}a.board&&e.includes(a.board)&&i.push({...d(n),key:`${t.key}:${n.id}`,taskId:n.id,topicKey:t.key,topicCwd:t.cwd||``,project:a.project||``,projectName:r(a.project,t)})}let a={run:0,wait:1,done:2};return i.sort((e,t)=>(a[e.status]??9)-(a[t.status]??9)||e.projectName.localeCompare(t.projectName)||Number(e.taskId)-Number(t.taskId))},[y,n]),[N,P]=(0,f.useState)(``),F=(0,f.useMemo)(()=>{let e=new Map;for(let t of M)t.projectName&&!e.has(t.projectName)&&e.set(t.projectName,!0);return[...e.keys()]},[M]),I=(0,f.useMemo)(()=>{if(y){let e=N&&F.includes(N)?N:``;return M.filter(t=>!e||t.projectName===e)}let e=T.map(d),t={run:0,wait:1,done:2};return e.sort((e,n)=>(t[e.status]??9)-(t[n.status]??9))},[y,M,N,F,T]),L=e=>y?e.key:e.id;(0,f.useEffect)(()=>{k(e=>{if(!e.size)return e;let t=new Set(I.map(L)),n=new Set([...e].filter(e=>t.has(e)));return n.size===e.size?e:n})},[I,y]);let R=I.filter(e=>e.status===`run`).length,z=I.filter(e=>e.status===`wait`).length,B=I.filter(e=>e.status===`done`).length,V=I.length?Math.round(B*100/I.length):0,H=I.length>0&&O.size===I.length,U=I.filter(e=>O.has(L(e))),W=e=>{k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},G=()=>{k(H?new Set:new Set(I.map(L)))},K=async()=>{if(A||!U.length)return;let t=U.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 x({title:`删除选中的 ${U.length} 条任务`,message:`${n}\n\n软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})){j(!0);try{let t=0,n=0;if(y){let e=new Map;for(let t of U)e.has(t.topicKey)||e.set(t.topicKey,{cwd:t.topicCwd,ids:[]}),e.get(t.topicKey).ids.push(t.taskId);for(let{cwd:r,ids:i}of e.values()){let e=await l(`/api/localtasks/items`,{method:`DELETE`,body:{cwd:r,ids:i}});t+=e?.count??i.length,n+=e?.missing?.length||0}}else{let e=U.map(e=>e.id),r=await l(`/api/localtasks/items`,{method:`DELETE`,body:{...C?{key:o}:{cwd:w.cwd},ids:e}});t=r?.count??e.length,n=r?.missing?.length||0}let r=n?`(${n} 条已不存在)`:``;if(g)for(let t of U){let n=y?t.topicKey:e,r=y?t.taskId:t.id,i=u(g,`page`,{dirKey:n,task:String(r)});i&&v&&v(i.getId())}k(new Set),m(),b(`已删除 ${t} 条任务${r}`)}catch(e){b(`删除失败: `+(e.message||e))}finally{j(!1)}}},q=e=>{_&&(y?_(e.taskId,e.topicKey):_(e.id))},J=t!=null&&String(t)!==``?String(t):``;return(0,p.jsxs)(`div`,{className:`mdw-prog-host`,children:[S,(0,p.jsxs)(`div`,{className:`mdw-prog-h`,children:[(0,p.jsx)(`span`,{className:`t`,children:y?`${y.name} · 任务进程`:w?.name||(C?`全局任务池`:`任务进程`)}),I.length>0&&(0,p.jsx)(`button`,{type:`button`,className:`mdw-prog-all`,onClick:G,title:H?`取消全选`:`全选任务`,children:H?`取消全选`:`全选`}),g&&(0,p.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭进程面板`,"aria-label":`关闭进程面板`,onClick:()=>c(g),children:(0,p.jsx)(i,{name:`x`,size:14})})]}),y&&F.length>1&&(0,p.jsxs)(`div`,{className:`mdw-prog-filters`,role:`tablist`,"aria-label":`按项目筛选进程卡`,children:[(0,p.jsxs)(`button`,{type:`button`,className:`mdw-prog-fchip`+(!N||!F.includes(N)?` on`:``),onClick:()=>P(``),children:[`全部 `,(0,p.jsx)(`b`,{children:M.length})]}),F.map(e=>(0,p.jsxs)(`button`,{type:`button`,className:`mdw-prog-fchip`+(N===e?` on`:``),onClick:()=>P(N===e?``:e),children:[e,` `,(0,p.jsx)(`b`,{children:M.filter(t=>t.projectName===e).length})]},e))]}),(0,p.jsxs)(`div`,{className:`mdw-prog-sum`,children:[(0,p.jsxs)(`div`,{className:`counts`,children:[(0,p.jsxs)(`span`,{className:`run`,children:[`进行中 `,(0,p.jsx)(`b`,{children:R})]}),(0,p.jsxs)(`span`,{className:`wait`,children:[`等待 `,(0,p.jsx)(`b`,{children:z})]}),(0,p.jsxs)(`span`,{className:`done`,children:[`已完成 `,(0,p.jsx)(`b`,{children:B})]})]}),(0,p.jsx)(`div`,{className:`bar`,title:`已完成 ${B} / 共 ${I.length}`,children:(0,p.jsx)(`i`,{style:{width:`${V}%`}})})]}),O.size>0&&(0,p.jsxs)(`div`,{className:`mdw-prog-sel`,children:[(0,p.jsxs)(`span`,{className:`n`,children:[`已选 `,(0,p.jsx)(`b`,{children:O.size}),` / `,I.length]}),(0,p.jsx)(`button`,{type:`button`,className:`mdw-prog-clear`,onClick:()=>k(new Set),children:`清除`}),(0,p.jsxs)(`button`,{type:`button`,className:`mdw-prog-del`,onClick:K,disabled:A,children:[(0,p.jsx)(i,{name:`trash`,size:12}),`删除所选`]})]}),(0,p.jsxs)(`div`,{className:`mdw-prog-list`,children:[!I.length&&(0,p.jsx)(`div`,{className:`mdw-prog-empty`,children:y?(0,p.jsxs)(p.Fragment,{children:[`本组还没有进行中的任务`,(0,p.jsx)(`br`,{}),`在本组创建的任务会出现在这里`]}):(0,p.jsxs)(p.Fragment,{children:[`此目录还没有 MD 任务`,(0,p.jsx)(`br`,{}),`写 MD 提交或导入`]})}),I.map(e=>{let t=L(e),n=O.has(t),r=J!==``&&String(e.taskId??e.id)===J;return(0,p.jsxs)(`div`,{className:`mdw-tcard-row${n?` on`:``}`,children:[(0,p.jsx)(`input`,{type:`checkbox`,className:`mdw-tcard-pick`,checked:n,onChange:()=>W(t),"aria-label":`选择任务 #${e.taskId??e.id} ${e.title}`,title:`选择此任务(可多选后批量删除)`}),(0,p.jsx)(`button`,{type:`button`,className:`mdw-tcard ${e.status}${r?` focus`:``}`,onClick:()=>q(e),children:(0,p.jsxs)(`div`,{className:`mdw-tcard-h`,children:[(0,p.jsx)(`span`,{className:`st ${e.status}`}),(0,p.jsxs)(`div`,{className:`titles`,children:[(0,p.jsxs)(`div`,{className:`n`,children:[e.title,y&&e.projectName&&(0,p.jsx)(`span`,{className:`rp-ptag mdw-tcard-proj`,title:`归属项目:${e.projectName}`,children:e.projectName})]}),(0,p.jsx)(`div`,{className:`sub`,children:e.detail})]}),(0,p.jsx)(`span`,{className:`el ${e.status}`,title:`从领取时刻起计;待领取与已完成回填不计时间`,children:h(e,E)})]})})]},t)})]}),(0,p.jsx)(`div`,{className:`mdw-prog-note`,children:y?`组内各项目的任务聚在这里;可按项目筛选,勾选后批量删除。`:`本目录的任务;点卡打开,勾选后批量删除。`})]})}export{g as default};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{d as e,f as t,h as n,l as r,o as i,r as a,u as ee}from"./attach-v8BxRJ7p.js";import{C as o,G as s,q as c,y as l}from"./index-DFMD9MV2.js";import{t as u}from"./route-crumb-D3TTGwPj.js";import{a as d,o as f}from"./md-history-DBs3hhRL.js";import{r as p}from"./Introduction-DK2deIP2.js";import{t as te}from"./member-picker-xneI-u00.js";var m=n(t(),1),h=e(),g={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function _({onClose:e,onChanged:t,repos:n,boards:i}){let a=r(),o=ee(),[s,l]=(0,m.useState)(`import`),[u,d]=(0,m.useState)({}),[f,p]=(0,m.useState)({}),[te,_]=(0,m.useState)(!1),[v,ne]=(0,m.useState)(``),[y,re]=(0,m.useState)(``),[b,x]=(0,m.useState)(null),[S,C]=(0,m.useState)({}),[w,T]=(0,m.useState)({}),[ie,E]=(0,m.useState)(`ours`),[ae,D]=(0,m.useState)(`none`),[O,oe]=(0,m.useState)(``),[k,A]=(0,m.useState)(null),[j,M]=(0,m.useState)(!1),N=(0,m.useMemo)(()=>n||[],[n]),se=(0,m.useMemo)(()=>N.map(e=>e.key),[N]),ce=(0,m.useMemo)(()=>(i||[]).map(e=>e.name),[i]),P=e=>{let t={};for(let n of se)t[n]=e;d(t)},le=e=>{let t={};for(let n of ce)t[n]=e;p(t)},F=()=>{let e={};for(let t of se)e[t]=!u[t];d(e)},ue=()=>a(async()=>{let e=Object.keys(u).filter(e=>u[e]),t=Object.keys(f).filter(e=>f[e]),n={repos:e.length&&e.length!==se.length?e:void 0,boards:t.length&&t.length!==ce.length?t.map(e=>`board/${e}`):void 0,noUnassigned:te},r=new URLSearchParams;n.repos?.length&&r.set(`repos`,n.repos.join(`,`)),n.boards?.length&&r.set(`boards`,n.boards.join(`,`)),te&&r.set(`no-unassigned`,`1`);let i=await c(`/api/repos/export`+(r.toString()?`?`+r:``));ne(JSON.stringify(i,null,2)),o(`已生成布局:${i.repos.length} 个仓库 / ${i.boards.length} 个看板`)}),de=()=>{if(!v)return;let e=new Blob([v],{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)},I=async e=>{let t=e.target.files?.[0];t&&(re(await t.text()),x(null),A(null))},fe=()=>a(async()=>{if(y.trim()){M(!0);try{let e=await c(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});x(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;C(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;T(n),A(null),o(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{M(!1)}}}),pe=()=>a(async()=>{let e=Object.keys(S).filter(e=>S[e]),n=Object.keys(w).filter(e=>w[e]);M(!0);try{let r=await c(`/api/repos/import`,{method:`POST`,body:{json:y,strategy:ie,clone:ae,selection:e.length?e:void 0,boards:n.length?n:void 0}});A(r),o(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await L(),t&&await t()}finally{M(!1)}}),L=(0,m.useCallback)(async()=>{try{let e=await c(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});x(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;C(t)}catch{}},[y]),R=(0,m.useMemo)(()=>b?O?b.repos.filter(e=>e.status===O):b.repos:[],[b,O]),me=(e,n)=>a(async()=>{if(n){M(!0);try{await c(`/api/repos/clone`,{method:`POST`,body:{remote:n,key:e,type:`ref`,depth:1}}),o(`已克隆: ${e}`),await L(),t&&await t()}finally{M(!1)}}}),he=e=>{let t={...S};for(let n of R)t[n.key]=e;C(t)};(0,m.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(t.stopImmediatePropagation(),e())};return document.addEventListener(`keydown`,t,!0),()=>document.removeEventListener(`keydown`,t,!0)},[e]);let z=(0,m.useMemo)(()=>{if(!b)return null;let e={new:0,changed:0,same:0};for(let t of b.repos)e[t.status]=(e[t.status]||0)+1;return e},[b]);return(0,h.jsx)(`div`,{className:`rp-full`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,h.jsxs)(`div`,{className:`rp-full-box`,children:[(0,h.jsxs)(`div`,{className:`rp-full-head`,children:[(0,h.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,h.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,h.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,h.jsx)(`button`,{className:`rp-tab`+(s===`import`?` on`:``),onClick:()=>l(`import`),children:`导入`}),(0,h.jsx)(`button`,{className:`rp-tab`+(s===`export`?` on`:``),onClick:()=>l(`export`),children:`导出`})]}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:e,children:`关闭`})]}),s===`export`?(0,h.jsxs)(`div`,{className:`rp-full-body`,children:[(0,h.jsxs)(`div`,{className:`rp-full-col`,children:[(0,h.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,h.jsx)(`span`,{children:`导出范围`}),(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>P(!0),children:`全选仓库`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>P(!1),children:`全不选`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:F,children:`反选`})]})]}),(0,h.jsxs)(`div`,{className:`rp-full-sel`,children:[N.map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!u[e.key],onChange:t=>d(n=>({...n,[e.key]:t.target.checked}))}),(0,h.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,h.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),N.length?null:(0,h.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,h.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,h.jsx)(`span`,{children:`看板`}),(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>le(!0),children:`全选`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>le(!1),children:`全不选`})]})]}),(0,h.jsxs)(`div`,{className:`rp-full-sel`,children:[(i||[]).map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!f[e.name],onChange:t=>p(n=>({...n,[e.name]:t.target.checked}))}),(0,h.jsx)(`span`,{children:e.name})]},e.name)),i?.length?null:(0,h.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,h.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:te,onChange:e=>_(e.target.checked)}),(0,h.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn`,onClick:ue,children:`生成布局`}),(0,h.jsx)(`button`,{className:`btn ghost`,disabled:!v,onClick:de,children:`下载 JSON`})]})]}),(0,h.jsxs)(`div`,{className:`rp-full-col`,children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,children:(0,h.jsx)(`span`,{children:`导出结果`})}),(0,h.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:v,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,h.jsxs)(`div`,{className:`rp-full-body`,children:[(0,h.jsxs)(`div`,{className:`rp-full-col`,children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,children:(0,h.jsx)(`span`,{children:`导入来源`})}),(0,h.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:I}),(0,h.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:y,onChange:e=>{re(e.target.value),x(null)}}),(0,h.jsx)(`div`,{className:`form-acts`,children:(0,h.jsx)(`button`,{className:`btn`,disabled:!y.trim()||j,onClick:fe,children:`差异检查`})}),b?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,h.jsx)(`span`,{children:`冲突方案`})}),(0,h.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,h.jsx)(`input`,{type:`radio`,name:`strategy`,checked:ie===e,onChange:()=>E(e)}),(0,h.jsx)(`span`,{children:t})]},e))}),(0,h.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,h.jsx)(`span`,{children:`克隆`})}),(0,h.jsxs)(`select`,{value:ae,onChange:e=>D(e.target.value),children:[(0,h.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,h.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,h.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,h.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,h.jsx)(`div`,{className:`form-acts`,children:(0,h.jsxs)(`button`,{className:`btn`,disabled:j,onClick:pe,children:[`执行导入(已选 `,Object.values(S).filter(Boolean).length,`)`]})})]}):null,k?(0,h.jsxs)(`div`,{className:`rp-import-result`,children:[(0,h.jsxs)(`div`,{children:[`新建 `,k.created.length,` · 覆盖 `,k.updated.length,` · 另存 `,k.duplicated.length,` · 跳过 `,k.skipped.length]}),(0,h.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,k.boardsCreated,` / 合并 `,k.boardsMerged,` · 参考关系 `,k.links]}),k.cloned.length?(0,h.jsxs)(`div`,{children:[`克隆 `,k.cloned.length,` 个`]}):null,k.unmatched.length?(0,h.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,k.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,h.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:b?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,h.jsxs)(`span`,{children:[`差异(新增 `,z.new,` · 有差异 `,z.changed,` · 一致 `,z.same,b.summary.missing?` · 本地未拥有 ${b.summary.missing}`:``,`)`]}),(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`rp-chip`+(O===``?` on`:``),onClick:()=>oe(``),children:`全部`}),(0,h.jsx)(`button`,{className:`rp-chip`+(O===`new`?` on`:``),onClick:()=>oe(`new`),children:`新增`}),(0,h.jsx)(`button`,{className:`rp-chip`+(O===`changed`?` on`:``),onClick:()=>oe(`changed`),children:`有差异`}),(0,h.jsx)(`button`,{className:`rp-chip`+(O===`same`?` on`:``),onClick:()=>oe(`same`),children:`一致`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>he(!0),children:`全选`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>he(!1),children:`全不选`})]})]}),(0,h.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,h.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{style:{width:`32px`}}),(0,h.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,h.jsx)(`th`,{children:`仓库 key`}),(0,h.jsx)(`th`,{children:`差异字段`})]})}),(0,h.jsxs)(`tbody`,{children:[R.map(e=>(0,h.jsxs)(`tr`,{className:`rp-diff-row `+g[e.status]?.cls,children:[(0,h.jsx)(`td`,{children:(0,h.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!S[e.key],onChange:t=>C(n=>({...n,[e.key]:t.target.checked}))})}),(0,h.jsx)(`td`,{children:(0,h.jsx)(`span`,{className:`rp-status `+g[e.status]?.cls,children:g[e.status]?.label})}),(0,h.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,h.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,h.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:j,onClick:()=>me(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,h.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`b`,{children:e.field}),`: `,(0,h.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,h.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,h.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),b.missing.map(e=>(0,h.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,h.jsx)(`td`,{}),(0,h.jsx)(`td`,{children:(0,h.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,h.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,h.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),b.boards.length?(0,h.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,children:(0,h.jsx)(`span`,{children:`看板`})}),b.boards.map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!w[e.key],onChange:t=>T(n=>({...n,[e.key]:t.target.checked}))}),(0,h.jsx)(`span`,{className:`rp-status `+g[e.status]?.cls,children:g[e.status]?.label}),(0,h.jsx)(`span`,{children:e.key}),(0,h.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),b.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,h.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,h.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,h.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,h.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,h.jsx)(`button`,{className:`btn small`,disabled:j,onClick:()=>me(e.key,e.remote),children:`克隆到本地`}):(0,h.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,h.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}function v(e,t){let n=[],r=e.descDocs||null;if(t){let r=(e.boards||[]).find(e=>e.id===t.id),i=r&&r.noteDocRel||``,a=r&&r.noteDocPath||``,ee=a?`path:`+a:i?`rel:`+i:``;ee&&n.push({id:ee,kind:`group`,label:`组内描述`,sub:`「${t.name}」里 ${e.name} 的角色`,note:r&&r.note||``,writable:!a})}let i=r&&r.main;i&&i.docId&&n.push({id:i.docId,kind:`main`,label:i.title||`项目主篇`,sub:i.rel||i.path||``,note:i.summary||``,exists:!!i.exists,writable:!i.path});for(let e of r&&r.links||[])e.docId&&n.push({id:e.docId,kind:`link`,label:e.title||e.docId,sub:e.tag?`#`+e.tag:``,note:e.note||``,writable:String(e.docId).startsWith(`rel:`)});return n}function ne({repo:e,board:t,onClose:n,onSaved:r,onOpenTab:i}){let s=ee(),u=(0,m.useMemo)(()=>v(e,t),[e,t]),[p,te]=(0,m.useState)(()=>u[0]?u[0].id:``),[g,_]=(0,m.useState)(null),[ne,y]=(0,m.useState)(!1),[re,b]=(0,m.useState)(`split`),[x,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(``),T=(0,m.useRef)(null),ie=u.find(e=>e.id===p)||null,E=(0,m.useCallback)(async e=>{if(!e){_(null);return}w(``);try{let t=await c(`/api/docs/item?ref=`+encodeURIComponent(e));_(t),y(!1)}catch(e){w(String(e.message||e)),_(null)}},[]);(0,m.useEffect)(()=>{E(p)},[p,E]);let ae=e=>{y(!0),_(t=>t&&{...t,body:e,title:o(e,t.title)})},D=e=>{y(!0),_(t=>{if(!t)return t;let n=/^#\s+/m.test(t.body)?t.body.replace(/^#\s+.+$/m,`# ${e||`未命名文档`}`):`# ${e||`未命名文档`}\n\n${t.body}`;return{...t,body:n,title:e}})},O=(0,m.useCallback)(async()=>{if(!g||!g.writable||x)return!0;S(!0),w(``);try{let e=g.missing?await c(`/api/docs/item`,{method:`POST`,body:{rel:g.rel,body:g.body}}):await c(`/api/docs/item`,{method:`PATCH`,body:{ref:p,body:g.body}});return _(t=>t&&{...t,missing:!1,summary:e&&e.summary}),y(!1),s&&s(`描述已保存`),r&&r(),!0}catch(e){return w(String(e.message||e)),!1}finally{S(!1)}},[g,x,p,s,r]),oe=async e=>{e!==p&&(ne&&g&&g.writable&&!await O()||te(e))},k=!!(g&&g.writable),A=(0,m.useMemo)(()=>g?l(g.body,[]):``,[g]);return(0,h.jsx)(a,{size:`wide`,title:`描述 · ${e.name}${t?` @「${t.name}」`:``}`,onClose:async()=>{ne&&g&&g.writable&&await O(),n()},children:(0,h.jsxs)(`div`,{className:`rpd`,children:[(0,h.jsxs)(`div`,{className:`rpd-list`,children:[u.length===0?(0,h.jsx)(`div`,{className:`rpd-none`,children:`这个仓库还没有描述文档`}):null,u.map(e=>{let t=e.kind===`link`||!!(e.note||e.exists);return(0,h.jsxs)(`button`,{type:`button`,className:`rpd-item`+(e.id===p?` on`:``),onClick:()=>oe(e.id),title:e.sub||e.label,children:[(0,h.jsxs)(`span`,{className:`rpd-item-top`,children:[(0,h.jsx)(`span`,{className:`rpd-item-label`,children:e.label}),e.kind===`group`?(0,h.jsx)(`span`,{className:`rpd-badge`,children:`组内`}):null,e.kind===`link`&&e.sub?(0,h.jsx)(`span`,{className:`rpd-badge`,children:e.sub}):null,t?null:(0,h.jsx)(`span`,{className:`rpd-todo`,children:`未写`})]}),e.note?(0,h.jsx)(`span`,{className:`rpd-item-note`,children:e.note}):null]},e.id)})]}),(0,h.jsxs)(`div`,{className:`rpd-main`,children:[(0,h.jsxs)(`div`,{className:`rpd-bar`,children:[(0,h.jsx)(`span`,{className:`rpd-path mono`,title:g?g.rel||g.path:``,children:g?g.rel||g.path:ie?ie.sub:``}),ne?(0,h.jsx)(`span`,{className:`rpd-dirty`,children:`未保存`}):null,g&&!k?(0,h.jsx)(`span`,{className:`rpd-badge`,children:`外部 · 只读`}):null,(0,h.jsx)(`span`,{className:`grow`}),k?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(f,{mode:re,onChange:b}),(0,h.jsx)(`button`,{type:`button`,className:`btn small`,disabled:x||!ne,onClick:O,children:x?`保存中…`:`保存`})]}):null,i&&g?(0,h.jsx)(`button`,{type:`button`,className:`btn small ghost`,title:`在文档页签里打开(读全文 / 点双链跳转)`,onClick:()=>{i(p),n()},children:`↗ 页签`}):null]}),C?(0,h.jsx)(`div`,{className:`rpd-err`,children:C}):null,g?(0,h.jsx)(`div`,{className:`rpd-body`,children:(0,h.jsx)(d,{mode:k?re:`preview`,title:g.title,body:g.body,previewHtml:A,onTitle:k?D:null,onBody:k?ae:null,attachments:[],docKey:p,editorApiRef:T,onSave:k?O:null})}):(0,h.jsx)(`div`,{className:`rpd-empty`,children:C?``:`选择左侧的一篇描述开始编辑`})]})]})})}var y={path:``,name:``,desc:``,notes:``,type:`dev`,remote:``};function re({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,h.jsx)(s,{text:t,children:t}):(0,h.jsxs)(s,{text:t,title:`点击复制完整路径`,children:[(0,h.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function b({docs:e,onOpen:t,tip:n=``}){let r=e&&e.main,i=e&&e.links||[];if(!r||!r.title)return null;let a=[n,`主篇:${r.rel||r.path}`,...i.map(e=>(e.tag?`[${e.tag}] `:``)+e.title+(e.note?` —— ${e.note}`:``))].filter(Boolean).join(`
|
|
1
|
+
import{d as e,f as t,h as n,l as r,o as i,r as a,u as ee}from"./attach-v8BxRJ7p.js";import{K as o,S as s,W as c,v as l}from"./index-CHdHAdre.js";import{t as u}from"./route-crumb-BhxIQoEf.js";import{a as d,o as f}from"./md-history-SmO9nIjG.js";import{r as p}from"./Introduction-BBa-4_6Z.js";import{t as te}from"./member-picker-ALREB8wV.js";var m=n(t(),1),h=e(),g={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function _({onClose:e,onChanged:t,repos:n,boards:i}){let a=r(),s=ee(),[c,l]=(0,m.useState)(`import`),[u,d]=(0,m.useState)({}),[f,p]=(0,m.useState)({}),[te,_]=(0,m.useState)(!1),[v,ne]=(0,m.useState)(``),[y,re]=(0,m.useState)(``),[b,x]=(0,m.useState)(null),[S,C]=(0,m.useState)({}),[w,T]=(0,m.useState)({}),[ie,E]=(0,m.useState)(`ours`),[ae,D]=(0,m.useState)(`none`),[O,oe]=(0,m.useState)(``),[k,A]=(0,m.useState)(null),[j,M]=(0,m.useState)(!1),N=(0,m.useMemo)(()=>n||[],[n]),se=(0,m.useMemo)(()=>N.map(e=>e.key),[N]),ce=(0,m.useMemo)(()=>(i||[]).map(e=>e.name),[i]),P=e=>{let t={};for(let n of se)t[n]=e;d(t)},le=e=>{let t={};for(let n of ce)t[n]=e;p(t)},F=()=>{let e={};for(let t of se)e[t]=!u[t];d(e)},ue=()=>a(async()=>{let e=Object.keys(u).filter(e=>u[e]),t=Object.keys(f).filter(e=>f[e]),n={repos:e.length&&e.length!==se.length?e:void 0,boards:t.length&&t.length!==ce.length?t.map(e=>`board/${e}`):void 0,noUnassigned:te},r=new URLSearchParams;n.repos?.length&&r.set(`repos`,n.repos.join(`,`)),n.boards?.length&&r.set(`boards`,n.boards.join(`,`)),te&&r.set(`no-unassigned`,`1`);let i=await o(`/api/repos/export`+(r.toString()?`?`+r:``));ne(JSON.stringify(i,null,2)),s(`已生成布局:${i.repos.length} 个仓库 / ${i.boards.length} 个看板`)}),de=()=>{if(!v)return;let e=new Blob([v],{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)},I=async e=>{let t=e.target.files?.[0];t&&(re(await t.text()),x(null),A(null))},fe=()=>a(async()=>{if(y.trim()){M(!0);try{let e=await o(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});x(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;C(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;T(n),A(null),s(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{M(!1)}}}),pe=()=>a(async()=>{let e=Object.keys(S).filter(e=>S[e]),n=Object.keys(w).filter(e=>w[e]);M(!0);try{let r=await o(`/api/repos/import`,{method:`POST`,body:{json:y,strategy:ie,clone:ae,selection:e.length?e:void 0,boards:n.length?n:void 0}});A(r),s(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await L(),t&&await t()}finally{M(!1)}}),L=(0,m.useCallback)(async()=>{try{let e=await o(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});x(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;C(t)}catch{}},[y]),R=(0,m.useMemo)(()=>b?O?b.repos.filter(e=>e.status===O):b.repos:[],[b,O]),me=(e,n)=>a(async()=>{if(n){M(!0);try{await o(`/api/repos/clone`,{method:`POST`,body:{remote:n,key:e,type:`ref`,depth:1}}),s(`已克隆: ${e}`),await L(),t&&await t()}finally{M(!1)}}}),he=e=>{let t={...S};for(let n of R)t[n.key]=e;C(t)};(0,m.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(t.stopImmediatePropagation(),e())};return document.addEventListener(`keydown`,t,!0),()=>document.removeEventListener(`keydown`,t,!0)},[e]);let z=(0,m.useMemo)(()=>{if(!b)return null;let e={new:0,changed:0,same:0};for(let t of b.repos)e[t.status]=(e[t.status]||0)+1;return e},[b]);return(0,h.jsx)(`div`,{className:`rp-full`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,h.jsxs)(`div`,{className:`rp-full-box`,children:[(0,h.jsxs)(`div`,{className:`rp-full-head`,children:[(0,h.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,h.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,h.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,h.jsx)(`button`,{className:`rp-tab`+(c===`import`?` on`:``),onClick:()=>l(`import`),children:`导入`}),(0,h.jsx)(`button`,{className:`rp-tab`+(c===`export`?` on`:``),onClick:()=>l(`export`),children:`导出`})]}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:e,children:`关闭`})]}),c===`export`?(0,h.jsxs)(`div`,{className:`rp-full-body`,children:[(0,h.jsxs)(`div`,{className:`rp-full-col`,children:[(0,h.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,h.jsx)(`span`,{children:`导出范围`}),(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>P(!0),children:`全选仓库`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>P(!1),children:`全不选`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:F,children:`反选`})]})]}),(0,h.jsxs)(`div`,{className:`rp-full-sel`,children:[N.map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!u[e.key],onChange:t=>d(n=>({...n,[e.key]:t.target.checked}))}),(0,h.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,h.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),N.length?null:(0,h.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,h.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,h.jsx)(`span`,{children:`看板`}),(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>le(!0),children:`全选`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>le(!1),children:`全不选`})]})]}),(0,h.jsxs)(`div`,{className:`rp-full-sel`,children:[(i||[]).map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!f[e.name],onChange:t=>p(n=>({...n,[e.name]:t.target.checked}))}),(0,h.jsx)(`span`,{children:e.name})]},e.name)),i?.length?null:(0,h.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,h.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:te,onChange:e=>_(e.target.checked)}),(0,h.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn`,onClick:ue,children:`生成布局`}),(0,h.jsx)(`button`,{className:`btn ghost`,disabled:!v,onClick:de,children:`下载 JSON`})]})]}),(0,h.jsxs)(`div`,{className:`rp-full-col`,children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,children:(0,h.jsx)(`span`,{children:`导出结果`})}),(0,h.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:v,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,h.jsxs)(`div`,{className:`rp-full-body`,children:[(0,h.jsxs)(`div`,{className:`rp-full-col`,children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,children:(0,h.jsx)(`span`,{children:`导入来源`})}),(0,h.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:I}),(0,h.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:y,onChange:e=>{re(e.target.value),x(null)}}),(0,h.jsx)(`div`,{className:`form-acts`,children:(0,h.jsx)(`button`,{className:`btn`,disabled:!y.trim()||j,onClick:fe,children:`差异检查`})}),b?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,h.jsx)(`span`,{children:`冲突方案`})}),(0,h.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,h.jsx)(`input`,{type:`radio`,name:`strategy`,checked:ie===e,onChange:()=>E(e)}),(0,h.jsx)(`span`,{children:t})]},e))}),(0,h.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,h.jsx)(`span`,{children:`克隆`})}),(0,h.jsxs)(`select`,{value:ae,onChange:e=>D(e.target.value),children:[(0,h.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,h.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,h.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,h.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,h.jsx)(`div`,{className:`form-acts`,children:(0,h.jsxs)(`button`,{className:`btn`,disabled:j,onClick:pe,children:[`执行导入(已选 `,Object.values(S).filter(Boolean).length,`)`]})})]}):null,k?(0,h.jsxs)(`div`,{className:`rp-import-result`,children:[(0,h.jsxs)(`div`,{children:[`新建 `,k.created.length,` · 覆盖 `,k.updated.length,` · 另存 `,k.duplicated.length,` · 跳过 `,k.skipped.length]}),(0,h.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,k.boardsCreated,` / 合并 `,k.boardsMerged,` · 参考关系 `,k.links]}),k.cloned.length?(0,h.jsxs)(`div`,{children:[`克隆 `,k.cloned.length,` 个`]}):null,k.unmatched.length?(0,h.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,k.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,h.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:b?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,h.jsxs)(`span`,{children:[`差异(新增 `,z.new,` · 有差异 `,z.changed,` · 一致 `,z.same,b.summary.missing?` · 本地未拥有 ${b.summary.missing}`:``,`)`]}),(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`rp-chip`+(O===``?` on`:``),onClick:()=>oe(``),children:`全部`}),(0,h.jsx)(`button`,{className:`rp-chip`+(O===`new`?` on`:``),onClick:()=>oe(`new`),children:`新增`}),(0,h.jsx)(`button`,{className:`rp-chip`+(O===`changed`?` on`:``),onClick:()=>oe(`changed`),children:`有差异`}),(0,h.jsx)(`button`,{className:`rp-chip`+(O===`same`?` on`:``),onClick:()=>oe(`same`),children:`一致`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>he(!0),children:`全选`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>he(!1),children:`全不选`})]})]}),(0,h.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,h.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{style:{width:`32px`}}),(0,h.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,h.jsx)(`th`,{children:`仓库 key`}),(0,h.jsx)(`th`,{children:`差异字段`})]})}),(0,h.jsxs)(`tbody`,{children:[R.map(e=>(0,h.jsxs)(`tr`,{className:`rp-diff-row `+g[e.status]?.cls,children:[(0,h.jsx)(`td`,{children:(0,h.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!S[e.key],onChange:t=>C(n=>({...n,[e.key]:t.target.checked}))})}),(0,h.jsx)(`td`,{children:(0,h.jsx)(`span`,{className:`rp-status `+g[e.status]?.cls,children:g[e.status]?.label})}),(0,h.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,h.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,h.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:j,onClick:()=>me(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,h.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`b`,{children:e.field}),`: `,(0,h.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,h.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,h.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),b.missing.map(e=>(0,h.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,h.jsx)(`td`,{}),(0,h.jsx)(`td`,{children:(0,h.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,h.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,h.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),b.boards.length?(0,h.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,children:(0,h.jsx)(`span`,{children:`看板`})}),b.boards.map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!w[e.key],onChange:t=>T(n=>({...n,[e.key]:t.target.checked}))}),(0,h.jsx)(`span`,{className:`rp-status `+g[e.status]?.cls,children:g[e.status]?.label}),(0,h.jsx)(`span`,{children:e.key}),(0,h.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),b.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,h.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,h.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,h.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,h.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,h.jsx)(`button`,{className:`btn small`,disabled:j,onClick:()=>me(e.key,e.remote),children:`克隆到本地`}):(0,h.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,h.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}function v(e,t){let n=[],r=e.descDocs||null;if(t){let r=(e.boards||[]).find(e=>e.id===t.id),i=r&&r.noteDocRel||``,a=r&&r.noteDocPath||``,ee=a?`path:`+a:i?`rel:`+i:``;ee&&n.push({id:ee,kind:`group`,label:`组内描述`,sub:`「${t.name}」里 ${e.name} 的角色`,note:r&&r.note||``,writable:!a})}let i=r&&r.main;i&&i.docId&&n.push({id:i.docId,kind:`main`,label:i.title||`项目主篇`,sub:i.rel||i.path||``,note:i.summary||``,exists:!!i.exists,writable:!i.path});for(let e of r&&r.links||[])e.docId&&n.push({id:e.docId,kind:`link`,label:e.title||e.docId,sub:e.tag?`#`+e.tag:``,note:e.note||``,writable:String(e.docId).startsWith(`rel:`)});return n}function ne({repo:e,board:t,onClose:n,onSaved:r,onOpenTab:i}){let c=ee(),u=(0,m.useMemo)(()=>v(e,t),[e,t]),[p,te]=(0,m.useState)(()=>u[0]?u[0].id:``),[g,_]=(0,m.useState)(null),[ne,y]=(0,m.useState)(!1),[re,b]=(0,m.useState)(`split`),[x,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(``),T=(0,m.useRef)(null),ie=u.find(e=>e.id===p)||null,E=(0,m.useCallback)(async e=>{if(!e){_(null);return}w(``);try{let t=await o(`/api/docs/item?ref=`+encodeURIComponent(e));_(t),y(!1)}catch(e){w(String(e.message||e)),_(null)}},[]);(0,m.useEffect)(()=>{E(p)},[p,E]);let ae=e=>{y(!0),_(t=>t&&{...t,body:e,title:s(e,t.title)})},D=e=>{y(!0),_(t=>{if(!t)return t;let n=/^#\s+/m.test(t.body)?t.body.replace(/^#\s+.+$/m,`# ${e||`未命名文档`}`):`# ${e||`未命名文档`}\n\n${t.body}`;return{...t,body:n,title:e}})},O=(0,m.useCallback)(async()=>{if(!g||!g.writable||x)return!0;S(!0),w(``);try{let e=g.missing?await o(`/api/docs/item`,{method:`POST`,body:{rel:g.rel,body:g.body}}):await o(`/api/docs/item`,{method:`PATCH`,body:{ref:p,body:g.body}});return _(t=>t&&{...t,missing:!1,summary:e&&e.summary}),y(!1),c&&c(`描述已保存`),r&&r(),!0}catch(e){return w(String(e.message||e)),!1}finally{S(!1)}},[g,x,p,c,r]),oe=async e=>{e!==p&&(ne&&g&&g.writable&&!await O()||te(e))},k=!!(g&&g.writable),A=(0,m.useMemo)(()=>g?l(g.body,[]):``,[g]);return(0,h.jsx)(a,{size:`wide`,title:`描述 · ${e.name}${t?` @「${t.name}」`:``}`,onClose:async()=>{ne&&g&&g.writable&&await O(),n()},children:(0,h.jsxs)(`div`,{className:`rpd`,children:[(0,h.jsxs)(`div`,{className:`rpd-list`,children:[u.length===0?(0,h.jsx)(`div`,{className:`rpd-none`,children:`这个仓库还没有描述文档`}):null,u.map(e=>{let t=e.kind===`link`||!!(e.note||e.exists);return(0,h.jsxs)(`button`,{type:`button`,className:`rpd-item`+(e.id===p?` on`:``),onClick:()=>oe(e.id),title:e.sub||e.label,children:[(0,h.jsxs)(`span`,{className:`rpd-item-top`,children:[(0,h.jsx)(`span`,{className:`rpd-item-label`,children:e.label}),e.kind===`group`?(0,h.jsx)(`span`,{className:`rpd-badge`,children:`组内`}):null,e.kind===`link`&&e.sub?(0,h.jsx)(`span`,{className:`rpd-badge`,children:e.sub}):null,t?null:(0,h.jsx)(`span`,{className:`rpd-todo`,children:`未写`})]}),e.note?(0,h.jsx)(`span`,{className:`rpd-item-note`,children:e.note}):null]},e.id)})]}),(0,h.jsxs)(`div`,{className:`rpd-main`,children:[(0,h.jsxs)(`div`,{className:`rpd-bar`,children:[(0,h.jsx)(`span`,{className:`rpd-path mono`,title:g?g.rel||g.path:``,children:g?g.rel||g.path:ie?ie.sub:``}),ne?(0,h.jsx)(`span`,{className:`rpd-dirty`,children:`未保存`}):null,g&&!k?(0,h.jsx)(`span`,{className:`rpd-badge`,children:`外部 · 只读`}):null,(0,h.jsx)(`span`,{className:`grow`}),k?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(f,{mode:re,onChange:b}),(0,h.jsx)(`button`,{type:`button`,className:`btn small`,disabled:x||!ne,onClick:O,children:x?`保存中…`:`保存`})]}):null,i&&g?(0,h.jsx)(`button`,{type:`button`,className:`btn small ghost`,title:`在文档页签里打开(读全文 / 点双链跳转)`,onClick:()=>{i(p),n()},children:`↗ 页签`}):null]}),C?(0,h.jsx)(`div`,{className:`rpd-err`,children:C}):null,g?(0,h.jsx)(`div`,{className:`rpd-body`,children:(0,h.jsx)(d,{mode:k?re:`preview`,title:g.title,body:g.body,previewHtml:A,onTitle:k?D:null,onBody:k?ae:null,attachments:[],docKey:p,editorApiRef:T,onSave:k?O:null})}):(0,h.jsx)(`div`,{className:`rpd-empty`,children:C?``:`选择左侧的一篇描述开始编辑`})]})]})})}var y={path:``,name:``,desc:``,notes:``,type:`dev`,remote:``};function re({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,h.jsx)(c,{text:t,children:t}):(0,h.jsxs)(c,{text:t,title:`点击复制完整路径`,children:[(0,h.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function b({docs:e,onOpen:t,tip:n=``}){let r=e&&e.main,i=e&&e.links||[];if(!r||!r.title)return null;let a=[n,`主篇:${r.rel||r.path}`,...i.map(e=>(e.tag?`[${e.tag}] `:``)+e.title+(e.note?` —— ${e.note}`:``))].filter(Boolean).join(`
|
|
2
2
|
`);return(0,h.jsxs)(`div`,{className:`rp-desc`,children:[(0,h.jsx)(`button`,{type:`button`,className:`rp-doc`+(r.exists?``:` ghost`),title:a||`打开项目介绍文档`,onClick:()=>t(r),children:(0,h.jsx)(`span`,{className:`rp-doc-tx`,children:r.exists?r.summary||r.title:`未写`})}),i.length?(0,h.jsxs)(`span`,{className:`rp-doc-more`,title:`另有 ${i.length} 篇补充文档`,children:[`+`,i.length]}):null]})}function x({r:e,filterBoard:t,refsOfRepo:n,acts:r}){let i=t?(e.boards||[]).find(e=>e.id===t.id)?.note||``:null,a=n.get(e.key)||[];return(0,h.jsxs)(`tr`,{children:[(0,h.jsxs)(`td`,{className:`rp-name`,children:[(0,h.jsxs)(`strong`,{children:[e.icon?(0,h.jsx)(`span`,{className:`rp-icon`,"aria-hidden":!0,children:e.icon}):null,e.name]}),(0,h.jsx)(b,{docs:e.descDocs,onOpen:r.doc,tip:i?`组内描述:${i}`:``})]}),(0,h.jsx)(`td`,{className:`mono rp-path`,children:(0,h.jsx)(re,{path:e.path})}),(0,h.jsxs)(`td`,{className:`rp-refs`,children:[a.length?a.map(t=>(0,h.jsxs)(`button`,{className:`rp-ref-chip`,title:`直接绑定:${t.remote||``}${t.note?`
|
|
3
|
-
`+t.note:``}\n点击改绑定描述`,onClick:()=>r.refNote(t,e),children:[t.note?(0,h.jsx)(`span`,{className:`rp-ref-chip-dot`}):null,t.name]},t.key)):(0,h.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`}),(0,h.jsx)(`button`,{className:`btn small ghost rp-ref-bind`,title:`管理这个仓库绑定的参考仓库`,onClick:()=>r.bind(e),children:`绑定`})]}),(0,h.jsxs)(`td`,{className:`rp-acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,title:`在文件管理器中打开`,onClick:()=>r.open(e),children:`打开`}),(0,h.jsx)(`button`,{className:`btn small ghost`,title:`对齐 remote:列出 git remote -v 的候选并检查远端是否存在`,onClick:()=>r.remote(e),children:`remote`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>r.edit(e),children:`编辑`}),t?(0,h.jsx)(`button`,{className:`btn small ghost`,title:`打开「${e.name}」在「${t.name}」里的组内描述文档`,onClick:()=>r.note(e),children:`描述`}):null,(0,h.jsx)(`button`,{className:`btn small ghost rp-del`,onClick:()=>r.del(e),children:`删除`})]})]})}function S(){let e=r(),t=ee(),{dialog:n,node:o}=i(),{openByDocId:l}=p(),[d,f]=(0,m.useState)(y),[g,v]=(0,m.useState)(null),[re,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(null),[T,ie]=(0,m.useState)(null),[E,ae]=(0,m.useState)(``),[D,O]=(0,m.useState)(null),[oe,k]=(0,m.useState)(!1),[A,j]=(0,m.useState)(``),[M,N]=(0,m.useState)(null),[se,ce]=(0,m.useState)(!1),[P,le]=(0,m.useState)([]),F=e=>t=>f(n=>({...n,[e]:t.target.value})),[ue,de]=(0,m.useState)(!1),[I,fe]=(0,m.useState)(null),[pe,L]=(0,m.useState)(!1),[R,me]=(0,m.useState)({gitRepoRoot:``,gitDevRoot:``}),[he,z]=(0,m.useState)(!1),[B,ge]=(0,m.useState)({url:``,name:``,desc:``,depth:`1`}),[_e,V]=(0,m.useState)({}),[ve,ye]=(0,m.useState)(null),[be,xe]=(0,m.useState)(null),[Se,Ce]=(0,m.useState)({}),[H,we]=(0,m.useState)(null),[Te,Ee]=(0,m.useState)({}),[De,Oe]=(0,m.useState)(null),[U,ke]=(0,m.useState)(null),[Ae,je]=(0,m.useState)(``),[Me,Ne]=(0,m.useState)(!1),[W,Pe]=(0,m.useState)(null),[G,Fe]=(0,m.useState)(null),[Ie,Le]=(0,m.useState)(!1),Re=()=>{f(y),v(null),S(!1)},K=(0,m.useCallback)(async()=>{le(await c(`/api/repos`).catch(()=>[])||[])},[]),q=(0,m.useCallback)(async()=>{ie(await c(`/api/boards`).catch(()=>null))},[]);(0,m.useEffect)(()=>{K(),q()},[K,q]),(0,m.useEffect)(()=>{let e=()=>{let e=location.hash.split(`?`)[1]||``;if(!e)return;let t=new URLSearchParams(e),n=t.get(`board`);n&&(ae(n),t.get(`add`)&&w(n))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let ze=(0,m.useCallback)(async()=>{fe(await c(`/api/setting`).catch(()=>null))},[]),J=(0,m.useCallback)(async()=>{ye(await c(`/api/repos/ref/check`).catch(()=>null))},[]);(0,m.useEffect)(()=>{ze(),J()},[ze,J]);let Be=()=>e(async()=>{let e={};R.gitRepoRoot.trim()&&(e.gitRepoRoot=R.gitRepoRoot.trim()),R.gitDevRoot.trim()&&(e.gitDevRoot=R.gitDevRoot.trim()),Object.keys(e).length&&(fe(await c(`/api/setting`,{method:`POST`,body:e})),L(!1),t(`已保存存储根目录`))}),Ve=()=>e(async()=>{let e=B.url.trim();if(!e)return;let n={url:e,name:B.name.trim()||void 0,desc:B.desc.trim()||void 0,depth:parseInt(B.depth,10)||1,"no-bind":!0},r=X.filter(e=>_e[`repo:`+e.id]).map(e=>e.id),i=Y.filter(e=>_e[`board:`+e.id]).map(e=>e.id);r.length&&(n.bind=r),i.length&&(n.board=i);let a=await c(`/api/repos/ref/clone`,{method:`POST`,body:n});z(!1),ge({url:``,name:``,desc:``,depth:`1`}),V({}),t(`已克隆: ${a.name} → ${a.dest||a.path}`),await Promise.all([K(),q(),J()])}),He=n=>e(async()=>{let e=await c(`/api/repos/ref/sync`,{method:`POST`,body:{id:n.id}});t(e.status===`updated`?`已更新: ${e.name}`:e.status===`upToDate`?`${e.name} 已是最新`:`${e.name}: ${e.status} ${e.output||``}`)}),Ue=()=>e(async()=>{let e=await c(`/api/repos/ref/sync`,{method:`POST`,body:{all:!0}}),n=e.results.filter(e=>e.status!==`updated`&&e.status!==`upToDate`);t(`同步 ${e.synced} 个${n.length?`,${n.length} 个有问题(见检查结果)`:`,全部完成`}`),await J()}),We=e=>{let t={};for(let n of e.linked||[])t[n.kind+`:`+n.id]=!0;Ce(t),xe(e)},Ge=()=>e(async()=>{if(!be)return;let e=new Set((be.linked||[]).map(e=>e.kind+`:`+e.id)),t=new Set(Object.keys(Se).filter(e=>Se[e]));for(let n of t){if(e.has(n))continue;let[t,r]=n.split(`:`);await c(`/api/repos/bind`,{method:`POST`,body:{id:be.key,[t]:[r]}})}for(let n of e){if(t.has(n))continue;let[e,r]=n.split(`:`);await c(`/api/repos/bind`,{method:`POST`,body:{id:be.key,[e]:[r],remove:!0}})}xe(null),await Promise.all([K(),J()])}),Ke=()=>e(async()=>{if(!H)return;let e=new Set;for(let t of H.linked||[])t.kind===`ref`&&e.add(t.id);for(let t of Z)(t.linked||[]).some(e=>e.kind===`repo`&&e.id===H.key)&&e.add(t.key);let t=new Set(Object.keys(Te).filter(e=>Te[e]));for(let n of t)e.has(n)||await c(`/api/repos/bind`,{method:`POST`,body:{id:n,repo:[H.key]}});for(let n of e)t.has(n)||await c(`/api/repos/bind`,{method:`POST`,body:{id:n,repo:[H.key],remove:!0}});we(null),await Promise.all([K(),J()])}),qe=(e,t,n,r)=>{let i=(e.linked||[]).find(e=>e.kind===t&&e.id===n);ke({ref:e,kind:t,targetId:n,targetName:r}),je(i?.note||``)},Je=()=>e(async()=>{let{ref:e,kind:n,targetId:r}=U;await c(`/api/repos/ref/note`,{method:`POST`,body:{id:e.key,[n]:r,note:Ae}}),ke(null),await Promise.all([K(),J()]),t(`已保存绑定描述`)}),Ye=(t,n,r)=>e(async()=>{await c(`/api/repos/bind`,{method:`POST`,body:{id:t.key,[n]:[r],remove:!0}}),await Promise.all([K(),J()])}),Xe=(0,m.useCallback)(async()=>{await Promise.all([K(),q(),J()])},[K,q,J]),Ze=async e=>{let n=e&&e.key?e.key:``;if(!n){t(`这个仓库还没有 key —— 先 nx-kv repo key set <id> <key>`);return}try{let e=await c(`/api/repos/remote/list?id=`+encodeURIComponent(n));if(!e||!Array.isArray(e.remotes))throw Error(`远程地址读取失败`);Pe(e),Fe(null),Le(!0)}catch(e){t(String(e&&e.message||e))}},Qe=n=>e(async()=>{await c(`/api/repos/remote/pick`,{method:`POST`,body:{id:W.key,url:n}}),Le(!1),t(`已对齐 remote`),await Promise.all([K(),J()])}),$e=async e=>{let t=W?W.key:``;if(!t){Fe({url:``,status:`unreachable`,detail:`没有仓库标识`});return}Fe({url:e||W.current||``,status:`checking`,detail:`检查中…`});try{let n=await c(`/api/repos/remote/check?id=`+encodeURIComponent(t)+(e?`&url=`+encodeURIComponent(e):``));Fe(n)}catch(t){Fe({url:e||W.current||``,status:`unreachable`,detail:String(t&&t.message||t)})}},Y=(0,m.useMemo)(()=>T&&T.boards||[],[T]),X=(0,m.useMemo)(()=>P.filter(e=>(e.type||`dev`)!==`ref`),[P]),Z=(0,m.useMemo)(()=>P.filter(e=>e.type===`ref`),[P]),et=(0,m.useMemo)(()=>E?X.filter(e=>(e.boards||[]).some(e=>e.id===E)):X,[X,E]),Q=(0,m.useMemo)(()=>Y.find(e=>e.id===E)||null,[Y,E]),tt=(0,m.useMemo)(()=>Y.find(e=>e.id===C)||null,[Y,C]),nt=(0,m.useMemo)(()=>{let e=new Map;return(ve?.refs||[]).forEach(t=>e.set(t.id,t)),e},[ve]),rt=(0,m.useMemo)(()=>{let e=new Map,t=(t,n,r)=>{e.has(t)||e.set(t,[]),e.get(t).push({key:n.key,id:n.id,name:n.name,remote:n.remote||``,note:r||``})},n=new Map(Z.map(e=>[e.key,e])),r=new Set;for(let e of X)for(let i of e.linked||[]){if(i.kind!==`ref`)continue;let a=n.get(i.id);a&&(r.add(e.key+`:`+a.key),t(e.key,a,i.note))}for(let e of Z)for(let n of e.linked||[])n.kind===`repo`&&(r.has(n.id+`:`+e.key)||t(n.id,e,n.note));return e},[X,Z]),it=(0,m.useMemo)(()=>{if(!Q)return[];let e=new Set((Q.repos||[]).map(e=>e.key)),t=Q.key||`board/${Q.name}`;return Z.map(n=>{let r=(n.linked||[]).find(e=>e.kind===`board`&&e.id===t),i=(n.linked||[]).filter(t=>t.kind===`repo`&&e.has(t.id));return!r&&!i.length?null:{...n,boardNote:r?.note||``,viaRepos:i.map(e=>(Q.repos||[]).find(t=>t.key===e.id)?.name||e.id)}}).filter(Boolean)},[Z,Q]),at=()=>{f(y),v(null),S(!0)},ot=(0,m.useMemo)(()=>{if(!g)return null;let e=P.find(e=>e.id===g);return e&&e.descDocs||null},[g,P]),st=()=>e(async()=>{if(!d.path.trim())return;let e={path:d.path.trim(),name:d.name.trim()||void 0,notes:d.notes,type:d.type===`ref`?`ref`:`dev`,remote:d.remote.trim()||void 0};g?await c(`/api/repos/${encodeURIComponent(g)}`,{method:`PATCH`,body:e}):await c(`/api/repos`,{method:`POST`,body:e}),Re(),await Promise.all([K(),q(),J()])}),$=(t,r)=>e(async()=>{if(t===`open`)await c(`/api/repos/open`,{method:`POST`,body:{id:r.id}});else if(t===`edit`)v(r.id),f({path:r.path,name:r.name||``,desc:r.desc||``,type:r.type||`dev`,remote:r.remote||``,notes:r.notes||``}),S(!0);else if(t===`del`){if(!await n({message:`删除仓库登记「${r.name}」?(仅移除登记,磁盘文件不受影响;各看板里的归属同步摘除)`,danger:!0}))return;await c(`/api/repos/${encodeURIComponent(r.id)}`,{method:`DELETE`}),await Promise.all([K(),q(),J()])}}),ct=()=>e(async()=>{let e={name:D.name.trim()};e.name&&(D.id||(e.desc=D.desc.trim()||void 0),D.id?await c(`/api/boards/${encodeURIComponent(D.id)}`,{method:`PATCH`,body:e}):await c(`/api/boards`,{method:`POST`,body:e}),O(null),await q())}),lt=t=>e(async()=>{await n({message:`删看板「${t.name}」?它里面的 ${t.repos.length} 个仓库**仍留在中心清单里**(只是少了一份归属)。`,danger:!0})&&(await c(`/api/boards/${encodeURIComponent(t.id)}`,{method:`DELETE`,body:{}}),await Promise.all([K(),q()]))}),ut=()=>e(async()=>{if(!A.trim())return;let e=await c(`/api/boards/import`,{method:`POST`,body:{json:A}});k(!1),j(``),t(`已导入:新建 ${e.created} 个看板、合并 ${e.merged} 个、匹配仓库 ${e.matched} 个`+(e.unmatched.length?`;未匹配 ${e.unmatched.length} 条(见 CLI board import 输出)`:``)),await Promise.all([K(),q()])}),dt=()=>e(async()=>{let e=await c(`/api/boards/export`);N(JSON.stringify(e,null,2))}),ft=async e=>{let t=e.target.files?.[0];t&&j(await t.text())},pt=(0,m.useMemo)(()=>{let e=new Map;for(let t of[...X,...Z]){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 t=[];for(let n of T&&T.boards||[])for(let r of n.repos||[]){if(r.present!==!1)continue;let i=String(r.key||``).split(`/`).filter(Boolean).pop()||``,a=e.get(String(r.name||``).toLowerCase())||e.get(i.toLowerCase())||null;t.push({...r,board:n.name,boardId:n.id,match:a})}return t},[T,X,Z]);if(T===null)return(0,h.jsxs)(`div`,{className:`rp-page`,children:[(0,h.jsx)(u,{}),(0,h.jsx)(`div`,{className:`muted`,style:{padding:20},children:`读取中…`}),o]});let mt=n=>e(async()=>{await c(`/api/repos/clone`,{method:`POST`,body:{remote:n.remote,key:n.key,name:n.name||void 0,type:`dev`}}),t(`已克隆并登记:${n.name||n.key}`),K(),q()}),ht=(n,r)=>e(async()=>{await c(`/api/boards/rekey`,{method:`POST`,body:{from:n.key,to:r}}),t(`已把「${n.name||n.key}」这个位置接到本机仓库`),K(),q()}),gt=r=>e(async()=>{let e=await n({title:`把「${r.name||r.key}」接到哪个本机仓库?`,input:!0,placeholder:`本机仓库:id / key / 名称 / 绝对路径`});e&&(await c(`/api/boards/rekey`,{method:`POST`,body:{from:r.key,to:e}}),t(`已重绑——这个位置现在指向本机仓库`),K(),q())}),_t=n=>e(async()=>{confirm(`把「${n.name||n.key}」从组「${n.board}」里移除?\n\n只摘这个组里的位置:本机仓库与看板本身都不动。`)&&(await c(`/api/boards/assign`,{method:`POST`,body:{key:n.key,board:n.boardId,remove:!0}}),t(`已从组「${n.board}」移除`),q())}),vt=()=>e(async()=>{let e=await c(`/api/boards/prune`,{method:`POST`,body:{apply:!1}});if(!e?.total){t(`没有可清理的占位(有远程地址的那些留着等 clone)`);return}let n=e.items.map(e=>`· ${e.name}(组 ${e.board})`).join(`
|
|
4
|
-
`);confirm(`清理 ${e.total} 个无来源占位?\n\n${n}\n\n它们没有远程地址,克隆不回来,只能删。`)&&(await
|
|
5
|
-
`):`尚未检查`}),(0,h.jsx)(
|
|
3
|
+
`+t.note:``}\n点击改绑定描述`,onClick:()=>r.refNote(t,e),children:[t.note?(0,h.jsx)(`span`,{className:`rp-ref-chip-dot`}):null,t.name]},t.key)):(0,h.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`}),(0,h.jsx)(`button`,{className:`btn small ghost rp-ref-bind`,title:`管理这个仓库绑定的参考仓库`,onClick:()=>r.bind(e),children:`绑定`})]}),(0,h.jsxs)(`td`,{className:`rp-acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,title:`在文件管理器中打开`,onClick:()=>r.open(e),children:`打开`}),(0,h.jsx)(`button`,{className:`btn small ghost`,title:`对齐 remote:列出 git remote -v 的候选并检查远端是否存在`,onClick:()=>r.remote(e),children:`remote`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>r.edit(e),children:`编辑`}),t?(0,h.jsx)(`button`,{className:`btn small ghost`,title:`打开「${e.name}」在「${t.name}」里的组内描述文档`,onClick:()=>r.note(e),children:`描述`}):null,(0,h.jsx)(`button`,{className:`btn small ghost rp-del`,onClick:()=>r.del(e),children:`删除`})]})]})}function S(){let e=r(),t=ee(),{dialog:n,node:s}=i(),{openByDocId:l}=p(),[d,f]=(0,m.useState)(y),[g,v]=(0,m.useState)(null),[re,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(null),[T,ie]=(0,m.useState)(null),[E,ae]=(0,m.useState)(``),[D,O]=(0,m.useState)(null),[oe,k]=(0,m.useState)(!1),[A,j]=(0,m.useState)(``),[M,N]=(0,m.useState)(null),[se,ce]=(0,m.useState)(!1),[P,le]=(0,m.useState)([]),F=e=>t=>f(n=>({...n,[e]:t.target.value})),[ue,de]=(0,m.useState)(!1),[I,fe]=(0,m.useState)(null),[pe,L]=(0,m.useState)(!1),[R,me]=(0,m.useState)({gitRepoRoot:``,gitDevRoot:``}),[he,z]=(0,m.useState)(!1),[B,ge]=(0,m.useState)({url:``,name:``,desc:``,depth:`1`}),[_e,V]=(0,m.useState)({}),[ve,ye]=(0,m.useState)(null),[be,xe]=(0,m.useState)(null),[Se,Ce]=(0,m.useState)({}),[H,we]=(0,m.useState)(null),[Te,Ee]=(0,m.useState)({}),[De,Oe]=(0,m.useState)(null),[U,ke]=(0,m.useState)(null),[Ae,je]=(0,m.useState)(``),[Me,Ne]=(0,m.useState)(!1),[W,Pe]=(0,m.useState)(null),[G,Fe]=(0,m.useState)(null),[Ie,Le]=(0,m.useState)(!1),Re=()=>{f(y),v(null),S(!1)},K=(0,m.useCallback)(async()=>{le(await o(`/api/repos`).catch(()=>[])||[])},[]),q=(0,m.useCallback)(async()=>{ie(await o(`/api/boards`).catch(()=>null))},[]);(0,m.useEffect)(()=>{K(),q()},[K,q]),(0,m.useEffect)(()=>{let e=()=>{let e=location.hash.split(`?`)[1]||``;if(!e)return;let t=new URLSearchParams(e),n=t.get(`board`);n&&(ae(n),t.get(`add`)&&w(n))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let ze=(0,m.useCallback)(async()=>{fe(await o(`/api/setting`).catch(()=>null))},[]),J=(0,m.useCallback)(async()=>{ye(await o(`/api/repos/ref/check`).catch(()=>null))},[]);(0,m.useEffect)(()=>{ze(),J()},[ze,J]);let Be=()=>e(async()=>{let e={};R.gitRepoRoot.trim()&&(e.gitRepoRoot=R.gitRepoRoot.trim()),R.gitDevRoot.trim()&&(e.gitDevRoot=R.gitDevRoot.trim()),Object.keys(e).length&&(fe(await o(`/api/setting`,{method:`POST`,body:e})),L(!1),t(`已保存存储根目录`))}),Ve=()=>e(async()=>{let e=B.url.trim();if(!e)return;let n={url:e,name:B.name.trim()||void 0,desc:B.desc.trim()||void 0,depth:parseInt(B.depth,10)||1,"no-bind":!0},r=X.filter(e=>_e[`repo:`+e.id]).map(e=>e.id),i=Y.filter(e=>_e[`board:`+e.id]).map(e=>e.id);r.length&&(n.bind=r),i.length&&(n.board=i);let a=await o(`/api/repos/ref/clone`,{method:`POST`,body:n});z(!1),ge({url:``,name:``,desc:``,depth:`1`}),V({}),t(`已克隆: ${a.name} → ${a.dest||a.path}`),await Promise.all([K(),q(),J()])}),He=n=>e(async()=>{let e=await o(`/api/repos/ref/sync`,{method:`POST`,body:{id:n.id}});t(e.status===`updated`?`已更新: ${e.name}`:e.status===`upToDate`?`${e.name} 已是最新`:`${e.name}: ${e.status} ${e.output||``}`)}),Ue=()=>e(async()=>{let e=await o(`/api/repos/ref/sync`,{method:`POST`,body:{all:!0}}),n=e.results.filter(e=>e.status!==`updated`&&e.status!==`upToDate`);t(`同步 ${e.synced} 个${n.length?`,${n.length} 个有问题(见检查结果)`:`,全部完成`}`),await J()}),We=e=>{let t={};for(let n of e.linked||[])t[n.kind+`:`+n.id]=!0;Ce(t),xe(e)},Ge=()=>e(async()=>{if(!be)return;let e=new Set((be.linked||[]).map(e=>e.kind+`:`+e.id)),t=new Set(Object.keys(Se).filter(e=>Se[e]));for(let n of t){if(e.has(n))continue;let[t,r]=n.split(`:`);await o(`/api/repos/bind`,{method:`POST`,body:{id:be.key,[t]:[r]}})}for(let n of e){if(t.has(n))continue;let[e,r]=n.split(`:`);await o(`/api/repos/bind`,{method:`POST`,body:{id:be.key,[e]:[r],remove:!0}})}xe(null),await Promise.all([K(),J()])}),Ke=()=>e(async()=>{if(!H)return;let e=new Set;for(let t of H.linked||[])t.kind===`ref`&&e.add(t.id);for(let t of Z)(t.linked||[]).some(e=>e.kind===`repo`&&e.id===H.key)&&e.add(t.key);let t=new Set(Object.keys(Te).filter(e=>Te[e]));for(let n of t)e.has(n)||await o(`/api/repos/bind`,{method:`POST`,body:{id:n,repo:[H.key]}});for(let n of e)t.has(n)||await o(`/api/repos/bind`,{method:`POST`,body:{id:n,repo:[H.key],remove:!0}});we(null),await Promise.all([K(),J()])}),qe=(e,t,n,r)=>{let i=(e.linked||[]).find(e=>e.kind===t&&e.id===n);ke({ref:e,kind:t,targetId:n,targetName:r}),je(i?.note||``)},Je=()=>e(async()=>{let{ref:e,kind:n,targetId:r}=U;await o(`/api/repos/ref/note`,{method:`POST`,body:{id:e.key,[n]:r,note:Ae}}),ke(null),await Promise.all([K(),J()]),t(`已保存绑定描述`)}),Ye=(t,n,r)=>e(async()=>{await o(`/api/repos/bind`,{method:`POST`,body:{id:t.key,[n]:[r],remove:!0}}),await Promise.all([K(),J()])}),Xe=(0,m.useCallback)(async()=>{await Promise.all([K(),q(),J()])},[K,q,J]),Ze=async e=>{let n=e&&e.key?e.key:``;if(!n){t(`这个仓库还没有 key —— 先 nx-kv repo key set <id> <key>`);return}try{let e=await o(`/api/repos/remote/list?id=`+encodeURIComponent(n));if(!e||!Array.isArray(e.remotes))throw Error(`远程地址读取失败`);Pe(e),Fe(null),Le(!0)}catch(e){t(String(e&&e.message||e))}},Qe=n=>e(async()=>{await o(`/api/repos/remote/pick`,{method:`POST`,body:{id:W.key,url:n}}),Le(!1),t(`已对齐 remote`),await Promise.all([K(),J()])}),$e=async e=>{let t=W?W.key:``;if(!t){Fe({url:``,status:`unreachable`,detail:`没有仓库标识`});return}Fe({url:e||W.current||``,status:`checking`,detail:`检查中…`});try{let n=await o(`/api/repos/remote/check?id=`+encodeURIComponent(t)+(e?`&url=`+encodeURIComponent(e):``));Fe(n)}catch(t){Fe({url:e||W.current||``,status:`unreachable`,detail:String(t&&t.message||t)})}},Y=(0,m.useMemo)(()=>T&&T.boards||[],[T]),X=(0,m.useMemo)(()=>P.filter(e=>(e.type||`dev`)!==`ref`),[P]),Z=(0,m.useMemo)(()=>P.filter(e=>e.type===`ref`),[P]),et=(0,m.useMemo)(()=>E?X.filter(e=>(e.boards||[]).some(e=>e.id===E)):X,[X,E]),Q=(0,m.useMemo)(()=>Y.find(e=>e.id===E)||null,[Y,E]),tt=(0,m.useMemo)(()=>Y.find(e=>e.id===C)||null,[Y,C]),nt=(0,m.useMemo)(()=>{let e=new Map;return(ve?.refs||[]).forEach(t=>e.set(t.id,t)),e},[ve]),rt=(0,m.useMemo)(()=>{let e=new Map,t=(t,n,r)=>{e.has(t)||e.set(t,[]),e.get(t).push({key:n.key,id:n.id,name:n.name,remote:n.remote||``,note:r||``})},n=new Map(Z.map(e=>[e.key,e])),r=new Set;for(let e of X)for(let i of e.linked||[]){if(i.kind!==`ref`)continue;let a=n.get(i.id);a&&(r.add(e.key+`:`+a.key),t(e.key,a,i.note))}for(let e of Z)for(let n of e.linked||[])n.kind===`repo`&&(r.has(n.id+`:`+e.key)||t(n.id,e,n.note));return e},[X,Z]),it=(0,m.useMemo)(()=>{if(!Q)return[];let e=new Set((Q.repos||[]).map(e=>e.key)),t=Q.key||`board/${Q.name}`;return Z.map(n=>{let r=(n.linked||[]).find(e=>e.kind===`board`&&e.id===t),i=(n.linked||[]).filter(t=>t.kind===`repo`&&e.has(t.id));return!r&&!i.length?null:{...n,boardNote:r?.note||``,viaRepos:i.map(e=>(Q.repos||[]).find(t=>t.key===e.id)?.name||e.id)}}).filter(Boolean)},[Z,Q]),at=()=>{f(y),v(null),S(!0)},ot=(0,m.useMemo)(()=>{if(!g)return null;let e=P.find(e=>e.id===g);return e&&e.descDocs||null},[g,P]),st=()=>e(async()=>{if(!d.path.trim())return;let e={path:d.path.trim(),name:d.name.trim()||void 0,notes:d.notes,type:d.type===`ref`?`ref`:`dev`,remote:d.remote.trim()||void 0};g?await o(`/api/repos/${encodeURIComponent(g)}`,{method:`PATCH`,body:e}):await o(`/api/repos`,{method:`POST`,body:e}),Re(),await Promise.all([K(),q(),J()])}),$=(t,r)=>e(async()=>{if(t===`open`)await o(`/api/repos/open`,{method:`POST`,body:{id:r.id}});else if(t===`edit`)v(r.id),f({path:r.path,name:r.name||``,desc:r.desc||``,type:r.type||`dev`,remote:r.remote||``,notes:r.notes||``}),S(!0);else if(t===`del`){if(!await n({message:`删除仓库登记「${r.name}」?(仅移除登记,磁盘文件不受影响;各看板里的归属同步摘除)`,danger:!0}))return;await o(`/api/repos/${encodeURIComponent(r.id)}`,{method:`DELETE`}),await Promise.all([K(),q(),J()])}}),ct=()=>e(async()=>{let e={name:D.name.trim()};e.name&&(D.id||(e.desc=D.desc.trim()||void 0),D.id?await o(`/api/boards/${encodeURIComponent(D.id)}`,{method:`PATCH`,body:e}):await o(`/api/boards`,{method:`POST`,body:e}),O(null),await q())}),lt=t=>e(async()=>{await n({message:`删看板「${t.name}」?它里面的 ${t.repos.length} 个仓库**仍留在中心清单里**(只是少了一份归属)。`,danger:!0})&&(await o(`/api/boards/${encodeURIComponent(t.id)}`,{method:`DELETE`,body:{}}),await Promise.all([K(),q()]))}),ut=()=>e(async()=>{if(!A.trim())return;let e=await o(`/api/boards/import`,{method:`POST`,body:{json:A}});k(!1),j(``),t(`已导入:新建 ${e.created} 个看板、合并 ${e.merged} 个、匹配仓库 ${e.matched} 个`+(e.unmatched.length?`;未匹配 ${e.unmatched.length} 条(见 CLI board import 输出)`:``)),await Promise.all([K(),q()])}),dt=()=>e(async()=>{let e=await o(`/api/boards/export`);N(JSON.stringify(e,null,2))}),ft=async e=>{let t=e.target.files?.[0];t&&j(await t.text())},pt=(0,m.useMemo)(()=>{let e=new Map;for(let t of[...X,...Z]){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 t=[];for(let n of T&&T.boards||[])for(let r of n.repos||[]){if(r.present!==!1)continue;let i=String(r.key||``).split(`/`).filter(Boolean).pop()||``,a=e.get(String(r.name||``).toLowerCase())||e.get(i.toLowerCase())||null;t.push({...r,board:n.name,boardId:n.id,match:a})}return t},[T,X,Z]);if(T===null)return(0,h.jsxs)(`div`,{className:`rp-page`,children:[(0,h.jsx)(u,{}),(0,h.jsx)(`div`,{className:`muted`,style:{padding:20},children:`读取中…`}),s]});let mt=n=>e(async()=>{await o(`/api/repos/clone`,{method:`POST`,body:{remote:n.remote,key:n.key,name:n.name||void 0,type:`dev`}}),t(`已克隆并登记:${n.name||n.key}`),K(),q()}),ht=(n,r)=>e(async()=>{await o(`/api/boards/rekey`,{method:`POST`,body:{from:n.key,to:r}}),t(`已把「${n.name||n.key}」这个位置接到本机仓库`),K(),q()}),gt=r=>e(async()=>{let e=await n({title:`把「${r.name||r.key}」接到哪个本机仓库?`,input:!0,placeholder:`本机仓库:id / key / 名称 / 绝对路径`});e&&(await o(`/api/boards/rekey`,{method:`POST`,body:{from:r.key,to:e}}),t(`已重绑——这个位置现在指向本机仓库`),K(),q())}),_t=n=>e(async()=>{confirm(`把「${n.name||n.key}」从组「${n.board}」里移除?\n\n只摘这个组里的位置:本机仓库与看板本身都不动。`)&&(await o(`/api/boards/assign`,{method:`POST`,body:{key:n.key,board:n.boardId,remove:!0}}),t(`已从组「${n.board}」移除`),q())}),vt=()=>e(async()=>{let e=await o(`/api/boards/prune`,{method:`POST`,body:{apply:!1}});if(!e?.total){t(`没有可清理的占位(有远程地址的那些留着等 clone)`);return}let n=e.items.map(e=>`· ${e.name}(组 ${e.board})`).join(`
|
|
4
|
+
`);confirm(`清理 ${e.total} 个无来源占位?\n\n${n}\n\n它们没有远程地址,克隆不回来,只能删。`)&&(await o(`/api/boards/prune`,{method:`POST`,body:{apply:!0}}),t(`已清理 ${e.total} 个占位`),q())}),yt=(t,n)=>e(async()=>{t&&(await o(`/api/docs/item`,{method:`POST`,body:{rel:t,body:`# ${n||t}\n\n`}}).catch(()=>{}),l(`rel:`+t),K())}),bt={open:e=>$(`open`,e),edit:e=>$(`edit`,e),del:e=>$(`del`,e),remote:e=>Ze(e),doc:e=>{if(e&&e.docId)return e.exists||!e.rel?l(e.docId):yt(e.rel,e.title)},bind:e=>{let t={};for(let n of e.linked||[])n.kind===`ref`&&(t[n.id]=!0);for(let n of Z)t[n.key]||(n.linked||[]).some(t=>t.kind===`repo`&&t.id===e.key)&&(t[n.key]=!0);Ee(t),we(e)},refNote:(e,t)=>{let n=Z.find(t=>t.key===e.key);n&&qe(n,`repo`,t.key,t.name)},note:e=>{Oe({repo:e,board:Q||null})}};return(0,h.jsxs)(`div`,{className:`rp-page`,children:[(0,h.jsxs)(`div`,{className:`page-head`,children:[(0,h.jsx)(`div`,{className:`title-block`,children:(0,h.jsx)(`h2`,{children:`仓库`})}),(0,h.jsx)(`div`,{className:`acts`,children:(0,h.jsx)(`button`,{className:`btn`,onClick:at,children:`添加仓库`})})]}),(0,h.jsxs)(`div`,{className:`rp-filters`,"data-testid":`rp-filters`,children:[(0,h.jsxs)(`div`,{className:`rp-filters-main`,children:[(0,h.jsxs)(`button`,{className:`rp-chip`+(E?``:` on`),onClick:()=>ae(``),title:`显示全部开发仓库`,children:[`开发仓库 `,(0,h.jsx)(`b`,{children:X.length})]}),Y.map(e=>(0,h.jsxs)(`button`,{className:`rp-chip`+(E===e.id?` on`:``),onClick:()=>ae(E===e.id?``:e.id),title:`只看「${e.name}」里的仓库(${e.repos.length} 个)`,children:[e.name,` `,(0,h.jsx)(`b`,{children:e.repos.length})]},e.id))]}),(0,h.jsxs)(`div`,{className:`rp-filters-side`,children:[(0,h.jsxs)(`button`,{className:`rp-chip`,onClick:()=>de(!0),title:`弹窗管理参考仓库:克隆 / 绑定 / 同步 / 检查 / 布局导入导出`,children:[`参考仓库 `,(0,h.jsx)(`b`,{children:Z.length}),(0,h.jsx)(`span`,{className:`rp-chip-go`,children:`↗`})]}),(0,h.jsxs)(`button`,{className:`rp-chip`,onClick:()=>ce(!0),title:`弹窗管理看板:新建 / 编辑 / 删除 / 导入 / 导出 / 成员管理`,children:[`看板 `,(0,h.jsx)(`b`,{children:Y.length}),(0,h.jsx)(`span`,{className:`rp-chip-go`,children:`↗`})]})]})]}),pt.length>0&&(0,h.jsxs)(`section`,{className:`rp-pending`,"data-testid":`rp-pending-init`,children:[(0,h.jsxs)(`header`,{className:`rp-pending-head`,children:[(0,h.jsxs)(`div`,{className:`rp-pending-head-main`,children:[(0,h.jsxs)(`h3`,{children:[`待初始化`,(0,h.jsx)(`span`,{className:`rp-pending-count`,children:pt.length})]}),(0,h.jsx)(`p`,{children:`组里有位置、本机没有登记。接到本机仓库、克隆下来,或者直接移除。`})]}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:vt,children:`清理无来源占位`})]}),(0,h.jsx)(`div`,{className:`rp-pending-list`,children:pt.map(e=>(0,h.jsxs)(`article`,{className:`rp-pending-card`,children:[(0,h.jsxs)(`div`,{className:`rp-pending-info`,children:[(0,h.jsxs)(`div`,{className:`rp-pending-title`,children:[(0,h.jsx)(`strong`,{children:e.name||e.key}),(0,h.jsxs)(`span`,{className:`rp-pending-board`,children:[`组 · `,e.board]}),e.remote?null:(0,h.jsx)(`span`,{className:`rp-pending-tag`,children:`无远程地址`})]}),(0,h.jsx)(`code`,{className:`rp-pending-key`,children:e.key}),e.desc?(0,h.jsx)(`p`,{className:`rp-pending-desc`,children:e.desc}):null]}),(0,h.jsxs)(`div`,{className:`rp-pending-acts`,children:[e.match?(0,h.jsxs)(`button`,{className:`btn small`,title:`把组里这个位置指向本机仓库「${e.match.name}」(仓库身份不变)`,onClick:()=>ht(e,e.match.id),children:[`绑定到「`,e.match.name,`」`]}):null,e.remote?(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>mt(e),children:`克隆到本地`}):null,(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>gt(e),children:`选本机仓库`}),(0,h.jsx)(`button`,{className:`btn small ghost rp-del`,title:`只从组里摘掉这个位置,本机仓库与看板都不动`,onClick:()=>_t(e),children:`移除`})]})]},e.key+`@`+e.boardId))})]}),Q?(0,h.jsxs)(`div`,{className:`rp-context`,"data-testid":`rp-context`,children:[(0,h.jsx)(`span`,{className:`rp-context-name`,children:Q.name}),Q.desc?(0,h.jsx)(`span`,{className:`rp-context-desc`,title:Q.desc,children:Q.desc}):(0,h.jsx)(`span`,{className:`muted rp-context-desc`,children:`还没有领域描述 —— 点「看板管理」补一句:侧重什么、谁配合谁、关键路径与搜索关键词在哪。`}),(0,h.jsx)(`span`,{className:`acts`,children:(0,h.jsx)(`button`,{className:`btn small`,onClick:()=>w(Q.id),children:`添加成员`})})]}):null,Q?(0,h.jsxs)(`div`,{className:`rp-ref-mounted`,"data-testid":`rp-board-refs`,children:[(0,h.jsxs)(`div`,{className:`rp-ref-mounted-head`,children:[(0,h.jsxs)(`span`,{className:`rp-ref-mounted-label`,children:[`「`,Q.name,`」的参考仓库 `,(0,h.jsx)(`b`,{children:it.length})]}),(0,h.jsx)(`span`,{className:`muted`,children:`组级参考 + 成员仓库各自的参考(多对多:一个参考可同时服务多个组/仓库)`})]}),it.length?it.map(e=>{let t=nt.get(e.id),n=(e.linked||[]).find(e=>e.kind===`board`&&e.id===(Q.key||`board/${Q.name}`));return(0,h.jsxs)(`div`,{className:`rp-ref-mounted-item`,children:[(0,h.jsx)(`span`,{className:`rp-ref-dot`+(t?t.ok?` ok`:` bad`:``),title:t?t.ok?`检查通过`:t.issues.join(`
|
|
5
|
+
`):`尚未检查`}),(0,h.jsx)(c,{text:e.remote||e.name,title:`点击复制远程地址`,className:`rp-ref-mounted-name`,children:e.name}),e.desc?(0,h.jsx)(`span`,{className:`muted rp-ref-mounted-desc`,title:e.desc,children:e.desc}):null,e.boardNote?(0,h.jsx)(`button`,{className:`rp-ref-note-chip`,title:`${e.boardNote}\n点击编辑这条命名空间描述`,onClick:()=>qe(e,`board`,Q.id,Q.name),children:e.boardNote.split(`
|
|
6
6
|
`)[0]}):(0,h.jsx)(`button`,{className:`btn small ghost`,title:`写「${e.name}」在这个组里参考什么(命名空间描述)`,onClick:()=>qe(e,`board`,Q.id,Q.name),children:`写描述`}),e.viaRepos.length?(0,h.jsxs)(`span`,{className:`muted`,title:`经由成员仓库: `+e.viaRepos.join(`、`),children:[`经由 `,e.viaRepos.join(`、`)]}):null,(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>He(e),children:`同步`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>$(`open`,e),children:`打开`}),n?(0,h.jsx)(`button`,{className:`btn small ghost rp-del`,title:`只从本组摘除(不影响其它绑定)`,onClick:()=>Ye(e,`board`,Q.id),children:`移出本组`}):null]})]},e.id)}):(0,h.jsx)(`div`,{className:`muted rp-refs-none`,children:`这个组还没有绑定的参考仓库 —— 在下方参考仓库面板里点「绑定」勾选本组,或在成员仓库行上绑定。`})]}):null,ue?(0,h.jsxs)(a,{size:`wide`,title:`参考仓库 · ${Z.length}`,onClose:()=>de(!1),children:[(0,h.jsx)(`div`,{className:`rp-modal-bar`,children:(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`btn small`,onClick:()=>{V({}),z(!0)},children:`克隆参考仓库`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:Ue,children:`同步全部`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:J,children:`检查`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>Ne(!0),children:`导入导出`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>{me({gitRepoRoot:I?.gitRepoRoot||``,gitDevRoot:I?.gitDevRoot||``}),L(!0)},children:`存储根`})]})}),I?.gitRepoRoot?null:(0,h.jsx)(`div`,{className:`rp-ref-warn`,children:`存储根未设置 —— 克隆会被拒绝。点「存储根」设一个非 C 盘目录(参考仓库体积不小,别放系统盘)。`}),(0,h.jsx)(`div`,{className:`rp-ref-table-wrap`,children:(0,h.jsxs)(`table`,{className:`rp-ref-table`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{scope:`col`,style:{width:`30px`}}),(0,h.jsx)(`th`,{scope:`col`,style:{width:`17%`},children:`参考仓库`}),(0,h.jsx)(`th`,{scope:`col`,style:{width:`22%`},children:`远程地址`}),(0,h.jsx)(`th`,{scope:`col`,children:`绑定(组 / 仓库 · 点击写描述 · × 摘除)`}),(0,h.jsx)(`th`,{scope:`col`,style:{width:`220px`},children:`操作`})]})}),(0,h.jsxs)(`tbody`,{children:[Z.map(e=>{let t=nt.get(e.id),n=e.linked||[];return(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`td`,{children:(0,h.jsx)(`span`,{className:`rp-ref-dot`+(t?t.ok?` ok`:` bad`:``),title:t?t.ok?`检查通过`:t.issues.join(`
|
|
7
|
-
`):`尚未检查`})}),(0,h.jsxs)(`td`,{className:`rp-ref-cell-name`,children:[(0,h.jsx)(`strong`,{children:e.name}),(0,h.jsx)(b,{docs:e.descDocs,onOpen:bt.doc})]}),(0,h.jsx)(`td`,{className:`mono rp-ref-cell-remote`,children:(0,h.jsx)(
|
|
7
|
+
`):`尚未检查`})}),(0,h.jsxs)(`td`,{className:`rp-ref-cell-name`,children:[(0,h.jsx)(`strong`,{children:e.name}),(0,h.jsx)(b,{docs:e.descDocs,onOpen:bt.doc})]}),(0,h.jsx)(`td`,{className:`mono rp-ref-cell-remote`,children:(0,h.jsx)(c,{text:e.remote||``,title:`点击复制远程地址`,children:e.remote||`(无)`})}),(0,h.jsxs)(`td`,{className:`rp-ref-cell-links`,children:[n.length?n.map(t=>{let n=t.kind===`board`?Y.find(e=>(e.key||`board/${e.name}`)===t.id)?.name||t.id:X.find(e=>e.key===t.id)?.name||t.id;return(0,h.jsxs)(`span`,{className:`rp-link-chip`,children:[(0,h.jsxs)(`button`,{className:`rp-link-chip-main`,title:t.note?`${t.note}\n点击编辑这条绑定描述`:`点击写「${e.name}」绑定到这里的描述`,onClick:()=>qe(e,t.kind,t.id,n),children:[(0,h.jsx)(`b`,{children:t.kind===`board`?`组`:`仓`}),` `,n,t.note?(0,h.jsx)(`i`,{className:`rp-link-chip-note`,title:t.note,children:t.note.split(`
|
|
8
8
|
`)[0]}):null]}),(0,h.jsx)(`button`,{className:`rp-link-chip-x`,title:`摘除这条绑定(不影响其它)`,onClick:()=>Ye(e,t.kind,t.id),children:`×`})]},t.kind+`:`+t.id)}):(0,h.jsx)(`span`,{className:`muted rp-refs-none`,children:`未绑定`}),(0,h.jsx)(`button`,{className:`btn small ghost rp-ref-bind`,onClick:()=>We(e),children:`绑定…`})]}),(0,h.jsxs)(`td`,{className:`rp-acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>He(e),children:`同步`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>$(`open`,e),children:`打开`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>$(`edit`,e),children:`编辑`}),(0,h.jsx)(`button`,{className:`btn small ghost rp-del`,onClick:()=>$(`del`,e),children:`删除`})]})]},e.id)}),Z.length?null:(0,h.jsx)(`tr`,{children:(0,h.jsx)(`td`,{colSpan:`5`,className:`muted rp-empty`,children:`还没有参考仓库 —— 点「克隆参考仓库」抓一个远程仓库下来(或用 CLI: nx-kv repo ref clone <url>)。`})})]})]})})]}):null,se?(0,h.jsxs)(a,{title:`看板 · ${Y.length}`,onClose:()=>ce(!1),children:[(0,h.jsx)(`div`,{className:`rp-modal-bar`,children:(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>O({id:null,name:``,desc:``}),children:`新建看板`}),(0,h.jsx)(`button`,{className:`btn small ghost`,title:`粘贴/选择看板 JSON,一个看板 = 一个主题`,onClick:()=>k(!0),children:`导入看板`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:dt,children:`导出`})]})}),(0,h.jsxs)(`div`,{className:`rp-board-list`,children:[Y.map(e=>(0,h.jsxs)(`div`,{className:`rp-board-item`,children:[(0,h.jsx)(`span`,{className:`rp-board-name`,children:e.name}),e.desc?(0,h.jsx)(`span`,{className:`muted rp-board-desc`,title:e.desc,children:e.desc}):null,(0,h.jsxs)(`span`,{className:`rp-board-count`,children:[e.repos.length,` 个仓库`]}),(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,title:`点选加入/摘除这个看板的成员仓库`,onClick:()=>w(e.id),children:`成员管理`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>O({id:e.id,name:e.name,desc:e.desc||``}),children:`编辑`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>lt(e),children:`删除看板`})]})]},e.id)),Y.length?null:(0,h.jsx)(`div`,{className:`muted`,children:`还没有看板 —— 建一个当标签用。`}),Y.length&&T.unassigned?.length?(0,h.jsxs)(`div`,{className:`rp-boards-unassigned`,children:[`未分组 `,(0,h.jsx)(`b`,{children:T.unassigned.length}),` 个 —— 不属于任何看板,只在「全部」里可见。`]}):null]})]}):null,(0,h.jsx)(`div`,{className:`rp-table-wrap`,children:(0,h.jsxs)(`table`,{className:`rp-table`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{scope:`col`,style:{width:`24%`},children:`仓库`}),(0,h.jsx)(`th`,{scope:`col`,style:{width:`28%`},children:`路径`}),(0,h.jsx)(`th`,{scope:`col`,children:`绑定的参考仓库`}),(0,h.jsx)(`th`,{scope:`col`,style:{width:`20%`},children:`操作`})]})}),(0,h.jsxs)(`tbody`,{children:[et.map(e=>(0,h.jsx)(x,{r:e,filterBoard:Q,refsOfRepo:rt,acts:bt},e.id)),et.length?null:(0,h.jsx)(`tr`,{children:(0,h.jsx)(`td`,{colSpan:`4`,className:`muted rp-empty`,children:X.length?(0,h.jsxs)(h.Fragment,{children:[`这个组还没有成员`,` `,Q?(0,h.jsx)(`button`,{className:`btn small`,onClick:()=>w(Q.id),children:`添加成员`}):null]}):`还没有登记开发仓库`})})]})]})}),re?(0,h.jsx)(a,{title:g?`编辑仓库 · ${g}`:`添加仓库`,onClose:Re,children:(0,h.jsxs)(`div`,{className:`form-grid`,children:[(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`repo-path`,children:`仓库绝对路径 *`}),(0,h.jsx)(`input`,{id:`repo-path`,placeholder:`D:/code/my-project`,spellCheck:`false`,value:d.path,onChange:F(`path`)})]}),(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`repo-name`,children:`名称`}),(0,h.jsx)(`input`,{id:`repo-name`,placeholder:`留空则用目录末段`,value:d.name,onChange:F(`name`)})]}),ot?(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{children:`项目描述(文档)`}),(0,h.jsxs)(`div`,{className:`rp-docpick`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-doc`,onClick:()=>{S(!1),l(ot.main.docId)},children:[ot.main.title,ot.main.exists?null:(0,h.jsx)(`span`,{className:`rp-doc-todo`,children:`未写`})]}),ot.links.length?(0,h.jsxs)(`span`,{className:`muted`,children:[`另有 `,ot.links.length,` 篇补充文档`]}):null]})]}):null,(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`repo-type`,children:`类型`}),(0,h.jsxs)(`select`,{id:`repo-type`,value:d.type,onChange:F(`type`),children:[(0,h.jsx)(`option`,{value:`dev`,children:`开发仓库(本机开发的)`}),(0,h.jsx)(`option`,{value:`ref`,children:`参考仓库(远程 clone 下来的)`})]})]}),(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`repo-remote`,children:`远程 git 地址`}),(0,h.jsx)(`input`,{id:`repo-remote`,spellCheck:`false`,placeholder:`https://github.com/me/x.git(导出时导它,不含本地路径)`,value:d.remote,onChange:F(`remote`)})]}),(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`repo-notes`,children:`备注`}),(0,h.jsx)(`textarea`,{id:`repo-notes`,placeholder:`补充信息(可选)`,value:d.notes,onChange:F(`notes`)})]}),(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn ghost`,onClick:Re,children:`取消`}),(0,h.jsx)(`button`,{className:`btn`,disabled:!d.path.trim(),onClick:st,children:g?`保存修改`:`添加仓库`})]})]})}):null,D?(0,h.jsx)(a,{title:D.id?`编辑看板`:`新建看板`,onClose:()=>O(null),children:(0,h.jsxs)(`div`,{className:`form-grid`,children:[(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`bd-name`,children:`看板名称 *`}),(0,h.jsx)(`input`,{id:`bd-name`,placeholder:`如 前端 / AI 工具`,value:D.name,onChange:e=>O(t=>({...t,name:e.target.value}))})]}),D.id?(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{children:`领域描述(文档)`}),(0,h.jsx)(`div`,{className:`rp-docpick`,children:(0,h.jsx)(`button`,{type:`button`,className:`rp-doc`+(D.desc?``:` ghost`),title:`打开组介绍文档`,onClick:()=>{let e=Y.find(e=>e.id===D.id);O(null),e&&(e.docRel||e.doc&&e.doc.rel)&&l(`rel:`+(e.docRel||e.doc.rel))},children:D.desc||`未写`})})]}):(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`bd-desc`,children:`初始描述`}),(0,h.jsx)(`textarea`,{id:`bd-desc`,rows:3,spellCheck:`false`,placeholder:`新建时给的介绍正文(之后以 board/<组>.md 文档为准)。
|
|
9
9
|
如:这组仓库在这个环境里的侧重、配合关系、关键路径与搜索关键词。`,value:D.desc,onChange:e=>O(t=>({...t,desc:e.target.value}))})]}),(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn ghost`,onClick:()=>O(null),children:`取消`}),(0,h.jsx)(`button`,{className:`btn`,disabled:!D.name.trim(),onClick:ct,children:D.id?`保存`:`新建看板`})]})]})}):null,oe?(0,h.jsx)(a,{title:`导入看板 JSON`,size:`lg`,onClose:()=>{k(!1),j(``)},children:(0,h.jsxs)(`div`,{className:`form-grid`,children:[(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`bd-imp`,children:`看板 JSON`}),(0,h.jsxs)(`div`,{className:`form-hint`,children:[`结构 `,`{ boards:[{ name, repos:[{ path|name }] }] }`,` —— 按 path 或 name 匹配已登记仓库,匹配不上的会如实报告`]}),(0,h.jsx)(`input`,{id:`bd-imp-file`,type:`file`,accept:`.json,application/json`,onChange:ft}),(0,h.jsx)(`textarea`,{id:`bd-imp`,rows:10,spellCheck:`false`,placeholder:`{"boards":[{"name":"前端","repos":[{"path":"D:/code/a_js/proj/nx-ft"}]}]}`,value:A,onChange:e=>j(e.target.value)})]}),(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn ghost`,onClick:()=>{k(!1),j(``)},children:`取消`}),(0,h.jsx)(`button`,{className:`btn`,disabled:!A.trim(),onClick:ut,children:`导入`})]})]})}):null,M?(0,h.jsx)(a,{title:`看板 JSON(可回灌给导入)`,size:`lg`,onClose:()=>N(null),children:(0,h.jsx)(`textarea`,{className:`bd-exp`,rows:14,readOnly:!0,value:M,spellCheck:`false`})}):null,tt?(0,h.jsx)(te,{board:tt,boards:Y,repos:P,onClose:()=>w(null),onChanged:async()=>{await Promise.all([K(),q()])}}):null,he?(0,h.jsx)(a,{title:`克隆参考仓库`,onClose:()=>{z(!1),V({})},children:(0,h.jsxs)(`div`,{className:`form-grid`,children:[(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`ref-url`,children:`远程 git 地址 *`}),(0,h.jsx)(`input`,{id:`ref-url`,spellCheck:`false`,placeholder:`git@github.com:lib/x.git 或 https://github.com/lib/x`,value:B.url,onChange:e=>ge(t=>({...t,url:e.target.value}))})]}),(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`ref-name`,children:`名称`}),(0,h.jsx)(`input`,{id:`ref-name`,placeholder:`留空则用 URL 末段`,value:B.name,onChange:e=>ge(t=>({...t,name:e.target.value}))})]}),(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`ref-desc`,children:`它参考什么`}),(0,h.jsx)(`input`,{id:`ref-desc`,spellCheck:`false`,placeholder:`如:liquid glass 的官方实现参考`,value:B.desc,onChange:e=>ge(t=>({...t,desc:e.target.value}))})]}),(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{children:`克隆后绑定到(可多选)`}),(0,h.jsxs)(`div`,{className:`rp-pick-list`,children:[(0,h.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,h.jsx)(`span`,{className:`rp-pick-group-label`,children:`开发仓库`}),X.map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!_e[`repo:`+e.id],onChange:t=>V(n=>({...n,[`repo:`+e.id]:t.target.checked}))}),(0,h.jsx)(`span`,{title:e.path,children:e.name})]},e.id)),X.length?null:(0,h.jsx)(`span`,{className:`muted`,children:`(还没有开发仓库)`})]}),(0,h.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,h.jsx)(`span`,{className:`rp-pick-group-label`,children:`看板(项目组)`}),Y.map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!_e[`board:`+e.id],onChange:t=>V(n=>({...n,[`board:`+e.id]:t.target.checked}))}),(0,h.jsx)(`span`,{title:e.desc||``,children:e.name})]},e.id)),Y.length?null:(0,h.jsx)(`span`,{className:`muted`,children:`(还没有看板)`})]})]}),(0,h.jsx)(`div`,{className:`form-hint`,children:`一个参考可同时服务多个仓库/组;之后随时在「绑定…」里增删。`})]}),(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn ghost`,onClick:()=>{z(!1),V({})},children:`取消`}),(0,h.jsx)(`button`,{className:`btn`,disabled:!B.url.trim()||!I?.gitRepoRoot,title:I?.gitRepoRoot?`克隆到 ${I.gitRepoRoot}`:`先在「存储根」设置 gitRepoRoot`,onClick:Ve,children:`克隆`})]})]})}):null,be?(0,h.jsx)(a,{title:`绑定 · ${be.name}`,onClose:()=>xe(null),children:(0,h.jsxs)(`div`,{className:`form-grid`,children:[(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`div`,{className:`form-hint`,children:`勾选 = 绑定,取消 = 摘除(保存时对比差异)。一个参考可同时绑多个仓库/组。`}),(0,h.jsxs)(`div`,{className:`rp-pick-list`,children:[(0,h.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,h.jsx)(`span`,{className:`rp-pick-group-label`,children:`开发仓库`}),X.map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!Se[`repo:`+e.id],onChange:t=>Ce(n=>({...n,[`repo:`+e.id]:t.target.checked}))}),(0,h.jsx)(`span`,{title:e.path,children:e.name})]},e.id)),X.length?null:(0,h.jsx)(`span`,{className:`muted`,children:`(还没有开发仓库)`})]}),(0,h.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,h.jsx)(`span`,{className:`rp-pick-group-label`,children:`看板(项目组)`}),Y.map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!Se[`board:`+e.id],onChange:t=>Ce(n=>({...n,[`board:`+e.id]:t.target.checked}))}),(0,h.jsx)(`span`,{title:e.desc||``,children:e.name})]},e.id)),Y.length?null:(0,h.jsx)(`span`,{className:`muted`,children:`(还没有看板)`})]})]})]}),(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn ghost`,onClick:()=>xe(null),children:`取消`}),(0,h.jsx)(`button`,{className:`btn`,onClick:Ge,children:`保存绑定`})]})]})}):null,H?(0,h.jsx)(a,{title:`「${H.name}」的参考仓库`,onClose:()=>we(null),children:(0,h.jsxs)(`div`,{className:`form-grid`,children:[(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsxs)(`div`,{className:`form-hint`,children:[`勾选 = 绑到「`,H.name,`」,取消 = 摘除。组级参考(绑在看板上)自动对该组所有成员生效,不在这里重复勾。`]}),(0,h.jsx)(`div`,{className:`rp-pick-list`,children:(0,h.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,h.jsx)(`span`,{className:`rp-pick-group-label`,children:`参考仓库`}),Z.map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!Te[e.key],onChange:t=>Ee(n=>({...n,[e.key]:t.target.checked}))}),(0,h.jsx)(`span`,{title:e.remote||``,children:e.name}),e.desc?(0,h.jsx)(`span`,{className:`muted rp-pick-desc`,children:e.desc}):null]},e.key)),Z.length?null:(0,h.jsx)(`span`,{className:`muted`,children:`(还没有参考仓库 —— 先在参考面板里克隆)`})]})})]}),(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn ghost`,onClick:()=>we(null),children:`取消`}),(0,h.jsx)(`button`,{className:`btn`,onClick:Ke,children:`保存绑定`})]})]})}):null,U?(0,h.jsx)(a,{title:`绑定描述 · ${U.ref.name} @ ${U.kind===`board`?`「`+U.targetName+`」`:U.targetName}`,onClose:()=>ke(null),children:(0,h.jsxs)(`div`,{className:`form-grid`,children:[(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsxs)(`label`,{htmlFor:`link-note`,children:[`「`,U.ref.name,`」`,U.kind===`board`?`在这个组里`:`在这个仓库里`,`参考什么`]}),(0,h.jsx)(`div`,{className:`form-hint`,children:`写这条参考在此处的角色与用法(可多行、可含关键路径/搜索词)。留空保存 = 清除。`}),(0,h.jsx)(`textarea`,{id:`link-note`,rows:5,spellCheck:`false`,placeholder:`如:project-graph 画布交互的实现参考;
|
|
10
|
-
看 src/extensions/ 的注册方式,搜 registerExtension。`,value:Ae,onChange:e=>je(e.target.value)})]}),(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn ghost`,onClick:()=>ke(null),children:`取消`}),(0,h.jsx)(`button`,{className:`btn`,onClick:Je,children:`保存`})]})]})}):null,pe?(0,h.jsx)(a,{title:`参考仓库存储根`,onClose:()=>L(!1),children:(0,h.jsxs)(`div`,{className:`form-grid`,children:[(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`roots-ref`,children:`参考仓库存储根(gitRepoRoot)`}),(0,h.jsx)(`input`,{id:`roots-ref`,spellCheck:`false`,placeholder:`如 D:/gitrepo-ref(非 C 盘)`,value:R.gitRepoRoot,onChange:e=>me(t=>({...t,gitRepoRoot:e.target.value}))}),(0,h.jsx)(`div`,{className:`form-hint`,children:`repo ref clone 的落盘位置。不设 = 克隆被拒绝。`})]}),(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`roots-dev`,children:`开发仓库克隆根(gitDevRoot,可选)`}),(0,h.jsx)(`input`,{id:`roots-dev`,spellCheck:`false`,placeholder:`导入布局时开发仓库克隆到哪里`,value:R.gitDevRoot,onChange:e=>me(t=>({...t,gitDevRoot:e.target.value}))})]}),(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn ghost`,onClick:()=>L(!1),children:`取消`}),(0,h.jsx)(`button`,{className:`btn`,onClick:Be,children:`保存`})]})]})}):null,De?(0,h.jsx)(ne,{repo:De.repo,board:De.board,onClose:()=>Oe(null),onSaved:K,onOpenTab:l}):null,Me?(0,h.jsx)(_,{onClose:()=>Ne(!1),onChanged:Xe,repos:P,boards:Y}):null,Ie&&W?(0,h.jsx)(a,{title:`对齐 remote · ${W.name}`,onClose:()=>Le(!1),children:(0,h.jsxs)(`div`,{className:`form-grid`,"data-testid":`rp-remote-modal`,children:[(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsxs)(`div`,{className:`form-hint`,children:[`当前采纳:`,(0,h.jsx)(`b`,{children:W.current||`(无)`}),`。换一条即对齐(key 随之重算;自定义 key 不动)。`]}),(0,h.jsxs)(`div`,{className:`rp-remote-list`,children:[W.remotes.map(e=>(0,h.jsxs)(`div`,{className:`rp-remote-item`,children:[(0,h.jsx)(`span`,{className:`rp-remote-name`,children:e.name}),(0,h.jsx)(`span`,{className:`mono rp-remote-url`,children:e.url}),(0,h.jsx)(`span`,{className:`rp-remote-kind`,children:e.kind}),e.current?(0,h.jsx)(`span`,{className:`rp-remote-on`,children:`当前`}):null,(0,h.jsxs)(`span`,{className:`acts`,children:[e.current?null:(0,h.jsx)(`button`,{className:`btn small`,onClick:()=>Qe(e.url),children:`对齐这条`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>$e(e.url),children:`检查`})]})]},e.name+`|`+e.url)),W.remotes.length?null:(0,h.jsx)(`div`,{className:`muted`,children:`这个仓库没有配置 remote —— 先在 git 里 git remote add`})]})]}),G?(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{children:`存在性检查`}),(0,h.jsxs)(`div`,{className:`rp-remote-check`,children:[(0,h.jsx)(`span`,{className:`rp-status `+(G.status===`exists`?`same`:G.status===`missing`?`new`:G.status===`checking`?`checking`:`missing`),children:G.status===`exists`?`存在`:G.status===`missing`?`不存在`:G.status===`checking`?`检查中`:`不可达`}),(0,h.jsx)(`span`,{className:`mono rp-remote-url`,children:G.url}),(0,h.jsx)(`span`,{className:`muted`,children:G.detail})]})]}):null,(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn ghost`,onClick:()=>Le(!1),children:`关闭`}),(0,h.jsx)(`button`,{className:`btn`,onClick:()=>$e(``),children:`检查当前 remote`})]})]})}):null,
|
|
10
|
+
看 src/extensions/ 的注册方式,搜 registerExtension。`,value:Ae,onChange:e=>je(e.target.value)})]}),(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn ghost`,onClick:()=>ke(null),children:`取消`}),(0,h.jsx)(`button`,{className:`btn`,onClick:Je,children:`保存`})]})]})}):null,pe?(0,h.jsx)(a,{title:`参考仓库存储根`,onClose:()=>L(!1),children:(0,h.jsxs)(`div`,{className:`form-grid`,children:[(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`roots-ref`,children:`参考仓库存储根(gitRepoRoot)`}),(0,h.jsx)(`input`,{id:`roots-ref`,spellCheck:`false`,placeholder:`如 D:/gitrepo-ref(非 C 盘)`,value:R.gitRepoRoot,onChange:e=>me(t=>({...t,gitRepoRoot:e.target.value}))}),(0,h.jsx)(`div`,{className:`form-hint`,children:`repo ref clone 的落盘位置。不设 = 克隆被拒绝。`})]}),(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{htmlFor:`roots-dev`,children:`开发仓库克隆根(gitDevRoot,可选)`}),(0,h.jsx)(`input`,{id:`roots-dev`,spellCheck:`false`,placeholder:`导入布局时开发仓库克隆到哪里`,value:R.gitDevRoot,onChange:e=>me(t=>({...t,gitDevRoot:e.target.value}))})]}),(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn ghost`,onClick:()=>L(!1),children:`取消`}),(0,h.jsx)(`button`,{className:`btn`,onClick:Be,children:`保存`})]})]})}):null,De?(0,h.jsx)(ne,{repo:De.repo,board:De.board,onClose:()=>Oe(null),onSaved:K,onOpenTab:l}):null,Me?(0,h.jsx)(_,{onClose:()=>Ne(!1),onChanged:Xe,repos:P,boards:Y}):null,Ie&&W?(0,h.jsx)(a,{title:`对齐 remote · ${W.name}`,onClose:()=>Le(!1),children:(0,h.jsxs)(`div`,{className:`form-grid`,"data-testid":`rp-remote-modal`,children:[(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsxs)(`div`,{className:`form-hint`,children:[`当前采纳:`,(0,h.jsx)(`b`,{children:W.current||`(无)`}),`。换一条即对齐(key 随之重算;自定义 key 不动)。`]}),(0,h.jsxs)(`div`,{className:`rp-remote-list`,children:[W.remotes.map(e=>(0,h.jsxs)(`div`,{className:`rp-remote-item`,children:[(0,h.jsx)(`span`,{className:`rp-remote-name`,children:e.name}),(0,h.jsx)(`span`,{className:`mono rp-remote-url`,children:e.url}),(0,h.jsx)(`span`,{className:`rp-remote-kind`,children:e.kind}),e.current?(0,h.jsx)(`span`,{className:`rp-remote-on`,children:`当前`}):null,(0,h.jsxs)(`span`,{className:`acts`,children:[e.current?null:(0,h.jsx)(`button`,{className:`btn small`,onClick:()=>Qe(e.url),children:`对齐这条`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>$e(e.url),children:`检查`})]})]},e.name+`|`+e.url)),W.remotes.length?null:(0,h.jsx)(`div`,{className:`muted`,children:`这个仓库没有配置 remote —— 先在 git 里 git remote add`})]})]}),G?(0,h.jsxs)(`div`,{className:`form-field`,children:[(0,h.jsx)(`label`,{children:`存在性检查`}),(0,h.jsxs)(`div`,{className:`rp-remote-check`,children:[(0,h.jsx)(`span`,{className:`rp-status `+(G.status===`exists`?`same`:G.status===`missing`?`new`:G.status===`checking`?`checking`:`missing`),children:G.status===`exists`?`存在`:G.status===`missing`?`不存在`:G.status===`checking`?`检查中`:`不可达`}),(0,h.jsx)(`span`,{className:`mono rp-remote-url`,children:G.url}),(0,h.jsx)(`span`,{className:`muted`,children:G.detail})]})]}):null,(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn ghost`,onClick:()=>Le(!1),children:`关闭`}),(0,h.jsx)(`button`,{className:`btn`,onClick:()=>$e(``),children:`检查当前 remote`})]})]})}):null,s]})}export{S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,f as t,h as n}from"./attach-v8BxRJ7p.js";import{
|
|
1
|
+
import{d as e,f as t,h as n}from"./attach-v8BxRJ7p.js";import{U as r,t as i}from"./index-CHdHAdre.js";var a=n(t(),1);function o(e,t={}){if(!e||!e.view)return[];switch(e.view){case`dir`:{let n=[];return t.boardName&&n.push(t.boardName),t.dirName&&n.push(t.dirName),e.task&&(/^draft/i.test(String(e.task))?n.push(`draft`):n.push(t.pageTitle||`#${e.task}`)),n}case`group`:return t.boardName?[t.boardName]:[`项目组`];case`repos`:return[`仓库管理`];case`cloud`:return[`云端总览`];case`overview`:return[`全部目录总览`];case`templates`:return[`任务模板`];default:return[]}}function s(e,t={}){if(!e||!e.view)return``;switch(e.view){case`dir`:return e.task?`#/dir/${encodeURIComponent(e.key||``)}`:t.boardId?`#/group/${encodeURIComponent(t.boardId)}`:`#/overview`;case`group`:return`#/overview`;case`overview`:return``;default:return`#/overview`}}function c(e,t=[],n={}){if(!e)return{boardName:``,boardId:``,dirName:``,pageTitle:``};let r=(n.boards||[]).find(t=>t.id===e.key),i=(t||[]).find(t=>t.key===e.key),a=i&&i.repo||(n.repos||[]).find(e=>i&&(e.id===i.repo?.id||e.path===i.cwd))||null,o=a&&a.boards&&a.boards[0]||null,s=i&&e.task?(i.tasks||[]).find(t=>String(t.id)===String(e.task)):null;return{boardName:r&&r.name||o&&o.name||``,boardId:r&&r.id||o&&o.id||``,dirName:i?i.name:``,pageTitle:s?`#${s.id}`:``}}var l=e();function u({route:e,ctx:t,onNavigate:n,onBack:r,inline:i=!1}){let c=(0,a.useMemo)(()=>o(e,t),[e,t]),u=(0,a.useMemo)(()=>s(e,t),[e,t]);return c.length?(0,l.jsxs)(`nav`,{className:`nx-crumb`+(i?` nx-crumb-inline`:``),"aria-label":`当前位置`,children:[u&&n?(0,l.jsx)(`button`,{type:`button`,className:`nx-crumb-back`,title:`返回上一级`,"aria-label":`返回上一级`,onClick:()=>r?r():n(u),children:`←`}):null,(0,l.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`[`}),c.map((e,t)=>(0,l.jsxs)(`span`,{className:`nx-crumb-i`,children:[t>0?(0,l.jsx)(`span`,{className:`nx-crumb-sep`,children:`/`}):null,(0,l.jsx)(`span`,{className:`nx-crumb-t`,children:e})]},`${e}-${t}`)),(0,l.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`]`})]}):null}function d(){let e=r()||{},t=e.route||{},n=e.rows||[],d=e.repoData||{},f=(0,a.useMemo)(()=>c(t,n,d),[t,n,d]);return(0,a.useMemo)(()=>o(t,f),[t,f]).length?(0,l.jsx)(u,{route:t,ctx:f,onNavigate:e.onNavigate,onBack:()=>{let n=i();if(n&&e.onNavigate){e.onNavigate(n);return}let r=s(t,f);r&&e.onNavigate&&e.onNavigate(r)},inline:!0}):null}export{d as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{d as e,f as t,h as n,o as r,s as i,u as a}from"./attach-v8BxRJ7p.js";import{
|
|
2
|
-
`)[0]);return(0,_.jsx)(`div`,{className:`pp-items-item`,children:o?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`div`,{className:`pp-items-body`,children:(0,_.jsx)(y,{value:e,onChange:e=>m(t,e),placeholder:r,rows:i,sections:a})}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>h(t),title:`删除第 ${t+1} 条`,children:`删除`})]}):(0,_.jsxs)(`button`,{type:`button`,className:`pp-items-row`,disabled:n,title:`点击展开编辑`,onClick:()=>p(t),children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`span`,{className:`pp-items-title`,children:s||`(空)`}),(0,_.jsxs)(`span`,{className:`pp-items-len`,children:[String(e).length,` 字`]})]})},t)})}):(0,_.jsx)(_.Fragment,{children:e.map((e,t)=>(0,_.jsxs)(`div`,{className:`pp-items-item`,children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`div`,{className:`pp-items-body`,children:(0,_.jsx)(y,{value:e,onChange:e=>m(t,e),placeholder:r,rows:i,sections:a,hint:o})}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>h(t),title:`删除第 ${t+1} 条`,children:`删除`})]},t))})}var x=10,S=[{id:`template`,label:`任务模板`},{id:`suffix`,label:`回调提示词`},{id:`ack`,label:`ack 总结`}];function C({listFlag:e,listKey:t,placeholder:n,offText:r}){let i=a(),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(-1),f=(0,g.useCallback)(()=>{p(`/api/localtasks`).then(e=>s(e?.settings?.[t]??[])).catch(e=>i(`读取失败:`+(e.message||e)))},[t,i]);(0,g.useEffect)(()=>{f()},[f]);let m=async n=>{if(!(n==null||c)){l(!0);try{let a=(await p(`/api/localtasks/setting`,{method:`PATCH`,body:{[e]:n}}))?.[t]??[];s(a),i(a.length?`已保存(${a.length} 条)`:r)}catch(e){i(String(e.message||e))}finally{l(!1)}}};return(0,_.jsxs)(`div`,{className:`setp-suffix`,children:[o!==null&&!o.length&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`已关闭`}),o!==null&&(0,_.jsx)(b,{items:o,onChange:s,disabled:c,placeholder:n,sections:!0,accordion:!0,openIndex:u,onOpenChange:d}),(0,_.jsxs)(`div`,{className:`setp-proj-a`,children:[(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:c||o===null||o.length>=x,onClick:()=>{let e=o.length;s([...o,``]),d(e)},children:`添加一条…`}),(0,_.jsx)(`span`,{className:`spacer`}),(0,_.jsx)(`button`,{className:`btn sm`,disabled:c||o===null,onClick:()=>m(o),children:`保存`}),(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:c||o===null,onClick:()=>m([]),title:r,children:`关闭`}),(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:c,onClick:f,children:`撤销改动`})]})]})}function w({openTemplates:e}){let t=a(),n=d(),[r,i]=(0,g.useState)(!1),o=n.templates||[],[s,c]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!o.length){c(null);return}(!s||!o.some(e=>e.id===s))&&c(n.defaultId||o[0].id)},[o,n.defaultId,s]);let l=o.find(e=>e.id===s)||null,u=l?f(l.body,l.values||{}):``,p=async(e,r)=>{i(!0);try{await n.update(e.id,{values:r}),t(`已保存「${e.name}」的槽位内容`)}catch(e){t(String(e.message||e))}finally{i(!1)}};return n.unsupported?(0,_.jsx)(`div`,{className:`setp-note`,children:`当前服务比面板旧——重启面板后才有模板功能。`}):o.length?(0,_.jsxs)(`div`,{className:`setp-tpl-split`,children:[(0,_.jsxs)(`div`,{className:`setp-tpl-side`,children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`选用模板`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>e?.(),children:`管理…`})]}),(0,_.jsx)(`div`,{className:`setp-tpl-list`,role:`listbox`,"aria-label":`任务模板`,children:o.map(e=>(0,_.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.id===s,className:`setp-tpl-pick${e.id===s?` is-on`:``}`,onClick:()=>c(e.id),children:[(0,_.jsx)(`span`,{className:`setp-tpl-name`,children:e.name}),e.id===n.defaultId&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`默认`}),e.builtin&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`内置`})]},e.id))})]}),(0,_.jsx)(`div`,{className:`setp-tpl-main`,children:l?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`setp-row`,children:(0,_.jsxs)(`span`,{children:[`槽位内容 · `,l.name]})}),(0,_.jsx)(h,{body:l.body,values:l.values,disabled:r,onSave:e=>p(l,e)}),u.trim()?(0,_.jsxs)(`details`,{className:`setp-tpl-preview`,children:[(0,_.jsx)(`summary`,{children:`预览新建任务正文`}),(0,_.jsx)(`pre`,{className:`setp-tpl-preview-body`,children:u})]}):null]}):(0,_.jsx)(`div`,{className:`setp-note`,children:`从左侧选一个模板。`})})]}):(0,_.jsx)(`div`,{className:`setp-note`,children:`还没有模板(内置默认模板加载中…)。`})}function T({openTemplates:e}){let[t,n]=(0,g.useState)(`template`);return(0,_.jsxs)(`div`,{className:`setp-prompts`,children:[(0,_.jsx)(`nav`,{className:`setp-prompts-nav`,"aria-label":`提示词与模板分类`,children:S.map(e=>(0,_.jsx)(`button`,{type:`button`,className:`setp-prompts-tab${t===e.id?` is-on`:``}`,onMouseEnter:()=>n(e.id),onClick:()=>n(e.id),children:e.label},e.id))}),(0,_.jsxs)(`div`,{className:`setp-prompts-pane`,children:[t===`template`&&(0,_.jsx)(w,{openTemplates:e}),t===`suffix`&&(0,_.jsx)(C,{listFlag:`suffixList`,listKey:`taskSuffixList`,placeholder:`一条收尾指令(支持 {{task.text}} / {{goal.*}} 占位符)`,offText:`已关闭回调提示词`}),t===`ack`&&(0,_.jsx)(C,{listFlag:`ackList`,listKey:`ackPromptList`,placeholder:`例如:完成总结按「改了什么 · 怎么验证 · 遗留什么」三段写,每段一行`,offText:`已关闭 ack 提示词`})]})]})}var E=10,D=`不要直接结束本轮:完成上面的任务(%s)之后,继续调用 nx-kv localtask get(带 --summary 当前现状)领取下一条任务,直到 get 返回 timeout 为止。`,O=[{id:`pref`,label:`偏好`,icon:`flow`},{id:`work`,label:`工作区`,icon:`sidebar`},{id:`cloud`,label:`云端与存储`,icon:`cloud`},{id:`prompts`,label:`提示词 / 模板`,icon:`list`},{id:`template`,label:`任务工具`,icon:`clock`},{id:`project`,label:`项目级设置`,icon:`repo`}];function k({repo:e,docStateOf:t,openDoc:n,bindExternal:r,unbind:s}){let c=o()||{},l=a(),[u,d]=(0,g.useState)(e.icon||``),[f,m]=(0,g.useState)(!1),[h,v]=(0,g.useState)(!1);(0,g.useEffect)(()=>{d(e.icon||``)},[e.icon]);let y=async t=>{let n=String(t??u).trim();if(n===String(e.icon||``).trim()){m(!1);return}v(!0);try{await p(`/api/repos/`+encodeURIComponent(e.id),{method:`PATCH`,body:{icon:n}}),d(n),l(n?`已保存「${e.name}」的图标`:`已清除「${e.name}」的图标`),c.refreshRepos&&c.refreshRepos(),m(!1)}catch(e){l(String(e.message||e))}finally{v(!1)}},b=t(e),x=!!(e.getLoop&&e.getLoop.enabled);return(0,_.jsxs)(`div`,{className:`setp-proj`,children:[(0,_.jsxs)(`div`,{className:`setp-proj-head`,children:[(0,_.jsx)(`div`,{className:`setp-icon`+(f?` open`:``),children:(0,_.jsx)(`button`,{type:`button`,className:`setp-icon-btn`,title:u?`项目图标:${u}(点击修改)`:`设置项目图标(emoji / 单字符)`,"aria-label":`项目图标`,"aria-expanded":f,onClick:()=>m(e=>!e),children:u?(0,_.jsx)(`span`,{className:`setp-icon-glyph`,"aria-hidden":!0,children:u}):(0,_.jsx)(i,{name:`folder`,size:14})})}),(0,_.jsxs)(`div`,{className:`setp-proj-meta`,children:[(0,_.jsxs)(`div`,{className:`setp-proj-t`,children:[(0,_.jsx)(`b`,{children:e.name}),(0,_.jsx)(`span`,{className:`setp-badge `+b.kind,children:b.kind===`external`?`外部`:b.kind===`own`?`自有`:`约定`}),x&&(0,_.jsx)(`span`,{className:`setp-badge loop`,children:`持续 get`})]}),(0,_.jsx)(`div`,{className:`setp-proj-p mono`,title:b.label,children:b.label})]}),(0,_.jsxs)(`div`,{className:`setp-proj-actions`,children:[(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>n(e),children:`介绍`}),(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>r(e),children:`绑定…`}),e.doc?(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>s(e),children:`解绑`}):null]})]}),f&&(0,_.jsxs)(`div`,{className:`setp-icon-edit`,role:`group`,"aria-label":`编辑项目图标`,children:[(0,_.jsx)(`input`,{autoFocus:!0,value:u,maxLength:8,placeholder:`emoji 或单字符`,onChange:e=>d(e.target.value),onKeyDown:t=>{t.key===`Enter`&&(t.preventDefault(),y(u)),t.key===`Escape`&&(t.preventDefault(),d(e.icon||``),m(!1))},disabled:h}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm`,disabled:h,onClick:()=>y(u),children:`保存`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:h||!u,title:`清空,侧栏回退默认文件夹图标`,onClick:()=>y(``),children:`清除`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:h,onClick:()=>{d(e.icon||``),m(!1)},children:`取消`})]}),(0,_.jsx)(j,{repo:e})]})}var A=2e3;function j({repo:e}){let t=o()||{},n=a(),r=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[i,s]=(0,g.useState)(!!(r&&r.enabled)),[c,l]=(0,g.useState)(String(r&&r.waitMinutes||10)),[u,d]=(0,g.useState)(()=>{let e=r&&r.template;return(Array.isArray(e)?e:e==null?[]:[e]).map(e=>String(e??``).trim()).filter(Boolean).map(e=>e.replaceAll(`{{task.id}}`,`%s`))}),[f,m]=(0,g.useState)(-1),[h,v]=(0,g.useState)(``),[y,x]=(0,g.useState)([]),[S,C]=(0,g.useState)(!1);(0,g.useEffect)(()=>{p(`/api/localtasks`).then(e=>x(e?.settings?.taskSuffixList??[])).catch(()=>x([]))},[]);let w=async()=>{C(!0);try{let r=u.map(e=>String(e??``).trim().replaceAll(`%s`,`{{task.id}}`)).filter(Boolean).slice(0,E);await p(`/api/repos/`+encodeURIComponent(e.id),{method:`PATCH`,body:{getLoop:{enabled:i,...i?{waitMinutes:Number(c)||10,template:r}:{}}}}),n(i?`已保存「${e.name}」的持续 get 设置(模板 ${r.length} 条)`:`已关闭「${e.name}」的持续 get`),t.refreshRepos&&t.refreshRepos()}catch(e){n(String(e.message||e))}finally{C(!1)}},T=()=>{let e=h.trim();!e||u.length>=E||(d([...u,e.slice(0,A)]),m(u.length),v(``))},O=e=>v(e);return i?(0,_.jsxs)(`div`,{className:`setp-loop`,children:[(0,_.jsxs)(`label`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`持续 get(waitgoal)`}),(0,_.jsxs)(`button`,{className:`toggle`+(i?` on`:``),onClick:()=>s(!1),children:[(0,_.jsx)(`span`,{className:`dot`}),i?`开`:`关`]})]}),i&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`阻塞窗口(分钟)`}),(0,_.jsx)(`input`,{className:`setp-min`,value:c,onChange:e=>l(e.target.value),inputMode:`numeric`})]}),(0,_.jsxs)(`div`,{className:`setp-oneline`,children:[(0,_.jsxs)(`select`,{className:`setp-oneline-pick`,value:``,title:`选提示词模板填入下方输入框`,onChange:e=>{e.target.value&&O(e.target.value),e.target.value=``},children:[(0,_.jsx)(`option`,{value:``,children:`选模板…`}),(0,_.jsx)(`option`,{value:D,children:`内置默认(继续 get 直到 timeout)`}),y.map((e,t)=>(0,_.jsx)(`option`,{value:e,children:(e.split(`
|
|
3
|
-
`)[0]||``).slice(0,40)||`回调提示词 ${t+1}`},t))]}),(0,_.jsx)(`input`,{className:`setp-oneline-input`,value:h,placeholder:`一句话(%s = 任务编号),选模板后可改`,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T()}}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:S||!h.trim(),onClick:T,children:`添加`})]}),
|
|
1
|
+
import{d as e,f as t,h as n,o as r,s as i,u as a}from"./attach-v8BxRJ7p.js";import{A as o,K as s,U as c,a as l,c as u,i as d,n as f,o as p,r as m}from"./index-CHdHAdre.js";import{t as h}from"./template-slots-BquXVLBT.js";var g=n(t(),1),_=e();function v(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 y({value:e,onChange:t,placeholder:n,rows:r=3,sections:i=!1,hint:a=``}){let[o,s]=(0,g.useState)(!1),c=(0,g.useRef)(null),f=(0,g.useRef)(null),p=n=>{let r=c.current,i=r?r.selectionStart:null,a=l(e,n,i);t(a.text),s(!1),requestAnimationFrame(()=>{let e=c.current;if(e){e.focus();try{e.setSelectionRange(a.caret,a.caret)}catch{}}})},h=u(e);return(0,_.jsxs)(`div`,{className:`pp-field`,ref:f,children:[(0,_.jsx)(`textarea`,{ref:c,className:`pp-field-ta mono`,rows:r,value:e,placeholder:n,spellCheck:!1,onChange:e=>t(e.target.value),onBlur:()=>{requestAnimationFrame(()=>{f.current&&f.current.contains(document.activeElement)||s(!1)})}}),(0,_.jsxs)(`div`,{className:`pp-field-bar`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`pp-field-ph-btn`+(o?` on`:``),title:`插入占位符`,onClick:()=>s(e=>!e),children:[`{`,`占位符`,`}`]}),h.length>0&&(0,_.jsx)(`span`,{className:`pp-field-used`,title:`本条用到的占位符`,children:h.map(e=>(0,_.jsx)(`span`,{className:`pp-field-used-chip mono`,children:`{{${e}}}`},e))}),o&&(0,_.jsxs)(`div`,{className:`pp-field-menu`,role:`menu`,children:[m.map(e=>(0,_.jsxs)(`div`,{className:`pp-field-menu-sec`,children:[(0,_.jsx)(`div`,{className:`pp-field-menu-lab`,children:e.label}),e.items.map(e=>(0,_.jsxs)(`button`,{type:`button`,className:`pp-field-menu-item`,title:e.desc,onMouseDown:t=>{t.preventDefault(),p(`{{${e.token}}}`)},children:[(0,_.jsx)(`span`,{className:`mono`,children:`{{${e.token}}}`}),(0,_.jsx)(`span`,{className:`pp-field-menu-desc`,children:e.desc})]},e.token))]},e.label)),i&&(0,_.jsxs)(`div`,{className:`pp-field-menu-sec`,children:[(0,_.jsx)(`div`,{className:`pp-field-menu-lab`,children:`段落`}),d.map(e=>(0,_.jsxs)(`button`,{type:`button`,className:`pp-field-menu-item`,onMouseDown:t=>{t.preventDefault(),p(e.token)},children:[(0,_.jsx)(`span`,{className:`mono`,children:e.token}),(0,_.jsx)(`span`,{className:`pp-field-menu-desc`,children:e.label})]},e.token))]})]})]}),a?(0,_.jsx)(`div`,{className:`pp-field-hint`,children:a}):null]})}function b({items:e,onChange:t,disabled:n=!1,placeholder:r,rows:i=3,sections:a=!1,hint:o=``,accordion:s=!1,openIndex:c,onOpenChange:l}){let[u,d]=(0,g.useState)(-1),f=c===void 0?u:c,p=e=>{d(e),l&&l(e)},m=(n,r)=>t(e.map((e,t)=>t===n?r:e)),h=n=>{t(e.filter((e,t)=>t!==n)),p(e=>e===n?-1:e>n?e-1:e)};return s?(0,_.jsx)(`div`,{className:`pp-items`,children:e.map((e,t)=>{let o=f===t,s=v(e.split(`
|
|
2
|
+
`)[0]);return(0,_.jsx)(`div`,{className:`pp-items-item`,children:o?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`div`,{className:`pp-items-body`,children:(0,_.jsx)(y,{value:e,onChange:e=>m(t,e),placeholder:r,rows:i,sections:a})}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>h(t),title:`删除第 ${t+1} 条`,children:`删除`})]}):(0,_.jsxs)(`button`,{type:`button`,className:`pp-items-row`,disabled:n,title:`点击展开编辑`,onClick:()=>p(t),children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`span`,{className:`pp-items-title`,children:s||`(空)`}),(0,_.jsxs)(`span`,{className:`pp-items-len`,children:[String(e).length,` 字`]})]})},t)})}):(0,_.jsx)(_.Fragment,{children:e.map((e,t)=>(0,_.jsxs)(`div`,{className:`pp-items-item`,children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`div`,{className:`pp-items-body`,children:(0,_.jsx)(y,{value:e,onChange:e=>m(t,e),placeholder:r,rows:i,sections:a,hint:o})}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>h(t),title:`删除第 ${t+1} 条`,children:`删除`})]},t))})}var x=10,S=[{id:`template`,label:`任务模板`},{id:`suffix`,label:`回调提示词`},{id:`ack`,label:`ack 总结`}];function C({listFlag:e,listKey:t,placeholder:n,offText:r}){let i=a(),[o,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(-1),p=(0,g.useCallback)(()=>{s(`/api/localtasks`).then(e=>c(e?.settings?.[t]??[])).catch(e=>i(`读取失败:`+(e.message||e)))},[t,i]);(0,g.useEffect)(()=>{p()},[p]);let m=async n=>{if(!(n==null||l)){u(!0);try{let a=(await s(`/api/localtasks/setting`,{method:`PATCH`,body:{[e]:n}}))?.[t]??[];c(a),i(a.length?`已保存(${a.length} 条)`:r)}catch(e){i(String(e.message||e))}finally{u(!1)}}};return(0,_.jsxs)(`div`,{className:`setp-suffix`,children:[o!==null&&!o.length&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`已关闭`}),o!==null&&(0,_.jsx)(b,{items:o,onChange:c,disabled:l,placeholder:n,sections:!0,accordion:!0,openIndex:d,onOpenChange:f}),(0,_.jsxs)(`div`,{className:`setp-proj-a`,children:[(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:l||o===null||o.length>=x,onClick:()=>{let e=o.length;c([...o,``]),f(e)},children:`添加一条…`}),(0,_.jsx)(`span`,{className:`spacer`}),(0,_.jsx)(`button`,{className:`btn sm`,disabled:l||o===null,onClick:()=>m(o),children:`保存`}),(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:l||o===null,onClick:()=>m([]),title:r,children:`关闭`}),(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:l,onClick:p,children:`撤销改动`})]})]})}function w({openTemplates:e}){let t=a(),n=f(),[r,i]=(0,g.useState)(!1),o=n.templates||[],[s,c]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!o.length){c(null);return}(!s||!o.some(e=>e.id===s))&&c(n.defaultId||o[0].id)},[o,n.defaultId,s]);let l=o.find(e=>e.id===s)||null,u=l?p(l.body,l.values||{}):``,d=async(e,r)=>{i(!0);try{await n.update(e.id,{values:r}),t(`已保存「${e.name}」的槽位内容`)}catch(e){t(String(e.message||e))}finally{i(!1)}};return n.unsupported?(0,_.jsx)(`div`,{className:`setp-note`,children:`当前服务比面板旧——重启面板后才有模板功能。`}):o.length?(0,_.jsxs)(`div`,{className:`setp-tpl-split`,children:[(0,_.jsxs)(`div`,{className:`setp-tpl-side`,children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`选用模板`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>e?.(),children:`管理…`})]}),(0,_.jsx)(`div`,{className:`setp-tpl-list`,role:`listbox`,"aria-label":`任务模板`,children:o.map(e=>(0,_.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.id===s,className:`setp-tpl-pick${e.id===s?` is-on`:``}`,onClick:()=>c(e.id),children:[(0,_.jsx)(`span`,{className:`setp-tpl-name`,children:e.name}),e.id===n.defaultId&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`默认`}),e.builtin&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`内置`})]},e.id))})]}),(0,_.jsx)(`div`,{className:`setp-tpl-main`,children:l?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`setp-row`,children:(0,_.jsxs)(`span`,{children:[`槽位内容 · `,l.name]})}),(0,_.jsx)(h,{body:l.body,values:l.values,disabled:r,onSave:e=>d(l,e)}),u.trim()?(0,_.jsxs)(`details`,{className:`setp-tpl-preview`,children:[(0,_.jsx)(`summary`,{children:`预览新建任务正文`}),(0,_.jsx)(`pre`,{className:`setp-tpl-preview-body`,children:u})]}):null]}):(0,_.jsx)(`div`,{className:`setp-note`,children:`从左侧选一个模板。`})})]}):(0,_.jsx)(`div`,{className:`setp-note`,children:`还没有模板(内置默认模板加载中…)。`})}function T({openTemplates:e}){let[t,n]=(0,g.useState)(`template`);return(0,_.jsxs)(`div`,{className:`setp-prompts`,children:[(0,_.jsx)(`nav`,{className:`setp-prompts-nav`,"aria-label":`提示词与模板分类`,children:S.map(e=>(0,_.jsx)(`button`,{type:`button`,className:`setp-prompts-tab${t===e.id?` is-on`:``}`,onMouseEnter:()=>n(e.id),onClick:()=>n(e.id),children:e.label},e.id))}),(0,_.jsxs)(`div`,{className:`setp-prompts-pane`,children:[t===`template`&&(0,_.jsx)(w,{openTemplates:e}),t===`suffix`&&(0,_.jsx)(C,{listFlag:`suffixList`,listKey:`taskSuffixList`,placeholder:`一条收尾指令(支持 {{task.text}} / {{goal.*}} 占位符)`,offText:`已关闭回调提示词`}),t===`ack`&&(0,_.jsx)(C,{listFlag:`ackList`,listKey:`ackPromptList`,placeholder:`例如:完成总结按「改了什么 · 怎么验证 · 遗留什么」三段写,每段一行`,offText:`已关闭 ack 提示词`})]})]})}var E=10,D=`不要直接结束本轮:完成上面的任务(%s)之后,继续调用 nx-kv localtask get(带 --summary 当前现状)领取下一条任务,直到 get 返回 timeout 为止。`,O=[{id:`pref`,label:`偏好`,icon:`flow`},{id:`work`,label:`工作区`,icon:`sidebar`},{id:`cloud`,label:`云端与存储`,icon:`cloud`},{id:`prompts`,label:`提示词 / 模板`,icon:`list`},{id:`template`,label:`任务工具`,icon:`clock`},{id:`project`,label:`项目级设置`,icon:`repo`}];function k({repo:e,docStateOf:t,openDoc:n,bindExternal:r,unbind:o}){let l=c()||{},u=a(),[d,f]=(0,g.useState)(e.icon||``),[p,m]=(0,g.useState)(!1),[h,v]=(0,g.useState)(!1);(0,g.useEffect)(()=>{f(e.icon||``)},[e.icon]);let y=async t=>{let n=String(t??d).trim();if(n===String(e.icon||``).trim()){m(!1);return}v(!0);try{await s(`/api/repos/`+encodeURIComponent(e.id),{method:`PATCH`,body:{icon:n}}),f(n),u(n?`已保存「${e.name}」的图标`:`已清除「${e.name}」的图标`),l.refreshRepos&&l.refreshRepos(),m(!1)}catch(e){u(String(e.message||e))}finally{v(!1)}},b=t(e),x=!!(e.getLoop&&e.getLoop.enabled);return(0,_.jsxs)(`div`,{className:`setp-proj`,children:[(0,_.jsxs)(`div`,{className:`setp-proj-head`,children:[(0,_.jsx)(`div`,{className:`setp-icon`+(p?` open`:``),children:(0,_.jsx)(`button`,{type:`button`,className:`setp-icon-btn`,title:d?`项目图标:${d}(点击修改)`:`设置项目图标(emoji / 单字符)`,"aria-label":`项目图标`,"aria-expanded":p,onClick:()=>m(e=>!e),children:d?(0,_.jsx)(`span`,{className:`setp-icon-glyph`,"aria-hidden":!0,children:d}):(0,_.jsx)(i,{name:`folder`,size:14})})}),(0,_.jsxs)(`div`,{className:`setp-proj-meta`,children:[(0,_.jsxs)(`div`,{className:`setp-proj-t`,children:[(0,_.jsx)(`b`,{children:e.name}),(0,_.jsx)(`span`,{className:`setp-badge `+b.kind,children:b.kind===`external`?`外部`:b.kind===`own`?`自有`:`约定`}),x&&(0,_.jsx)(`span`,{className:`setp-badge loop`,children:`持续 get`})]}),(0,_.jsx)(`div`,{className:`setp-proj-p mono`,title:b.label,children:b.label})]}),(0,_.jsxs)(`div`,{className:`setp-proj-actions`,children:[(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>n(e),children:`介绍`}),(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>r(e),children:`绑定…`}),e.doc?(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>o(e),children:`解绑`}):null]})]}),p&&(0,_.jsxs)(`div`,{className:`setp-icon-edit`,role:`group`,"aria-label":`编辑项目图标`,children:[(0,_.jsx)(`input`,{autoFocus:!0,value:d,maxLength:8,placeholder:`emoji 或单字符`,onChange:e=>f(e.target.value),onKeyDown:t=>{t.key===`Enter`&&(t.preventDefault(),y(d)),t.key===`Escape`&&(t.preventDefault(),f(e.icon||``),m(!1))},disabled:h}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm`,disabled:h,onClick:()=>y(d),children:`保存`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:h||!d,title:`清空,侧栏回退默认文件夹图标`,onClick:()=>y(``),children:`清除`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:h,onClick:()=>{f(e.icon||``),m(!1)},children:`取消`})]}),(0,_.jsx)(j,{repo:e})]})}var A=2e3;function j({repo:e}){let t=c()||{},n=a(),r=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[i,o]=(0,g.useState)(!!(r&&r.enabled)),[l,u]=(0,g.useState)(String(r&&r.waitMinutes||10)),[d,f]=(0,g.useState)(()=>{let e=r&&r.template;return(Array.isArray(e)?e:e==null?[]:[e]).map(e=>String(e??``).trim()).filter(Boolean).map(e=>e.replaceAll(`{{task.id}}`,`%s`))}),[p,m]=(0,g.useState)(-1),[h,v]=(0,g.useState)(``),[y,x]=(0,g.useState)([]),[S,C]=(0,g.useState)(!1);(0,g.useEffect)(()=>{s(`/api/localtasks`).then(e=>x(e?.settings?.taskSuffixList??[])).catch(()=>x([]))},[]);let w=async()=>{C(!0);try{let r=d.map(e=>String(e??``).trim().replaceAll(`%s`,`{{task.id}}`)).filter(Boolean).slice(0,E);await s(`/api/repos/`+encodeURIComponent(e.id),{method:`PATCH`,body:{getLoop:{enabled:i,...i?{waitMinutes:Number(l)||10,template:r}:{}}}}),n(i?`已保存「${e.name}」的持续 get 设置(模板 ${r.length} 条)`:`已关闭「${e.name}」的持续 get`),t.refreshRepos&&t.refreshRepos()}catch(e){n(String(e.message||e))}finally{C(!1)}},T=()=>{let e=h.trim();!e||d.length>=E||(f([...d,e.slice(0,A)]),m(d.length),v(``))},O=e=>v(e);return i?(0,_.jsxs)(`div`,{className:`setp-loop`,children:[(0,_.jsxs)(`label`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`持续 get(waitgoal)`}),(0,_.jsxs)(`button`,{className:`toggle`+(i?` on`:``),onClick:()=>o(!1),children:[(0,_.jsx)(`span`,{className:`dot`}),i?`开`:`关`]})]}),i&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`阻塞窗口(分钟)`}),(0,_.jsx)(`input`,{className:`setp-min`,value:l,onChange:e=>u(e.target.value),inputMode:`numeric`})]}),(0,_.jsxs)(`div`,{className:`setp-oneline`,children:[(0,_.jsxs)(`select`,{className:`setp-oneline-pick`,value:``,title:`选提示词模板填入下方输入框`,onChange:e=>{e.target.value&&O(e.target.value),e.target.value=``},children:[(0,_.jsx)(`option`,{value:``,children:`选模板…`}),(0,_.jsx)(`option`,{value:D,children:`内置默认(继续 get 直到 timeout)`}),y.map((e,t)=>(0,_.jsx)(`option`,{value:e,children:(e.split(`
|
|
3
|
+
`)[0]||``).slice(0,40)||`回调提示词 ${t+1}`},t))]}),(0,_.jsx)(`input`,{className:`setp-oneline-input`,value:h,placeholder:`一句话(%s = 任务编号),选模板后可改`,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T()}}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:S||!h.trim(),onClick:T,children:`添加`})]}),d.length?(0,_.jsx)(b,{items:d,onChange:f,disabled:S,placeholder:`一句话(%s = 任务编号)`,accordion:!0,openIndex:p,onOpenChange:m}):(0,_.jsx)(`div`,{className:`setp-note`,children:`未配置模板 —— 用默认「继续调用 localtask get 直到 timeout」。`}),(0,_.jsxs)(`div`,{className:`setp-proj-a`,children:[(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:S||d.length>=E,title:d.length>=E?`最多 ${E} 条`:`新增一条「继续 get」指令`,onClick:()=>{f([...d,``]),m(d.length)},children:`添加一条…`}),(0,_.jsx)(`button`,{className:`btn sm`,disabled:S,onClick:w,children:`保存持续 get 设置`})]})]})]}):(0,_.jsxs)(`button`,{className:`setp-gl-off`,title:`开启持续 get(waitgoal)`,onClick:()=>o(!0),children:[(0,_.jsx)(`span`,{className:`dot`}),`持续 get`]})}function M(){let e=c()||{},t=a(),{dialog:n,node:l}=r(),u=e.prefs||{},d=e.patchPrefs||(()=>{}),f=e.model,p=e.repoData&&e.repoData.repos||[],[m,h]=(0,g.useState)(`pref`),[v,y]=(0,g.useState)(null),[b,x]=(0,g.useState)(!1),S=(0,g.useCallback)(async()=>{try{y(await s(`/api/setting`))}catch(e){t(`读取设置失败:`+(e.message||e))}},[t]);(0,g.useEffect)(()=>{S()},[S]);let C=e=>e().catch(e=>t(String(e.message||e))),w=e=>C(async()=>{x(!0);try{y(await s(`/api/setting`,{method:`POST`,body:e})),t(`已保存`)}finally{x(!1)}}),E=e=>e.doc&&e.doc.path?{kind:`external`,docId:`path:`+e.doc.path,label:e.doc.path}:e.doc&&e.doc.rel?{kind:`own`,docId:`rel:`+e.doc.rel,label:e.doc.rel}:{kind:`default`,docId:`rel:`+(e.docRel||``),label:e.docRel||`(未创建)`},D=e=>{if(!f)return;let n=E(e);if(!n.docId||n.docId===`rel:`)return t(`这个项目还没有介绍文档`);o(f,{component:`doc`,name:e.name+` · 介绍`,config:{docId:n.docId},location:`center`})},A=r=>C(async()=>{let i=await n({title:`绑定外部介绍文档`,input:!0,placeholder:`D:\\vault\\nx\\nx-kv.md(只读引用,不进导出包)`});i&&(await s(`/api/docs/bind`,{method:`POST`,body:{repo:r.key,path:i.trim()}}),t(`已绑定:${i.trim()}`),e.refreshRepos&&e.refreshRepos())}),j=n=>C(async()=>{await s(`/api/docs/bind`,{method:`POST`,body:{repo:n.key,reset:!0}}),t(`已解除绑定(回到约定路径)`),e.refreshRepos&&e.refreshRepos()}),M={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)(`button`,{className:`btn ghost sm`,onClick:()=>d({hidden:[]}),children:`恢复显示`})]})]}),work:(0,_.jsx)(_.Fragment,{children:(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`布局`}),(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:async()=>{await n({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:()=>w({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)(`button`,{className:`btn ghost sm`,disabled:!v||b,onClick:()=>w({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)(`button`,{className:`btn ghost sm`,disabled:!v||b,onClick:()=>w({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)(`button`,{className:`btn ghost sm`,disabled:!v||b,onClick:()=>w({gitDevRoot:v.gitDevRoot}),children:`保存`})]})]})]}),prompts:(0,_.jsx)(T,{openTemplates:()=>{f&&o(f,{component:`templates`,name:`任务模板`,config:{},location:`center`})}}),project:(0,_.jsx)(_.Fragment,{children:(0,_.jsxs)(`div`,{className:`setp-projs`,children:[p.map(e=>(0,_.jsx)(k,{repo:e,docStateOf:E,openDoc:D,bindExternal:A,unbind:j},e.key)),!p.length&&(0,_.jsx)(`div`,{className:`setp-note`,children:`还没有登记仓库。`})]})})};return(0,_.jsxs)(`div`,{className:`setp`,children:[(0,_.jsx)(`nav`,{className:`setp-nav`,"aria-label":`设置分区`,children:O.map(e=>(0,_.jsxs)(`button`,{className:`setp-navitem`+(m===e.id?` on`:``),"aria-current":m===e.id,onMouseEnter:()=>h(e.id),onClick:()=>h(e.id),children:[(0,_.jsx)(i,{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:O.find(e=>e.id===m).label}),M[m]]}),l]})}export{M as default};
|