lantern-harness 0.1.24 → 0.1.26
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 +44 -0
- package/dist/500.html +4 -4
- package/dist/_astro/Base.Bilfw8As.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.DHRjA0au.js → Base.astro_astro_type_script_index_0_lang._n0VHShs.js} +1 -1
- package/dist/_astro/{CaseExecBoard.Xd7KUpkU.js → CaseExecBoard.cl2Od7av.js} +1 -1
- package/dist/_astro/{CaseGenerateApp.BgIi4YGn.js → CaseGenerateApp.nE3RR7bV.js} +5 -5
- package/dist/_astro/CasesLibrary.BkQY421S.js +21 -0
- package/dist/_astro/ChatApp.C_nGSCqd.js +226 -0
- package/dist/_astro/{DashboardBoard.CmxqpmzI.js → DashboardBoard.g_53rLV5.js} +2 -2
- package/dist/_astro/{DocsFileBrowser.Diq5zuSt.js → DocsFileBrowser.BdpWp8zQ.js} +1 -1
- package/dist/_astro/DocsPager.D55FTK9d.js +1 -0
- package/dist/_astro/{KnowledgeLibrary.CYutSepl.js → KnowledgeLibrary.DKci9jN8.js} +1 -1
- package/dist/_astro/NamePromptDialog.Csfnh5eM.js +1 -0
- package/dist/_astro/{PluginsPage.CgcXB7Ap.js → PluginsPage.Crrq4Ibd.js} +2 -2
- package/dist/_astro/PluginsPage.DzI3Xfa3.js +1 -0
- package/dist/_astro/PmBugsBoard.DVhrHxD2.js +1 -0
- package/dist/_astro/PmIterationsBoard.BQPHdbpp.js +1 -0
- package/dist/_astro/{PmProjectDetail.5tybGC46.js → PmProjectDetail.DZmqbZLO.js} +1 -1
- package/dist/_astro/PmProjectsBoard.tk8cI-lO.js +1 -0
- package/dist/_astro/PmRequirementsBoard.BjC9CEFr.js +1 -0
- package/dist/_astro/PmRequirementsBoard.CtuavIey.js +1 -0
- package/dist/_astro/{PmShared.Bzn6AGsN.js → PmShared.DRYCFoRc.js} +1 -1
- package/dist/_astro/{PromptsLibrary.DydrgeIw.js → PromptsLibrary.uvoZTwhi.js} +1 -1
- package/dist/_astro/{ReportsPage.BRVCnzL-.js → ReportsPage.B7MOskzc.js} +1 -1
- package/dist/_astro/{ReqAnalysisBoard.BCq_OoRo.js → ReqAnalysisBoard.Bz2de2Vj.js} +8 -8
- package/dist/_astro/{RequirementsLibrary.DtbFESBh.js → RequirementsLibrary._OviMClB.js} +1 -1
- package/dist/_astro/{SettingsDialog.DtEJLxtx.js → SettingsDialog.CC5S6knQ.js} +1 -1
- package/dist/_astro/SlideOverDrawer.C1IVOc_8.js +1 -0
- package/dist/_astro/{SpaceSwitcher.Cdveup1T.js → SpaceSwitcher.DQOG363O.js} +1 -1
- package/dist/_astro/TasksBoard.Uj4XWtWz.js +1 -0
- package/dist/_astro/{TemplatesLibrary.Bg-MFL57.js → TemplatesLibrary.CEVQPDDz.js} +1 -1
- package/dist/_astro/{TestStatsBoard.eiMbNGpn.js → TestStatsBoard.CO4JMh4N.js} +1 -1
- package/dist/_astro/TodosBoard.BkszTn-p.js +1 -0
- package/dist/_astro/UiAutoBoard.DegcBc_3.js +9 -0
- package/dist/_astro/app-version.D-te3dRV.js +1 -0
- package/dist/_astro/case-gen-run.Byxy6M5X.js +22 -0
- package/dist/_astro/{case-review.D1E3ldss.js → case-review.DlCarphW.js} +1 -1
- package/dist/_astro/{llm.BuR7z55C.js → llm.DyweO-KK.js} +1 -1
- package/dist/_astro/{pm.pMOkNqqK.js → pm.BXmOiFfW.js} +1 -1
- package/dist/_astro/{story-review.BRcUdixS.js → story-review.B5I45C1T.js} +1 -1
- package/dist/_astro/tasks.jfnSAEmg.js +1 -0
- package/dist/case-exec/index.html +5 -5
- package/dist/cases/generate/index.html +5 -5
- package/dist/cases/library/index.html +5 -5
- package/dist/dashboard/index.html +5 -5
- package/dist/docs/changelog/index.html +45 -5
- package/dist/docs/install/index.html +4 -4
- package/dist/docs/manual/index.html +12 -12
- package/dist/knowledge/index.html +5 -5
- package/dist/plugins/index.html +5 -5
- package/dist/pm/bugs/index.html +5 -5
- package/dist/pm/iterations/index.html +5 -5
- package/dist/pm/projects/detail/index.html +5 -5
- package/dist/pm/projects/index.html +5 -5
- package/dist/pm/requirements/index.html +5 -5
- package/dist/prompts/index.html +5 -5
- package/dist/reports/index.html +5 -5
- package/dist/requirement-analysis/index.html +5 -5
- package/dist/requirements/index.html +5 -5
- package/dist/tasks/index.html +5 -5
- package/dist/templates/index.html +5 -5
- package/dist/test-automation/index.html +5 -5
- package/dist/test-stats/index.html +5 -5
- package/dist/todos/index.html +5 -5
- package/dist/workbench/index.html +5 -5
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +8 -8
- package/lh-plugins/lh-case-review.mjs +115 -34
- package/lh-plugins/lh-pm.mjs +6 -2
- package/lh-plugins/lh-todos.mjs +59 -18
- package/package.json +1 -1
- package/dist/_astro/Base.nGl8De0W.css +0 -1
- package/dist/_astro/CasesLibrary.B2VCAoTt.js +0 -21
- package/dist/_astro/ChatApp.CeSatNSf.js +0 -220
- package/dist/_astro/DocsPager.WMztSW4O.js +0 -1
- package/dist/_astro/NamePromptDialog.5XFIvdqv.js +0 -1
- package/dist/_astro/PluginsPage.pgN80K8r.js +0 -1
- package/dist/_astro/PmBugsBoard.Ceyt3pp6.js +0 -1
- package/dist/_astro/PmIterationsBoard.Dwsntvw6.js +0 -1
- package/dist/_astro/PmProjectsBoard.X2LZfFff.js +0 -1
- package/dist/_astro/PmRequirementsBoard.CXaGeFl9.js +0 -1
- package/dist/_astro/PmRequirementsBoard.CYbicBqS.js +0 -1
- package/dist/_astro/SlideOverDrawer.DMWJPD_W.js +0 -1
- package/dist/_astro/TasksBoard.rwdPWLAh.js +0 -1
- package/dist/_astro/TodosBoard.CrZMl6Ei.js +0 -1
- package/dist/_astro/UiAutoBoard.CLi9vmuE.js +0 -9
- package/dist/_astro/app-version.XPYyWuno.js +0 -1
- package/dist/_astro/case-gen-run.BbI2iGo9.js +0 -21
- package/dist/_astro/tasks.BNBkrFC3.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{p as n}from"./app-config.DAIyT--R.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./SelectDropdown.apWlFGbA.js";var a=e(t(),1),o=[5,10,20,50],s=`tw.docs.page-size.v1`;function c(e){return typeof e==`number`&&o.includes(e)}function l(e,t=s){try{let r=localStorage.getItem(n(t)),i=r===null?NaN:Number(r);return c(i)?i:e}catch{return e}}function u(e,t=s){if(c(e))try{localStorage.setItem(n(t),String(e))}catch{}}var d=r(),f=`h-8 px-3 shrink-0 whitespace-nowrap text-sm text-stone-600 border border-stone-200 rounded-lg hover:bg-stone-50 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer`,p=o.map(e=>({value:String(e),label:String(e)}));function m(e,t){let[n,r]=(0,a.useState)(()=>l(e,t));return[n,(0,a.useCallback)(e=>{c(e)&&(u(e,t),r(e))},[t])]}function h({page:e,totalPages:t,pageSize:n,busy:r=!1,onPage:a,onPageSize:o}){return(0,d.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-t border-stone-100 flex items-center justify-between gap-2 flex-wrap`,children:[(0,d.jsxs)(`span`,{className:`text-xs text-stone-500 flex items-center gap-1.5`,children:[(0,d.jsxs)(`span`,{children:[`第 `,e,` / `,t,` 页 ·`]}),(0,d.jsx)(i,{compact:!0,centerContent:!0,options:p,value:String(n),onChange:e=>o(Number(e)),disabled:r,ariaLabel:`每页条数`,showCheck:!1,className:`w-18`}),(0,d.jsx)(`span`,{children:`条`})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,d.jsx)(`button`,{type:`button`,disabled:r||e<=1,onClick:()=>a(1),className:f,children:`首页`}),(0,d.jsx)(`button`,{type:`button`,disabled:r||e<=1,onClick:()=>a(e-1),className:f,children:`上一页`}),(0,d.jsx)(`button`,{type:`button`,disabled:r||e>=t,onClick:()=>a(e+1),className:f,children:`下一页`}),(0,d.jsx)(`button`,{type:`button`,disabled:r||e>=t,onClick:()=>a(t),className:f,children:`末页`})]})]})}export{m as n,h as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,n as r,r as i,t as a}from"./dialog.DZHZCe_T.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";var s=e(t(),1),c=o();function l({open:e,title:t=`新建文件夹`,label:o=`文件夹名称`,placeholder:l=`请输入名称`,initialValue:u=``,lockExtension:d=!1,confirmLabel:f=`创建`,cancelLabel:p=`取消`,error:m=``,onClose:h,onConfirm:g}){let[_,v]=(0,s.useState)(``),[y,b]=(0,s.useState)(``),x=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(e){let e=u,t=``;if(d){let n=u.lastIndexOf(`.`);n>0&&(e=u.slice(0,n),t=u.slice(n))}v(e),b(t);let n=window.setTimeout(()=>{x.current?.focus(),x.current?.select()},50);return()=>window.clearTimeout(n)}},[e,u,d]);function S(){let e=_.trim();e&&g(e+y)}return(0,c.jsxs)(i,{open:e,onClose:h,className:`relative z-50`,children:[(0,c.jsx)(a,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,c.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,c.jsxs)(n,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,c.jsx)(r,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:t}),(0,c.jsxs)(`label`,{className:`tw-confirm-msg mt-4 block text-xs font-medium text-stone-500`,children:[o,(0,c.jsxs)(`span`,{className:`mt-1.5 flex items-center gap-0 rounded-lg border border-stone-200 focus-within:ring-2 focus-within:ring-[#4176e6]/30 focus-within:border-[#4176e6] transition-colors`,children:[(0,c.jsx)(`input`,{ref:x,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S())},placeholder:l,className:`flex-1 min-w-0 h-9 px-3 text-sm rounded-lg border-0 bg-transparent text-stone-800 outline-none`}),y?(0,c.jsx)(`span`,{className:`shrink-0 pr-3 text-sm text-stone-400 select-none`,children:y}):null]}),m?(0,c.jsx)(`span`,{className:`mt-1.5 block text-[11px] font-normal leading-relaxed text-red-600`,children:m}):null]}),(0,c.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,c.jsx)(`button`,{type:`button`,onClick:h,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg text-stone-600 hover:bg-stone-100 transition-colors`,children:p}),(0,c.jsx)(`button`,{type:`button`,disabled:!_.trim(),onClick:S,className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:f})]})]})})]})}export{l as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{t as default}from"./PluginsPage.CgcXB7Ap.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.Di6uuouN.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.D5qXeML0.js";import{c as te,d as ne,i as re,l as ie,n as ae,o as oe,r as se,s as ce,t as i}from"./ColumnResize.BgYkV9Iy.js";import{n as le,t as ue}from"./DocsPager.WMztSW4O.js";import{t as a}from"./SelectDropdown.apWlFGbA.js";import{showToast as o}from"./Toast.BO2NFckG.js";import{A as s,L as c,M as de,N as fe,R as pe,b as me,g as he,h as ge,i as _e,k as l,m as ve,n as ye,p as be,r as u,t as d}from"./pm.pMOkNqqK.js";import{A as xe,C as Se,D as Ce,E as we,O as f,S as p,_ as m,a as h,c as Te,d as Ee,f as g,g as De,h as Oe,k as ke,l as Ae,m as _,n as je,p as Me,s as v,t as Ne,u as Pe,y}from"./PmShared.Bzn6AGsN.js";var b=e(t(),1),x=r(),Fe=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`severity`,width:100,min:80},{key:`status`,width:120,min:96}],Ie={key:`project`,width:140,min:100},S=[{key:`iteration`,width:120,min:88},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],Le=20,Re=`tw.pm-bugs.page-size.v1`,ze=[`all`,...u],Be=[`all`,...d],Ve=`pm.bugs.project`,He=`pm.bugs.iteration`,Ue=`pm.bugs.status`,We=`pm.bugs.severity`,Ge=`pm.bugs.keyword`,Ke=d.map(e=>({value:e,label:ye[e]})),qe=u.map(e=>({value:e,label:_e[e]}));function Je(e=``){return{projectId:e,iterationId:``,requirementId:``,title:``,severity:`minor`,status:`pending`,reproduceSteps:``,expectedResult:``,actualResult:``,environment:``,githubIssue:``,attachment:``,remark:``}}function Ye(e){try{let t=new URL(e,`http://localhost`).searchParams.get(`p`)??``;return/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(t)}catch{return!1}}function C({scopeProjectId:e=``}={}){let t=!!e,r=ke(`bugs`),{store:u,live:d,loading:C,error:Xe,setError:w,reload:T}=xe(),[E,D]=f(Ve,`all`),O=e||E,[k,A]=f(He,`all`),[j,Ze]=Ce(Ue,ze,`all`),[M,Qe]=Ce(We,Be,`all`),[N,$e]=f(Ge),[et,P]=(0,b.useState)(1),[F,tt]=le(Le,Re),[I,L]=(0,b.useState)(null),[R,z]=(0,b.useState)(!1),[B,V]=(0,b.useState)(!1),H=(0,b.useRef)(null),U=(0,b.useRef)(new Set),[W,G]=(0,b.useState)(null),[nt,K]=(0,b.useState)(null),q=(0,b.useMemo)(()=>s(I?.attachment??``),[I?.attachment]),J=(0,b.useMemo)(()=>t?[...Fe,...S]:[...Fe,Ie,...S],[t]),Y=ie(t?`pm.bugs.cols.scoped.v1`:`pm.bugs.cols.v1`,J),rt=ne(t?`pm.bugs.scroll.scoped`:`pm.bugs.scroll`),it=Y.widthOf(`id`)??88;(0,b.useEffect)(()=>{for(let e of q)U.current.add(e.url)},[q]);let at=(0,b.useMemo)(()=>[{value:`all`,label:`全部项目`},...u.projects.map(e=>({value:e.id,label:e.name}))],[u.projects]),ot=(0,b.useMemo)(()=>[{value:`all`,label:`全部迭代`},...u.iterations.filter(e=>O===`all`||e.projectId===O).map(e=>({value:e.id,label:e.name}))],[u.iterations,O]),st=(0,b.useMemo)(()=>{let e=new Map(u.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[u.projects]),ct=(0,b.useMemo)(()=>{let e=new Map(u.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[u.iterations]),X=(0,b.useMemo)(()=>de(me(u.bugs,{projectId:O,iterationId:k,status:j,severity:M,keyword:N})),[u.bugs,O,k,j,M,N]),Z=t?u.bugs.filter(e=>e.projectId===O).length:u.bugs.length,lt=Math.max(1,Math.ceil(X.length/F)),Q=Math.min(et,lt),ut=X.slice((Q-1)*F,Q*F);(0,b.useEffect)(()=>{t||d===!0&&E!==`all`&&!u.projects.some(e=>e.id===E)&&D(`all`)},[d,u.projects,E,D,t]),(0,b.useEffect)(()=>{d===!0&&k!==`all`&&!u.iterations.some(e=>e.id===k&&(O===`all`||e.projectId===O))&&A(`all`)},[d,u.iterations,O,k,A]);let dt=I?fe(u.iterations.filter(e=>e.projectId===I.projectId)):[],ft=I?u.requirements.filter(e=>e.projectId===I.projectId):[];async function pt(){if(!I)return;if(!I.projectId){w(`请先选择所属项目`);return}let e=I.reproduceSteps.trim();if(!e){w(`缺陷描述不能为空`);return}let t=be(e);z(!0);try{let n={projectId:I.projectId,iterationId:I.iterationId,requirementId:I.requirementId,title:t,severity:I.severity,status:I.status,reproduceSteps:e,expectedResult:I.expectedResult,actualResult:I.actualResult,environment:I.environment,githubIssue:I.githubIssue,attachment:I.attachment,remark:I.remark};I.id?await c(`bugs`,I.id,n):await ge(`bugs`,[n]);let r=!!I.id;L(null),U.current.clear(),w(``),await T(!0),o(r?`已保存缺陷`:`已新建缺陷`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);w(t),o(`保存缺陷失败:${t}`,`error`)}finally{z(!1)}}let $=(0,b.useCallback)(async e=>{if(e&&e.length){V(!0);try{let t=await pe(Array.from(e));L(e=>{if(!e)return e;let n=s(e.attachment);return{...e,attachment:l([...n,...t])}}),w(``)}catch(e){w(e instanceof Error?e.message:String(e))}finally{V(!1),H.current&&(H.current.value=``)}}},[w]),mt=I!==null;(0,b.useEffect)(()=>{if(!mt)return;let e=e=>{let t=Array.from(e.clipboardData?.files??[]);t.length&&(e.preventDefault(),$(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[mt,$]);async function ht(e){if(!I)return;let t=l(q.filter(t=>t.url!==e));if(I.id)try{await c(`bugs`,I.id,{attachment:t}),await T(!0)}catch(e){w(e instanceof Error?e.message:String(e));return}L(e=>e&&{...e,attachment:t}),ve([e],I.id??``)}function gt(){let e=[...U.current,...q.map(e=>e.url)];U.current.clear(),L(null),e.length&&ve(e)}async function _t(e,t){z(!0);try{await c(`bugs`,e.id,{status:t}),await T(!0)}catch(e){w(e instanceof Error?e.message:String(e))}finally{z(!1)}}async function vt(){let e=W;if(e){G(null),z(!0);try{await he(`bugs`,[e.id]),await T(!0),o(`已删除缺陷`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);w(t),o(`删除缺陷失败:${t}`,`error`)}finally{z(!1)}}}if(!r.ready)return(0,x.jsx)(De,{label:`正在读取插件开关`});if(!r.on)return(0,x.jsx)(m,{children:n(`bugs`)});if(d===null)return(0,x.jsx)(De,{label:`正在连接项目管理服务`});if(!d)return(0,x.jsx)(m,{children:`缺陷管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(u.projects.length===0&&!C&&!t)return(0,x.jsx)(m,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来记录缺陷。`});let yt=[{value:`all`,label:`全部`},...qe];return(0,x.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,x.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-600`,children:Z}),` 条缺陷`,X.length===Z?``:` · 筛选出 ${X.length} 条`]}),(0,x.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,x.jsx)(a,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选缺陷`,className:`w-36`,options:at,value:E,onChange:e=>{D(e),A(`all`),P(1)}}),(0,x.jsx)(a,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选缺陷`,className:`w-32`,options:ot,value:k,onChange:e=>{A(e),P(1)}}),(0,x.jsx)(a,{flat:!0,showCheck:!1,ariaLabel:`按严重程度筛选缺陷`,className:`w-32`,options:[{value:`all`,label:`全部严重程度`},...Ke],value:M,onChange:e=>{Qe(e),P(1)}}),(0,x.jsxs)(`label`,{className:`relative block`,children:[(0,x.jsx)(_,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,x.jsx)(`input`,{value:N,onChange:e=>{$e(e.target.value),P(1)},placeholder:`搜索编号 / 标题…`,className:`h-9 w-48 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,x.jsxs)(`button`,{type:`button`,disabled:R,onClick:()=>L(Je(O===`all`?``:O)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,x.jsx)(_,{name:`plus`,size:14}),`新建缺陷`]})]})]}),(0,x.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,x.jsx)(Me,{ariaLabel:`按状态筛选缺陷`,options:yt,value:j,onChange:e=>{Ze(e),P(1)}})}),Xe?(0,x.jsx)(Ee,{message:Xe,onClose:()=>w(``)}):null,(0,x.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,x.jsx)(`div`,{ref:rt,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,x.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:Y.tableStyle,children:[(0,x.jsx)(`colgroup`,{children:J.map(e=>(0,x.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,x.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,x.jsxs)(`tr`,{children:[(0,x.jsxs)(`th`,{className:`${ce} relative`,children:[`ID`,(0,x.jsx)(i,{...Y.resizeProps(`id`)})]}),(0,x.jsxs)(`th`,{className:oe,style:{"--tw-sticky-left":`${it}px`},children:[`缺陷标题`,(0,x.jsx)(i,{...Y.resizeProps(`title`)})]}),(0,x.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`严重程度`,(0,x.jsx)(i,{...Y.resizeProps(`severity`)})]}),(0,x.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`缺陷状态`,(0,x.jsx)(i,{...Y.resizeProps(`status`)})]}),t?null:(0,x.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属项目`,(0,x.jsx)(i,{...Y.resizeProps(`project`)})]}),(0,x.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属迭代`,(0,x.jsx)(i,{...Y.resizeProps(`iteration`)})]}),(0,x.jsx)(`th`,{"aria-hidden":`true`}),(0,x.jsx)(`th`,{className:te,children:`操作`})]})}),(0,x.jsxs)(`tbody`,{children:[C&&!u.bugs.length?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:J.length,className:`px-4 py-16 text-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):ut.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:J.length,children:Z?(0,x.jsx)(Ae,{children:`没有符合筛选条件的缺陷。`}):(0,x.jsx)(Pe,{icon:`bug`,title:`暂无缺陷`,hint:`记录第一个缺陷,跟踪严重程度与修复状态。`,action:(0,x.jsxs)(`button`,{type:`button`,onClick:()=>L(Je(O===`all`?``:O)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,x.jsx)(_,{name:`plus`,size:13}),`新建缺陷`]})})})}):null,ut.map(e=>(0,x.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,x.jsx)(`td`,{className:`${se} font-mono text-xs text-stone-400`,children:e.autoId}),(0,x.jsx)(`td`,{className:ae,style:{"--tw-sticky-left":`${it}px`},children:(0,x.jsx)(Se,{text:e.title,onClick:()=>L({id:e.id,projectId:e.projectId,iterationId:e.iterationId,requirementId:e.requirementId,title:e.title,severity:e.severity,status:e.status,reproduceSteps:e.reproduceSteps||e.title,expectedResult:e.expectedResult,actualResult:e.actualResult,environment:e.environment,githubIssue:e.githubIssue,attachment:e.attachment,remark:e.remark})})}),(0,x.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,x.jsx)(p,{tone:Ne[e.severity],children:ye[e.severity]})}),(0,x.jsx)(`td`,{className:`min-w-0 overflow-hidden px-2 py-1 align-middle`,children:(0,x.jsx)(a,{unstyled:!0,hideChevron:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:R,options:qe,value:e.status,onChange:t=>void _t(e,t),renderOptionPrefix:e=>(0,x.jsx)(v,{tone:je[e.value]}),renderTrigger:()=>(0,x.jsx)(p,{tone:je[e.status],children:_e[e.status]})})}),t?null:(0,x.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-600`,children:(0,x.jsx)(`a`,{href:we(e.projectId),className:`block truncate transition-colors hover:text-[#3370ff]`,children:st(e.projectId)})}),(0,x.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-500`,children:ct(e.iterationId)}),(0,x.jsx)(`td`,{"aria-hidden":`true`}),(0,x.jsx)(`td`,{className:re,children:(0,x.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:R,onClick:()=>G(e),className:`tw-icon-danger inline-flex h-7 w-7 items-center justify-center rounded-md`,children:(0,x.jsx)(_,{name:`trash`,size:15})})})]},e.id))]})]})}),X.length>0?(0,x.jsx)(ue,{page:Q,totalPages:lt,pageSize:F,busy:R,onPage:P,onPageSize:e=>{tt(e),P(1)}}):null]}),(0,x.jsx)(Te,{open:I!==null,title:I?.id?`编辑缺陷`:`新建缺陷`,busy:R,submitLabel:I?.id?`保存`:`创建`,onClose:gt,onSubmit:()=>void pt(),children:I?(0,x.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,x.jsx)(g,{label:`所属项目`,required:!0,children:(0,x.jsx)(y,{ariaLabel:`所属项目`,options:u.projects.map(e=>({value:e.id,label:e.name})),value:I.projectId,onChange:e=>L({...I,projectId:e,iterationId:``,requirementId:``})})}),(0,x.jsx)(g,{label:`所属迭代`,children:(0,x.jsx)(y,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...dt.map(e=>({value:e.id,label:e.name}))],value:I.iterationId,onChange:e=>L({...I,iterationId:e}),disabled:dt.length===0})}),(0,x.jsx)(g,{label:`关联需求`,children:(0,x.jsx)(y,{ariaLabel:`关联需求`,options:[{value:``,label:`不关联需求`},...ft.map(e=>({value:e.id,label:`${e.autoId} ${e.title}`}))],value:I.requirementId,onChange:e=>L({...I,requirementId:e}),disabled:ft.length===0})}),(0,x.jsx)(g,{label:`缺陷描述`,required:!0,children:(0,x.jsx)(`textarea`,{autoFocus:!0,value:I.reproduceSteps,onChange:e=>L({...I,reproduceSteps:e.target.value}),placeholder:`描述问题现象、复现步骤与影响范围`,rows:5,className:h})}),(0,x.jsx)(g,{label:`严重程度`,children:(0,x.jsx)(y,{ariaLabel:`严重程度`,options:Ke,value:I.severity,onChange:e=>L({...I,severity:e}),renderOptionPrefix:e=>(0,x.jsx)(v,{tone:Ne[e.value]})})}),(0,x.jsx)(g,{label:`附件`,children:(0,x.jsxs)(`div`,{className:`space-y-2`,children:[q.length?(0,x.jsx)(`ul`,{className:`space-y-1.5`,children:q.map(e=>{let t=Ye(e.url);return(0,x.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[t?(0,x.jsx)(`button`,{type:`button`,onClick:()=>K(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,x.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,x.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,x.jsx)(_,{name:`file`,size:15})}),t?(0,x.jsx)(`button`,{type:`button`,onClick:()=>K(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}):(0,x.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`min-w-0 flex-1 truncate text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>ht(e.url),className:`tw-icon-danger flex h-6 w-6 shrink-0 items-center justify-center rounded`,children:`✕`})]},e.url)})}):null,(0,x.jsx)(`input`,{ref:H,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void $(e.target.files)}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsxs)(`button`,{type:`button`,disabled:B,onClick:()=>H.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-dashed border-stone-300 px-2.5 text-xs text-stone-500 transition-colors hover:border-stone-400 hover:text-stone-700 disabled:opacity-40`,children:[(0,x.jsx)(_,{name:B?`file`:`plus`,size:13}),B?`上传中…`:`上传文件 / 图片`]}),(0,x.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可直接粘贴截图 / 图片(⌘V / Ctrl+V),支持多张`})]})]})}),(0,x.jsx)(g,{label:`备注`,children:(0,x.jsx)(`textarea`,{value:I.remark,onChange:e=>L({...I,remark:e.target.value}),rows:2,className:h})})]}):null}),(0,x.jsx)(ee,{open:W!==null,title:`删除缺陷`,message:`确定删除「${W?.title??``}」?此操作无法恢复。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>G(null),onConfirm:()=>void vt()}),(0,x.jsx)(Oe,{file:nt,onClose:()=>K(null)})]})}export{C as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.Di6uuouN.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.D5qXeML0.js";import{t as a}from"./DatePicker.Bkl71M49.js";import{t as o}from"./SelectDropdown.apWlFGbA.js";import{showToast as s}from"./Toast.BO2NFckG.js";import{D as c,I as ee,L as l,N as te,O as ne,a as u,g as re,h as ie,o as d,x as ae}from"./pm.pMOkNqqK.js";import{A as f,D as oe,E as se,O as p,S as m,_ as h,a as ce,c as le,d as ue,f as g,g as _,i as v,k as de,l as fe,m as y,r as b,s as x,u as S,v as pe,y as C}from"./PmShared.Bzn6AGsN.js";var w=e(t(),1),T=r(),E=10,me=[`all`,...u],he=`pm.iterations.project`,D=`pm.iterations.status`,ge=`pm.iterations.keyword`,O=u.map(e=>({value:e,label:d[e]}));function k(e=``){return{projectId:e,name:``,startDate:``,endDate:``,status:`planning`,remark:``}}function A({scopeProjectId:e=``}={}){let t=!!e,r=de(`iterations`),{store:u,live:A,loading:j,error:M,setError:N,reload:P}=f(),[F,I]=p(he,`all`),L=e||F,[R,_e]=oe(D,me,`all`),[z,ve]=p(ge),[ye,B]=(0,w.useState)(1),[V,H]=(0,w.useState)(null),[U,W]=(0,w.useState)(!1),[G,K]=(0,w.useState)(null),q=ee(),be=(0,w.useMemo)(()=>{let e=new Map(u.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`未关联项目`},[u.projects]),xe=(0,w.useMemo)(()=>[{value:`all`,label:`全部项目`},...u.projects.map(e=>({value:e.id,label:e.name}))],[u.projects]),J=(0,w.useMemo)(()=>te(ae(u.iterations,{projectId:L,status:R,keyword:z})),[u.iterations,L,R,z]),Y=t?u.iterations.filter(e=>e.projectId===L).length:u.iterations.length,X=Math.max(1,Math.ceil(J.length/E)),Z=Math.min(ye,X),Q=J.slice((Z-1)*E,Z*E);(0,w.useEffect)(()=>{t||A===!0&&F!==`all`&&!u.projects.some(e=>e.id===F)&&I(`all`)},[A,u.projects,F,I,t]);async function Se(){if(!V)return;if(!V.projectId){N(`请先选择所属项目`);return}let e=V.name.trim();if(!e)N(`迭代名称不能为空`);else if(V.startDate&&V.endDate&&V.endDate<V.startDate)N(`迭代结束日期不能早于开始日期`);else{W(!0);try{let t={projectId:V.projectId,name:e,startDate:V.startDate,endDate:V.endDate,status:V.status,remark:V.remark};V.id?await l(`iterations`,V.id,t):await ie(`iterations`,[t]),H(null),N(``),await P(!0),s(V.id?`已保存迭代`:`已新建迭代`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),s(`保存迭代失败:${t}`,`error`)}finally{W(!1)}}}async function $(e,t){W(!0);try{await l(`iterations`,e.id,{status:t}),await P(!0),s(`已更新迭代状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),s(`更新迭代失败:${t}`,`error`)}finally{W(!1)}}async function Ce(){let e=G;if(e){K(null),W(!0);try{await re(`iterations`,[e.id]),await P(!0),s(`已删除迭代`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),s(`删除迭代失败:${t}`,`error`)}finally{W(!1)}}}return r.ready?r.on?A===null?(0,T.jsx)(_,{label:`正在连接项目管理服务`}):A?u.projects.length===0&&!j&&!t?(0,T.jsx)(h,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护迭代。`}):(0,T.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-600`,children:Y}),` 个迭代`,J.length===Y?``:` · 筛选出 ${J.length} 个`]}),(0,T.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,T.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选迭代`,className:`w-36`,options:xe,value:F,onChange:e=>{I(e),B(1)}}),(0,T.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按状态筛选迭代`,className:`w-28`,options:[{value:`all`,label:`全部状态`},...O],value:R,onChange:e=>{_e(e),B(1)}}),(0,T.jsxs)(`label`,{className:`relative block`,children:[(0,T.jsx)(y,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,T.jsx)(`input`,{value:z,onChange:e=>{ve(e.target.value),B(1)},placeholder:`搜索迭代名称…`,className:`h-9 w-44 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>H(k(L===`all`?``:L)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`plus`,size:14}),`新建迭代`]})]})]}),M?(0,T.jsx)(ue,{message:M,onClose:()=>N(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pb-4`,children:j&&!u.iterations.length?(0,T.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):Q.length===0?Y?(0,T.jsx)(fe,{children:`没有符合筛选条件的迭代。`}):(0,T.jsx)(S,{icon:`calendar`,title:`暂无迭代`,hint:`新建一个迭代,用开始 / 截止日期跟踪进度。`,action:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>H(k(L===`all`?``:L)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,T.jsx)(y,{name:`plus`,size:13}),`新建迭代`]})}):(0,T.jsx)(`div`,{className:`space-y-3`,children:Q.map(e=>{let n=ne(e,q),r=c(e,q),i=e.endDate&&e.status!==`done`?Math.round((Date.parse(`${e.endDate}T00:00:00`)-Date.parse(`${q}T00:00:00`))/864e5):null;return(0,T.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3.5 transition-[border-color,box-shadow] hover:border-[#ddd6fe] hover:shadow-sm`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`truncate text-[15px] font-medium text-stone-800`,children:e.name}),(0,T.jsx)(m,{tone:b[e.status],children:d[e.status]})]}),(0,T.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-stone-500`,children:[t?null:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`a`,{href:se(e.projectId),className:`transition-colors hover:text-[#3370ff]`,children:be(e.projectId)}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`})]}),(0,T.jsxs)(`span`,{className:`tabular-nums`,children:[e.startDate||`—`,` → `,e.endDate||`—`]}),r===null?i!==null&&i>=0&&e.endDate?(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[`还剩 `,i,` 天`]}):null:(0,T.jsxs)(`span`,{className:`text-red-500`,children:[`逾期 `,r,` 天`]})]}),e.remark?(0,T.jsx)(`p`,{className:`mt-1 line-clamp-1 text-xs text-stone-400`,children:e.remark}):null]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.status===`planning`?(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>void $(e,`in_progress`),className:`inline-flex h-8 items-center gap-1 rounded-lg px-2 text-xs text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`play`,size:12}),`开始`]}):null,e.status===`in_progress`?(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>void $(e,`done`),className:`inline-flex h-8 items-center gap-1 rounded-lg px-2 text-xs text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`check`,size:12}),`完成`]}):null,(0,T.jsx)(`button`,{type:`button`,"aria-label":`编辑 ${e.name}`,onClick:()=>H({id:e.id,projectId:e.projectId,name:e.name,startDate:e.startDate,endDate:e.endDate,status:e.status,remark:e.remark}),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,children:(0,T.jsx)(y,{name:`pencil`,size:15})}),(0,T.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.name}`,disabled:U,onClick:()=>K(e),className:`tw-icon-danger flex h-8 w-8 items-center justify-center rounded-lg`,children:(0,T.jsx)(y,{name:`trash`,size:15})})]})]}),(0,T.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,T.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,T.jsx)(`div`,{className:`h-full rounded-full bg-[#3370ff] transition-[width] duration-300`,style:{width:`${n}%`}})}),(0,T.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs tabular-nums text-stone-500`,children:[n,`%`]})]})]},e.id)})})}),J.length>0?(0,T.jsx)(pe,{page:Z,totalPages:X,busy:U,onPage:B}):null,(0,T.jsx)(le,{open:V!==null,title:V?.id?`编辑迭代`:`新建迭代`,busy:U,submitLabel:V?.id?`保存`:`创建`,onClose:()=>H(null),onSubmit:()=>void Se(),children:V?(0,T.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,T.jsx)(g,{label:`所属项目`,required:!0,children:(0,T.jsx)(C,{ariaLabel:`所属项目`,options:u.projects.map(e=>({value:e.id,label:e.name})),value:V.projectId,onChange:e=>H({...V,projectId:e}),disabled:u.projects.length===0})}),(0,T.jsx)(g,{label:`迭代名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),placeholder:`如:v1.0 迭代`,className:v})}),(0,T.jsx)(g,{label:`开始日期`,children:(0,T.jsx)(a,{value:V.startDate,onChange:e=>H({...V,startDate:e}),placeholder:`选择开始日期`,className:`${v} tabular-nums`})}),(0,T.jsx)(g,{label:`截止日期`,children:(0,T.jsx)(a,{value:V.endDate,onChange:e=>H({...V,endDate:e}),placeholder:`选择截止日期`,className:`${v} tabular-nums`})}),(0,T.jsx)(g,{label:`状态`,children:(0,T.jsx)(C,{ariaLabel:`迭代状态`,options:O,value:V.status,onChange:e=>H({...V,status:e}),renderOptionPrefix:e=>(0,T.jsx)(x,{tone:b[e.value]})})}),(0,T.jsx)(g,{label:`备注`,children:(0,T.jsx)(`textarea`,{value:V.remark,onChange:e=>H({...V,remark:e.target.value}),placeholder:`迭代目标、范围等(可选)`,rows:3,className:ce})})]}):null}),(0,T.jsx)(i,{open:G!==null,title:`删除迭代`,message:`确定删除「${G?.name??``}」?关联的需求与缺陷会保留,但不再关联到这个迭代。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>K(null),onConfirm:()=>void Ce()})]}):(0,T.jsx)(h,{children:`迭代管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(h,{children:n(`iterations`)}):(0,T.jsx)(_,{label:`正在读取插件开关`})}export{A as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as ee}from"./plugins.Di6uuouN.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.D5qXeML0.js";import{t as i}from"./SelectDropdown.apWlFGbA.js";import{showToast as a}from"./Toast.BO2NFckG.js";import{L as o,S as te,c as s,g as ne,h as c,j as l,s as u}from"./pm.pMOkNqqK.js";import{A as d,D as f,E as p,O as m,S as h,_ as g,a as re,c as ie,d as ae,f as _,g as v,i as oe,k as se,l as y,m as b,o as x,s as ce,u as le,v as S,y as C}from"./PmShared.Bzn6AGsN.js";var w=e(t(),1),T=n(),E=10,D=u.map(e=>({value:e,label:s[e]})),O=[`all`,...u],k=`pm.projects.status`,A=`pm.projects.keyword`;function j(){return{name:``,description:``,status:`planning`}}function M(){let e=se(`projects`),{store:t,live:n,loading:u,error:M,setError:N,reload:P}=d(),[F,I]=f(k,O,`all`),[L,R]=m(A),[z,B]=(0,w.useState)(1),[V,H]=(0,w.useState)(null),[U,W]=(0,w.useState)(!1),[G,K]=(0,w.useState)(null),[q,J]=(0,w.useState)(null),Y=(0,w.useRef)(null),ue=(0,w.useMemo)(()=>l(t),[t]),X=(0,w.useMemo)(()=>te(t.projects,{status:F,keyword:L}),[t.projects,F,L]),Z=Math.max(1,Math.ceil(X.length/E)),Q=Math.min(z,Z),$=X.slice((Q-1)*E,Q*E);(0,w.useEffect)(()=>{if(!q)return;function e(e){Y.current?.contains(e.target)||J(null)}function t(e){e.key===`Escape`&&J(null)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[q]);async function de(){if(!V)return;let e=V.name.trim();if(!e)N(`项目名称不能为空`);else{W(!0);try{V.id?await o(`projects`,V.id,{name:e,description:V.description,status:V.status}):await c(`projects`,[{name:e,description:V.description,status:V.status}]),H(null),N(``),await P(!0),a(V.id?`已保存项目`:`已新建项目`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),a(`保存项目失败:${t}`,`error`)}finally{W(!1)}}}async function fe(e){J(null),W(!0);try{let t=e.status!==`archived`;await o(`projects`,e.id,{status:t?`archived`:`planning`}),await P(!0),a(t?`已归档「${e.name}」`:`已取消归档「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),a(`更新项目失败:${t}`,`error`)}finally{W(!1)}}async function pe(){let e=G;if(e){K(null),W(!0);try{await ne(`projects`,[e.id]),await P(!0),a(`已删除项目`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),a(`删除项目失败:${t}`,`error`)}finally{W(!1)}}}return e.ready?e.on?n===null?(0,T.jsx)(v,{label:`正在连接项目管理服务`}):n?(0,T.jsxs)(`section`,{className:`flex min-h-0 flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsx)(`div`,{className:`text-xs text-stone-400`,children:t.projects.length?(0,T.jsxs)(T.Fragment,{children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-600`,children:t.projects.length}),` 个项目`,X.length===t.projects.length?``:` · 筛选出 ${X.length} 个`]}):`暂无项目`}),(0,T.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(i,{flat:!0,showCheck:!1,ariaLabel:`按状态筛选项目`,className:`w-32`,options:[{value:`all`,label:`全部状态`},...D],value:F,onChange:e=>{I(e),B(1)}}),(0,T.jsxs)(`label`,{className:`relative block`,children:[(0,T.jsx)(b,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,T.jsx)(`input`,{value:L,onChange:e=>{R(e.target.value),B(1)},placeholder:`搜索项目名称 / 描述…`,className:`h-9 w-52 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>H(j()),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,T.jsx)(b,{name:`plus`,size:14}),`新建项目`]})]})]}),M?(0,T.jsx)(ae,{message:M,onClose:()=>N(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pt-1 pb-4`,children:u&&!t.projects.length?(0,T.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):$.length===0?t.projects.length?(0,T.jsx)(y,{children:`没有符合筛选条件的项目。`}):(0,T.jsx)(le,{icon:`folder`,title:`暂无项目`,hint:`创建第一个项目开始吧`,action:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>H(j()),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,T.jsx)(b,{name:`plus`,size:13}),`新建项目`]})}):(0,T.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3`,children:$.map(e=>{let t=ue[e.id];return(0,T.jsxs)(`article`,{className:`tw-pm-card group relative rounded-2xl border border-stone-200 bg-white`,children:[(0,T.jsx)(`span`,{className:`pointer-events-none absolute inset-0 overflow-hidden rounded-2xl`,"aria-hidden":`true`,children:(0,T.jsx)(`span`,{className:`tw-pm-card-accent absolute -right-6 -top-6 h-20 w-20 rounded-full bg-[#f1edff]`})}),(0,T.jsx)(`a`,{href:p(e.id),"aria-label":`打开项目 ${e.name}`,className:`absolute inset-0 z-0 rounded-2xl`}),(0,T.jsxs)(`div`,{className:`pointer-events-none relative z-10 flex h-full flex-col p-5`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,T.jsx)(`span`,{className:`tw-pm-tile flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-xs font-bold`,children:e.name.slice(0,1)}),(0,T.jsx)(`h3`,{className:`truncate text-[15px] font-semibold text-stone-800`,children:e.name})]}),(0,T.jsx)(h,{tone:x[e.status],children:s[e.status]})]}),(0,T.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-[40px] text-sm ${e.description?`text-stone-500`:`italic text-stone-300`}`,children:e.description||`暂无描述`}),(0,T.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-xs text-stone-500`,children:[(0,T.jsxs)(`span`,{children:[t?.iterations??0,` 迭代`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.requirements??0,` 需求`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.bugs??0,` 缺陷`]})]}),(0,T.jsxs)(`div`,{className:`mt-auto flex items-center justify-between pt-4`,children:[(0,T.jsxs)(`div`,{className:`pointer-events-auto relative`,ref:q===e.id?Y:void 0,children:[(0,T.jsx)(`button`,{type:`button`,"aria-label":`${e.name} 的操作`,"aria-haspopup":`menu`,"aria-expanded":q===e.id,onClick:()=>J(q===e.id?null:e.id),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,children:(0,T.jsx)(b,{name:`more`,size:18})}),q===e.id?(0,T.jsxs)(`div`,{role:`menu`,className:`absolute left-0 top-9 z-30 w-36 overflow-hidden rounded-lg border border-stone-200 bg-white py-1 shadow-lg`,children:[(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{J(null),H({id:e.id,name:e.name,description:e.description,status:e.status})},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-stone-700 hover:bg-stone-50`,children:[(0,T.jsx)(b,{name:`pencil`,size:14}),`编辑`]}),(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>void fe(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-stone-700 hover:bg-stone-50`,children:[(0,T.jsx)(b,{name:`folder`,size:14}),e.status===`archived`?`取消归档`:`归档`]}),(0,T.jsx)(`div`,{className:`my-1 border-t border-stone-100`}),(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{J(null),K(e)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-red-600 hover:bg-red-50`,children:[(0,T.jsx)(b,{name:`trash`,size:14}),`删除`]})]}):null]}),(0,T.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-stone-400`,children:[`需求完成 `,t?.requirementPercent??0,`%`,(0,T.jsx)(b,{name:`chevronRight`,size:14,className:`tw-pm-card-chevron text-stone-300`})]})]})]})]},e.id)})})}),X.length>0?(0,T.jsx)(S,{page:Q,totalPages:Z,busy:U,onPage:B}):null,(0,T.jsx)(ie,{open:V!==null,title:V?.id?`编辑项目`:`新建项目`,busy:U,submitLabel:V?.id?`保存`:`创建`,onClose:()=>H(null),onSubmit:()=>void de(),children:V?(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(_,{label:`项目名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),placeholder:`输入项目名称`,className:oe})}),(0,T.jsx)(_,{label:`描述`,children:(0,T.jsx)(`textarea`,{value:V.description,onChange:e=>H({...V,description:e.target.value}),placeholder:`项目描述(可选)`,rows:4,className:re})}),(0,T.jsx)(_,{label:`状态`,children:(0,T.jsx)(C,{ariaLabel:`项目状态`,options:D,value:V.status,onChange:e=>H({...V,status:e}),renderOptionPrefix:e=>(0,T.jsx)(ce,{tone:x[e.value]})})})]}):null}),(0,T.jsx)(r,{open:G!==null,title:`删除项目`,message:`确定删除「${G?.name??``}」?该项目下的迭代、需求与缺陷会一并删除,且无法恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:`solid`,onClose:()=>K(null),onConfirm:()=>void pe()})]}):(0,T.jsx)(g,{children:`项目列表需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(g,{children:ee(`projects`)}):(0,T.jsx)(v,{label:`正在读取插件开关`})}export{M as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.Di6uuouN.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.D5qXeML0.js";import{c as a,d as ee,i as o,l as s,n as c,o as te,r as l,s as ne,t as u}from"./ColumnResize.BgYkV9Iy.js";import{n as d,t as f}from"./DocsPager.WMztSW4O.js";import{t as p}from"./SelectDropdown.apWlFGbA.js";import{showToast as m}from"./Toast.BO2NFckG.js";import{A as h,C as re,E as g,L as _,N as ie,P as ae,R as v,d as y,f as oe,g as se,h as ce,k as b,l as x,m as le,u as ue}from"./pm.pMOkNqqK.js";import{A as de,C as fe,D as pe,E as me,O as S,S as he,T as C,_ as w,a as ge,c as _e,d as ve,f as T,g as ye,h as E,k as be,l as xe,m as D,p as Se,s as O,u as Ce,w as we,y as k}from"./PmShared.Bzn6AGsN.js";var A=e(t(),1),j=r();function Te({value:e,onChange:t,entity:n,recordId:r=``,seenUrls:i,onError:a,onPersisted:ee}){let o=h(e),[s,c]=(0,A.useState)(!1),[te,l]=(0,A.useState)(!1),[ne,u]=(0,A.useState)(null),d=(0,A.useRef)(null);(0,A.useEffect)(()=>{for(let t of h(e))i.current.add(t.url)},[e,i]);let f=(0,A.useCallback)(async n=>{if(n&&n.length){c(!0);try{let r=await v(Array.from(n));t(b([...h(e),...r])),a(``)}catch(e){a(e instanceof Error?e.message:String(e))}finally{c(!1),d.current&&(d.current.value=``)}}},[t,a,e]);(0,A.useEffect)(()=>{let e=e=>{let t=Array.from(e.clipboardData?.files??[]);t.length&&(e.preventDefault(),f(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[f]);async function p(e){let i=b(o.filter(t=>t.url!==e));if(r)try{await _(n,r,{attachment:i}),ee?.()}catch(e){a(e instanceof Error?e.message:String(e));return}t(i),le([e],r)}return(0,j.jsxs)(`div`,{className:`space-y-2 rounded-lg transition-colors ${te?`bg-[#3370ff]/5 ring-1 ring-[#3370ff]/40`:``}`,onDragOver:e=>{e.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:e=>{e.preventDefault(),l(!1),f(e.dataTransfer?.files??null)},children:[o.length?(0,j.jsx)(`ul`,{className:`space-y-1.5`,children:o.map(e=>(0,j.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[g(e.url)?(0,j.jsx)(`button`,{type:`button`,onClick:()=>u(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,j.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,j.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,j.jsx)(D,{name:`file`,size:15})}),g(e.url)?(0,j.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}):(0,j.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`min-w-0 flex-1 truncate text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}),(0,j.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>void p(e.url),className:`tw-icon-danger flex h-6 w-6 shrink-0 items-center justify-center rounded`,children:`✕`})]},e.url))}):null,(0,j.jsx)(`input`,{ref:d,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void f(e.target.files)}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,j.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>d.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-dashed border-stone-300 px-2.5 text-xs text-stone-500 transition-colors hover:border-stone-400 hover:text-stone-700 disabled:opacity-40`,children:[(0,j.jsx)(D,{name:s?`file`:`plus`,size:13}),s?`上传中…`:`上传文件 / 图片`]}),(0,j.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可拖拽到这里,或直接粘贴截图(⌘V / Ctrl+V),支持多张`})]}),(0,j.jsx)(E,{file:ne,onClose:()=>u(null)})]})}var Ee=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`priority`,width:100,min:80},{key:`status`,width:120,min:96}],De={key:`project`,width:140,min:100},Oe=[{key:`iteration`,width:120,min:88},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],ke=20,Ae=`tw.pm-requirements.page-size.v1`,je=[`all`,...y],Me=[`all`,...x],Ne=`pm.requirements.project`,Pe=`pm.requirements.iteration`,Fe=`pm.requirements.status`,Ie=`pm.requirements.priority`,Le=`pm.requirements.keyword`,Re=x.map(e=>({value:e,label:ue[e]})),M=y.map(e=>({value:e,label:oe[e]}));function ze(e=``){return{projectId:e,iterationId:``,title:``,priority:`medium`,status:`pending`,description:``,acceptanceCriteria:[],githubIssue:``,attachment:``}}function N({scopeProjectId:e=``}={}){let t=!!e,r=be(`pmRequirements`),{store:g,live:v,loading:y,error:b,setError:x,reload:E}=de(),[N,P]=S(Ne,`all`),F=e||N,[I,L]=S(Pe,`all`),[R,Be]=pe(Fe,je,`all`),[z,Ve]=pe(Ie,Me,`all`),[B,He]=S(Le),[Ue,V]=(0,A.useState)(1),[H,We]=d(ke,Ae),[U,W]=(0,A.useState)(null),[G,K]=(0,A.useState)(!1),[q,J]=(0,A.useState)(null),Y=(0,A.useRef)(new Set),X=(0,A.useMemo)(()=>t?[...Ee,...Oe]:[...Ee,De,...Oe],[t]),Z=s(t?`pm.requirements.cols.scoped.v1`:`pm.requirements.cols.v1`,X),Ge=ee(t?`pm.requirements.scroll.scoped`:`pm.requirements.scroll`),Ke=Z.widthOf(`id`)??88,qe=(0,A.useMemo)(()=>[{value:`all`,label:`全部项目`},...g.projects.map(e=>({value:e.id,label:e.name}))],[g.projects]),Je=(0,A.useMemo)(()=>[{value:`all`,label:`全部迭代`},...ie(g.iterations.filter(e=>F===`all`||e.projectId===F)).map(e=>({value:e.id,label:e.name}))],[g.iterations,F]),Ye=(0,A.useMemo)(()=>{let e=new Map(g.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[g.projects]),Xe=(0,A.useMemo)(()=>{let e=new Map(g.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[g.iterations]),Q=(0,A.useMemo)(()=>ae(re(g.requirements,{projectId:F,iterationId:I,status:R,priority:z,keyword:B})),[g.requirements,F,I,R,z,B]),$=t?g.requirements.filter(e=>e.projectId===F).length:g.requirements.length,Ze=Math.max(1,Math.ceil(Q.length/H)),Qe=Math.min(Ue,Ze),$e=Q.slice((Qe-1)*H,Qe*H);(0,A.useEffect)(()=>{t||v===!0&&N!==`all`&&!g.projects.some(e=>e.id===N)&&P(`all`)},[v,g.projects,N,P,t]),(0,A.useEffect)(()=>{v===!0&&I!==`all`&&!g.iterations.some(e=>e.id===I&&(F===`all`||e.projectId===F))&&L(`all`)},[v,g.iterations,F,I,L]);let et=U?ie(g.iterations.filter(e=>e.projectId===U.projectId)):[];async function tt(){if(!U)return;if(!U.projectId){x(`请先选择所属项目`);return}let e=U.title.trim();if(!e)x(`需求描述不能为空`);else{K(!0);try{let t={projectId:U.projectId,iterationId:U.iterationId,title:e,priority:U.priority,status:U.status,description:U.description,acceptanceCriteria:U.acceptanceCriteria.filter(e=>e.text.trim()),githubIssue:U.githubIssue,attachment:U.attachment};U.id?await _(`requirements`,U.id,t):await ce(`requirements`,[t]);let n=!!U.id;W(null),Y.current.clear(),x(``),await E(!0),m(n?`已保存需求`:`已新建需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),m(`保存需求失败:${t}`,`error`)}finally{K(!1)}}}function nt(){let e=[...Y.current,...h(U?.attachment??``).map(e=>e.url)];Y.current.clear(),W(null),e.length&&le(e)}async function rt(e,t){K(!0);try{await _(`requirements`,e.id,{status:t}),await E(!0),m(`已更新需求状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),m(`更新状态失败:${t}`,`error`)}finally{K(!1)}}async function it(){let e=q;if(e){J(null),K(!0);try{await se(`requirements`,[e.id]),await E(!0),m(`已删除需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),m(`删除需求失败:${t}`,`error`)}finally{K(!1)}}}if(!r.ready)return(0,j.jsx)(ye,{label:`正在读取插件开关`});if(!r.on)return(0,j.jsx)(w,{children:n(`pmRequirements`)});if(v===null)return(0,j.jsx)(ye,{label:`正在连接项目管理服务`});if(!v)return(0,j.jsx)(w,{children:`需求管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(g.projects.length===0&&!y&&!t)return(0,j.jsx)(w,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护需求。`});let at=[{value:`all`,label:`全部`},...M];return(0,j.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,j.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,j.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,j.jsx)(`span`,{className:`font-medium text-stone-600`,children:$}),` 条需求`,Q.length===$?``:` · 筛选出 ${Q.length} 条`]}),(0,j.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,j.jsx)(p,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选需求`,className:`w-36`,options:qe,value:N,onChange:e=>{P(e),L(`all`),V(1)}}),(0,j.jsx)(p,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选需求`,className:`w-32`,options:Je,value:I,onChange:e=>{L(e),V(1)}}),(0,j.jsx)(p,{flat:!0,showCheck:!1,ariaLabel:`按优先级筛选需求`,className:`w-28`,options:[{value:`all`,label:`全部优先级`},...Re],value:z,onChange:e=>{Ve(e),V(1)}}),(0,j.jsxs)(`label`,{className:`relative block`,children:[(0,j.jsx)(D,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,j.jsx)(`input`,{value:B,onChange:e=>{He(e.target.value),V(1)},placeholder:`搜索编号 / 名称…`,className:`h-9 w-44 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,j.jsxs)(`button`,{type:`button`,disabled:G,onClick:()=>W(ze(F===`all`?``:F)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,j.jsx)(D,{name:`plus`,size:14}),`新建需求`]})]})]}),(0,j.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,j.jsx)(Se,{ariaLabel:`按状态筛选需求`,options:at,value:R,onChange:e=>{Be(e),V(1)}})}),b?(0,j.jsx)(ve,{message:b,onClose:()=>x(``)}):null,(0,j.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,j.jsx)(`div`,{ref:Ge,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,j.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:Z.tableStyle,children:[(0,j.jsx)(`colgroup`,{children:X.map(e=>(0,j.jsx)(`col`,{style:Z.widthOf(e.key)?{width:Z.widthOf(e.key)}:void 0},e.key))}),(0,j.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsxs)(`th`,{className:`${ne} relative`,children:[`ID`,(0,j.jsx)(u,{...Z.resizeProps(`id`)})]}),(0,j.jsxs)(`th`,{className:te,style:{"--tw-sticky-left":`${Ke}px`},children:[`需求描述`,(0,j.jsx)(u,{...Z.resizeProps(`title`)})]}),(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`优先级`,(0,j.jsx)(u,{...Z.resizeProps(`priority`)})]}),(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`需求状态`,(0,j.jsx)(u,{...Z.resizeProps(`status`)})]}),t?null:(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属项目`,(0,j.jsx)(u,{...Z.resizeProps(`project`)})]}),(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属迭代`,(0,j.jsx)(u,{...Z.resizeProps(`iteration`)})]}),(0,j.jsx)(`th`,{"aria-hidden":`true`}),(0,j.jsx)(`th`,{className:a,children:`操作`})]})}),(0,j.jsxs)(`tbody`,{children:[y&&!g.requirements.length?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:X.length,className:`px-4 py-16 text-center`,children:(0,j.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):$e.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:X.length,children:$?(0,j.jsx)(xe,{children:`没有符合筛选条件的需求。`}):(0,j.jsx)(Ce,{icon:`file`,title:`暂无需求`,hint:`拆出第一条需求,再关联迭代、补充描述。`,action:(0,j.jsxs)(`button`,{type:`button`,onClick:()=>W(ze(F===`all`?``:F)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,j.jsx)(D,{name:`plus`,size:13}),`新建需求`]})})})}):null,$e.map(e=>(0,j.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,j.jsx)(`td`,{className:`${l} font-mono text-xs text-stone-400`,children:e.autoId}),(0,j.jsx)(`td`,{className:c,style:{"--tw-sticky-left":`${Ke}px`},children:(0,j.jsx)(fe,{text:e.title,onClick:()=>W({id:e.id,projectId:e.projectId,iterationId:e.iterationId,title:e.title,priority:e.priority,status:e.status,description:e.description,acceptanceCriteria:e.acceptanceCriteria.map(e=>({...e})),githubIssue:e.githubIssue,attachment:e.attachment})})}),(0,j.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,j.jsx)(he,{tone:we[e.priority],children:ue[e.priority]})}),(0,j.jsx)(`td`,{className:`min-w-0 overflow-hidden px-2 py-1 align-middle`,children:(0,j.jsx)(p,{unstyled:!0,hideChevron:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:G,options:M,value:e.status,onChange:t=>void rt(e,t),renderOptionPrefix:e=>(0,j.jsx)(O,{tone:C[e.value]}),renderTrigger:()=>(0,j.jsx)(he,{tone:C[e.status],children:oe[e.status]})})}),t?null:(0,j.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-600`,children:(0,j.jsx)(`a`,{href:me(e.projectId),className:`block truncate transition-colors hover:text-[#3370ff]`,children:Ye(e.projectId)})}),(0,j.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-500`,children:Xe(e.iterationId)}),(0,j.jsx)(`td`,{"aria-hidden":`true`}),(0,j.jsx)(`td`,{className:o,children:(0,j.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:G,onClick:()=>J(e),className:`tw-icon-danger inline-flex h-7 w-7 items-center justify-center rounded-md`,children:(0,j.jsx)(D,{name:`trash`,size:15})})})]},e.id))]})]})}),Q.length>0?(0,j.jsx)(f,{page:Qe,totalPages:Ze,pageSize:H,busy:G,onPage:V,onPageSize:e=>{We(e),V(1)}}):null]}),(0,j.jsx)(_e,{open:U!==null,title:U?.id?`编辑需求`:`新建需求`,busy:G,submitLabel:U?.id?`保存`:`创建`,onClose:()=>nt(),onSubmit:()=>void tt(),children:U?(0,j.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,j.jsx)(T,{label:`所属项目`,required:!0,children:(0,j.jsx)(k,{ariaLabel:`所属项目`,options:g.projects.map(e=>({value:e.id,label:e.name})),value:U.projectId,onChange:e=>{let t=g.iterations.some(t=>t.id===U.iterationId&&t.projectId===e);W({...U,projectId:e,iterationId:t?U.iterationId:``})}})}),(0,j.jsx)(T,{label:`所属迭代`,children:(0,j.jsx)(k,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...et.map(e=>({value:e.id,label:e.name}))],value:U.iterationId,onChange:e=>W({...U,iterationId:e}),disabled:et.length===0})}),(0,j.jsx)(T,{label:`需求描述`,required:!0,children:(0,j.jsx)(`textarea`,{autoFocus:!0,value:U.title,onChange:e=>W({...U,title:e.target.value}),placeholder:`一句话写清要做什么`,rows:3,className:ge})}),(0,j.jsx)(T,{label:`优先级`,children:(0,j.jsx)(k,{ariaLabel:`优先级`,options:Re,value:U.priority,onChange:e=>W({...U,priority:e}),renderOptionPrefix:e=>(0,j.jsx)(O,{tone:we[e.value]})})}),(0,j.jsx)(T,{label:`需求状态`,children:(0,j.jsx)(k,{ariaLabel:`需求状态`,options:M,value:U.status,onChange:e=>W({...U,status:e}),renderOptionPrefix:e=>(0,j.jsx)(O,{tone:C[e.value]})})}),(0,j.jsx)(T,{label:`附件`,children:(0,j.jsx)(Te,{value:U.attachment,onChange:e=>W(t=>t&&{...t,attachment:e}),entity:`requirements`,recordId:U.id??``,seenUrls:Y,onError:x,onPersisted:()=>void E(!0)})}),(0,j.jsx)(T,{label:`备注`,children:(0,j.jsx)(`textarea`,{value:U.description,onChange:e=>W({...U,description:e.target.value}),placeholder:`补充背景、目标与范围(可选)`,rows:4,className:ge})})]}):null}),(0,j.jsx)(i,{open:q!==null,title:`删除需求`,message:`确定删除「${q?.title??``}」?关联的缺陷会保留,但不再关联到这条需求。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>J(null),onConfirm:()=>void it()})]})}export{N as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{t as default}from"./PmRequirementsBoard.CXaGeFl9.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";var i=e(t(),1),a=e(n(),1),o=r(),s=280;function c({open:e,onClose:t,title:n,closeAriaLabel:r=`关闭面板`,widthClass:c=`max-w-md`,escDisabled:l=!1,children:u,footer:d}){let[f,p]=(0,i.useState)(e),[m,h]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{if(e){p(!0);let e=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>h(!0))});return()=>window.cancelAnimationFrame(e)}h(!1);let t=window.setTimeout(()=>p(!1),s);return()=>window.clearTimeout(t)},[e]),(0,i.useEffect)(()=>{if(!e||l)return;function n(e){e.key===`Escape`&&(document.querySelector(`[aria-haspopup="listbox"][aria-expanded="true"]`)||(e.preventDefault(),e.stopPropagation(),t()))}return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t,l]),!f)return null;let g=(0,o.jsxs)(`div`,{className:`fixed inset-0 z-60 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,o.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-stone-900/30 transition-opacity duration-[280ms] ease-out ${m?`opacity-100`:`opacity-0`}`,"aria-label":r,onClick:t}),(0,o.jsxs)(`aside`,{className:`tw-slide-over relative w-full ${c} h-full shadow-2xl border-l border-stone-200 flex flex-col transition-[translate] duration-[280ms] ease-[cubic-bezier(0.32,0.72,0,1)] will-change-[translate] ${m?`translate-x-0`:`translate-x-full`}`,children:[(0,o.jsxs)(`header`,{className:`shrink-0 h-12 px-4 border-b border-stone-100 flex items-center gap-2`,children:[(0,o.jsx)(`h2`,{className:`tw-slide-over-title text-sm font-semibold text-stone-800 flex-1`,children:n}),(0,o.jsx)(`button`,{type:`button`,onClick:t,className:`tw-icon-btn w-8 h-8 rounded-lg`,"data-hint":`关闭(Esc)`,children:`✕`})]}),(0,o.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 space-y-4`,children:u}),d]})]});return typeof document>`u`?g:(0,a.createPortal)(g,document.body)}export{c as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DAIyT--R.js";import{i as r,o as i,s as ee}from"./plugins.Di6uuouN.js";import{n as a,o,r as s,s as c}from"./view-prefs.DkS1ldnh.js";import{i as l,n as u,r as d,t as f}from"./dialog.DZHZCe_T.js";import{t as p}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./ConfirmDialog.D5qXeML0.js";import{c as h,d as g,i as _,l as v,n as y,o as b,t as x}from"./ColumnResize.BgYkV9Iy.js";import{t as S}from"./DatePicker.Bkl71M49.js";import{t as C}from"./SelectDropdown.apWlFGbA.js";import{showToast as w}from"./Toast.BO2NFckG.js";import{A as T,C as E,D as te,P as ne,a as D,b as O,c as re,f as ie,g as ae,h as oe,i as k,m as se,n as A,o as ce,p as le,r as ue,s as de,t as j,u as fe}from"./tasks.BNBkrFC3.js";import{a as M,l as N,n as P,o as F,r as I,s as L,t as R}from"./DrawerField.C0MkN-LW.js";var z=e(t(),1),B=p(),pe=8e3,V=[{key:`title`,width:280,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],me={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`,cancelled:`bg-stone-100 text-stone-400 line-through`},he={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},H={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},ge={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},_e={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},ve=ue.map(e=>({value:e,label:k[e]})),U=[{value:``,label:`未设置`},...j.map(e=>({value:e,label:A[e]}))],ye=[{value:`all`,label:`全部优先级`},...j.map(e=>({value:e,label:A[e]}))],be=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],xe=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],Se=`tasks.status-tab`,Ce=`tasks.priority-filter`,we=`tasks.search`,Te=ye.map(e=>e.value);function W(e){return(0,B.jsxs)(`div`,{"data-tone":e.tone,className:`tw-stat-card flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,B.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,B.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function Ee(e){let{open:t,task:n,todos:r,onClose:i,onSaved:ee}=e,[a,o]=(0,z.useState)({title:``}),[s,c]=(0,z.useState)(``),[p,m]=(0,z.useState)(!1);(0,z.useEffect)(()=>{t&&(c(``),m(!1),o(n?{title:n.title,status:n.status,priority:n.priority,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pool`,priority:``,startDate:T(),dueDate:T()}))},[t,n]);function h(e){o(t=>({...t,...e}))}let g=se({startDate:a.startDate??``,dueDate:a.dueDate??``}),_=n?r.filter(e=>e.taskId===n.id):[],v=_.filter(e=>e.status===`done`).length,y=_.length?Math.round(v/_.length*100):0;async function b(){let e=(a.title??``).trim();if(!e)c(`请填写任务名称`);else if(a.startDate&&a.dueDate&&a.dueDate<a.startDate)c(`截止日期不能早于开始日期`);else{m(!0),c(``);try{n?await ae(n.id,a):await D([{...a,title:e}],{mode:`manual`}),await ee(),w(n?`已保存任务`:`已新建任务`,`success`),i()}catch(e){let t=e instanceof Error?e.message:String(e);c(t),w(`保存任务失败:${t}`,`error`)}finally{m(!1)}}}return(0,B.jsxs)(d,{open:t,onClose:i,transition:!0,className:`relative z-100`,children:[(0,B.jsx)(f,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,B.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,B.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,B.jsx)(u,{className:`text-base font-semibold text-stone-900`,children:n?`任务详情`:`新建任务`}),(0,B.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,B.jsx)(P,{icon:(0,B.jsx)(N,{}),label:`任务名称`,children:(0,B.jsx)(`input`,{autoFocus:!0,value:a.title,onChange:e=>h({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())},placeholder:`请输入内容`,className:R})}),(0,B.jsx)(P,{icon:(0,B.jsx)(L,{}),label:`任务状态`,children:(0,B.jsx)(I,{ariaLabel:`任务状态`,menuMinWidth:140,options:ve,value:a.status??`pool`,onChange:e=>h({status:e}),label:k[a.status??`pool`],optionDotClassName:e=>ge[e]})}),(0,B.jsx)(P,{icon:(0,B.jsx)(L,{}),label:`紧急程度`,children:(0,B.jsx)(I,{ariaLabel:`紧急程度`,menuMinWidth:140,options:U,value:a.priority??``,onChange:e=>h({priority:e}),label:a.priority?A[a.priority]:`未设置`,optionDotClassName:e=>_e[e]})}),(0,B.jsx)(P,{icon:(0,B.jsx)(M,{}),label:`开始日期`,children:(0,B.jsx)(S,{value:a.startDate??``,onChange:e=>h({startDate:e}),className:`${R} tabular-nums`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(M,{}),label:`截止日期`,children:(0,B.jsx)(S,{value:a.dueDate??``,onChange:e=>h({dueDate:e}),className:`${R} tabular-nums`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(F,{}),label:`任务周期`,children:(0,B.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:g===null?`—`:`${g} 天`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(F,{}),label:`待办进度`,children:(0,B.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_.length?`${v}/${_.length} · ${y}%`:`还没有关联待办`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(N,{}),label:`备注`,children:(0,B.jsx)(`textarea`,{value:a.note??``,onChange:e=>h({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),n&&_.length?(0,B.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,B.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,B.jsx)(`ul`,{className:`space-y-1.5`,children:_.map(e=>{let t=E(e,T());return(0,B.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,B.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${H[t]}`,children:O[t]})]},e.id)})})]}):null,s?(0,B.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:s}):null]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:i,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void b(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function De(){let[e,t]=(0,z.useState)(!1),[l,u]=(0,z.useState)(!0),[d,f]=(0,z.useState)(!0),[p,T]=(0,z.useState)(null),[E,D]=(0,z.useState)([]),[O,ue]=(0,z.useState)([]),[j,M]=(0,z.useState)(null),[N,P]=(0,z.useState)(!1),[F,I]=(0,z.useState)(()=>s(we)),[L,R]=(0,z.useState)(()=>a(Se,xe,`all`)),[H,De]=(0,z.useState)(()=>a(Ce,Te,`all`)),[Oe,G]=(0,z.useState)(null),[K,q]=(0,z.useState)(null);function ke(e){o(Se,e),R(e)}function Ae(e){c(we,e),I(e)}function je(e){o(Ce,e),De(e)}let J=(0,z.useRef)(!0),Y=v(`lh:tasks:cols:v1`,V),Me=g(`tasks`);(0,z.useEffect)(()=>(J.current=!0,()=>{J.current=!1}),[]);let X=(0,z.useCallback)(async()=>{try{let[e,t]=await Promise.all([fe(),d?te().catch(()=>[]):Promise.resolve([])]);if(!J.current)return;D(e),ue(t),M(null)}catch(e){if(!J.current)return;M(e instanceof Error?e.message:String(e))}},[d]);(0,z.useEffect)(()=>{let e=i(e=>{u(!!e.tasks),f(!!e.todos)});return n().then(()=>{u(r(`tasks`)),f(r(`todos`)),t(!0)}),e},[]),(0,z.useEffect)(()=>{e&&l&&(async()=>{let e=await de();J.current&&(e?(await X(),J.current&&T(!0)):T(!1))})()},[e,l,X]),(0,z.useEffect)(()=>{if(p!==!0)return;let e=window.setInterval(()=>void X(),pe),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[p,X]);let Ne=(0,z.useMemo)(()=>oe(O),[O]),Z=(0,z.useMemo)(()=>le(E),[E]),Pe=(0,z.useMemo)(()=>re(E,{status:L,priority:H,keyword:F}),[E,L,H,F]),Q=(0,z.useMemo)(()=>ie(Pe),[Pe]);async function $(e,t){D(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await ae(e,t);if(!J.current)return;D(t=>t.map(t=>t.id===e?n:t)),M(null)}catch(e){M(e instanceof Error?e.message:String(e)),await X()}}async function Fe(){let e=K;if(e){q(null),P(!0);try{await ce([e.id]),await Promise.all(O.filter(t=>t.taskId===e.id).map(e=>ne(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X(),w(`已删除任务「${e.title}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),w(`删除任务失败:${t}`,`error`)}finally{J.current&&P(!1)}}}return e?l?p===null?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接任务服务`,children:(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,B.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):p?(0,B.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,B.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-7`,children:[(0,B.jsx)(W,{label:`全部任务`,value:Z.total}),(0,B.jsx)(W,{label:`任务池`,value:Z.pool}),(0,B.jsx)(W,{label:`进行中`,value:Z.in_progress}),(0,B.jsx)(W,{label:`已完成`,value:Z.done}),(0,B.jsx)(W,{label:`已关闭`,value:Z.closed}),(0,B.jsx)(W,{label:`已取消`,value:Z.cancelled}),(0,B.jsx)(W,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,B.jsx)(`input`,{value:F,onChange:e=>Ae(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,B.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:be.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>ke(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${L===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,B.jsx)(C,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:ye,value:H,onChange:e=>je(e)}),(0,B.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,B.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,B.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>G({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建任务`})]})]}),j?(0,B.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1`,children:j}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>M(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,B.jsx)(`div`,{ref:Me,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,B.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:Y.tableStyle,children:[(0,B.jsx)(`colgroup`,{children:V.map(e=>(0,B.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,B.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`th`,{className:b,children:[`任务描述`,(0,B.jsx)(x,{...Y.resizeProps(`title`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,B.jsx)(x,{...Y.resizeProps(`status`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,B.jsx)(x,{...Y.resizeProps(`priority`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,B.jsx)(x,{...Y.resizeProps(`start`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,B.jsx)(x,{...Y.resizeProps(`due`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,B.jsx)(x,{...Y.resizeProps(`cycle`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,B.jsx)(x,{...Y.resizeProps(`todos`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,B.jsx)(x,{...Y.resizeProps(`progress`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,B.jsx)(x,{...Y.resizeProps(`note`)})]}),(0,B.jsx)(`th`,{"aria-hidden":`true`}),(0,B.jsx)(`th`,{className:h,children:`操作`})]})}),(0,B.jsxs)(`tbody`,{children:[Q.map(e=>{let t=se(e),n=Ne[e.id]??{total:0,done:0,percent:0};return(0,B.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,B.jsx)(`td`,{className:y,children:(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,B.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,B.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),(0,B.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,B.jsx)(C,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:ve,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${me[e.status]}`,renderTrigger:()=>(0,B.jsx)(`span`,{className:`truncate`,children:k[e.status]}),renderOptionPrefix:e=>(0,B.jsx)(`span`,{className:`h-2 w-2 rounded-full ${ge[e.value]}`})})}),(0,B.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,B.jsx)(C,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:U,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${he[e.priority]}`,renderTrigger:()=>(0,B.jsx)(`span`,{className:`truncate`,children:e.priority?A[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,B.jsx)(`span`,{className:`h-2 w-2 rounded-full ${_e[e.value]}`})})}),(0,B.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,B.jsx)(S,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,B.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,B.jsx)(S,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,B.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}),(0,B.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:d?n.total?`${n.total} 条`:`0`:(0,B.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}),(0,B.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:d?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,B.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,B.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,B.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}),(0,B.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}),(0,B.jsx)(`td`,{"aria-hidden":`true`}),(0,B.jsx)(`td`,{className:_,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M14 4h6v6`}),(0,B.jsx)(`path`,{d:`M20 4 13 11`}),(0,B.jsx)(`path`,{d:`M10 20H4v-6`}),(0,B.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,B.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>q(e),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M3 6h18`}),(0,B.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,B.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,B.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:11,className:`px-3 py-16 text-center text-sm text-stone-400`,children:E.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,B.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,B.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,B.jsx)(Ee,{open:Oe!==null,task:Oe?.task??null,todos:O,onClose:()=>G(null),onSaved:X}),(0,B.jsx)(m,{open:K!=null,title:`删除任务`,message:`删除「${K?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>q(null),onConfirm:()=>void Fe()})]}):(0,B.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,B.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:ee(`tasks`)}):(0,B.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,B.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{De as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DAIyT--R.js";import{i as r,o as i,s as a}from"./plugins.Di6uuouN.js";import{n as o,o as s,r as c,s as ee}from"./view-prefs.DkS1ldnh.js";import{i as l,n as te,r as u,t as ne}from"./dialog.DZHZCe_T.js";import{t as d}from"./jsx-runtime.DUg_B_vD.js";import{t as f}from"./ConfirmDialog.D5qXeML0.js";import{a as p,c as m,d as h,i as re,l as ie,n as g,o as ae,r as _,s as oe,t as v}from"./ColumnResize.BgYkV9Iy.js";import{n as se,t as y}from"./DatePicker.Bkl71M49.js";import{t as ce}from"./OverflowHint.pvo2Xc8R.js";import{t as b}from"./SelectDropdown.apWlFGbA.js";import{showToast as x}from"./Toast.BO2NFckG.js";import{A as S,C as le,D as ue,E as de,M as fe,N as pe,P as C,S as me,T as he,_ as ge,b as w,f as _e,g as ve,j as ye,k as be,n as T,u as xe,v as E,w as Se,x as Ce,y as D}from"./tasks.BNBkrFC3.js";import{a as O,c as k,i as we,l as A,n as j,o as M,r as N,s as P,t as F}from"./DrawerField.C0MkN-LW.js";var I=e(t(),1),L=d(),Te=8e3,Ee=[{key:`select`,width:32,min:28},{key:`index`,width:36,min:28},{key:`title`,width:300,min:160},{key:`status`,width:104,min:76},{key:`task`,width:156,min:96},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`end`,width:108,min:88},{key:`cycle`,width:64,min:52},{key:`remain`,width:86,min:64},{key:`note`,width:160,min:100},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],De=[`title`,`status`,`priority`,`linkedTask`,`startDate`,`dueDate`,`note`],Oe={in_progress:`bg-[#3370ff] text-white`,pending:`bg-stone-400 text-white`,done:`bg-[#34c724] text-white`,cancelled:`bg-stone-300 text-stone-600`,overdue:`bg-[#f54a45] text-white`},ke={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,pending:`bg-stone-100 text-stone-600`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},R={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},Ae={pending:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,overdue:`bg-[#f54a45]`,cancelled:`bg-stone-300`},je={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},z={status:`按状态分组`,priority:`按紧急程度分组`,none:`不分组`},Me=[`status`,`priority`,`none`],Ne=`todos.group-by`,Pe=[`in_progress`,`pending`,`overdue`,`done`,`cancelled`],Fe=D.map(e=>({value:e,label:w[e]})),Ie=[{value:``,label:`未设置`},...ge.map(e=>({value:e,label:E[e]}))],Le=Object.keys(z).map(e=>({value:e,label:z[e]})),Re=[{value:`all`,label:`全部紧急程度`},...ge.map(e=>({value:e,label:E[e]}))],ze=Re.map(e=>e.value),Be=`todos.priority-filter`,Ve=`todos.search`,He=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300`;function Ue(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,L.jsx)(`input`,{type:`text`,value:t,placeholder:n,autoFocus:i,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),s(),e.currentTarget.blur())},className:`${He} ${r&&!t?`text-stone-300`:``}`})}function We(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,I.useState)(!1);return a?(0,L.jsx)(Ue,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,L.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`block h-8 w-full min-w-0 truncate rounded-md border border-transparent px-1.5 text-left text-sm leading-8 text-stone-700 transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:outline-none`,children:t||(0,L.jsx)(`span`,{className:`text-stone-300`,children:`—`})})}function Ge(e){return(0,L.jsx)(y,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}function Ke(e){let{open:t,item:n,preset:r,tasks:i,tasksOn:a,onClose:o,onSaved:s}=e,[c,ee]=(0,I.useState)({title:``}),[d,f]=(0,I.useState)(``),[p,m]=(0,I.useState)(!1),[h,re]=(0,I.useState)(!0);(0,I.useEffect)(()=>{t&&(f(``),m(!1),re(!0),ee(n?{title:n.title,status:n.status,priority:n.priority,linkedTask:n.linkedTask,taskId:n.taskId,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pending`,priority:``,startDate:S(),dueDate:S(),...r}))},[t,n,r]);let ie=[{value:``,label:`不关联`},..._e(i.filter(e=>e.status!==`closed`&&e.status!==`cancelled`||e.id===n?.taskId)).map(e=>({value:e.id,label:e.title}))];function g(e){ee(t=>({...t,...e}))}let ae=ye({startDate:c.startDate??``,dueDate:c.dueDate??``}),_=pe({dueDate:c.dueDate??``}),oe=de(c.status??`pending`),v=oe?se((n&&de(n.status)?n.taskEndDate:``)||S()):``,le=_===null?``:c.status===`done`?`已完成`:c.status===`cancelled`?`已取消`:_<0?`逾期 ${Math.abs(_)} 天`:_===0?`今天截止`:`${_} 天`;async function ue(){let e=(c.title??``).trim();if(!e)f(`请填写待办名称`);else if(c.startDate&&c.dueDate&&c.dueDate<c.startDate)f(`截止日期不能早于开始日期`);else{m(!0),f(``);try{let t={...c,title:e};n?await C(n.id,t):await Ce([t],{mode:`manual`}),await s(),x(n?`已保存待办`:`已新建待办`,`success`),o()}catch(e){let t=e instanceof Error?e.message:String(e);f(t),x(`保存待办失败:${t}`,`error`)}finally{m(!1)}}}return(0,L.jsxs)(u,{open:t,onClose:o,transition:!0,className:`relative z-100`,children:[(0,L.jsx)(ne,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,L.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,L.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,L.jsx)(te,{className:`text-base font-semibold text-stone-900`,children:n?`待办详情`:`新建待办`}),(0,L.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,L.jsx)(j,{icon:(0,L.jsx)(A,{}),label:`待办名称`,children:(0,L.jsx)(`input`,{autoFocus:!0,value:c.title,onChange:e=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ue())},placeholder:`请输入内容`,className:F})}),(0,L.jsx)(j,{icon:(0,L.jsx)(P,{}),label:`待办状态`,children:(0,L.jsx)(N,{ariaLabel:`待办状态`,menuMinWidth:140,options:Fe,value:c.status??`pending`,onChange:e=>g({status:e}),label:w[c.status??`pending`],optionDotClassName:e=>Ae[e]})}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>re(e=>!e),"aria-expanded":h,className:`flex w-full items-center gap-2 px-6 py-2 text-left text-sm text-stone-600 hover:bg-stone-50`,children:[(0,L.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center text-stone-400`,children:(0,L.jsx)(k,{})}),(0,L.jsx)(`span`,{children:`任务详情`}),(0,L.jsx)(`span`,{className:`text-stone-400`,children:(0,L.jsx)(we,{open:h})})]}),h?(0,L.jsxs)(`div`,{className:`ml-[42px] border-l border-stone-100 pl-1`,children:[(0,L.jsx)(j,{icon:(0,L.jsx)(k,{}),label:`所属任务`,children:a?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{flat:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:ie,value:c.taskId??``,onChange:e=>{let t=i.find(t=>t.id===e);g({taskId:e,linkedTask:t?.title??``,...t?{priority:t.priority}:{}})},renderTrigger:()=>(0,L.jsx)(ce,{text:c.taskId?i.find(e=>e.id===c.taskId)?.title??``:c.linkedTask||`请选择任务`,className:`min-w-0 truncate ${c.taskId||c.linkedTask?`text-stone-800`:`text-stone-400`}`})}),i.length===0?(0,L.jsx)(`p`,{className:`mt-1 px-2 text-xs text-stone-400`,children:`任务管理里还没有任务,可到「任务管理」新建后再关联。`}):null]}):(0,L.jsx)(`div`,{className:`flex h-9 items-center rounded-md bg-stone-50 px-2 text-sm text-stone-400`,children:(0,L.jsx)(`span`,{className:`truncate`,children:c.linkedTask?`${c.linkedTask}(任务管理插件未启用)`:`任务管理插件未启用,无法关联任务`})})}),(0,L.jsx)(j,{icon:(0,L.jsx)(P,{}),label:`重要紧急程度`,children:(()=>{let e=c.taskId?i.find(e=>e.id===c.taskId):void 0;return e?(0,L.jsxs)(`div`,{className:`flex h-9 items-center gap-2 px-2 text-sm`,children:[(0,L.jsx)(`span`,{className:e.priority?`text-stone-800`:`text-stone-400`,children:e.priority?T[e.priority]:`任务未设置`}),(0,L.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`跟随所属任务`})]}):(0,L.jsx)(N,{ariaLabel:`重要紧急程度`,menuMinWidth:140,options:Ie,value:c.priority??``,onChange:e=>g({priority:e}),label:c.priority?E[c.priority]:`未设置`,optionDotClassName:e=>je[e]})})()}),(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`结束日期`,children:(0,L.jsxs)(`div`,{className:`flex h-9 items-center px-2 text-sm tabular-nums`,"aria-readonly":`true`,children:[v?(0,L.jsx)(`span`,{className:`text-stone-800`,children:v}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`}),(0,L.jsx)(`span`,{className:`ml-2 text-[11px] text-stone-400`,children:oe?`按完成日期自动记录`:`状态为已完成 / 已取消时自动记录`})]})})]}):null,(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`开始日期`,children:(0,L.jsx)(y,{value:c.startDate??``,onChange:e=>g({startDate:e}),className:`${F} tabular-nums`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`截止日期`,children:(0,L.jsx)(y,{value:c.dueDate??``,onChange:e=>g({dueDate:e}),className:`${F} tabular-nums`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(M,{}),label:`待办周期`,children:(0,L.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:ae===null?`—`:`${ae} 天`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(M,{}),label:`剩余天数`,children:(0,L.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:le||`—`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(A,{}),label:`备注`,children:(0,L.jsx)(`textarea`,{value:c.note??``,onChange:e=>g({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),d?(0,L.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:d}):null]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:o,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>void ue(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function B(){let[e,t]=(0,I.useState)(!1),[l,te]=(0,I.useState)(!0),[u,ne]=(0,I.useState)(null),[d,T]=(0,I.useState)([]),[D,O]=(0,I.useState)([]),[k,we]=(0,I.useState)(!1),[A,j]=(0,I.useState)(null),[M,N]=(0,I.useState)(!1),[P,F]=(0,I.useState)(()=>c(Ve)),[z,He]=(0,I.useState)(()=>o(Be,ze,`all`)),[B,qe]=(0,I.useState)(()=>o(Ne,Me,`status`)),[Je,Ye]=(0,I.useState)({}),[V,Xe]=(0,I.useState)({});function Ze(e){s(Ne,e),qe(e)}function Qe(e){s(Be,e),He(e)}function $e(e){ee(Ve,e),F(e)}let[et,tt]=(0,I.useState)({}),[H,U]=(0,I.useState)(null),[W,G]=(0,I.useState)(null),[nt,rt]=(0,I.useState)(!1),[it,at]=(0,I.useState)(null),K=(0,I.useRef)(!0),ot=(0,I.useRef)(!1),st=(0,I.useRef)(!1),q=ie(`lh:todos:cols:v1`,Ee),ct=h(`todos`),lt=H!==null,ut=(0,I.useRef)(H);ut.current=H;let dt=(0,I.useRef)(!1),ft=(0,I.useRef)(async()=>{});ft.current=bt,(0,I.useEffect)(()=>(K.current=!0,()=>{K.current=!1}),[]),(0,I.useEffect)(()=>{if(!lt)return;let e=e=>{let t=e.target;if(!(t instanceof Element)||t.closest(`.tw-new-row`)||t.closest(`.tw-date-panel`)||t.closest(`.tw-select-menu`))return;let n=ut.current;if(!n)return;if(n.title.trim()){ft.current();return}let r=S();!n.note.trim()&&!n.taskId&&n.status===n.baseStatus&&n.priority===n.basePriority&&n.startDate===r&&n.dueDate===r&&U(null)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[lt]);let J=(0,I.useCallback)(async()=>{try{let[e,t]=await Promise.all([ue(),k?xe().catch(()=>[]):Promise.resolve([])]);if(!K.current)return;let n=t;if(!ot.current&&k){ot.current=!0;let r=new Set(e.filter(e=>e.status===`pending`||e.status===`in_progress`).map(e=>e.taskId).filter(Boolean)),i=t.filter(e=>r.has(e.id)&&(e.status===`pool`||e.status===`done`));if(i.length){let e=await Promise.all(i.map(e=>ve(e.id,{status:`in_progress`}).catch(()=>null))),r=new Map(e.filter(e=>!!e).map(e=>[e.id,e]));n=t.map(e=>r.get(e.id)??e)}}T(e),O(n),j(null)}catch(e){if(!K.current)return;j(e instanceof Error?e.message:String(e))}},[k]);(0,I.useEffect)(()=>{let e=i(e=>{te(!!e.todos),we(!!e.tasks)});return n().then(()=>{te(r(`todos`)),we(r(`tasks`)),t(!0)}),e},[]),(0,I.useEffect)(()=>{e&&l&&(async()=>{let e=await Se();K.current&&(e?(await J(),K.current&&ne(!0)):ne(!1))})()},[e,l,J]),(0,I.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{st.current||J()},Te),t=()=>{st.current||J()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,J]),(0,I.useEffect)(()=>{if(!k||u!==!0||D.length===0)return;let e=d.filter(e=>!e.taskId&&e.linkedTask.trim());if(!e.length)return;let t=!1;return(async()=>{let n=[];for(let t of e){let e=D.find(e=>e.title.trim()===t.linkedTask.trim());if(e)try{n.push(await C(t.id,{taskId:e.id}))}catch{}}!t&&n.length&&T(e=>e.map(e=>n.find(t=>t.id===e.id)??e))})(),()=>{t=!0}},[k,u,d,D]);function pt(e,t,n){tt(r=>({...r,[e]:{...r[e],[t]:n}}))}function Y(e){tt(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}let mt=(0,I.useMemo)(()=>[{value:``,label:`不关联`},..._e(D.filter(e=>e.status!==`closed`&&e.status!==`cancelled`)).map(e=>({value:e.id,label:e.title}))],[D]);function ht(e){return e.taskId?D.find(t=>t.id===e.taskId)?.title??e.linkedTask:e.linkedTask}function gt(e){return e.taskId?D.find(t=>t.id===e.taskId):void 0}function _t(e){let t=gt(e);return t?t.priority:e.priority}async function X(e,t){T(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await C(e,t);if(!K.current)return;T(t=>t.map(t=>t.id===e?n:t)),j(null),t.taskId&&await J()}catch(e){j(e instanceof Error?e.message:String(e)),await J()}}async function vt(e){let t=et[e],n=d.find(t=>t.id===e);if(!t||!n)return;let r={},i=n;for(let e of De){let n=t[e];n!==void 0&&String(i[e]??``)!==String(n)&&(r[e]=n)}if(!Object.keys(r).length)Y(e);else if(typeof r.title==`string`&&!r.title.trim())j(`待办名称不能为空`),Y(e);else try{let t=await C(e,r);if(!K.current)return;T(n=>n.map(n=>n.id===e?t:n)),tt(t=>{let n=t[e];if(!n)return t;let i={...n};for(let e of Object.keys(r))String(i[e]??``)===String(r[e]??``)&&delete i[e];if(!Object.keys(i).length){let n={...t};return delete n[e],n}return{...t,[e]:i}}),j(null)}catch(t){j(t instanceof Error?t.message:String(t)),Y(e)}}function yt(e){let t=e.newStatus??`pending`,n=e.newPriority??``;U({groupKey:e.key,title:``,status:t,priority:n,taskId:``,startDate:S(),dueDate:S(),note:``,baseStatus:t,basePriority:n}),Ye(t=>({...t,[e.key]:!1}))}async function bt(){let e=ut.current;if(!e||dt.current)return;let t=e.title.trim();if(t){dt.current=!0,rt(!0);try{let n=D.find(t=>t.id===e.taskId);await Ce([{title:t,status:e.status,priority:e.priority,taskId:e.taskId,linkedTask:n?.title??``,startDate:e.startDate,dueDate:e.dueDate,note:e.note}],{mode:`manual`}),ut.current===e&&U(null),j(null),await J()}catch(e){j(e instanceof Error?e.message:String(e))}finally{dt.current=!1,K.current&&rt(!1)}}}async function xt(){let e=W;if(e){G(null),N(!0),j(null);try{await me(e.map(e=>e.id)),Xe({}),await J(),x(e.length>1?`已删除 ${e.length} 条待办`:`已删除待办`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),x(`删除待办失败:${t}`,`error`)}finally{K.current&&N(!1)}}}let Z=S(),St=(0,I.useMemo)(()=>d.map(e=>{let t=e.taskId?D.find(t=>t.id===e.taskId):void 0;return t?{...e,priority:t.priority}:e}),[d,D]),Ct=(0,I.useMemo)(()=>he(St,{status:`all`,priority:z,keyword:P,today:Z}),[St,z,P,Z]),Q=(0,I.useMemo)(()=>be(Ct),[Ct]),wt=(0,I.useMemo)(()=>B===`none`?[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:Q}]:B===`priority`?[...ge,``].map(e=>({key:`priority:${e||`none`}`,label:e?E[e]:`未设置`,pill:e?R[e]:`bg-stone-300 text-stone-600`,items:Q.filter(t=>t.priority===e),newPriority:e})):Pe.map(e=>({key:`status:${e}`,label:w[e],pill:Oe[e],items:Q.filter(t=>le(t,Z)===e),newStatus:e===`overdue`?`pending`:e})),[B,Q,Z]).filter(e=>e.items.length>0||H?.groupKey===e.key&&!!H),Tt=Object.keys(V).filter(e=>V[e]),$=(0,I.useMemo)(()=>{let e={total:d.length,pending:0,in_progress:0,done:0,overdue:0};for(let t of d){let n=le(t,Z);n===`overdue`?e.overdue+=1:n===`pending`?e.pending+=1:n===`in_progress`?e.in_progress+=1:n===`done`&&(e.done+=1)}return e},[d,Z]);return e?l?u===null?(0,L.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接待办服务`,children:(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,L.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,L.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,L.jsx)(`span`,{className:`font-medium text-stone-800`,children:$.total}),` 条`,(0,L.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 待开始 `,$.pending,` · 进行中 `,$.in_progress,` · 已完成 `,$.done,$.overdue?` · 已延期 ${$.overdue}`:``]})]}),(0,L.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`input`,{value:P,onChange:e=>$e(e.target.value),placeholder:`搜索待办…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,L.jsx)(b,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Le,value:B,onChange:e=>Ze(e)}),(0,L.jsx)(b,{flat:!0,className:`w-[136px]`,ariaLabel:`紧急程度筛选`,options:Re,value:z,onChange:e=>Qe(e)}),(0,L.jsx)(`button`,{type:`button`,disabled:M||Tt.length===0,onClick:()=>G(d.filter(e=>V[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,L.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>at({item:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建待办`})]})]}),A?(0,L.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1`,children:A}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>j(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,L.jsx)(`div`,{ref:ct,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{st.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{st.current=!!document.activeElement?.closest(`.tw-todo-table`)},0)},children:(0,L.jsxs)(`table`,{className:`tw-todo-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,L.jsx)(`colgroup`,{children:Ee.map(e=>(0,L.jsx)(`col`,{style:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,L.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{className:p,children:(0,L.jsx)(`input`,{type:`checkbox`,"aria-label":`全选可见待办`,checked:Q.length>0&&Q.every(e=>V[e.id]),onChange:e=>{let t=e.target.checked;Xe(e=>{let n={...e};for(let e of Q)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,L.jsx)(`th`,{className:oe,style:{"--tw-sticky-left":`32px`},"aria-label":`行号`}),(0,L.jsxs)(`th`,{className:ae,style:{"--tw-sticky-left":`68px`},children:[`待办名称`,(0,L.jsx)(v,{...q.resizeProps(`title`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办状态`,(0,L.jsx)(v,{...q.resizeProps(`status`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属任务`,(0,L.jsx)(v,{...q.resizeProps(`task`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,L.jsx)(v,{...q.resizeProps(`priority`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,L.jsx)(v,{...q.resizeProps(`start`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,L.jsx)(v,{...q.resizeProps(`due`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`结束日期`,(0,L.jsx)(v,{...q.resizeProps(`end`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`周期`,(0,L.jsx)(v,{...q.resizeProps(`cycle`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`剩余`,(0,L.jsx)(v,{...q.resizeProps(`remain`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,L.jsx)(v,{...q.resizeProps(`note`)})]}),(0,L.jsx)(`th`,{"aria-hidden":`true`}),(0,L.jsx)(`th`,{className:m,children:`操作`})]})}),wt.map(e=>{let t=Je[e.key]===!0;return(0,L.jsxs)(`tbody`,{children:[(0,L.jsx)(`tr`,{className:`bg-white`,children:(0,L.jsx)(`td`,{colSpan:14,className:`px-2 py-0 pt-3 pb-1.5`,children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>Ye(n=>({...n,[e.key]:!t})),className:`flex items-center gap-2 rounded-md px-1 py-0.5 text-left hover:bg-stone-50`,"aria-expanded":!t,children:[(0,L.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`text-stone-400 transition-transform ${t?`-rotate-90`:``}`,children:(0,L.jsx)(`path`,{d:`m6 9 6 6 6-6`})}),(0,L.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs font-medium ${e.pill}`,children:e.label}),(0,L.jsxs)(`span`,{className:`text-xs text-stone-400 tabular-nums`,children:[e.items.length,` 条记录`]})]})})}),t?null:e.items.map((e,t)=>{let n=et[e.id]??{},r={...e,...n},i=le(r,Z),a=ye(r),o=pe(r,Z),s=o===null?`—`:r.status===`done`?`已完成`:r.status===`cancelled`?`已取消`:o<0?`逾期 ${Math.abs(o)} 天`:o===0?`今天截止`:`${o} 天`;return(0,L.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,L.jsx)(`td`,{className:g,children:(0,L.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.title}`,checked:!!V[e.id],onChange:t=>Xe(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,L.jsx)(`td`,{className:`${_} text-xs text-stone-400 tabular-nums`,style:{"--tw-sticky-left":`32px`},children:t+1}),(0,L.jsx)(`td`,{className:g,style:{"--tw-sticky-left":`68px`},children:(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.source===`ai`?(0,L.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,title:`AI 记录`,children:`AI`}):null,(0,L.jsx)(Ue,{value:r.title,placeholder:`输入待办名称`,onChange:t=>pt(e.id,`title`,t),onCommit:()=>void vt(e.id),onCancel:()=>Y(e.id)})]})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Fe,value:e.status,onChange:t=>void X(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ke[i]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`truncate`,children:w[i]}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ae[e.value]}`})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,L.jsx)(b,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:mt,value:r.taskId,onChange:t=>{let n=D.find(e=>e.id===t);X(e.id,{taskId:t,linkedTask:n?.title??``,...n?{priority:n.priority}:{}})},triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>(0,L.jsx)(ce,{text:ht(r)||`未关联`,className:`min-w-0 truncate ${ht(r)?`text-stone-800`:`text-stone-300`}`})}):(0,L.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:ht(r)?`${ht(r)} · 插件未启用`:`任务管理插件未启用`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:gt(r)?(0,L.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${R[_t(r)]??`text-stone-300`}`,children:_t(r)?E[_t(r)]:`未设置`}):(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ie,value:e.priority,onChange:t=>void X(e.id,{priority:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${R[e.priority]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`truncate`,children:e.priority?E[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${je[e.value]}`})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ge,{value:r.startDate,onChange:t=>void X(e.id,{startDate:t})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ge,{value:r.dueDate,onChange:t=>void X(e.id,{dueDate:t})})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:fe(r)?(0,L.jsx)(`span`,{className:`text-stone-500`,children:se(fe(r))}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:a===null?`—`:`${a} 天`}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums ${o!==null&&o<0&&i!==`done`&&i!==`cancelled`?`font-medium text-[#c02a26]`:`text-stone-500`}`,children:s}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(We,{value:r.note,onChange:t=>pt(e.id,`note`,t),onCommit:()=>void vt(e.id),onCancel:()=>Y(e.id)})}),(0,L.jsx)(`td`,{"aria-hidden":`true`}),(0,L.jsx)(`td`,{className:re,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>at({item:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M14 4h6v6`}),(0,L.jsx)(`path`,{d:`M20 4 13 11`}),(0,L.jsx)(`path`,{d:`M10 20H4v-6`}),(0,L.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,L.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>G([e]),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M3 6h18`}),(0,L.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,L.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,L.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),t?null:H?.groupKey===e.key?(0,L.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:e.items.length+1}),(0,L.jsx)(`td`,{className:_,children:(0,L.jsx)(`input`,{autoFocus:!0,value:H.title,disabled:nt,placeholder:`输入待办名称,回车或点空白处保存`,onChange:e=>U(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),bt()):e.key===`Escape`&&(e.preventDefault(),U(null))},className:`h-8 w-full truncate rounded-md border border-[#3370ff]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#3370ff]`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Fe,value:H.status,onChange:e=>U(t=>t&&{...t,status:e}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ke[H.status]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`truncate`,children:w[H.status]})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,L.jsx)(b,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:mt,value:H.taskId,onChange:e=>U(t=>{if(!t)return t;let n=D.find(t=>t.id===e);return{...t,taskId:e,...n?{priority:n.priority}:{}}}),triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>{let e=D.find(e=>e.id===H.taskId);return(0,L.jsx)(ce,{text:e?.title||`未关联`,className:`min-w-0 truncate ${e?`text-stone-800`:`text-stone-300`}`})}}):(0,L.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:`任务管理插件未启用`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(()=>{let e=D.find(e=>e.id===H.taskId);return e?(0,L.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${R[e.priority]??`text-stone-300`}`,children:e.priority?E[e.priority]:`未设置`}):(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ie,value:H.priority,onChange:e=>U(t=>t&&{...t,priority:e}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${R[H.priority]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`truncate`,children:H.priority?E[H.priority]:`未设置`})})})()}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(y,{value:H.startDate,onChange:e=>U(t=>t&&{...t,startDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(y,{value:H.dueDate,onChange:e=>U(t=>t&&{...t,dueDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:de(H.status)?(0,L.jsx)(`span`,{className:`text-stone-500`,children:se(S())}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(`input`,{value:H.note,disabled:nt,placeholder:`—`,onChange:e=>U(t=>t&&{...t,note:e.target.value}),className:`h-8 w-full truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors placeholder:text-stone-300 hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{"aria-hidden":`true`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`})]}):(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{className:`px-2 py-0.5`}),(0,L.jsx)(`td`,{className:`px-1 py-0.5`}),(0,L.jsx)(`td`,{className:`px-1 py-0.5`,colSpan:12,children:(0,L.jsxs)(`button`,{type:`button`,disabled:nt,onClick:()=>yt(e),className:`flex items-center gap-1 rounded px-1 py-0.5 text-xs text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[(0,L.jsx)(`span`,{className:`text-sm leading-none`,children:`+`}),`新增记录`]})})]})]},e.key)}),wt.length===0?(0,L.jsx)(`tbody`,{children:(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:14,className:`px-3 py-16 text-center text-sm text-stone-400`,children:d.length===0?`还没有待办`:`没有匹配的待办,试试调整搜索或筛选`})})}):null]})}),(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,L.jsxs)(`span`,{children:[`共 `,Q.length,` 条`,Tt.length?` · 已选 ${Tt.length}`:``]}),(0,L.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`点击单元格直接编辑,回车或点空白处保存`})]}),(0,L.jsx)(Ke,{open:it!==null,item:it?.item??null,preset:it?.preset,tasks:D,tasksOn:k,onClose:()=>at(null),onSaved:J}),(0,L.jsx)(f,{open:W!=null,title:W&&W.length>1?`批量删除`:`删除待办`,message:W&&W.length>1?`确认删除已选中的 ${W.length} 条待办?此操作不可恢复。`:`删除「${W?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>G(null),onConfirm:()=>void xt()})]}):(0,L.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`待办事项需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,L.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`todos`)}):(0,L.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,L.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{B as default};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DAIyT--R.js";import{a as r,r as i,s as a,t as o}from"./view-prefs.DkS1ldnh.js";import{i as s,n as c,r as l,t as u}from"./dialog.DZHZCe_T.js";import{i as ee,n as d,r as te,t as f}from"./menu.Dnrpz489.js";import{t as ne}from"./jsx-runtime.DUg_B_vD.js";import{t as re}from"./ConfirmDialog.D5qXeML0.js";import{t as p}from"./OverflowHint.pvo2Xc8R.js";import{t as ie}from"./SelectDropdown.apWlFGbA.js";import{showToast as ae}from"./Toast.BO2NFckG.js";import{c as oe}from"./project-docs.DAw9bzgk.js";import{s as se}from"./llm.BuR7z55C.js";import{u as ce}from"./prompts-meta.C_MeYq8G.js";import{m as le,p as ue,u as de}from"./settings.DbhUT6Ao.js";import{n as fe,t as pe}from"./PromptMountDialog.CpTT6L0a.js";import{a as me,n as m,r as h,t as he}from"./ui-auto-prompt.l_EXfDs5.js";import{S as ge,_ as _e,a as ve,b as g,c as ye,d as be,f as xe,h as Se,i as Ce,l as we,m as Te,n as Ee,o as De,p as Oe,r as ke,t as Ae,u as _,v,x as je,y as Me}from"./ui-auto.BmC9JJ_X.js";import{t as Ne}from"./hydrate-cache.C0F0L04c.js";import{S as y,d as Pe,g as b,k as Fe,l as Ie,m as Le}from"./PmShared.Bzn6AGsN.js";var x=e(t(),1),Re=`${Ee}/agent`;async function S(e,t){let n=await fetch(`${Re}${e}`,{...t,headers:{"Content-Type":`application/json`,...t?.headers??{}}}),r=await n.text(),i=null;try{i=r?JSON.parse(r):null}catch{i=null}if(!n.ok){let e=(i&&typeof i==`object`&&`error`in i?String(i.error):``)||r.slice(0,300)||`请求失败(${n.status})`;throw Error(e)}return i??{}}async function ze(e){return S(`/prepare`,{method:`POST`,body:JSON.stringify(e)})}async function Be(e,t){return S(`/open`,{method:`POST`,body:JSON.stringify({sessionId:e,url:t})})}async function C(e,t={}){return S(`/snapshot`,{method:`POST`,body:JSON.stringify({sessionId:e,...t})})}async function w(e,t){return S(`/action`,{method:`POST`,body:JSON.stringify({sessionId:e,...t})})}async function T(e,t={}){return S(`/wait`,{method:`POST`,body:JSON.stringify({sessionId:e,...t})})}async function Ve(e){return S(`/console`,{method:`POST`,body:JSON.stringify({sessionId:e})})}async function He(e){return S(`/network`,{method:`POST`,body:JSON.stringify({sessionId:e})})}async function Ue(e,t,n){return S(`/probe`,{method:`POST`,body:JSON.stringify({sessionId:e,ref:t,stepId:n})})}async function We(e,t){return S(`/screenshot`,{method:`POST`,body:JSON.stringify({sessionId:e,label:t})})}async function Ge(e){await S(`/close`,{method:`POST`,body:JSON.stringify({sessionId:e})})}async function E(e){return S(`/save`,{method:`POST`,body:JSON.stringify(e)})}async function Ke(e,t,n={}){return S(`/emit`,{method:`POST`,body:JSON.stringify({ir:e,target:t,...n})})}async function D(e,t,n){return S(`/verify`,{method:`POST`,body:JSON.stringify({sessionId:e,ir:t,target:n,timeoutMs:18e4})})}async function qe(e){return S(`/write`,{method:`POST`,body:JSON.stringify(e)})}async function Je(e){return S(`/sessions?projectId=${encodeURIComponent(e)}`)}async function O(e){return S(`/session?id=${encodeURIComponent(e)}`)}async function Ye(e,t){return S(`/debug`,{method:`POST`,body:JSON.stringify({sessionId:e,mode:t})})}async function Xe(e){return S(`/debug/stop`,{method:`POST`,body:JSON.stringify({sessionId:e})})}async function Ze(e){return S(`/changes?sessionId=${encodeURIComponent(e)}`)}async function Qe(e){return S(`/reveal`,{method:`POST`,body:JSON.stringify(e)})}var k=null;async function $e(e=!1){return(!k||e)&&(k=S(`/apps`).then(e=>({apps:e.apps??[],defaultId:e.defaultId??``})).catch(e=>{throw k=null,e})),k}async function et(e,t){return S(`/run-file`,{method:`POST`,body:JSON.stringify({sessionId:e,path:t,timeoutMs:18e4})})}async function tt(e){return S(`/draft/clean`,{method:`POST`,body:JSON.stringify({sessionId:e})})}var A={type:`string`,description:`快照里的 ref,例如 d1-e12。页面导航后会失效。`},nt={type:`function`,function:{name:`ui_plan_steps`,description:`提交整份步骤计划(人可读的动作 + 目标描述,不含定位器)。这一步只做测试设计,不会打开浏览器。`,parameters:{type:`object`,properties:{title:{type:`string`,description:`用例标题,中文即可`},steps:{type:`array`,description:`按执行顺序排列的计划步骤`,items:{type:`object`,properties:{action:{type:`string`,enum:[`goto`,`click`,`fill`,`select`,`press`,`hover`,`expect`,`expectUrl`,`wait`],description:`测试动作;不要写「截图」——截图是探索时给人看的,不是测试步骤`},target:{type:`string`,description:`给人看的目标描述,例如「右上角的登录按钮」「用户名输入框」`},value:{type:`string`,description:"输入内容 / 选项;账号密码等占位数据写成 ${ENV_NAME}"},url:{type:`string`,description:`goto / expectUrl 的地址,相对路径即可`},note:{type:`string`,description:`补充说明,例如断言什么结果`}},required:[`action`,`target`]}}},required:[`steps`]}}},rt=[nt],it=[nt,{type:`function`,function:{name:`ui_browser_open`,description:`在浏览器里打开一个地址(相对地址会用 baseURL 拼接),返回页面快照。`,parameters:{type:`object`,properties:{url:{type:`string`,description:`绝对地址或 / 开头的相对地址`}},required:[`url`]}}},{type:`function`,function:{name:`ui_browser_snapshot`,description:`重新获取当前页面快照。页面变化较大、或 ref 不确定时用。`,parameters:{type:`object`,properties:{depth:{type:`number`,description:`快照深度,默认 6,越大越啰嗦`},targetRef:{type:`string`,description:`只看某个元素的子树`}}}}},{type:`function`,function:{name:`ui_browser_click`,description:`点击一个元素。成功后会自动返回新快照。`,parameters:{type:`object`,properties:{ref:A,note:{type:`string`,description:`这一步在做什么`}},required:[`ref`]}}},{type:`function`,function:{name:`ui_browser_fill`,description:`填写输入框(会先清空已有内容)。`,parameters:{type:`object`,properties:{ref:A,text:{type:`string`,description:"要填入的内容;占位数据用 ${ENV_NAME} 表示环境变量"},note:{type:`string`}},required:[`ref`,`text`]}}},{type:`function`,function:{name:`ui_browser_select`,description:`选择下拉框选项(按 value 或可见文本)。`,parameters:{type:`object`,properties:{ref:A,value:{type:`string`},note:{type:`string`}},required:[`ref`,`value`]}}},{type:`function`,function:{name:`ui_browser_press`,description:`按一个键,例如 Enter / Tab / Escape。`,parameters:{type:`object`,properties:{key:{type:`string`},ref:{type:`string`}},required:[`key`]}}},{type:`function`,function:{name:`ui_browser_hover`,description:`悬停到元素上(用于展开菜单)。`,parameters:{type:`object`,properties:{ref:A,note:{type:`string`}},required:[`ref`]}}},{type:`function`,function:{name:`ui_browser_back`,description:`浏览器后退一步。`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`ui_browser_wait`,description:`等待:给 text 时等到页面出现该文案(比死等毫秒可靠),否则等待指定毫秒。返回等待后的快照。`,parameters:{type:`object`,properties:{text:{type:`string`,description:`要等待出现的可见文案`},ms:{type:`number`,description:`没有 text 时等待的毫秒数`},timeout:{type:`number`,description:`等待 text 的超时毫秒数,默认 15000`}}}}},{type:`function`,function:{name:`ui_browser_screenshot`,description:`截一张当前页面图,给用户看(模型看不到图片内容)。`,parameters:{type:`object`,properties:{label:{type:`string`,description:`截图标签,例如 after-login`}}}}},{type:`function`,function:{name:`ui_browser_console`,description:`读取浏览器控制台里的 error / warning / pageerror(排查偶发失败用)。`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`ui_browser_network`,description:`读取最近的失败请求(状态码 ≥ 400 或请求失败),用来判断是不是接口挂了。`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`ui_locator_probe`,description:`把一个 ref 转成可写进脚本的定位器,并校验唯一性。写步骤之前,对每个要操作的元素都调用一次。`,parameters:{type:`object`,properties:{ref:A,stepId:{type:`string`,description:`可选:左侧计划里的步骤 id(如 p2)。传了会把定位器回填到该步骤。`}},required:[`ref`]}}},{type:`function`,function:{name:`ui_test_set_steps`,description:`提交 / 替换整份测试步骤(IR)。每次提交都会刷新右侧代码预览。先探索、再提交,不要凭想象写定位器。`,parameters:{type:`object`,properties:{title:{type:`string`,description:`用例标题,中文即可`},steps:{type:`array`,description:`按执行顺序排列的步骤`,items:{type:`object`,properties:{action:{type:`string`,enum:[`goto`,`click`,`fill`,`select`,`press`,`hover`,`expect`,`expectUrl`,`wait`,`screenshot`]},locator:{type:`object`,description:`定位器。首选 ui_locator_probe 给出的 recommended,不要自己拼长 CSS`,properties:{kind:{type:`string`,enum:[`testid`,`role`,`label`,`placeholder`,`text`,`attr`,`css`]},role:{type:`string`},name:{type:`string`},value:{type:`string`},attr:{type:`string`},exact:{type:`boolean`},nth:{type:`number`,description:`同名元素有多个时取第几个(0 = 第一个)。用 ui_locator_probe 返回的 nth,不要自己猜`}},required:[`kind`]},url:{type:`string`},value:{type:`string`,description:`输入内容 / 选项值 / 截图名`},key:{type:`string`},text:{type:`string`,description:`expect 时要断言的文本`},state:{type:`string`,enum:[`visible`,`hidden`]},ms:{type:`number`},note:{type:`string`},planStepId:{type:`string`,description:`可选:对应左侧计划步骤 id,便于逐条勾掉计划`}},required:[`action`]}}},required:[`steps`]}}},{type:`function`,function:{name:`ui_test_get_steps`,description:`读取当前已提交的步骤,改之前先看一眼。`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`ui_test_verify`,description:`在临时目录试跑当前步骤对应的脚本,返回是否通过和日志尾部。`,parameters:{type:`object`,properties:{}}}}],at=`浏览器已被关闭,这一轮探索已结束`;function ot(e){if(!e||!e.includes(`error`))return!1;let t;try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!=`object`)return!1;let n=String(t.error??``);return n.includes(`浏览器已被关闭`)||n.includes(`浏览器进程已退出`)||n.includes(`Target page, context or browser has been closed`)}var j=(e,t)=>e.length>t?`${e.slice(0,t)}…(已截断)`:e;async function st(e,t,n){let r={};try{r=JSON.parse(t||`{}`)}catch{return JSON.stringify({error:`工具参数不是合法 JSON`})}let i=n.sessionId,a=e=>typeof r[e]==`string`?String(r[e]):``;try{if(e===`ui_plan_steps`){let e=Array.isArray(r.steps)?r.steps:[];if(!e.length){let e=await O(i).then(e=>e.session.plan??[]).catch(()=>[]);return JSON.stringify({ok:!0,stepCount:e.length,plan:e.map(e=>({id:e.id,action:e.action,target:e.target})),note:`没有提交新步骤,计划保持不变。`})}let t=(await E({sessionId:i,title:a(`title`)||void 0,plan:e,mergePlan:!0})).session.plan??[];return n.onPlan?.(t),JSON.stringify({ok:!0,stepCount:t.length,plan:t.map(e=>({id:e.id,action:e.action,target:e.target})),note:`计划已保存,用户可以在左侧调整。接下来开始探索:逐个 probe 并回填定位器。`})}if(e===`ui_browser_open`){let e=await Be(i,a(`url`));return JSON.stringify({url:e.url,title:e.title,elements:e.count,truncated:e.truncated,snapshot:j(e.snapshot,12e3)})}if(e===`ui_browser_snapshot`){let e=await C(i,{depth:Number(r.depth)||void 0,targetRef:a(`targetRef`)||void 0});return JSON.stringify({url:e.url,title:e.title,elements:e.count,truncated:e.truncated,snapshot:j(e.snapshot,12e3)})}if(e===`ui_browser_click`||e===`ui_browser_fill`||e===`ui_browser_select`||e===`ui_browser_hover`){let t=await w(i,{action:e.replace(`ui_browser_`,``),ref:a(`ref`),text:a(`text`),value:a(`value`),note:a(`note`)});return JSON.stringify({ok:!0,action:t.action,url:t.url,snapshot:j(t.snapshot,9e3)})}if(e===`ui_browser_press`){let e=await w(i,{action:`press`,ref:a(`ref`),key:a(`key`)});return JSON.stringify({ok:!0,url:e.url,snapshot:j(e.snapshot,9e3)})}if(e===`ui_browser_back`){let e=await w(i,{action:`back`});return JSON.stringify({ok:!0,url:e.url,snapshot:j(e.snapshot,9e3)})}if(e===`ui_browser_wait`){let e=await T(i,{text:a(`text`)||void 0,ms:Number(r.ms)||void 0,timeout:Number(r.timeout)||void 0});return JSON.stringify({ok:!0,action:e.action,url:e.url,snapshot:j(e.snapshot,9e3)})}if(e===`ui_browser_screenshot`){let e=await We(i,a(`label`)||`snapshot`);return n.onShot?.(e.url),JSON.stringify({ok:!0,url:e.url,note:`截图已显示在面板里;你看不到图片内容,需要判断结构请用快照。`})}if(e===`ui_browser_console`){let e=(await Ve(i)).messages??[];return JSON.stringify(e.length?{count:e.length,messages:e.slice(-20)}:{count:0})}if(e===`ui_browser_network`){let e=(await He(i)).requests??[];return JSON.stringify(e.length?{count:e.length,requests:e.slice(-20)}:{count:0})}if(e===`ui_locator_probe`){let e=a(`ref`);if(!e)return JSON.stringify({error:`缺少 ref`});let t=a(`stepId`),r=await Ue(i,e,t||void 0);return t&&r.plan&&n.onPlan?.(r.plan),JSON.stringify({ref:r.ref,element:r.element,confidence:r.confidence,recommended:r.recommended,fragile:!!r.fragile,warning:r.warning??``,candidates:r.candidates.slice(0,3),boundStep:r.planStep?{id:r.planStep.id,status:r.planStep.status}:void 0,note:r.confidence===`high`?`定位器唯一且指向同一元素,可以写进步骤`:r.recommended?`能用但不稳:${r.warning||`同名元素较多`}。照抄 recommended(含 nth),并补一条结果断言`:`没有唯一候选:换一个更具体的元素,或改成对结果文案的 expect`})}if(e===`ui_test_set_steps`){let e=Array.isArray(r.steps)?r.steps:[],t={title:a(`title`)||`未命名流程`,target:n.target,steps:e},o=await E({sessionId:i,title:t.title,ir:t}),s=o.session.ir??t,c=t.steps.length-s.steps.length;return n.onIr?.(s),n.onCode?.(o.code,o.suggestedPath),JSON.stringify({ok:!0,title:s.title,stepCount:s.steps.length,previewPath:o.suggestedPath,note:c?`步骤已保存,但有 ${c} 步被丢掉(动作不支持或没带 locator)。用 ui_test_get_steps 核对后重新提交;不要自己试跑,试跑由用户确认代码后手动发起。`:`步骤已保存,右侧代码预览已刷新。不要自己试跑:试跑由用户确认代码后手动发起。`})}if(e===`ui_test_get_steps`){let e=await O(i);return JSON.stringify({title:e.session.ir?.title??``,steps:e.session.ir?.steps??[],suggestedPath:e.suggestedPath})}if(e===`ui_test_verify`){let e=await D(i),t=String(e.log??``);return typeof e.code==`string`&&n.onCode?.(e.code,e.suggestedPath??``),JSON.stringify({passed:!!e.passed,exitCode:e.exitCode??null,timedOut:!!e.timedOut,durationMs:e.durationMs??0,draftPath:e.draftPath??``,tracePath:e.tracePath??``,log:j(t.slice(-4e3),4e3),note:e.passed?`试跑通过。草稿留在 .lantern-ai 里,用户可以直接看 trace / 用 Playwright UI 调试,确认后再写入项目。`:`试跑失败:只改步骤 IR(定位器 / 等待 / 断言)。草稿和 trace 会保留,用户能打开看现场;如果是功能本身不符合预期,不要为了跑绿改断言。`})}return JSON.stringify({error:`未知工具:${e}`})}catch(e){return JSON.stringify({error:e instanceof Error?e.message:String(e)})}}function ct(e){return e?.length?e.map((e,t)=>{let n=[`${t+1}. [${e.id}] ${e.action}`];return e.target&&n.push(`目标:${e.target}`),e.url&&n.push(`url=${e.url}`),e.value&&n.push(`值=${e.value}`),e.locator&&n.push(`已绑定 ${M(e.locator)}`),n.join(` · `)}).join(`
|
|
2
|
-
`):``}function M(e){if(!e)return``;let t=Number.isInteger(e.nth)?` nth=${e.nth}`:``;return e.kind===`role`?`role=${e.role??``}${e.name?` name="${e.name}"`:``}${t}`:e.kind===`attr`?`[${e.attr}="${e.value??``}"]${t}`:e.kind===`testid`?`testid=${e.value??``}${t}`:`${e.kind}="${e.value??e.name??``}"${t}`}function lt(e){return e===`python`?`Python + pytest + playwright.sync_api`:`TypeScript + @playwright/test`}function ut(e,t){return e.replaceAll(`{{project}}`,t.project).replaceAll(`{{dir}}`,t.dir).replaceAll(`{{language}}`,t.language).replaceAll(`{{plan}}`,t.plan)}function dt(e,t,n,r,i){let a=ct(n);if(r?.trim()){let n=ut(r.trim(),{project:e.name,dir:e.dir,language:lt(t),plan:a||`如果还没有计划:先调用 ui_plan_steps 列出计划,再开始探索。`}),o=String(i??``).trim();return o?`${n}\n\n${o}`:n}return[`你是 UI 自动化测试工程师:用浏览器把流程点一遍,确认元素能唯一定位,再提交步骤。`,`项目:${e.name}(${e.dir}),目标语言:${lt(t)}。`,`ref 导航后失效要重新 snapshot;每个元素先用 ui_locator_probe 拿唯一定位器,再用 ui_test_set_steps 提交。`,"探索阶段不要自己试跑;至少一条 expect 断言用户可见的结果;账号等占位值写成 ${ENV_NAME}。",a?`\n${a}`:``,`最后用中文简短汇报。`].filter(Boolean).join(`
|
|
3
|
-
`)}function ft(e,t,n){return n?.trim()?ut(n.trim(),{project:e.name,dir:e.dir,language:lt(t),plan:``}):[`你是测试设计师:只把需求拆成「动作 + 目标描述」的步骤计划,不打开浏览器、不写定位器。`,`项目:${e.name}(${e.dir}),目标语言:${lt(t)}。`,`只调用一次 ui_plan_steps;4~12 步,覆盖打开页面、前置、核心操作与至少一条结果断言。`,"账号密码等写成 ${ENV_NAME}。"].join(`
|
|
4
|
-
`)}function pt(e,t,n){return[`需求 / 流程:`,e.trim(),``,t?`起始地址(baseURL):${t}`:`起始地址:从需求里判断,用相对路径。`,`目标语言:${n===`python`?`Python (pytest)`:`TypeScript`}`,``,`请给出步骤计划。`].join(`
|
|
5
|
-
`)}function mt(e,t,n,r){return[`要自动化的流程 / 需求:`,e.trim(),``,t?`起始地址(baseURL):${t}`:`起始地址:从需求里判断,用相对路径。`,`目标语言:${n===`python`?`Python (pytest)`:`TypeScript`}`,r?.length?`
|
|
6
|
-
已确认的步骤计划(按顺序执行,probe 时带上 stepId):
|
|
7
|
-
`+ct(r):``,``,`请开始:打开页面、探索并确认元素、提交步骤。`].filter(Boolean).join(`
|
|
8
|
-
`)}var N=ne(),ht=`ui-auto.openapp`,gt={finder:`#3b82f6`,terminal:`#334155`,editor:`#64748b`};function _t({app:e,size:t=16}){let[n,r]=(0,x.useState)(!1);return!e.iconUrl||n?e.kind===`finder`?(0,N.jsx)(`svg`,{className:`shrink-0 text-[#3b82f6]`,width:t,height:t,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:(0,N.jsx)(`path`,{d:`M2 5.5A1.5 1.5 0 013.5 4h4l1.5 2h7.5A1.5 1.5 0 0118 7.5v7A1.5 1.5 0 0116.5 16h-13A1.5 1.5 0 012 14.5v-9z`})}):e.kind===`terminal`?(0,N.jsxs)(`svg`,{className:`shrink-0 text-stone-700`,width:t,height:t,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,"aria-hidden":`true`,children:[(0,N.jsx)(`rect`,{x:`2.5`,y:`3.5`,width:`15`,height:`13`,rx:`2`}),(0,N.jsx)(`path`,{d:`M6 8l2.5 2L6 12M10.5 12.5h3.5`,strokeLinecap:`round`,strokeLinejoin:`round`})]}):(0,N.jsx)(`span`,{className:`flex shrink-0 items-center justify-center rounded-[4px] text-[9px] font-semibold text-white`,style:{width:t,height:t,backgroundColor:gt[e.kind]??`#94a3b8`},"aria-hidden":`true`,children:e.label.slice(0,1).toUpperCase()}):(0,N.jsx)(`img`,{src:e.iconUrl,alt:``,width:t,height:t,className:`shrink-0 rounded-[4px] object-contain`,onError:()=>r(!0)})}function vt({onOpen:e,disabled:t=!1,compact:n=!1}){let[r,o]=(0,x.useState)([]),[s,c]=(0,x.useState)(``),[l,u]=(0,x.useState)(()=>i(ht)),[ne,re]=(0,x.useState)(!1);(0,x.useEffect)(()=>{let e=!0;return $e().then(t=>{e&&(o(t.apps),c(t.defaultId))}).catch(()=>void 0).finally(()=>{e&&re(!0)}),()=>{e=!1}},[]);let p=r.find(e=>e.id===l)??r.find(e=>e.id===s),ie=r.length>0,ae=t||!ie,oe=t=>{t&&(u(t.id),a(ht,t.id),e(t))};return(0,N.jsxs)(`div`,{className:`inline-flex shrink-0 overflow-hidden rounded-lg border border-stone-200 bg-white ${n?`h-7`:`h-8`} ${ae?`opacity-50`:``}`,children:[(0,N.jsx)(`button`,{type:`button`,className:`flex items-center px-1.5 transition-colors enabled:hover:bg-stone-50 disabled:cursor-not-allowed`,onClick:()=>{ie&&e(p??null)},disabled:ae,"aria-label":p?`用 ${p.label} 打开`:`打开方式`,children:p?(0,N.jsx)(_t,{app:p,size:n?14:16}):(0,N.jsx)(`span`,{className:`px-1 text-[11px] text-stone-400`,children:ne?`无可用应用`:`加载中`})}),(0,N.jsx)(`span`,{className:`my-1 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,N.jsxs)(te,{as:`div`,className:`relative flex`,children:[(0,N.jsx)(f,{type:`button`,className:`flex w-7 items-center justify-center text-stone-400 transition-colors enabled:hover:bg-stone-50 enabled:hover:text-stone-600 disabled:cursor-not-allowed`,disabled:ae,"aria-label":`选择打开方式`,children:(0,N.jsx)(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:(0,N.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}),(0,N.jsxs)(ee,{anchor:{to:`bottom end`,gap:4,padding:12},transition:!0,className:`tw-select-menu tw-menu-anim z-80 w-max min-w-[180px] space-y-0.5 rounded-lg p-1 pb-2 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:[r.map(e=>{let t=e.id===(l||s);return(0,N.jsx)(d,{children:(0,N.jsxs)(`button`,{type:`button`,className:`flex w-full select-none items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm ${t?`bg-(--tw-accent-soft) font-medium text-(--tw-accent)`:`text-stone-700 data-[focus]:bg-stone-50`}`,onClick:()=>oe(e),children:[(0,N.jsx)(_t,{app:e,size:18}),(0,N.jsx)(`span`,{className:`truncate`,children:e.label}),e.id===s?(0,N.jsx)(`span`,{className:`ml-auto shrink-0 pl-3 text-[11px] text-stone-400`,children:`默认`}):null]})},e.id)}),r.length?null:(0,N.jsx)(`div`,{className:`px-2.5 py-2 text-xs text-stone-400`,children:`没有探测到可用应用`})]})]})]})}var yt=`bg-[var(--tw-surface-panel)] border-[var(--tw-border)]`,P=`divide-[var(--tw-border)]`,F=`border-[var(--tw-border)]`,bt=`text-[var(--tw-label-primary)]`,I=`text-[var(--tw-label-secondary)]`,L=`text-[var(--tw-label-tertiary)]`,R=`hover:bg-[var(--tw-session-hover-bg)]`,z=`h-8 min-w-0 rounded-lg border ${F} bg-[var(--tw-surface-recessed)] px-2.5 text-xs ${bt} outline-none transition-colors placeholder:text-[var(--tw-label-tertiary)] focus:border-[#3370ff]`,B=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-[#4176e6] px-3 text-sm font-medium text-white transition-colors hover:bg-[#3566d0] disabled:cursor-not-allowed disabled:opacity-50`,V=`shrink-0 rounded px-1.5 py-0.5 text-[11px] ${L} transition-colors`;function xt({open:e,projectName:t,detected:n,customTasks:r,hiddenCount:i,editedCount:a,error:o,onClose:ee,onAdd:d,onRemove:te,onEdit:f,onHide:ne,onReset:re,onRescan:p}){let[ie,ae]=(0,x.useState)(``),[oe,se]=(0,x.useState)(``),[ce,le]=(0,x.useState)(!1),[ue,de]=(0,x.useState)(!1),[fe,pe]=(0,x.useState)(``),[me,m]=(0,x.useState)(``),[h,he]=(0,x.useState)(``),[ge,_e]=(0,x.useState)(``);(0,x.useEffect)(()=>{e&&(ae(``),se(``),le(!1),de(!1),pe(``),m(``))},[e]);let ve=async()=>{let e=oe.trim();if(e&&!ce){le(!0);try{await d(ie.trim(),e),ae(``),se(``)}finally{le(!1)}}},g=async()=>{if(!ue){de(!0);try{await p(),pe(new Date().toLocaleTimeString(`zh-CN`,{hour12:!1}))}finally{de(!1)}}},ye=e=>{m(e.id),he(e.edited?e.display:``),_e(e.command)},be=async()=>{if(!me)return;let e=me;m(``),await f(e,h,ge)};return(0,N.jsxs)(l,{open:e,onClose:ee,className:`relative z-110`,children:[(0,N.jsx)(u,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,N.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,N.jsxs)(s,{transition:!0,className:`tw-dialog-panel-anim relative flex max-h-[80vh] w-full max-w-2xl flex-col overflow-hidden rounded-xl border shadow-xl ${yt}`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b px-5 py-4 ${F}`,children:[(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(c,{className:`text-base font-semibold ${bt}`,children:`运行配置`}),(0,N.jsxs)(`p`,{className:`mt-1 truncate text-xs leading-relaxed ${L}`,children:[t,` · 命令在该项目目录下用 shell 执行,支持引号与 &&`]})]}),(0,N.jsx)(`button`,{type:`button`,onClick:ee,className:`tw-confirm-cancel -mr-1 -mt-1 flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${L} transition-colors hover:bg-[var(--tw-session-hover-bg)] hover:text-[var(--tw-label-primary)]`,"aria-label":`关闭`,children:`✕`})]}),(0,N.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[(0,N.jsxs)(`section`,{className:`border-b px-5 py-4 ${F}`,children:[(0,N.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,N.jsx)(`span`,{className:`text-xs font-medium ${I}`,children:`自定义命令`}),(0,N.jsxs)(`span`,{className:`text-[11px] ${L}`,children:[r.length,` 条`]})]}),r.length?(0,N.jsx)(`ul`,{className:`mt-2 divide-y rounded-lg border ${P} ${F}`,children:r.map(e=>(0,N.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 px-2.5 py-1.5`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 truncate ${I}`,children:e.name?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`text-xs`,children:e.name}),(0,N.jsx)(`span`,{className:`ml-1.5 font-mono text-[11px] ${L}`,children:e.command})]}):(0,N.jsx)(`span`,{className:`font-mono text-[11px] ${I}`,children:e.command})}),(0,N.jsx)(`button`,{type:`button`,className:`${V} hover:bg-red-50 hover:text-red-600`,onClick:()=>void te(e.id),children:`删除`})]},e.id))}):(0,N.jsx)(`p`,{className:`mt-2 rounded-lg border border-dashed px-2.5 py-2 text-[11px] ${F} ${L}`,children:`还没有自定义命令。名称可以不填,不填时下拉里直接显示命令。`}),(0,N.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-2`,children:[(0,N.jsx)(`input`,{className:`${z} w-28 shrink-0`,value:ie,onChange:e=>ae(e.target.value),placeholder:`名称(可选)`,"aria-label":`运行任务名称`}),(0,N.jsx)(`input`,{className:`${z} flex-1 font-mono`,value:oe,onChange:e=>se(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ve()},placeholder:`npm run test:smoke`,"aria-label":`运行命令`,spellCheck:!1}),(0,N.jsxs)(`button`,{type:`button`,className:B,onClick:()=>void ve(),disabled:!oe.trim()||ce,children:[(0,N.jsx)(Le,{name:`plus`,size:13}),`添加`]})]})]}),(0,N.jsxs)(`section`,{className:`px-5 py-4`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`text-xs font-medium ${I}`,children:`自动发现`}),(0,N.jsxs)(`span`,{className:`text-[11px] ${L}`,children:[n.length,` 条`,fe?` · ${fe} 已扫描`:` · 挂载时扫描项目配置`]}),i||a?(0,N.jsxs)(`span`,{className:`text-[11px] ${L}`,children:[`已改 `,a,` · 已删 `,i]}):null,(0,N.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[i||a?(0,N.jsx)(`button`,{type:`button`,className:`${V} hover:bg-[var(--tw-session-hover-bg)] hover:text-[#4176e6]`,onClick:()=>void re(),children:`恢复默认`}):null,(0,N.jsxs)(`button`,{type:`button`,className:`${V} inline-flex items-center gap-1 hover:bg-[var(--tw-session-hover-bg)] hover:text-[var(--tw-label-primary)] disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void g(),disabled:ue,children:[(0,N.jsxs)(`svg`,{className:`h-3 w-3 shrink-0 ${ue?`animate-spin`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,N.jsx)(`path`,{d:`M21 12a9 9 0 1 1-2.6-6.4`}),(0,N.jsx)(`path`,{d:`M21 4v5h-5`})]}),ue?`扫描中…`:`重新扫描`]})]})]}),n.length?(0,N.jsx)(`ul`,{className:`mt-2 divide-y rounded-lg border ${P} ${F}`,children:n.map(e=>me===e.id?(0,N.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-2.5 py-2`,children:[(0,N.jsx)(`input`,{className:`${z} w-28 shrink-0`,value:h,onChange:e=>he(e.target.value),placeholder:`名称(留空用原名称)`,"aria-label":`修改名称 ${e.id}`}),(0,N.jsx)(`input`,{className:`${z} flex-1 font-mono`,value:ge,onChange:e=>_e(e.target.value),onKeyDown:e=>{e.key===`Enter`&&be(),e.key===`Escape`&&m(``)},placeholder:`命令`,"aria-label":`修改命令 ${e.id}`,spellCheck:!1}),(0,N.jsx)(`button`,{type:`button`,className:`h-8 shrink-0 rounded-lg bg-[#4176e6] px-2.5 text-xs text-white transition-colors hover:bg-[#3566d0]`,onClick:()=>void be(),children:`保存`}),(0,N.jsx)(`button`,{type:`button`,className:`h-8 shrink-0 rounded-lg border px-2.5 text-xs ${F} ${I} transition-colors hover:bg-[var(--tw-session-hover-bg)]`,onClick:()=>m(``),children:`取消`})]},e.id):(0,N.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 px-2.5 py-1.5 ${R}`,children:[(0,N.jsx)(`span`,{className:`w-24 shrink-0 truncate text-xs ${I}`,children:e.display||e.command}),(0,N.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] ${L}`,children:e.command}),e.edited?(0,N.jsx)(`span`,{className:`shrink-0 rounded bg-amber-500/15 px-1.5 py-0.5 text-[10px] text-amber-600`,children:`已改`}):e.hint?(0,N.jsx)(`span`,{className:`hidden max-w-[170px] shrink-0 truncate text-[11px] sm:block ${L}`,children:e.hint}):null,(0,N.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,N.jsx)(`button`,{type:`button`,className:`${V} hover:bg-[var(--tw-session-hover-bg)] hover:text-[var(--tw-label-primary)]`,onClick:()=>ye(e),children:`修改`}),(0,N.jsx)(`button`,{type:`button`,className:`${V} hover:bg-red-50 hover:text-red-600`,onClick:()=>void ne(e.id),children:`删除`})]})]},e.id))}):(0,N.jsx)(`p`,{className:`mt-2 rounded-lg border border-dashed px-2.5 py-2 text-[11px] ${F} ${L}`,children:`没扫到可复用命令(项目里没有测试脚本 / Makefile 目标 / marker),只保留全量运行。`}),(0,N.jsx)(`p`,{className:`mt-2 text-[11px] leading-relaxed ${L}`,children:`扫描来源:package.json 的 scripts、Makefile 目标、pytest markers、Maven profiles。改过的命令按原样用 shell 执行,不再追加框架参数。`})]})]}),o?(0,N.jsx)(`p`,{className:`shrink-0 border-t px-5 py-2 text-[11px] text-red-600 ${F}`,children:o}):null]})})]})}function H(e){return e.kind===`create`?{label:`新增`,className:`bg-emerald-50 text-emerald-600`}:e.kind===`merge`?{label:`追加`,className:`bg-sky-50 text-sky-600`}:{label:`修改`,className:`bg-amber-50 text-amber-600`}}function St({changes:e,git:t,draft:n,loading:r,onReveal:i,onRefresh:a}){let[o,s]=(0,x.useState)(``),c=(0,x.useMemo)(()=>e.find(e=>e.path===o)??e[0]??null,[o,e]);return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-stone-100 px-3 py-1`,children:[(0,N.jsxs)(`span`,{className:`shrink-0 text-[11px] text-stone-500`,children:[`本次写入 `,(0,N.jsx)(`span`,{className:`font-medium text-stone-700`,children:e.length}),` 个文件`]}),n?.draftRoot?(0,N.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[10px] text-stone-400`,children:n.draftRoot}):null,(0,N.jsxs)(`button`,{type:`button`,className:`ml-auto flex shrink-0 items-center gap-1 whitespace-nowrap text-[11px] text-[#3370ff] hover:underline disabled:opacity-40`,onClick:a,disabled:r,children:[`刷新`,(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-full border border-[#3370ff]/30 border-t-[#3370ff] ${r?`animate-spin`:`opacity-0`}`})]})]}),e.length===0?(0,N.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-1 px-4 text-center`,children:(0,N.jsx)(`p`,{className:`text-[11px] leading-relaxed text-stone-400`,children:`还没有写入项目。试跑通过后点「写入项目」,这里会出现精确到行的改动内容。`})}):(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,N.jsxs)(`div`,{className:`flex w-60 shrink-0 flex-col overflow-auto border-r border-stone-100`,children:[(0,N.jsx)(`div`,{className:`shrink-0`,children:e.map(e=>{let t=H(e),n=c?.path===e.path;return(0,N.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 px-2.5 py-1.5 text-left text-[11px] transition-colors ${n?`bg-[#f2f6ff]`:`hover:bg-stone-50`}`,onClick:()=>s(e.path),children:[(0,N.jsx)(`span`,{className:`shrink-0 rounded px-1 text-[10px] leading-4 ${t.className}`,children:t.label}),(0,N.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-stone-700`,children:e.path}),(0,N.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-emerald-600`,children:[`+`,e.added]}),(0,N.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-red-500`,children:[`-`,e.removed]})]},e.path)})}),t?.ok&&t.entries.length?(0,N.jsxs)(`details`,{className:`mt-auto shrink-0 border-t border-stone-100 px-2.5 py-1.5`,children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer list-none text-[11px] text-stone-500`,children:[`项目工作区其它改动 `,t.entries.length,t.truncated?`(截断)`:``]}),(0,N.jsx)(`ul`,{className:`mt-1 space-y-0.5`,children:t.entries.map(e=>(0,N.jsxs)(`li`,{className:`flex items-center gap-1.5 font-mono text-[10px] text-stone-500`,children:[(0,N.jsx)(`span`,{className:`w-4 shrink-0 text-[#3370ff]`,children:e.code}),(0,N.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left hover:underline`,onClick:()=>i(e.path),children:e.path})]},`${e.code}-${e.path}`))})]}):null]}),c?(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-stone-100 px-3 py-1`,children:[(0,N.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-stone-600`,children:c.path}),(0,N.jsx)(`button`,{type:`button`,className:`ml-auto shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>i(c.path),children:`打开文件`}),(0,N.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>{let e=c.path.lastIndexOf(`/`);i(e===-1?``:c.path.slice(0,e))},children:`打开目录`})]}),(0,N.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto bg-stone-50/40`,children:[c.truncated?(0,N.jsx)(`p`,{className:`px-3 py-2 text-[11px] text-stone-500`,children:c.message}):null,(c.hunks??[]).map((e,t)=>(0,N.jsxs)(`div`,{className:`border-b border-stone-100`,children:[(0,N.jsxs)(`div`,{className:`bg-stone-100/70 px-3 py-0.5 font-mono text-[10px] text-stone-500`,children:[`@@ -`,e.oldStart,`,`,e.oldLines,` +`,e.newStart,`,`,e.newLines,` @@`]}),(0,N.jsx)(`div`,{className:`py-1`,children:(()=>{let t=e.oldStart,n=e.newStart;return e.lines.map((e,r)=>{let i=e.type===`add`?`+`:e.type===`del`?`-`:` `,a=e.type===`add`?``:t,o=e.type===`del`?``:n;return e.type!==`add`&&(t+=1),e.type!==`del`&&(n+=1),(0,N.jsxs)(`div`,{className:`flex gap-2 px-2 font-mono text-[11px] leading-5 ${e.type===`add`?`bg-emerald-50 text-emerald-800`:e.type===`del`?`bg-red-50 text-red-700`:`text-stone-600`}`,children:[(0,N.jsx)(`span`,{className:`w-8 shrink-0 select-none text-right text-[10px] text-stone-400`,children:a}),(0,N.jsx)(`span`,{className:`w-8 shrink-0 select-none text-right text-[10px] text-stone-400`,children:o}),(0,N.jsx)(`span`,{className:`w-2 shrink-0 select-none text-stone-400`,children:i}),(0,N.jsx)(`span`,{className:`whitespace-pre`,children:e.text||` `})]},r)})})()})]},`${c.path}-${t}`)),!c.truncated&&(c.hunks??[]).length===0?(0,N.jsx)(`p`,{className:`px-3 py-2 text-[11px] text-stone-400`,children:`内容没有变化`}):null]})]}):null]})]})}var Ct=[{value:`goto`,label:`打开页面`},{value:`click`,label:`点击`},{value:`fill`,label:`填写`},{value:`select`,label:`选择`},{value:`press`,label:`按键`},{value:`hover`,label:`悬停`},{value:`expect`,label:`断言元素`},{value:`expectUrl`,label:`断言地址`},{value:`wait`,label:`等待`}],U=`h-7 w-full rounded-md border border-stone-200 bg-white px-2 text-[11px] text-stone-700 outline-none transition-colors focus:border-[#3370ff]`,wt={pending:{label:`待绑定`,className:`bg-stone-100 text-stone-500`},bound:{label:`已绑定`,className:`bg-emerald-50 text-emerald-600`},done:{label:`已完成`,className:`bg-emerald-50 text-emerald-600`},failed:{label:`没绑上`,className:`bg-red-50 text-red-600`}};function Tt(e){let t=new Set(e.map(e=>e.id)),n=e.length+1;for(;t.has(`p${n}`);)n+=1;return`p${n}`}function Et({plan:e,disabled:t,onChange:n}){let r=(t,r)=>{n(e.map(e=>e.id===t?{...e,...r}:e))},i=(t,r)=>{let i=t+r;if(i<0||i>=e.length)return;let a=e.slice(),[o]=a.splice(t,1);a.splice(i,0,o),n(a)},a=t=>n(e.filter(e=>e.id!==t)),o=()=>n([...e,{id:Tt(e),action:`click`,target:``,status:`pending`}]),s=e.filter(e=>e.status===`bound`||e.status===`done`).length;return(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-1 pb-1.5`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(`span`,{className:`text-xs font-medium text-stone-600`,children:`步骤计划`}),e.length?(0,N.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[s,`/`,e.length,` 已绑定`]}):null]}),(0,N.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,N.jsx)(`button`,{type:`button`,className:`text-[11px] text-[#3370ff] hover:underline disabled:opacity-40`,onClick:o,disabled:t||e.length>=40,children:`+ 添加`})})]}),(0,N.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-1.5 overflow-auto px-0.5`,children:[e.length===0?(0,N.jsxs)(`p`,{className:`rounded-lg border border-dashed border-stone-200 px-3 py-6 text-center text-[11px] leading-relaxed text-stone-400`,children:[`还没有步骤。`,(0,N.jsx)(`br`,{}),`输入需求后点「生成步骤」,这里会出来一份可以手动调整的计划。`]}):null,e.map((n,o)=>{let s=wt[n.status]??wt.pending,c=n.action===`fill`||n.action===`select`||n.action===`press`;return(0,N.jsxs)(`div`,{className:`rounded-lg border border-stone-200 bg-white px-2 py-1.5`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(`span`,{className:`w-4 shrink-0 text-center font-mono text-[10px] text-stone-400`,children:o+1}),(0,N.jsx)(`div`,{className:`w-[88px] shrink-0`,children:(0,N.jsx)(ie,{options:Ct,value:n.action,onChange:e=>r(n.id,{action:e}),disabled:t,unstyled:!0,ariaLabel:`步骤动作`,triggerClassName:`flex h-6 w-full items-center gap-1 rounded-md border border-stone-200 bg-white px-1 text-[10px] text-stone-600 outline-none transition-colors hover:border-stone-300 focus:border-[#3370ff] disabled:cursor-not-allowed disabled:opacity-50`,menuMinWidth:120})}),(0,N.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${s.className}`,children:s.label}),(0,N.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,N.jsx)(`button`,{type:`button`,className:`px-1 text-[11px] text-stone-400 hover:text-stone-700 disabled:opacity-30`,onClick:()=>i(o,-1),disabled:t||o===0,"aria-label":`上移`,children:`↑`}),(0,N.jsx)(`button`,{type:`button`,className:`px-1 text-[11px] text-stone-400 hover:text-stone-700 disabled:opacity-30`,onClick:()=>i(o,1),disabled:t||o===e.length-1,"aria-label":`下移`,children:`↓`}),(0,N.jsx)(`button`,{type:`button`,className:`tw-icon-danger px-1 text-[11px]`,onClick:()=>a(n.id),disabled:t,"aria-label":`删除`,children:`×`})]})]}),(0,N.jsx)(`input`,{className:`${U} mt-1`,value:n.target,disabled:t,placeholder:n.action===`goto`?`打开哪个页面`:`目标描述,例如「登录按钮」`,onChange:e=>r(n.id,{target:e.target.value}),spellCheck:!1}),n.action===`goto`||n.action===`expectUrl`?(0,N.jsx)(`input`,{className:`${U} mt-1 font-mono`,value:n.url??``,disabled:t,placeholder:`/login`,onChange:e=>r(n.id,{url:e.target.value}),spellCheck:!1}):null,c?(0,N.jsx)(`input`,{className:`${U} mt-1 font-mono`,value:n.value??``,disabled:t,placeholder:n.action===`press`?`Enter`:"输入值 / 选项(${ENV} 占位)",onChange:e=>r(n.id,{value:e.target.value}),spellCheck:!1}):null,n.locator?(0,N.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-emerald-700`,children:M(n.locator)}):null,n.warning?(0,N.jsx)(`p`,{className:`mt-0.5 text-[10px] leading-4 text-amber-600`,children:n.warning}):null]},n.id)})]})]})}var Dt=`inline-flex h-8 shrink-0 select-none items-center gap-1.5 whitespace-nowrap rounded-lg px-3 text-sm outline-none transition-[background-color,border-color,color,box-shadow,opacity,transform] duration-150 motion-safe:active:translate-y-px focus-visible:ring-2 focus-visible:ring-[#4176e6]/35 disabled:cursor-not-allowed disabled:motion-safe:active:translate-y-0`,W=`${Dt} font-medium text-white shadow-[0_1px_2px_rgba(23,43,99,0.12),inset_0_1px_0_rgba(255,255,255,0.18)] bg-[#4176e6] hover:bg-[#3566d0] active:bg-[#2f5cbd] active:shadow-none disabled:opacity-40 disabled:shadow-none disabled:hover:bg-[#4176e6] disabled:active:bg-[#4176e6]`,Ot=`${Dt} border border-stone-200 text-stone-600 hover:border-stone-300 hover:bg-stone-50 disabled:opacity-40`,kt=`${Dt} border border-red-200 bg-red-50 text-red-600 hover:opacity-90 active:opacity-80`,At=`inline-flex h-7 select-none items-center gap-1.5 whitespace-nowrap rounded-md px-2 text-xs outline-none transition-[background-color,color,box-shadow,opacity,transform] duration-150 motion-safe:active:translate-y-px focus-visible:ring-2 focus-visible:ring-[#4176e6]/30 disabled:cursor-not-allowed disabled:motion-safe:active:translate-y-0`,jt=`${At} text-stone-600 hover:bg-stone-100 disabled:opacity-40`,Mt=`${At} bg-(--tw-accent-soft) text-[#4176e6]`,Nt=`text-[11px] text-[#3370ff] hover:underline disabled:opacity-40 disabled:no-underline`,Pt=`h-8 w-full rounded-lg border border-stone-200 bg-white px-2.5 text-xs text-stone-700 outline-none transition-colors focus:border-[#3370ff]`,Ft=3,It=`ui-auto.gen.panel`,Lt=160,Rt=260,zt=36,Bt=60,Vt=`ui-auto.gen.side`,Ht=330,Ut=560,Wt=380,Gt=`ui-auto.gen.top`,Kt=`ui-auto.gen.bottom`,qt=`ui-auto.gen.target`,Jt=72,Yt=420,Xt=Jt,Zt=`ui-auto.gen.reqheight`,Qt=[{value:`activity`,label:`探索活动`},{value:`code`,label:`代码`},{value:`changes`,label:`变更`}],$t=[{value:`console`,label:`控制台`},{value:`network`,label:`网络`},{value:`run`,label:`试跑`}];function en(e,t,n){let r=i(e);return t.includes(r)?r:n}var tn=`ui-auto.requirement`;function nn(){let e=o(tn,``);return typeof e==`string`&&e?e:i(tn,``)}function rn(e,t,n,r){let a=Number(i(e));return!Number.isFinite(a)||a<t?r:Math.min(a,n)}function an(e,t){let n=i(e);return n===`1`||n!==`0`&&t}var on=[{value:`1`,label:`有头(可围观)`},{value:`0`,label:`无头(更快)`}];function sn(e,t){let n=t.some(e=>e.endsWith(`.py`)),r=t.some(e=>/\.(ts|js|mjs|cjs|tsx|jsx)$/.test(e));return e===`pytest`||n&&!r?{options:[{value:`python`,label:`Python`}],fallback:`python`}:{options:[{value:`ts`,label:`TypeScript`},{value:`python`,label:`Python`}],fallback:`ts`}}var cn=new Set([`goto`,`click`,`fill`,`select`,`press`,`hover`,`expect`,`expectUrl`,`wait`]);function ln(e){return e.filter(e=>cn.has(e.action))}function un(e,t){if(!t.length)return e;let n=new Map(t.map(e=>[e.id,e])),r=e.map(e=>{let t=n.get(e.id);return t?{...e,status:t.status,locator:t.locator,warning:t.warning}:e});for(let n of t)e.some(e=>e.id===n.id)||r.push(n);return ln(r)}function dn(e,t){if(!t)return``;if(e!==`ui_browser_fill`&&e!==`ui_browser_select`)return t.slice(0,240);try{let e=JSON.parse(t);for(let t of[`text`,`value`]){let n=e[t];typeof n==`string`&&!n.startsWith("${")&&(e[t]=n.replace(/[\s\S]/g,`•`))}return JSON.stringify(e).slice(0,240)}catch{return t.slice(0,240)}}function fn(e){window.dispatchEvent(new CustomEvent(`lantern:uiauto-changed`,{detail:{count:e}}))}function pn(e){return e.split(`/`).pop()||e}function mn(e){let t=e.split(`/`);return t.pop(),t.join(`/`)||`.`}function hn(e){return e===`page`?{label:`页面`,className:`bg-sky-50 text-sky-600`}:e===`fixture`?{label:`登录态`,className:`bg-violet-50 text-violet-600`}:{label:`用例`,className:`bg-emerald-50 text-emerald-600`}}function gn({project:e,promptFile:t,onError:o}){let[s,c]=(0,x.useState)(null),l=(0,x.useCallback)(async()=>h(t),[t]),u=(0,x.useCallback)(async()=>{let e=await l();return!e.plan.trim()&&!e.agent.trim()?(ae(`没有读到「提示词管理」里的「${e.file||`Playwright提示词.md`}」。本平台提示词以提示词管理为准,请先在「提示词管理」里写好(需包含「## 规划阶段」「## 探索阶段」)再生成。`,`error`),null):e},[l]),ee=(0,x.useMemo)(()=>sn(e.framework,e.specFiles??[]),[e.framework,e.specFiles]),[d,te]=(0,x.useState)(()=>{let{options:t,fallback:n}=sn(e.framework,e.specFiles??[]),r=i(qt);return t.some(e=>e.value===r)?r:n}),[f,ne]=(0,x.useState)(nn),re=`ui-auto.baseurl.${e.id}`,[p,oe]=(0,x.useState)(()=>e.baseURL||i(re)||e.detectedBaseURL||i(`ui-auto.baseurl`)||`http://localhost:5173`),[ce,pe]=(0,x.useState)(e.detectedBaseURL||``),me=`ui-auto.storage.${e.id}`,[m,he]=(0,x.useState)(()=>e.storageState||e.detectedStorageState||i(me)||``),[_e,ve]=(0,x.useState)(e.detectedStorageState||``),[g,ye]=(0,x.useState)(()=>an(`ui-auto.headed`,!0)),[be,xe]=(0,x.useState)(()=>rn(Zt,Jt,Yt,Xt)),[Se,Ce]=(0,x.useState)(!1),we=(0,x.useRef)(null),[Te,Ee]=(0,x.useState)(()=>an(`ui-auto.gen.address`,!1)),[De,Oe]=(0,x.useState)(()=>an(`ui-auto.gen.accept`,!1)),[ke,Ae]=(0,x.useState)(!0),[_,v]=(0,x.useState)(`idle`),[je,Me]=(0,x.useState)([]),[y,Pe]=(0,x.useState)(null),[b,Fe]=(0,x.useState)([]),[Ie,Le]=(0,x.useState)(!1),[Re,S]=(0,x.useState)(!1),[Be,C]=(0,x.useState)(``),[w,T]=(0,x.useState)(``),[Ue,We]=(0,x.useState)([]),[k,$e]=(0,x.useState)(()=>i(`ui-auto.gen.file.${e.id}`)),[A,nt]=(0,x.useState)(()=>an(`ui-auto.gen.force`,!1)),[j,ct]=(0,x.useState)([]),[M,lt]=(0,x.useState)(()=>{let e=Number(i(Vt));return!Number.isFinite(e)||e<Ht?Wt:Math.min(e,Ut)}),ut=(0,x.useRef)(null),[ht,gt]=(0,x.useState)(``),[_t,yt]=(0,x.useState)(``),[P,F]=(0,x.useState)(``),[bt,I]=(0,x.useState)(``),[L,R]=(0,x.useState)(null),[z,B]=(0,x.useState)(0),[V,xt]=(0,x.useState)(()=>en(Kt,$t.map(e=>e.value),`run`)),[H,Ct]=(0,x.useState)(()=>en(Gt,Qt.map(e=>e.value),`activity`)),[U,wt]=(0,x.useState)(()=>{let e=Number(i(It));return!Number.isFinite(e)||e<zt||e<=Bt?Rt:Math.min(e,640)}),[Tt,Dt]=(0,x.useState)(()=>i(It)===`closed`),[At,cn]=(0,x.useState)(!1),gn=(0,x.useRef)(null),[xn,Sn]=(0,x.useState)([]),[Cn,wn]=(0,x.useState)([]),[Tn,En]=(0,x.useState)([]),[Dn,On]=(0,x.useState)(null),[G,K]=(0,x.useState)(null),[kn,An]=(0,x.useState)(!1),[q,jn]=(0,x.useState)(null),[Mn,Nn]=(0,x.useState)(!1),[Pn,Fn]=(0,x.useState)(``),[J,In]=(0,x.useState)(null),[Ln,Rn]=(0,x.useState)(!1),zn=(0,x.useRef)(null),Y=(0,x.useRef)(``),Bn=(0,x.useRef)(0),Vn=(0,x.useRef)([]),Hn=(0,x.useRef)(null),X=(0,x.useRef)(null),Un=(0,x.useRef)(null),Wn=(0,x.useRef)([]);(0,x.useEffect)(()=>{Wn.current=b},[b]);let[Gn,Kn]=(0,x.useState)(!1);(0,x.useEffect)(()=>{let e=!0;n().then(()=>{e&&c(de())});let t=ue(()=>c(de()));return()=>{e=!1,t()}},[]);let Z=(0,x.useCallback)(e=>{Bn.current+=1;let t=Bn.current;return Me(n=>[...n,{...e,id:t,at:e.at??new Date().toISOString()}]),t},[]),qn=(0,x.useRef)(null),Jn=(0,x.useRef)(``);(0,x.useEffect)(()=>{let e=Y.current;if(!e)return;let t=je.map(({kind:e,name:t,detail:n,status:r,at:i})=>({kind:e,name:t,detail:n,status:r,at:i})),n=JSON.stringify(t);n!==Jn.current&&(Jn.current=n,qn.current&&window.clearTimeout(qn.current),qn.current=window.setTimeout(()=>{E({sessionId:e,activity:t}).catch(()=>void 0)},600))},[je]),(0,x.useEffect)(()=>{r(tn,f)},[f]),(0,x.useEffect)(()=>{a(re,p),a(`ui-auto.baseurl`,p)},[re,p]);let Yn=(0,x.useRef)(null),Xn=(0,x.useRef)(p);(0,x.useEffect)(()=>{p!==Xn.current&&(Xn.current=p,Yn.current&&window.clearTimeout(Yn.current),Yn.current=window.setTimeout(()=>{ge({id:e.id,baseURL:p}).then(e=>pe(e.detectedBaseURL||``)).catch(()=>void 0)},600))},[p,e.id]),(0,x.useEffect)(()=>{a(me,m)},[me,m]);let Zn=(0,x.useRef)(null),Qn=(0,x.useRef)(m);(0,x.useEffect)(()=>{m!==Qn.current&&(Qn.current=m,Zn.current&&window.clearTimeout(Zn.current),Zn.current=window.setTimeout(()=>{ge({id:e.id,storageState:m}).then(e=>ve(e.detectedStorageState||``)).catch(()=>void 0)},600))},[m,e.id]),(0,x.useEffect)(()=>{a(`ui-auto.headed`,g?`1`:`0`)},[g]),(0,x.useEffect)(()=>{a(`ui-auto.gen.force`,A?`1`:`0`)},[A]),(0,x.useEffect)(()=>{a(`ui-auto.gen.address`,Te?`1`:`0`)},[Te]),(0,x.useEffect)(()=>{a(`ui-auto.gen.accept`,De?`1`:`0`)},[De]),(0,x.useEffect)(()=>{k&&a(`ui-auto.gen.file.${e.id}`,k)},[k,e.id]),(0,x.useEffect)(()=>{Se||a(Zt,String(be))},[be,Se]);let $n=(0,x.useCallback)(e=>{Ct(e),a(Gt,e)},[]),er=(0,x.useCallback)(e=>{xt(e),a(Kt,e),Tt&&(Dt(!1),a(It,String(U)))},[Tt,U]),tr=(0,x.useCallback)(()=>{Dt(e=>{let t=!e;return a(It,t?`closed`:String(U)),t})},[U]),nr=(0,x.useCallback)(async()=>{if(!Y.current)En([]),On(null),K(null);else{An(!0);try{let e=await Ze(Y.current);En(e.changes),On(e.git),K(e.draft),e.changes.length&&fn(e.changes.length)}catch{}finally{An(!1)}}},[]),rr=(0,x.useCallback)(async(e,t,n=``)=>{if(!e?.steps?.length)return We([]),[];try{let r=await Ke(e,t,{testDir:n.includes(`/`)?n.replace(/\/[^/]+$/,``):`tests`});return We(r.files),$e(e=>r.files.some(t=>t.path===e)?e:r.files[0]?.path??``),r.files}catch{return[]}},[]),ir=(0,x.useCallback)(async()=>{if(!Y.current)return[];S(!0);try{let e=await O(Y.current);return C(e.code),T(e.suggestedPath),await rr(e.session.ir,e.session.target===`python`?`python`:`ts`,e.suggestedPath)}catch{return[]}finally{S(!1)}},[rr]);(0,x.useEffect)(()=>{let t=!0;return Pe(null),Y.current=``,Fe([]),C(``),R(null),yt(``),Me([]),En([]),On(null),K(null),jn(null),Fn(``),In(null),Ae(!0),Je(e.id).then(async n=>{if(!t)return;let r=n.sessions[0];if(!r){let t=e.baseURL||e.detectedBaseURL||``;Xn.current=t,oe(t),pe(e.detectedBaseURL||``);let n=e.storageState||e.detectedStorageState||``;Qn.current=n,he(n),ve(e.detectedStorageState||``);return}let a=await O(r.id);if(!t)return;Pe(a.session),Y.current=a.session.id,Fe(ln(a.session.plan??[])),C(a.code),T(a.suggestedPath),We([]),$e(i(`ui-auto.gen.file.${e.id}`)),rr(a.session.ir,a.session.target===`python`?`python`:`ts`,a.suggestedPath),te(a.session.target===`python`?`python`:`ts`);let o=e.baseURL||a.session.baseURL||e.detectedBaseURL||``;Xn.current=o,oe(o),pe(e.detectedBaseURL||``);let s=e.storageState||a.session.storageState||e.detectedStorageState||``;if(Qn.current=s,he(s),ve(e.detectedStorageState||``),ne(e=>a.session.source||e),K(a.draft??null),En(a.changes??[]),a.session.lastVerify&&R({passed:a.session.lastVerify.passed,exitCode:a.session.lastVerify.exitCode,durationMs:a.session.lastVerify.durationMs,log:a.session.lastVerify.log}),Array.isArray(a.session.activity)&&a.session.activity.length){let e=a.session.activity.map(e=>{Bn.current+=1;let t=e.status===`running`?`failed`:e.status;return{id:Bn.current,kind:e.kind===`tool`||e.kind===`error`?e.kind:`info`,name:e.name,detail:e.detail,status:t,at:e.at}});Jn.current=JSON.stringify(e.map(({kind:e,name:t,detail:n,status:r,at:i})=>({kind:e,name:t,detail:n,status:r,at:i}))),Me(e)}a.session.savedPath&&$n(`changes`),I(`已载入上次生成的草稿`),await nr()}).catch(()=>void 0).finally(()=>{t&&Ae(!1)}),()=>{t=!1}},[e.id,nr,rr,$n]),(0,x.useEffect)(()=>{let{options:t,fallback:n}=sn(e.framework,e.specFiles??[]);t.some(e=>e.value===d)||te(n)},[e.framework,e.specFiles,d]),(0,x.useEffect)(()=>{Hn.current?.scrollTo({top:Hn.current.scrollHeight})},[je]),(0,x.useEffect)(()=>()=>{X.current?.release(),zn.current?.abort(),Un.current&&window.clearTimeout(Un.current),Y.current&&(Xe(Y.current).catch(()=>void 0),Ge(Y.current).catch(()=>void 0))},[]),(0,x.useEffect)(()=>{if(!y?.id)return;let e=y.id;V===`console`?Ve(e).then(e=>Sn(e.messages??[])).catch(()=>Sn([])):V===`network`&&He(e).then(e=>wn(e.requests??[])).catch(()=>wn([]))},[V,y?.id]);let Q=_!==`idle`,ar=_===`exploring`||_===`verifying`||_===`repairing`,or=Q||!f.trim()||!b.length,sr=y?.status===`explored`||y?.status===`verified`||y?.status===`written`||y?.status===`failed`,cr=Q||!sr||!y?.ir?.steps?.length,lr=(0,x.useCallback)(()=>({sessionId:Y.current,target:d,onPlan:e=>Fe(t=>un(t,e)),onShot:e=>gt(e),onCode:(e,t)=>{C(e),T(t)},onIr:e=>{Z({kind:`info`,name:`提交步骤`,detail:`${e.title} · ${e.steps.length} 步`,status:`done`})}}),[Z,d]),ur=(0,x.useCallback)(async(e,t)=>{if(!s)throw le(`model`),Error(`请先配置模型`);let n=lr();for await(let r of se(s,e,t,{tools:it,maxToolRounds:40,runTool:async(e,t)=>{X.current&&await X.current.promise;let r=await st(e,t,n);if(ot(r)){for(let e of Vn.current.splice(0))Me(t=>t.map(t=>t.id===e?{...t,status:`failed`}:t));throw Error(at)}return r}}))if(r.type===`tool`){if(r.status===`running`){let e=Z({kind:`tool`,name:r.name,detail:dn(r.name,r.args??``),status:`running`});Vn.current.push(e)}else{let e=Vn.current.pop();Me(t=>t.map(t=>t.id===e?{...t,status:`done`,detail:(r.result??``).slice(0,240)}:t))}}else r.type===`content`&&yt(e=>e+r.delta)},[Z,s,lr]),dr=(0,x.useCallback)(async(t=!1)=>{let n=await ze({projectId:e.id,sessionId:Y.current||void 0,title:f.trim().split(/\r?\n/)[0]?.slice(0,60)||`未命名流程`,target:d,baseURL:p,storageState:m,source:f.trim(),headed:g,reset:t,plan:Wn.current.length?Wn.current:void 0});return Y.current=n.session.id,Pe(n.session),T(n.suggestedPath),K(n.draft),t&&(C(``),We([]),R(null),En([]),jn(null),In(null)),n.session.storageState&&he(n.session.storageState),n},[p,g,e.id,f,m,d]),fr=(0,x.useCallback)(async(t,n)=>{if(!s)throw le(`model`),Error(`请先配置模型`);let r=lr(),i=await l(),a=[{role:`system`,content:ft(e,d,i.plan)},{role:`user`,content:pt(t,p,d)}];for await(let e of se(s,a,n,{tools:rt,maxToolRounds:2,runTool:async(e,t)=>st(e,t,r)}))e.type===`tool`&&e.status===`running`?Z({kind:`info`,name:`规划步骤`,detail:`只做测试设计,不打开浏览器`,status:`done`}):e.type===`content`&&yt(t=>t+e.delta);let o=ln((await O(Y.current)).session.plan??[]);return Fe(o),o},[p,l,e,Z,s,d,lr]),pr=(0,x.useCallback)(async()=>{let e=f.trim();if(!e||Q)return;if(!s){F(`还没有配置模型,请先在设置里填好 API Key`),le(`model`);return}if(!await u())return;r(tn,e),a(`ui-auto.baseurl`,p),a(me,m),a(`ui-auto.headed`,g?`1`:`0`);let t=new AbortController;zn.current=t,F(``),I(``),yt(``),v(`planning`);try{await dr(!0);let n=await fr(e,t.signal);I(n.length?`已生成 ${n.length} 步计划,可以手动调整后再探索`:`没有得到步骤,补充需求后再试`)}catch(e){if(t.signal.aborted)I(`已停止`);else{let t=e instanceof Error?e.message:String(e);F(t),o?.(t),Z({kind:`error`,name:`规划失败`,detail:t,status:`failed`})}}finally{zn.current=null,v(`idle`)}},[p,Q,dr,g,o,fr,Z,u,f,s,m]),mr=(0,x.useCallback)(async(e,t)=>{let n=e;for(let e=0;e<=Ft;e+=1){B(e),v(`verifying`),er(`run`);let r=Z({kind:`info`,name:e?`第 ${e} 次修复后试跑`:`试跑`,detail:`写进 .lantern-ai 草稿并执行,失败保留现场`,status:`running`}),i=await D(Y.current);if(R(i),jn(null),typeof i.code==`string`&&C(i.code),Me(e=>e.map(e=>e.id===r?{...e,status:i.passed?`done`:`failed`,detail:i.passed?`通过 · ${Math.round((i.durationMs??0)/100)/10}s`:(i.log??i.error??``).slice(-800)}:e)),nr(),ir(),i.passed)return Z({kind:`info`,name:`试跑通过`,detail:`${Math.round((i.durationMs??0)/100)/10}s · 草稿在 ${i.draftPath??``}`,status:`done`}),I(`试跑通过,可以打开草稿 / trace 调试,确认后写入项目`),Pe(e=>e&&{...e,status:`verified`}),v(`idle`),!0;if(e===Ft)break;v(`repairing`),n=[...n,{role:`user`,content:[`第 ${e+1} 次试跑失败(exitCode=${i.exitCode??`?`})。日志尾部:`,"```",(i.log??i.error??``).slice(-3500),"```",`请先调用 ui_test_get_steps 看当前步骤,只修改步骤 IR(定位器 / 等待 / 断言),再 ui_test_verify 重跑。`,`如果是页面行为本身不符合需求,不要为了跑绿改断言,直接在回答里说明疑似缺陷。`].join(`
|
|
9
|
-
`)}],await ur(n,t)}return I(`自动修复 ${Ft} 轮仍未通过,请看试跑日志 / 打开 trace`),v(`idle`),!1},[er,Z,nr,ir,ur]),hr=(0,x.useCallback)(async()=>{let t=f.trim();if(!t||Q)return;if(!s){F(`还没有配置模型,请先在设置里填好 API Key`),le(`model`);return}if(!await u())return;r(tn,t),a(`ui-auto.baseurl`,p),a(me,m),a(`ui-auto.headed`,g?`1`:`0`);let n=new AbortController;zn.current=n,F(``),I(``),C(``),R(null),gt(``),B(0),We([]),ct([]),In(null),jn(null),Fn(``),yt(e=>e.trim()?`${e.trimEnd()}\n\n---\n\n`:e),$n(`activity`),v(`exploring`);let i=``;try{let r=await dr(!0);i=r.session.id,Z({kind:`info`,name:`探索开始`,detail:`${g?`有头`:`无头`}浏览器 · ${e.name}`,status:`done`});let a=b;if(a.length||(Z({kind:`info`,name:`先规划步骤`,detail:`还没有计划,先做一次测试设计`,status:`done`}),a=await fr(t,n.signal)),!a.length){I(`没有得到步骤计划,请补充需求后重试`),v(`idle`);return}await E({sessionId:r.session.id,plan:a});let o=await l(),s=[{role:`system`,content:dt(e,d,a,o.agent,o.code)},{role:`user`,content:mt(t,p,d,a)}];await ur(s,n.signal);let c=await O(r.session.id);if(c.code&&(C(c.code),T(c.suggestedPath)),Fe(e=>un(e,c.session.plan??[])),!(c.session.ir?.steps?.length??0)){Z({kind:`error`,name:`没有提交步骤`,detail:`探索结束了,但这轮没有可用的步骤 IR,代码与试跑保持为空`,status:`failed`}),I(`AI 没有提交步骤,请补充需求后重试`),await E({sessionId:r.session.id,status:`draft`}).catch(()=>void 0);return}let u=await rr(c.session.ir,d,c.suggestedPath);Z({kind:`info`,name:`生成代码`,detail:u.length?`按步骤出了 ${u.length} 个文件(用例 / 页面对象 / 登录态)`:`步骤已就绪,代码页可点「重新出码」`,status:`done`}),await E({sessionId:r.session.id,status:`explored`}).catch(()=>void 0),Pe({...c.session,status:`explored`}),K(c.draft??null),En(c.changes??[]),I(`探索完成,可以点「生成代码」出码;出码后会进入代码页`)}catch(e){if(n.signal.aborted)I(`已停止`);else if(e instanceof Error&&e.message===`浏览器已被关闭,这一轮探索已结束`)I(`浏览器已关闭,这一轮探索结束;重新点「开始探索」会新开一个浏览器`),Z({kind:`error`,name:`浏览器已关闭`,detail:`窗口被关闭,AI 停止操作;已提交的步骤与计划保留`,status:`failed`});else{let t=e instanceof Error?e.message:String(e);F(t),o?.(t),Z({kind:`error`,name:`生成中断`,detail:t,status:`failed`})}i&&await E({sessionId:i,status:`draft`}).catch(()=>void 0)}finally{X.current?.release(),X.current=null,Kn(!1),zn.current=null,v(`idle`),nr()}},[p,Q,dr,$n,g,l,o,b,fr,e,Z,nr,rr,u,f,ur,s,m,d]),gr=(0,x.useCallback)(()=>{X.current?.release(),X.current=null,Kn(!1),zn.current?.abort(),Y.current&&(Xe(Y.current).catch(()=>void 0),Ge(Y.current).catch(()=>void 0))},[]),_r=(0,x.useCallback)(()=>{if(X.current){X.current.release(),X.current=null,Kn(!1),Z({kind:`info`,name:`继续探索`,detail:`已手动完成登录 / 验证码`,status:`done`});return}let e=()=>{},t=new Promise(t=>{e=t});X.current={promise:t,release:e},Kn(!0),Z({kind:`info`,name:`暂停`,detail:`请在打开的浏览器窗口里完成登录,完成后点「我已登录,继续」`,status:`running`})},[Z]),vr=(0,x.useRef)(b.length);(0,x.useEffect)(()=>{vr.current=b.length},[b.length]);let yr=(0,x.useCallback)(e=>{if(Fe(e),!Y.current)return;let t=e.length!==vr.current;vr.current=e.length,t&&Ne(`ui-auto`);let n=()=>{let t=Y.current;t&&(Le(!0),E({sessionId:t,plan:e,allowEmptyPlan:!0}).catch(()=>void 0).finally(()=>Le(!1)))};Un.current&&window.clearTimeout(Un.current),t?n():Un.current=window.setTimeout(n,400)},[]),$=(0,x.useMemo)(()=>Ue.length?Ue:Be?[{path:w||(d===`python`?`tests/test_ai_generated.py`:`tests/ai-generated.spec.ts`),content:Be,language:d,role:`spec`}]:[],[Be,Ue,w,d]),br=(0,x.useMemo)(()=>$.find(e=>e.path===k)??$[0]??null,[k,$]),xr=(0,x.useCallback)((e,t)=>{We(n=>n.map(n=>n.path===e?{...n,path:t}:n)),$e(t)},[]),Sr=(0,x.useCallback)(async()=>{if(Y.current&&$.length){F(``),ct([]);try{let e=await qe({sessionId:Y.current,files:$.map(e=>({path:e.path,content:e.content,role:e.role})),force:A});if(!e.ok){F(e.error??`写入失败`),ct((e.conflicts??[]).map(e=>e.path));return}let t=e.savedPaths?.length??e.paths?.length??1,n=e.summary?.merged??0,r=e.summary?.created??0,i=e.summary?.unchanged??0,a=[r?`新建 ${r}`:``,n?`合并 ${n}`:``,i?`无变化 ${i}`:``].filter(Boolean).join(`、`);I(`已写入 ${t} 个文件${a?`(${a})`:``}${e.path?`,主用例 ${e.path}`:``},可以按项目配置验收`),Pe(t=>t&&{...t,status:`written`,savedPath:e.path,savedPaths:e.savedPaths}),nt(!1),await nr(),$n(`changes`)}catch(e){F(e instanceof Error?e.message:String(e))}}},[A,$n,nr,$]),Cr=(0,x.useCallback)(async()=>{if(Y.current&&!Ln){Rn(!0),F(``),In(null);try{let e=await et(Y.current,y?.savedPath||$.find(e=>e.role===`spec`)?.path||w);In(e),Z({kind:`info`,name:`按项目配置验收`,detail:e.ok?e.passed?`通过`:e.excluded?`被 testMatch 排除,没跑起来`:`失败(exit ${e.exitCode??`?`})`:e.error??`失败`,status:e.ok&&e.passed?`done`:`failed`})}catch(e){F(e instanceof Error?e.message:String(e))}finally{Rn(!1)}}},[Ln,Z,y?.savedPath,w,$]),wr=(0,x.useCallback)(async()=>{if(!Y.current||_!==`idle`)return;if(!y?.ir?.steps?.length){F(`还没有步骤,先「开始探索」把流程跑一遍`);return}let t=new AbortController;zn.current=t,F(``);try{if(!s){v(`verifying`),er(`run`);let e=Z({kind:`info`,name:`试跑`,detail:`在 .lantern-ai 草稿里执行(未配置模型,不做自动修复)`,status:`running`}),t=await D(Y.current);R(t),jn(null),typeof t.code==`string`&&C(t.code),Me(n=>n.map(n=>n.id===e?{...n,status:t.passed?`done`:`failed`,detail:t.passed?`通过 · ${Math.round((t.durationMs??0)/100)/10}s`:(t.log??t.error??``).slice(-800)}:n)),I(t.passed?`试跑通过`:`试跑失败,草稿与 trace 已保留`),await nr(),await ir();return}let n=await l(),r=[{role:`system`,content:dt(e,d,b,n.agent,n.code)},{role:`user`,content:mt(f.trim()||y?.source||``,p,d,b)}];await mr(r,t.signal)}catch(e){t.signal.aborted?I(`已停止`):F(e instanceof Error?e.message:String(e))}finally{zn.current=null,v(`idle`);let e=Y.current;e&&O(e).then(e=>Pe(e.session)).catch(()=>void 0)}},[p,er,l,_,b,e,Z,nr,ir,f,mr,y?.ir?.steps?.length,y?.source,s,d]),Tr=(0,x.useCallback)(async e=>{if(Y.current&&!Mn){Nn(!0),F(``);try{let t=await Ye(Y.current,e);jn(t),t.url&&Fn(t.url),t.ok?e===`headed`&&typeof t.tracePath==`string`&&t.tracePath&&K(e=>e&&{...e,tracePath:t.tracePath??``}):F(t.error??`调试启动失败`),Z({kind:`info`,name:e===`ui`?`Playwright UI`:`调试运行`,detail:t.ok?t.url||`exit ${t.exitCode??`?`} · ${t.tracePath||`无 trace`}`:t.error??`失败`,status:t.ok&&t.passed!==!1?`done`:`failed`})}catch(e){F(e instanceof Error?e.message:String(e))}finally{Nn(!1)}}},[Mn,Z]),Er=(0,x.useCallback)(async()=>{Y.current&&(await Xe(Y.current).catch(()=>void 0),Fn(``),jn(null))},[]),Dr=(0,x.useCallback)(async()=>{if(Q||!Y.current)return;F(``);let e=await ir();$n(`code`),I(e.length?`已生成 ${e.length} 个文件,确认后到「试跑」里执行`:`当前没有可出码的步骤,先「开始探索」把流程跑一遍`)},[Q,$n,ir]),Or=(0,x.useCallback)(async e=>{if(Y.current)try{await Qe({sessionId:Y.current,path:e})}catch(e){F(e instanceof Error?e.message:String(e))}},[]),kr=(0,x.useCallback)(async()=>{if(Y.current){Nn(!0);try{let e=await tt(Y.current);K(e.draft),jn(null),R(null),Fn(``),I(`草稿已清理`)}catch(e){F(e instanceof Error?e.message:String(e))}finally{Nn(!1)}}},[]),Ar=(0,x.useCallback)(async e=>{if(te(e),a(qt,e),Y.current)try{let t=await E({sessionId:Y.current,target:e});C(t.code),T(t.suggestedPath),await rr(y?.ir??null,e,t.suggestedPath)}catch(e){F(e instanceof Error?e.message:String(e))}},[rr,y?.ir]),jr=(0,x.useCallback)(()=>{let e=br?.content??Be;e&&navigator.clipboard.writeText(e).then(()=>I(`已复制当前文件`)).catch(()=>F(`复制失败,请手动选中`))},[br?.content,Be]),Mr=(0,x.useMemo)(()=>Gn?`已暂停:请在浏览器窗口里完成登录,然后点「我已登录,继续」`:_===`planning`?`AI 正在拆解步骤计划…`:_===`exploring`?`AI 正在操作浏览器…`:_===`verifying`?`正在草稿里试跑生成的脚本…`:_===`repairing`?`试跑失败,正在修复(第 ${z} 轮)…`:``,[Gn,_,z]),Nr=_===`planning`,Pr=Re,Fr=y?y.status===`verified`?`试跑通过`:y.status===`written`?`已写入项目`:y.status===`explored`?`已探索`:y.status===`failed`?`试跑失败`:`草稿`:``,Ir=q?.tracePath||G?.tracePath||L?.tracePath||``,Lr=q?.draftPath||L?.draftPath||``,Rr=!!(G?.hasSteps||(y?.ir?.steps?.length??0));return(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden bg-stone-50/40`,"aria-busy":ke?`true`:void 0,children:[(0,N.jsxs)(`aside`,{className:`flex min-h-0 min-w-0 shrink-0 flex-col gap-2 overflow-hidden bg-white px-2.5 py-2`,style:{width:M},children:[(0,N.jsxs)(`div`,{className:`flex min-h-[104px] shrink flex-col`,children:[(0,N.jsx)(`div`,{className:`mb-1 flex items-center`,children:(0,N.jsx)(`label`,{htmlFor:`ui-gen-req`,className:`text-xs font-medium text-stone-600`,children:`需求 / 步骤`})}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-lg border border-stone-200 bg-white transition-colors focus-within:border-[#3370ff] ${Se?``:`transition-[height] duration-150`}`,style:{flexBasis:be},children:(0,N.jsx)(`textarea`,{id:`ui-gen-req`,className:`block h-full w-full resize-none bg-transparent px-2.5 py-2 text-xs leading-relaxed text-stone-700 outline-none`,value:f,onChange:e=>ne(e.target.value),placeholder:`例:登录后进入商品列表,把第一个商品加入购物车,断言购物车出现该商品`,spellCheck:!1})}),(0,N.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":`调整需求框高度`,title:`拖动调整高度,双击恢复默认`,className:`group mt-1 flex h-2 cursor-row-resize touch-none items-center justify-center`,onPointerDown:e=>{we.current={startY:e.clientY,startHeight:be},Ce(!0),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{let t=we.current;if(!t)return;let n=Math.max(Jt,Math.min(Yt,Math.round(window.innerHeight*.45)));xe(Math.min(n,Math.max(Jt,t.startHeight+(e.clientY-t.startY))))},onPointerUp:e=>{we.current&&(we.current=null,Ce(!1),e.currentTarget.releasePointerCapture(e.pointerId))},onDoubleClick:()=>xe(Xt),onPointerCancel:()=>{we.current=null,Ce(!1)},children:(0,N.jsx)(`span`,{className:`h-[3px] w-8 rounded-full transition-colors ${Se?`bg-[#4176e6]/70`:`bg-stone-200 group-hover:bg-[#4176e6]/50`}`})})]}),(0,N.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-2`,children:[(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`span`,{className:`mb-1 block text-[11px] text-stone-500`,children:`目标语言`}),(0,N.jsx)(ie,{options:ee.options,value:d,onChange:e=>void Ar(e),compact:!0,ariaLabel:`目标语言`,className:`w-full`})]}),(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`span`,{className:`mb-1 block text-[11px] text-stone-500`,children:`浏览器`}),(0,N.jsx)(ie,{options:on,value:g?`1`:`0`,onChange:e=>ye(e===`1`),compact:!0,ariaLabel:`浏览器`,className:`w-full`})]})]}),(0,N.jsxs)(`details`,{className:`shrink-0 rounded-lg border border-stone-200 px-2 py-1.5`,open:Te,onToggle:e=>Ee(e.currentTarget.open),children:[(0,N.jsx)(`summary`,{className:`cursor-pointer list-none text-[11px] text-stone-500`,children:`地址与登录态`}),(0,N.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,N.jsx)(`input`,{id:`ui-gen-base`,className:`${Pt} font-mono`,value:p,onChange:e=>oe(e.target.value),placeholder:`http://localhost:5173`,spellCheck:!1,"aria-label":`起始地址`}),ce?(0,N.jsxs)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:[`项目配置里读到:`,(0,N.jsx)(`button`,{type:`button`,className:`ml-1 font-mono text-[#3370ff] hover:underline`,onClick:()=>oe(ce),disabled:p===ce,children:ce})]}):null,(0,N.jsx)(`input`,{id:`ui-gen-storage`,className:`${Pt} font-mono`,value:m,onChange:e=>he(e.target.value),placeholder:`登录态文件,留空自动检测;填 - 不用`,spellCheck:!1,"aria-label":`登录态文件`}),_e?(0,N.jsxs)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:[`项目里找到:`,(0,N.jsx)(`button`,{type:`button`,className:`ml-1 font-mono text-[#3370ff] hover:underline`,onClick:()=>he(_e),disabled:m===_e,children:_e})]}):m===`-`?(0,N.jsx)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:`按未登录身份跑,不加载 cookie`}):m?(0,N.jsx)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:`项目里没找到这个文件,跑之前会再确认一次;找不到就按未登录身份跑`}):(0,N.jsx)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:`项目里没找到登录态文件:会以未登录身份打开,探索中可以点「手动登录」`})]})]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,N.jsxs)(`div`,{className:`inline-flex h-8 items-center rounded-lg border border-stone-200 bg-white p-0.5`,children:[(0,N.jsxs)(`button`,{type:`button`,className:Nr?Mt:jt,onClick:()=>void pr(),disabled:Q||!f.trim(),"aria-busy":Nr||void 0,children:[Nr?(0,N.jsx)(yn,{}):(0,N.jsx)(bn,{name:`steps`}),(0,N.jsx)(`span`,{className:`min-w-[52px] text-center`,children:Nr?`规划中…`:`生成步骤`})]}),(0,N.jsx)(`span`,{className:`mx-0.5 h-4 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,N.jsxs)(`button`,{type:`button`,className:Pr?Mt:jt,onClick:()=>void Dr(),disabled:cr,"aria-busy":Pr||void 0,children:[Pr?(0,N.jsx)(yn,{}):(0,N.jsx)(bn,{name:`code`}),(0,N.jsx)(`span`,{className:`min-w-[52px] text-center`,children:Pr?`出码中…`:`生成代码`})]})]}),(0,N.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:(0,N.jsx)(`button`,{type:`button`,className:`${ar?kt:W} min-w-[104px] justify-center`,onClick:()=>ar?gr():void hr(),disabled:!ar&&or,"aria-busy":ar||void 0,children:ar?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(yn,{}),`停止`]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(bn,{name:`play`}),`开始探索`]})})})]}),!b.length&&!Q&&!ke?(0,N.jsx)(`p`,{className:`shrink-0 text-[11px] leading-relaxed text-stone-400`,children:`先「生成步骤」,确认计划后就能开始探索`}):null,(0,N.jsxs)(`div`,{className:`max-h-[96px] shrink-0 space-y-1 overflow-y-auto`,children:[Mr||Ie||_===`exploring`&&g?(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[Mr?(0,N.jsx)(`p`,{className:`text-[11px] text-[#4176e6]`,children:Mr}):null,Ie?(0,N.jsx)(`p`,{className:`text-[10px] text-stone-400`,children:`保存中…`}):null,_===`exploring`&&g?(0,N.jsx)(`button`,{type:`button`,className:`text-[11px] font-medium text-[#4176e6] underline-offset-2 hover:underline`,onClick:_r,children:Gn?`我已登录,继续`:`手动登录`}):null]}):null,P?(0,N.jsx)(`p`,{className:`rounded-lg bg-red-50 px-3 py-2 text-[11px] leading-relaxed break-words text-red-600`,children:P}):null,bt?(0,N.jsx)(`p`,{className:`rounded-lg bg-emerald-50 px-3 py-2 text-[11px] leading-relaxed break-words text-emerald-700`,children:bt}):null]}),(0,N.jsx)(`div`,{className:`flex min-h-[150px] min-w-0 flex-1 flex-col`,children:ke?(0,N.jsx)(vn,{}):(0,N.jsx)(Et,{plan:b,disabled:Q,onChange:yr})})]}),(0,N.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`调整左栏宽度`,className:`w-1 shrink-0 cursor-col-resize touch-none bg-stone-200/70 transition-colors hover:bg-[#4176e6]/40`,onPointerDown:e=>{ut.current={startX:e.clientX,startWidth:M},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{let t=ut.current;t&<(Math.min(Ut,Math.max(Ht,t.startWidth+(e.clientX-t.startX))))},onPointerUp:e=>{ut.current&&(ut.current=null,e.currentTarget.releasePointerCapture(e.pointerId),a(Vt,String(M)))},onPointerCancel:()=>{ut.current=null}}),(0,N.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,N.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-white`,children:[(0,N.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-1 border-b border-stone-100 px-3`,children:[Qt.map(e=>(0,N.jsx)(`button`,{type:`button`,className:`rounded px-2 py-0.5 text-[11px] transition-colors ${H===e.value?`bg-[#f2f6ff] text-[#3370ff]`:`text-stone-500 hover:bg-stone-50`}`,onClick:()=>$n(e.value),children:e.value===`changes`&&Tn.length?`${e.label} ${Tn.length}`:e.label},e.value)),(0,N.jsxs)(`div`,{className:`ml-auto flex min-w-0 shrink items-center gap-2`,children:[H===`activity`&&je.length?(0,N.jsx)(`button`,{type:`button`,className:`shrink-0 text-[10px] text-stone-400 transition-colors hover:text-red-500`,onClick:()=>{Me([]),Y.current&&E({sessionId:Y.current,activity:[],replaceActivity:!0}).catch(()=>void 0)},children:`清除活动日志`}):null,y?(0,N.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-[10px] text-stone-400`,children:[(0,N.jsx)(`span`,{className:`shrink-0`,children:`会话`}),(0,N.jsx)(`span`,{className:`truncate font-mono`,children:y.id})]}):null]})]}),(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[H===`activity`?(0,N.jsx)(`div`,{ref:Hn,className:`min-h-0 flex-1 overflow-auto px-3 py-2`,children:ke?(0,N.jsx)(_n,{rows:4}):(0,N.jsxs)(N.Fragment,{children:[je.length===0?(0,N.jsx)(`p`,{className:`py-6 text-center text-xs leading-relaxed text-stone-400`,children:`生成时这里会显示每一步操作与探测结果`}):(0,N.jsx)(`ul`,{className:`space-y-1.5`,children:je.map(e=>(0,N.jsx)(`li`,{className:`text-[11px] leading-relaxed`,children:(0,N.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,N.jsx)(`span`,{className:`mt-1 h-1.5 w-1.5 shrink-0 rounded-full ${e.status===`running`?`animate-pulse bg-[#4176e6]`:e.status===`failed`?`bg-red-500`:`bg-emerald-500`}`}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsx)(`span`,{className:`font-mono text-stone-700`,children:e.name}),e.detail?(0,N.jsx)(`pre`,{className:`mt-0.5 max-h-24 overflow-hidden whitespace-pre-wrap break-all text-[11px] text-stone-400`,children:e.detail}):null]})]})},e.id))}),_t?(0,N.jsx)(`div`,{className:`chat-md prose prose-sm prose-stone mt-3 max-w-none border-t border-stone-100 pt-2 text-stone-600`,style:{fontSize:11,lineHeight:1.7},onClick:e=>{let t=e.target;if(!t.closest(`[data-copy-code]`))return;let n=t.closest(`.code-block`)?.querySelector(`code`);n&&navigator.clipboard?.writeText(n.textContent??``).then(()=>ae(`已复制`,`success`),()=>ae(`复制失败`,`error`))},dangerouslySetInnerHTML:{__html:fe(_t)}}):null]})}):null,H===`code`?ke?(0,N.jsx)(_n,{rows:5}):$.length?(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,N.jsxs)(`div`,{className:`flex w-56 shrink-0 flex-col border-r border-stone-100`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-stone-100 px-2.5 py-1.5`,children:[(0,N.jsxs)(`span`,{className:`text-[11px] font-medium text-stone-600`,children:[`待写入 `,$.length,` 个文件`]}),(0,N.jsx)(`button`,{type:`button`,className:`ml-auto rounded px-1 text-[11px] text-stone-400 hover:bg-stone-50 hover:text-stone-600`,onClick:()=>void ir(),disabled:!y?.ir||Re,children:Re?`出码中…`:`重新出码`})]}),(0,N.jsx)(`ul`,{className:`min-h-0 flex-1 overflow-auto p-1`,children:$.map(e=>{let t=br?.path===e.path;return(0,N.jsx)(`li`,{children:(0,N.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-1.5 rounded-md px-1.5 py-1 text-left transition-colors ${t?`bg-[#f2f6ff]`:`hover:bg-stone-50`}`,onClick:()=>$e(e.path),children:[(0,N.jsx)(`span`,{className:`mt-0.5 shrink-0 rounded px-1 py-px text-[10px] leading-4 ${hn(e.role).className}`,children:hn(e.role).label}),(0,N.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,N.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-stone-700`,children:pn(e.path)}),(0,N.jsx)(`span`,{className:`block truncate font-mono text-[10px] leading-4 text-stone-400`,children:mn(e.path)})]})]})},e.path)})}),(0,N.jsxs)(`div`,{className:`shrink-0 space-y-1.5 border-t border-stone-100 px-2.5 py-2`,children:[(0,N.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[11px] text-stone-500`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:A,onChange:e=>nt(e.target.checked)}),`整文件覆盖(默认与已有文件合并)`]}),(0,N.jsxs)(`button`,{type:`button`,className:`${W} w-full justify-center`,onClick:()=>void Sr(),disabled:Q||!$.length,children:[`写入 `,$.length,` 个文件`]})]})]}),(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-stone-100 px-3 py-1.5`,children:[(0,N.jsx)(`span`,{className:`shrink-0 rounded bg-stone-100 px-1.5 py-0.5 text-[10px] text-stone-500`,children:d===`python`?`pytest`:`Playwright Test`}),(0,N.jsx)(`input`,{className:`${Pt} min-w-[180px] flex-1 font-mono`,value:br?.path??``,onChange:e=>{br&&xr(br.path,e.target.value)},placeholder:w||`tests/xxx.spec.ts`,spellCheck:!1,"aria-label":`写入路径`}),(0,N.jsx)(`button`,{type:`button`,className:Ot,onClick:jr,children:`复制`}),(0,N.jsx)(vt,{compact:!0,disabled:!br||!y?.savedPaths?.length,onOpen:e=>{br&&Qe({sessionId:Y.current,path:br.path,app:e?.id}).catch(e=>F(e instanceof Error?e.message:String(e)))}})]}),j.length?(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-amber-100 bg-amber-50 px-3 py-1.5 text-[11px] text-amber-700`,children:[(0,N.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`这些文件已存在:`,j.join(`、`)]}),(0,N.jsx)(`button`,{type:`button`,className:`shrink-0 rounded border border-amber-300 px-1.5 py-0.5 text-amber-800 hover:bg-amber-100`,onClick:()=>{nt(!0),ct([])},children:`勾选覆盖`})]}):null,(0,N.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre px-3 py-2 font-mono text-[11px] leading-relaxed text-stone-700`,children:br?.content||`生成后这里显示要写入的文件`})]})]}):(0,N.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs leading-relaxed text-stone-400`,children:`生成步骤并试跑后,这里会列出要写入项目的 spec、页面对象与登录态文件`}):null,H===`changes`?ke?(0,N.jsx)(_n,{rows:4}):(0,N.jsx)(St,{changes:Tn,git:Dn,draft:G,loading:kn,onReveal:e=>void Or(e),onRefresh:()=>void nr()}):null]}),ht&&H===`activity`?(0,N.jsx)(`div`,{className:`shrink-0 border-t border-stone-100 p-2`,children:(0,N.jsx)(`img`,{src:ht,alt:`最近一步截图`,className:`max-h-52 w-full rounded-md border border-stone-100 object-contain`})}):null]}),(0,N.jsxs)(`section`,{className:`relative flex shrink-0 flex-col overflow-hidden border-t border-stone-200 bg-white ${At?``:`transition-[height] duration-200 ease-out`}`,style:{height:Tt?zt:U},children:[Tt?null:(0,N.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":`调整底部面板高度`,className:`h-1 shrink-0 cursor-row-resize touch-none bg-stone-100 transition-colors hover:bg-[#4176e6]/40`,onPointerDown:e=>{gn.current={startY:e.clientY,startHeight:U},cn(!0),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{let t=gn.current;if(!t)return;let n=Math.max(Lt,Math.round(window.innerHeight*.65));wt(Math.min(n,Math.max(zt,t.startHeight+(t.startY-e.clientY))))},onPointerUp:e=>{let t=gn.current;if(!t)return;gn.current=null,cn(!1),e.currentTarget.releasePointerCapture(e.pointerId);let n=Math.max(Lt,Math.round(window.innerHeight*.65)),r=Math.min(n,Math.max(zt,t.startHeight+(t.startY-e.clientY)));r<=Bt?(wt(Math.max(Lt,t.startHeight)),Dt(!0),a(It,`closed`)):(wt(r),a(It,String(r)))},onPointerCancel:()=>{gn.current=null,cn(!1)}}),(0,N.jsxs)(`div`,{className:`relative flex h-9 shrink-0 items-center gap-1 border-b border-stone-100 px-2`,children:[$t.map(e=>(0,N.jsx)(`button`,{type:`button`,className:`rounded px-2 py-0.5 text-[11px] transition-colors ${V===e.value?`bg-[#f2f6ff] text-[#3370ff]`:`text-stone-500 hover:bg-stone-50`}`,onClick:()=>er(e.value),children:e.label},e.value)),(0,N.jsx)(`span`,{className:`ml-2 min-w-0 truncate text-[10px] text-stone-400`,children:Fr}),(0,N.jsx)(`button`,{type:`button`,"aria-label":Tt?`展开底部面板`:`收起底部面板`,"aria-expanded":!Tt,className:`group absolute left-1/2 top-1/2 flex h-6 w-20 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 focus-visible:ring-2 focus-visible:ring-[#4176e6]/30 focus-visible:outline-none`,onClick:tr,children:(0,N.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 transition-transform duration-200 ${Tt?`rotate-180`:``}`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,N.jsx)(`path`,{d:`m6 9 6 6 6-6`})})})]}),Tt?null:(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[V===`console`?(0,N.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-3 py-2`,children:xn.length?(0,N.jsx)(`ul`,{className:`space-y-1 font-mono text-[11px]`,children:xn.slice(-80).map((e,t)=>(0,N.jsxs)(`li`,{className:e.type===`error`?`text-red-600`:`text-stone-600`,children:[(0,N.jsxs)(`span`,{className:`mr-1 text-stone-400`,children:[`[`,e.type,`]`]}),e.text]},t))}):(0,N.jsx)(`p`,{className:`py-6 text-center text-xs text-stone-400`,children:`暂无控制台错误 / 警告`})}):null,V===`network`?(0,N.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-3 py-2`,children:Cn.length?(0,N.jsx)(`ul`,{className:`space-y-1 font-mono text-[11px]`,children:Cn.slice(-80).map((e,t)=>(0,N.jsxs)(`li`,{className:`text-stone-600`,children:[(0,N.jsx)(`span`,{className:`mr-1 text-red-500`,children:e.status}),(0,N.jsx)(`span`,{className:`mr-1 text-stone-400`,children:e.method}),(0,N.jsx)(`span`,{className:`break-all`,children:e.url})]},t))}):(0,N.jsx)(`p`,{className:`py-6 text-center text-xs text-stone-400`,children:`暂无失败请求`})}):null,V===`run`?(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-stone-100 px-3 py-1.5`,children:[(0,N.jsx)(`span`,{className:`text-[11px] text-stone-500`,children:`最近一次试跑`}),(0,N.jsx)(`span`,{className:`text-[11px] font-medium ${L?L.passed?`text-emerald-600`:`text-red-600`:`text-stone-400`}`,children:L?L.passed?`通过`:`失败(exit ${L.exitCode??`?`})`:`未试跑`}),(0,N.jsxs)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:[`耗时 `,Math.round((L?.durationMs??0)/100)/10,`s`,L?.timedOut?` · 超时`:``]}),(0,N.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,className:W,onClick:()=>void wr(),disabled:Q||!Rr,children:_===`verifying`?`试跑中…`:L?`重新试跑`:`试跑`}),(0,N.jsx)(`button`,{type:`button`,className:Ot,onClick:()=>void Tr(`headed`),disabled:Mn||!Rr,children:`调试运行`}),(0,N.jsx)(`button`,{type:`button`,className:Ot,onClick:()=>void Tr(`ui`),disabled:Mn||!Rr||d===`python`,children:`Playwright UI`}),Pn?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`a`,{className:Nt,href:Pn,target:`_blank`,rel:`noreferrer`,children:[`打开 `,Pn]}),(0,N.jsx)(`button`,{type:`button`,className:Nt,onClick:()=>void Er(),children:`结束 UI`})]}):null]})]}),(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,N.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-all bg-stone-50/40 px-3 py-2 font-mono text-[11px] leading-relaxed text-stone-700`,children:L?.log||(L?`试跑没有输出`:`试跑后这里显示日志;失败时草稿与 trace 会保留,方便回看现场。`)}),(0,N.jsxs)(`div`,{className:`w-64 shrink-0 space-y-2 overflow-auto border-l border-stone-100 p-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`text-[11px] text-stone-500`,children:`草稿工作区`}),(0,N.jsx)(`p`,{className:`mt-1 break-all font-mono text-[10px] leading-4 text-stone-500`,children:G?.draftRoot||`还没有草稿,试跑后生成`}),(0,N.jsx)(`p`,{className:`break-all font-mono text-[10px] leading-4 text-stone-400`,children:Lr?`用例:${Lr}`:``}),(0,N.jsx)(`p`,{className:`break-all font-mono text-[10px] leading-4 text-stone-400`,children:Ir?`trace:${Ir}`:``}),(0,N.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,N.jsx)(`button`,{type:`button`,className:Nt,onClick:()=>void Or(Lr||G?.draftDir||``),disabled:!Lr&&!G?.draftDir,children:`打开草稿`}),(0,N.jsx)(`button`,{type:`button`,className:Nt,onClick:()=>void Or(G?.draftRoot??``),disabled:!G?.exists,children:`打开目录`}),(0,N.jsx)(`button`,{type:`button`,className:Nt,onClick:()=>void Or(Ir),disabled:!Ir,children:`打开 trace`}),(0,N.jsx)(`button`,{type:`button`,className:`${Nt} text-stone-400`,onClick:()=>void kr(),disabled:Mn||!G?.exists,children:`清理草稿`})]})]}),(0,N.jsxs)(`details`,{className:`rounded-lg border border-stone-200 px-2 py-1.5`,open:De,onToggle:e=>Oe(e.currentTarget.open),children:[(0,N.jsx)(`summary`,{className:`cursor-pointer list-none text-[11px] text-stone-500`,children:`写入后验收`}),(0,N.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-2`,children:[(0,N.jsx)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:`用项目自己的配置跑正式文件`}),(0,N.jsx)(`button`,{type:`button`,className:Ot,onClick:()=>void Cr(),disabled:Ln||!(y?.savedPath||$.find(e=>e.role===`spec`)?.path),children:Ln?`验收中…`:`开始验收`})]}),J?(0,N.jsxs)(`div`,{className:`mt-1.5`,children:[(0,N.jsx)(`p`,{className:`text-[11px] font-medium ${J.passed?`text-emerald-600`:`text-red-600`}`,children:J.ok?J.passed?`验收通过`:J.excluded?`没被项目配置识别为用例`:`失败(exit ${J.exitCode??`?`})`:J.error??`失败`}),J.note?(0,N.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-4 text-amber-600`,children:J.note}):null,J.log?(0,N.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded bg-stone-50 p-2 font-mono text-[10px] leading-4 text-stone-600`,children:J.log}):null]}):null]}),q?(0,N.jsxs)(`div`,{className:`rounded-lg border border-stone-200 px-2 py-1.5`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsx)(`span`,{className:`text-[11px] text-stone-500`,children:q.mode===`ui`?`Playwright UI`:`调试运行`}),(0,N.jsx)(`span`,{className:`text-[11px] ${q.ok&&q.passed!==!1?`text-emerald-600`:`text-red-600`}`,children:q.ok?q.mode===`ui`?q.ready?`已启动`:`启动较慢`:q.passed?`通过`:`失败(exit ${q.exitCode??`?`})`:q.error??`失败`})]}),q.url?(0,N.jsx)(`p`,{className:`mt-1 break-all font-mono text-[10px] text-stone-500`,children:q.url}):null,q.log?(0,N.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded bg-stone-50 p-2 font-mono text-[10px] leading-4 text-stone-600`,children:q.log}):null]}):null]})]})]}):null]})]})]})]})}function _n({rows:e=3}){return(0,N.jsx)(`div`,{className:`space-y-2 p-3`,"aria-hidden":`true`,children:Array.from({length:e}).map((e,t)=>(0,N.jsx)(`div`,{className:`h-3 animate-pulse rounded bg-stone-100`,style:{width:`${Math.max(40,92-t*14)}%`}},t))})}function vn(){return(0,N.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-1.5`,"aria-hidden":`true`,children:[0,1,2].map(e=>(0,N.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-stone-50`},e))})}function yn(){return(0,N.jsxs)(`svg`,{className:`h-3.5 w-3.5 shrink-0 animate-spin`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[(0,N.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,stroke:`currentColor`,strokeWidth:`2`,opacity:`0.25`}),(0,N.jsx)(`path`,{d:`M14 8a6 6 0 0 0-6-6`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})]})}function bn({name:e}){let t={width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`};return e===`play`?(0,N.jsx)(`svg`,{...t,fill:`currentColor`,stroke:`none`,children:(0,N.jsx)(`path`,{d:`M8 5.5v13l11-6.5Z`})}):e===`code`?(0,N.jsxs)(`svg`,{...t,children:[(0,N.jsx)(`path`,{d:`m9 8-4 4 4 4`}),(0,N.jsx)(`path`,{d:`m15 8 4 4-4 4`})]}):(0,N.jsxs)(`svg`,{...t,children:[(0,N.jsx)(`path`,{d:`M4 7h10`}),(0,N.jsx)(`path`,{d:`M4 12h7`}),(0,N.jsx)(`path`,{d:`M4 17h10`}),(0,N.jsx)(`path`,{d:`M17 12h3`}),(0,N.jsx)(`path`,{d:`m18 10 2 2-2 2`})]})}function xn(e){if(e.kind===`full`)return`全量运行`;let t=e.display?.trim()??``;return!t||t===e.command?e.label||e.command:`${t}(${e.command})`}var Sn=[{value:`run`,label:`运行`},{value:`generate`,label:`生成`},{value:`history`,label:`历史`}],Cn=`ui-auto.project`,wn=`ui-auto.tab`,Tn=`ui-auto.task`,En=e=>`ui-auto.log-scroll.${e}`,Dn=e=>`${Tn}.${e}`,On=1e3,G=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-[#4176e6] px-3 text-sm font-medium text-white transition-colors hover:bg-[#3566d0] disabled:cursor-not-allowed disabled:opacity-50`,K=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`,kn=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg border border-red-200 px-3 text-sm text-red-600 transition-colors hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-40`;function An(){let{ready:e,on:t}=Fe(`uiAuto`),[n,s]=(0,x.useState)([]),[c,l]=(0,x.useState)([]),[u,ne]=(0,x.useState)(()=>i(Cn)),[se,le]=(0,x.useState)(!0),[ue,de]=(0,x.useState)(!0),[fe,h]=(0,x.useState)(``),[Ee,Ne]=(0,x.useState)(()=>i(wn)===`history`?`history`:i(wn)===`generate`?`generate`:`run`),[Re,S]=(0,x.useState)(()=>i(Tn)||`full`),[ze,Be]=(0,x.useState)(!1),[C,w]=(0,x.useState)(``),[T,Ve]=(0,x.useState)([]),[He,Ue]=(0,x.useState)(!1),[We,Ge]=(0,x.useState)(!1),[E,Ke]=(0,x.useState)([]),[D,qe]=(0,x.useState)(null),[Je,O]=(0,x.useState)(``),[Ye,Xe]=(0,x.useState)(!1),[Ze,k]=(0,x.useState)(!1),$e=(0,x.useRef)(0),et=(0,x.useRef)(null),tt=(0,x.useRef)(!0),A=(0,x.useRef)(null),nt=(0,x.useRef)(0),[rt,it]=(0,x.useState)(!1),[at,ot]=(0,x.useState)(``),[j,st]=(0,x.useState)(null),[ct,M]=(0,x.useState)(``),[lt,ut]=(0,x.useState)(!1),[dt,ft]=(0,x.useState)(null),[pt,mt]=(0,x.useState)(null),[ht,gt]=(0,x.useState)(!1),[_t,yt]=(0,x.useState)(()=>Date.now()),P=(0,x.useMemo)(()=>n.find(e=>e.id===u)??null,[n,u]),F=(0,x.useMemo)(()=>{let e=P?.promptFile??``;return e&&T.some(t=>t.value===e)?e:he},[P?.promptFile,T]),bt=(0,x.useMemo)(()=>{if(!P||!He)return!1;let e=(P.promptFile??``).trim();return!e||!T.some(t=>t.value===e)},[P,He,T]),I=(0,x.useMemo)(()=>n.map(e=>({value:e.id,label:e.name,secondary:e.dir.replace(/^\/Users\/[^/]+/,`~`)})),[n]),L=(0,x.useCallback)(e=>{Ne(e),a(wn,e)},[]),R=(0,x.useCallback)(async()=>{let e=async t=>{let{entries:n}=await oe(`prompts`,t),r=t===`.`?``:`${t}/`,i=n.filter(e=>e.type===`file`&&/\.md$/i.test(e.name)).map(e=>`${r}${e.name}`),a=await Promise.all(n.filter(e=>e.type===`dir`).map(t=>e(`${r}${t.name}`)));return[...i,...a.flat()]},t=(await e(`.`)).filter(e=>{let t=ce(e);return!t||t===`uiAuto`}).sort().map(e=>({value:e,label:e}));return Ve(t),t},[]);(0,x.useEffect)(()=>{if(!t)return;R().catch(()=>void 0).finally(()=>Ue(!0));let e=()=>{document.visibilityState===`visible`&&R().catch(()=>void 0)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[t,R]);let z=(0,x.useCallback)(async()=>{let e=await ye();return s(e.projects),e.frameworks.length&&l(e.frameworks),e.projects},[]),B=(0,x.useCallback)(async e=>{let t=await _(e);return Ke(t),t},[]),V=(0,x.useRef)(``);V.current=D?.id??``;let H=(0,x.useCallback)(()=>{let e=et.current,t=V.current;if(!e||!t)return;let n=e.scrollHeight-e.scrollTop-e.clientHeight<40;r(En(t),{top:e.scrollTop,stick:n})},[]),St=(0,x.useCallback)(async e=>{H();let t=await we(e,0);qe(t.run),O(t.log),Xe(t.stopping),$e.current=t.nextOffset;let n=o(En(e),null),r=n&&typeof n.top==`number`&&!n.stick?n:null;A.current=r,tt.current=!r},[H]);(0,x.useEffect)(()=>{if(!t)return;let e=!0;return me(!0).catch(()=>void 0),le(!0),z().catch(t=>{e&&h(t instanceof Error?t.message:String(t))}).finally(()=>{e&&le(!1)}),()=>{e=!1}},[t,z]),(0,x.useEffect)(()=>{if(!n.length||n.some(e=>e.id===u))return;let e=n[0].id;ne(e),a(Cn,e)},[n,u]),(0,x.useEffect)(()=>{if(!t||!u){Ke([]),qe(null),O(``),t&&de(!1);return}let e=!0;return Ke([]),qe(null),O(``),Xe(!1),$e.current=0,A.current=null,S(i(Dn(u))||`full`),B(u).then(t=>{if(!e)return;let n=t.find(e=>e.status===`running`)??t[0];n&&St(n.id).catch(()=>void 0)}).catch(t=>{e&&h(t instanceof Error?t.message:String(t))}).finally(()=>{e&&de(!1)}),()=>{e=!1}},[t,u,B,St]);let Ct=(0,x.useCallback)(async()=>{await z().catch(()=>null),u&&await B(u).catch(()=>null)},[z,B,u]),U=(0,x.useMemo)(()=>P?.runTasks??[],[P?.runTasks]),wt=(0,x.useMemo)(()=>U.find(e=>e.id===Re)??U[0]??null,[U,Re]),Tt=(0,x.useMemo)(()=>[...U.length?U.map(e=>({value:e.id,label:xn(e)})):[{value:`full`,label:`全量运行`}]],[U]),Et=D?.status??``,Dt=D?.id??``,W=D?.status===`running`;(0,x.useEffect)(()=>{if(!Dt||!W)return;let e=!0,t=async()=>{try{let t=await we(Dt,$e.current);if(!e)return;t.reset?O(t.log):t.log&&O(e=>e+t.log),$e.current=t.nextOffset,Xe(t.stopping),qe(t.run),Te(t.run.status)&&Ct()}catch{}},n=window.setInterval(()=>void t(),On);return()=>{e=!1,window.clearInterval(n)}},[Dt,W,Ct]),(0,x.useEffect)(()=>{if(!W)return;let e=window.setInterval(()=>yt(Date.now()),1e3);return()=>window.clearInterval(e)},[W]),(0,x.useEffect)(()=>{if(W)return;let e=window.setInterval(()=>{document.visibilityState===`visible`&&(z().catch(()=>null),u&&B(u).catch(()=>null))},15e3);return()=>window.clearInterval(e)},[W,u,z,B]),(0,x.useEffect)(()=>{let e=et.current;if(!e)return;let t=A.current;t?(A.current=null,e.scrollTop=t.top):tt.current&&(e.scrollTop=e.scrollHeight)},[Je]),(0,x.useEffect)(()=>{let e=()=>H(),t=()=>{document.visibilityState===`hidden`&&H()};return window.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`pagehide`,e),document.removeEventListener(`visibilitychange`,t),window.clearTimeout(nt.current)}},[H]);let Ot=()=>{let e=et.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<40;tt.current=t,window.clearTimeout(nt.current),nt.current=window.setTimeout(()=>H(),200)},kt=(0,x.useCallback)(async(e={})=>{if(u){h(``),k(!0);try{let t=await Me(u,{taskId:wt?.id??`full`,...e});qe(t),O(``),Xe(!1),$e.current=0,A.current=null,tt.current=!0,L(`run`),await B(u).catch(()=>null),await z().catch(()=>null)}catch(e){h(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[u,wt,B,z,L]),At=(e=null)=>{h(``),M(``),st(e),ot(e?.dir??``),it(!0)},jt=()=>{lt||it(!1)},Mt=(0,x.useCallback)(e=>{P&&Qe({projectId:P.id,path:e.path,app:e.app}).catch(e=>h(e instanceof Error?e.message:String(e)))},[P]),Nt=async()=>{ut(!0),M(``);try{let e=await _e();e&&ot(e)}catch(e){M(`${e instanceof Error?e.message:String(e)}(可在下方直接填写目录路径)`)}finally{ut(!1)}},Pt=async e=>{if(P){w(``);try{let t=await ge({id:P.id,customTasks:e.customTasks?.map(({id:e,name:t,command:n})=>({id:e,name:t,command:n})),taskOverrides:e.taskOverrides,hiddenTasks:e.hiddenTasks});s(e=>e.map(e=>e.id===t.id?t:e)),(t.runTasks??[]).some(e=>e.id===Re)||(S(`full`),a(Dn(t.id),`full`))}catch(e){w(e instanceof Error?e.message:String(e))}}},Ft=e=>Pt({customTasks:e}),It=(0,x.useCallback)(async e=>{if(!P)return;let t=P.id;s(n=>n.map(n=>n.id===t?{...n,promptFile:e}:n));try{let n=await ge({id:t,promptFile:e});s(e=>e.map(e=>e.id===n.id?n:e)),Ge(!1),Se(),ae(e?`已挂载「${e}」`:`已取消挂载`,`success`)}catch(e){throw await z().catch(()=>void 0),e}},[P,z]),Lt=(0,x.useCallback)(async e=>{await me(!0).catch(()=>void 0);let t=await m(e,he);return await R(),t},[R]),Rt=async(e,t,n)=>{if(!P)return;let r=(P.taskOverrides??[]).filter(t=>t.id!==e),i={id:e,name:t.trim(),command:n.trim()};(i.name||i.command)&&r.push(i),await Pt({taskOverrides:r})},zt=async e=>{P&&await Pt({taskOverrides:(P.taskOverrides??[]).filter(t=>t.id!==e),hiddenTasks:[...new Set([...P.hiddenTasks??[],e])]})},Bt=async()=>{await Pt({taskOverrides:[],hiddenTasks:[]})},Vt=async(e,t)=>{if(!P)return;let n=t.trim();n?await Ft([...P.customTasks??[],{id:``,name:e,command:n}]):w(`先填要执行的命令`)},Ht=async e=>{P&&await Ft((P.customTasks??[]).filter(t=>t.id!==e))},Ut=async()=>{let e=at.trim();if(!e)M(`请先选择或填写项目目录`);else{k(!0),M(``);try{let t;t=j?(await ge({id:j.id,dir:e})).id:(await ke(e)).id,await z(),ne(t),a(Cn,t),L(`run`),it(!1),st(null),ot(``)}catch(t){let r=t instanceof Error?t.message:String(t),i=n.find(t=>t.dir===e);if(i&&/已经添加/.test(r)){ne(i.id),a(Cn,i.id),L(`run`),it(!1),ot(``);return}M(r)}finally{k(!1)}}},Wt=async()=>{if(D){h(``);try{await g(D.id),Xe(!0)}catch(e){h(e instanceof Error?e.message:String(e))}}},Gt=()=>{wt?.failureFlags?kt({lastFailed:!0}):h(`当前运行任务不支持只跑失败用例,切到「全量运行」或 pytest 任务再试`)},Kt=async()=>{if(pt){h(``);try{await Ce(pt.id),D?.id===pt.id&&(qe(null),O(``)),u&&await B(u),await z().catch(()=>null)}catch(e){h(e instanceof Error?e.message:String(e))}finally{mt(null)}}};if(!e||ue)return(0,N.jsx)(`div`,{className:`tw-hydrate-pending h-full w-full`,children:(0,N.jsx)(b,{label:`加载自动化测试…`})});if(!t)return(0,N.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`该插件未启用,到「我的插件」里打开「自动化测试」就能挂载 Playwright / pytest / Selenium 项目。`});let qt=(0,N.jsxs)(`div`,{className:`border-b border-stone-100 bg-stone-50/60 px-4 py-3`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`text-xs font-medium text-stone-700`,children:j?`重新指定项目目录`:`挂载项目`}),(0,N.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`自动识别 Playwright / pytest / Selenium,只读取与运行,不改项目文件`})]}),(0,N.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`input`,{className:`h-8 min-w-[260px] flex-1 rounded-lg border border-stone-200 bg-white px-2.5 font-mono text-xs text-stone-700 outline-none transition-colors focus:border-[#3370ff]`,value:at,onChange:e=>ot(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Ut()},placeholder:`/path/to/your-test-project`,"aria-label":`项目目录`,spellCheck:!1}),(0,N.jsxs)(`button`,{type:`button`,className:K,onClick:()=>void Nt(),disabled:lt,children:[(0,N.jsx)(Le,{name:`folder`,size:13}),lt?`选择中…`:`浏览…`]}),(0,N.jsx)(`button`,{type:`button`,className:G,onClick:()=>void Ut(),disabled:Ze||lt||!at.trim(),children:Ze?`挂载中…`:j?`保存目录`:`挂载`})]}),ct?(0,N.jsx)(`p`,{className:`mt-2 rounded-lg bg-red-50 px-3 py-2 text-[11px] leading-relaxed text-red-600`,children:ct}):null]}),Jt=D?W?Math.max(0,_t-Date.parse(D.startedAt)):D.durationMs:0,Yt=rt||!n.length;return(0,N.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-white`,children:[fe?(0,N.jsx)(Pe,{message:fe,onClose:()=>h(``)}):null,(0,N.jsxs)(`header`,{className:`relative z-20 flex h-12 shrink-0 items-center gap-3 border-b border-stone-200 px-4`,children:[(0,N.jsx)(`h1`,{className:`shrink-0 text-sm font-semibold text-stone-800`,children:`自动化测试`}),(0,N.jsx)(`span`,{className:`h-4 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),P?(0,N.jsx)(`div`,{role:`tablist`,"aria-label":`自动化测试视图`,className:`flex h-full shrink-0 items-stretch`,children:Sn.map(e=>{let t=e.value===`history`?E.length:0,n=Ee===e.value;return(0,N.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n,onClick:()=>L(e.value),className:`relative flex h-full items-center gap-1.5 border-b-2 px-2.5 text-[13px] transition-colors ${n?`border-[#3370ff] font-medium text-stone-900`:`border-transparent text-stone-500 hover:text-stone-800`}`,children:[e.label,t?(0,N.jsx)(`span`,{className:`rounded-full px-1.5 text-[11px] leading-4 tabular-nums ${n?`bg-[#eaf1ff] text-[#3370ff]`:`bg-stone-100 text-stone-400`}`,children:t}):null]},e.value)})}):(0,N.jsx)(`span`,{className:`truncate text-[11px] text-stone-400`,children:se?`正在读取挂载列表…`:`还没有挂载项目`}),(0,N.jsxs)(`div`,{className:`ml-auto flex min-w-0 shrink-0 items-center gap-2`,children:[P?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{type:`button`,className:`flex h-8 w-40 min-w-0 items-center rounded-lg border bg-white px-2.5 text-left transition-colors hover:border-stone-300 focus:border-[#4176e6] focus:outline-none focus-visible:ring-2 focus-visible:ring-[#4176e6]/30 ${bt?`border-amber-300 text-amber-700`:`border-stone-200`}`,onClick:()=>Ge(!0),"aria-label":`挂载提示词`,children:(0,N.jsx)(p,{text:bt?`未挂载提示词 · 点击挂载`:F,className:`min-w-0 flex-1 truncate text-sm ${bt?`text-amber-700`:`text-stone-700`}`})}),(0,N.jsx)(ie,{options:I,value:P.id,onChange:e=>{ne(e),a(Cn,e)},compact:!0,className:`w-48`,ariaLabel:`切换项目`,triggerClassName:P.exists?``:`text-amber-700`,hideTriggerHint:!0,renderOptionAction:e=>{let t=n.find(t=>t.id===e.value);return t?(0,N.jsx)(`button`,{type:`button`,disabled:Ze,"aria-label":`移出 ${t.name}`,className:`tw-icon-danger rounded p-1 opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100 disabled:opacity-0 disabled:group-hover:opacity-40`,onClick:()=>ft(t),children:(0,N.jsx)(Le,{name:`trash`,size:13})}):null}}),P.frameworkReady?(0,N.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-[11px] text-stone-500`,children:[c.find(e=>e.id===P.framework)?.label||P.framework,P.kind?Oe(P.kind):``].filter(Boolean).join(` · `)}):(0,N.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-[11px] text-amber-600`,children:`运行环境未就绪`}),(0,N.jsx)(vt,{onOpen:e=>Mt({path:``,app:e?.id}),disabled:!P.exists})]}):null,(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`${K} ${rt?`border-[#4176e6] bg-[#f2f6ff] text-[#3566d0] hover:bg-[#eaf1ff]`:``}`,onClick:()=>rt?jt():At(null),disabled:Ze||lt,"aria-expanded":rt,children:[(0,N.jsx)(Le,{name:`plus`,size:13}),`挂载`]}),P?(0,N.jsxs)(te,{as:`div`,className:`relative shrink-0`,children:[(0,N.jsx)(f,{type:`button`,className:`flex h-8 w-8 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-700`,"aria-label":`更多操作`,children:(0,N.jsx)(Le,{name:`more`,size:16})}),(0,N.jsxs)(ee,{anchor:{to:`bottom end`,gap:4,padding:12},transition:!0,className:`tw-select-menu tw-menu-anim z-80 w-max min-w-[168px] space-y-0.5 rounded-lg p-1 pb-2 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:[(0,N.jsx)(d,{children:(0,N.jsx)(`button`,{type:`button`,className:`flex w-full items-center rounded-md px-2.5 py-1.5 text-left text-sm text-stone-700 data-[focus]:bg-stone-50`,onClick:()=>{(navigator.clipboard?.writeText(P.dir))?.then(()=>gt(!0)).catch(()=>void 0),window.setTimeout(()=>gt(!1),1200)},children:ht?`已复制路径`:`复制项目路径`})}),(0,N.jsx)(d,{children:(0,N.jsx)(`button`,{type:`button`,className:`flex w-full items-center rounded-md px-2.5 py-1.5 text-left text-sm text-stone-700 data-[focus]:bg-stone-50`,onClick:()=>At(P),children:`重新指定目录`})}),(0,N.jsx)(`div`,{className:`my-1 h-px bg-stone-100`,"aria-hidden":`true`}),(0,N.jsx)(d,{children:(0,N.jsx)(`button`,{type:`button`,className:`flex w-full items-center rounded-md px-2.5 py-1.5 text-left text-sm text-red-600 data-[focus]:bg-red-50`,onClick:()=>ft(P),children:`移出项目`})})]})]}):null]})]})]}),!P&&!se?(0,N.jsx)(`p`,{className:`shrink-0 border-b border-stone-100 bg-stone-50/60 px-4 py-1.5 text-[11px] text-stone-500`,children:`还没有挂载项目。点右上角「挂载」选一个 Playwright / pytest / Selenium 目录,自动识别框架。`}):null,(0,N.jsx)(`div`,{className:`grid shrink-0 transition-[grid-template-rows,opacity] duration-200 ease-out ${Yt?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`}`,"aria-hidden":!Yt,children:(0,N.jsx)(`div`,{className:`overflow-hidden`,inert:!Yt,children:qt})}),(0,N.jsx)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:(0,N.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:P?bt?(0,N.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 px-6 py-10 text-center`,children:[(0,N.jsx)(`p`,{className:`text-sm font-medium text-stone-700`,children:`这个项目还没有挂载提示词`}),(0,N.jsx)(`p`,{className:`max-w-md text-xs leading-relaxed text-stone-500`,children:Ee===`run`?`挂载后才能运行用例:运行前的规划与命令都由提示词驱动,缺了它跑出来的结果不可信。`:Ee===`generate`?`挂载后才能生成:规划、探索、生成代码三段都按提示词里的要求执行。`:`历史记录里是已经跑完的结果,挂载提示词后可以重新跑同一条用例。`}),(0,N.jsx)(`button`,{type:`button`,className:`${G} mt-1`,onClick:()=>Ge(!0),children:`挂载提示词`}),(0,N.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:`一份提示词可同时挂给多个项目;也可以先去「提示词管理」新建一份`})]}):(0,N.jsxs)(N.Fragment,{children:[Ee===`run`?(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`text-xs text-stone-400`,children:`运行任务`}),(0,N.jsx)(ie,{options:Tt,value:wt?.id??`full`,onChange:e=>{S(e),P&&a(Dn(P.id),e)},compact:!0,className:`w-60`,ariaLabel:`运行任务`}),(0,N.jsxs)(`button`,{type:`button`,className:K,onClick:()=>{w(``),Be(!0)},disabled:Ze,"aria-label":`运行配置`,children:[(0,N.jsxs)(`svg`,{className:`h-3.5 w-3.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,N.jsx)(`path`,{d:`M4 7h10M18 7h2M4 17h4M12 17h8`}),(0,N.jsx)(`circle`,{cx:`16`,cy:`7`,r:`2`}),(0,N.jsx)(`circle`,{cx:`10`,cy:`17`,r:`2`})]}),`配置`]}),(0,N.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:W?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`button`,{type:`button`,className:`${G} cursor-default`,disabled:!0,children:[(0,N.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-white/90`}),`运行中…`]}),(0,N.jsx)(`button`,{type:`button`,className:kn,onClick:()=>void Wt(),disabled:Ye,children:Ye?`停止中…`:`停止`})]}):(0,N.jsxs)(`button`,{type:`button`,className:G,onClick:()=>void kt(),disabled:Ze||!P.exists,children:[(0,N.jsx)(Le,{name:`play`,size:14}),Ze?`启动中…`:Et?`重新运行`:`运行`]})})]}),P.exists?P.frameworkReady?null:(0,N.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-700`,children:P.readyHint||`运行环境未就绪,先按项目要求安装依赖后再运行。`}):(0,N.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 rounded-lg bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-700`,children:[`项目目录已不存在(换机器或被移动过),记录与历史报告不会丢。`,(0,N.jsx)(`button`,{type:`button`,className:`font-medium text-amber-800 underline underline-offset-2 hover:text-amber-900`,onClick:()=>At(P),children:`重新指定目录`})]}),D?(0,N.jsxs)(`div`,{className:`rounded-lg border border-stone-200 bg-stone-50/60 px-3 py-2.5`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-stone-600`,children:[(0,N.jsx)(y,{tone:Ae[D.status].tone,children:Ae[D.status].label}),(0,N.jsxs)(`span`,{className:`tabular-nums`,children:[`耗时 `,xe(Jt)]}),D.status===`running`?null:(0,N.jsx)(`span`,{className:`tabular-nums`,children:je(D)}),(0,N.jsx)(`span`,{className:D.command?`max-w-[360px] truncate font-mono text-[11px] text-stone-400`:`text-stone-400`,children:D.command?De(D.command):ve(D.args,D.framework)}),D.reportRel?(0,N.jsxs)(`span`,{className:`max-w-[320px] truncate font-mono text-[11px] text-stone-400`,children:[`存储:`,D.reportRel.replace(/\/[^/]+$/,``)]}):null,(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D.reportUrl&&D.status!==`running`?(0,N.jsx)(`a`,{className:K,href:D.reportUrl,target:`_blank`,rel:`noreferrer`,children:`查看报告`}):null,D.failed>0&&D.status!==`running`?(0,N.jsx)(`button`,{type:`button`,className:K,onClick:Gt,disabled:Ze||!P.exists,children:`重跑失败用例`}):null]})]}),D.error?(0,N.jsx)(`pre`,{className:`mt-2 max-h-24 overflow-auto whitespace-pre-wrap break-all rounded bg-red-50 px-2 py-1.5 text-[11px] leading-relaxed text-red-600`,children:D.error}):null]}):null,(0,N.jsxs)(`div`,{className:`flex min-h-[220px] flex-1 flex-col overflow-hidden rounded-lg border border-stone-200`,children:[(0,N.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-stone-100 bg-stone-50 px-3 text-xs text-stone-500`,children:[(0,N.jsx)(`span`,{children:`运行日志`}),W?(0,N.jsx)(`span`,{className:`text-[#3370ff]`,children:`实时`}):null,Je?(0,N.jsxs)(`span`,{className:`tabular-nums text-stone-400`,children:[Je.length,` 字符`]}):null]}),(0,N.jsx)(`pre`,{ref:et,onScroll:Ot,className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-all bg-white p-3 font-mono text-[12px] leading-relaxed text-stone-700`,children:Je||`运行后这里会显示实时输出…`})]})]}):null,Ee===`generate`?(0,N.jsx)(gn,{project:P,promptFile:F,onError:h},P.id):null,Ee===`history`?(0,N.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:E.length===0?(0,N.jsx)(Ie,{children:`还没有运行记录`}):(0,N.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-stone-200 text-left text-xs text-stone-400`,children:[(0,N.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`开始时间`}),(0,N.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`框架`}),(0,N.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`结果`}),(0,N.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`用例`}),(0,N.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`耗时`}),(0,N.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`参数`}),(0,N.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`操作`})]})}),(0,N.jsx)(`tbody`,{children:E.map(e=>(0,N.jsxs)(`tr`,{className:`border-b border-stone-100 last:border-0`,children:[(0,N.jsx)(`td`,{className:`whitespace-nowrap px-2 py-2 text-xs text-stone-600`,children:be(e.startedAt)}),(0,N.jsx)(`td`,{className:`whitespace-nowrap px-2 py-2 text-xs text-stone-500`,children:c.find(t=>t.id===e.framework)?.label??e.framework}),(0,N.jsx)(`td`,{className:`px-2 py-2`,children:(0,N.jsx)(y,{tone:Ae[e.status].tone,children:Ae[e.status].label})}),(0,N.jsx)(`td`,{className:`whitespace-nowrap px-2 py-2 text-xs tabular-nums text-stone-600`,children:e.total?`${e.passed}/${e.total} 通过${e.failed?` · ${e.failed} 失败`:``}`:`—`}),(0,N.jsx)(`td`,{className:`whitespace-nowrap px-2 py-2 text-xs tabular-nums text-stone-600`,children:xe(e.durationMs)}),(0,N.jsx)(`td`,{className:`max-w-[240px] truncate px-2 py-2 text-xs text-stone-500`,children:e.command?De(e.command):ve(e.args,e.framework)}),(0,N.jsxs)(`td`,{className:`whitespace-nowrap px-2 py-2 text-right`,children:[(0,N.jsx)(`button`,{type:`button`,className:`text-xs text-[#3370ff] hover:underline`,onClick:()=>{L(`run`),St(e.id).catch(e=>h(String(e)))},children:`日志`}),e.reportUrl?(0,N.jsx)(`a`,{className:`ml-3 text-xs text-[#3370ff] hover:underline`,href:e.reportUrl,target:`_blank`,rel:`noreferrer`,children:`报告`}):null,(0,N.jsx)(`button`,{type:`button`,className:`ml-3 text-xs text-red-500 hover:underline`,onClick:()=>mt(e),children:`删除`})]})]},e.id))})]})}):null]}):(0,N.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-1 px-6 py-10 text-center`,children:[(0,N.jsx)(`p`,{className:`text-sm text-stone-500`,children:`挂载一个项目后就能在这里运行用例`}),(0,N.jsx)(`p`,{className:`text-xs text-stone-400`,children:`移出项目只删除挂载记录,项目文件与历史报告都保留`})]})})}),(0,N.jsx)(pe,{open:We,prompts:T.map(e=>e.value),value:P?.promptFile&&T.some(e=>e.value===P.promptFile)?P.promptFile:``,force:bt,onClose:()=>Ge(!1),onMount:It,onCreate:Lt}),(0,N.jsx)(xt,{open:ze,projectName:P?.name??``,detected:U.filter(e=>!e.custom&&e.kind!==`full`),customTasks:P?.customTasks??[],hiddenCount:P?.hiddenTasks?.length??0,editedCount:(P?.taskOverrides??[]).length,error:C,onClose:()=>{Be(!1),w(``)},onAdd:(e,t)=>Vt(e,t),onRemove:e=>Ht(e),onEdit:(e,t,n)=>Rt(e,t,n),onHide:e=>zt(e),onReset:()=>Bt(),onRescan:()=>z().then(()=>void 0)}),(0,N.jsx)(re,{open:!!dt,title:`移出项目`,message:`确定把「${dt?.name??``}」移出挂载列表吗?\n只删除挂载记录,项目文件与历史报告都保留;该项目挂载的提示词也会自动取消引用。`,confirmLabel:`移出`,danger:`outline`,onClose:()=>ft(null),onConfirm:()=>{let e=dt;ft(null),e&&v(e.id).then(async()=>{let t=await z();if(e.id===u){let e=t[0]?.id??``;ne(e),a(Cn,e)}Se()}).catch(e=>h(e instanceof Error?e.message:String(e)))}}),(0,N.jsx)(re,{open:!!pt,title:`删除运行记录`,message:`会同时删除该次运行的 HTML 报告与原始日志,确定删除吗?`,confirmLabel:`删除`,danger:`solid`,onClose:()=>mt(null),onConfirm:()=>void Kt()})]})}export{An as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=`0.1.24`;export{e as t};
|