nx-kv 0.67.2 → 0.67.3
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 +21 -0
- package/package.json +1 -1
- package/src/web/frontend/workspace/open.ts +4 -2
- package/src/web/public/assets/{bar-C0Q_Qe4z.js → bar-C-XvccT_.js} +1 -1
- package/src/web/public/assets/{composer-launch-BF3_hyn5.js → composer-launch-DocQvHKh.js} +1 -1
- package/src/web/public/assets/{composer-panel-BWJzkrXS.js → composer-panel-CNHQT6LM.js} +1 -1
- package/src/web/public/assets/{dag-C3OiVSpt.js → dag-D--zCQnc.js} +1 -1
- package/src/web/public/assets/{dir-BD8bocip.js → dir-BUHnfIMz.js} +1 -1
- package/src/web/public/assets/{doc-CVIVBV6n.js → doc-z8eXM9dk.js} +1 -1
- package/src/web/public/assets/{group-DaBalriD.js → group-hJw7aCS3.js} +1 -1
- package/src/web/public/assets/{index-q51dndMj.js → index-GSk_7QV5.js} +3 -3
- package/src/web/public/assets/{md-history-COQu16vy.js → md-history-sxG54jJ_.js} +1 -1
- package/src/web/public/assets/{progress-CDh6DY7g.js → progress-CPQSMxLp.js} +1 -1
- package/src/web/public/assets/{refs-t79ynSY8.js → refs-Cp2bMHIB.js} +1 -1
- package/src/web/public/assets/{repo-form-modal-dZqpHyUj.js → repo-form-modal-DJMWkbA6.js} +1 -1
- package/src/web/public/assets/{repos-DdhOQJqF.js → repos-CwB-fsSw.js} +1 -1
- package/src/web/public/assets/{settings-2rNJ_YAJ.js → settings-CTsPHoTG.js} +1 -1
- package/src/web/public/assets/{task-PK9OACFo.js → task-_XhRBJ8y.js} +1 -1
- package/src/web/public/assets/{task-ops-CWb5frMG.js → task-ops-D3pxL8l5.js} +1 -1
- package/src/web/public/assets/{templates-B9Nu7yqL.js → templates-MH1Mxml2.js} +3 -3
- package/src/web/public/assets/{tool-bar-DPXnjdQF.js → tool-bar-DpfJRjFG.js} +1 -1
- package/src/web/public/assets/{use-rail-drag-B6J0iqFK.js → use-rail-drag-DcUzHeV_.js} +1 -1
- package/src/web/public/index.html +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,f as t,h as n,i as r,l as i,t as a,u as o}from"./popup-dBtYqEM1.js";import{d as s}from"./task-status-Cjsm0xF7.js";import{S as c,_ as l,g as u,o as d,p as f,v as p,x as ee,y as m}from"./md-history-COQu16vy.js";var h=n(t(),1),g=e(),_=a,v={position:(e,t)=>(e.position||0)-(t.position||0)||String(e.id).localeCompare(String(t.id)),name:(e,t)=>String(e.name||``).localeCompare(String(t.name||``)),kind:(e,t)=>String(e.kind).localeCompare(String(t.kind))||String(e.name||``).localeCompare(String(t.name||``))};function y(e,{onRemove:t,onPreview:n,onPreviewMd:r,onOpenTask:i,onOpenDoc:a,onEditNote:o,onReplace:s}){let c=e.kind===`image`?m(e.id):``;return(0,g.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,g.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:c,name:e.name}),title:`点击看大图`,children:(0,g.jsx)(`img`,{src:c,alt:e.name,loading:`lazy`})}):(0,g.jsx)(`span`,{className:`att-kind-badge`,children:p(e.kind)}),(0,g.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>i?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:e.note||e.title||e.name||`打开文档`,onClick:()=>a?.(e.refId?`ref:`+e.refId:e.locator||e.targetRef),children:e.title||e.name}):e.kind===`url`?(0,g.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,g.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,g.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,g.jsx)(`span`,{children:e.sizeText}):null,e.kind===`mdfile`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 源文件已不在`:``]}):null,e.kind===`folder`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 目录已不在`:``]}):null,e.note?(0,g.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`mdfile`?(0,g.jsx)(`span`,{className:`att-item-acts`,children:(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`按 md 渲染磁盘当前内容(读时核对指纹)`,onClick:()=>r?.(e),children:`预览`})}):null,e.kind===`file`||e.kind===`image`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[(0,g.jsx)(`a`,{className:`att-act`,href:m(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,g.jsx)(`a`,{className:`att-act`,href:m(e.id),download:e.name,children:`下载`})]}):null,e.kind===`ref`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[o?(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`改这条绑定的一行说明(交付清单会透出)`,onClick:()=>o(e),children:`✎ 说明`}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`换成另一篇文档(替换这条绑定)`,onClick:()=>s?.(e),children:`⇄ 更换`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}function b({host:e=`task`,hostId:t,hostKey:n,hostCwd:a,refId:p,allow:m={file:!0,url:!0,folder:!0,task:!1,ref:!1,repo:!1},taskOptions:b=[],docOptions:x,disabled:S=!1,disabledText:C=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:w,onChanged:T,onOpenTask:E,onOpenDoc:D}){let O=i(),{dialog:te,node:ne}=r(),[k,A]=(0,h.useState)([]),[j,M]=(0,h.useState)(!1),[N,P]=(0,h.useState)(``),[re,F]=(0,h.useState)(!1),[ie,I]=(0,h.useState)(!1),[ae,L]=(0,h.useState)(!1),[R,oe]=(0,h.useState)(`position`),[z,B]=(0,h.useState)(null),[V,H]=(0,h.useState)(null),[U,W]=(0,h.useState)(!1),[G,K]=(0,h.useState)(null),[q,J]=(0,h.useState)(null),Y=(0,h.useMemo)(()=>ee(e,{hostId:t,hostKey:n,hostCwd:a,refId:p}),[e,t,n,a,p]),X=(0,h.useCallback)(async()=>{if(S){A([]);return}M(!0),P(``);try{let e=await Y.list();A((e.attachments||[]).map(c))}catch(e){P(String(e.message||e))}finally{M(!1)}},[Y,S]);(0,h.useEffect)(()=>{X()},[X]),(0,h.useImperativeHandle)(w,()=>({open:()=>F(!0),refresh:X}),[X]),(0,h.useEffect)(()=>{if(!G)return;let e=e=>{e.key===`Escape`&&K(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[G]);let Z=(0,h.useMemo)(()=>[...k].sort(v[R]||v.position),[k,R]),Q=Z.filter(e=>e.area===`inline`),$=Z.filter(e=>e.area===`area`),se=async(e,t)=>{if(S)return;let n=f(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;L(!0);let i=0;for(let e of r)try{let t=await u(e),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await Y.attach({fileId:n,name:t.name}),i+=1}catch(t){O(`「${e.name||`文件`}」添加失败:${t.message||t}`)}L(!1),i&&(O(`已挂到附件区 ${i} 个文件`),await X(),T?.())},ce=async r=>{if(r&&e!==`doc`)try{let e=await te({title:`说明 · ${r.name}`,input:!0,placeholder:`这一行里大概是什么(交付清单会透出给 agent)`,value:r.note||``,okText:`保存说明`});if(e===null)return;let i=typeof e==`string`?e:e&&e.value||``,s={id:Number(t),...n?{key:n}:a?{cwd:a}:{},attachment:r.id,note:i};await o(`/api/localtasks/attach-note`,{method:`PATCH`,body:s}),O(i?`已保存说明:${i}`:`已清空说明`),await X(),T?.()}catch(e){O(`改说明失败:${e.message||e}`)}},le=e=>{e&&(H(e),F(!0))},ue=async()=>{let e=z;if(e){W(!0);try{await Y.detach(e.id),B(null),O(`已解除关联:${e.name}`),await X(),T?.()}catch(e){O(`移除失败:${e.message||e}`)}finally{W(!1)}}},de=async e=>{if(e)try{let t=await o(`/api/docs/mdfile?attachment=${encodeURIComponent(String(e.id))}`),n=String(t.body||``);J({name:e.name||`md`,html:s(n),path:String(t.absPath||e.absPath||``),stale:!!t.stale,missing:!!t.missing})}catch(e){O(`读取失败:${e.message||e}`)}},fe=!j&&!N&&!k.length;return(0,g.jsxs)(`div`,{className:`att-area${S?` is-disabled`:``}`,onDragOver:e=>{!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),I(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||I(!1)},onDrop:e=>{I(!1),!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),se(null,e))},children:[ne,(0,g.jsxs)(`div`,{className:`att-area-head`+(ie&&!S?` is-over`:``),children:[(0,g.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,k.length?(0,g.jsx)(`span`,{className:`att-count`,children:k.length}):null,ae?(0,g.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,g.jsxs)(`span`,{className:`att-area-acts`,children:[k.length?(0,g.jsxs)(`select`,{className:`att-sort`,value:R,onChange:e=>oe(e.target.value),"aria-label":`附件排序`,children:[(0,g.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,g.jsx)(`option`,{value:`name`,children:`按名称`}),(0,g.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:S,onClick:()=>F(!0),children:`添加附件`})]})]}),S?(0,g.jsx)(`div`,{className:`att-empty`,children:C}):null,j?(0,g.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,N?(0,g.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,N]}):null,fe?(0,g.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,Q.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[l.inline,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),Q.map(t=>y(t,{onRemove:B,onPreview:K,onPreviewMd:de,onOpenTask:E,onOpenDoc:D,onEditNote:e===`task`?ce:void 0,onReplace:le,key:t.id}))]}):null,$.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[l.area,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),$.map(t=>y(t,{onRemove:B,onPreview:K,onPreviewMd:de,onOpenTask:E,onOpenDoc:D,onEditNote:e===`task`?ce:void 0,onReplace:le,key:t.id}))]}):null,(0,g.jsx)(d,{open:re,host:e,hostId:t,hostKey:n,hostCwd:a,refId:p,allow:m,taskOptions:b,docOptions:x,replaceAttachment:V?V.id:null,replaceNote:V&&V.note||``,onClose:()=>{F(!1),H(null)},onDone:async()=>{H(null),await X(),T?.()}}),z?(0,g.jsx)(_,{title:`移除附件`,size:`sm`,busy:U,onClose:U?void 0:()=>B(null),footer:(0,g.jsxs)(`div`,{className:`att-foot`,children:[(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:U,onClick:()=>B(null),children:`取消`}),(0,g.jsx)(`button`,{type:`button`,className:`btn`,disabled:U,onClick:()=>void ue(),children:`移除(解除关联)`})]}),children:(0,g.jsxs)(`div`,{className:`att-confirm`,children:[(0,g.jsx)(`div`,{className:`att-confirm-name`,children:z.name}),(0,g.jsxs)(`div`,{className:`att-confirm-text`,children:[`会从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源本身(行与字节)保留在孤儿池, 之后仍可重新挂载;需要清理时由库级 GC 统一回收。`]})]})}):null,q?(0,g.jsx)(_,{title:(0,g.jsxs)(`span`,{children:[q.name,(0,g.jsx)(`span`,{className:`att-md-path`,children:q.path})]}),size:`lg`,onClose:()=>J(null),footer:(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>J(null),children:`关闭`}),children:q.missing?(0,g.jsxs)(`div`,{className:`att-empty`,children:[`源文件已不在:`,q.path||`(路径为空)`]}):(0,g.jsxs)(`div`,{className:`att-md-preview`,children:[q.stale?(0,g.jsx)(`div`,{className:`att-md-warn`,children:`内容已变化(与登记指纹不一致),以下为磁盘当前内容。`}):null,(0,g.jsx)(`article`,{dangerouslySetInnerHTML:{__html:q.html}})]})}):null,G?(0,g.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&K(null)},children:(0,g.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,g.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,g.jsx)(`span`,{className:`att-lightbox-name`,children:G.name}),(0,g.jsx)(`a`,{className:`att-lightbox-open`,href:G.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,g.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>K(null),children:`×`})]}),(0,g.jsx)(`img`,{className:`att-lightbox-img`,src:G.src,alt:G.name})]})}):null]})}function x(e=`task`,t=!0){let n=(0,h.useCallback)(t=>`nxkv.${e}Dock${t}`,[e]),[r,i]=(0,h.useState)(()=>{let e=localStorage.getItem(n(`Open`));return e===null?t:e!==`0`}),[a,o]=(0,h.useState)(()=>localStorage.getItem(n(`Tab`))||`attach`),[s,c]=(0,h.useState)(()=>{let e=Number(localStorage.getItem(n(`H`)));return Number.isFinite(e)&&e>=96?e:176}),l=(0,h.useRef)(s);l.current=s;let u=(0,h.useRef)(null),[d,f]=(0,h.useState)(!1),p=(0,h.useRef)(176);return(0,h.useEffect)(()=>{localStorage.setItem(n(`Open`),r?`1`:`0`)},[r,n]),(0,h.useEffect)(()=>{localStorage.setItem(n(`Tab`),a)},[a,n]),{dockOpen:r,setDockOpen:i,dockTab:a,setDockTab:o,dockH:s,dockHRef:l,dockRef:u,dockMax:d,setDockMax:f,dockPrevHRef:p,showDockTab:(0,h.useCallback)(e=>{o(e),i(!0)},[]),onDockDragStart:(0,h.useCallback)(e=>{if(!r)return;e.preventDefault(),f(!1);let t=e.clientY,i=l.current,a=u.current?.parentElement?.clientHeight||window.innerHeight,o=e=>Math.max(96,Math.min(Math.round(a*.62),Math.round(e))),s=e=>{let n=o(i-(e.clientY-t));l.current=n,c(n)},d=()=>{window.removeEventListener(`mousemove`,s),window.removeEventListener(`mouseup`,d),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(n(`H`),String(l.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,s),window.addEventListener(`mouseup`,d)},[r,n]),toggleDockMax:(0,h.useCallback)(()=>{if(d){c(p.current),f(!1);return}p.current=l.current;let e=u.current?.parentElement?.clientHeight||window.innerHeight,t=Math.max(96,Math.round(e*.62));l.current=t,c(t),f(!0)},[d])}}var S=`nx-kv-ack-rail-pos`,C=`nx-kv-doc-rail-pos`;function w(e={}){let{x:t,y:n,parentW:r,parentH:i,railW:a=0,railH:o=0,margin:s=8}=e||{};if(![t,n,r,i].every(e=>Number.isFinite(e)))return null;let c=Number(t),l=Number(n),u=Number(r),d=Number(i),f=Math.max(s,u-a-s),p=Math.max(s,d-o-s);return{x:Math.min(f,Math.max(s,c)),y:Math.min(p,Math.max(s,l))}}function T(e=S){try{let t=JSON.parse(localStorage.getItem(e)||`null`);if(!t||typeof t!=`object`)return null;let n=Number(t.x),r=Number(t.y);return!Number.isFinite(n)||!Number.isFinite(r)?null:{x:n,y:r}}catch{return null}}function E(e,t=S){try{e?localStorage.setItem(t,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(t)}catch{}}var D=4;function O(e){let[t,n]=(0,h.useState)(()=>T(e)),[r,i]=(0,h.useState)(!1),a=(0,h.useRef)(null),o=(0,h.useRef)(null),s=(0,h.useRef)(!1);(0,h.useEffect)(()=>{let e=a.current,t=e&&e.parentElement;if(!e||!t)return;let r=()=>{n(n=>{if(!n)return n;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),a=w({x:n.x,y:n.y,parentW:r.width,parentH:r.height,railW:i.width,railH:i.height});return a&&(a.x!==n.x||a.y!==n.y)?a:n})};return r(),window.addEventListener(`resize`,r,{passive:!0}),()=>window.removeEventListener(`resize`,r)},[]);let c=(0,h.useCallback)(e=>{if(e.pointerType===`mouse`&&e.button!==0)return;let t=a.current,n=t&&t.parentElement;if(!t||!n)return;let r=t.style.bottom;t.style.bottom=`auto`;let i=t.getBoundingClientRect();t.style.bottom=r||``;let s=n.getBoundingClientRect();o.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startLeft:i.left-s.left,startTop:i.top-s.top,parentW:s.width,parentH:s.height,railW:i.width,railH:i.height,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}},[]),l=(0,h.useCallback)(e=>{let t=o.current;if(!t||e.pointerId!==t.pointerId)return;let r=e.clientX-t.startX,a=e.clientY-t.startY;if(!t.moved){if(Math.hypot(r,a)<D)return;t.moved=!0,s.current=!0,i(!0),document.body.style.userSelect=`none`}let c=w({x:t.startLeft+r,y:t.startTop+a,parentW:t.parentW,parentH:t.parentH,railW:t.railW,railH:t.railH});c&&(t.last=c,n(c))},[]),u=(0,h.useCallback)(t=>{let n=o.current;n&&t.pointerId===n.pointerId&&(o.current=null,n.moved&&(i(!1),document.body.style.userSelect=``,E(n.last,e)))},[e]),d=(0,h.useCallback)(()=>{n(null),E(null,e)},[e]);return{railRef:a,pos:t,dragging:r,draggedRef:s,resetPos:d,handleProps:{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,onDoubleClick:d}}}export{b as i,C as n,x as r,O as t};
|
|
1
|
+
import{d as e,f as t,h as n,i as r,l as i,t as a,u as o}from"./popup-dBtYqEM1.js";import{d as s}from"./task-status-Cjsm0xF7.js";import{S as c,_ as l,g as u,o as d,p as f,v as p,x as ee,y as m}from"./md-history-sxG54jJ_.js";var h=n(t(),1),g=e(),_=a,v={position:(e,t)=>(e.position||0)-(t.position||0)||String(e.id).localeCompare(String(t.id)),name:(e,t)=>String(e.name||``).localeCompare(String(t.name||``)),kind:(e,t)=>String(e.kind).localeCompare(String(t.kind))||String(e.name||``).localeCompare(String(t.name||``))};function y(e,{onRemove:t,onPreview:n,onPreviewMd:r,onOpenTask:i,onOpenDoc:a,onEditNote:o,onReplace:s}){let c=e.kind===`image`?m(e.id):``;return(0,g.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,g.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:c,name:e.name}),title:`点击看大图`,children:(0,g.jsx)(`img`,{src:c,alt:e.name,loading:`lazy`})}):(0,g.jsx)(`span`,{className:`att-kind-badge`,children:p(e.kind)}),(0,g.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>i?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:e.note||e.title||e.name||`打开文档`,onClick:()=>a?.(e.refId?`ref:`+e.refId:e.locator||e.targetRef),children:e.title||e.name}):e.kind===`url`?(0,g.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,g.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,g.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,g.jsx)(`span`,{children:e.sizeText}):null,e.kind===`mdfile`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 源文件已不在`:``]}):null,e.kind===`folder`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 目录已不在`:``]}):null,e.note?(0,g.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`mdfile`?(0,g.jsx)(`span`,{className:`att-item-acts`,children:(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`按 md 渲染磁盘当前内容(读时核对指纹)`,onClick:()=>r?.(e),children:`预览`})}):null,e.kind===`file`||e.kind===`image`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[(0,g.jsx)(`a`,{className:`att-act`,href:m(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,g.jsx)(`a`,{className:`att-act`,href:m(e.id),download:e.name,children:`下载`})]}):null,e.kind===`ref`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[o?(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`改这条绑定的一行说明(交付清单会透出)`,onClick:()=>o(e),children:`✎ 说明`}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`换成另一篇文档(替换这条绑定)`,onClick:()=>s?.(e),children:`⇄ 更换`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}function b({host:e=`task`,hostId:t,hostKey:n,hostCwd:a,refId:p,allow:m={file:!0,url:!0,folder:!0,task:!1,ref:!1,repo:!1},taskOptions:b=[],docOptions:x,disabled:S=!1,disabledText:C=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:w,onChanged:T,onOpenTask:E,onOpenDoc:D}){let O=i(),{dialog:te,node:ne}=r(),[k,A]=(0,h.useState)([]),[j,M]=(0,h.useState)(!1),[N,P]=(0,h.useState)(``),[re,F]=(0,h.useState)(!1),[ie,I]=(0,h.useState)(!1),[ae,L]=(0,h.useState)(!1),[R,oe]=(0,h.useState)(`position`),[z,B]=(0,h.useState)(null),[V,H]=(0,h.useState)(null),[U,W]=(0,h.useState)(!1),[G,K]=(0,h.useState)(null),[q,J]=(0,h.useState)(null),Y=(0,h.useMemo)(()=>ee(e,{hostId:t,hostKey:n,hostCwd:a,refId:p}),[e,t,n,a,p]),X=(0,h.useCallback)(async()=>{if(S){A([]);return}M(!0),P(``);try{let e=await Y.list();A((e.attachments||[]).map(c))}catch(e){P(String(e.message||e))}finally{M(!1)}},[Y,S]);(0,h.useEffect)(()=>{X()},[X]),(0,h.useImperativeHandle)(w,()=>({open:()=>F(!0),refresh:X}),[X]),(0,h.useEffect)(()=>{if(!G)return;let e=e=>{e.key===`Escape`&&K(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[G]);let Z=(0,h.useMemo)(()=>[...k].sort(v[R]||v.position),[k,R]),Q=Z.filter(e=>e.area===`inline`),$=Z.filter(e=>e.area===`area`),se=async(e,t)=>{if(S)return;let n=f(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;L(!0);let i=0;for(let e of r)try{let t=await u(e),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await Y.attach({fileId:n,name:t.name}),i+=1}catch(t){O(`「${e.name||`文件`}」添加失败:${t.message||t}`)}L(!1),i&&(O(`已挂到附件区 ${i} 个文件`),await X(),T?.())},ce=async r=>{if(r&&e!==`doc`)try{let e=await te({title:`说明 · ${r.name}`,input:!0,placeholder:`这一行里大概是什么(交付清单会透出给 agent)`,value:r.note||``,okText:`保存说明`});if(e===null)return;let i=typeof e==`string`?e:e&&e.value||``,s={id:Number(t),...n?{key:n}:a?{cwd:a}:{},attachment:r.id,note:i};await o(`/api/localtasks/attach-note`,{method:`PATCH`,body:s}),O(i?`已保存说明:${i}`:`已清空说明`),await X(),T?.()}catch(e){O(`改说明失败:${e.message||e}`)}},le=e=>{e&&(H(e),F(!0))},ue=async()=>{let e=z;if(e){W(!0);try{await Y.detach(e.id),B(null),O(`已解除关联:${e.name}`),await X(),T?.()}catch(e){O(`移除失败:${e.message||e}`)}finally{W(!1)}}},de=async e=>{if(e)try{let t=await o(`/api/docs/mdfile?attachment=${encodeURIComponent(String(e.id))}`),n=String(t.body||``);J({name:e.name||`md`,html:s(n),path:String(t.absPath||e.absPath||``),stale:!!t.stale,missing:!!t.missing})}catch(e){O(`读取失败:${e.message||e}`)}},fe=!j&&!N&&!k.length;return(0,g.jsxs)(`div`,{className:`att-area${S?` is-disabled`:``}`,onDragOver:e=>{!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),I(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||I(!1)},onDrop:e=>{I(!1),!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),se(null,e))},children:[ne,(0,g.jsxs)(`div`,{className:`att-area-head`+(ie&&!S?` is-over`:``),children:[(0,g.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,k.length?(0,g.jsx)(`span`,{className:`att-count`,children:k.length}):null,ae?(0,g.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,g.jsxs)(`span`,{className:`att-area-acts`,children:[k.length?(0,g.jsxs)(`select`,{className:`att-sort`,value:R,onChange:e=>oe(e.target.value),"aria-label":`附件排序`,children:[(0,g.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,g.jsx)(`option`,{value:`name`,children:`按名称`}),(0,g.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:S,onClick:()=>F(!0),children:`添加附件`})]})]}),S?(0,g.jsx)(`div`,{className:`att-empty`,children:C}):null,j?(0,g.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,N?(0,g.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,N]}):null,fe?(0,g.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,Q.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[l.inline,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),Q.map(t=>y(t,{onRemove:B,onPreview:K,onPreviewMd:de,onOpenTask:E,onOpenDoc:D,onEditNote:e===`task`?ce:void 0,onReplace:le,key:t.id}))]}):null,$.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[l.area,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),$.map(t=>y(t,{onRemove:B,onPreview:K,onPreviewMd:de,onOpenTask:E,onOpenDoc:D,onEditNote:e===`task`?ce:void 0,onReplace:le,key:t.id}))]}):null,(0,g.jsx)(d,{open:re,host:e,hostId:t,hostKey:n,hostCwd:a,refId:p,allow:m,taskOptions:b,docOptions:x,replaceAttachment:V?V.id:null,replaceNote:V&&V.note||``,onClose:()=>{F(!1),H(null)},onDone:async()=>{H(null),await X(),T?.()}}),z?(0,g.jsx)(_,{title:`移除附件`,size:`sm`,busy:U,onClose:U?void 0:()=>B(null),footer:(0,g.jsxs)(`div`,{className:`att-foot`,children:[(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:U,onClick:()=>B(null),children:`取消`}),(0,g.jsx)(`button`,{type:`button`,className:`btn`,disabled:U,onClick:()=>void ue(),children:`移除(解除关联)`})]}),children:(0,g.jsxs)(`div`,{className:`att-confirm`,children:[(0,g.jsx)(`div`,{className:`att-confirm-name`,children:z.name}),(0,g.jsxs)(`div`,{className:`att-confirm-text`,children:[`会从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源本身(行与字节)保留在孤儿池, 之后仍可重新挂载;需要清理时由库级 GC 统一回收。`]})]})}):null,q?(0,g.jsx)(_,{title:(0,g.jsxs)(`span`,{children:[q.name,(0,g.jsx)(`span`,{className:`att-md-path`,children:q.path})]}),size:`lg`,onClose:()=>J(null),footer:(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>J(null),children:`关闭`}),children:q.missing?(0,g.jsxs)(`div`,{className:`att-empty`,children:[`源文件已不在:`,q.path||`(路径为空)`]}):(0,g.jsxs)(`div`,{className:`att-md-preview`,children:[q.stale?(0,g.jsx)(`div`,{className:`att-md-warn`,children:`内容已变化(与登记指纹不一致),以下为磁盘当前内容。`}):null,(0,g.jsx)(`article`,{dangerouslySetInnerHTML:{__html:q.html}})]})}):null,G?(0,g.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&K(null)},children:(0,g.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,g.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,g.jsx)(`span`,{className:`att-lightbox-name`,children:G.name}),(0,g.jsx)(`a`,{className:`att-lightbox-open`,href:G.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,g.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>K(null),children:`×`})]}),(0,g.jsx)(`img`,{className:`att-lightbox-img`,src:G.src,alt:G.name})]})}):null]})}function x(e=`task`,t=!0){let n=(0,h.useCallback)(t=>`nxkv.${e}Dock${t}`,[e]),[r,i]=(0,h.useState)(()=>{let e=localStorage.getItem(n(`Open`));return e===null?t:e!==`0`}),[a,o]=(0,h.useState)(()=>localStorage.getItem(n(`Tab`))||`attach`),[s,c]=(0,h.useState)(()=>{let e=Number(localStorage.getItem(n(`H`)));return Number.isFinite(e)&&e>=96?e:176}),l=(0,h.useRef)(s);l.current=s;let u=(0,h.useRef)(null),[d,f]=(0,h.useState)(!1),p=(0,h.useRef)(176);return(0,h.useEffect)(()=>{localStorage.setItem(n(`Open`),r?`1`:`0`)},[r,n]),(0,h.useEffect)(()=>{localStorage.setItem(n(`Tab`),a)},[a,n]),{dockOpen:r,setDockOpen:i,dockTab:a,setDockTab:o,dockH:s,dockHRef:l,dockRef:u,dockMax:d,setDockMax:f,dockPrevHRef:p,showDockTab:(0,h.useCallback)(e=>{o(e),i(!0)},[]),onDockDragStart:(0,h.useCallback)(e=>{if(!r)return;e.preventDefault(),f(!1);let t=e.clientY,i=l.current,a=u.current?.parentElement?.clientHeight||window.innerHeight,o=e=>Math.max(96,Math.min(Math.round(a*.62),Math.round(e))),s=e=>{let n=o(i-(e.clientY-t));l.current=n,c(n)},d=()=>{window.removeEventListener(`mousemove`,s),window.removeEventListener(`mouseup`,d),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(n(`H`),String(l.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,s),window.addEventListener(`mouseup`,d)},[r,n]),toggleDockMax:(0,h.useCallback)(()=>{if(d){c(p.current),f(!1);return}p.current=l.current;let e=u.current?.parentElement?.clientHeight||window.innerHeight,t=Math.max(96,Math.round(e*.62));l.current=t,c(t),f(!0)},[d])}}var S=`nx-kv-ack-rail-pos`,C=`nx-kv-doc-rail-pos`;function w(e={}){let{x:t,y:n,parentW:r,parentH:i,railW:a=0,railH:o=0,margin:s=8}=e||{};if(![t,n,r,i].every(e=>Number.isFinite(e)))return null;let c=Number(t),l=Number(n),u=Number(r),d=Number(i),f=Math.max(s,u-a-s),p=Math.max(s,d-o-s);return{x:Math.min(f,Math.max(s,c)),y:Math.min(p,Math.max(s,l))}}function T(e=S){try{let t=JSON.parse(localStorage.getItem(e)||`null`);if(!t||typeof t!=`object`)return null;let n=Number(t.x),r=Number(t.y);return!Number.isFinite(n)||!Number.isFinite(r)?null:{x:n,y:r}}catch{return null}}function E(e,t=S){try{e?localStorage.setItem(t,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(t)}catch{}}var D=4;function O(e){let[t,n]=(0,h.useState)(()=>T(e)),[r,i]=(0,h.useState)(!1),a=(0,h.useRef)(null),o=(0,h.useRef)(null),s=(0,h.useRef)(!1);(0,h.useEffect)(()=>{let e=a.current,t=e&&e.parentElement;if(!e||!t)return;let r=()=>{n(n=>{if(!n)return n;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),a=w({x:n.x,y:n.y,parentW:r.width,parentH:r.height,railW:i.width,railH:i.height});return a&&(a.x!==n.x||a.y!==n.y)?a:n})};return r(),window.addEventListener(`resize`,r,{passive:!0}),()=>window.removeEventListener(`resize`,r)},[]);let c=(0,h.useCallback)(e=>{if(e.pointerType===`mouse`&&e.button!==0)return;let t=a.current,n=t&&t.parentElement;if(!t||!n)return;let r=t.style.bottom;t.style.bottom=`auto`;let i=t.getBoundingClientRect();t.style.bottom=r||``;let s=n.getBoundingClientRect();o.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startLeft:i.left-s.left,startTop:i.top-s.top,parentW:s.width,parentH:s.height,railW:i.width,railH:i.height,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}},[]),l=(0,h.useCallback)(e=>{let t=o.current;if(!t||e.pointerId!==t.pointerId)return;let r=e.clientX-t.startX,a=e.clientY-t.startY;if(!t.moved){if(Math.hypot(r,a)<D)return;t.moved=!0,s.current=!0,i(!0),document.body.style.userSelect=`none`}let c=w({x:t.startLeft+r,y:t.startTop+a,parentW:t.parentW,parentH:t.parentH,railW:t.railW,railH:t.railH});c&&(t.last=c,n(c))},[]),u=(0,h.useCallback)(t=>{let n=o.current;n&&t.pointerId===n.pointerId&&(o.current=null,n.moved&&(i(!1),document.body.style.userSelect=``,E(n.last,e)))},[e]),d=(0,h.useCallback)(()=>{n(null),E(null,e)},[e]);return{railRef:a,pos:t,dragging:r,draggedRef:s,resetPos:d,handleProps:{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,onDoubleClick:d}}}export{b as i,C as n,x as r,O as t};
|
|
@@ -12,19 +12,19 @@
|
|
|
12
12
|
<!-- .ico 兜底:浏览器不认上面的 <link> 时会自己请求 /favicon.ico -->
|
|
13
13
|
<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
|
14
14
|
<link rel="apple-touch-icon" sizes="512x512" href="/logo-rounded.png">
|
|
15
|
-
<script type="module" crossorigin src="/assets/index-
|
|
15
|
+
<script type="module" crossorigin src="/assets/index-GSk_7QV5.js"></script>
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/popup-dBtYqEM1.js">
|
|
17
|
-
<link rel="modulepreload" crossorigin href="/assets/tool-bar-
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/assets/tool-bar-DpfJRjFG.js">
|
|
18
18
|
<link rel="modulepreload" crossorigin href="/assets/button-Cs6w2CDi.js">
|
|
19
19
|
<link rel="modulepreload" crossorigin href="/assets/app-context-CngKv8Tc.js">
|
|
20
20
|
<link rel="modulepreload" crossorigin href="/assets/task-status-Cjsm0xF7.js">
|
|
21
|
-
<link rel="modulepreload" crossorigin href="/assets/md-history-
|
|
22
|
-
<link rel="modulepreload" crossorigin href="/assets/use-rail-drag-
|
|
21
|
+
<link rel="modulepreload" crossorigin href="/assets/md-history-sxG54jJ_.js">
|
|
22
|
+
<link rel="modulepreload" crossorigin href="/assets/use-rail-drag-DcUzHeV_.js">
|
|
23
23
|
<link rel="modulepreload" crossorigin href="/assets/list-search-DFvFY408.js">
|
|
24
24
|
<link rel="modulepreload" crossorigin href="/assets/board-view-C8OQhkyi.js">
|
|
25
25
|
<link rel="modulepreload" crossorigin href="/assets/route-crumb-BKq2jry0.js">
|
|
26
|
-
<link rel="modulepreload" crossorigin href="/assets/doc-
|
|
27
|
-
<link rel="modulepreload" crossorigin href="/assets/repo-form-modal-
|
|
26
|
+
<link rel="modulepreload" crossorigin href="/assets/doc-z8eXM9dk.js">
|
|
27
|
+
<link rel="modulepreload" crossorigin href="/assets/repo-form-modal-DJMWkbA6.js">
|
|
28
28
|
<link rel="stylesheet" crossorigin href="/assets/popup-BAvk7J7u.css">
|
|
29
29
|
<link rel="stylesheet" crossorigin href="/assets/tool-bar-CLIs9Dr0.css">
|
|
30
30
|
<link rel="stylesheet" crossorigin href="/assets/button-DA4lNJeC.css">
|