nx-kv 0.43.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/package.json +1 -1
- package/src/modules/localtask/task-ops.js +17 -4
- package/src/modules/tasktool/index.js +12 -5
- package/src/modules/tasktool/plugins/goal-template.js +86 -0
- package/src/modules/tasktool/plugins/taskgoal-store.js +61 -43
- package/src/modules/tasktool/plugins/timegoal-task-store.js +40 -3
- package/src/modules/tasktool/wait.js +18 -2
- package/src/shared/prompt-blocks.js +21 -0
- package/src/web/frontend/page/dir/task-actions.js +13 -5
- package/src/web/frontend/page/dir/task-goal-section.jsx +29 -24
- package/src/web/frontend/page/dir/task-goal.js +6 -1
- package/src/web/frontend/page/dir/task.jsx +3 -3
- package/src/web/frontend/page/settings/prompt-template-params.js +38 -2
- package/src/web/public/assets/{Introduction-DAXj7E6q.js → Introduction-CDSLSy0q.js} +1 -1
- package/src/web/public/assets/{bar-KTPTE33i.js → bar-Dp9JHQEk.js} +1 -1
- package/src/web/public/assets/{cloud-CLco1knr.js → cloud-D13Ed3Pg.js} +1 -1
- package/src/web/public/assets/{composer-panel-D3N_wO9r.js → composer-panel-eKhM7jDM.js} +1 -1
- package/src/web/public/assets/{deleted-panel-B6sZddUs.js → deleted-panel-QHsQZ5Ez.js} +1 -1
- package/src/web/public/assets/{dir-DEbQhSfL.js → dir-CiDjsHfd.js} +1 -1
- package/src/web/public/assets/{group-CxqVtyyh.js → group-DDXtRIPf.js} +1 -1
- package/src/web/public/assets/{index-DNB8tgNi.js → index-Dq7eNqAB.js} +2 -2
- package/src/web/public/assets/{md-history-C9vOgGLz.js → md-history-DI1Ukbvc.js} +1 -1
- package/src/web/public/assets/{overview-9nXafXeK.js → overview-BE6O6j51.js} +1 -1
- package/src/web/public/assets/{refs-B5YIZ9SG.js → refs-BkncFh9X.js} +1 -1
- package/src/web/public/assets/{repos-Dbr-i-gg.js → repos-C9wx2OXj.js} +1 -1
- package/src/web/public/assets/{route-crumb-BfRi1GKw.js → route-crumb-_IyS9fTT.js} +1 -1
- package/src/web/public/assets/settings-DlgWRz3r.js +7 -0
- package/src/web/public/assets/{status-tag-p3fo3Hbr.js → status-tag-Bop-R-gG.js} +1 -1
- package/src/web/public/assets/task-CNbU9Z6v.js +11 -0
- package/src/web/public/assets/{templates-BGhPIp0x.js → templates-CK9nH5WD.js} +1 -1
- package/src/web/public/assets/{tool-bar-DpwpQ47h.js → tool-bar-9LD5jcE3.js} +1 -1
- package/src/web/public/index.html +1 -1
- package/src/web/public/assets/settings-B4FvZtu0.js +0 -6
- package/src/web/public/assets/task-CUb7dohw.js +0 -11
|
@@ -105,7 +105,7 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
105
105
|
const { dockOpen, setDockOpen, dockTab, dockH, dockRef, dockMax, showDockTab, onDockDragStart, toggleDockMax } = dock;
|
|
106
106
|
|
|
107
107
|
const goalState = useGoal({ id, isDraft, topicKey, task, taskRow });
|
|
108
|
-
const { goalDraft, setGoalDraft, goal, goalEditable, declaredGoal, goalLog, loadGoalLog, canShowGoalLog } = goalState;
|
|
108
|
+
const { goalDraft, setGoalDraft, goal, goalEditable, goalPromptEditable, declaredGoal, goalLog, loadGoalLog, canShowGoalLog } = goalState;
|
|
109
109
|
|
|
110
110
|
const chainState = useChain({
|
|
111
111
|
isDraft, task, taskRow, topicKey, topic, isGlobal, groupAnchored, groupId,
|
|
@@ -196,7 +196,7 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
196
196
|
groupAnchored, groupId, rows, app, model, tabId, tpl, refreshLocal,
|
|
197
197
|
markDirty, histRef, editorApiRef, attachAreaRef,
|
|
198
198
|
setDirty,
|
|
199
|
-
goal, goalEditable, declaredGoal, guard, dialog, showDockTab,
|
|
199
|
+
goal, goalEditable, goalPromptEditable, declaredGoal, guard, dialog, showDockTab,
|
|
200
200
|
});
|
|
201
201
|
const { composeText, submit, importMd, delTask, canClosePending, closeTask, addFiles, newTask, cloneCur, forkCur, openProgress, openAttachPanel } = actions;
|
|
202
202
|
|
|
@@ -214,7 +214,7 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
214
214
|
}, [showDockTab, loadGoalLog]);
|
|
215
215
|
|
|
216
216
|
const { goalBadge, goalMenu } = goalSection({
|
|
217
|
-
goal, goalDraft, setGoalDraft, goalEditable, declaredGoal, openGoalLog, markDirty, task,
|
|
217
|
+
goal, goalDraft, setGoalDraft, goalEditable, goalPromptEditable, declaredGoal, openGoalLog, markDirty, task,
|
|
218
218
|
});
|
|
219
219
|
|
|
220
220
|
// ─── 预览提示词(任务 #65)───
|
|
@@ -155,19 +155,55 @@ export const BLOCK_PARAMS = {
|
|
|
155
155
|
{
|
|
156
156
|
label: '时间目标',
|
|
157
157
|
items: [
|
|
158
|
-
['goal.check', '
|
|
158
|
+
['goal.check', '时间检查指令(任务级;每轮 check 按当下模板渲染)'],
|
|
159
159
|
['goal.statusLine', '目录级目标状态行'],
|
|
160
160
|
['goal.name', '目标名'],
|
|
161
|
+
['goal.goalKey', '任务级目标 key(check --task 用)'],
|
|
162
|
+
['goal.durationHuman', '持续时长(人话,如 2 小时)'],
|
|
163
|
+
['goal.durationSec', '持续秒数'],
|
|
161
164
|
['goal.deadline', '截止时间'],
|
|
162
165
|
['goal.remainingSec', '剩余秒数'],
|
|
166
|
+
['goal.remainingHuman', '剩余时长(人话)'],
|
|
163
167
|
['goal.remainingMin', '剩余分钟(向上取整)'],
|
|
168
|
+
['goal.elapsedHuman', '已过时长(人话)'],
|
|
169
|
+
['goal.elapsedSec', '已过秒数'],
|
|
164
170
|
['goal.overtimeSec', '超时秒数'],
|
|
165
171
|
['goal.reached', '是否到点'],
|
|
172
|
+
['goal.extra', '发布方附加要求(领取后可动态改)'],
|
|
166
173
|
],
|
|
167
174
|
},
|
|
168
175
|
{
|
|
169
176
|
label: '通用',
|
|
170
|
-
items: [
|
|
177
|
+
items: [
|
|
178
|
+
['task.id', '任务号'],
|
|
179
|
+
['task.text', '任务实时原文'],
|
|
180
|
+
],
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
goalhint: [
|
|
184
|
+
{
|
|
185
|
+
label: '时间目标上下文(任务级)',
|
|
186
|
+
items: [
|
|
187
|
+
['goal.goalKey', '任务级目标 key(check --task 用)'],
|
|
188
|
+
['goal.durationHuman', '持续时长(人话)'],
|
|
189
|
+
['goal.durationSec', '持续秒数'],
|
|
190
|
+
['goal.startedAt', '开始计时时间'],
|
|
191
|
+
['goal.deadline', '截止时间'],
|
|
192
|
+
['goal.remainingHuman', '剩余时长(人话)'],
|
|
193
|
+
['goal.remainingSec', '剩余秒数'],
|
|
194
|
+
['goal.elapsedHuman', '已过时长(人话)'],
|
|
195
|
+
['goal.elapsedSec', '已过秒数'],
|
|
196
|
+
['goal.overtimeSec', '超时秒数'],
|
|
197
|
+
['goal.reached', '是否到点'],
|
|
198
|
+
['goal.extra', '发布方附加要求(领取后可动态改)'],
|
|
199
|
+
],
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
label: '任务',
|
|
203
|
+
items: [
|
|
204
|
+
['task.id', '任务号'],
|
|
205
|
+
['task.text', '任务实时原文(check 返回对象同样可用)'],
|
|
206
|
+
],
|
|
171
207
|
},
|
|
172
208
|
],
|
|
173
209
|
ext: [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as e,h as t,l as n,m as r,o as i,p as a,v as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,v as l,w as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{_ as f,a as p,i as m,n as h,p as g,r as _,t as v,u as y,v as b,y as x}from"./md-history-
|
|
1
|
+
import{g as e,h as t,l as n,m as r,o as i,p as a,v as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,v as l,w as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{_ as f,a as p,i as m,n as h,p as g,r as _,t as v,u as y,v as b,y as x}from"./md-history-DI1Ukbvc.js";import{a as S,i as C}from"./upload-BIMbGcCB.js";import{r as ee}from"./md-parse-awNLHAzO.js";import{t as w}from"./route-crumb-_IyS9fTT.js";import{a as T,c as E,i as D,l as O,o as te,r as k,s as A,t as j,u as ne}from"./tool-bar-9LD5jcE3.js";var M=s(e(),1),N=u(),P=t(),F=`doc`,I=[{id:`edit`,label:`编辑`},{id:`doc`,label:`文档`},{id:`view`,label:`查看`}];function re({crumb:e=null,title:t,pathLabel:n=``,dirty:r=!1,writable:i=!1,onSave:a=null,onSaveLabel:o=`保存`,menuGroups:s=[],saving:c=!1,external:l=!1,afterTitle:u=null}){let d=D(),{layout:f,setLayout:p}=te(F),[m,h]=(0,M.useState)(!1),g={};for(let e of s||[])for(let t of e?.items||[])t&&t.id&&(g[t.id]=t);g.save=a&&{id:`save`,label:c?`保存中…`:o,run:a,primary:!0,disabled:c||!r};let _=e=>e===`more`||!!g[e],v=f.filter(e=>O(F,e)&&_(e.id)),y=f.filter(e=>A(F,e)&&_(e.id)),b=e=>{g[e]?.run?.(),d.setOpen(!1)},x=e=>{if(e===`more`)return(0,P.jsx)(`div`,{className:`docp-more`,ref:d.ref,children:(0,P.jsx)(`button`,{type:`button`,className:`btn ghost sm${d.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":d.open,onClick:e=>k(d,e,`right`),children:`更多`})},`more`);let t=g[e];return t?(0,P.jsx)(`button`,{type:`button`,className:t.primary||e===`save`?`btn sm primary docp-save`:`btn ghost sm`,disabled:!!t.disabled,onClick:()=>b(e),children:t.label||E(F,e).label||e},e):null},S=I.map(e=>({...e,items:y.filter(t=>E(F,t.id).menuGroup===e.id)})).filter(e=>e.items.length),C=y.filter(e=>!E(F,e.id).menuGroup);return i?(0,P.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,P.jsxs)(`div`,{className:`mdw-head`,children:[(0,P.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,P.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,P.jsx)(`span`,{className:`grow`}),u,(0,P.jsxs)(`div`,{className:`docp-actions`,children:[v.map(e=>x(e.id)),(0,P.jsxs)(j,{menu:d,className:`mdw-act-menu`,children:[S.map(e=>(0,P.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,P.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=g[e.id],n=t?.danger||E(F,e.id).danger;return(0,P.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>b(e.id),children:[t?.label||E(F,e.id).label||e.id,t?.hint?(0,P.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),C.map(e=>{let t=g[e.id];return(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||E(F,e.id).danger?` danger`:``),onClick:()=>b(e.id),children:t?.label||E(F,e.id).label||e.id},e.id)}),(0,P.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{d.setOpen(!1),h(!0)},children:`自定义工具栏…`})]})]})]}),m&&(0,N.createPortal)((0,P.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>h(!1),children:(0,P.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,P.jsx)(T,{kind:F,layout:f,setLayout:p,onClose:()=>h(!1)})})}),document.body)]}):(0,P.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,P.jsxs)(`div`,{className:`mdw-head`,children:[(0,P.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,P.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,P.jsx)(`span`,{className:`grow`}),u,(0,P.jsx)(`div`,{className:`docp-actions`,children:(0,P.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function L(e,t,n){return{id:e,label:t,items:n.filter(Boolean)}}function R(e){let t=String(e??``).replace(/^/,``).replace(/\r\n/g,`
|
|
2
2
|
`),n=t.match(/^---\n([\s\S]*?)\n---\n?/),r=n?t.slice(n[0].length):t;for(let e of r.split(`
|
|
3
3
|
`)){let t=e.trim();if(t)return t}return``}function z(e){let t=R(e).match(/^#\s+(.+)$/);return t?t[1].trim():``}function ie(e,t){let n=String(e??``),r=String(t||``).trim()||`未命名文档`,i=n.replace(/\r\n/g,`
|
|
4
4
|
`),a=i.match(/^---\n([\s\S]*?)\n---\n?/),o=a?i.slice(0,a[0].length):``,s=(a?i.slice(a[0].length):i).split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,h as t,y as n}from"./task-status-BnymQMTw.js";import{w as r}from"./workspace-C_5X2gIr.js";import{a as i,c as a,l as o,o as s,s as c}from"./tool-bar-
|
|
1
|
+
import{g as e,h as t,y as n}from"./task-status-BnymQMTw.js";import{w as r}from"./workspace-C_5X2gIr.js";import{a as i,c as a,l as o,o as s,s as c}from"./tool-bar-9LD5jcE3.js";var l=n(e(),1),u=r(),d=t();function f({kind:e,renderers:t={},actions:n={},titles:r={},disabled:f={},labels:p={},className:m=``}){let{layout:h,setLayout:g}=s(e),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),C=(0,l.useRef)(null),w=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(!_)return;let e=e=>{C.current?.contains(e.target)||w.current?.contains(e.target)||v(!1)},t=e=>{e.key===`Escape`&&v(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[_]);let T=h.filter(t=>o(e,t)),E=h.filter(t=>c(e,t)),D=t=>p[t]||a(e,t).label||t,O=(e,t={})=>(0,d.jsx)(`button`,{type:`button`,className:t.primary?`btn small primary`:`btn small ghost`,title:r[e]||D(e),disabled:!!f[e],onClick:()=>n[e]&&n[e](),children:D(e)},e),k=n=>n===`more`?(0,d.jsxs)(`button`,{ref:C,type:`button`,className:`btn small ghost`+(_?` is-open`:``),title:r.more||`更多操作`,"aria-haspopup":`menu`,"aria-expanded":_,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();b({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)}),v(e=>!e)},children:[D(`more`),` ▾`]},`more`):t[n]?(0,d.jsx)(`span`,{className:`ta-slot`,children:t[n]({open:_})},n):O(n,{primary:a(e,n).section===`primary`});return(0,d.jsxs)(`div`,{className:`ta-bar`+(m?` ${m}`:``),children:[T.map(e=>k(e.id)),_&&y&&(0,u.createPortal)((0,d.jsxs)(`div`,{ref:w,className:`ta-more-menu`,role:`menu`,style:{top:y.top,right:y.right},children:[E.length===0&&(0,d.jsx)(`div`,{className:`ta-more-empty`,children:`没有收纳的工具——可在编排里把按钮收入更多`}),E.map(e=>(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it`,disabled:!!f[e.id],title:r[e.id]||D(e.id),onClick:()=>{v(!1),n[e.id]&&n[e.id]()},children:D(e.id)},e.id)),(0,d.jsx)(`div`,{className:`ta-more-sep`}),(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it ta-more-cfg`,onClick:()=>{v(!1),S(!0)},children:`自定义工具栏…`})]}),document.body),x&&(0,u.createPortal)((0,d.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>S(!1),children:(0,d.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,d.jsx)(i,{kind:e,layout:h,setLayout:g,onClose:()=>S(!1)})})}),document.body)]})}export{f as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{c as e,f as t,g as n,h as r,l as i,m as a,o,p as s,y as c}from"./task-status-BnymQMTw.js";import{a as l,i as u,l as d,n as f,t as p}from"./upload-BIMbGcCB.js";import{S as m,x as h}from"./index-DNB8tgNi.js";import{t as g}from"./route-crumb-BfRi1GKw.js";var _=c(n(),1),v=r(),y=e=>`/api/file/content/${encodeURIComponent(e)}`;function b({text:e,compact:t=!1,className:n=``}){let r=d(e);return r.some(e=>e.type!==`text`)?(0,v.jsx)(`span`,{className:n?`mdtext ${n}`:`mdtext`,children:r.map((e,n)=>{if(e.type===`text`)return(0,v.jsx)(`span`,{className:`mdtext-plain`,children:e.value},n);let r=y(e.id);return e.type===`image`?(0,v.jsx)(`a`,{className:`embed-image`+(t?` compact`:``),href:r,target:`_blank`,rel:`noreferrer`,title:e.alt?`${e.alt}(点击看原图)`:e.id,children:(0,v.jsx)(`img`,{src:r,alt:e.alt||e.id,loading:`lazy`})},n):(0,v.jsx)(`a`,{className:`embed-file`,href:r,target:`_blank`,rel:`noreferrer`,title:e.id,children:e.alt||e.id},n)})}):(0,v.jsx)(`span`,{className:n,children:e})}function x({task:e,pick:t,group:n,onSaved:r,onCancel:i}){let o=s(),[c,d]=(0,_.useState)(e.text||``),[m,h]=(0,_.useState)(e.note||``),[g,y]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(!1),T=(0,_.useRef)(null),E=(0,_.useRef)(null),D=(0,_.useRef)(c),O=e=>{D.current=e,d(e)};(0,_.useEffect)(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[]);let k=e=>{if(!e)return;let t=T.current,n=D.current,r=t&&t.selectionStart!==null?t.selectionStart:n.length,i=t&&t.selectionEnd!==null?t.selectionEnd:r,a=n.slice(0,r),o=n.slice(i),s=a&&!/\s$/.test(a)?` `:``,c=`${a}${s}${e}${o&&!/^\s/.test(o)?` `:``}${o}`;O(c);let l=a.length+s.length+e.length;requestAnimationFrame(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(l,l))})},A=async e=>{let t=Array.from(e||[]).filter(e=>e&&e.size>0);if(t.length&&!x){S({done:0,total:t.length});try{let e=await l(t,{group:n,onProgress:(e,t)=>S({done:e,total:t})});k(u(e));let r=e.filter(e=>e.isImage).length;o(e.length===1?`已插入 ${e[0].name}`:`已插入 ${e.length} 个附件${r?`(图片 ${r} 个)`:``}`)}catch(e){o(String(e&&e.message||e))}finally{S(null)}}},j=e=>{let t=p(e);t.length&&(e.preventDefault(),A(t))},M=(0,_.useRef)(null);M.current=e=>A(f(e)),(0,_.useEffect)(()=>{let e=e=>Array.from(e.dataTransfer&&e.dataTransfer.types||[]).includes(`Files`),t=t=>{e(t)&&(t.preventDefault(),w(!0))},n=e=>{e.relatedTarget||w(!1)},r=t=>{e(t)&&(t.preventDefault(),w(!1),M.current&&M.current(t))};return window.addEventListener(`dragover`,t),window.addEventListener(`dragleave`,n),window.addEventListener(`drop`,r),()=>{window.removeEventListener(`dragover`,t),window.removeEventListener(`dragleave`,n),window.removeEventListener(`drop`,r)}},[]);let N=()=>{if(g)return;if(!String(D.current).trim()){o(`正文不能为空`);return}let i={group:n,ref:e.text,pick:t,matchTopic:e.topic,text:D.current};m!==(e.note||``)&&(i.note=m),y(!0),a(`/api/todo/item`,{method:`PATCH`,body:i}).then(()=>{o(`已保存`),r()}).catch(e=>o(String(e&&e.message||e))).finally(()=>y(!1))},P=e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),N())},F=x?`上传中 ${x.done}/${x.total}…`:`选择文件上传`,I=!String(c).trim();return(0,v.jsxs)(`div`,{className:`editor`+(C?` drag`:``),children:[(0,v.jsxs)(`div`,{className:`ed-tip`,children:[`粘贴(`,(0,v.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,v.jsx)(`kbd`,{children:`V`}),` 截图)、拖文件进来,或`,(0,v.jsx)(`button`,{type:`button`,className:`ed-link`,onClick:()=>E.current&&E.current.click(),disabled:!!x,children:`选择文件`}),`—— 会自动上传并插到光标处。`,(0,v.jsx)(`input`,{ref:E,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,A(t)}})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`正文`}),(0,v.jsx)(`textarea`,{ref:T,className:`ed-textarea`,rows:4,value:c,spellCheck:`false`,placeholder:`要做什么… 图片写 ,其他文件写 [文件名](fileId)`,onChange:e=>O(e.target.value),onPaste:j,onKeyDown:P}),(0,v.jsxs)(`div`,{className:`ed-meta`,children:[(0,v.jsxs)(`span`,{className:`ed-acts`,children:[(0,v.jsx)(`button`,{type:`button`,className:`btn small`,onClick:()=>E.current&&E.current.click(),disabled:!!x,children:F}),(0,v.jsxs)(`span`,{className:`hint`,children:[`图片 `,(0,v.jsx)(`code`,{children:``}),` 文件 `,(0,v.jsx)(`code`,{children:`[文件名](id)`})]})]}),(0,v.jsxs)(`span`,{className:`hint`,children:[c.length,` 字符`]})]})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`预览`}),(0,v.jsx)(`div`,{className:`preview`+(I?` empty`:``),children:I?(0,v.jsx)(`span`,{className:`muted`,children:`(暂无内容)`}):(0,v.jsx)(b,{text:c})})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`备注`}),(0,v.jsx)(`textarea`,{className:`ed-textarea`,rows:2,value:m,spellCheck:`false`,placeholder:`可选:完成结果、上下文补充`,onChange:e=>h(e.target.value)})]}),(0,v.jsxs)(`div`,{className:`ed-foot`,children:[(0,v.jsxs)(`span`,{className:`hint`,children:[(0,v.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,v.jsx)(`kbd`,{children:`Enter`}),` 保存`]}),(0,v.jsxs)(`span`,{className:`ed-acts`,children:[(0,v.jsx)(`button`,{className:`btn ghost`,onClick:i,disabled:g,children:`取消`}),(0,v.jsx)(`button`,{className:`btn`,onClick:N,disabled:g||!!x,children:g?`保存中…`:`保存`})]})]})]})}function S({onClose:e}){let{boot:n,refreshBoot:r}=m(),c=s(),l=t(),{dialog:u,node:d}=i(),[f,p]=(0,_.useState)([]),[g,y]=(0,_.useState)(``),[b,x]=(0,_.useState)({name:``,description:``}),[S,C]=(0,_.useState)(null),w=(0,_.useCallback)(async()=>{try{let e=await a(`/api/groups`);p(e.groups||[]),y(``)}catch(e){y(e.message||String(e))}},[]);(0,_.useEffect)(()=>{w()},[w]);let T=n?.groupId??0,E=e=>l(async()=>{let t=await a(`/api/group`,{method:`POST`,body:{locator:e}});c(t.id===0?`已切回默认组`:`已切换到 ${t.name}`),await r(),await w()}),D=()=>l(async()=>{let e=b.name.trim();if(!e){c(`请填名称`);return}let t=await a(`/api/groups`,{method:`POST`,body:{name:e,description:b.description.trim()}});x({name:``,description:``}),c(`已新建工作空间 ${t.name}(id=${t.id})`),await r(),await w()}),O=e=>l(async()=>{let t=await u({title:`重命名「${e.name}」`,input:!0,value:e.name});t!==null&&t.trim()&&(await a(`/api/groups/${e.id}`,{method:`PATCH`,body:{name:t.trim()}}),c(`已更新名称`),await r(),await w())}),k=e=>l(async()=>{await u({message:`解散工作空间「${e.name}」(id=${e.id})?\n\n后端要求组内已无 KV 数据,否则会拒绝。此操作不可撤销。`,danger:!0})&&(await a(`/api/groups/${e.id}`,{method:`DELETE`}),c(`已解散 ${e.name}`),await r(),await w())}),A=e=>l(async()=>{let t=await a(`/api/groups/${e.id}/members`);C({group:t.group,list:t.members||[]})});return n?.loggedIn?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(o,{title:`工作空间`,onClose:e,children:[(0,v.jsx)(`div`,{className:`muted`,style:{marginBottom:8},children:`清单按工作空间隔离读写。切换只改本机配置,不动服务端数据。`}),g?(0,v.jsx)(`div`,{className:`row muted`,children:g}):null,(0,v.jsxs)(`div`,{className:`list`,children:[(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(`span`,{className:`name`,children:`默认组`}),(0,v.jsx)(`span`,{className:`desc`,children:`不传 groupId,由后端回落`}),(0,v.jsx)(`span`,{className:`acts`,children:T===0?(0,v.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,v.jsx)(`button`,{className:`btn small`,onClick:()=>E(`default`),children:`切到这里`})})]}),f.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(h,{className:`name`,text:e.name,title:`点击复制名称`,children:e.name}),(0,v.jsx)(`span`,{className:`tag`,children:e.myRole||`member`}),e.description?(0,v.jsx)(`span`,{className:`desc`,children:e.description}):null,(0,v.jsxs)(`span`,{className:`muted mono`,children:[`id=`,e.id]}),(0,v.jsxs)(`span`,{className:`muted`,children:[e.memberCount,` 人`]}),(0,v.jsxs)(`span`,{className:`acts`,children:[e.id===T?(0,v.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,v.jsx)(`button`,{className:`btn small`,onClick:()=>E(String(e.id)),children:`切到这里`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>A(e),children:`成员`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>O(e),children:`改名`}),(0,v.jsx)(`button`,{className:`btn small ghost danger`,onClick:()=>k(e),children:`解散`})]})]},e.id)),!g&&!f.length?(0,v.jsx)(`div`,{className:`row muted`,children:`(没有其他工作空间)`}):null]}),(0,v.jsxs)(`div`,{className:`toolbar`,style:{marginTop:10},children:[(0,v.jsx)(`input`,{placeholder:`新工作空间名称`,size:`16`,value:b.name,onChange:e=>x({...b,name:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&D()}}),(0,v.jsx)(`input`,{placeholder:`描述(可选)`,size:`20`,value:b.description,onChange:e=>x({...b,description:e.target.value})}),(0,v.jsx)(`button`,{className:`btn`,onClick:D,children:`新建`}),(0,v.jsx)(`button`,{className:`btn ghost`,onClick:()=>l(w),children:`刷新`})]})]}),S?(0,v.jsx)(o,{title:`成员 · ${S.group.name}`,onClose:()=>C(null),children:(0,v.jsx)(`div`,{className:`list`,children:S.list.length?S.list.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(h,{className:`name`,text:e.email,title:`点击复制邮箱`,children:e.email}),(0,v.jsx)(`span`,{className:`tag`,children:e.role||`member`}),(0,v.jsx)(`span`,{className:`muted`,children:e.nickname})]},e.userId)):(0,v.jsx)(`div`,{className:`row muted`,children:`(没有成员)`})})}):null,d]}):(0,v.jsx)(o,{title:`工作空间`,onClose:e,children:(0,v.jsx)(`div`,{className:`muted`,children:`工作空间需要登录后才能列出。`})})}var C=[[`open`,`待办`],[`done`,`已完成`],[`freeze`,`冻结`]],w=e=>e?String(e).slice(0,16).replace(`T`,` `):``,T=15,E=(e,t)=>`${e}:${t.id}:${t.text}`;function D({bucket:t,task:n,dupCount:r,onAct:i}){let a=t===`done`,o=t===`freeze`,s=a?n.doneAt:o?n.frozenAt:n.createdAt;return(0,v.jsxs)(`div`,{className:`row cloud-row`,children:[(0,v.jsxs)(`div`,{className:`row-main`,children:[(0,v.jsxs)(`span`,{className:`tid`,children:[`#`,n.id]}),(0,v.jsx)(h,{className:`topic`,text:n.topic,title:`点击复制主题`,children:n.topic}),(0,v.jsx)(`span`,{className:`text`,title:n.text,children:(0,v.jsx)(b,{text:n.text,compact:!0})}),r>1?(0,v.jsxs)(`span`,{className:`tag`,title:`同内容有 ${r} 条,操作时需要消歧`,children:[`同内容×`,r]}):null,(0,v.jsx)(`span`,{className:`muted time`,children:w(s)}),(0,v.jsxs)(`span`,{className:`acts`,children:[t===`open`?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`done`,n),children:`完成`}):null,o?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`unfreeze`,n),children:`解冻`}):null,(0,v.jsx)(e,{items:[t===`open`&&{label:`冻结`,onPick:()=>i(`freeze`,n)},{label:`编辑`,onPick:()=>i(`edit`,n,t)},{label:`删除`,danger:!0,onPick:()=>i(`remove`,n,t)}]})]})]}),n.note?(0,v.jsx)(`div`,{className:`note`,children:n.note}):null]})}function O(){let{boot:e,ui:n,patchUi:r,refreshBoot:c}=m(),d=s(),f=t(),{dialog:y,node:b}=i(),[O,k]=(0,_.useState)(null),[A,j]=(0,_.useState)(``),[M,N]=(0,_.useState)(!1),[P,F]=(0,_.useState)({topic:``,text:``}),[I,L]=(0,_.useState)(null),[R,z]=(0,_.useState)(!1),[B,ee]=(0,_.useState)({}),[V,H]=(0,_.useState)(null),[U,W]=(0,_.useState)(null),G=e?.groupId??0,te=(e?.groups||[]).find(e=>e.id===G)?.name||(G?`#${G}`:`默认组`),[K,q]=(0,_.useState)({email:e?.email||``,password:``,busy:!1,open:!1}),J=()=>f(async()=>{if(!K.email.trim()){d(`请填邮箱`);return}if(!K.password){d(`请填密码`);return}q(e=>({...e,busy:!0}));try{let e=await a(`/api/auth/login`,{method:`POST`,body:{email:K.email.trim(),password:K.password}});q(e=>({...e,password:``})),d(`已登录: ${e.email}`),await c()}finally{q(e=>({...e,busy:!1}))}}),ne=()=>f(async()=>{await a(`/api/auth/logout`,{method:`POST`}),d(`已登出`),await c()}),Y=(0,_.useCallback)(async()=>{if(e?.loggedIn)try{k(await a(`/api/todo`)),j(``)}catch(e){j(String(e.message||e))}},[e?.loggedIn]);(0,_.useEffect)(()=>{Y()},[Y,G]),(0,_.useEffect)(()=>{a(`/api/setting`).then(W).catch(()=>{})},[]);let X=!!U?.autoSyncAttachments,re=()=>f(async()=>{let e=!X,t=await a(`/api/setting`,{method:`POST`,body:{autoSyncAttachments:e}});W(t),d(e?`已开启:读任务时自动下载附件到本地`:`已关闭自动下载附件`)}),Z=(0,_.useCallback)(async()=>{N(!0);try{await Y()}finally{N(!1)}},[Y]),ie=(0,_.useMemo)(()=>{let e=new Map;if(!O)return e;for(let[t]of C)for(let n of O[t]||[])e.set(n.text,(e.get(n.text)||0)+1);return e},[O]),Q=(0,_.useMemo)(()=>{if(!O)return null;let e=n.topic,t=t=>t?e?t.filter(t=>t.topic===e):t:null;return{open:t(O.open),done:t(O.done),freeze:t(O.freeze)}},[O,n.topic]);if(!e?.loggedIn)return(0,v.jsxs)(`div`,{className:`cloud-page`,children:[(0,v.jsx)(g,{}),(0,v.jsxs)(`div`,{className:`card`,style:{padding:16,maxWidth:640},children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:`登录云端`}),(0,v.jsx)(`span`,{className:`tag bad`,children:`未登录`})]}),(0,v.jsxs)(`div`,{className:`row-inline`,style:{padding:12},children:[(0,v.jsx)(`input`,{placeholder:`邮箱`,size:`24`,spellCheck:`false`,value:K.email,onChange:e=>q(t=>({...t,email:e.target.value}))}),(0,v.jsx)(`input`,{placeholder:`密码`,type:`password`,size:`18`,value:K.password,onChange:e=>q(t=>({...t,password:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&J()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:J,disabled:K.busy,children:K.busy?`登录中…`:`登录`})]}),(0,v.jsxs)(`div`,{className:`muted`,style:{padding:`0 12px 12px`,fontSize:12},children:[`密码只用于本次请求,不写入本机配置;配置里只保存 token。 也可以用 CLI:`,(0,v.jsx)(`code`,{children:`nx-kv auth login <email>`}),`。`]})]})]});let ae=async(e,t)=>{let n=[];for(let[t]of C)for(let r of O[t]||[])r.text===e.text&&n.push({bucket:t,task:r});if(n.length<=1)return{bucket:t,task:e,pick:void 0};let r=n.findIndex(n=>n.bucket===t&&n.task.createdAt===e.createdAt),i=await y({title:`「${e.text.slice(0,30)}」有 ${n.length} 条,选哪一条?`,message:n.map((e,t)=>`[${t}] ${e.bucket} ${w(e.task.createdAt)} #${e.task.id}`).join(`
|
|
1
|
+
import{c as e,f as t,g as n,h as r,l as i,m as a,o,p as s,y as c}from"./task-status-BnymQMTw.js";import{a as l,i as u,l as d,n as f,t as p}from"./upload-BIMbGcCB.js";import{S as m,x as h}from"./index-Dq7eNqAB.js";import{t as g}from"./route-crumb-_IyS9fTT.js";var _=c(n(),1),v=r(),y=e=>`/api/file/content/${encodeURIComponent(e)}`;function b({text:e,compact:t=!1,className:n=``}){let r=d(e);return r.some(e=>e.type!==`text`)?(0,v.jsx)(`span`,{className:n?`mdtext ${n}`:`mdtext`,children:r.map((e,n)=>{if(e.type===`text`)return(0,v.jsx)(`span`,{className:`mdtext-plain`,children:e.value},n);let r=y(e.id);return e.type===`image`?(0,v.jsx)(`a`,{className:`embed-image`+(t?` compact`:``),href:r,target:`_blank`,rel:`noreferrer`,title:e.alt?`${e.alt}(点击看原图)`:e.id,children:(0,v.jsx)(`img`,{src:r,alt:e.alt||e.id,loading:`lazy`})},n):(0,v.jsx)(`a`,{className:`embed-file`,href:r,target:`_blank`,rel:`noreferrer`,title:e.id,children:e.alt||e.id},n)})}):(0,v.jsx)(`span`,{className:n,children:e})}function x({task:e,pick:t,group:n,onSaved:r,onCancel:i}){let o=s(),[c,d]=(0,_.useState)(e.text||``),[m,h]=(0,_.useState)(e.note||``),[g,y]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(!1),T=(0,_.useRef)(null),E=(0,_.useRef)(null),D=(0,_.useRef)(c),O=e=>{D.current=e,d(e)};(0,_.useEffect)(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[]);let k=e=>{if(!e)return;let t=T.current,n=D.current,r=t&&t.selectionStart!==null?t.selectionStart:n.length,i=t&&t.selectionEnd!==null?t.selectionEnd:r,a=n.slice(0,r),o=n.slice(i),s=a&&!/\s$/.test(a)?` `:``,c=`${a}${s}${e}${o&&!/^\s/.test(o)?` `:``}${o}`;O(c);let l=a.length+s.length+e.length;requestAnimationFrame(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(l,l))})},A=async e=>{let t=Array.from(e||[]).filter(e=>e&&e.size>0);if(t.length&&!x){S({done:0,total:t.length});try{let e=await l(t,{group:n,onProgress:(e,t)=>S({done:e,total:t})});k(u(e));let r=e.filter(e=>e.isImage).length;o(e.length===1?`已插入 ${e[0].name}`:`已插入 ${e.length} 个附件${r?`(图片 ${r} 个)`:``}`)}catch(e){o(String(e&&e.message||e))}finally{S(null)}}},j=e=>{let t=p(e);t.length&&(e.preventDefault(),A(t))},M=(0,_.useRef)(null);M.current=e=>A(f(e)),(0,_.useEffect)(()=>{let e=e=>Array.from(e.dataTransfer&&e.dataTransfer.types||[]).includes(`Files`),t=t=>{e(t)&&(t.preventDefault(),w(!0))},n=e=>{e.relatedTarget||w(!1)},r=t=>{e(t)&&(t.preventDefault(),w(!1),M.current&&M.current(t))};return window.addEventListener(`dragover`,t),window.addEventListener(`dragleave`,n),window.addEventListener(`drop`,r),()=>{window.removeEventListener(`dragover`,t),window.removeEventListener(`dragleave`,n),window.removeEventListener(`drop`,r)}},[]);let N=()=>{if(g)return;if(!String(D.current).trim()){o(`正文不能为空`);return}let i={group:n,ref:e.text,pick:t,matchTopic:e.topic,text:D.current};m!==(e.note||``)&&(i.note=m),y(!0),a(`/api/todo/item`,{method:`PATCH`,body:i}).then(()=>{o(`已保存`),r()}).catch(e=>o(String(e&&e.message||e))).finally(()=>y(!1))},P=e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),N())},F=x?`上传中 ${x.done}/${x.total}…`:`选择文件上传`,I=!String(c).trim();return(0,v.jsxs)(`div`,{className:`editor`+(C?` drag`:``),children:[(0,v.jsxs)(`div`,{className:`ed-tip`,children:[`粘贴(`,(0,v.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,v.jsx)(`kbd`,{children:`V`}),` 截图)、拖文件进来,或`,(0,v.jsx)(`button`,{type:`button`,className:`ed-link`,onClick:()=>E.current&&E.current.click(),disabled:!!x,children:`选择文件`}),`—— 会自动上传并插到光标处。`,(0,v.jsx)(`input`,{ref:E,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,A(t)}})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`正文`}),(0,v.jsx)(`textarea`,{ref:T,className:`ed-textarea`,rows:4,value:c,spellCheck:`false`,placeholder:`要做什么… 图片写 ,其他文件写 [文件名](fileId)`,onChange:e=>O(e.target.value),onPaste:j,onKeyDown:P}),(0,v.jsxs)(`div`,{className:`ed-meta`,children:[(0,v.jsxs)(`span`,{className:`ed-acts`,children:[(0,v.jsx)(`button`,{type:`button`,className:`btn small`,onClick:()=>E.current&&E.current.click(),disabled:!!x,children:F}),(0,v.jsxs)(`span`,{className:`hint`,children:[`图片 `,(0,v.jsx)(`code`,{children:``}),` 文件 `,(0,v.jsx)(`code`,{children:`[文件名](id)`})]})]}),(0,v.jsxs)(`span`,{className:`hint`,children:[c.length,` 字符`]})]})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`预览`}),(0,v.jsx)(`div`,{className:`preview`+(I?` empty`:``),children:I?(0,v.jsx)(`span`,{className:`muted`,children:`(暂无内容)`}):(0,v.jsx)(b,{text:c})})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`备注`}),(0,v.jsx)(`textarea`,{className:`ed-textarea`,rows:2,value:m,spellCheck:`false`,placeholder:`可选:完成结果、上下文补充`,onChange:e=>h(e.target.value)})]}),(0,v.jsxs)(`div`,{className:`ed-foot`,children:[(0,v.jsxs)(`span`,{className:`hint`,children:[(0,v.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,v.jsx)(`kbd`,{children:`Enter`}),` 保存`]}),(0,v.jsxs)(`span`,{className:`ed-acts`,children:[(0,v.jsx)(`button`,{className:`btn ghost`,onClick:i,disabled:g,children:`取消`}),(0,v.jsx)(`button`,{className:`btn`,onClick:N,disabled:g||!!x,children:g?`保存中…`:`保存`})]})]})]})}function S({onClose:e}){let{boot:n,refreshBoot:r}=m(),c=s(),l=t(),{dialog:u,node:d}=i(),[f,p]=(0,_.useState)([]),[g,y]=(0,_.useState)(``),[b,x]=(0,_.useState)({name:``,description:``}),[S,C]=(0,_.useState)(null),w=(0,_.useCallback)(async()=>{try{let e=await a(`/api/groups`);p(e.groups||[]),y(``)}catch(e){y(e.message||String(e))}},[]);(0,_.useEffect)(()=>{w()},[w]);let T=n?.groupId??0,E=e=>l(async()=>{let t=await a(`/api/group`,{method:`POST`,body:{locator:e}});c(t.id===0?`已切回默认组`:`已切换到 ${t.name}`),await r(),await w()}),D=()=>l(async()=>{let e=b.name.trim();if(!e){c(`请填名称`);return}let t=await a(`/api/groups`,{method:`POST`,body:{name:e,description:b.description.trim()}});x({name:``,description:``}),c(`已新建工作空间 ${t.name}(id=${t.id})`),await r(),await w()}),O=e=>l(async()=>{let t=await u({title:`重命名「${e.name}」`,input:!0,value:e.name});t!==null&&t.trim()&&(await a(`/api/groups/${e.id}`,{method:`PATCH`,body:{name:t.trim()}}),c(`已更新名称`),await r(),await w())}),k=e=>l(async()=>{await u({message:`解散工作空间「${e.name}」(id=${e.id})?\n\n后端要求组内已无 KV 数据,否则会拒绝。此操作不可撤销。`,danger:!0})&&(await a(`/api/groups/${e.id}`,{method:`DELETE`}),c(`已解散 ${e.name}`),await r(),await w())}),A=e=>l(async()=>{let t=await a(`/api/groups/${e.id}/members`);C({group:t.group,list:t.members||[]})});return n?.loggedIn?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(o,{title:`工作空间`,onClose:e,children:[(0,v.jsx)(`div`,{className:`muted`,style:{marginBottom:8},children:`清单按工作空间隔离读写。切换只改本机配置,不动服务端数据。`}),g?(0,v.jsx)(`div`,{className:`row muted`,children:g}):null,(0,v.jsxs)(`div`,{className:`list`,children:[(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(`span`,{className:`name`,children:`默认组`}),(0,v.jsx)(`span`,{className:`desc`,children:`不传 groupId,由后端回落`}),(0,v.jsx)(`span`,{className:`acts`,children:T===0?(0,v.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,v.jsx)(`button`,{className:`btn small`,onClick:()=>E(`default`),children:`切到这里`})})]}),f.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(h,{className:`name`,text:e.name,title:`点击复制名称`,children:e.name}),(0,v.jsx)(`span`,{className:`tag`,children:e.myRole||`member`}),e.description?(0,v.jsx)(`span`,{className:`desc`,children:e.description}):null,(0,v.jsxs)(`span`,{className:`muted mono`,children:[`id=`,e.id]}),(0,v.jsxs)(`span`,{className:`muted`,children:[e.memberCount,` 人`]}),(0,v.jsxs)(`span`,{className:`acts`,children:[e.id===T?(0,v.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,v.jsx)(`button`,{className:`btn small`,onClick:()=>E(String(e.id)),children:`切到这里`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>A(e),children:`成员`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>O(e),children:`改名`}),(0,v.jsx)(`button`,{className:`btn small ghost danger`,onClick:()=>k(e),children:`解散`})]})]},e.id)),!g&&!f.length?(0,v.jsx)(`div`,{className:`row muted`,children:`(没有其他工作空间)`}):null]}),(0,v.jsxs)(`div`,{className:`toolbar`,style:{marginTop:10},children:[(0,v.jsx)(`input`,{placeholder:`新工作空间名称`,size:`16`,value:b.name,onChange:e=>x({...b,name:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&D()}}),(0,v.jsx)(`input`,{placeholder:`描述(可选)`,size:`20`,value:b.description,onChange:e=>x({...b,description:e.target.value})}),(0,v.jsx)(`button`,{className:`btn`,onClick:D,children:`新建`}),(0,v.jsx)(`button`,{className:`btn ghost`,onClick:()=>l(w),children:`刷新`})]})]}),S?(0,v.jsx)(o,{title:`成员 · ${S.group.name}`,onClose:()=>C(null),children:(0,v.jsx)(`div`,{className:`list`,children:S.list.length?S.list.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(h,{className:`name`,text:e.email,title:`点击复制邮箱`,children:e.email}),(0,v.jsx)(`span`,{className:`tag`,children:e.role||`member`}),(0,v.jsx)(`span`,{className:`muted`,children:e.nickname})]},e.userId)):(0,v.jsx)(`div`,{className:`row muted`,children:`(没有成员)`})})}):null,d]}):(0,v.jsx)(o,{title:`工作空间`,onClose:e,children:(0,v.jsx)(`div`,{className:`muted`,children:`工作空间需要登录后才能列出。`})})}var C=[[`open`,`待办`],[`done`,`已完成`],[`freeze`,`冻结`]],w=e=>e?String(e).slice(0,16).replace(`T`,` `):``,T=15,E=(e,t)=>`${e}:${t.id}:${t.text}`;function D({bucket:t,task:n,dupCount:r,onAct:i}){let a=t===`done`,o=t===`freeze`,s=a?n.doneAt:o?n.frozenAt:n.createdAt;return(0,v.jsxs)(`div`,{className:`row cloud-row`,children:[(0,v.jsxs)(`div`,{className:`row-main`,children:[(0,v.jsxs)(`span`,{className:`tid`,children:[`#`,n.id]}),(0,v.jsx)(h,{className:`topic`,text:n.topic,title:`点击复制主题`,children:n.topic}),(0,v.jsx)(`span`,{className:`text`,title:n.text,children:(0,v.jsx)(b,{text:n.text,compact:!0})}),r>1?(0,v.jsxs)(`span`,{className:`tag`,title:`同内容有 ${r} 条,操作时需要消歧`,children:[`同内容×`,r]}):null,(0,v.jsx)(`span`,{className:`muted time`,children:w(s)}),(0,v.jsxs)(`span`,{className:`acts`,children:[t===`open`?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`done`,n),children:`完成`}):null,o?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`unfreeze`,n),children:`解冻`}):null,(0,v.jsx)(e,{items:[t===`open`&&{label:`冻结`,onPick:()=>i(`freeze`,n)},{label:`编辑`,onPick:()=>i(`edit`,n,t)},{label:`删除`,danger:!0,onPick:()=>i(`remove`,n,t)}]})]})]}),n.note?(0,v.jsx)(`div`,{className:`note`,children:n.note}):null]})}function O(){let{boot:e,ui:n,patchUi:r,refreshBoot:c}=m(),d=s(),f=t(),{dialog:y,node:b}=i(),[O,k]=(0,_.useState)(null),[A,j]=(0,_.useState)(``),[M,N]=(0,_.useState)(!1),[P,F]=(0,_.useState)({topic:``,text:``}),[I,L]=(0,_.useState)(null),[R,z]=(0,_.useState)(!1),[B,ee]=(0,_.useState)({}),[V,H]=(0,_.useState)(null),[U,W]=(0,_.useState)(null),G=e?.groupId??0,te=(e?.groups||[]).find(e=>e.id===G)?.name||(G?`#${G}`:`默认组`),[K,q]=(0,_.useState)({email:e?.email||``,password:``,busy:!1,open:!1}),J=()=>f(async()=>{if(!K.email.trim()){d(`请填邮箱`);return}if(!K.password){d(`请填密码`);return}q(e=>({...e,busy:!0}));try{let e=await a(`/api/auth/login`,{method:`POST`,body:{email:K.email.trim(),password:K.password}});q(e=>({...e,password:``})),d(`已登录: ${e.email}`),await c()}finally{q(e=>({...e,busy:!1}))}}),ne=()=>f(async()=>{await a(`/api/auth/logout`,{method:`POST`}),d(`已登出`),await c()}),Y=(0,_.useCallback)(async()=>{if(e?.loggedIn)try{k(await a(`/api/todo`)),j(``)}catch(e){j(String(e.message||e))}},[e?.loggedIn]);(0,_.useEffect)(()=>{Y()},[Y,G]),(0,_.useEffect)(()=>{a(`/api/setting`).then(W).catch(()=>{})},[]);let X=!!U?.autoSyncAttachments,re=()=>f(async()=>{let e=!X,t=await a(`/api/setting`,{method:`POST`,body:{autoSyncAttachments:e}});W(t),d(e?`已开启:读任务时自动下载附件到本地`:`已关闭自动下载附件`)}),Z=(0,_.useCallback)(async()=>{N(!0);try{await Y()}finally{N(!1)}},[Y]),ie=(0,_.useMemo)(()=>{let e=new Map;if(!O)return e;for(let[t]of C)for(let n of O[t]||[])e.set(n.text,(e.get(n.text)||0)+1);return e},[O]),Q=(0,_.useMemo)(()=>{if(!O)return null;let e=n.topic,t=t=>t?e?t.filter(t=>t.topic===e):t:null;return{open:t(O.open),done:t(O.done),freeze:t(O.freeze)}},[O,n.topic]);if(!e?.loggedIn)return(0,v.jsxs)(`div`,{className:`cloud-page`,children:[(0,v.jsx)(g,{}),(0,v.jsxs)(`div`,{className:`card`,style:{padding:16,maxWidth:640},children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:`登录云端`}),(0,v.jsx)(`span`,{className:`tag bad`,children:`未登录`})]}),(0,v.jsxs)(`div`,{className:`row-inline`,style:{padding:12},children:[(0,v.jsx)(`input`,{placeholder:`邮箱`,size:`24`,spellCheck:`false`,value:K.email,onChange:e=>q(t=>({...t,email:e.target.value}))}),(0,v.jsx)(`input`,{placeholder:`密码`,type:`password`,size:`18`,value:K.password,onChange:e=>q(t=>({...t,password:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&J()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:J,disabled:K.busy,children:K.busy?`登录中…`:`登录`})]}),(0,v.jsxs)(`div`,{className:`muted`,style:{padding:`0 12px 12px`,fontSize:12},children:[`密码只用于本次请求,不写入本机配置;配置里只保存 token。 也可以用 CLI:`,(0,v.jsx)(`code`,{children:`nx-kv auth login <email>`}),`。`]})]})]});let ae=async(e,t)=>{let n=[];for(let[t]of C)for(let r of O[t]||[])r.text===e.text&&n.push({bucket:t,task:r});if(n.length<=1)return{bucket:t,task:e,pick:void 0};let r=n.findIndex(n=>n.bucket===t&&n.task.createdAt===e.createdAt),i=await y({title:`「${e.text.slice(0,30)}」有 ${n.length} 条,选哪一条?`,message:n.map((e,t)=>`[${t}] ${e.bucket} ${w(e.task.createdAt)} #${e.task.id}`).join(`
|
|
2
2
|
`),input:!0,placeholder:`输入 0..${n.length-1}`,value:String(r>=0?r:0)});if(i===null)return null;let a=Number(i);return!Number.isInteger(a)||!n[a]?(d(`请输入 0..${n.length-1}`),null):{...n[a],pick:a}},oe=(e,t,n)=>f(async()=>{let r=e===`remove`||e===`edit`?await ae(t,n):{bucket:n,task:t,pick:void 0};if(!r)return;let i={group:G,ref:r.task.text,pick:r.pick};if(e===`done`){let e=await y({title:`完成结果`,message:`完成「${t.text.slice(0,40)}」`,input:!0,placeholder:`可选:写一句完成结果`});if(e===null)return;await a(`/api/todo/done`,{method:`POST`,body:{...i,result:e||void 0}}),d(`已完成`)}else if(e===`freeze`)await a(`/api/todo/freeze`,{method:`POST`,body:i}),d(`已冻结`);else if(e===`unfreeze`)await a(`/api/todo/unfreeze`,{method:`POST`,body:i}),d(`已解冻`);else if(e===`remove`){if(!await y({message:`删除「${t.text.slice(0,40)}」?`,danger:!0}))return;await a(`/api/todo/item`,{method:`DELETE`,body:i}),d(`已删除`)}else if(e===`edit`){H({task:r.task,pick:r.pick});return}await Z(),await c()}),se=()=>f(async()=>{let e=await y({title:`归档已完成的旧记录`,message:`把「完成时间早于该日期」的记录移到冷 key(默认 30 天前)。留空用默认值。`,input:!0,placeholder:`YYYY-MM-DD,留空 = 30 天前`});if(e===null)return;let t=await a(`/api/todo/archive`,{method:`POST`,body:{before:e.trim()||void 0,group:G}});d(t.moved?`已归档 ${t.moved} 条 → ${t.coldKey}`:`没有需要归档的记录`),await Z()}),ce=async e=>{let t=p(e);if(t.length){e.preventDefault();try{let e=await l(t,{group:G}),n=u(e);F(e=>({...e,text:[e.text,n].filter(Boolean).join(` `)})),d(e.length===1?`已上传 ${e[0].name} 并附到内容里`:`已上传 ${e.length} 个附件并附到内容里`)}catch(e){d(String(e&&e.message||e))}}},$=()=>f(async()=>{let e=P.topic.trim(),t=P.text.trim();if(!e){d(`请填主题`);return}if(!t){d(`请填内容`);return}let n=await a(`/api/todo`,{method:`POST`,body:{topic:e,text:t,group:G}});F({topic:e,text:``}),d(`已加入待办${n.topicAdded?`(新主题 ${e})`:``}`),await Z()}),le=(e,t)=>B[e]?t:t.slice(0,T),ue=O?.topics||[];return(0,v.jsxs)(`div`,{className:`cloud-page`,children:[(0,v.jsxs)(`div`,{className:`cloud-toolbar`,children:[(0,v.jsxs)(`button`,{className:`pill on rp-ws-trigger`,title:`切换工作空间 / 管理(清单按工作空间隔离)`,onClick:()=>z(!0),children:[te,` `,(0,v.jsx)(`span`,{className:`rp-caret`,children:`▾`})]}),(0,v.jsx)(`span`,{className:`sep`}),(0,v.jsx)(`label`,{children:`主题`}),(0,v.jsxs)(`select`,{value:n.topic,onChange:e=>r({topic:e.target.value}),children:[(0,v.jsx)(`option`,{value:``,children:`全部`}),ue.map(e=>(0,v.jsx)(`option`,{value:e,children:e},e))]}),(0,v.jsx)(`span`,{className:`grow`}),(0,v.jsxs)(`label`,{className:`toggle`+(X?` on`:``),title:`开启后,读取任务时会把正文引用的附件下载到本地,并把本地绝对路径一并返回给 agent。
|
|
3
3
|
当前目录:${U?U.resolvedDir:`(读取中…)`}`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:X,onChange:re}),(0,v.jsx)(`span`,{className:`dot`}),`附件自动下载`]}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:Z,disabled:M,children:M?`刷新中…`:`刷新`}),(0,v.jsx)(`button`,{className:`pill`+(K.open?` on`:``),title:`账号 ${e.email||``}(点击展开登录态 / 登出)`,onClick:()=>q(e=>({...e,open:!e.open})),children:e.email||`已登录`})]}),K.open?(0,v.jsxs)(`div`,{className:`card`,style:{padding:16,marginBottom:12},children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:`登录态`}),(0,v.jsx)(`button`,{className:`btn small ghost danger`,onClick:ne,children:`登出`})]}),(0,v.jsxs)(`div`,{className:`settings`,children:[(0,v.jsx)(`dt`,{children:`账号`}),(0,v.jsx)(`dd`,{children:e?.email}),(0,v.jsx)(`dt`,{children:`userId`}),(0,v.jsx)(`dd`,{children:e?.userId||`-`}),(0,v.jsx)(`dt`,{children:`后端`}),(0,v.jsx)(`dd`,{className:`mono`,children:(0,v.jsx)(h,{text:e?.baseUrl,children:e?.baseUrl})}),(0,v.jsx)(`dt`,{children:`本机配置`}),(0,v.jsx)(`dd`,{className:`mono`,children:(0,v.jsx)(h,{text:e?.configPath,children:e?.configPath})})]}),(0,v.jsxs)(`div`,{className:`row-inline`,style:{padding:`10px 0 0`},children:[(0,v.jsx)(`input`,{placeholder:`切换账号:邮箱`,size:`24`,spellCheck:`false`,value:K.email,onChange:e=>q(t=>({...t,email:e.target.value}))}),(0,v.jsx)(`input`,{placeholder:`密码`,type:`password`,size:`18`,value:K.password,onChange:e=>q(t=>({...t,password:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&J()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:J,disabled:K.busy,children:K.busy?`登录中…`:`登录`})]})]}):null,(0,v.jsxs)(`div`,{className:`cloud-compose`,children:[(0,v.jsx)(`input`,{className:`cloud-compose-topic`,placeholder:`主题`,"aria-label":`新任务主题`,value:P.topic,onChange:e=>F({...P,topic:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&$()}}),(0,v.jsx)(`input`,{className:`cloud-compose-text`,placeholder:`要做什么…(可 Ctrl+V 粘贴图片)`,"aria-label":`新任务内容`,value:P.text,title:`可以直接 Ctrl+V 粘贴截图:会自动上传为附件并附在内容里`,onChange:e=>F({...P,text:e.target.value}),onPaste:ce,onKeyDown:e=>{e.key===`Enter`&&$()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:$,children:`加入待办`})]}),A?(0,v.jsxs)(`div`,{className:`cloud-error`,children:[(0,v.jsxs)(`span`,{children:[`清单读取失败:`,A]}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:Z,children:`重试`})]}):null,!O&&!A?(0,v.jsx)(`div`,{className:`cloud-loading muted`,children:`读取中…`}):null,O?(0,v.jsx)(`div`,{className:`cols`,children:C.map(([e,t])=>(0,v.jsxs)(`div`,{className:`col col-`+e,children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:t}),(0,v.jsx)(`span`,{className:`cnt`,children:(Q?.[e]||[]).length}),e===`done`&&(Q?.done||[]).length?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`span`,{className:`grow`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:se,title:`把较旧的完成记录移到冷 key`,children:`归档旧记录`})]}):null]}),(0,v.jsxs)(`div`,{className:`card list`,children:[(Q?.[e]||[]).length?le(e,Q[e]).map(t=>(0,v.jsx)(D,{bucket:e,task:t,dupCount:ie.get(t.text)||1,onAct:oe},E(e,t))):(0,v.jsx)(`div`,{className:`cloud-empty`,children:e===`open`?(0,v.jsxs)(v.Fragment,{children:[`还没有待办`,(0,v.jsx)(`br`,{}),`在上方投递条输入,`,(0,v.jsx)(`kbd`,{children:`Enter`}),` 直达`]}):e===`done`?`还没有完成记录`:`没有冻结的任务`}),(Q?.[e]||[]).length>T?(0,v.jsx)(`div`,{className:`row muted`,style:{cursor:`pointer`,justifyContent:`center`},onClick:()=>ee(t=>({...t,[e]:!t[e]})),children:B[e]?`收起`:`还有 ${Q[e].length-T} 条,点击展开`}):null]})]},e))}):null,R?(0,v.jsx)(S,{onClose:()=>z(!1)}):null,V?(0,v.jsx)(o,{title:`编辑任务`,onClose:()=>H(null),children:(0,v.jsx)(x,{task:V.task,pick:V.pick,group:G,onCancel:()=>H(null),onSaved:async()=>{H(null),await Z(),await c()}})}):null,I?(0,v.jsx)(o,{title:I.title,size:`lg`,onClose:()=>L(null),children:I.node}):null,b]})}export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,h as t,p as n,u as r,y as i}from"./task-status-BnymQMTw.js";import{t as a}from"./workspace-C_5X2gIr.js";import{n as o}from"./app-context-D7HAx67n.js";import{a as s,i as c,n as l,p as u,r as d,t as f}from"./md-history-
|
|
1
|
+
import{g as e,h as t,p as n,u as r,y as i}from"./task-status-BnymQMTw.js";import{t as a}from"./workspace-C_5X2gIr.js";import{n as o}from"./app-context-D7HAx67n.js";import{a as s,i as c,n as l,p as u,r as d,t as f}from"./md-history-DI1Ukbvc.js";import"./index-Dq7eNqAB.js";import{i as p,o as m,r as ee,t as h}from"./composer-launch-Bf4rXhLs.js";var g=i(e(),1),_=t(),v=96;function y({token:e,mode:t=`comment`,quote:i=``,prevQuote:y=``,taskLabel:b=``,taskTitle:x=``,src:S=null}){let C=o()||{},w=n(),[T,E]=(0,g.useState)(``),[D,O]=(0,g.useState)([]),[k,A]=(0,g.useState)(!1),j=(0,g.useRef)(null),M=t===`feedback`,N=(0,g.useRef)(new Map),P=`compose-`+e,F=()=>{f(N.current,P),ee(C.model,e)},I=(e,t=`op`)=>{l(N.current,P,{title:``,body:T},t),E(e)},L=()=>{let e=c(N.current,P,{title:``,body:T});e&&E(e.body)},R=()=>{let e=d(N.current,P,{title:``,body:T});e&&E(e.body)},z=async()=>{let t=String(T||``).trim();if(!t&&!D.length){w(M?`写一下要改的地方`:`写一下要提的问题`);return}let n=h(e);if(!n||!n.onSubmit){w(`提交入口已失效(来源页面已关闭)`);return}A(!0);try{await n.onSubmit({text:t,attachments:D,inserts:``}),F()}catch(e){w(String(e.message||e))}finally{A(!1)}},B=async e=>{if(!e||!e.length)return;let{items:t,imageInserts:n,fileInserts:r}=await p(e),i=[...n,...r].join(``);i&&E(e=>u(e,i,{}).body),t.length&&O(e=>[...e,...t])},V=(0,g.useRef)(null),[H,U]=(0,g.useState)(()=>localStorage.getItem(`nxkv.cmpDockOpen`)!==`0`),[W,G]=(0,g.useState)(()=>{let e=Number(localStorage.getItem(`nxkv.cmpDockH`));return Number.isFinite(e)&&e>=v?e:176}),K=(0,g.useRef)(W);K.current=W;let[q,J]=(0,g.useState)(!1),Y=(0,g.useRef)(176);(0,g.useEffect)(()=>{localStorage.setItem(`nxkv.cmpDockOpen`,H?`1`:`0`)},[H]);let X=()=>{if(q){G(Y.current),J(!1);return}Y.current=W;let e=document.querySelector(`.cmp`)?.clientHeight||window.innerHeight;G(Math.max(v,Math.round(e*.62))),J(!0)},Z=e=>{if(!H)return;e.preventDefault(),J(!1);let t=e.clientY,n=K.current,r=e=>Math.max(v,Math.min(Math.round(e),Math.round((document.querySelector(`.cmp`)?.clientHeight||window.innerHeight)*.62))),i=e=>{K.current=r(n-(e.clientY-t)),G(K.current)},a=()=>{window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(`nxkv.cmpDockH`,String(K.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)},Q=()=>{let e=C.model;e&&S&&S.task&&a(e,{component:`page`,name:S.name||`原文`,config:{dirKey:S.dirKey,task:String(S.task)}})},$=!!(S&&S.task);return(0,_.jsxs)(`div`,{className:`cmp`,children:[(0,_.jsxs)(`div`,{className:`cmp-head`,children:[(0,_.jsx)(`span`,{className:`cmp-tag`+(M?` is-fb`:``),children:M?`反馈`:`评论`}),(0,_.jsx)(`div`,{className:`cmp-ctx`,children:M?(0,_.jsxs)(`span`,{className:`cmp-ctx-line`,title:x||``,children:[`反馈 `,b||``,` 的任务`,x?` · ${x}`:``]}):(0,_.jsx)(`span`,{className:`cmp-ctx-line`,children:`对本任务提出问题`})}),(0,_.jsx)(`span`,{className:`grow`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:F,disabled:k,children:`关闭`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:z,disabled:k,children:M?`提交反馈`:`提交评论`})]}),M?(0,_.jsxs)(`div`,{className:`cmp-quote-wrap`,children:[(0,_.jsxs)(`div`,{className:`cmp-quote-cap`,children:[`之前的引用`,$&&(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote-cmp`,onClick:Q,title:`在右侧并排显示原文,方便对照`,children:`对照原文 ↗`})]}),$?(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote`,onClick:Q,title:`点击在右侧并排显示原文,方便对照`,children:y||`(这条任务还没有可引用的上轮总结)`}):(0,_.jsx)(`div`,{className:`cmp-quote`,children:y||`(这条任务还没有可引用的上轮总结)`})]}):i?(0,_.jsxs)(`div`,{className:`cmp-quote-wrap`,children:[(0,_.jsxs)(`div`,{className:`cmp-quote-cap`,children:[`引用`,$&&(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote-cmp`,onClick:Q,title:`在右侧并排显示原文,方便对照`,children:`对照原文 ↗`})]}),$?(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote`,onClick:Q,title:`点击在右侧并排显示原文,方便对照`,children:i}):(0,_.jsx)(`div`,{className:`cmp-quote`,children:i})]}):null,(0,_.jsx)(`div`,{className:`cmp-body`,children:(0,_.jsx)(s,{mode:`split`,title:``,body:T,onTitle:()=>{},onBody:I,attachments:D,docKey:`compose-`+e,editorApiRef:j,onFiles:B,onSave:z,onUndo:L,onRedo:R,hideTitle:!0})}),H&&(0,_.jsxs)(`div`,{className:`mdw-dock`,style:{height:`${W}px`},children:[(0,_.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:Z,onDoubleClick:X}),(0,_.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,_.jsx)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:(0,_.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":`true`,className:`mdw-dock-tab is-on`,onClick:()=>U(!0),children:[`附件`,D.length?(0,_.jsx)(`span`,{className:`mdw-dock-tab-num`,children:D.length}):null]})}),(0,_.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,title:`添加附件`,"aria-label":`添加附件`,onClick:()=>V.current?.click(),children:(0,_.jsx)(r,{name:`plus`})}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:X,title:q?`还原面板高度`:`最大化面板高度`,"aria-label":q?`还原面板高度`:`最大化面板高度`,children:(0,_.jsx)(r,{name:q?`collapse`:`expand`})}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>U(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,_.jsx)(r,{name:`x`})})]})]}),(0,_.jsx)(`div`,{className:`mdw-dock-body`,children:D.length?(0,_.jsx)(m,{attachments:D,onRemove:e=>O(t=>t.filter(t=>t.id!==e))}):(0,_.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有附件——粘贴 / 拖图片进正文即附件,或点右上「+」添加文件。`})})]}),(0,_.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${H?` is-on`:``}`,onClick:()=>U(e=>!e),title:`附件(点击展开/收起信息面板)`,children:[(0,_.jsx)(r,{name:`list`}),(0,_.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`}),D.length?(0,_.jsx)(`span`,{className:`mdw-sbar-num`,children:D.length}):null]}),(0,_.jsx)(`span`,{className:`mdw-sbar-grow`}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${H?` is-open`:``}`,onClick:()=>U(e=>!e),title:H?`收起信息面板`:`展开信息面板`,"aria-expanded":H,"aria-label":H?`收起信息面板`:`展开信息面板`,children:(0,_.jsx)(r,{name:`chevron`})})]}),(0,_.jsx)(`input`,{ref:V,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&B(t)}})]})}export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,o as t,u as n}from"./task-status-BnymQMTw.js";import{a as r}from"./md-parse-awNLHAzO.js";import{n as i}from"./model-DzdWfp14.js";import{t as a}from"./status-tag-
|
|
1
|
+
import{h as e,o as t,u as n}from"./task-status-BnymQMTw.js";import{a as r}from"./md-parse-awNLHAzO.js";import{n as i}from"./model-DzdWfp14.js";import{t as a}from"./status-tag-Bop-R-gG.js";var o=e();function s({icon:e=`list`,title:t,pendingCount:r=0,headerExtra:i=null,children:a=null,emptyText:s=``}){return(0,o.jsxs)(`div`,{className:`rp-tasks`,children:[(0,o.jsxs)(`div`,{className:`rp-tasks-h`,children:[(0,o.jsx)(n,{name:e,size:13}),` `,t,r>0&&(0,o.jsxs)(`span`,{className:`rp-chip-count`,children:[`待领取 `,r]}),i]}),a,!a&&s?(0,o.jsx)(`div`,{className:`rp-proj-none muted`,children:s}):null]})}function c({name:e,counts:t=[],icon:r=`folder`,actions:i=null,intro:a=null,batch:s=null,list:c=null,footer:l=null,extra:u=null}){return(0,o.jsxs)(`div`,{className:`rp-page`,children:[(0,o.jsxs)(`div`,{className:`rp-group-head`,children:[(0,o.jsxs)(`h2`,{children:[(0,o.jsx)(n,{name:r,size:15}),` `,e,t.map((e,t)=>{let n=typeof e==`string`?e:e&&e.text||``;return n?(0,o.jsx)(`span`,{className:`rp-chip-count`,children:n},t):null})]}),i?(0,o.jsx)(`div`,{className:`rp-group-acts`,children:i}):null]}),a,s,c,l,u]})}function l(e){let t=String(e||``).trim();if(!t)return`—`;let n=t.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/);return n?`${n[1].slice(5)} ${n[2]}`:t.slice(0,16)}function u({t:e,projectTag:t=``,projectTitle:r=``,selectable:s=!1,picked:c=!1,onTogglePick:u,draggable:d=!1,dragHandlers:f=null,dragVisual:p,onOpen:m,showTimes:h=!1,downs:g=[],history:_=!1,ops:v=null}){let y=`rp-proj-row`+(p?.dragging?` dragging`:``)+(p?.drop?` drop-`+p.drop:``),b=e.status===`pending`&&e.ready===!1;return(0,o.jsxs)(`div`,{className:y,...f?{onDragOver:f.onDragOver,onDragLeave:f.onDragLeave,onDrop:f.onDrop}:{},children:[d?(0,o.jsx)(`span`,{className:`rp-drag-handle`,draggable:!0,title:`拖动调整队列内顺序`,"aria-label":`拖动排序`,onDragStart:f?.onDragStart,onDragEnd:f?.onDragEnd,onClick:e=>e.stopPropagation(),children:(0,o.jsx)(n,{name:`grip`,size:12})}):(0,o.jsx)(`span`,{className:`rp-drag-handle off`,"aria-hidden":`true`}),s?(0,o.jsx)(`span`,{className:`rp-proj-pick`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,o.jsx)(`input`,{type:`checkbox`,checked:c,onChange:()=>u?.(e.id),"aria-label":`选择任务 #${e.id}`})}):null,(0,o.jsxs)(`div`,{className:`rp-proj-task`+(_?` done`:``),role:`button`,tabIndex:0,title:`打开这条任务`,onClick:()=>m?.(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),m?.(e))},children:[(0,o.jsxs)(`span`,{className:`mono`,children:[`#`,e.id]}),t?(0,o.jsx)(`span`,{className:`rp-ptag`,title:`归属项目:${r||t}`,children:t}):null,(0,o.jsx)(`span`,{className:`rp-proj-task-tx`,children:i(e)}),e.timegoal&&(0,o.jsxs)(`span`,{className:`rp-proj-goal`,title:`时间目标 ${e.timegoal.duration}:领取即计时,未到点不许标完成`,children:[(0,o.jsx)(n,{name:`clock`,size:11}),` `,e.timegoal.duration]}),e.blocksFollowing&&(0,o.jsxs)(`span`,{className:`rp-tgate`,title:g.length?`闸门:未完成前挡住 ${g.length} 个后续任务(#${g.join(`, #`)})`:`闸门:未完成前挡住队列里排在后面的待领取任务`,children:[`闸门`,g.length?`×${g.length}`:``]}),b&&(0,o.jsx)(`span`,{className:`rp-tlock`,title:e.blockBy?.length?`等待依赖完成:#${e.blockBy.join(`, #`)}`:`被前方闸门挡住`,children:`锁定`}),h&&(0,o.jsxs)(`span`,{className:`rp-proj-times mono`,title:`创建 ${e.createdAt||`—`}${e.consumedAt?` · 领取 ${e.consumedAt}`:``}`,children:[l(e.createdAt),e.consumedAt?` → ${l(e.consumedAt)}`:``]}),(0,o.jsx)(a,{t:e}),v?(0,o.jsx)(`span`,{className:`rp-proj-ops`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:v}):null]})]})}function d(e){let t=String(e||``).trim();if(!t)return`—`;let n=t.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/);return n?`${n[1].slice(5)} ${n[2]}`:t.slice(0,16)}function f({tasks:e=[],onClose:n,onRestore:i,onPurge:a}){return(0,o.jsx)(t,{title:`已删除任务(${e.length})`,onClose:n,children:e.length===0?(0,o.jsx)(`div`,{className:`mdw-del-empty`,children:`这个目录没有已删除的任务。`}):(0,o.jsx)(`table`,{className:`mdw-del-list`,children:(0,o.jsx)(`tbody`,{children:e.map(e=>(0,o.jsxs)(`tr`,{children:[(0,o.jsxs)(`td`,{className:`mdw-del-id mono`,children:[`#`,e.id]}),(0,o.jsx)(`td`,{className:`mdw-del-title`,title:r(e.text),children:r(e.text)||`—`}),(0,o.jsx)(`td`,{className:`mdw-del-time mono`,children:d(e.deletedAt)}),(0,o.jsxs)(`td`,{className:`mdw-del-ops`,children:[(0,o.jsx)(`button`,{type:`button`,className:`btn sm ghost`,title:`恢复到队列原位置`,onClick:()=>i?.(e),children:`恢复`}),(0,o.jsx)(`button`,{type:`button`,className:`btn sm danger`,title:`彻底删除(不可恢复)`,onClick:()=>a?.(e),children:`彻底删除`})]})]},e.id))})})})}export{s as i,u as n,c as r,f as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as e,g as t,h as n,l as r,m as i,o as a,p as o,s,u as c,y as l}from"./task-status-BnymQMTw.js";import{r as u,u as d}from"./workspace-C_5X2gIr.js";import{n as f}from"./app-context-D7HAx67n.js";import{a as p,n as m}from"./md-parse-awNLHAzO.js";import{o as h,r as g,t as _}from"./board-view-CZKZsyk-.js";import{n as v}from"./model-DzdWfp14.js";import{_ as y,a as b,g as x,i as S,m as C,o as w,p as T,r as ee,s as E,u as D}from"./index-DNB8tgNi.js";import{t as O}from"./graph-DM-zDRdL.js";import{n as te,r as k,t as ne}from"./reopen-text-BylkngqC.js";import{t as A}from"./Introduction-DAXj7E6q.js";import{t as j}from"./bar-KTPTE33i.js";import{i as M,n as re,r as N,t as P}from"./deleted-panel-B6sZddUs.js";var F=l(t(),1),I=n();function L({isGlobal:t,topic:n,repo:r=null,model:i=null,tasks:a=[],taskCount:o=0,pendingCount:s=0,page:l=0,pageCount:u=1,onPage:d,onNew:f,onOpenTask:p,onDeleteTask:m,onDeleteTasks:h,onCancelTasks:g,onCompleteTasks:_,onReopenTask:y,onTplMenu:b,onImport:S,onProg:C,onMoveTask:w,onOpenDag:T,onOpenFlow:ee,onToggleGate:E,downstreamOf:D,onDeleted:O,onRefs:te,deletedCount:k=0}){let ne=t?`全局池`:n?.name||`目录`,P=(0,F.useRef)(null),[L,R]=(0,F.useState)(null),[z,B]=(0,F.useState)(null),[V,H]=(0,F.useState)(()=>new Set);(0,F.useEffect)(()=>{H(new Set)},[l]);let U=a.map(e=>Number(e.id)),W=U.length>0&&U.every(e=>V.has(e)),G=a.filter(e=>V.has(Number(e.id))),K=G.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),ie=e=>{let t=Number(e);H(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},q=()=>{H(e=>{let t=new Set(e);return W?U.forEach(e=>t.delete(e)):U.forEach(e=>t.add(e)),t})},J=async e=>{let t=[...V],n=e===`cancel`?g:e===`complete`?_:h;t.length&&n&&await n(t)&&H(new Set)},Y=e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt,X=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},ae=(e,t)=>{P.current={id:Number(t.id)},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.id),R(Number(t.id))},oe=(e,t)=>{P.current&&Y(t)&&Number(t.id)!==P.current.id&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,B({id:Number(t.id),zone:X(e,e.currentTarget)}))},se=e=>{e.currentTarget.contains(e.relatedTarget)||B(null)},Z=(e,t)=>{e.preventDefault();let n=X(e,e.currentTarget),r=P.current;P.current=null,R(null),B(null),r&&Y(t)&&Number(t.id)!==r.id&&w&&w({id:r.id},t.id,n)},Q=()=>{P.current=null,R(null),B(null)},ce=G.length>0?(0,I.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,I.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,G.length,` 条`]}),_&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!K.length,title:K.length?`把选中的待领取任务标为已完成(补一条完成记录,原文留档)`:`只有待领取任务可以直接标为完成`,onClick:()=>J(`complete`),children:[`标为完成选中`,K.length?` (${K.length})`:``]}),g&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!K.length,title:K.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消`,onClick:()=>J(`cancel`),children:[`取消选中`,K.length?` (${K.length})`:``]}),h&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>J(`delete`),children:[`删除选中 (`,G.length,`)`]}),(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>H(new Set),children:`清空`})]}):null,le=(0,I.jsx)(M,{title:t?`全局池任务`:`任务`,pendingCount:s,headerExtra:a.length?(0,I.jsxs)(`label`,{className:`rp-proj-pickall`,title:`全选/取消全选当前页`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:W,onChange:q,"aria-label":`全选当前页任务`}),`全选本页`]}):null,emptyText:`还没有页面:点「+ 新建页」写第一篇,或让 agent 往${t?`全局池`:`这个目录`}投递任务。`,children:a.map(t=>{let n=Y(t),r=D&&D[t.id]||[];return(0,I.jsx)(re,{t,selectable:!0,picked:V.has(Number(t.id)),onTogglePick:ie,draggable:n,dragHandlers:n?{onDragStart:e=>ae(e,t),onDragOver:e=>oe(e,t),onDragLeave:se,onDrop:e=>Z(e,t),onDragEnd:Q}:null,dragVisual:{dragging:L===Number(t.id),drop:z&&z.id===Number(t.id)?z.zone:null},showTimes:!0,downs:r,onOpen:e=>p(e.id),ops:(0,I.jsxs)(I.Fragment,{children:[n&&(T||E)&&(0,I.jsx)(e,{items:[{label:`编排依赖…`,onPick:()=>T&&T(t)},{label:t.blocksFollowing?`取消闸门(不再挡后续)`:`设为闸门(挡住后续)`,onPick:()=>E&&E(t)}]}),y&&t.status!==`cancelled`&&!t.childCount&&(t.status===`claimed`||t.status===`done`||t.completedAt)&&(0,I.jsx)(`span`,{className:`op`,role:`button`,tabIndex:-1,title:t.completedAt?`反馈:新开一条任务(原任务不动)`:`反馈修改:回写本任务并记入任务链`,"aria-label":`反馈 ${v(t)}`,onClick:()=>y(t),children:(0,I.jsx)(c,{name:`refresh`,size:12})}),m&&(0,I.jsx)(`span`,{className:`op danger`,role:`button`,tabIndex:-1,title:`删除此任务(软删除,CLI 可恢复)`,"aria-label":`删除 ${v(t)}`,onClick:()=>m(t),children:(0,I.jsx)(c,{name:`x`,size:12})})]})},t.id)})}),$=o>0?(0,I.jsx)(`div`,{className:`mdw-land-pager`,children:(0,I.jsx)(x,{page:l,pageCount:u,total:o,onPage:d,unit:`个任务`})}):null;return(0,I.jsx)(N,{name:ne,counts:[`${o} 个任务`,...s>0?[`待领取 ${s}`]:[]],intro:!t&&r?(0,I.jsx)(A,{kind:`repo`,owner:r,model:i}):null,batch:ce,list:le,footer:$,actions:(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(j,{kind:`dir`,labels:{more:k>0?`更多 (${k})`:`更多`,deleted:k>0?`已删除任务(${k})`:`已删除任务`},titles:{new:`按默认模板新建一页(▾ 选模板)`,import:`把一个 .md 文件导入成任务`,progress:`打开这个目录的进程面板`,more:k>0?`更多操作(含 ${k} 条已删除任务)`:`更多操作`,deleted:`查看并恢复已删除任务`,refs:`查看文档 / reference 列表`},renderers:{new:()=>(0,I.jsx)(`span`,{className:`rp-newtask`,children:(0,I.jsxs)(`button`,{type:`button`,className:`btn small primary`,title:`按默认模板新建一页(▾ 选模板)`,onClick:()=>f(),children:[`+ 新建页`,(0,I.jsx)(`span`,{role:`button`,tabIndex:0,"aria-label":`选择模板新建一页`,"aria-haspopup":`menu`,className:`rp-newtask-caret`,title:`选择模板新建一页`,onClick:e=>{e.stopPropagation(),b?.(e)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),b?.(e))},children:(0,I.jsx)(c,{name:`chevron`,size:11})})]})})},actions:{new:f,import:S,progress:C,orch:ee,deleted:O,refs:te}})})})}var R=(e,t,n)=>O(e=>n.get(e)||[],e,t);function z({task:e,tasks:t,onClose:n,onSave:r}){let i=e=>Number(e.id),o=i(e),s=t.filter(e=>i(e)!==o),[c,l]=(0,F.useState)(!!e.blocksFollowing),[u,d]=(0,F.useState)(()=>new Set((e.blockBy||[]).map(Number))),[f,m]=(0,F.useState)(()=>new Set(s.filter(e=>(e.blockBy||[]).map(Number).includes(o)).map(i))),[h,g]=(0,F.useState)(!1),_=t.findIndex(e=>i(e)===o),v=t.slice(_+1).map(i),y=new Map(t.map(e=>[i(e),i(e)===o?[...u]:(e.blockBy||[]).map(Number)])),b=e=>c||!u.has(i(e))&&R(i(e),o,y),x=e=>!f.has(i(e))&&R(o,i(e),y),S=e=>t=>e(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}),C=()=>l(e=>(e||d(new Set),!e)),w=async()=>{g(!0);try{let e=[{id:o,gate:c,blockBy:[...u]}];if(!c)for(let t of s){let n=i(t),r=f.has(n),a=(t.blockBy||[]).map(Number);r!==a.includes(o)&&e.push({id:n,blockBy:r?[...a,o]:a.filter(e=>e!==o)})}await r(e),n()}catch{}finally{g(!1)}},T=(e,t,n,r)=>{let a=p(e.text)||`#${i(e)}`;return(0,I.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!h?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:t,disabled:h||n,onChange:()=>r(i(e))}),(0,I.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,I.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,I.jsx)(a,{title:`编排 · #${o} ${p(e.text)||``}`,onClose:n,busy:h,size:`md`,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:h,onClick:n,children:`取消`}),(0,I.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:h,onClick:w,children:h?`保存中…`:`保存编排`})]}),children:(0,I.jsxs)(`div`,{className:`mdw-dag`,children:[(0,I.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:c,disabled:h,onChange:C}),(0,I.jsx)(`b`,{children:`闸门`}),(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),c?(0,I.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,v.length,` 个后续任务`,v.length?`:${v.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,I.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,c?(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,I.jsx)(`div`,{className:`mdw-dag-list`+(c?` dim`:``),children:s.length?s.map(e=>T(e,u.has(i(e)),b(e),S(d))):(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,I.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,c?(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,I.jsx)(`div`,{className:`mdw-dag-list`+(c?` dim`:``),children:s.length?s.map(e=>T(e,f.has(i(e)),c||x(e),S(m))):(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}var B=20;function V({dirKey:e}){let{dialog:t,node:n}=r(),a=f()||{},c=o(),l=a.rows||[],p=a.refreshLocal,v=a.tpl,x=a.model,O=a.repoData&&a.repoData.repos||[],A=!e||e===`__GLOBAL__`,[j,M]=(0,F.useState)(null),[re,N]=(0,F.useState)(!1),[R,V]=(0,F.useState)(null),H=(0,F.useRef)(null),U=(0,F.useMemo)(()=>A?l.find(e=>e.isGlobal)||null:l.find(t=>t.key===e)||null,[l,e,A]),W=(0,F.useMemo)(()=>{if(!U||A)return null;let e=U.repo&&U.repo.key;if(e){let t=O.find(t=>t.key===e);if(t)return t}let t=String(U.cwd||``).replace(/\\/g,`/`).toLowerCase();return t&&O.find(e=>String(e.path||``).replace(/\\/g,`/`).toLowerCase()===t)||null},[U,O,A]),G=(0,F.useMemo)(()=>h((U?.tasks||[]).filter(e=>!e.deletedAt&&!g(e))),[U]),K=y(G,B),ie=(0,F.useMemo)(()=>G.filter(e=>e.status===`pending`&&!e.migratedTo).length,[G]),q=e=>e().catch(e=>c(String(e.message||e))),J=()=>A?{key:_}:{cwd:U.cwd},Y=(e,t,n)=>{q(async()=>{await i(`/api/localtasks/reorder`,{method:`PATCH`,body:{...J(),id:e.id,...n===`before`?{beforeId:t}:{afterId:t}}}),p()})},X=e=>{q(async()=>{await i(`/api/localtasks/item`,{method:`PATCH`,body:{...J(),id:e.id,gate:!e.blocksFollowing}}),c(e.blocksFollowing?`#${e.id} 闸门已取消`:`#${e.id} 已设为闸门——挡住所有后续待领取任务`),p()})},ae=async e=>{try{for(let t of e)await i(`/api/localtasks/item`,{method:`PATCH`,body:{...J(),...t}});c(`编排已保存`),p()}catch(e){throw c(String(e.message||e)),e}},oe=(0,F.useMemo)(()=>{let e={},t=G.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt);return t.forEach((n,r)=>{n.blocksFollowing&&(e[n.id]=t.slice(r+1).map(e=>e.id))}),e},[G]),se=(0,F.useMemo)(()=>G.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),[G]),Z=t=>{a.openPage&&a.openPage({dirKey:e,task:String(t),name:`#${t}`})},Q=t=>{let n=D();T(E(C(e),n),{title:``,body:t}),a.openPage&&a.openPage({dirKey:e,task:n,name:`新任务`})},ce=()=>{x&&b(x)},le=()=>{x&&u(x,{component:`progress`,name:`进程`,config:{dirKey:e||`__GLOBAL__`},location:`right`})},$=A?_:e,ue=ee($).templates||v&&v.templates||[],de=()=>{if(!x){c(`工作区未就绪`);return}w(x,{mode:`new`,topic:$,scope:A?[]:[`topic:${$}`],name:``})},fe=[...ue.length?ue.map(e=>({label:(e.id===v?.defaultId?`✓ `:``)+e.name,icon:`list`,onClick:()=>Q(S(e.body,{...m,...e.values||{}}))})):[{label:`按默认模板新建一页`,icon:`list`,onClick:()=>Q(v?v.defaultBody():``)}],`sep`,{label:`为本${A?`全局池`:`目录`}新建模板…`,icon:`plus`,onClick:de},{label:`管理模板…`,icon:`gear`,onClick:ce}],pe=async e=>{if(e==null)return null;let t=A?`key=${encodeURIComponent(_)}&id=${Number(e.id)}`:`cwd=${encodeURIComponent(U?.cwd||``)}&id=${Number(e.id)}`;return i(`/api/localtasks/item?${t}`).catch(()=>null)},me=n=>{if(!n)return;let r=(n.text||``).split(`
|
|
1
|
+
import{c as e,g as t,h as n,l as r,m as i,o as a,p as o,s,u as c,y as l}from"./task-status-BnymQMTw.js";import{r as u,u as d}from"./workspace-C_5X2gIr.js";import{n as f}from"./app-context-D7HAx67n.js";import{a as p,n as m}from"./md-parse-awNLHAzO.js";import{o as h,r as g,t as _}from"./board-view-CZKZsyk-.js";import{n as v}from"./model-DzdWfp14.js";import{_ as y,a as b,g as x,i as S,m as C,o as w,p as T,r as ee,s as E,u as D}from"./index-Dq7eNqAB.js";import{t as O}from"./graph-DM-zDRdL.js";import{n as te,r as k,t as ne}from"./reopen-text-BylkngqC.js";import{t as A}from"./Introduction-CDSLSy0q.js";import{t as j}from"./bar-Dp9JHQEk.js";import{i as M,n as re,r as N,t as P}from"./deleted-panel-QHsQZ5Ez.js";var F=l(t(),1),I=n();function L({isGlobal:t,topic:n,repo:r=null,model:i=null,tasks:a=[],taskCount:o=0,pendingCount:s=0,page:l=0,pageCount:u=1,onPage:d,onNew:f,onOpenTask:p,onDeleteTask:m,onDeleteTasks:h,onCancelTasks:g,onCompleteTasks:_,onReopenTask:y,onTplMenu:b,onImport:S,onProg:C,onMoveTask:w,onOpenDag:T,onOpenFlow:ee,onToggleGate:E,downstreamOf:D,onDeleted:O,onRefs:te,deletedCount:k=0}){let ne=t?`全局池`:n?.name||`目录`,P=(0,F.useRef)(null),[L,R]=(0,F.useState)(null),[z,B]=(0,F.useState)(null),[V,H]=(0,F.useState)(()=>new Set);(0,F.useEffect)(()=>{H(new Set)},[l]);let U=a.map(e=>Number(e.id)),W=U.length>0&&U.every(e=>V.has(e)),G=a.filter(e=>V.has(Number(e.id))),K=G.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),ie=e=>{let t=Number(e);H(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},q=()=>{H(e=>{let t=new Set(e);return W?U.forEach(e=>t.delete(e)):U.forEach(e=>t.add(e)),t})},J=async e=>{let t=[...V],n=e===`cancel`?g:e===`complete`?_:h;t.length&&n&&await n(t)&&H(new Set)},Y=e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt,X=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},ae=(e,t)=>{P.current={id:Number(t.id)},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.id),R(Number(t.id))},oe=(e,t)=>{P.current&&Y(t)&&Number(t.id)!==P.current.id&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,B({id:Number(t.id),zone:X(e,e.currentTarget)}))},se=e=>{e.currentTarget.contains(e.relatedTarget)||B(null)},Z=(e,t)=>{e.preventDefault();let n=X(e,e.currentTarget),r=P.current;P.current=null,R(null),B(null),r&&Y(t)&&Number(t.id)!==r.id&&w&&w({id:r.id},t.id,n)},Q=()=>{P.current=null,R(null),B(null)},ce=G.length>0?(0,I.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,I.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,G.length,` 条`]}),_&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!K.length,title:K.length?`把选中的待领取任务标为已完成(补一条完成记录,原文留档)`:`只有待领取任务可以直接标为完成`,onClick:()=>J(`complete`),children:[`标为完成选中`,K.length?` (${K.length})`:``]}),g&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!K.length,title:K.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消`,onClick:()=>J(`cancel`),children:[`取消选中`,K.length?` (${K.length})`:``]}),h&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>J(`delete`),children:[`删除选中 (`,G.length,`)`]}),(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>H(new Set),children:`清空`})]}):null,le=(0,I.jsx)(M,{title:t?`全局池任务`:`任务`,pendingCount:s,headerExtra:a.length?(0,I.jsxs)(`label`,{className:`rp-proj-pickall`,title:`全选/取消全选当前页`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:W,onChange:q,"aria-label":`全选当前页任务`}),`全选本页`]}):null,emptyText:`还没有页面:点「+ 新建页」写第一篇,或让 agent 往${t?`全局池`:`这个目录`}投递任务。`,children:a.map(t=>{let n=Y(t),r=D&&D[t.id]||[];return(0,I.jsx)(re,{t,selectable:!0,picked:V.has(Number(t.id)),onTogglePick:ie,draggable:n,dragHandlers:n?{onDragStart:e=>ae(e,t),onDragOver:e=>oe(e,t),onDragLeave:se,onDrop:e=>Z(e,t),onDragEnd:Q}:null,dragVisual:{dragging:L===Number(t.id),drop:z&&z.id===Number(t.id)?z.zone:null},showTimes:!0,downs:r,onOpen:e=>p(e.id),ops:(0,I.jsxs)(I.Fragment,{children:[n&&(T||E)&&(0,I.jsx)(e,{items:[{label:`编排依赖…`,onPick:()=>T&&T(t)},{label:t.blocksFollowing?`取消闸门(不再挡后续)`:`设为闸门(挡住后续)`,onPick:()=>E&&E(t)}]}),y&&t.status!==`cancelled`&&!t.childCount&&(t.status===`claimed`||t.status===`done`||t.completedAt)&&(0,I.jsx)(`span`,{className:`op`,role:`button`,tabIndex:-1,title:t.completedAt?`反馈:新开一条任务(原任务不动)`:`反馈修改:回写本任务并记入任务链`,"aria-label":`反馈 ${v(t)}`,onClick:()=>y(t),children:(0,I.jsx)(c,{name:`refresh`,size:12})}),m&&(0,I.jsx)(`span`,{className:`op danger`,role:`button`,tabIndex:-1,title:`删除此任务(软删除,CLI 可恢复)`,"aria-label":`删除 ${v(t)}`,onClick:()=>m(t),children:(0,I.jsx)(c,{name:`x`,size:12})})]})},t.id)})}),$=o>0?(0,I.jsx)(`div`,{className:`mdw-land-pager`,children:(0,I.jsx)(x,{page:l,pageCount:u,total:o,onPage:d,unit:`个任务`})}):null;return(0,I.jsx)(N,{name:ne,counts:[`${o} 个任务`,...s>0?[`待领取 ${s}`]:[]],intro:!t&&r?(0,I.jsx)(A,{kind:`repo`,owner:r,model:i}):null,batch:ce,list:le,footer:$,actions:(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(j,{kind:`dir`,labels:{more:k>0?`更多 (${k})`:`更多`,deleted:k>0?`已删除任务(${k})`:`已删除任务`},titles:{new:`按默认模板新建一页(▾ 选模板)`,import:`把一个 .md 文件导入成任务`,progress:`打开这个目录的进程面板`,more:k>0?`更多操作(含 ${k} 条已删除任务)`:`更多操作`,deleted:`查看并恢复已删除任务`,refs:`查看文档 / reference 列表`},renderers:{new:()=>(0,I.jsx)(`span`,{className:`rp-newtask`,children:(0,I.jsxs)(`button`,{type:`button`,className:`btn small primary`,title:`按默认模板新建一页(▾ 选模板)`,onClick:()=>f(),children:[`+ 新建页`,(0,I.jsx)(`span`,{role:`button`,tabIndex:0,"aria-label":`选择模板新建一页`,"aria-haspopup":`menu`,className:`rp-newtask-caret`,title:`选择模板新建一页`,onClick:e=>{e.stopPropagation(),b?.(e)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),b?.(e))},children:(0,I.jsx)(c,{name:`chevron`,size:11})})]})})},actions:{new:f,import:S,progress:C,orch:ee,deleted:O,refs:te}})})})}var R=(e,t,n)=>O(e=>n.get(e)||[],e,t);function z({task:e,tasks:t,onClose:n,onSave:r}){let i=e=>Number(e.id),o=i(e),s=t.filter(e=>i(e)!==o),[c,l]=(0,F.useState)(!!e.blocksFollowing),[u,d]=(0,F.useState)(()=>new Set((e.blockBy||[]).map(Number))),[f,m]=(0,F.useState)(()=>new Set(s.filter(e=>(e.blockBy||[]).map(Number).includes(o)).map(i))),[h,g]=(0,F.useState)(!1),_=t.findIndex(e=>i(e)===o),v=t.slice(_+1).map(i),y=new Map(t.map(e=>[i(e),i(e)===o?[...u]:(e.blockBy||[]).map(Number)])),b=e=>c||!u.has(i(e))&&R(i(e),o,y),x=e=>!f.has(i(e))&&R(o,i(e),y),S=e=>t=>e(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}),C=()=>l(e=>(e||d(new Set),!e)),w=async()=>{g(!0);try{let e=[{id:o,gate:c,blockBy:[...u]}];if(!c)for(let t of s){let n=i(t),r=f.has(n),a=(t.blockBy||[]).map(Number);r!==a.includes(o)&&e.push({id:n,blockBy:r?[...a,o]:a.filter(e=>e!==o)})}await r(e),n()}catch{}finally{g(!1)}},T=(e,t,n,r)=>{let a=p(e.text)||`#${i(e)}`;return(0,I.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!h?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:t,disabled:h||n,onChange:()=>r(i(e))}),(0,I.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,I.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,I.jsx)(a,{title:`编排 · #${o} ${p(e.text)||``}`,onClose:n,busy:h,size:`md`,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:h,onClick:n,children:`取消`}),(0,I.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:h,onClick:w,children:h?`保存中…`:`保存编排`})]}),children:(0,I.jsxs)(`div`,{className:`mdw-dag`,children:[(0,I.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:c,disabled:h,onChange:C}),(0,I.jsx)(`b`,{children:`闸门`}),(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),c?(0,I.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,v.length,` 个后续任务`,v.length?`:${v.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,I.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,c?(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,I.jsx)(`div`,{className:`mdw-dag-list`+(c?` dim`:``),children:s.length?s.map(e=>T(e,u.has(i(e)),b(e),S(d))):(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,I.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,c?(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,I.jsx)(`div`,{className:`mdw-dag-list`+(c?` dim`:``),children:s.length?s.map(e=>T(e,f.has(i(e)),c||x(e),S(m))):(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}var B=20;function V({dirKey:e}){let{dialog:t,node:n}=r(),a=f()||{},c=o(),l=a.rows||[],p=a.refreshLocal,v=a.tpl,x=a.model,O=a.repoData&&a.repoData.repos||[],A=!e||e===`__GLOBAL__`,[j,M]=(0,F.useState)(null),[re,N]=(0,F.useState)(!1),[R,V]=(0,F.useState)(null),H=(0,F.useRef)(null),U=(0,F.useMemo)(()=>A?l.find(e=>e.isGlobal)||null:l.find(t=>t.key===e)||null,[l,e,A]),W=(0,F.useMemo)(()=>{if(!U||A)return null;let e=U.repo&&U.repo.key;if(e){let t=O.find(t=>t.key===e);if(t)return t}let t=String(U.cwd||``).replace(/\\/g,`/`).toLowerCase();return t&&O.find(e=>String(e.path||``).replace(/\\/g,`/`).toLowerCase()===t)||null},[U,O,A]),G=(0,F.useMemo)(()=>h((U?.tasks||[]).filter(e=>!e.deletedAt&&!g(e))),[U]),K=y(G,B),ie=(0,F.useMemo)(()=>G.filter(e=>e.status===`pending`&&!e.migratedTo).length,[G]),q=e=>e().catch(e=>c(String(e.message||e))),J=()=>A?{key:_}:{cwd:U.cwd},Y=(e,t,n)=>{q(async()=>{await i(`/api/localtasks/reorder`,{method:`PATCH`,body:{...J(),id:e.id,...n===`before`?{beforeId:t}:{afterId:t}}}),p()})},X=e=>{q(async()=>{await i(`/api/localtasks/item`,{method:`PATCH`,body:{...J(),id:e.id,gate:!e.blocksFollowing}}),c(e.blocksFollowing?`#${e.id} 闸门已取消`:`#${e.id} 已设为闸门——挡住所有后续待领取任务`),p()})},ae=async e=>{try{for(let t of e)await i(`/api/localtasks/item`,{method:`PATCH`,body:{...J(),...t}});c(`编排已保存`),p()}catch(e){throw c(String(e.message||e)),e}},oe=(0,F.useMemo)(()=>{let e={},t=G.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt);return t.forEach((n,r)=>{n.blocksFollowing&&(e[n.id]=t.slice(r+1).map(e=>e.id))}),e},[G]),se=(0,F.useMemo)(()=>G.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),[G]),Z=t=>{a.openPage&&a.openPage({dirKey:e,task:String(t),name:`#${t}`})},Q=t=>{let n=D();T(E(C(e),n),{title:``,body:t}),a.openPage&&a.openPage({dirKey:e,task:n,name:`新任务`})},ce=()=>{x&&b(x)},le=()=>{x&&u(x,{component:`progress`,name:`进程`,config:{dirKey:e||`__GLOBAL__`},location:`right`})},$=A?_:e,ue=ee($).templates||v&&v.templates||[],de=()=>{if(!x){c(`工作区未就绪`);return}w(x,{mode:`new`,topic:$,scope:A?[]:[`topic:${$}`],name:``})},fe=[...ue.length?ue.map(e=>({label:(e.id===v?.defaultId?`✓ `:``)+e.name,icon:`list`,onClick:()=>Q(S(e.body,{...m,...e.values||{}}))})):[{label:`按默认模板新建一页`,icon:`list`,onClick:()=>Q(v?v.defaultBody():``)}],`sep`,{label:`为本${A?`全局池`:`目录`}新建模板…`,icon:`plus`,onClick:de},{label:`管理模板…`,icon:`gear`,onClick:ce}],pe=async e=>{if(e==null)return null;let t=A?`key=${encodeURIComponent(_)}&id=${Number(e.id)}`:`cwd=${encodeURIComponent(U?.cwd||``)}&id=${Number(e.id)}`;return i(`/api/localtasks/item?${t}`).catch(()=>null)},me=n=>{if(!n)return;let r=(n.text||``).split(`
|
|
2
2
|
`).find(e=>e.trim())||`#${n.id}`;q(async()=>{let a=!!n.completedAt,o=await t({title:a?`反馈 · #${n.id}`:`反馈修改 · #${n.id}`,input:!0,placeholder:a?`写下反馈(将新开一条任务,原任务不动)`:`写下要改的地方(留空 = 只重开,不改正文)`});if(o==null)return;let s=String(o).trim(),l=await pe(n),u=String(l?.text??``).trim()||String(n.text||``).trim(),d=a&&(l?.roundSummary||n.roundSummary)||``;if(!s&&!a&&!u){c(`拿不到任务当前正文,已取消(防止丢内容)`);return}if(a){let t=s?ne({base:u,feedback:s,ackSummary:d,feedbackHeading:te,bold:!0}):``;if(!t){c(`写一下反馈`);return}let a=await i(`/api/localtasks`,{method:`POST`,body:A?{global:!0,text:t,forkOf:String(n.id),forkKind:`reopen`}:{cwd:U.cwd,text:t,forkOf:String(n.id),forkKind:`reopen`}}),o=String(a?.task?.id??a?.id??``),l=a?.key||e;o&&T(E(C(l),o),{body:t}),c(`已反馈「${r.replace(/^#\s*/,``)}」→ 新任务 #${o||`?`}`),p();return}let f=await i(`/api/localtasks/reopen`,{method:`POST`,body:{...J(),id:n.id,kind:`reopen`,...s?{feedback:s,feedbackHeading:k,feedbackBold:!1}:{}}}),m=f?.key||e,h=String(f?.task?.id??n.id),g=String(f?.task?.text??``);g&&T(E(C(m),h),{body:g}),c(`已回写「${r.replace(/^#\s*/,``)}」#${h}`+(f?.moved&&f.name?`;归属迁到「${f.name}」`:``)),p()})},he=async n=>{if(!n)return;let r=(n.text||``).split(`
|
|
3
3
|
`).find(e=>e.trim())||`#${n.id}`;await t({title:`删除任务「${r.replace(/^#\s*/,``)}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&q(async()=>{if(await i(`/api/localtasks/item`,{method:`DELETE`,body:A?{key:_,id:n.id}:{cwd:U.cwd,id:n.id}}),c(`已删除「${r.replace(/^#\s*/,``)}」`),x){let t=d(x,`page`,{dirKey:e,task:String(n.id)});t&&a.closePanel&&a.closePanel(t.getId())}p()})},ge=async e=>{let n=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!n.length||!await t({title:`删除选中的 ${n.length} 条任务`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})?!1:q(async()=>{let e=await i(`/api/localtasks/items`,{method:`DELETE`,body:{...J(),ids:n}});return c(`已删除 ${e?.count??n.length} 条任务`),p(),!0})},_e=async e=>{let n=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!n.length||!await t({title:`取消选中的 ${n.length} 条待领取任务`,message:`只处理待领取任务;已领取/已交付/已取消会跳过。取消为终态,原文留档。`,okText:`取消任务`})?!1:q(async()=>{let e=await i(`/api/localtasks/items/cancel`,{method:`POST`,body:{...J(),ids:n}}),t=e?.skipped?.length||0;return c(`已取消 ${e?.count??0} 条任务${t?`,跳过 ${t} 条`:``}`),p(),!0})},ve=async e=>{let n=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!n.length||!await t({title:`把选中的 ${n.length} 条待领取任务标为完成`,message:`只处理待领取任务;已领取/已交付/已取消会跳过。完成会补一条完成记录,原文留档。`,okText:`标为完成`})?!1:q(async()=>{let e=await i(`/api/localtasks/items/close`,{method:`POST`,body:{...J(),ids:n,status:`done`}}),t=e?.skipped?.length||0;return c(`已标为完成 ${e?.count??0} 条任务${t?`,跳过 ${t} 条`:``}`),p(),!0})},ye=(0,F.useMemo)(()=>(U?.tasks||[]).filter(e=>e.deletedAt).slice().reverse(),[U]),be=e=>{e&&q(async()=>{await i(`/api/localtasks/tasks/restore`,{method:`POST`,body:A?{key:_,id:e.id}:{cwd:U.cwd,id:e.id}}),c(`已恢复 #${e.id}「${(e.text||``).split(`
|
|
4
4
|
`).find(e=>e.trim())?.replace(/^#\s*/,``)||``}」`),p()})},xe=async e=>{if(!e)return;let n=(e.text||``).split(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{g as e,h as t,l as n,m as r,p as i,u as a,y as o}from"./task-status-BnymQMTw.js";import{r as s,w as c}from"./workspace-C_5X2gIr.js";import{n as l}from"./app-context-D7HAx67n.js";import{r as ee,t as u}from"./frontmatter-QvrjUNzF.js";import{n as te}from"./md-parse-awNLHAzO.js";import{_ as d,g as f,i as p,m,n as ne,o as re,p as ie,r as ae,s as oe,u as se}from"./index-
|
|
1
|
+
import{g as e,h as t,l as n,m as r,p as i,u as a,y as o}from"./task-status-BnymQMTw.js";import{r as s,w as c}from"./workspace-C_5X2gIr.js";import{n as l}from"./app-context-D7HAx67n.js";import{r as ee,t as u}from"./frontmatter-QvrjUNzF.js";import{n as te}from"./md-parse-awNLHAzO.js";import{_ as d,g as f,i as p,m,n as ne,o as re,p as ie,r as ae,s as oe,u as se}from"./index-Dq7eNqAB.js";import{t as ce}from"./route-crumb-_IyS9fTT.js";import{t as h}from"./Introduction-CDSLSy0q.js";import{t as le}from"./bar-Dp9JHQEk.js";import{i as ue,n as de,r as fe,t as g}from"./deleted-panel-QHsQZ5Ez.js";import{t as _}from"./member-picker-BAgkj36N.js";var v=o(e(),1),y=c(),b=t(),x=20;function S({dirKey:e,rows:t,repoData:o,model:c}){let S=i(),{dialog:pe,node:me}=n(),C=l()||{},w=ne(),T=o&&o.boards||[],E=o&&o.repos||[],D=t||[],[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(!1),[M,N]=(0,v.useState)(!1),[P,F]=(0,v.useState)(null),I=(0,v.useRef)(null),L=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!M)return;let e=e=>{I.current?.contains(e.target)||L.current?.contains(e.target)||N(!1)},t=e=>{e.key===`Escape`&&N(!1)},n=()=>{let e=I.current?.querySelector(`button`);if(!e)return;let t=e.getBoundingClientRect(),n=L.current?.offsetHeight||240,r=window.innerHeight-t.bottom-6,i=r>=n||r>=t.top?t.bottom+6:Math.max(8,t.top-6-n);F({top:i,right:Math.max(8,window.innerWidth-t.right)})};n();let r=requestAnimationFrame(n);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),window.addEventListener(`resize`,n),window.addEventListener(`scroll`,n,!0),()=>{cancelAnimationFrame(r),document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),window.removeEventListener(`resize`,n),window.removeEventListener(`scroll`,n,!0)}},[M]);let R=(0,v.useMemo)(()=>T.find(t=>t.id===e)||T.find(t=>t.key===e)||null,[T,e]),z=(0,v.useMemo)(()=>{if(!R)return[];let e=new Map(E.map(e=>[e.key,e])),t=new Map;for(let e of D)!e.isGlobal&&e.repo&&e.repo.key&&(t.has(e.repo.key)||t.set(e.repo.key,e));return(R.repos||[]).map(n=>{let r=e.get(n.key)||null,i=t.get(n.key)||null;return{key:n.key,name:n.name||r&&r.name||n.key,path:n.path||r&&r.path||``,cwd:i&&i.cwd||n.path||r&&r.path||``,desc:n.note||r&&r.desc||``,pending:i&&i.pending||0,waiting:!!(i&&i.waiting),topicKey:i?i.key:``,summary:i&&i.summary||``,tasks:i&&i.tasks||[],present:n.present!==!1,noteDocId:n.noteDocPath?`path:`+n.noteDocPath:`rel:`+n.noteDocRel}})},[R,E,D]);if(!R)return(0,b.jsxs)(`div`,{className:`rp-page`,children:[(0,b.jsx)(ce,{}),(0,b.jsx)(`div`,{className:`rp-empty`,children:`项目组不存在(看板可能被删了)`})]});let B=z.reduce((e,t)=>e+t.pending,0),he=(0,v.useMemo)(()=>{let e=new Map;for(let t of D){if(!t.key||t.isGlobal)continue;let n=(t.tasks||[]).filter(e=>e&&!e.deletedAt&&!e.migratedTo&&e.status===`pending`),r={};n.forEach((e,t)=>{e.blocksFollowing&&(r[e.id]=n.slice(t+1).map(e=>e.id))}),e.set(t.key,{tasks:n,downstream:r})}return e},[D]),V=z.find(e=>e.pending>0)||z[0]||null,H=(0,v.useMemo)(()=>{let e=R?[R.id,R.key,R.name].filter(Boolean):[],t=[],n=[];for(let r of z)for(let i of r.tasks||[]){if(i.deletedAt)continue;let a=u(i.text);a.board&&e.includes(a.board)&&(i.status===`pending`?t:n).push({member:r,task:i,project:a.project||``})}return n.sort((e,t)=>String(t.task.consumedAt||``).localeCompare(String(e.task.consumedAt||``))),[...t,...n]},[R,z]),U=(0,v.useMemo)(()=>{let e=R?[R.id,R.key,R.name].filter(Boolean):[],t=[];for(let n of z)for(let r of n.tasks||[]){if(!r.deletedAt)continue;let i=u(r.text);i.board&&e.includes(i.board)&&t.push({...r,memberName:n.name,memberCwd:n.cwd})}return t.reverse()},[R,z]),ge=async e=>{if(e)try{await r(`/api/localtasks/tasks/restore`,{method:`POST`,body:{cwd:e.memberCwd,id:e.id}}),S(`已恢复 #${e.id}`),C.refreshLocal&&await C.refreshLocal()}catch(e){S(`恢复失败:${e&&e.message||e}`)}},_e=async e=>{if(!e)return;let t=(e.text||``).split(`
|
|
2
2
|
`).find(e=>e.trim())||`#${e.id}`;if(await pe({title:`彻底删除「${t.replace(/^#\s*/,``)}」`,message:`彻底删除后不可恢复(行从队列里真正摘除)。`,danger:!0,okText:`彻底删除`}))try{await r(`/api/localtasks/item`,{method:`DELETE`,body:{cwd:e.memberCwd,id:e.id,purge:!0}}),S(`已彻底删除 #${e.id}`),C.refreshLocal&&await C.refreshLocal()}catch(e){S(`删除失败:${e&&e.message||e}`)}},ve=(0,v.useMemo)(()=>H.filter(e=>e.task.status===`pending`).length,[H]),W=d(H,x),G=(0,v.useRef)(null),[ye,K]=(0,v.useState)(null),[q,J]=(0,v.useState)(null),Y=(e,t)=>e.key+`:`+t.id,X=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},Z=(e,t,n)=>{G.current={id:Number(n.id),topicKey:t.topicKey,cwd:t.cwd||t.path||``,row:Y(t,n)},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+n.id),K(Y(t,n))},be=(e,t,n)=>{let r=G.current;r&&r.row!==Y(t,n)&&(e.preventDefault(),e.dataTransfer.dropEffect=r.topicKey===t.topicKey?`move`:`none`,J({key:Y(t,n),zone:X(e,e.currentTarget)}))},xe=e=>{e.currentTarget.contains(e.relatedTarget)||J(null)},Se=async(e,t,n)=>{e.preventDefault();let i=X(e,e.currentTarget),a=G.current;if(G.current=null,K(null),J(null),!a||a.row===Y(t,n))return;if(a.topicKey!==t.topicKey){S(`只能在同一项目队列内排序(跨项目请用编排连线)`);return}let o=t.cwd||t.path;if(!t.topicKey||!o){S(`该成员还没有本地队列,无法排序`);return}try{await r(`/api/localtasks/reorder`,{method:`PATCH`,body:{cwd:o,id:a.id,...i===`before`?{beforeId:Number(n.id)}:{afterId:Number(n.id)}}}),C.refreshLocal&&await C.refreshLocal()}catch(e){S(String(e.message||e))}},Ce=()=>{G.current=null,K(null),J(null)},Q=e=>{if(!R)return;if(!V)return S(`这个组还没有成员——先「添加成员」,再建任务`);let t=se(),n=oe(m(R.id),t);ie(n,{title:``,body:ee(e||w.defaultBody(),{board:R.id,project:V.key})}),C.openPage?.({groupId:R.id,task:t,name:`新任务`})},$=ae({topic:V?V.topicKey:``,group:R?R.key:``,repo:V?V.key:``}).templates||w.templates||[],we=()=>{R&&c&&re(c,{mode:`new`,scope:[`group:${R.key}`],name:``})},Te=(0,b.jsx)(h,{kind:`board`,owner:R,model:c}),Ee=(0,b.jsx)(ue,{title:`本组任务`,pendingCount:ve,emptyText:`本组还没有任务——点「+ 新增任务」创建;只有在本组创建的任务(携带本组语义)才会出现在这里。`,children:W.items.map(({member:e,task:t})=>{let n=t.status===`pending`,r=he.get(e.topicKey),i=r&&r.downstream[t.id]||[],a=Y(e,t);return(0,b.jsx)(de,{t,projectTag:e.name,history:!n,draggable:n&&!!e.topicKey,dragHandlers:n&&e.topicKey?{onDragStart:n=>Z(n,e,t),onDragOver:n=>be(n,e,t),onDragLeave:xe,onDrop:n=>Se(n,e,t),onDragEnd:Ce}:null,dragVisual:{dragging:ye===a,drop:q&&q.key===a?q.zone:null},downs:i,onOpen:()=>C.openPage&&C.openPage({groupId:R.id,task:String(t.id),name:`#${t.id}`})},a)})}),De=(0,b.jsx)(`div`,{className:`mdw-land-pager`,children:(0,b.jsx)(f,{page:W.page,pageCount:W.pageCount,total:W.total,onPage:W.setPage,unit:`个任务`})});return(0,b.jsxs)(fe,{name:R.name,counts:[`${z.length} 个目录`,...B>0?[`待领取 ${B}`]:[]],intro:Te,list:Ee,footer:De,actions:(0,b.jsx)(b.Fragment,{children:(0,b.jsx)(le,{kind:`group`,titles:{progress:`打开本组的任务进程面板`,addMember:`挑项目加进这个组`,orch:`打开可视化编排面板`,deleted:`查看本组已删除的任务(可恢复)`,refs:`查看文档 / reference 列表`},labels:{more:U.length?`更多 (${U.length})`:`更多`,deleted:U.length?`已删除任务(${U.length})`:`已删除任务`},disabled:{new:!V},renderers:{new:()=>(0,b.jsxs)(`div`,{className:`rp-newtask`,ref:I,children:[(0,b.jsxs)(`button`,{type:`button`,className:`btn small`+(M?` is-open`:``),title:`按默认模板新建任务(▾ 选模板;携带本组语义)`,disabled:!V,onClick:()=>Q(``),children:[`+ 新增任务`,(0,b.jsx)(`span`,{role:`button`,tabIndex:V?0:void 0,"aria-label":`选择模板新建任务`,"aria-haspopup":`menu`,"aria-expanded":M,className:`rp-newtask-caret`+(M?` rot`:``),title:`选择模板新建任务`,onClick:e=>{e.stopPropagation();let t=(e.currentTarget.closest(`.rp-newtask`)||e.currentTarget).getBoundingClientRect();F({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)}),N(e=>!e)},onKeyDown:e=>{if(e.key===`Enter`||e.key===` `){e.preventDefault(),e.stopPropagation();let t=(e.currentTarget.closest(`.rp-newtask`)||e.currentTarget).getBoundingClientRect();F({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)}),N(e=>!e)}},children:(0,b.jsx)(a,{name:`chevron`,size:11})})]}),M&&V&&P&&(0,y.createPortal)((0,b.jsxs)(`div`,{ref:L,className:`rp-tpl-fly rp-tpl-fly-portal`,role:`menu`,"aria-label":`选择模板新建任务`,style:{top:P.top,right:P.right},children:[(0,b.jsxs)(`div`,{className:`rp-tpl-fly-h`,children:[R.name,` · 可用模板`]}),(0,b.jsx)(`div`,{className:`rp-tpl-fly-list`,children:($.length?$:[{id:`__fallback__`,name:`按默认模板新建`,fallback:!0}]).map(e=>(0,b.jsx)(`button`,{type:`button`,className:`rp-tpl-fly-it`,role:`menuitem`,onClick:()=>{N(!1),Q(e.fallback?``:p(e.body,{...te,...e.values||{}}))},children:(e.id===w.defaultId&&!e.fallback?`✓ `:``)+e.name},e.id))}),(0,b.jsx)(`div`,{className:`rp-tpl-fly-foot`,children:(0,b.jsx)(`button`,{type:`button`,className:`rp-tpl-fly-new`,onClick:()=>{N(!1),we()},children:`+ 新增模板…`})})]}),document.body)]})},actions:{progress:()=>{c&&s(c,{component:`progress`,name:`进程`,config:{groupKey:e},location:`right`})},addMember:()=>k(!0),orch:()=>{c&&s(c,{component:`dag`,name:`编排`,config:{dirKey:V&&V.topicKey||``,groupId:R&&R.id}})},refs:()=>{c&&R&&s(c,{component:`refs`,name:`文档列表`,config:{boardKey:e,boardName:R.name},location:`right`})},deleted:()=>j(!0)}})}),children:[me,O&&R?(0,b.jsx)(_,{board:R,boards:T,repos:E,onClose:()=>k(!1),onChanged:()=>C.refreshRepos&&C.refreshRepos()}):null,A&&(0,b.jsx)(g,{tasks:U,onClose:()=>j(!1),onRestore:ge,onPurge:_e})]})}export{S as default};
|