lantern-harness 0.1.19 → 0.1.21
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/builtin/session/lh-fs.mjs +41 -1
- package/cli/data-root.mjs +11 -6
- package/cli/seed-skip.mjs +72 -0
- package/cli/spaces.mjs +23 -9
- package/dist/500.html +4 -4
- package/dist/_astro/Base.NUwtco4a.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.BMvdPyIE.js → Base.astro_astro_type_script_index_0_lang.2J3Qrd4B.js} +1 -1
- package/dist/_astro/{CaseExecBoard.cBdsZU9e.js → CaseExecBoard.CwH1rd8R.js} +1 -1
- package/dist/_astro/CaseGenerateApp.CpL1po9n.js +9 -0
- package/dist/_astro/CasesLibrary.DAZMRzzt.js +19 -0
- package/dist/_astro/ChatApp.iDy6-iVA.js +212 -0
- package/dist/_astro/{DashboardBoard.BNuKH_zX.js → DashboardBoard.BDURPamv.js} +1 -1
- package/dist/_astro/ExcelFieldTags.CXif3Ilh.js +1 -0
- package/dist/_astro/{KnowledgeLibrary.D0r8ieOZ.js → KnowledgeLibrary.B_99kzox.js} +1 -1
- package/dist/_astro/{NavLibraries.D1J9BwYo.js → NavLibraries.RH3Sinuh.js} +1 -1
- package/dist/_astro/PluginsPage.B349vNQ7.js +1 -0
- package/dist/_astro/{PluginsPage.Du4g_yr4.js → PluginsPage.aQKIWMKz.js} +2 -2
- package/dist/_astro/{PmBugsBoard.BTtm1lki.js → PmBugsBoard.Catlw5fm.js} +1 -1
- package/dist/_astro/{PmIterationsBoard.Dm67iXe_.js → PmIterationsBoard.D4Bg969F.js} +1 -1
- package/dist/_astro/{PmProjectDetail.B7oWL7y-.js → PmProjectDetail.BYVt43oh.js} +1 -1
- package/dist/_astro/{PmProjectsBoard.8QI44RlE.js → PmProjectsBoard.D06_aCFK.js} +1 -1
- package/dist/_astro/PmRequirementsBoard.CyW9CfFH.js +1 -0
- package/dist/_astro/{PmRequirementsBoard.X98441HZ.js → PmRequirementsBoard.DuXUq0HB.js} +1 -1
- package/dist/_astro/PmShared.CwcLNMW2.js +1 -0
- package/dist/_astro/{PromptsLibrary.17cDZsjQ.js → PromptsLibrary.dMO4dOAT.js} +1 -1
- package/dist/_astro/{ReportsPage.BjcajHR6.js → ReportsPage.DOW1fswe.js} +1 -1
- package/dist/_astro/ReqAnalysisBoard.DQpPjNNr.js +29 -0
- package/dist/_astro/RequirementsLibrary.Dd2DRKxL.js +1 -0
- package/dist/_astro/SearchableSelect.DZb-mxqw.js +1 -0
- package/dist/_astro/{SettingsDialog.BMa8eGFr.js → SettingsDialog.BBYaIU0N.js} +1 -1
- package/dist/_astro/{SlideOverDrawer.HqVYaIjP.js → SlideOverDrawer.DMWJPD_W.js} +1 -1
- package/dist/_astro/{SpaceSwitcher.B8dzGxrR.js → SpaceSwitcher.DyzMNGfy.js} +2 -2
- package/dist/_astro/{TasksBoard.Bz_JL_uQ.js → TasksBoard.BODqpiYV.js} +1 -1
- package/dist/_astro/TemplatesLibrary.DDJLVEZk.js +1 -0
- package/dist/_astro/{TestStatsBoard.EIDxmU_8.js → TestStatsBoard.diX5s3sH.js} +1 -1
- package/dist/_astro/{TodosBoard.DV1VzVDe.js → TodosBoard.DQBEeiWU.js} +1 -1
- package/dist/_astro/{UiAutoBoard.BwKG4DcV.js → UiAutoBoard.3Xs5RjDq.js} +3 -3
- package/dist/_astro/app-version.BqfBCSsN.js +1 -0
- package/dist/_astro/case-fields.CtFiDM_d.js +1 -0
- package/dist/_astro/case-gen-run.BI_ld4oo.js +16 -0
- package/dist/_astro/case-review._K-6xl4v.js +3 -0
- package/dist/_astro/case-template.BGCVpSKI.js +5 -0
- package/dist/_astro/{i18n.B3BVhlok.js → i18n.CjqQGCAI.js} +1 -1
- package/dist/_astro/{index.astro_astro_type_script_index_0_lang.CM78W1qz.js → index.astro_astro_type_script_index_0_lang.DMnFoepS.js} +1 -1
- package/dist/_astro/{open-docs-in-session.B6uyOxPn.js → open-docs-in-session.Cj0J2-XT.js} +1 -1
- package/dist/_astro/{plugins.DYyAjBXb.js → plugins.CVM1IaoC.js} +1 -1
- package/dist/_astro/req-analysis.Dkbi-5A_.js +9 -0
- package/dist/_astro/{settings.BvxRxdqa.js → settings.B1yetppp.js} +2 -2
- package/dist/_astro/{spaces-client.Dy3tSPta.js → spaces-client.DnS6MgGy.js} +1 -1
- package/dist/_astro/story-review.DvCTzGfr.js +12 -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 -9
- package/dist/index.html +1 -1
- 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/lantern-harness.code-workspace +11 -0
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +8 -5
- package/lh-plugins/case-review-prompt.mjs +16 -13
- package/lh-plugins/lh-case-review.mjs +2 -0
- package/lh-plugins/lh-project-docs.mjs +17 -0
- package/lh-plugins/lh-reports.mjs +28 -44
- package/package.json +1 -1
- package/dist/_astro/Base.VCz1UVxQ.css +0 -1
- package/dist/_astro/CaseGenerateApp.DLcUOrpS.js +0 -9
- package/dist/_astro/CasesLibrary.BERmgS2j.js +0 -19
- package/dist/_astro/ChatApp.azDLrlxw.js +0 -226
- package/dist/_astro/ExcelFieldTags.ytbpKt-Z.js +0 -5
- package/dist/_astro/PluginsPage.BNlpKMUM.js +0 -1
- package/dist/_astro/PmRequirementsBoard.DMJVLCqz.js +0 -1
- package/dist/_astro/PmShared.DbDseTcc.js +0 -1
- package/dist/_astro/ReqAnalysisBoard.CBgma-zG.js +0 -29
- package/dist/_astro/RequirementsLibrary.B5TE-2Ds.js +0 -1
- package/dist/_astro/SearchableSelect.mvcBwegf.js +0 -1
- package/dist/_astro/TemplatesLibrary.DazYm5Sh.js +0 -1
- package/dist/_astro/app-version.CdxtY1WM.js +0 -1
- package/dist/_astro/case-review.DYyZat83.js +0 -3
- package/dist/_astro/req-analysis.DGQa1vaH.js +0 -6
- package/dist/_astro/story-review.BjrulZG8.js +0 -10
- package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +0 -851
- package/dist/raw/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203.md +0 -168
- package/dist/raw/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277.md +0 -58
- package/dist/raw/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277.md +0 -54
- package/dist/raw/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277.md +0 -35
- package/dist/raw/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277.md +0 -48
- package/dist/raw/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277.md +0 -30
- package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +0 -710
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +0 -690
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +0 -652
- package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +0 -679
- package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +0 -654
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.CVM1IaoC.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{c as i,j as a}from"./pm.CagBA-ht.js";import{E as o,O as s,S as c,_ as l,b as u,g as d,k as f,m as p,o as m,u as h,x as g}from"./PmShared.CwcLNMW2.js";import _ from"./PmBugsBoard.Catlw5fm.js";import v from"./PmIterationsBoard.D4Bg969F.js";import{t as y}from"./PmRequirementsBoard.DuXUq0HB.js";var b=e(t(),1),x=r(),S=[`iterations`,`requirements`,`bugs`],C=`pm.project.tab`,w=`/pm/projects/`;function T(){let e=s(`projects`);return e.ready?e.on?(0,x.jsx)(u,{children:(0,x.jsx)(E,{})}):(0,x.jsx)(l,{children:n(`projects`)}):(0,x.jsx)(d,{label:`正在读取插件开关`})}function E(){let{store:e,live:t,loading:n}=f(),[r,s]=(0,b.useState)(``),[u,T]=o(C,S,`iterations`);(0,b.useEffect)(()=>{s(new URLSearchParams(window.location.search).get(`id`)??``)},[]);let E=(0,b.useMemo)(()=>e.projects.find(e=>e.id===r),[e.projects,r]),O=(0,b.useMemo)(()=>a(e),[e]);if(t===null)return(0,x.jsx)(d,{label:`正在连接项目管理服务`});if(!t)return(0,x.jsx)(l,{children:`项目详情需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(!E)return n&&!e.projects.length?(0,x.jsx)(d,{label:`正在读取项目`}):(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsx)(D,{}),(0,x.jsx)(h,{icon:`folder`,title:`没有找到这个项目`,hint:`它可能已被删除,或链接里的项目 id 不正确。`})]});let k=O[E.id],A=[{value:`iterations`,label:`迭代`,count:k?.iterations??0},{value:`requirements`,label:`需求`,count:k?.requirements??0},{value:`bugs`,label:`缺陷`,count:k?.bugs??0}];return(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3`,children:[(0,x.jsx)(`a`,{href:w,"aria-label":`返回项目列表`,className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-stone-500 transition-colors hover:bg-stone-100 hover:text-stone-800`,children:(0,x.jsx)(p,{name:`arrowLeft`,size:18})}),(0,x.jsx)(`span`,{className:`tw-pm-tile flex h-9 w-9 shrink-0 items-center justify-center rounded-xl text-sm font-bold`,children:E.name.slice(0,1)}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`h1`,{className:`truncate text-lg font-semibold text-stone-800`,children:E.name}),(0,x.jsx)(c,{tone:m[E.status],children:i[E.status]})]}),(0,x.jsx)(`p`,{className:`mt-0.5 text-xs ${E.description?`text-stone-400`:`text-stone-300 italic`}`,children:E.description||`暂无描述`})]})]}),(0,x.jsxs)(`div`,{className:`mt-5 flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[(0,x.jsx)(g,{tabs:A,value:u,onChange:T,ariaLabel:`项目二级菜单`}),(0,x.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`需求完成 `,k?.requirementPercent??0,`% · 缺陷完成 `,k?.bugClosedPercent??100,`%`]})]}),(0,x.jsxs)(`div`,{className:`mt-4 flex min-h-0 flex-1 flex-col`,children:[u===`iterations`?(0,x.jsx)(v,{scopeProjectId:E.id}):null,u===`requirements`?(0,x.jsx)(y,{scopeProjectId:E.id}):null,u===`bugs`?(0,x.jsx)(_,{scopeProjectId:E.id}):null]})]})}function D(){return(0,x.jsxs)(`a`,{href:w,className:`mb-2 inline-flex w-fit items-center gap-1.5 text-sm text-stone-500 transition-colors hover:text-stone-800`,children:[(0,x.jsx)(p,{name:`arrowLeft`,size:16}),`返回项目列表`]})}export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as ee}from"./plugins.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{s as ee}from"./plugins.CVM1IaoC.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.CsMwWevK.js";import{t as i}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as a}from"./Toast.BO2NFckG.js";import{I as o,S as te,c as s,g as ne,h as c,j as l,s as u}from"./pm.CagBA-ht.js";import{D as d,E as f,O as p,S as m,T 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.CwcLNMW2.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=p(`projects`),{store:t,live:n,loading:u,error:M,setError:N,reload:P}=se(),[F,I]=f(k,O,`all`),[L,R]=d(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:h(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)(m,{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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{t as default}from"./PmRequirementsBoard.DuXUq0HB.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.DYyAjBXb.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.CsMwWevK.js";import{n as a,t as ee}from"./DocsPager.v4kQH163.js";import{t as o}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as s}from"./Toast.BO2NFckG.js";import{A as c,C as l,E as u,I as d,L as f,d as p,f as m,g as h,h as g,k as _,l as v,m as y,u as b}from"./pm.CagBA-ht.js";import{C as x,D as S,E as te,O as ne,S as re,T as ie,_ as C,a as ae,c as oe,d as se,f as w,g as ce,h as T,k as le,l as ue,m as E,p as de,s as D,u as fe,w as O,y as k}from"./PmShared.DbDseTcc.js";var A=e(t(),1),j=r();function pe({value:e,onChange:t,entity:n,recordId:r=``,seenUrls:i,onError:a,onPersisted:ee}){let o=c(e),[s,l]=(0,A.useState)(!1),[p,m]=(0,A.useState)(!1),[h,g]=(0,A.useState)(null),v=(0,A.useRef)(null);(0,A.useEffect)(()=>{for(let t of c(e))i.current.add(t.url)},[e,i]);let b=(0,A.useCallback)(async n=>{if(n&&n.length){l(!0);try{let r=await f(Array.from(n));t(_([...c(e),...r])),a(``)}catch(e){a(e instanceof Error?e.message:String(e))}finally{l(!1),v.current&&(v.current.value=``)}}},[t,a,e]);(0,A.useEffect)(()=>{let e=e=>{let t=Array.from(e.clipboardData?.files??[]);t.length&&(e.preventDefault(),b(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[b]);async function x(e){let i=_(o.filter(t=>t.url!==e));if(r)try{await d(n,r,{attachment:i}),ee?.()}catch(e){a(e instanceof Error?e.message:String(e));return}t(i),y([e],r)}return(0,j.jsxs)(`div`,{className:`space-y-2 rounded-lg transition-colors ${p?`bg-[#3370ff]/5 ring-1 ring-[#3370ff]/40`:``}`,onDragOver:e=>{e.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:e=>{e.preventDefault(),m(!1),b(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:[u(e.url)?(0,j.jsx)(`button`,{type:`button`,onClick:()=>g(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)(E,{name:`file`,size:15})}),u(e.url)?(0,j.jsx)(`button`,{type:`button`,onClick:()=>g(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 x(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:v,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void b(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:()=>v.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)(E,{name:s?`file`:`plus`,size:13}),s?`上传中…`:`上传文件 / 图片`]}),(0,j.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可拖拽到这里,或直接粘贴截图(⌘V / Ctrl+V),支持多张`})]}),(0,j.jsx)(T,{file:h,onClose:()=>g(null)})]})}var me=20,he=`tw.pm-requirements.page-size.v1`,ge=[`all`,...p],_e=[`all`,...v],ve=`pm.requirements.project`,ye=`pm.requirements.iteration`,be=`pm.requirements.status`,xe=`pm.requirements.priority`,Se=`pm.requirements.keyword`,M=v.map(e=>({value:e,label:b[e]})),N=p.map(e=>({value:e,label:m[e]}));function Ce(e=``){return{projectId:e,iterationId:``,title:``,priority:`medium`,status:`pending`,description:``,acceptanceCriteria:[],githubIssue:``,attachment:``}}function P({scopeProjectId:e=``}={}){let t=!!e,r=ne(`pmRequirements`),{store:u,live:f,loading:p,error:_,setError:v,reload:T}=le(),[P,F]=S(ve,`all`),I=e||P,[L,R]=S(ye,`all`),[z,we]=te(be,ge,`all`),[B,Te]=te(xe,_e,`all`),[V,Ee]=S(Se),[De,H]=(0,A.useState)(1),[U,Oe]=a(me,he),[W,G]=(0,A.useState)(null),[K,q]=(0,A.useState)(!1),[J,Y]=(0,A.useState)(null),X=(0,A.useRef)(new Set),ke=(0,A.useMemo)(()=>[{value:`all`,label:`全部项目`},...u.projects.map(e=>({value:e.id,label:e.name}))],[u.projects]),Ae=(0,A.useMemo)(()=>[{value:`all`,label:`全部迭代`},...u.iterations.filter(e=>I===`all`||e.projectId===I).map(e=>({value:e.id,label:e.name}))],[u.iterations,I]),je=(0,A.useMemo)(()=>{let e=new Map(u.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[u.projects]),Me=(0,A.useMemo)(()=>{let e=new Map(u.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[u.iterations]),Z=(0,A.useMemo)(()=>l(u.requirements,{projectId:I,iterationId:L,status:z,priority:B,keyword:V}),[u.requirements,I,L,z,B,V]),Q=t?u.requirements.filter(e=>e.projectId===I).length:u.requirements.length,Ne=Math.max(1,Math.ceil(Z.length/U)),$=Math.min(De,Ne),Pe=Z.slice(($-1)*U,$*U);(0,A.useEffect)(()=>{t||f===!0&&P!==`all`&&!u.projects.some(e=>e.id===P)&&F(`all`)},[f,u.projects,P,F,t]),(0,A.useEffect)(()=>{f===!0&&L!==`all`&&!u.iterations.some(e=>e.id===L&&(I===`all`||e.projectId===I))&&R(`all`)},[f,u.iterations,I,L,R]);let Fe=W?u.iterations.filter(e=>e.projectId===W.projectId):[];async function Ie(){if(!W)return;if(!W.projectId){v(`请先选择所属项目`);return}let e=W.title.trim();if(!e)v(`需求描述不能为空`);else{q(!0);try{let t={projectId:W.projectId,iterationId:W.iterationId,title:e,priority:W.priority,status:W.status,description:W.description,acceptanceCriteria:W.acceptanceCriteria.filter(e=>e.text.trim()),githubIssue:W.githubIssue,attachment:W.attachment};W.id?await d(`requirements`,W.id,t):await g(`requirements`,[t]);let n=!!W.id;G(null),X.current.clear(),v(``),await T(!0),s(n?`已保存需求`:`已新建需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),s(`保存需求失败:${t}`,`error`)}finally{q(!1)}}}function Le(){let e=[...X.current,...c(W?.attachment??``).map(e=>e.url)];X.current.clear(),G(null),e.length&&y(e)}async function Re(e,t){q(!0);try{await d(`requirements`,e.id,{status:t}),await T(!0),s(`已更新需求状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),s(`更新状态失败:${t}`,`error`)}finally{q(!1)}}async function ze(){let e=J;if(e){Y(null),q(!0);try{await h(`requirements`,[e.id]),await T(!0),s(`已删除需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),s(`删除需求失败:${t}`,`error`)}finally{q(!1)}}}if(!r.ready)return(0,j.jsx)(ce,{label:`正在读取插件开关`});if(!r.on)return(0,j.jsx)(C,{children:n(`pmRequirements`)});if(f===null)return(0,j.jsx)(ce,{label:`正在连接项目管理服务`});if(!f)return(0,j.jsx)(C,{children:`需求管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(u.projects.length===0&&!p&&!t)return(0,j.jsx)(C,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护需求。`});let Be=[{value:`all`,label:`全部`},...N];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}),` 条需求`,Z.length===Q?``:` · 筛选出 ${Z.length} 条`]}),(0,j.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,j.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选需求`,className:`w-36`,options:ke,value:P,onChange:e=>{F(e),R(`all`),H(1)}}),(0,j.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选需求`,className:`w-32`,options:Ae,value:L,onChange:e=>{R(e),H(1)}}),(0,j.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按优先级筛选需求`,className:`w-28`,options:[{value:`all`,label:`全部优先级`},...M],value:B,onChange:e=>{Te(e),H(1)}}),(0,j.jsxs)(`label`,{className:`relative block`,children:[(0,j.jsx)(E,{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:V,onChange:e=>{Ee(e.target.value),H(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:K,onClick:()=>G(Ce(I===`all`?``:I)),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)(E,{name:`plus`,size:14}),`新建需求`]})]})]}),(0,j.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,j.jsx)(de,{ariaLabel:`按状态筛选需求`,options:Be,value:z,onChange:e=>{we(e),H(1)}})}),_?(0,j.jsx)(se,{message:_,onClose:()=>v(``)}):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`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,j.jsxs)(`table`,{className:`tw-data-table w-full border-collapse text-sm`,children:[(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.jsx)(`th`,{className:`w-24 px-4 py-2.5 text-left font-medium whitespace-nowrap`,children:`ID`}),(0,j.jsx)(`th`,{className:`px-4 py-2.5 text-left font-medium`,children:`需求描述`}),(0,j.jsx)(`th`,{className:`w-24 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`优先级`}),(0,j.jsx)(`th`,{className:`w-32 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`需求状态`}),t?null:(0,j.jsx)(`th`,{className:`w-40 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`所属项目`}),(0,j.jsx)(`th`,{className:`w-40 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`所属迭代`}),(0,j.jsx)(`th`,{className:`w-24 px-3 py-2.5 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,j.jsxs)(`tbody`,{children:[p&&!u.requirements.length?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:t?6:7,className:`px-4 py-16 text-center`,children:(0,j.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):Pe.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:t?6:7,children:Q?(0,j.jsx)(ue,{children:`没有符合筛选条件的需求。`}):(0,j.jsx)(fe,{icon:`file`,title:`暂无需求`,hint:`拆出第一条需求,再关联迭代、补充描述。`,action:(0,j.jsxs)(`button`,{type:`button`,onClick:()=>G(Ce(I===`all`?``:I)),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)(E,{name:`plus`,size:13}),`新建需求`]})})})}):null,Pe.map(e=>(0,j.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,j.jsx)(`td`,{className:`px-4 py-2.5 font-mono text-xs text-stone-400`,children:e.autoId}),(0,j.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,j.jsx)(`button`,{type:`button`,onClick:()=>G({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}),className:`max-w-full truncate text-left text-stone-800 hover:text-[#3370ff]`,children:e.title})}),(0,j.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,j.jsx)(re,{tone:x[e.priority],children:b[e.priority]})}),(0,j.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,j.jsx)(o,{unstyled:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:K,options:N,value:e.status,onChange:t=>void Re(e,t),renderOptionPrefix:e=>(0,j.jsx)(D,{tone:O[e.value]}),renderTrigger:()=>(0,j.jsx)(re,{tone:O[e.status],children:m[e.status]})})}),t?null:(0,j.jsx)(`td`,{className:`truncate px-3 py-2.5 text-sm text-stone-600`,children:(0,j.jsx)(`a`,{href:ie(e.projectId),className:`transition-colors hover:text-[#3370ff]`,children:je(e.projectId)})}),(0,j.jsx)(`td`,{className:`truncate px-3 py-2.5 text-sm text-stone-500`,children:Me(e.iterationId)}),(0,j.jsx)(`td`,{className:`px-3 py-2.5 text-center`,children:(0,j.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:K,onClick:()=>Y(e),className:`tw-icon-danger inline-flex h-7 w-7 items-center justify-center rounded-md`,children:(0,j.jsx)(E,{name:`trash`,size:15})})})]},e.id))]})]})}),Z.length>0?(0,j.jsx)(ee,{page:$,totalPages:Ne,pageSize:U,busy:K,onPage:H,onPageSize:e=>{Oe(e),H(1)}}):null]}),(0,j.jsx)(oe,{open:W!==null,title:W?.id?`编辑需求`:`新建需求`,busy:K,submitLabel:W?.id?`保存`:`创建`,onClose:()=>Le(),onSubmit:()=>void Ie(),children:W?(0,j.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,j.jsx)(w,{label:`所属项目`,required:!0,children:(0,j.jsx)(k,{ariaLabel:`所属项目`,options:u.projects.map(e=>({value:e.id,label:e.name})),value:W.projectId,onChange:e=>{let t=u.iterations.some(t=>t.id===W.iterationId&&t.projectId===e);G({...W,projectId:e,iterationId:t?W.iterationId:``})}})}),(0,j.jsx)(w,{label:`所属迭代`,children:(0,j.jsx)(k,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...Fe.map(e=>({value:e.id,label:e.name}))],value:W.iterationId,onChange:e=>G({...W,iterationId:e}),disabled:Fe.length===0})}),(0,j.jsx)(w,{label:`需求描述`,required:!0,children:(0,j.jsx)(`textarea`,{autoFocus:!0,value:W.title,onChange:e=>G({...W,title:e.target.value}),placeholder:`一句话写清要做什么`,rows:3,className:ae})}),(0,j.jsx)(w,{label:`优先级`,children:(0,j.jsx)(k,{ariaLabel:`优先级`,options:M,value:W.priority,onChange:e=>G({...W,priority:e}),renderOptionPrefix:e=>(0,j.jsx)(D,{tone:x[e.value]})})}),(0,j.jsx)(w,{label:`需求状态`,children:(0,j.jsx)(k,{ariaLabel:`需求状态`,options:N,value:W.status,onChange:e=>G({...W,status:e}),renderOptionPrefix:e=>(0,j.jsx)(D,{tone:O[e.value]})})}),(0,j.jsx)(w,{label:`附件`,children:(0,j.jsx)(pe,{value:W.attachment,onChange:e=>G(t=>t&&{...t,attachment:e}),entity:`requirements`,recordId:W.id??``,seenUrls:X,onError:v,onPersisted:()=>void T(!0)})}),(0,j.jsx)(w,{label:`备注`,children:(0,j.jsx)(`textarea`,{value:W.description,onChange:e=>G({...W,description:e.target.value}),placeholder:`补充背景、目标与范围(可选)`,rows:4,className:ae})})]}):null}),(0,j.jsx)(i,{open:J!==null,title:`删除需求`,message:`确定删除「${J?.title??``}」?关联的缺陷会保留,但不再关联到这条需求。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>Y(null),onConfirm:()=>void ze()})]})}export{P as t};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.CVM1IaoC.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.CsMwWevK.js";import{n as a,t as ee}from"./DocsPager.v4kQH163.js";import{t as o}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as s}from"./Toast.BO2NFckG.js";import{A as c,C as l,E as u,I as d,L as f,d as p,f as m,g as h,h as g,k as _,l as v,m as y,u as b}from"./pm.CagBA-ht.js";import{C as x,D as S,E as te,O as ne,S as re,T as ie,_ as C,a as ae,c as oe,d as se,f as w,g as ce,h as T,k as le,l as ue,m as E,p as de,s as D,u as fe,w as O,y as k}from"./PmShared.CwcLNMW2.js";var A=e(t(),1),j=r();function pe({value:e,onChange:t,entity:n,recordId:r=``,seenUrls:i,onError:a,onPersisted:ee}){let o=c(e),[s,l]=(0,A.useState)(!1),[p,m]=(0,A.useState)(!1),[h,g]=(0,A.useState)(null),v=(0,A.useRef)(null);(0,A.useEffect)(()=>{for(let t of c(e))i.current.add(t.url)},[e,i]);let b=(0,A.useCallback)(async n=>{if(n&&n.length){l(!0);try{let r=await f(Array.from(n));t(_([...c(e),...r])),a(``)}catch(e){a(e instanceof Error?e.message:String(e))}finally{l(!1),v.current&&(v.current.value=``)}}},[t,a,e]);(0,A.useEffect)(()=>{let e=e=>{let t=Array.from(e.clipboardData?.files??[]);t.length&&(e.preventDefault(),b(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[b]);async function x(e){let i=_(o.filter(t=>t.url!==e));if(r)try{await d(n,r,{attachment:i}),ee?.()}catch(e){a(e instanceof Error?e.message:String(e));return}t(i),y([e],r)}return(0,j.jsxs)(`div`,{className:`space-y-2 rounded-lg transition-colors ${p?`bg-[#3370ff]/5 ring-1 ring-[#3370ff]/40`:``}`,onDragOver:e=>{e.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:e=>{e.preventDefault(),m(!1),b(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:[u(e.url)?(0,j.jsx)(`button`,{type:`button`,onClick:()=>g(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)(E,{name:`file`,size:15})}),u(e.url)?(0,j.jsx)(`button`,{type:`button`,onClick:()=>g(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 x(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:v,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void b(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:()=>v.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)(E,{name:s?`file`:`plus`,size:13}),s?`上传中…`:`上传文件 / 图片`]}),(0,j.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可拖拽到这里,或直接粘贴截图(⌘V / Ctrl+V),支持多张`})]}),(0,j.jsx)(T,{file:h,onClose:()=>g(null)})]})}var me=20,he=`tw.pm-requirements.page-size.v1`,ge=[`all`,...p],_e=[`all`,...v],ve=`pm.requirements.project`,ye=`pm.requirements.iteration`,be=`pm.requirements.status`,xe=`pm.requirements.priority`,Se=`pm.requirements.keyword`,M=v.map(e=>({value:e,label:b[e]})),N=p.map(e=>({value:e,label:m[e]}));function Ce(e=``){return{projectId:e,iterationId:``,title:``,priority:`medium`,status:`pending`,description:``,acceptanceCriteria:[],githubIssue:``,attachment:``}}function P({scopeProjectId:e=``}={}){let t=!!e,r=ne(`pmRequirements`),{store:u,live:f,loading:p,error:_,setError:v,reload:T}=le(),[P,F]=S(ve,`all`),I=e||P,[L,R]=S(ye,`all`),[z,we]=te(be,ge,`all`),[B,Te]=te(xe,_e,`all`),[V,Ee]=S(Se),[De,H]=(0,A.useState)(1),[U,Oe]=a(me,he),[W,G]=(0,A.useState)(null),[K,q]=(0,A.useState)(!1),[J,Y]=(0,A.useState)(null),X=(0,A.useRef)(new Set),ke=(0,A.useMemo)(()=>[{value:`all`,label:`全部项目`},...u.projects.map(e=>({value:e.id,label:e.name}))],[u.projects]),Ae=(0,A.useMemo)(()=>[{value:`all`,label:`全部迭代`},...u.iterations.filter(e=>I===`all`||e.projectId===I).map(e=>({value:e.id,label:e.name}))],[u.iterations,I]),je=(0,A.useMemo)(()=>{let e=new Map(u.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[u.projects]),Me=(0,A.useMemo)(()=>{let e=new Map(u.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[u.iterations]),Z=(0,A.useMemo)(()=>l(u.requirements,{projectId:I,iterationId:L,status:z,priority:B,keyword:V}),[u.requirements,I,L,z,B,V]),Q=t?u.requirements.filter(e=>e.projectId===I).length:u.requirements.length,Ne=Math.max(1,Math.ceil(Z.length/U)),$=Math.min(De,Ne),Pe=Z.slice(($-1)*U,$*U);(0,A.useEffect)(()=>{t||f===!0&&P!==`all`&&!u.projects.some(e=>e.id===P)&&F(`all`)},[f,u.projects,P,F,t]),(0,A.useEffect)(()=>{f===!0&&L!==`all`&&!u.iterations.some(e=>e.id===L&&(I===`all`||e.projectId===I))&&R(`all`)},[f,u.iterations,I,L,R]);let Fe=W?u.iterations.filter(e=>e.projectId===W.projectId):[];async function Ie(){if(!W)return;if(!W.projectId){v(`请先选择所属项目`);return}let e=W.title.trim();if(!e)v(`需求描述不能为空`);else{q(!0);try{let t={projectId:W.projectId,iterationId:W.iterationId,title:e,priority:W.priority,status:W.status,description:W.description,acceptanceCriteria:W.acceptanceCriteria.filter(e=>e.text.trim()),githubIssue:W.githubIssue,attachment:W.attachment};W.id?await d(`requirements`,W.id,t):await g(`requirements`,[t]);let n=!!W.id;G(null),X.current.clear(),v(``),await T(!0),s(n?`已保存需求`:`已新建需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),s(`保存需求失败:${t}`,`error`)}finally{q(!1)}}}function Le(){let e=[...X.current,...c(W?.attachment??``).map(e=>e.url)];X.current.clear(),G(null),e.length&&y(e)}async function Re(e,t){q(!0);try{await d(`requirements`,e.id,{status:t}),await T(!0),s(`已更新需求状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),s(`更新状态失败:${t}`,`error`)}finally{q(!1)}}async function ze(){let e=J;if(e){Y(null),q(!0);try{await h(`requirements`,[e.id]),await T(!0),s(`已删除需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),s(`删除需求失败:${t}`,`error`)}finally{q(!1)}}}if(!r.ready)return(0,j.jsx)(ce,{label:`正在读取插件开关`});if(!r.on)return(0,j.jsx)(C,{children:n(`pmRequirements`)});if(f===null)return(0,j.jsx)(ce,{label:`正在连接项目管理服务`});if(!f)return(0,j.jsx)(C,{children:`需求管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(u.projects.length===0&&!p&&!t)return(0,j.jsx)(C,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护需求。`});let Be=[{value:`all`,label:`全部`},...N];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}),` 条需求`,Z.length===Q?``:` · 筛选出 ${Z.length} 条`]}),(0,j.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,j.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选需求`,className:`w-36`,options:ke,value:P,onChange:e=>{F(e),R(`all`),H(1)}}),(0,j.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选需求`,className:`w-32`,options:Ae,value:L,onChange:e=>{R(e),H(1)}}),(0,j.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按优先级筛选需求`,className:`w-28`,options:[{value:`all`,label:`全部优先级`},...M],value:B,onChange:e=>{Te(e),H(1)}}),(0,j.jsxs)(`label`,{className:`relative block`,children:[(0,j.jsx)(E,{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:V,onChange:e=>{Ee(e.target.value),H(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:K,onClick:()=>G(Ce(I===`all`?``:I)),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)(E,{name:`plus`,size:14}),`新建需求`]})]})]}),(0,j.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,j.jsx)(de,{ariaLabel:`按状态筛选需求`,options:Be,value:z,onChange:e=>{we(e),H(1)}})}),_?(0,j.jsx)(se,{message:_,onClose:()=>v(``)}):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`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,j.jsxs)(`table`,{className:`tw-data-table w-full border-collapse text-sm`,children:[(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.jsx)(`th`,{className:`w-24 px-4 py-2.5 text-left font-medium whitespace-nowrap`,children:`ID`}),(0,j.jsx)(`th`,{className:`px-4 py-2.5 text-left font-medium`,children:`需求描述`}),(0,j.jsx)(`th`,{className:`w-24 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`优先级`}),(0,j.jsx)(`th`,{className:`w-32 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`需求状态`}),t?null:(0,j.jsx)(`th`,{className:`w-40 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`所属项目`}),(0,j.jsx)(`th`,{className:`w-40 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`所属迭代`}),(0,j.jsx)(`th`,{className:`w-24 px-3 py-2.5 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,j.jsxs)(`tbody`,{children:[p&&!u.requirements.length?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:t?6:7,className:`px-4 py-16 text-center`,children:(0,j.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):Pe.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:t?6:7,children:Q?(0,j.jsx)(ue,{children:`没有符合筛选条件的需求。`}):(0,j.jsx)(fe,{icon:`file`,title:`暂无需求`,hint:`拆出第一条需求,再关联迭代、补充描述。`,action:(0,j.jsxs)(`button`,{type:`button`,onClick:()=>G(Ce(I===`all`?``:I)),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)(E,{name:`plus`,size:13}),`新建需求`]})})})}):null,Pe.map(e=>(0,j.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,j.jsx)(`td`,{className:`px-4 py-2.5 font-mono text-xs text-stone-400`,children:e.autoId}),(0,j.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,j.jsx)(`button`,{type:`button`,onClick:()=>G({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}),className:`max-w-full truncate text-left text-stone-800 hover:text-[#3370ff]`,children:e.title})}),(0,j.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,j.jsx)(re,{tone:x[e.priority],children:b[e.priority]})}),(0,j.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,j.jsx)(o,{unstyled:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:K,options:N,value:e.status,onChange:t=>void Re(e,t),renderOptionPrefix:e=>(0,j.jsx)(D,{tone:O[e.value]}),renderTrigger:()=>(0,j.jsx)(re,{tone:O[e.status],children:m[e.status]})})}),t?null:(0,j.jsx)(`td`,{className:`truncate px-3 py-2.5 text-sm text-stone-600`,children:(0,j.jsx)(`a`,{href:ie(e.projectId),className:`transition-colors hover:text-[#3370ff]`,children:je(e.projectId)})}),(0,j.jsx)(`td`,{className:`truncate px-3 py-2.5 text-sm text-stone-500`,children:Me(e.iterationId)}),(0,j.jsx)(`td`,{className:`px-3 py-2.5 text-center`,children:(0,j.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:K,onClick:()=>Y(e),className:`tw-icon-danger inline-flex h-7 w-7 items-center justify-center rounded-md`,children:(0,j.jsx)(E,{name:`trash`,size:15})})})]},e.id))]})]})}),Z.length>0?(0,j.jsx)(ee,{page:$,totalPages:Ne,pageSize:U,busy:K,onPage:H,onPageSize:e=>{Oe(e),H(1)}}):null]}),(0,j.jsx)(oe,{open:W!==null,title:W?.id?`编辑需求`:`新建需求`,busy:K,submitLabel:W?.id?`保存`:`创建`,onClose:()=>Le(),onSubmit:()=>void Ie(),children:W?(0,j.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,j.jsx)(w,{label:`所属项目`,required:!0,children:(0,j.jsx)(k,{ariaLabel:`所属项目`,options:u.projects.map(e=>({value:e.id,label:e.name})),value:W.projectId,onChange:e=>{let t=u.iterations.some(t=>t.id===W.iterationId&&t.projectId===e);G({...W,projectId:e,iterationId:t?W.iterationId:``})}})}),(0,j.jsx)(w,{label:`所属迭代`,children:(0,j.jsx)(k,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...Fe.map(e=>({value:e.id,label:e.name}))],value:W.iterationId,onChange:e=>G({...W,iterationId:e}),disabled:Fe.length===0})}),(0,j.jsx)(w,{label:`需求描述`,required:!0,children:(0,j.jsx)(`textarea`,{autoFocus:!0,value:W.title,onChange:e=>G({...W,title:e.target.value}),placeholder:`一句话写清要做什么`,rows:3,className:ae})}),(0,j.jsx)(w,{label:`优先级`,children:(0,j.jsx)(k,{ariaLabel:`优先级`,options:M,value:W.priority,onChange:e=>G({...W,priority:e}),renderOptionPrefix:e=>(0,j.jsx)(D,{tone:x[e.value]})})}),(0,j.jsx)(w,{label:`需求状态`,children:(0,j.jsx)(k,{ariaLabel:`需求状态`,options:N,value:W.status,onChange:e=>G({...W,status:e}),renderOptionPrefix:e=>(0,j.jsx)(D,{tone:O[e.value]})})}),(0,j.jsx)(w,{label:`附件`,children:(0,j.jsx)(pe,{value:W.attachment,onChange:e=>G(t=>t&&{...t,attachment:e}),entity:`requirements`,recordId:W.id??``,seenUrls:X,onError:v,onPersisted:()=>void T(!0)})}),(0,j.jsx)(w,{label:`备注`,children:(0,j.jsx)(`textarea`,{value:W.description,onChange:e=>G({...W,description:e.target.value}),placeholder:`补充背景、目标与范围(可选)`,rows:4,className:ae})})]}):null}),(0,j.jsx)(i,{open:J!==null,title:`删除需求`,message:`确定删除「${J?.title??``}」?关联的缺陷会保留,但不再关联到这条需求。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>Y(null),onConfirm:()=>void ze()})]})}export{P as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i}from"./plugins.CVM1IaoC.js";import{a,n as o,o as s,r as c}from"./view-prefs.D1snIG5o.js";import{t as l}from"./react-dom.DLW9pGCF.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./SelectDropdown.Cb-QtC-D.js";import{t as f}from"./SlideOverDrawer.DMWJPD_W.js";import{_ as p,v as m,y as h}from"./pm.CagBA-ht.js";var g=e(t(),1),_=e(l(),1),v=u(),y=8e3;function b(e,t,n){let[r,i]=(0,g.useState)(()=>o(e,t,n));return[r,(0,g.useCallback)(t=>{i(t),a(e,t)},[e])]}function x(e,t=``){let[n,r]=(0,g.useState)(()=>c(e)||t);return[n,(0,g.useCallback)(n=>{r(n),s(e,n===t?``:n)},[e,t])]}function S(e){let[t,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(()=>r(e));return(0,g.useEffect)(()=>{let t=!0,o=i(()=>s(r(e)));return n().then(()=>{t&&(s(r(e)),a(!0))}),()=>{t=!1,o()}},[e]),{ready:t,on:o}}var C=(0,g.createContext)(null);function w(e){let[t,n]=(0,g.useState)(p),[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(!0),[s,c]=(0,g.useState)(``),l=(0,g.useRef)(!0),u=(0,g.useCallback)(async(e=!1)=>{e||o(!0);try{let e=await h();return l.current?(n(e),i(!0),c(``),e):null}catch(e){return l.current&&c(e instanceof Error?e.message:String(e)),null}finally{l.current&&!e&&o(!1)}},[]);return(0,g.useEffect)(()=>{if(!e){o(!1);return}l.current=!0;let t=null;return(async()=>{let e=await m();l.current&&(e?(await u(),l.current&&(i(!0),t=window.setInterval(()=>void u(!0),y))):(i(!1),o(!1)))})(),()=>{l.current=!1,t!==null&&window.clearInterval(t)}},[e,u]),{store:t,live:r,loading:a,error:s,setError:c,reload:u}}function T({children:e}){let t=w(!0);return(0,v.jsx)(C.Provider,{value:t,children:e})}function E(){let e=(0,g.useContext)(C),t=w(e===null);return e??t}var D={gray:`bg-stone-100 text-stone-600`,blue:`bg-[#e1eaff] text-[#1f4ec2]`,amber:`bg-[#fff1e3] text-[#a85b00]`,yellow:`bg-[#fff7d6] text-[#8a6100]`,red:`bg-[#fee4e3] text-[#c02a26]`,purple:`bg-[#efe7ff] text-[#5b32b4]`,green:`bg-[#d9f5d2] text-[#1d7a12]`,muted:`bg-stone-100 text-stone-400`},O={planning:`blue`,in_progress:`amber`,archived:`gray`},k={planning:`blue`,in_progress:`amber`,done:`green`},A={urgent:`red`,high:`amber`,medium:`yellow`,low:`gray`},j={pending:`gray`,todo:`blue`,in_progress:`blue`,testing:`purple`,done:`green`,cancelled:`muted`},M={critical:`red`,major:`amber`,minor:`yellow`,trivial:`gray`},N={pending:`gray`,todo:`blue`,fixed:`amber`,verifying:`purple`,passed:`green`,cancelled:`muted`},P={gray:`#a8a29e`,blue:`#3370ff`,amber:`#f59e0b`,yellow:`#eab308`,red:`#ef4444`,purple:`#8b5cf6`,green:`#22c55e`,muted:`#d6d3d1`};function F({tone:e}){return(0,v.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:P[e]}})}function I({tone:e,children:t}){return(0,v.jsx)(`span`,{className:`inline-flex h-6 shrink-0 items-center rounded-md px-2 text-xs font-medium ${D[e]}`,children:t})}var L={plus:[`M12 5v14`,`M5 12h14`],more:[],chevronRight:[`m9 5 7 7-7 7`],chevronDown:[`m5 9 7 7 7-7`],arrowLeft:[`M19 12H5`,`m11 18-6-6 6-6`],pencil:[`M12 20h9`,`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`],trash:[`M3 6h18`,`M8 6V4h8v2`,`M19 6l-1 14H6L5 6`,`M10 11v6`,`M14 11v6`],copy:[`M9 9.5A1.5 1.5 0 0 1 10.5 8h7A1.5 1.5 0 0 1 19 9.5v7A1.5 1.5 0 0 1 17.5 18h-7A1.5 1.5 0 0 1 9 16.5Z`,`M5 15V5.5A1.5 1.5 0 0 1 6.5 4H15`],check:[`m4.5 12.5 5 5 10-11`],play:[`M8 5.5v13l11-6.5Z`],search:[`M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14Z`,`m20 20-3.6-3.6`],folder:[`M3 7.5A2.5 2.5 0 0 1 5.5 5h3.2l2 2h7.8A2.5 2.5 0 0 1 21 9.5v7A2.5 2.5 0 0 1 18.5 19h-13A2.5 2.5 0 0 1 3 16.5Z`],calendar:[`M4 7.5A2.5 2.5 0 0 1 6.5 5h11A2.5 2.5 0 0 1 20 7.5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2Z`,`M8 3v4`,`M16 3v4`,`M4 10h16`],file:[`M7 3.5h6.5L18 8v12.5H7Z`,`M13.5 3.5V8H18`,`M10 12.5h5`,`M10 16h5`],bug:[`M8.5 9.5h7V14a3.5 3.5 0 0 1-7 0Z`,`M9.5 6.2 12 8l2.5-1.8`,`M4.5 13H8.5`,`M15.5 13h4`,`M6 18.5l2-2`,`M18 18.5l-2-2`]};function R({name:e,size:t=16,className:n=``}){return e===`more`?(0,v.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,className:n,children:[(0,v.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.6`}),(0,v.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.6`}),(0,v.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.6`})]}):(0,v.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:n,children:L[e].map(e=>(0,v.jsx)(`path`,{d:e},e))})}function z({tabs:e,value:t,onChange:n,ariaLabel:r}){return(0,v.jsx)(`div`,{className:`tw-pm-tabs`,role:`tablist`,"aria-label":r,children:e.map(e=>(0,v.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:`tw-pm-tab`,children:[e.label,typeof e.count==`number`?(0,v.jsx)(`span`,{className:`tw-pm-tab-count`,children:e.count}):null]},e.value))})}function B({options:e,value:t,onChange:n,ariaLabel:r}){return(0,v.jsx)(`div`,{className:`tw-pm-pills`,role:`group`,"aria-label":r,children:e.map(e=>(0,v.jsx)(`button`,{type:`button`,"aria-pressed":t===e.value,onClick:()=>n(e.value),children:e.label},e.value))})}function V({icon:e,title:t,hint:n,action:r}){return(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-4 py-20 text-center`,children:[(0,v.jsx)(`span`,{className:`tw-pm-tile mb-4 flex h-16 w-16 items-center justify-center rounded-2xl`,children:(0,v.jsx)(R,{name:e,size:30})}),(0,v.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:t}),(0,v.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:n}),r?(0,v.jsx)(`div`,{className:`mt-4`,children:r}):null]})}function H(e){return`/pm/projects/detail/?id=${encodeURIComponent(e)}`}var U=`h-9 w-full rounded-md border border-transparent bg-transparent px-2 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`,W=`min-h-[72px] w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`;function G(e){return(0,v.jsx)(d,{flat:!0,menuMatchTrigger:!0,ariaLabel:e.ariaLabel,options:e.options,value:e.value,onChange:e.onChange,disabled:e.disabled,renderOptionPrefix:e.renderOptionPrefix})}function K({page:e,totalPages:t,busy:n=!1,onPage:r}){let i=`h-7 shrink-0 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`;return(0,v.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-center gap-2 pt-3`,children:[(0,v.jsx)(`button`,{type:`button`,className:i,disabled:n||e<=1,onClick:()=>r(e-1),children:`上一页`}),(0,v.jsxs)(`span`,{className:`px-2 text-xs tabular-nums text-stone-400`,children:[e,` / `,t]}),(0,v.jsx)(`button`,{type:`button`,className:i,disabled:n||e>=t,onClick:()=>r(e+1),children:`下一页`})]})}function q({label:e}){return(0,v.jsx)(`div`,{className:`flex min-h-[240px] items-center justify-center rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":e,children:(0,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}function J({children:e}){return(0,v.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:e})}function Y({children:e}){return(0,v.jsx)(`div`,{className:`px-4 py-16 text-center text-sm text-stone-400`,children:e})}function X({open:e,title:t,busy:n,submitLabel:r,onClose:i,onSubmit:a,children:o}){return(0,v.jsx)(f,{open:e,onClose:i,title:t,footer:(0,v.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-stone-100 px-2 py-3`,children:[(0,v.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 hover:bg-stone-100`,children:`取消`}),(0,v.jsx)(`button`,{type:`button`,disabled:n,onClick:a,className:`h-8 rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:r})]}),children:o})}function Z({label:e,required:t,children:n}){return(0,v.jsxs)(`div`,{className:`flex items-start gap-3 px-2 py-2`,children:[(0,v.jsx)(`div`,{className:`flex h-9 w-[88px] shrink-0 items-center text-sm text-stone-600`,children:(0,v.jsxs)(`span`,{className:`truncate`,children:[e,t?(0,v.jsx)(`span`,{className:`ml-0.5 text-red-500`,children:`*`}):null]})}),(0,v.jsx)(`div`,{className:`min-w-0 flex-1 [&>div]:mt-0`,children:n})]})}function Q({file:e,onClose:t}){return e?(0,_.createPortal)((0,v.jsxs)(`div`,{className:`fixed inset-0 z-[70] flex items-center justify-center bg-stone-900/70 p-6 sm:p-10`,role:`dialog`,"aria-modal":`true`,"aria-label":e.name,onClick:t,children:[(0,v.jsx)(`img`,{src:e.url,alt:e.name,className:`max-h-full max-w-full rounded-lg bg-white object-contain shadow-2xl`,onClick:e=>e.stopPropagation()}),(0,v.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,onClick:t,className:`absolute right-4 top-4 flex h-9 w-9 items-center justify-center rounded-full bg-white/90 text-lg text-stone-600 shadow-md transition-colors hover:bg-white hover:text-stone-900`,children:`✕`})]}),document.body):null}function $({message:e,onClose:t}){return(0,v.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,v.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,v.jsx)(`button`,{type:`button`,onClick:t,"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:`✕`})]})}export{A as C,x as D,b as E,S as O,I as S,H as T,J as _,W as a,T as b,X as c,$ as d,Z as f,q as g,Q as h,U as i,E as k,Y as l,R as m,N as n,O as o,B as p,k as r,F as s,M as t,V as u,K as v,j as w,z as x,G as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.CF1xVPmo.js";import{a as i,i as a,n as o,o as ee,s}from"./plugins.DYyAjBXb.js";import{t as c}from"./jsx-runtime.DUg_B_vD.js";import{t as te}from"./ConfirmDialog.CsMwWevK.js";import{showToast as l}from"./Toast.BO2NFckG.js";import{i as ne}from"./case-types.DS1EQ5yP.js";import{c as u,d,h as re,n as f,p as ie,r as ae,u as oe,v as se}from"./project-docs.DAw9bzgk.js";import{n as ce}from"./doc-roots.DAJP9Svr.js";import{a as p,c as m,d as le,i as h,l as g,o as _,s as v,u as y}from"./prompts-meta.C_MeYq8G.js";import{i as ue,n as de,r as fe,t as pe}from"./DocsFileBrowser.-dkkxR4X.js";import{t as me,u as he}from"./open-docs-in-session.B6uyOxPn.js";import{E as ge,T as _e,i as ve,r as ye}from"./case-review.DYyZat83.js";import{T as be,a as xe}from"./req-analysis.DGQa1vaH.js";import{r as Se}from"./report-prompt.CAfZ6RIo.js";import{g as Ce,s as we}from"./ui-auto.BmC9JJ_X.js";import{_ as Te,d as Ee,o as De,t as Oe}from"./story-review.BjrulZG8.js";import{t as b}from"./NamePromptDialog.CS1pTTVl.js";import{m as x}from"./PmShared.DbDseTcc.js";var S=e(t(),1),C=`tw.prompts.mounted.v1`;function ke(){try{let e=sessionStorage.getItem(r(C));if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t))typeof e==`string`&&typeof r==`string`&&(n[e]=r);return n}catch{return{}}}function Ae(e){try{sessionStorage.setItem(r(C),JSON.stringify(e))}catch{}}var w=c(),je=10;async function T(e=`.`){let{entries:t}=await u(`prompts`,e),n=[];for(let e of t)e.type===`file`?n.push(e):n.push(...await T(e.path));return n}function Me({path:e,enabled:t,mounted:n}){let r=y(e,n);if(!r)return(0,w.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`未关联`});if(r===`system`)return(0,w.jsx)(`span`,{className:`text-[11px] text-stone-600`,children:`系统默认`});let i=o(r)?.name??r,a=t[r]===!0,ee=_(e,n);return(0,w.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,w.jsx)(`span`,{className:`truncate text-[11px] text-stone-600`,children:i}),ee&&a?(0,w.jsx)(`span`,{className:`shrink-0 rounded bg-(--tw-accent-soft) px-1 text-[10px] text-(--tw-accent)`,children:`引用中`}):null]})}function E(){let e=fe(`prompts`),[t,r]=(0,S.useState)(!1),[c,u]=(0,S.useState)(!0),[_,C]=(0,S.useState)(e?!0:null),[E,Ne]=(0,S.useState)(()=>e??[]),[D,O]=(0,S.useState)(null),[k,A]=(0,S.useState)(!1),[j,M]=(0,S.useState)({}),[N,P]=(0,S.useState)(null),[F,I]=(0,S.useState)(()=>i()),[L,Pe]=(0,S.useState)(()=>ke()),[R,z]=(0,S.useState)(null),[B,V]=(0,S.useState)(null),[H,U]=(0,S.useState)(``),W=de(E,je,`prompts`),G=(0,S.useRef)(!1),K=(0,S.useRef)(!1),q=(0,S.useRef)(!1),J=(0,S.useRef)(!1),Fe=(0,S.useRef)(!1),Y=(0,S.useCallback)(async()=>{O(null);try{let e=await T(`.`);Ne(e),ue(`prompts`,e)}catch(e){O(e instanceof Error?e.message:String(e))}},[]);(0,S.useEffect)(()=>{_&&F.reqAnalysis===!0&&!G.current&&(E.some(e=>e.name===`需求分析提示词.md`)||(G.current=!0,be(!0).then(()=>Y()).catch(()=>void 0)))},[_,F.reqAnalysis,E,Y]),(0,S.useEffect)(()=>{_&&F.storyReview===!0&&!K.current&&(E.some(e=>e.name===`用户故事审查提示词.md`)||(K.current=!0,De(!0).then(()=>Y()).catch(()=>void 0)))},[_,F.storyReview,E,Y]),(0,S.useEffect)(()=>{_&&F.testPoints===!0&&!q.current&&(E.some(e=>e.name===`测试点生成提示词.md`)||(q.current=!0,Te(!0).then(()=>Y()).catch(()=>void 0)))},[_,F.testPoints,E,Y]),(0,S.useEffect)(()=>{_&&F.caseReview===!0&&!J.current&&(E.some(e=>e.name===`用例质量评审提示词.md`)||(J.current=!0,ge(!0).then(()=>Y()).catch(()=>void 0)))},[_,F.caseReview,E,Y]),(0,S.useEffect)(()=>{_&&F.caseBlindspot===!0&&!Fe.current&&(E.some(e=>e.name===`场景遗漏补全提示词.md`)||(Fe.current=!0,_e(!0).then(()=>Y()).catch(()=>void 0)))},[_,F.caseBlindspot,E,Y]),(0,S.useEffect)(()=>{let e=ee(e=>{u(!!e.prompts),I(e)});return n().then(()=>{u(a(`prompts`)),I(i()),r(!0)}),e},[]),(0,S.useEffect)(()=>{t&&c&&(async()=>{await ae(`prompts`)?(await he().catch(()=>null),await Y(),C(!0)):C(!1)})()},[t,c,Y]);let X=(0,S.useCallback)(async()=>{let e=await we(),t=a(`reports`),n=t?await Se().catch(()=>null):null;Pe(r=>{let i={};if(e)for(let t of e)i[m(t)]=`uiAuto`;else for(let[e,t]of Object.entries(r))t===`uiAuto`&&(i[e]=t);if(t){if(n?.promptFile)i[m(n.promptFile)]=`reports`;else for(let[e,t]of Object.entries(r))t===`reports`&&(i[e]=t)}if(F.reqAnalysis&&(i[m(xe)]=`reqAnalysis`),F.storyReview&&(i[m(Oe)]=`storyReview`),F.testPoints&&(i[m(Ee)]=`testPoints`),F.caseReview&&(i[m(ve)]=`caseReview`),F.caseBlindspot&&(i[m(ye)]=`caseBlindspot`),F.caseGen)for(let e of ne()){let t=(e.promptPath??``).trim();t&&(i[m(t)]=`caseGen`)}return Ae(i),i})},[F.reqAnalysis,F.storyReview,F.testPoints,F.caseReview,F.caseBlindspot,F.caseGen]);(0,S.useEffect)(()=>{if(!t||!c)return;X();let e=()=>{document.visibilityState===`visible`&&X()};document.addEventListener(`visibilitychange`,e);let n=Ce(()=>void X());return()=>{document.removeEventListener(`visibilitychange`,e),n()}},[t,c,F.uiAuto,F.reports,F.reqAnalysis,F.storyReview,F.testPoints,F.caseReview,F.caseBlindspot,F.caseGen,X]);let Z=(0,S.useMemo)(()=>Object.keys(j).filter(e=>j[e]),[j]),Q=(0,S.useCallback)(e=>{let t=y(e,L);return!t||t===`system`||le(e)?``:F[t]===!0?t:``},[L,F]);async function Ie(e){A(!0),O(null);try{await oe(`prompts`,e.path)}catch(e){O(e instanceof Error?e.message:String(e))}finally{A(!1)}}async function Le(e){A(!0),O(null);try{await me(`prompts`,e)}catch(e){O(e instanceof Error?e.message:String(e)),A(!1)}}function Re(e){if(v(e.path)){O(`默认提示词不可删除`);return}if(h(e.path,F)){O(g(e.path,F));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;O(`这份提示词正被「${e}」的项目挂载,先在那里换一份再删除`)}else P({kind:`one`,entry:e})}function ze(e){if(v(e.path)){O(`默认提示词不可改名`);return}if(h(e.path,F)){O(g(e.path,F));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;O(`这份提示词正被「${e}」的项目挂载,先在那里换一份再改名`)}else z(e),U(``)}function Be(e){V(e),U(``)}async function Ve(){let e=N;if(e){P(null),A(!0),O(null);try{if(e.kind===`one`)await f(`prompts`,e.entry.path);else{let t=0;for(let n of e.paths)v(n)||h(n,F)||Q(n)?t+=1:await f(`prompts`,n);t&&O(`有 ${t} 个提示词仍被插件或项目引用,已跳过;先解除引用再删。`),M({})}await Y(),l(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个提示词`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);O(t),l(`删除失败:${t}`,`error`)}finally{A(!1)}}}function He(){a(`promptGen`)?window.location.href=`/workbench/?plugin=promptGen`:O(s(`promptGen`))}let $=(0,S.useCallback)((e,t,n=``)=>{let r=(e===`.`?t:`${e}/${t}`).toLowerCase(),i=E.find(e=>e.path.toLowerCase()===r&&e.path.toLowerCase()!==n.toLowerCase());return i?i.name:``},[E]);async function Ue(e){let t=R;if(!t)return;let n=e.trim();if(!n||n===t.name){z(null),U(``);return}let r=$(d(t.path),n,t.path);if(r)U(`已存在同名文件「${r}」,换个名字再试`);else{A(!0),U(``);try{await re(`prompts`,t.path,n),z(null),await Y(),l(`已重命名为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);U(t),l(`重命名失败:${t}`,`error`)}finally{A(!1)}}}async function We(e){let t=B;if(!t)return;let n=e.trim();if(!n)return;let r=$(d(t.path),n);if(r)U(`已存在同名文件「${r}」,换个名字再试`);else{A(!0),U(``);try{let{content:e}=await ie(`prompts`,t.path);await se(`prompts`,d(t.path)===`.`?n:`${d(t.path)}/${n}`,e),V(null),await Y(),l(`已复制为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);U(t),l(`复制失败:${t}`,`error`)}finally{A(!1)}}}let Ge=N?.kind===`one`?`删除「${N.entry.name}」?将从 ${ce(`prompts`)} 中移除。`:N?.kind===`batch`?`确认删除已选中的 ${N.paths.length} 个提示词?此操作不可恢复。`:``;return t?c?_===null?(0,w.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,w.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,w.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):_?(0,w.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,w.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,w.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[W.query.trim()?(0,w.jsxs)(w.Fragment,{children:[`匹配 `,(0,w.jsx)(`span`,{className:`font-medium text-stone-800`,children:W.filtered.length}),` 个`,(0,w.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,E.length]})]}):(0,w.jsxs)(w.Fragment,{children:[`共 `,(0,w.jsx)(`span`,{className:`font-medium text-stone-800`,children:E.length}),` 个提示词`]}),Z.length>0?(0,w.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,Z.length]}):null]}),(0,w.jsx)(`button`,{type:`button`,disabled:k||Z.length===0,onClick:()=>P({kind:`batch`,paths:Z}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,w.jsx)(`button`,{type:`button`,disabled:k,onClick:He,className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`生成提示词`})]}),D?(0,w.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:D}):null,(0,w.jsx)(pe,{resizeKey:`docs:prompts:cols:v1`,files:E,filtered:W.filtered,pageFiles:W.pageFiles,query:W.query,onQuery:W.setQuery,sortBy:W.sortBy,onSortBy:W.setSortBy,page:W.page,totalPages:W.totalPages,pageSize:W.pageSize,onPage:W.setPage,onPageSize:W.setPageSize,busy:k,emptyText:`暂无提示词,点击「生成提示词」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selectable:e=>!p(e.path,F)&&!Q(e.path),selected:j,onToggleRow:e=>M(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>M(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void Ie(e),extraColumn:{header:`关联插件`,render:e=>(0,w.jsx)(Me,{path:e.path,enabled:F,mounted:L})},renderNameAction:e=>(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`button`,{type:`button`,disabled:k,"aria-label":`重命名 ${e.name}`,onClick:()=>ze(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,w.jsx)(x,{name:`pencil`,size:12})}),(0,w.jsx)(`button`,{type:`button`,disabled:k,"aria-label":`复制 ${e.name}`,onClick:()=>Be(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,w.jsx)(x,{name:`copy`,size:12})})]}),renderActions:e=>{let t=p(e.path,F)||!!Q(e.path);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>void Le(e),className:`inline-flex h-6 items-center whitespace-nowrap rounded bg-[#4176e6] px-2 text-xs text-white hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,w.jsx)(`button`,{type:`button`,disabled:k||t,"aria-label":`删除 ${e.name}`,onClick:()=>Re(e),className:`tw-icon-danger inline-flex h-6 w-6 items-center justify-center rounded`,children:(0,w.jsx)(x,{name:`trash`,size:12})})]})}}),(0,w.jsx)(b,{open:R!=null,title:`重命名提示词`,label:`文件名称`,initialValue:R?.name??``,lockExtension:!0,confirmLabel:`保存`,error:H,onClose:()=>{z(null),U(``)},onConfirm:e=>void Ue(e)}),(0,w.jsx)(b,{open:B!=null,title:`复制提示词`,label:`新文件名称`,initialValue:B?B.name.replace(/(\.[^.]+)?$/,e=>`(副本)${e}`):``,lockExtension:!0,confirmLabel:`复制`,error:H,onClose:()=>{V(null),U(``)},onConfirm:e=>void We(e)}),(0,w.jsx)(te,{open:N!=null,title:N?.kind===`batch`?`批量删除`:`删除提示词`,message:Ge,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>P(null),onConfirm:()=>void Ve()})]}):(0,w.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:`提示词管理需要本地文档服务,当前未就绪。`}):(0,w.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:s(`prompts`)}):(0,w.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,w.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,w.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{E as default};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.CF1xVPmo.js";import{a as i,i as a,n as o,o as ee,s}from"./plugins.CVM1IaoC.js";import{t as c}from"./jsx-runtime.DUg_B_vD.js";import{t as te}from"./ConfirmDialog.CsMwWevK.js";import{showToast as l}from"./Toast.BO2NFckG.js";import{i as ne}from"./case-types.DS1EQ5yP.js";import{c as u,d,h as re,n as f,p as ie,r as ae,u as oe,v as se}from"./project-docs.DAw9bzgk.js";import{n as ce}from"./doc-roots.DAJP9Svr.js";import{a as p,c as m,d as le,i as h,l as g,o as _,s as v,u as y}from"./prompts-meta.C_MeYq8G.js";import{i as ue,n as de,r as fe,t as pe}from"./DocsFileBrowser.-dkkxR4X.js";import{t as me,u as he}from"./open-docs-in-session.Cj0J2-XT.js";import{E as ge,T as _e,i as ve,r as ye}from"./case-review._K-6xl4v.js";import{D as be,a as xe}from"./req-analysis.Dkbi-5A_.js";import{r as Se}from"./report-prompt.CAfZ6RIo.js";import{g as Ce,s as we}from"./ui-auto.BmC9JJ_X.js";import{d as Te,o as Ee,t as De,v as Oe}from"./story-review.DvCTzGfr.js";import{t as b}from"./NamePromptDialog.CS1pTTVl.js";import{m as x}from"./PmShared.CwcLNMW2.js";var S=e(t(),1),C=`tw.prompts.mounted.v1`;function ke(){try{let e=sessionStorage.getItem(r(C));if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t))typeof e==`string`&&typeof r==`string`&&(n[e]=r);return n}catch{return{}}}function Ae(e){try{sessionStorage.setItem(r(C),JSON.stringify(e))}catch{}}var w=c(),je=10;async function T(e=`.`){let{entries:t}=await u(`prompts`,e),n=[];for(let e of t)e.type===`file`?n.push(e):n.push(...await T(e.path));return n}function Me({path:e,enabled:t,mounted:n}){let r=y(e,n);if(!r)return(0,w.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`未关联`});if(r===`system`)return(0,w.jsx)(`span`,{className:`text-[11px] text-stone-600`,children:`系统默认`});let i=o(r)?.name??r,a=t[r]===!0,ee=_(e,n);return(0,w.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,w.jsx)(`span`,{className:`truncate text-[11px] text-stone-600`,children:i}),ee&&a?(0,w.jsx)(`span`,{className:`shrink-0 rounded bg-(--tw-accent-soft) px-1 text-[10px] text-(--tw-accent)`,children:`引用中`}):null]})}function E(){let e=fe(`prompts`),[t,r]=(0,S.useState)(!1),[c,u]=(0,S.useState)(!0),[_,C]=(0,S.useState)(e?!0:null),[E,Ne]=(0,S.useState)(()=>e??[]),[D,O]=(0,S.useState)(null),[k,A]=(0,S.useState)(!1),[j,M]=(0,S.useState)({}),[N,P]=(0,S.useState)(null),[F,I]=(0,S.useState)(()=>i()),[L,Pe]=(0,S.useState)(()=>ke()),[R,z]=(0,S.useState)(null),[B,V]=(0,S.useState)(null),[H,U]=(0,S.useState)(``),W=de(E,je,`prompts`),G=(0,S.useRef)(!1),K=(0,S.useRef)(!1),q=(0,S.useRef)(!1),J=(0,S.useRef)(!1),Fe=(0,S.useRef)(!1),Y=(0,S.useCallback)(async()=>{O(null);try{let e=await T(`.`);Ne(e),ue(`prompts`,e)}catch(e){O(e instanceof Error?e.message:String(e))}},[]);(0,S.useEffect)(()=>{_&&F.reqAnalysis===!0&&!G.current&&(E.some(e=>e.name===`需求分析提示词.md`)||(G.current=!0,be(!0).then(()=>Y()).catch(()=>void 0)))},[_,F.reqAnalysis,E,Y]),(0,S.useEffect)(()=>{_&&F.storyReview===!0&&!K.current&&(E.some(e=>e.name===`用户故事审查提示词.md`)||(K.current=!0,Ee(!0).then(()=>Y()).catch(()=>void 0)))},[_,F.storyReview,E,Y]),(0,S.useEffect)(()=>{_&&F.testPoints===!0&&!q.current&&(E.some(e=>e.name===`测试点生成提示词.md`)||(q.current=!0,Oe(!0).then(()=>Y()).catch(()=>void 0)))},[_,F.testPoints,E,Y]),(0,S.useEffect)(()=>{_&&F.caseReview===!0&&!J.current&&(E.some(e=>e.name===`用例质量评审提示词.md`)||(J.current=!0,ge(!0).then(()=>Y()).catch(()=>void 0)))},[_,F.caseReview,E,Y]),(0,S.useEffect)(()=>{_&&F.caseBlindspot===!0&&!Fe.current&&(E.some(e=>e.name===`场景遗漏补全提示词.md`)||(Fe.current=!0,_e(!0).then(()=>Y()).catch(()=>void 0)))},[_,F.caseBlindspot,E,Y]),(0,S.useEffect)(()=>{let e=ee(e=>{u(!!e.prompts),I(e)});return n().then(()=>{u(a(`prompts`)),I(i()),r(!0)}),e},[]),(0,S.useEffect)(()=>{t&&c&&(async()=>{await ae(`prompts`)?(await he().catch(()=>null),await Y(),C(!0)):C(!1)})()},[t,c,Y]);let X=(0,S.useCallback)(async()=>{let e=await we(),t=a(`reports`),n=t?await Se().catch(()=>null):null;Pe(r=>{let i={};if(e)for(let t of e)i[m(t)]=`uiAuto`;else for(let[e,t]of Object.entries(r))t===`uiAuto`&&(i[e]=t);if(t){if(n?.promptFile)i[m(n.promptFile)]=`reports`;else for(let[e,t]of Object.entries(r))t===`reports`&&(i[e]=t)}if(F.reqAnalysis&&(i[m(xe)]=`reqAnalysis`),F.storyReview&&(i[m(De)]=`storyReview`),F.testPoints&&(i[m(Te)]=`testPoints`),F.caseReview&&(i[m(ve)]=`caseReview`),F.caseBlindspot&&(i[m(ye)]=`caseBlindspot`),F.caseGen)for(let e of ne()){let t=(e.promptPath??``).trim();t&&(i[m(t)]=`caseGen`)}return Ae(i),i})},[F.reqAnalysis,F.storyReview,F.testPoints,F.caseReview,F.caseBlindspot,F.caseGen]);(0,S.useEffect)(()=>{if(!t||!c)return;X();let e=()=>{document.visibilityState===`visible`&&X()};document.addEventListener(`visibilitychange`,e);let n=Ce(()=>void X());return()=>{document.removeEventListener(`visibilitychange`,e),n()}},[t,c,F.uiAuto,F.reports,F.reqAnalysis,F.storyReview,F.testPoints,F.caseReview,F.caseBlindspot,F.caseGen,X]);let Z=(0,S.useMemo)(()=>Object.keys(j).filter(e=>j[e]),[j]),Q=(0,S.useCallback)(e=>{let t=y(e,L);return!t||t===`system`||le(e)?``:F[t]===!0?t:``},[L,F]);async function Ie(e){A(!0),O(null);try{await oe(`prompts`,e.path)}catch(e){O(e instanceof Error?e.message:String(e))}finally{A(!1)}}async function Le(e){A(!0),O(null);try{await me(`prompts`,e)}catch(e){O(e instanceof Error?e.message:String(e)),A(!1)}}function Re(e){if(v(e.path)){O(`默认提示词不可删除`);return}if(h(e.path,F)){O(g(e.path,F));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;O(`这份提示词正被「${e}」的项目挂载,先在那里换一份再删除`)}else P({kind:`one`,entry:e})}function ze(e){if(v(e.path)){O(`默认提示词不可改名`);return}if(h(e.path,F)){O(g(e.path,F));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;O(`这份提示词正被「${e}」的项目挂载,先在那里换一份再改名`)}else z(e),U(``)}function Be(e){V(e),U(``)}async function Ve(){let e=N;if(e){P(null),A(!0),O(null);try{if(e.kind===`one`)await f(`prompts`,e.entry.path);else{let t=0;for(let n of e.paths)v(n)||h(n,F)||Q(n)?t+=1:await f(`prompts`,n);t&&O(`有 ${t} 个提示词仍被插件或项目引用,已跳过;先解除引用再删。`),M({})}await Y(),l(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个提示词`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);O(t),l(`删除失败:${t}`,`error`)}finally{A(!1)}}}function He(){a(`promptGen`)?window.location.href=`/workbench/?plugin=promptGen`:O(s(`promptGen`))}let $=(0,S.useCallback)((e,t,n=``)=>{let r=(e===`.`?t:`${e}/${t}`).toLowerCase(),i=E.find(e=>e.path.toLowerCase()===r&&e.path.toLowerCase()!==n.toLowerCase());return i?i.name:``},[E]);async function Ue(e){let t=R;if(!t)return;let n=e.trim();if(!n||n===t.name){z(null),U(``);return}let r=$(d(t.path),n,t.path);if(r)U(`已存在同名文件「${r}」,换个名字再试`);else{A(!0),U(``);try{await re(`prompts`,t.path,n),z(null),await Y(),l(`已重命名为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);U(t),l(`重命名失败:${t}`,`error`)}finally{A(!1)}}}async function We(e){let t=B;if(!t)return;let n=e.trim();if(!n)return;let r=$(d(t.path),n);if(r)U(`已存在同名文件「${r}」,换个名字再试`);else{A(!0),U(``);try{let{content:e}=await ie(`prompts`,t.path);await se(`prompts`,d(t.path)===`.`?n:`${d(t.path)}/${n}`,e),V(null),await Y(),l(`已复制为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);U(t),l(`复制失败:${t}`,`error`)}finally{A(!1)}}}let Ge=N?.kind===`one`?`删除「${N.entry.name}」?将从 ${ce(`prompts`)} 中移除。`:N?.kind===`batch`?`确认删除已选中的 ${N.paths.length} 个提示词?此操作不可恢复。`:``;return t?c?_===null?(0,w.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,w.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,w.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):_?(0,w.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,w.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,w.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[W.query.trim()?(0,w.jsxs)(w.Fragment,{children:[`匹配 `,(0,w.jsx)(`span`,{className:`font-medium text-stone-800`,children:W.filtered.length}),` 个`,(0,w.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,E.length]})]}):(0,w.jsxs)(w.Fragment,{children:[`共 `,(0,w.jsx)(`span`,{className:`font-medium text-stone-800`,children:E.length}),` 个提示词`]}),Z.length>0?(0,w.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,Z.length]}):null]}),(0,w.jsx)(`button`,{type:`button`,disabled:k||Z.length===0,onClick:()=>P({kind:`batch`,paths:Z}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,w.jsx)(`button`,{type:`button`,disabled:k,onClick:He,className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`生成提示词`})]}),D?(0,w.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:D}):null,(0,w.jsx)(pe,{resizeKey:`docs:prompts:cols:v1`,files:E,filtered:W.filtered,pageFiles:W.pageFiles,query:W.query,onQuery:W.setQuery,sortBy:W.sortBy,onSortBy:W.setSortBy,page:W.page,totalPages:W.totalPages,pageSize:W.pageSize,onPage:W.setPage,onPageSize:W.setPageSize,busy:k,emptyText:`暂无提示词,点击「生成提示词」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selectable:e=>!p(e.path,F)&&!Q(e.path),selected:j,onToggleRow:e=>M(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>M(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void Ie(e),extraColumn:{header:`关联插件`,render:e=>(0,w.jsx)(Me,{path:e.path,enabled:F,mounted:L})},renderNameAction:e=>(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`button`,{type:`button`,disabled:k,"aria-label":`重命名 ${e.name}`,onClick:()=>ze(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,w.jsx)(x,{name:`pencil`,size:12})}),(0,w.jsx)(`button`,{type:`button`,disabled:k,"aria-label":`复制 ${e.name}`,onClick:()=>Be(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,w.jsx)(x,{name:`copy`,size:12})})]}),renderActions:e=>{let t=p(e.path,F)||!!Q(e.path);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>void Le(e),className:`inline-flex h-6 items-center whitespace-nowrap rounded bg-[#4176e6] px-2 text-xs text-white hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,w.jsx)(`button`,{type:`button`,disabled:k||t,"aria-label":`删除 ${e.name}`,onClick:()=>Re(e),className:`tw-icon-danger inline-flex h-6 w-6 items-center justify-center rounded`,children:(0,w.jsx)(x,{name:`trash`,size:12})})]})}}),(0,w.jsx)(b,{open:R!=null,title:`重命名提示词`,label:`文件名称`,initialValue:R?.name??``,lockExtension:!0,confirmLabel:`保存`,error:H,onClose:()=>{z(null),U(``)},onConfirm:e=>void Ue(e)}),(0,w.jsx)(b,{open:B!=null,title:`复制提示词`,label:`新文件名称`,initialValue:B?B.name.replace(/(\.[^.]+)?$/,e=>`(副本)${e}`):``,lockExtension:!0,confirmLabel:`复制`,error:H,onClose:()=>{V(null),U(``)},onConfirm:e=>void We(e)}),(0,w.jsx)(te,{open:N!=null,title:N?.kind===`batch`?`批量删除`:`删除提示词`,message:Ge,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>P(null),onConfirm:()=>void Ve()})]}):(0,w.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:`提示词管理需要本地文档服务,当前未就绪。`}):(0,w.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:s(`prompts`)}):(0,w.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,w.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,w.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.CF1xVPmo.js";import{i,o as a,s as o}from"./plugins.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.CF1xVPmo.js";import{i,o as a,s as o}from"./plugins.CVM1IaoC.js";import{t as s}from"./jsx-runtime.DUg_B_vD.js";import{n as c,t as l}from"./DocsPager.v4kQH163.js";import{t as u}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as d}from"./Toast.BO2NFckG.js";import{a as ee,c as te,i as ne,o as re,s as f,t as p}from"./report-prompt.CAfZ6RIo.js";var m=e(t(),1),h=`tw.reports.kind.v1`,g=Object.keys(p);function _(e){return typeof e==`string`&&g.includes(e)}function v(e=`day`){try{let t=localStorage.getItem(r(h));return _(t)?t:e}catch{return e}}function y(e){if(_(e))try{localStorage.setItem(r(h),e)}catch{}}var b=s(),x=[`day`,`week`,`month`],S=20,C=`tw.reports.page-size.v1`;function w(e){return e.replace(/\.(md|markdown|txt)$/i,``)}function T(e){return e.replace(/\.(md|markdown|txt|html?)$/i,``)}function E(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}/${n(t.getMonth()+1)}/${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function ie(e){return!Number.isFinite(e)||e<=0?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var ae={day:`日`,week:`周`,month:`月`};function D(){let[e,t]=(0,m.useState)(!1),[r,s]=(0,m.useState)(!0),[h,g]=(0,m.useState)(()=>v()),_=(0,m.useRef)(h),[D,O]=(0,m.useState)([]),[k,A]=(0,m.useState)(``),[j,M]=(0,m.useState)(!1),[N,P]=(0,m.useState)(null),[F,I]=(0,m.useState)(``),[L,R]=(0,m.useState)([]),[z,B]=(0,m.useState)(``),[V,H]=(0,m.useState)(!1),[U,W]=(0,m.useState)(1),[G,K]=c(S,C),q=(0,m.useCallback)(async(e,t)=>{M(!0),P(null);try{if(t?.ensure)try{await te(!0)}catch{}let n=await ee(e);O(n.items),A(n.dir)}catch(e){let t=e instanceof Error?e.message:String(e);P(t.includes(`404`)?`工作汇报需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`:t),O([])}finally{M(!1)}},[]);(0,m.useEffect)(()=>{let e=a(e=>s(!!e.reports));return n().then(()=>{s(i(`reports`)),t(!0)}),e},[]);let J=(0,m.useCallback)(async()=>{try{let e=await ne();R(e.items),B(e.promptFile),e.promptFile||d(`没有读到「提示词管理」里的工作汇报提示词,写汇报前请先在提示词管理里补一份。`,`error`)}catch(e){let t=e instanceof Error?e.message:String(e);d(`读取工作汇报提示词失败:${t}`,`error`)}},[]);(0,m.useEffect)(()=>{e&&r&&(async()=>{await q(_.current,{ensure:!0}),await J()})()},[e,r,q,J]);function oe(e){y(e),e!==h&&(g(e),W(1),O([]),q(e))}async function se(e){if(e&&e!==z){H(!0),P(null);try{let t=await f(e);B(t),R(e=>e.map(e=>({...e,selected:e.name===t})))}catch(e){let t=e instanceof Error?e.message:String(e);P(t),d(`切换提示词失败:${t}`,`error`)}finally{H(!1)}}}let ce=(0,m.useMemo)(()=>L.length?L.map(e=>({value:e.name,label:w(e.name)})):[{value:``,label:`暂无提示词`}],[L]),Y=(0,m.useMemo)(()=>[...D].sort((e,t)=>t.generatedAt-e.generatedAt),[D]),X=Math.max(1,Math.ceil(Y.length/G)),Z=Math.min(U,X),le=(0,m.useMemo)(()=>Y.slice((Z-1)*G,Z*G),[Y,Z,G]),ue=`/workbench/?report=${h}`;async function Q(e){if(!F){I(e.name),P(null);try{await re(e.kind,e.name)}catch(e){P(e instanceof Error?e.message:String(e))}finally{I(``)}}}if(!e)return(0,b.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex items-center justify-center min-h-[220px]`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,b.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!r)return(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:o(`reports`)});let $=Y[0];return(0,b.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,b.jsxs)(`div`,{className:`shrink-0 border-b border-stone-100 px-4 py-3`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:x.map(e=>(0,b.jsx)(`button`,{type:`button`,onClick:()=>oe(e),className:`h-8 rounded-md px-3 text-sm transition-colors ${h===e?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:p[e]},e))}),(0,b.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,b.jsx)(u,{className:`w-[172px]`,flat:!0,options:ce,value:z,onChange:e=>void se(e),disabled:!L.length||V,ariaLabel:`选择工作汇报提示词`,menuMinWidth:200}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{await q(h),await J()})(),disabled:j,"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 disabled:opacity-40`,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)(`a`,{href:ue,className:`inline-flex h-9 items-center whitespace-nowrap rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9]`,children:`去工作台写汇报`})]})]}),(0,b.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-stone-400`,children:[(0,b.jsxs)(`span`,{children:[p[h],` · 共 `,D.length,` 篇`]}),$?(0,b.jsxs)(`span`,{className:`tabular-nums`,children:[`最近生成 `,E($.generatedAt)]}):null,(0,b.jsx)(`span`,{className:`min-w-0 truncate`,children:k||`—`}),(0,b.jsx)(`span`,{className:`ml-auto hidden shrink-0 sm:inline`,children:`点击卡片用系统默认程序打开`})]})]}),N?(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:N}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>P(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`,{className:`min-h-0 flex-1 overflow-auto bg-stone-50/60 p-3 sm:p-4`,children:j&&D.length===0?(0,b.jsx)(`div`,{className:`flex min-h-[180px] items-center justify-center`,"aria-busy":`true`,children:(0,b.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):D.length===0?(0,b.jsxs)(`div`,{className:`flex min-h-[260px] flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-stone-300 px-6 py-10 text-center`,children:[(0,b.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-xl bg-stone-100 text-stone-400`,children:(0,b.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,b.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,b.jsx)(`path`,{d:`M14 3v5h5`}),(0,b.jsx)(`path`,{d:`M9 13h6M9 17h4`})]})}),(0,b.jsxs)(`div`,{className:`text-sm font-medium text-stone-700`,children:[`还没有`,p[h]]}),(0,b.jsxs)(`p`,{className:`max-w-md text-xs leading-5 text-stone-400`,children:[`保存到 `,k||`工作汇报/${p[h]}`,` 后会自动出现在这里。`]})]}):(0,b.jsx)(`ul`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,380px),1fr))] gap-2.5`,children:le.map(e=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(`button`,{type:`button`,onClick:()=>void Q(e),disabled:!!F,className:`group flex w-full items-center gap-3 rounded-xl border border-stone-200 bg-white px-3.5 py-3 text-left transition-colors hover:border-[#3370ff]/50 hover:bg-stone-50 disabled:cursor-progress disabled:opacity-60`,children:[(0,b.jsx)(`span`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-stone-100 text-[13px] font-semibold text-stone-600`,children:ae[e.kind]}),(0,b.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`span`,{className:`block truncate text-sm font-medium text-stone-800 transition-colors group-hover:text-[#3370ff]`,children:T(e.name)}),(0,b.jsxs)(`span`,{className:`mt-0.5 block truncate text-xs text-stone-400 tabular-nums`,children:[E(e.generatedAt),` · `,ie(e.size)]})]}),(0,b.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 text-xs text-stone-400 transition-colors group-hover:text-[#3370ff]`,children:[F===e.name?`打开中…`:`打开`,(0,b.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,b.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})]})},e.name))})}),D.length>0?(0,b.jsx)(l,{page:Z,totalPages:X,pageSize:G,busy:j,onPage:W,onPageSize:e=>{K(e),W(1)}}):(0,b.jsx)(`div`,{className:`pb-2.5`})]})}export{D as default};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{s as r}from"./plugins.CVM1IaoC.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./view-prefs.D1snIG5o.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./ConfirmDialog.CsMwWevK.js";import{t as f}from"./OverflowHint.pvo2Xc8R.js";import{t as p}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as m}from"./Toast.BO2NFckG.js";import{o as h}from"./project-docs.DAw9bzgk.js";import{s as ee}from"./llm.BZEzE0x2.js";import{f as te,l as ne,p as g}from"./settings.B1yetppp.js";import{C as _,D as re,O as ie,S as ae,T as oe,_ as se,a as ce,b as le,c as ue,d as de,f as fe,g as pe,h as v,i as me,k as y,l as he,m as ge,n as _e,o as b,p as ve,r as ye,s as be,t as x,u as xe,v as Se,w as Ce,x as we,y as Te}from"./req-analysis.Dkbi-5A_.js";import{a as S,c as Ee,d as De,f as Oe,g as ke,h as Ae,i as je,l as Me,m as Ne,n as Pe,o as Fe,p as Ie,r as Le,s as Re,u as ze,v as Be}from"./story-review.DvCTzGfr.js";import{t as Ve}from"./hydrate-cache.CmC22o_H.js";import{O as He,S as C,_ as Ue,g as We,m as w,u as Ge}from"./PmShared.CwcLNMW2.js";var T=e(t(),1),Ke=`可用工具(只调用这些,不要自己编工具名):
|
|
2
|
+
- req_set_outline:提交本批「需求条目」,返回每个条目的 id。
|
|
3
|
+
- req_set_stories:提交「用户故事」;补写时提交合并后的完整故事集(带原 id 原地更新)。
|
|
4
|
+
- req_save_check:提交体检结果(缺口清单 + 结论)。
|
|
5
|
+
- req_save_test_points:提交测试点(功能 / 边界值 / 异常 / 业务规则 / 非功能五维,P0–P3)。
|
|
6
|
+
|
|
7
|
+
提交后不要重复提交同样的内容;工具返回 ok 之后再写最终回答。`,E=[`missing-scenario`,`missing-dimension`,`untestable-acceptance`,`conflict`,`over-split`,`other`];function qe(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function D(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function Je(e){return String(e??``).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``)}function O(e){let t=D(e,10);return t===`high`||t===`medium`||t===`low`?t:`medium`}function Ye(e){let t=D(e,40);return E.includes(t)?t:`other`}var k=[`functional`,`boundary`,`exception`,`business`,`nonfunctional`];function Xe(e){let t=D(e,40);if(k.includes(t))return t;let n=D(e,20);return k.find(e=>Re[e]===n)??`functional`}function A(e){let t=D(e,4).toUpperCase();return ze.includes(t)?t:`P1`}function Ze(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=D(n.title,200);if(!r)return null;let i=D(n.storyId,20);return{id:``,storyId:t.has(i)?i:``,dimension:Xe(n.dimension),priority:A(n.priority),title:r,precondition:D(n.precondition,1e3),steps:Array.isArray(n.steps)?n.steps.map(e=>D(e,500)).filter(Boolean).slice(0,20):[],expected:D(n.expected,1e3)}}var Qe=[{type:`function`,function:{name:`req_set_outline`,description:`提交本批从原始需求里抽出的需求条目(一条 = 一个可独立验收的能力点)。返回每个条目的 id,供 sourceRefs 引用。`,parameters:{type:`object`,properties:{items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`,description:`一句话概括`},quote:{type:`string`,description:`原文关键句,不超过 80 字`}},required:[`title`]}}},required:[`items`]}}},{type:`function`,function:{name:`req_set_stories`,description:`提交用户故事。拆解时只提交这一批新故事;补写时提交合并后的完整故事集(带原 id 的原地更新,新故事不带 id)。`,parameters:{type:`object`,properties:{stories:{type:`array`,items:{type:`object`,properties:{id:{type:`string`,description:`已有故事才带(US-001 这种)`},title:{type:`string`,description:`一句话说明这条故事做什么`},role:{type:`string`,description:`角色(来自原文;推断的要在 value 里注明)`},goal:{type:`string`,description:`用户想达成的目标`},value:{type:`string`,description:`业务价值 / 补充说明(角色为推断时写在这里)`},sourceRefs:{type:`array`,items:{type:`string`},description:`对应的需求条目 id(req_set_outline 返回的真实 id)`},priority:{type:`string`,enum:[`P0`,`P1`,`P2`]},preconditions:{type:`array`,items:{type:`string`}},mainFlow:{type:`array`,items:{type:`object`,properties:{actor:{type:`string`},action:{type:`string`,description:`动词开头的一步`},result:{type:`string`,description:`用户能看到的变化`}},required:[`action`]}},altFlows:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},trigger:{type:`string`,description:`什么情况下走这条替代路径`},steps:{type:`array`,items:{type:`string`}}},required:[`name`,`trigger`]}},exceptions:{type:`array`,items:{type:`object`,properties:{scenario:{type:`string`,description:`异常场景`},expected:{type:`string`,description:`系统应有的表现`}},required:[`scenario`,`expected`]}},postconditions:{type:`array`,items:{type:`string`}},acceptance:{type:`array`,items:{type:`object`,properties:{given:{type:`string`},when:{type:`string`},then:{type:`string`,description:`必须可判定`}},required:[`given`,`when`,`then`]}},dimensions:{type:`array`,items:{type:`string`},description:`权限 / 边界值 / 并发与幂等 / 空数据 / 超时与失败 / 国际化与时区`}},required:[`title`,`role`,`mainFlow`,`acceptance`]}}},required:[`stories`]}}},{type:`function`,function:{name:`req_save_check`,description:`提交需求体检结果:语义类缺口清单 + 两三句话结论。只出问题,不改写故事。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论,两三句话`},gaps:{type:`array`,items:{type:`object`,properties:{storyTitle:{type:`string`,description:`相关故事标题;全局问题填空串`},type:{type:`string`,enum:E},severity:{type:`string`,enum:[`high`,`medium`,`low`]},title:{type:`string`},detail:{type:`string`,description:`位置 + 原因`},suggestion:{type:`string`,description:`建议补写什么`}},required:[`title`,`detail`]}}},required:[`gaps`]}}},{type:`function`,function:{name:`req_save_test_points`,description:`提交基于用户故事拆出的测试点:功能 / 边界值 / 异常 / 业务规则 / 非功能五个维度全覆盖,每条标 P0–P3。一次提交全部,不要分多次。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论:几条、五维覆盖情况、最该先测什么`},points:{type:`array`,items:{type:`object`,properties:{storyId:{type:`string`,description:`对应故事 id(US-001 这种);全局测试点填空串`},dimension:{type:`string`,enum:k,description:`functional 功能 / boundary 边界值 / exception 异常 / business 业务规则 / nonfunctional 非功能`},priority:{type:`string`,enum:ze},title:{type:`string`,description:`一句话说清测什么(动词开头,带条件)`},precondition:{type:`string`,description:`执行前需要的数据 / 角色 / 状态`},steps:{type:`array`,items:{type:`string`},description:`可执行步骤,一步一个动作`},expected:{type:`string`,description:`可判定的预期结果,有阈值写具体数值`}},required:[`dimension`,`priority`,`title`]}}},required:[`points`]}}}];async function $e(e,t,n){let r=qe(t),i=n.getDoc();if(!i)return JSON.stringify({ok:!1,error:`当前还没有打开分析文档`});if(e===`req_set_outline`){let e=Array.isArray(r.items)?r.items:[];if(!e.length)return JSON.stringify({ok:!0,added:0,total:i.outline.length,items:i.outline.map(({id:e,title:t})=>({id:e,title:t})),note:`没有提交新条目,需求条目保持不变。`});let t=i.outline,a=new Set(t.map(e=>Je(e.title))),o=new Set(t.map(e=>e.id)),s=[];for(let t of e){let e=t&&typeof t==`object`?t:{},r=D(e.title,200)||D(e.quote,200);if(!r||a.has(Je(r)))continue;a.add(Je(r));let i=`RO-${n.batch+1}-${s.length+1}`,c=i,l=1;for(;o.has(c);)c=`${i}-${l++}`;o.add(c),s.push({id:c,title:r,quote:D(e.quote,500)})}let c=[...t,...s],l=await n.saveOutline(c);return JSON.stringify({ok:!0,added:s.length,total:l.length,items:l.map(({id:e,title:t})=>({id:e,title:t})),note:s.length>0?`条目已保存。接下来用 req_set_stories 提交故事,sourceRefs 只能引用上面返回的 id。`:`这些条目已经存在,没有重复写入;继续提交故事即可。`})}if(e===`req_set_stories`){let e=Array.isArray(r.stories)?r.stories:[];if(!e.length)return JSON.stringify({ok:!0,added:0,total:i.stories.length,note:`没有提交故事,故事集保持不变。`});let t=i.stories.length,a=Te(i.stories,e),o=await n.saveStories(a),s=new Set(i.outline.map(e=>e.id)),c=o.stories.flatMap(e=>e.sourceRefs).filter(e=>!s.has(e));return JSON.stringify({ok:!0,added:Math.max(0,o.stories.length-t),total:o.stories.length,stories:o.stories.map(({id:e,title:t,priority:n})=>({id:e,title:t,priority:n})),danglingSourceRefs:Array.from(new Set(c)).slice(0,10),note:c.length>0?`有些 sourceRefs 不在需求条目里,覆盖率会算不到;需要的话用真实条目 id 修正。`:`故事已保存。`})}if(e===`req_save_check`){let e=ue(i),t=new Map(i.stories.filter(e=>e.title).map(e=>[Je(e.title),e.id])),a=new Set(i.stories.map(e=>e.id)),o=Array.isArray(r.gaps)?r.gaps:[],s=[];for(let e of o){let n=e&&typeof e==`object`?e:{},r=D(n.title,200);if(!r)continue;let i=D(n.storyId,20),o=a.has(i)&&i||t.get(Je(D(n.storyTitle,200)))||``,c=Ye(n.type);s.push({id:v(c,o,r),storyId:o,type:c,severity:O(n.severity),title:r,detail:D(n.detail,1e3),suggestion:D(n.suggestion,1e3),origin:`model`,selected:!1})}let c=Se(e.gaps,s),l=D(r.summary,1500)||e.summary;return await n.saveCheck({...e,summary:l,gaps:c}),JSON.stringify({ok:!0,gaps:c.length,high:c.filter(e=>e.severity===`high`).length,coverage:e.coverage,dimensions:e.dimensions.map(e=>({label:e.label,covered:e.covered})),note:`体检报告已保存:整体 ${c.length} 个缺口(高 ${c.filter(e=>e.severity===`high`).length} 个),覆盖率 ${Math.round(e.coverage.rate*100)}%。用户可以在页面上勾选缺口补写。`})}if(e===`req_save_test_points`){let e=Array.isArray(r.points)?r.points:[];if(!e.length)return JSON.stringify({ok:!0,total:i.testPoints?.points.length??0,note:`没有提交测试点,原结果保持不变。`});if(typeof n.saveTestPoints!=`function`)return JSON.stringify({ok:!1,error:`当前上下文不支持保存测试点`});let t=new Set(i.stories.map(e=>e.id)),a=e.slice(0,500).map(e=>Ze(e,t)).filter(e=>e!==null);if(!a.length)return JSON.stringify({ok:!1,error:`测试点都缺少标题,没有保存`});let o=(await n.saveTestPoints({at:new Date().toISOString(),summary:D(r.summary,2e3),points:a})).testPoints?.points??a,s=k.map(e=>({dimension:Re[e],count:o.filter(t=>t.dimension===e).length})),c=ze.map(e=>({priority:e,count:o.filter(t=>t.priority===e).length})),l=s.filter(e=>e.count===0).map(e=>e.dimension);return JSON.stringify({ok:!0,total:o.length,byDimension:s,byPriority:c,uncoveredDimensions:l,note:l.length>0?`测试点已保存:整体 ${o.length} 条。${l.join(`、`)}还没有测试点,如确实不适用请在回答里说明。`:`测试点已保存:整体 ${o.length} 条,五个维度都有覆盖。`})}return JSON.stringify({ok:!1,error:`未知工具:${e}`})}function j(e){let t=[],n=/```json\s*([\s\S]*?)```/gi,r;for(;(r=n.exec(e))!==null;)r[1]?.trim()&&t.push(r[1].trim());return t}function et(e){let t=j(String(e??``));for(let e of t)try{let t=JSON.parse(e),n=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.stories)?t.stories:null;if(!n?.length)continue;let r=n.filter(e=>!!(e&&typeof e==`object`&&typeof e.title==`string`));if(r.length)return r}catch{}return[]}function tt(e,t=[]){let n=new Set(t),r=j(String(e??``));for(let e of r)try{let t=JSON.parse(e),r=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.points)?t.points:null;if(!r?.length)continue;let i=r.map(e=>Ze(e,n)).filter(e=>e!==null);if(!i.length)continue;let a=t&&typeof t==`object`&&!Array.isArray(t)?D(t.summary,2e3):``;return{at:new Date().toISOString(),summary:a,points:i}}catch{}return null}var M=u(),N=`text-xs font-semibold tracking-wide text-stone-500`,nt=`inline-flex h-7 items-center justify-center rounded-md bg-[#3370ff] px-2.5 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,P=`inline-flex h-7 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`;function rt({check:e,stories:t,busy:n,onToggleGap:r,onToggleAll:i,onFix:a,onReview:o,onExport:s}){if(!e)return(0,M.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-dashed border-stone-200 px-4 py-16 text-center`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有审查结果`}),(0,M.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`审查会先用固定规则核对覆盖率与字段完整性,再让模型专查场景遗漏与维度缺失(替代流程不成立、验收不可测也会一并报)。`}),(0,M.jsx)(`button`,{type:`button`,className:`mt-4 h-9 rounded-md bg-[#3370ff] px-4 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:n||!t.length,onClick:o,children:`开始审查`})]});let c=S(e.gaps),l=e.gaps.filter(e=>e.selected).length,u=e.coverage.total?Math.round(e.coverage.rate*100):0,d=Pe(e.gaps),p=new Map(t.map(e=>[e.id,e.title]));return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:N,children:`需求条目覆盖率`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.coverage.covered,(0,M.jsxs)(`span`,{className:`text-sm font-normal text-stone-400`,children:[` / `,e.coverage.total]}),(0,M.jsxs)(`span`,{className:`ml-2 text-sm font-normal text-stone-500`,children:[u,`%`]})]})]}),(0,M.jsxs)(`div`,{className:`min-w-[160px] flex-1`,children:[(0,M.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-stone-100`,children:(0,M.jsx)(`div`,{className:`h-full rounded-full transition-all ${u>=90?`bg-emerald-500`:u>=60?`bg-amber-500`:`bg-red-500`}`,style:{width:`${Math.max(u,e.coverage.total?2:0)}%`}})}),(0,M.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:e.coverage.total?`有故事引用的条目算覆盖;sourceRefs 为空的故事不会计入`:`还没有需求条目,先回「需求分析」做一次拆解`})]}),(0,M.jsxs)(`div`,{className:`text-right`,children:[(0,M.jsx)(`p`,{className:N,children:`缺口`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.gaps.length,(0,M.jsxs)(`span`,{className:`ml-1.5 text-xs font-normal text-stone-400`,children:[`高 `,d.high,` · 中 `,d.medium,` · 低 `,d.low]})]})]})]}),e.summary?(0,M.jsx)(`p`,{className:`mt-3 border-t border-stone-100 pt-2 text-xs leading-relaxed text-stone-500`,children:e.summary}):null]}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsx)(`p`,{className:N,children:`维度覆盖`}),(0,M.jsx)(`div`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2 lg:grid-cols-3`,children:e.dimensions.map(e=>{let t=e.stories.join(`, `);return(0,M.jsxs)(`div`,{"data-hint-width":!0,className:`min-w-0 rounded-lg border px-2.5 py-1.5 text-xs ${e.covered?`border-emerald-200 bg-emerald-50/60`:`border-stone-200 bg-stone-50`}`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 ${e.covered?`text-emerald-600`:`text-stone-400`}`,children:e.covered?`✓`:`—`}),(0,M.jsx)(`span`,{className:`shrink-0 whitespace-nowrap font-medium ${e.covered?`text-emerald-800`:`text-stone-500`}`,children:e.label}),(0,M.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.stories.length?`${e.stories.length} 条`:`未覆盖`})]}),(0,M.jsx)(`div`,{className:`mt-0.5 min-w-0 pl-[18px]`,children:t?(0,M.jsx)(f,{text:t,matchAnchorWidth:!0,className:`block truncate text-[11px] text-stone-400`}):(0,M.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:`没有故事覆盖`})})]},e.key)})})]}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-stone-100 px-4 py-2.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-700`,children:`缺口清单`}),(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`已选 `,l,` 条`]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,className:P,onClick:s,children:`导出 Markdown`}),(0,M.jsx)(`button`,{type:`button`,className:P,onClick:()=>i(l!==e.gaps.length),children:l===e.gaps.length&&e.gaps.length?`清空选择`:`全选`}),(0,M.jsx)(`button`,{type:`button`,className:nt,disabled:n||!l,onClick:a,children:`补写选中缺口`})]})]}),c.length?(0,M.jsx)(`div`,{className:`divide-y divide-stone-100`,children:c.map(e=>(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/60 px-4 py-1.5`,children:[(0,M.jsx)(`p`,{className:`text-xs font-semibold text-stone-600`,children:e.label}),(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500`,children:e.gaps.length}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e.hint})]}),(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.gaps.map(e=>(0,M.jsx)(it,{gap:e,storyTitle:p.get(e.storyId)??``,onToggle:r},e.id))})]},e.key))}):(0,M.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-stone-400`,children:`没有发现缺口。覆盖率与维度都过了,可以再人工过一遍验收标准。`})]})]})}function it({gap:e,storyTitle:t,onToggle:n}){return(0,M.jsxs)(`li`,{className:`flex items-start gap-2.5 px-4 py-2.5`,children:[(0,M.jsx)(`input`,{type:`checkbox`,className:`mt-1 h-3.5 w-3.5 shrink-0 accent-[#3370ff]`,checked:e.selected,onChange:t=>n(e.id,t.target.checked)}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,M.jsx)(C,{tone:_e[e.severity],children:x[e.severity]}),(0,M.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 text-[11px] text-stone-500`,children:ye[e.type]}),e.storyId?(0,M.jsxs)(`span`,{className:`font-mono text-[11px] text-stone-400`,children:[e.storyId,t?` · ${t}`:``]}):(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`全局`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:e.origin===`model`?`模型`:`规则`})]}),(0,M.jsx)(`p`,{className:`mt-0.5 text-sm text-stone-800`,children:e.title}),e.detail?(0,M.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-stone-500`,children:e.detail}):null,e.suggestion?(0,M.jsxs)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-amber-700`,children:[`建议:`,e.suggestion]}):null]})]})}var at=`reqanalysis.testPointsView`,ot=[`map`,`list`],F=`inline-flex h-7 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`;function st({point:e}){return(0,M.jsxs)(`div`,{className:`space-y-1 text-[11px] leading-relaxed text-stone-500`,children:[e.precondition?(0,M.jsxs)(`p`,{children:[(0,M.jsx)(`span`,{className:`text-stone-400`,children:`前置:`}),e.precondition]}):null,e.steps.length?(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-stone-400`,children:`步骤:`}),(0,M.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4`,children:e.steps.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})]}):null,e.expected?(0,M.jsxs)(`p`,{children:[(0,M.jsx)(`span`,{className:`text-stone-400`,children:`预期:`}),e.expected]}):null]})}function I({req:e}){return(0,M.jsxs)(`div`,{className:`flex items-stretch gap-0`,children:[(0,M.jsxs)(`div`,{className:`flex w-36 shrink-0 flex-col justify-center rounded-l-xl border border-r-0 border-[#c9d8ff] bg-[#f5f8ff] px-3 py-3`,children:[(0,M.jsx)(`p`,{className:`text-[11px] text-[#5b7fd6]`,children:`需求`}),(0,M.jsx)(`p`,{className:`text-sm font-semibold leading-snug text-stone-800`,children:e.title}),(0,M.jsxs)(`p`,{className:`mt-1 text-[11px] tabular-nums text-stone-400`,children:[e.points.length,` 条`]})]}),(0,M.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-hidden rounded-r-xl border border-stone-200 bg-white`,children:e.dimensions.map((e,t)=>{let n=Ee[e.key];return(0,M.jsxs)(`div`,{className:`flex w-[9.5rem] shrink-0 flex-col ${t>0?`border-l border-stone-100`:``}`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-1 border-b border-stone-100 px-2 py-1.5`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${n.accent}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`truncate text-[11px] font-medium text-stone-700`,children:n.label})]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-stone-400`,children:e.points.length})]}),(0,M.jsx)(`div`,{className:`max-h-52 space-y-1.5 overflow-y-auto px-1.5 py-1.5`,children:e.points.length?e.points.map(e=>(0,M.jsx)(`div`,{className:`rounded-lg border border-stone-100 bg-stone-50/70 px-1.5 py-1`,children:(0,M.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,M.jsx)(C,{tone:Me[e.priority].tone,children:e.priority}),(0,M.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-[11px] leading-snug text-stone-700`,children:e.title})]})},e.id)):(0,M.jsx)(`p`,{className:`py-3 text-center text-[11px] text-stone-300`,children:`无`})})]},e.key)})})]})}function L({doc:e,idealTitles:t}){let n=(0,T.useMemo)(()=>ke(e,t),[e,t]);return(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsx)(`div`,{className:`overflow-x-auto pb-1`,children:(0,M.jsx)(`div`,{className:`min-w-[62rem] space-y-3`,children:n.length?n.map(e=>(0,M.jsx)(I,{req:e},e.key)):(0,M.jsx)(`p`,{className:`py-8 text-center text-xs text-stone-400`,children:`还没有测试点。`})})}),(0,M.jsx)(`p`,{className:`text-center text-[11px] text-stone-400`,children:`每条需求横向展开五个维度;列过窄时整行左右滑动。导出 XMind 为同结构的向右逻辑图。`})]})}function R({doc:e,idealTitles:t}){let n=(0,T.useMemo)(()=>ke(e,t),[e,t]);return(0,M.jsx)(`div`,{className:`space-y-3`,children:n.map(e=>(0,M.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`border-b border-stone-100 bg-[#f8fafc] px-3.5 py-2.5`,children:[(0,M.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:`需求`}),(0,M.jsx)(`p`,{className:`text-sm font-semibold text-stone-800`,children:e.title}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-stone-400`,children:[e.points.length,` 条`]})]}),(0,M.jsx)(`div`,{className:`divide-y divide-stone-100`,children:e.dimensions.map(e=>(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3.5 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${Ee[e.key].accent}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`text-xs font-medium text-stone-700`,children:e.label}),(0,M.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-stone-400`,children:e.hint})]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.points.length})]}),e.points.length?(0,M.jsx)(`ul`,{className:`border-t border-stone-50`,children:e.points.map(e=>(0,M.jsx)(`li`,{className:`border-t border-stone-50 first:border-t-0`,children:(0,M.jsxs)(`details`,{className:`group px-3.5 py-2 pl-8`,children:[(0,M.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,M.jsx)(C,{tone:Me[e.priority].tone,children:e.priority})}),(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`span`,{className:`block text-sm text-stone-800`,children:e.title}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1.5 text-[11px] text-stone-400`,children:[(0,M.jsxs)(`span`,{children:[e.steps.length,` 步`]}),e.expected?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,M.jsx)(f,{text:e.expected,className:`min-w-0 flex-1 truncate`})]}):null]})]}),(0,M.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[11px] text-stone-300 group-open:hidden`,children:`展开`}),(0,M.jsx)(`span`,{className:`mt-0.5 hidden shrink-0 text-[11px] text-stone-300 group-open:inline`,children:`收起`})]}),(0,M.jsx)(`div`,{className:`mt-1.5 border-l-2 border-stone-100 pl-2.5`,children:(0,M.jsx)(st,{point:e})})]})},e.id))}):(0,M.jsx)(`p`,{className:`px-3.5 py-2 pl-8 text-[11px] text-stone-300`,children:`本维度没有测试点。`})]},e.key))})]},e.key))})}function ct({doc:e,idealTitles:t=[],generating:n,busy:r,promptReady:a,onExportXmind:s,onExportMarkdown:c}){let[l,u]=(0,T.useState)(()=>o(at,ot,`map`)),d=e.testPoints,f=Oe(d),p=!!e.sourcePath&&t.length===0,m=(0,T.useMemo)(()=>p?0:ke(e,t).length,[e,t,p]),h=e=>{u(e),i(at,e)};if(!d){let t=e.stories.length?a?``:`「测试点生成提示词.md」还没就绪,重新打开插件会自动补齐`:`还没有用户故事,先做一次拆解`;return(0,M.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-dashed border-stone-200 px-4 py-16 text-center`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有测试点`}),(0,M.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`按需求文档每一行整理标题,再按功能 / 边界值 / 异常 / 业务规则 / 非功能拆测试点;导图左右展开,可导出 XMind(向右逻辑图)与 Markdown。`}),t?(0,M.jsx)(`p`,{className:`mt-2 text-xs text-amber-700`,children:t}):null,(0,M.jsx)(`p`,{className:`mt-3 text-xs text-stone-400`,children:n?`正在生成测试点,完成后会自动出现在这里。`:`用左栏的「生成测试点」开始拆。`})]})}return(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-stone-200 bg-white px-3.5 py-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs text-stone-500`,children:[`需求 `,(0,M.jsx)(`span`,{className:`font-medium text-stone-700`,children:m}),` · 测试点`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-700`,children:f.total})]}),(0,M.jsx)(`span`,{className:`flex items-center gap-1`,children:ze.map(e=>(0,M.jsxs)(C,{tone:Me[e].tone,children:[e,` `,f.byPriority[e]]},e))}),(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`维度覆盖 `,f.coveredDimensions,`/5`]}),(0,M.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`flex overflow-hidden rounded-md border border-stone-200`,children:[{id:`map`,label:`导图`},{id:`list`,label:`列表`}].map(e=>(0,M.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs transition-colors ${l===e.id?`bg-[#eef3ff] font-medium text-[#1f4fd8]`:`bg-white text-stone-500 hover:bg-stone-50`}`,onClick:()=>h(e.id),children:e.label},e.id))}),(0,M.jsx)(`button`,{type:`button`,className:F,disabled:r,onClick:s,children:`导出 XMind`}),(0,M.jsx)(`button`,{type:`button`,className:F,disabled:r,onClick:c,children:`导出 Markdown`})]})]}),p?(0,M.jsxs)(`div`,{className:`flex items-center justify-center gap-2 rounded-xl border border-dashed border-stone-200 py-16 text-xs text-stone-400`,"aria-busy":`true`,children:[(0,M.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),`正在按需求文档行整理…`]}):l===`map`?(0,M.jsx)(L,{doc:e,idealTitles:t}):(0,M.jsx)(R,{doc:e,idealTitles:t}),d.summary?(0,M.jsxs)(`details`,{className:`rounded-xl border border-stone-200 bg-white px-3.5 py-2`,children:[(0,M.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-stone-600`,children:`生成说明`}),(0,M.jsx)(`p`,{className:`mt-1.5 text-xs leading-relaxed whitespace-pre-wrap text-stone-500`,children:d.summary})]}):null]})}var lt=[{value:`P0`,label:`P0 · 必须做`},{value:`P1`,label:`P1 · 应该做`},{value:`P2`,label:`P2 · 可以做`}],ut=`h-9 w-full rounded-md border border-stone-200 bg-white px-2 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`,dt=`w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`,z=`text-xs font-semibold tracking-wide text-stone-500`,ft=`text-[11px] font-medium tracking-wide text-stone-400`,pt={P0:`bg-red-400`,P1:`bg-amber-400`,P2:`bg-stone-300`};function B({label:e,children:t}){return(0,M.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-[88px_minmax(0,1fr)] sm:gap-3`,children:[(0,M.jsx)(`p`,{className:`${ft} pt-0.5`,children:e}),(0,M.jsx)(`div`,{className:`min-w-0 text-[13px] leading-relaxed text-stone-700`,children:t})]})}function V(e){return e.split(`
|
|
8
|
+
`).map(e=>e.trim()).filter(Boolean)}function mt({label:e,value:t,placeholder:n,onChange:r}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsxs)(`span`,{className:z,children:[e,`(一行一条)`]}),(0,M.jsx)(`textarea`,{className:`${dt} mt-1 min-h-[64px]`,value:t.join(`
|
|
9
|
+
`),placeholder:n,onChange:e=>r(V(e.target.value))})]})}function H({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`主流程(一行一步:动作 -> 结果)`}),(0,M.jsx)(`textarea`,{className:`${dt} mt-1 min-h-[80px]`,value:e.map(e=>e.result?`${e.action} -> ${e.result}`:e.action).join(`
|
|
10
|
+
`),placeholder:`填写申请单 -> 进入待审批`,onChange:e=>t(V(e.target.value).map(e=>{let t=e.indexOf(`->`)>=0?e.indexOf(`->`):e.indexOf(`→`);return t<0?{action:e}:{action:e.slice(0,t).trim(),result:e.slice(t+(e.startsWith(`->`,t)?2:1)).trim()}}))})]})}function ht({value:e,onChange:t}){let n=e.map(e=>[`${e.name} | ${e.trigger}`,...e.steps.map((e,t)=>`${t+1}. ${e}`)].join(`
|
|
11
|
+
`)).join(`
|
|
12
|
+
|
|
13
|
+
`);return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`替代流程(空行分段:名称 | 触发条件,下面写步骤)`}),(0,M.jsx)(`textarea`,{className:`${dt} mt-1 min-h-[80px]`,value:n,placeholder:`转人工审批 | 金额超过 5 万
|
|
14
|
+
1. 提交后进入人工队列
|
|
15
|
+
2. 审批通过再继续`,onChange:e=>t(e.target.value.split(/\n{2,}/).map(e=>{let t=e.split(`
|
|
16
|
+
`).map(e=>e.trim()).filter(Boolean),[n,r]=(t.shift()??``).split(`|`);return{name:(n??``).trim()||`替代流程`,trigger:(r??``).trim(),steps:t.map(e=>e.replace(/^\d+[.、)]\s*/,``))}}).filter(e=>e.name!==`替代流程`||e.steps.length||e.trigger))})]})}function gt({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`异常场景(一行一条:场景 -> 预期)`}),(0,M.jsx)(`textarea`,{className:`${dt} mt-1 min-h-[80px]`,value:e.map(e=>e.expected?`${e.scenario} -> ${e.expected}`:e.scenario).join(`
|
|
17
|
+
`),placeholder:`提交时网络中断 -> 提示重试并保留草稿`,onChange:e=>t(V(e.target.value).map(e=>{let t=e.indexOf(`->`)>=0?e.indexOf(`->`):e.indexOf(`→`);return t<0?{scenario:e,expected:``}:{scenario:e.slice(0,t).trim(),expected:e.slice(t+(e.startsWith(`->`,t)?2:1)).trim()}}))})]})}function _t({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`验收标准(一行一条:Given | When | Then)`}),(0,M.jsx)(`textarea`,{className:`${dt} mt-1 min-h-[80px]`,value:e.map(e=>`${e.given} | ${e.when} | ${e.then}`).join(`
|
|
18
|
+
`),placeholder:`已登录且有权限 | 提交申请单 | 列表里出现一条待审批记录`,onChange:e=>t(V(e.target.value).map(e=>{let[t=``,n=``,r=``]=e.split(`|`).map(e=>e.trim());return{given:t,when:n,then:r}}))})]})}function vt({story:e,index:t,total:n,gaps:r,busy:i,onSave:a,onDelete:o,onMove:s,domId:c}){let[l,u]=(0,T.useState)(!1),[d,f]=(0,T.useState)(!1),[m,h]=(0,T.useState)(e),[ee,te]=(0,T.useState)(!1);(0,T.useEffect)(()=>{if(l||d){te(!0);return}let e=window.setTimeout(()=>te(!1),200);return()=>window.clearTimeout(e)},[l,d]);let ne=()=>{h({...e}),f(!0),u(!0)},g=e=>h(t=>({...t,...e})),_=r.filter(e=>e.severity===`high`).length;return(0,M.jsxs)(`li`,{id:c,className:`overflow-hidden rounded-xl border bg-white transition-colors ${l||d?`border-stone-200 shadow-sm`:`border-stone-200 hover:border-stone-300`}`,children:[(0,M.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":l,"aria-label":l?`收起 ${e.id}`:`展开 ${e.id}`,className:`flex cursor-pointer items-start gap-3 px-3.5 py-3 outline-none transition-colors hover:bg-stone-50/70 focus-visible:bg-stone-50/70`,onClick:()=>u(e=>!e),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(e=>!e))},children:[(0,M.jsx)(`span`,{className:`mt-1 h-9 w-[3px] shrink-0 rounded-full ${pt[e.priority]}`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id||`待编号`}),(0,M.jsx)(C,{tone:b[e.priority],children:e.priority}),(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),r.length>0?(0,M.jsxs)(C,{tone:_?`red`:`amber`,children:[r.length,` 个缺口`,_?` · 高 ${_}`:``]}):null]}),(0,M.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-stone-500`,children:[e.role&&`角色:${e.role}`,e.goal&&`目标:${e.goal}`].filter(Boolean).join(` · `)||`还没有写角色与目标`}),l?null:(0,M.jsxs)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:[`验收 `,e.acceptance.length,` · 异常 `,e.exceptions.length,` · 维度`,` `,e.dimensions.length]})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-30`,"aria-label":`上移`,disabled:i||t===0,onClick:()=>s(-1),children:(0,M.jsx)(w,{name:`chevronRight`,size:14,className:`-rotate-90`})}),(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-30`,"aria-label":`下移`,disabled:i||t>=n-1,onClick:()=>s(1),children:(0,M.jsx)(w,{name:`chevronRight`,size:14,className:`rotate-90`})}),(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,"aria-label":d?`取消编辑`:`编辑`,onClick:()=>d?f(!1):ne(),children:(0,M.jsx)(w,{name:`pencil`,size:14})}),(0,M.jsx)(`button`,{type:`button`,className:`tw-icon-danger rounded p-1`,"aria-label":`删除`,disabled:i,onClick:o,children:(0,M.jsx)(w,{name:`trash`,size:14})}),(0,M.jsx)(w,{name:`chevronRight`,size:14,className:`ml-1 text-stone-300 transition-transform duration-150 ${l||d?`rotate-90`:``}`})]})]}),(0,M.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${l||d?`grid-rows-[1fr]`:`grid-rows-[0fr]`}`,children:(0,M.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[ee&&d?(0,M.jsxs)(`div`,{className:`space-y-3 border-t border-stone-100 px-4 py-3`,children:[(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`标题`}),(0,M.jsx)(`input`,{className:`${ut} mt-1`,value:m.title,onChange:e=>g({title:e.target.value})})]}),(0,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`角色`}),(0,M.jsx)(`input`,{className:`${ut} mt-1`,value:m.role,onChange:e=>g({role:e.target.value})})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`优先级`}),(0,M.jsx)(`div`,{className:`mt-1`,children:(0,M.jsx)(p,{options:lt,value:m.priority,onChange:e=>g({priority:e}),ariaLabel:`优先级`,flat:!0})})]})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`目标`}),(0,M.jsx)(`input`,{className:`${ut} mt-1`,value:m.goal,onChange:e=>g({goal:e.target.value})})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`价值 / 备注`}),(0,M.jsx)(`input`,{className:`${ut} mt-1`,value:m.value,onChange:e=>g({value:e.target.value})})]}),(0,M.jsx)(mt,{label:`前置条件`,value:m.preconditions,placeholder:`已登录且拥有申请权限`,onChange:e=>g({preconditions:e})}),(0,M.jsx)(H,{value:m.mainFlow,onChange:e=>g({mainFlow:e})}),(0,M.jsx)(ht,{value:m.altFlows,onChange:e=>g({altFlows:e})}),(0,M.jsx)(gt,{value:m.exceptions,onChange:e=>g({exceptions:e})}),(0,M.jsx)(mt,{label:`后置条件`,value:m.postconditions,placeholder:`申请单状态变为待审批`,onChange:e=>g({postconditions:e})}),(0,M.jsx)(_t,{value:m.acceptance,onChange:e=>g({acceptance:e})}),(0,M.jsx)(mt,{label:`覆盖维度`,value:m.dimensions,placeholder:`权限、边界值、超时与失败`,onChange:e=>g({dimensions:e})}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`来源条目:`,e.sourceRefs.join(`、`)||`(未关联)`]}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,className:`h-8 rounded-md border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,onClick:()=>f(!1),children:`取消`}),(0,M.jsx)(`button`,{type:`button`,className:`h-8 rounded-md bg-[#3370ff] px-3 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:i||!m.title.trim(),onClick:()=>{a(m),f(!1)},children:`保存`})]})]})]}):null,ee&&!d?(0,M.jsxs)(`div`,{className:`border-t border-stone-100 bg-stone-50/50 px-3.5 py-3.5`,children:[(0,M.jsxs)(`div`,{className:`space-y-3.5`,children:[e.value?(0,M.jsx)(B,{label:`价值`,children:e.value}):null,e.preconditions.length?(0,M.jsx)(B,{label:`前置条件`,children:(0,M.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.preconditions.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})}):null,e.mainFlow.length?(0,M.jsx)(B,{label:`主流程`,children:(0,M.jsx)(`ol`,{className:`list-decimal space-y-0.5 pl-4`,children:e.mainFlow.map((e,t)=>(0,M.jsxs)(`li`,{children:[e.actor?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[e.actor,`:`]}):null,e.action,e.result?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.result]}):null]},t))})}):null,e.altFlows.length?(0,M.jsx)(B,{label:`替代流程`,children:(0,M.jsx)(`ul`,{className:`space-y-1.5`,children:e.altFlows.map((e,t)=>(0,M.jsxs)(`li`,{children:[(0,M.jsxs)(`p`,{className:`font-medium text-stone-700`,children:[e.name,e.trigger?(0,M.jsxs)(`span`,{className:`font-normal text-stone-500`,children:[`(触发:`,e.trigger,`)`]}):null]}),(0,M.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4 text-stone-600`,children:e.steps.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})]},t))})}):null,e.exceptions.length?(0,M.jsx)(B,{label:`异常场景`,children:(0,M.jsx)(`ul`,{className:`space-y-0.5`,children:e.exceptions.map((e,t)=>(0,M.jsxs)(`li`,{children:[e.scenario,e.expected?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.expected]}):null]},t))})}):null,e.postconditions.length?(0,M.jsx)(B,{label:`后置条件`,children:(0,M.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.postconditions.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})}):null,e.acceptance.length?(0,M.jsx)(B,{label:`验收标准`,children:(0,M.jsx)(`ul`,{className:`space-y-1`,children:e.acceptance.map((e,t)=>(0,M.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5 rounded-md bg-white px-2 py-1 ring-1 ring-stone-100`,children:[(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Given`}),(0,M.jsx)(`span`,{children:e.given||`—`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`When`}),(0,M.jsx)(`span`,{children:e.when||`—`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Then`}),(0,M.jsx)(`span`,{className:e.then?`text-stone-800`:`text-red-500`,children:e.then||`(未写)`})]},t))})}):null,e.dimensions.length?(0,M.jsx)(B,{label:`覆盖维度`,children:(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.dimensions.map(e=>(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500 ring-1 ring-stone-100`,children:e},e))})}):null,(0,M.jsx)(B,{label:`来源条目`,children:(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.sourceRefs.length?e.sourceRefs.map(e=>(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 font-mono text-[11px] text-stone-500 ring-1 ring-stone-100`,children:e},e)):(0,M.jsx)(`span`,{className:`text-amber-600`,children:`未关联(覆盖率会算不到)`})})})]}),r.length?(0,M.jsxs)(`div`,{className:`mt-3 rounded-lg border border-amber-200 bg-amber-50/70 px-3 py-2`,children:[(0,M.jsx)(`p`,{className:`text-xs font-medium text-amber-900`,children:`审查发现的问题`}),(0,M.jsx)(`ul`,{className:`mt-1 space-y-1`,children:r.map(e=>(0,M.jsxs)(`li`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,M.jsx)(C,{tone:_e[e.severity],children:x[e.severity]}),(0,M.jsx)(`span`,{className:`text-stone-500`,children:ye[e.type]}),(0,M.jsx)(`span`,{className:`text-stone-700`,children:e.title})]},e.id))})]}):null]}):null]})})]})}var yt=`reqanalysis.doc`,bt=`reqanalysis.listmode`,xt=`reqanalysis.view`,St=`reqanalysis.tab`,Ct=`reqanalysis.storykeyword`,wt=[`list`,`work`],Tt=[`stories`,`check`,`outline`,`points`],Et=`reqanalysis.activity`,Dt=[`info`,`tool`,`done`,`error`,`stage`];function Ot(e){return`${Et}.${e}`}function kt(e){if(!e)return[];let t=l(Ot(e),[]);return Array.isArray(t)?t.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`number`&&typeof t.text==`string`&&typeof t.at==`string`&&typeof(t.detail??``)==`string`&&Dt.includes(t.kind)}).slice(-200):[]}var At=`reqanalysis.run`,jt=[`decompose`,`audit`,`fix`,`testpoints`],U=null,Mt={current:null},Nt=new Set;function Pt(e){return`${At}.${e}`}function Ft(e){let t=e?.docId??U?.docId;U=e,t&&a(Pt(t),e);for(let t of Nt)t(e)}function It(e){return Nt.add(e),()=>{Nt.delete(e)}}function W(e,t){if(!U||U.status!==`running`)return;let n=Math.max(0,Math.min(100,Math.round(e)));(n!==U.done||t!==void 0&&t!==U.message)&&Ft({...U,total:100,done:n,...t===void 0?{}:{message:t}})}var G=96;function Lt(e,t=1){if(!U||U.status!==`running`)return;let n=Math.max(1,Math.min(G,Math.round(e))),r=U.done;if(r>=n)return;let i=n-r,a=i>28?Math.min(Math.max(1,t),i):1;Ft({...U,total:100,done:Math.min(n,r+a)})}function Rt(e,t=1200){let n=0,r=window.setInterval(()=>{if(!U||U.status!==`running`)return;let t=Math.max(1,Math.min(G,Math.round(e)))-U.done;t<=0||(n+=1,n%(t>40?1:t>24?2:t>12?3:t>5?5:8)==0&&Lt(e,1))},t);return()=>window.clearInterval(r)}function zt(e){if(!e)return null;let t=l(Pt(e),null);if(!t||typeof t!=`object`)return null;let n=t;if(typeof n.label!=`string`||typeof n.message!=`string`||!jt.includes(n.kind))return null;let r=n.status===`done`||n.status===`error`?n.status:`stopped`;return{docId:e,kind:n.kind,label:n.label,done:Math.max(0,Number(n.done)||0),total:Math.max(0,Number(n.total)||0),message:n.message,startedAt:Number(n.startedAt)||0,status:r,finishedAt:Number(n.finishedAt)||void 0}}var Bt={md:`Markdown`,markdown:`Markdown`,txt:`文本`,csv:`CSV`,docx:`Word`,xlsx:`Excel`,xls:`Excel`,doc:`Word(旧版)`,pdf:`PDF`,ppt:`PPT`,pptx:`PPT`},Vt=`inline-flex h-9 items-center justify-center gap-1.5 rounded-md bg-[#3370ff] px-3.5 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,Ht=`inline-flex h-9 items-center justify-center gap-1.5 rounded-md border border-stone-200 bg-white px-3 text-sm text-stone-700 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`,Ut=`text-xs font-semibold tracking-wide text-stone-500`;function Wt(e){return e.split(`/`).pop()||e}function Gt(e){return(e.format||Wt(e.path).split(`.`).pop()||``).toLowerCase()}function Kt(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`),r=`${n(t.getMonth()+1)}/${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`;return t.getFullYear()===new Date().getFullYear()?r:`${t.getFullYear()}/${r}`}function qt(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function K(e,t=160){if(e==null)return``;let n=``;try{n=typeof e==`string`?e:JSON.stringify(e)}catch{return``}return n?n.length>t?`${n.slice(0,t)}…`:n:``}function Jt(e){let t=Math.max(0,(Date.now()-e)/1e3);return t<10?`${t.toFixed(1)}s`:`${Math.round(t)}s`}function Yt(e){return[...e].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))}function Xt({name:e,ready:t}){return(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(f,{text:e,className:`min-w-0 flex-1 truncate text-xs text-stone-500`}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-stone-400`}`,children:t?`已就绪`:`未就绪`})]})}function Zt(){let e=He(`reqAnalysis`),t=He(`storyReview`),u=He(`testPoints`),[v,_e]=(0,T.useState)(null),[b,ye]=(0,T.useState)([]),[x,Se]=(0,T.useState)(``),[S,Ee]=(0,T.useState)(null),[Oe,ke]=(0,T.useState)([]),[Me,Pe]=(0,T.useState)(``),[Re,ze]=(0,T.useState)(``),[E,qe]=(0,T.useState)(null),[D,Je]=(0,T.useState)(null),[O,Ye]=(0,T.useState)(null),[k,Xe]=(0,T.useState)(null),[A,Ze]=(0,T.useState)(()=>U);(0,T.useEffect)(()=>(Ze(U),It(Ze)),[]);let j=A?.status===`running`?A.kind:null,N=A?.status===`running`&&A.docId===x?{label:A.label,done:A.done,total:A.total,message:A.message}:null,nt=(0,T.useRef)(Date.now()),P=A&&A.docId===x&&A.status!==`running`&&(A.finishedAt??0)<nt.current?A:null,[it,at]=(0,T.useState)([]),[ot,F]=(0,T.useState)(``),[st,I]=(0,T.useState)(``),[L,R]=(0,T.useState)(()=>o(St,Tt,`stories`));(0,T.useEffect)(()=>{i(St,L)},[L]);let[lt,ut]=(0,T.useState)(`list`),dt=(0,T.useRef)(o(xt,wt,`list`)),[z,ft]=(0,T.useState)(!0),[pt,B]=(0,T.useState)(()=>o(bt,[`doc`,`story`],`doc`)),[V,mt]=(0,T.useState)(()=>c(Ct,``));(0,T.useEffect)(()=>{s(Ct,V)},[V]);let[H,ht]=(0,T.useState)(null),[gt,_t]=(0,T.useState)([]),Et=(0,T.useRef)(``),[Dt,At]=(0,T.useState)(``),[jt,Nt]=(0,T.useState)([]),G=(0,T.useRef)([]),[Zt,Qt]=(0,T.useState)(!1),[$t,en]=(0,T.useState)(!1),q=(0,T.useRef)(null),tn=(0,T.useRef)(0),nn=(0,T.useRef)(null),rn=(0,T.useRef)(null),an=(0,T.useCallback)(e=>t.on||e!==`checked`&&e!==`accepted`?be[e]:be.decomposed,[t.on]),on=(0,T.useMemo)(()=>{let e=e=>+!e.supported;return[...Oe].filter(e=>!h(e.name)).sort((t,n)=>e(t)-e(n)||t.path.localeCompare(n.path,`zh`)).map(e=>{let t=Gt(e),n=Bt[t]??t.toUpperCase();return{value:e.path,label:e.path,secondary:e.supported?t:`${n} · 暂不支持,请另存为 .docx / .xlsx / .md`,disabled:!e.supported}})},[Oe]),J=(0,T.useCallback)(e=>{q.current=e,Ee(e),ye(t=>Yt(t.map(t=>t.id===e.id?e:t)))},[]),Y=(0,T.useCallback)((e,t=`info`,n)=>{tn.current+=1,at(r=>[...r,{id:tn.current,kind:t,text:e,detail:n?.trim()||void 0,at:new Date().toISOString()}])},[]),X=(0,T.useCallback)((e,t,n,r)=>{Ft({docId:q.current?.id??``,kind:e,label:t,done:0,total:100,message:r,startedAt:Date.now(),status:`running`})},[]),sn=(0,T.useCallback)(e=>{if(!U||U.status!==`running`)return;let t=e.done==null?U.done:Math.max(0,Math.min(100,Math.round(e.done)));Ft({...U,...e,total:100,done:t})},[]),Z=(0,T.useCallback)((e,t,n)=>{U?.kind===e&&(Mt.current=null,Ft({...U,status:t,done:t===`done`?100:U.done,total:100,message:n??U.message,finishedAt:Date.now()}))},[]);(0,T.useEffect)(()=>{x&&Ze(U??zt(x))},[x]);let cn=(0,T.useCallback)(()=>{x&&a(Pt(x),null),Ft(null)},[x]),ln=(0,T.useRef)(!1);(0,T.useEffect)(()=>{if(!x){ln.current=!0,at([]);return}let e=kt(x);tn.current=e.reduce((e,t)=>Math.max(e,t.id),0),ln.current=!0,at(e)},[x]),(0,T.useEffect)(()=>{ln.current?ln.current=!1:x&&a(Ot(x),it.slice(-200))},[it,x]);let un=(0,T.useCallback)((e,t)=>{let n=G.current,r=n.length===t.length&&n.every((e,n)=>e===t[n]);G.current=t,r||Nt(t),e&&a(`reqanalysis.idealTitles.${e}`,t)},[]),Q=(0,T.useCallback)(e=>{if(q.current=e,Ee(e),Se(e?.id??``),s(yt,e?.id??``),e?.sourcePath&&Pe(e.sourcePath),e?.id){let t=l(`reqanalysis.idealTitles.${e.id}`,[]),n=Array.isArray(t)?t.filter(e=>typeof e==`string`):[];G.current=n,Nt(n)}else G.current=[],Nt([])},[]),dn=(0,T.useCallback)(e=>{ut(e),i(xt,e)},[]),fn=(0,T.useCallback)(async e=>{if(!e?.sourcePath)return un(``,[]),[];try{let t=await we(e.sourcePath),n=fe(t);return un(e.id,n),n}catch{return un(e.id,G.current),G.current}},[un]),pn=(0,T.useCallback)(async e=>{try{let t=await we(e.sourcePath),n=fe(t);return un(e.id,n),e}catch{return e}},[un]),mn=(0,T.useCallback)((e,t=`stories`)=>{Q(e),R(t),dn(`work`),Ve(`req-analysis`),pn(e)},[dn,Q,pn]),hn=(0,T.useCallback)((e,t)=>{Et.current=t,mn(e,`stories`)},[mn]);(0,T.useEffect)(()=>{if(lt!==`work`||!Et.current)return;let e=Et.current;Et.current=``;let t=0,n=requestAnimationFrame(()=>{let n=document.getElementById(`req-story-${e}`);n&&(n.scrollIntoView({block:`center`,behavior:`smooth`}),n.classList.add(`tw-req-story-focus`),t=window.setTimeout(()=>n.classList.remove(`tw-req-story-focus`),1600))});return()=>{cancelAnimationFrame(n),t&&window.clearTimeout(t)}},[lt,S?.id]);let gn=(0,T.useMemo)(()=>b.flatMap(e=>e.stories.map(t=>({doc:e,story:t}))),[b]),_n=gn.length,vn=(0,T.useMemo)(()=>{let e=V.trim().toLowerCase(),t=t=>String(t??``).toLowerCase().includes(e),n=e?gn.filter(({doc:e,story:n})=>t(n.id)||t(n.title)||t(n.role)||t(n.goal)||t(_(e))||t(e.title)):gn,r=[],i=new Map;for(let e of n){let t=i.get(e.doc.id);t===void 0?(i.set(e.doc.id,r.length),r.push({doc:e.doc,rows:[e]})):r[t].rows.push(e)}return r.sort((e,t)=>t.doc.updatedAt.localeCompare(e.doc.updatedAt))},[gn,V]),yn=(0,T.useMemo)(()=>new Set(H?.ids??[]),[H]),bn=(0,T.useCallback)((e,t)=>{ht(n=>{if(!n||n.docId!==e)return{docId:e,ids:[t]};let r=n.ids.includes(t)?n.ids.filter(e=>e!==t):[...n.ids,t];return r.length?{docId:e,ids:r}:null})},[]),xn=(0,T.useCallback)((e,t)=>{ht(n=>n?.docId===e&&t.every(e=>n.ids.includes(e))?null:t.length?{docId:e,ids:t}:null)},[]),Sn=(0,T.useCallback)(e=>{B(e),i(bt,e)},[]);(0,T.useEffect)(()=>{let e=!0;(async()=>{if(await n(),!e)return;qe(ne());let t=await ve();if(e){if(_e(t),!t)ft(!1);else try{let[t,n,r,i]=await Promise.all([pe(),ge(),je(),Ae()]);if(!e)return;let a=n;if((!n.exists||!n.decompose.trim())&&(await re(!0).catch(()=>void 0),a=await ge()),!e)return;Je(a);let o=r;if((!r.exists||!r.review.trim())&&(await Fe(!0).catch(()=>void 0),o=await je()),!e)return;o.exists&&Ye(o),i.exists&&Xe(i);let s=Yt(t);ye(s);let l=c(yt,``),u=s.find(e=>e.id===l)??s[0]??null;Q(u);let d=dt.current;if(dt.current=`list`,d===`work`&&u&&l&&u.id===l&&(dn(`work`),Ve(`req-analysis`)),u&&await pn(u),!e)return;ft(!1)}catch(t){e&&(ft(!1),I(t instanceof Error?t.message:String(t)))}}})();let t=te(()=>qe(ne()));return()=>{e=!1,t()}},[dn,Q,pn]),(0,T.useEffect)(()=>{if(!t.ready)return;if(!t.on){Ye(null),R(e=>e===`check`?`stories`:e);return}if(!v||O!==null)return;let e=!0;return(async()=>{let t=await je();(!t.exists||!t.review.trim())&&(await Fe(!0).catch(()=>void 0),t=await je()),e&&Ye(t)})(),()=>{e=!1}},[t.ready,t.on,v,O]),(0,T.useEffect)(()=>{L===`points`&&S?.sourcePath&&(G.current.length||fn(S))},[L,S,fn]),(0,T.useEffect)(()=>{if(!u.ready)return;if(!u.on){Xe(null),R(e=>e===`points`?`stories`:e);return}if(!v||k!==null)return;let e=!0;return(async()=>{let t=await Ae();(!t.exists||!t.generate.trim())&&(await Be(!0).catch(()=>void 0),t=await Ae()),e&&Xe(t)})(),()=>{e=!1}},[u.ready,u.on,v,k]),(0,T.useEffect)(()=>{if(!v)return;let e=!0;return se().then(t=>{e&&ke(t)}).catch(t=>{e&&ze(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[v]),(0,T.useEffect)(()=>{let e=S?.sourcePath;if(!e){At(``);return}let t=!0;return we(e).then(e=>{t&&At(Ce(e))}).catch(()=>{t&&At(``)}),()=>{t=!1}},[S?.sourcePath,S?.sourceHash]),(0,T.useEffect)(()=>{let e=nn.current;e&&(e.scrollTop=e.scrollHeight)},[it]);let Cn=!!(S?.sourceHash&&Dt&&S.sourceHash!==Dt),wn=(0,T.useMemo)(()=>new Set((S?.stories??[]).flatMap(e=>e.sourceRefs)),[S?.stories]),Tn=D??null,En=!!Tn?.decompose.trim(),Dn=(0,T.useMemo)(()=>(S?.check?.gaps??[]).filter(e=>e.selected).length,[S?.check]),$=(0,T.useCallback)(async(e,t)=>{let n=t??q.current;if(!n)throw Error(`还没有分析文档`);let r=await y(n.id,e);return J(r),r},[J]),On=(0,T.useCallback)(()=>{rn.current&&window.clearTimeout(rn.current),rn.current=window.setTimeout(()=>{let e=q.current;e?.check&&y(e.id,{check:e.check}).catch(()=>void 0)},600)},[]),kn=(0,T.useCallback)(async e=>{if(!e)return null;let t=b.find(t=>t.sourcePath===e);if(t)return mn(t,`stories`),t;try{let t=await we(e),n=Wt(e),r=await he({sourcePath:e,sourceTitle:n,sourceHash:Ce(t),title:n});return ye(e=>Yt([r,...e])),mn(r,`stories`),Y(`新建分析:${_(r)}`),r}catch(e){let t=e instanceof Error?e.message:String(e);return I(t),m(t,`error`),Pe(q.current?.sourcePath??``),null}},[b,mn,Y]),An=!!(E?.baseURL&&E.apiKey&&E.model),jn=(0,T.useCallback)(()=>!An||!E?(m(`请先在设置里配置模型`,`error`),g(`model`),null):E,[An,E]),Mn=(0,T.useCallback)((e,t)=>({getDoc:()=>q.current,batch:t,saveOutline:async t=>{let n=await y(e.id,{outline:t});return J(n),n.outline},saveStories:async t=>{let n=await y(e.id,{stories:t});return J(n),Y(`已写入 ${n.stories.length} 个用户故事`),n},saveCheck:async t=>{let n=q.current?.check,r={...t,gaps:le(n?.gaps??[],t.gaps)},i=await y(e.id,{check:r});return J(i),i},saveTestPoints:async t=>{let n=await y(e.id,{testPoints:t});return J(n),n}}),[J,Y]),Nn=(0,T.useCallback)(async()=>{let e=q.current,n=jn();if(!e||!n)return;let r=Tn?.decompose.trim()??``;if(!r){m(`没有读到「${ce}」的「## 拆解」段落`,`error`);return}I(``),F(``),Y(`开始拆解`,`stage`),X(`decompose`,`拆解`,100,`正在读取来源文档`);let i=new AbortController;Mt.current=i;let a=`done`;try{let a=await y(e.id,{status:`draft`,progress:{stage:`stories`,done:0,total:100,message:`正在读取来源文档`,at:new Date().toISOString()}});J(a);let o=await we(e.sourcePath);if(!o.trim())throw Error(`来源文档是空的`);let s=oe(o);if(!s.length)throw Error(`来源文档没有可拆解的内容`);W(5,`共 ${s.length} 批,准备拆第 1 批`),Y(s.length>1?`来源 ${o.length} 字,已分 ${s.length} 批拆解`:`来源 ${o.length} 字,单批拆解`);let c=await y(e.id,{replaceStories:!0,stories:[],outline:[],check:null,status:`draft`,sourceHash:Ce(o)});J(c);for(let t of s){if(i.signal.aborted)break;let a=q.current?.stories.length??0,o=[r,``,Ke,``,`## 已抽取的需求条目(sourceRefs 只能引用这些 id)`,(q.current?.outline??[]).map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
19
|
+
`)||`(本批还没有条目,先调用 req_set_outline)`].join(`
|
|
20
|
+
`),c=[`这一批是原始需求的第 ${t.index+1}/${s.length} 段${t.title?`(章节:${t.title})`:``}。只处理这一段的条目与故事,已完成的部分不要重写。`,``,`## 原始需求`,``,t.text].join(`
|
|
21
|
+
`),l=5+Math.floor(t.index/s.length*85),u=5+Math.floor((t.index+1)/s.length*85),d=t.index===s.length-1,f=Math.max(l+1,d?Math.min(90,u):Math.min(u-2,88));await $({progress:{stage:`stories`,done:l,total:100,message:`正在拆第 ${t.index+1}/${s.length} 批`,at:new Date().toISOString()}},q.current).catch(()=>void 0);let p=Date.now();Y(`第 ${t.index+1}/${s.length} 批开始`,`info`,[t.title?`章节:${t.title}`:``,`${t.text.length} 字`].filter(Boolean).join(` · `)),W(l,`正在拆第 ${t.index+1}/${s.length} 批`);let m=Rt(f),h=``;try{for await(let r of ee(n,[{role:`system`,content:o},{role:`user`,content:c}],i.signal,{tools:Qe.filter(e=>[`req_set_outline`,`req_set_stories`].includes(e.function.name)),maxToolRounds:20,runTool:(n,r)=>$e(n,r,Mn(e,t.index))}))r.type===`content`?(h+=r.delta,F(e=>e+r.delta),Lt(f,1)):r.type===`tool`&&r.status===`running`?(Y(`调用 ${r.name}`,`tool`,K(r.args)),Lt(f,1)):r.type===`tool`&&r.status===`done`&&(Y(`${r.name} 返回`,`tool`,K(r.result,120)),Lt(f,2))}finally{m()}if(W(Math.min(90,Math.max(f+2,u-2)),`第 ${t.index+1}/${s.length} 批返回,正在写入`),(q.current?.stories.length??0)===a){let n=et(h);if(n.length){let t=Te(q.current?.stories??[],n),r=await y(e.id,{stories:t});J(r),Y(`模型没调工具,已从回答里兜底解析 ${n.length} 个故事`,`info`)}else Y(`第 ${t.index+1} 批没有拿到结构化故事`,`error`)}let te=Math.max(0,(q.current?.stories.length??0)-a);Y(`第 ${t.index+1}/${s.length} 批完成`,`done`,`新增 ${te} 个故事 · 耗时 ${Jt(p)}`),W(u,`第 ${t.index+1}/${s.length} 批已写入`)}if(i.signal.aborted){Y(`已中断:已经写入的故事保留`,`info`);return}W(92,`正在保存拆解结果`);let l=await y(e.id,{status:`decomposed`,progress:{stage:`done`,done:100,total:100,message:`拆解完成`,at:new Date().toISOString()}});J(l),Y(`拆解完成:${l.outline.length} 条需求条目、${l.stories.length} 个用户故事`,`done`),R(`stories`),t.on&&!i.signal.aborted?(W(96,`拆解完成,接着审查`),m(`拆解完成,接着做用户故事审查`,`success`),await Fn.current?.(!0)):(W(100,`拆解完成`),m(`拆解完成`,`success`))}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?(a=`stopped`,Y(`已中断:已经写入的故事保留`,`info`)):(a=`error`,I(t),Y(`拆解失败:${t}`,`error`))}finally{i.signal.aborted&&(a=`stopped`),Z(`decompose`,a,a===`done`?`拆解完成`:a===`stopped`?`已中断:已经写入的故事保留`:`拆解失败,详见活动日志`)}},[X,Z,Mn,J,Y,Tn,jn,sn,t.on,$]),Pn=(0,T.useCallback)(async(e=!1)=>{let t=q.current;if(!t)return;if(!t.stories.length){e||m(`还没有用户故事,先做一次拆解`,`info`);return}I(``),e||F(``),Y(e?`继续审查用户故事`:`开始审查用户故事`,`stage`,e?`拆解完成后自动接续`:void 0),X(`audit`,`审查用户故事`,100,`正在跑规则体检`);let n=new AbortController;Mt.current=n;let r={status:`done`,message:`审查完成`};try{let e=Date.now();W(8,`正在跑规则体检`);let i=ue(t),a=await y(t.id,{check:{...i,gaps:le(t.check?.gaps??[],i.gaps)},progress:{stage:`audit`,done:18,total:100,message:`规则体检完成,等待模型评审`,at:new Date().toISOString()}});J(a),Y(`规则体检:覆盖率 ${Math.round(i.coverage.rate*100)}%,${i.gaps.length} 个缺口`,`info`,`${t.outline.length} 条需求条目 · ${t.stories.length} 个故事 · 耗时 ${Jt(e)}`),W(18,`规则体检完成,等待模型评审`);let o=O?.review.trim()??``,s=An?E:null;if(!s||!o){Y(s?`「用户故事审查提示词.md」缺少「## 审查」段落,只保留规则结果`:`没有配置模型,只保留规则结果`,`info`),r.message=`没有配置模型,只保留规则结果`,await y(t.id,{status:`checked`,progress:{stage:`done`,done:100,total:100,message:r.message,at:new Date().toISOString()}}).then(J).catch(()=>void 0),R(`check`);return}let c=!1,l=Mn(t,90),u=l.saveCheck;l.saveCheck=async e=>{c=!0,W(96,`正在写入审查结果`);let t=await u(e);return Y(`模型体检:整体 ${t.check?.gaps.length??0} 个缺口`,`done`),t};let d=q.current??a,f=await ae(d.sourcePath);f.text||Y(`没有读到原始需求,只能依据需求条目摘句审查`,`info`),Y(`提交模型审查`,`tool`,`模型 ${s.model} · ${d.stories.length} 个故事 · 原文 ${f.text.length} 字`),W(22,`正在提交模型审查`);let p=[`## 原始需求`,f.text?f.truncated?`${f.text}\n\n(原文共 ${f.total} 字,以上为前 ${f.text.length} 字,没看到的部分不要猜)`:f.text:`(未读到原始需求,只能依据下面的需求条目摘句判断)`,``,`## 需求条目`,d.outline.length?d.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
22
|
+
`):`(无)`,``,`## 用户故事(${d.stories.length} 条)`,"```json",JSON.stringify(d.stories,null,2),"```"].join(`
|
|
23
|
+
`),h=Rt(90);try{for await(let e of ee(s,[{role:`system`,content:`${o}\n\n${Ke}`},{role:`user`,content:p}],n.signal,{tools:Qe.filter(e=>e.function.name===`req_save_check`),maxToolRounds:8,runTool:(e,t)=>$e(e,t,l)}))e.type===`content`?(F(t=>t+e.delta),Lt(90,1)):e.type===`tool`&&e.status===`running`?(Y(`调用 ${e.name}`,`tool`,K(e.args)),W(94,`模型正在提交审查结果`)):e.type===`tool`&&e.status===`done`&&(Y(`${e.name} 返回`,`tool`,K(e.result,120)),W(97,`审查结果已返回`))}finally{h()}c||(Y(`模型没有提交体检结果,当前只保留规则结果`,`error`),m(`模型没有提交体检结果,只保留了规则检查`,`error`)),W(100,c?`模型评审完成`:`已保留规则结果`),r.message=c?`审查完成`:`模型没提交结果,已保留规则结果`,await y(t.id,{status:`checked`,progress:{stage:`done`,done:100,total:100,message:r.message,at:new Date().toISOString()}}).then(J).catch(()=>void 0),R(`check`)}catch(e){let t=e instanceof Error?e.message:String(e);n.signal.aborted?(r.status=`stopped`,Y(`已中断:规则体检结果已保留`,`info`)):(r.status=`error`,I(t),Y(`体检失败:${t}`,`error`))}finally{n.signal.aborted&&(r.status=`stopped`),Z(`audit`,r.status,r.status===`error`?`审查失败,详见活动日志`:r.message)}},[X,Z,Mn,An,J,Y,sn,O,E]),Fn=(0,T.useRef)(null);Fn.current=Pn;let In=(0,T.useCallback)(async()=>{let e=q.current,t=jn();if(!e||!t)return;let n=(e.check?.gaps??[]).filter(e=>e.selected);if(!n.length){m(`先在缺口清单里勾选要补写的条目`,`info`);return}let r=O?.fix.trim()??``;if(!r){m(`「用户故事审查提示词.md」缺少「## 补写」段落`,`error`);return}I(``),F(``),Y(`开始补写选中条目`,`stage`,`勾选 ${n.length} 个缺口`),X(`fix`,`补写选中条目`,100,`正在按 ${n.length} 个勾选缺口补写`);let i=Date.now(),a=new AbortController;Mt.current=a;let o={status:`done`,message:`补写完成`};try{W(5,`正在按 ${n.length} 个勾选缺口补写`),Y(`按 ${n.length} 个勾选缺口补写`,`info`,n.map(e=>`[${e.severity}] ${e.storyId||`全局`}|${e.title}`).join(`;`));let s=new Map(e.stories.map(e=>[e.id,e.title])),c=await ae(e.sourcePath),l=[`## 原始需求`,c.text?c.truncated?`${c.text}\n\n(原文共 ${c.total} 字,以上为前 ${c.text.length} 字,没看到的部分不要猜)`:c.text:`(未读到原始需求,只能依据需求条目与当前故事集判断)`,``,`## 需求条目(新增故事的 sourceRefs 只能引用这里的 id)`,e.outline.length?e.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
24
|
+
`):`(无)`,``,`## 当前故事集(${e.stories.length} 条,没被点名的必须原样保留)`,"```json",JSON.stringify(e.stories,null,2),"```",``,`## 勾选待补写的缺口`,n.map(e=>{let t=e.storyId?`${e.storyId} ${s.get(e.storyId)??``}`:`全局问题`;return[`- [${e.severity}] ${t}|${e.title}`,e.detail?` 原因:${e.detail}`:``,e.suggestion?` 建议:${e.suggestion}`:``].filter(Boolean).join(`
|
|
25
|
+
`)}).join(`
|
|
26
|
+
`)].join(`
|
|
27
|
+
`),u=Mn(e,90),d=!1,f=u.saveStories;u.saveStories=async e=>(d=!0,W(90,`正在写入补写结果`),f(e)),W(12,`正在提交模型补写`);let p=Rt(88);try{for await(let e of ee(t,[{role:`system`,content:`${r}\n\n${Ke}`},{role:`user`,content:l}],a.signal,{tools:Qe.filter(e=>e.function.name===`req_set_stories`),maxToolRounds:10,runTool:(e,t)=>$e(e,t,u)}))e.type===`content`?(F(t=>t+e.delta),Lt(88,1)):e.type===`tool`&&e.status===`running`?(Y(`调用 ${e.name}`,`tool`,K(e.args)),W(90,`模型正在提交补写`)):e.type===`tool`&&e.status===`done`&&(Y(`${e.name} 返回`,`tool`,K(e.result,120)),W(94,`补写结果已返回`))}finally{p()}if(!d){o.status=`error`,o.message=`模型没有提交补写结果,故事集保持不变`,Y(`模型没有提交补写结果,故事集保持不变`,`error`),m(`模型没有提交补写结果`,`error`);return}W(94,`已写入补写结果,正在重算覆盖率`);let h=q.current;if(h){let e=ue(h),t=await y(h.id,{check:e,status:`decomposed`});J(t)}let te=Math.round((q.current?.check?.coverage.rate??0)*100);Y(`补写完成,已按规则重算覆盖率;建议再跑一次体检`,`done`,`覆盖率 ${te}% · 耗时 ${Jt(i)}`),await $({progress:{stage:`done`,done:100,total:100,message:`补写完成`,at:new Date().toISOString()}},q.current).catch(()=>void 0),R(`check`),m(`补写完成,建议再跑一次体检`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);a.signal.aborted?(o.status=`stopped`,Y(`已中断:已经写入的改动保留`,`info`)):(o.status=`error`,o.message=t,I(t),Y(`补写失败:${t}`,`error`))}finally{a.signal.aborted&&(o.status=`stopped`),Z(`fix`,o.status,o.status===`error`?`补写失败:${o.message}`:o.message)}},[X,Z,Mn,J,Y,sn,jn,O,$]),Ln=(0,T.useCallback)(async()=>{let e=q.current,t=jn();if(!e||!t)return;if(!e.stories.length){m(`还没有用户故事,先做一次拆解`,`info`);return}let n=k?.generate.trim()??``;if(!n){m(`没有读到「${De}」的「## 生成」段落`,`error`);return}I(``),F(``),Y(`开始生成测试点`,`stage`,`基于 ${e.stories.length} 个用户故事,五维覆盖 P0–P3`),X(`testpoints`,`生成测试点`,100,`正在整理用户故事,等待模型生成`),R(`points`),await $({progress:{stage:`points`,done:5,total:100,message:`正在生成测试点`,at:new Date().toISOString()}},e).catch(()=>void 0);let r=Date.now();W(8,`正在整理用户故事`),Y(`整理用户故事,提交模型生成`,`info`,`${e.outline.length} 条需求条目 · ${e.stories.length} 个故事 · 模型 ${t.model}`);let i=new AbortController;Mt.current=i;let a={status:`done`,message:`测试点已生成`};try{let o=Mn(e,90),s=!1,c=o.saveTestPoints;o.saveTestPoints=async e=>{s=!0,W(90,`正在写入测试点`);let t=await c(e);return Y(`测试点已写入:${t.testPoints?.points.length??0} 条`,`done`),t};let l=[`## 分析标题\n${e.title||`未命名分析`}`,``,`## 需求条目`,e.outline.length?e.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
28
|
+
`):`(无)`,``,`## 用户故事(${e.stories.length} 条)`,"```json",JSON.stringify(e.stories,null,2),"```"].join(`
|
|
29
|
+
`);W(15,`正在提交模型生成`);let u=``,d=Rt(88);try{for await(let e of ee(t,[{role:`system`,content:`${n}\n\n${Ke}`},{role:`user`,content:l}],i.signal,{tools:Qe.filter(e=>e.function.name===`req_save_test_points`),maxToolRounds:8,runTool:(e,t)=>$e(e,t,o)}))e.type===`content`?(u+=e.delta,F(t=>t+e.delta),Lt(88,1)):e.type===`tool`&&e.status===`running`?(Y(`调用 ${e.name}`,`tool`,K(e.args)),W(90,`模型正在提交测试点`)):e.type===`tool`&&e.status===`done`&&(Y(`${e.name} 返回`,`tool`,K(e.result,120)),W(94,`测试点已返回`))}finally{d()}if(!s){let t=tt(u,e.stories.map(e=>e.id));t&&(await o.saveTestPoints(t),s=!0,Y(`模型没调工具,已从回答里兜底解析 ${t.points.length} 条`,`info`))}if(!s)a.status=`error`,a.message=`模型没有提交测试点,原结果保持不变`,Y(`模型没有提交测试点,原结果保持不变`,`error`),m(`模型没有提交测试点,原结果保持不变`,`error`);else{let e=q.current?.testPoints?.points??[],t=t=>e.filter(e=>e.priority===t).length;Y(`测试点完成:${e.length} 条`,`done`,`P0 ${t(`P0`)} / P1 ${t(`P1`)} / P2 ${t(`P2`)} / P3 ${t(`P3`)} · 耗时 ${Jt(r)}`),W(100,`已生成 ${e.length} 条`),a.message=`测试点已生成 ${e.length} 条`,await $({progress:{stage:`done`,done:100,total:100,message:`测试点已生成 ${e.length} 条`,at:new Date().toISOString()}},q.current).catch(()=>void 0),m(`测试点已生成`,`success`)}}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?(a.status=`stopped`,Y(`已中断:已经生成的测试点保留`,`info`)):(a.status=`error`,a.message=t,I(t),Y(`生成测试点失败:${t}`,`error`))}finally{i.signal.aborted&&(a.status=`stopped`),Z(`testpoints`,a.status,a.status===`error`?`生成测试点失败:${a.message}`:a.message)}},[X,Z,Mn,Y,sn,jn,$,k]),Rn=(0,T.useCallback)(async()=>{let e=q.current;if(!e?.testPoints)m(`还没有测试点可导出`,`info`);else try{let t=G.current;t.length||(t=await fn(e));let n=await Ne(e,t);Y(`已导出 ${n}`,`done`)}catch(e){m(`导出失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[Y,fn]),zn=(0,T.useCallback)(async()=>{let e=q.current;if(!e?.testPoints){m(`还没有测试点可导出`,`info`);return}let t=G.current;t.length||(t=await fn(e));let n=Ie(e,t);Y(`已导出 ${n}`,`done`)},[Y,fn]),Bn=(0,T.useCallback)(async e=>{let t=q.current;if(t)try{await $({stories:e},t)}catch(e){m(`保存失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[$]),Vn=(0,T.useCallback)((e,t)=>{let n=q.current;if(!n)return;let r=n.stories.map((n,r)=>r===e?{...t,id:n.id}:n);Bn(r)},[Bn]),Hn=(0,T.useCallback)(e=>{let t=q.current;t&&Bn(t.stories.filter((t,n)=>n!==e))},[Bn]),Un=(0,T.useCallback)((e,t)=>{let n=q.current;if(!n)return;let r=e+t;if(r<0||r>=n.stories.length)return;let i=[...n.stories],a=i[e],o=i[r];a&&o&&(i[e]=o,i[r]=a,Bn(i))},[Bn]),Wn=(0,T.useCallback)((e,t)=>{let n=q.current;if(!n?.check)return;let r={...n,check:{...n.check,gaps:n.check.gaps.map(n=>n.id===e?{...n,selected:t}:n)}};J(r),On()},[J,On]),Gn=(0,T.useCallback)(e=>{let t=q.current;if(!t?.check)return;let n={...t,check:{...t.check,gaps:t.check.gaps.map(t=>({...t,selected:e}))}};J(n),On()},[J,On]),Kn=(0,T.useCallback)(async()=>{let e=q.current;if(e)try{await xe(e.id);let t=b.filter(t=>t.id!==e.id);ye(t),Q(t[0]??null),dn(`list`),m(`已删除分析记录`,`success`)}catch(e){m(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}finally{Qt(!1)}},[dn,b,Q]),qn=(0,T.useCallback)(()=>{let e=q.current;if(!e)return;let t=new Blob([ie(e)],{type:`text/markdown;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=de(e),document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3),m(`已导出 Markdown`,`success`)},[]),Jn=(0,T.useCallback)(()=>{let e=q.current;if(!e?.check)return;let t=Le(e,e.check);m(`已导出 ${t}`,`success`)},[]),Yn=(0,T.useCallback)(()=>{Mt.current?.abort()},[]);if(!e.ready)return(0,M.jsx)(We,{label:`正在读取插件开关`});if(!e.on)return(0,M.jsx)(Ue,{children:r(`reqAnalysis`)});if(v===null)return(0,M.jsx)(We,{label:`正在连接需求分析服务`});if(!v)return(0,M.jsx)(Ue,{children:"需求分析需要本地服务,当前未就绪:确认服务已升级到最新版本并重启(`lantern` 一体服务或 `npm run dev`),静态部署的页面用不了。"});if(z)return(0,M.jsx)(We,{label:`正在回到上次的分析`});let Xn=S?.outline.filter(e=>wn.has(e.id)).length??0,Zn=S?.check?.gaps??[],Qn=(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,M.jsxs)(`section`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,M.jsxs)(`div`,{className:`min-w-[240px] flex-1`,children:[(0,M.jsx)(`p`,{className:Ut,children:`新建分析`}),(0,M.jsx)(`div`,{className:`mt-1.5 max-w-[440px]`,children:(0,M.jsx)(p,{options:on,value:Me,onChange:e=>{Pe(e),e&&kn(e)},triggerTitle:Me||`选择来源需求文档…`,ariaLabel:`选择来源需求文档`,searchable:!0,searchPlaceholder:`搜索文件名或路径…`,flat:!0})})]}),(0,M.jsxs)(`span`,{className:`pb-1 text-[11px] text-stone-400`,children:[`共 `,b.length,` 份分析`]})]}),Re?(0,M.jsxs)(`p`,{className:`mt-2 text-xs leading-relaxed text-amber-700`,children:[`读不到需求文档库:`,Re,(0,M.jsx)(`br`,{}),`请先启用「需求文档库」插件,或确认 `,me,` 之外的内容目录没有被移动。`]}):null]}),st?(0,M.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[(0,M.jsx)(`span`,{className:`break-all`,children:st}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>I(``),children:`✕`})]}):null,(0,M.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`inline-flex rounded-lg border border-stone-200 bg-stone-50 p-0.5`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>Sn(`doc`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${pt===`doc`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按需求说明书`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>Sn(`story`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${pt===`story`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按用户故事`})]}),pt===`story`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`label`,{className:`relative block`,children:[(0,M.jsx)(w,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,M.jsx)(`input`,{value:V,onChange:e=>mt(e.target.value),placeholder:`搜索编号 / 标题 / 角色…`,className:`h-8 w-52 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-xs text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,M.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[_n,` 个故事`,H?` · 已选 ${H.ids.length}`:``]}),(0,M.jsx)(`button`,{type:`button`,disabled:!H,onClick:()=>{if(!H)return;let e=new URLSearchParams({plugin:`caseGen`,reqDoc:H.docId,stories:H.ids.join(`,`)});window.location.href=`/workbench/?${e.toString()}`},className:`${Vt} ml-auto h-8 text-xs`,children:`用选中故事生成用例`})]}):(0,M.jsxs)(`span`,{className:`ml-auto text-[11px] text-stone-400`,children:[b.length,` 份分析 · `,_n,` 个故事`]})]}),(0,M.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:pt===`doc`?b.length?(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:b.map(e=>{let t=an(e.status);return(0,M.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center text-left`,onClick:()=>mn(e,`stories`),children:(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:_(e)}),(0,M.jsx)(C,{tone:t.tone,children:t.label})]}),(0,M.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-stone-400`,children:[(0,M.jsx)(`span`,{className:`truncate`,children:e.sourcePath||`(未指定来源)`}),(0,M.jsxs)(`span`,{children:[`用户故事 `,e.stories.length]}),(0,M.jsxs)(`span`,{children:[`需求条目 `,e.outline.length]}),(0,M.jsx)(`span`,{children:Kt(e.updatedAt)})]})]})}),(0,M.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-700 transition-colors hover:border-[#3370ff] hover:text-[#3370ff]`,onClick:()=>mn(e,`stories`),children:[`用户故事`,(0,M.jsx)(w,{name:`chevronRight`,size:13})]}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`删除 ${_(e)}`,className:`tw-icon-danger flex h-8 w-8 shrink-0 items-center justify-center rounded-md`,onClick:()=>{Q(e),Qt(!0)},children:(0,M.jsx)(w,{name:`trash`,size:14})})]},e.id)})}):(0,M.jsx)(Ge,{icon:`file`,title:`还没有分析记录`,hint:`上面选一份需求文档,系统会新建一份分析并进入用户故事拆解。`}):vn.length?(0,M.jsx)(`div`,{className:`divide-y divide-stone-100`,children:vn.map(({doc:e,rows:t})=>{let n=gt.includes(e.id),r=t.map(e=>e.story.id),i=H?.docId===e.id&&r.length>0&&r.every(e=>yn.has(e));return(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/70 px-3 py-1.5`,children:[(0,M.jsx)(`input`,{type:`checkbox`,"aria-label":`选中 ${_(e)} 的全部故事`,checked:i,onChange:()=>xn(e.id,r)}),(0,M.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>_t(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id]),children:[(0,M.jsx)(w,{name:n?`chevronRight`:`chevronDown`,size:13,className:`shrink-0 text-stone-400`}),(0,M.jsx)(`span`,{className:`truncate text-xs font-medium text-stone-700`,children:_(e)}),(0,M.jsxs)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:[t.length,` 个故事 · `,Kt(e.updatedAt)]})]}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>mn(e,`stories`),children:`打开拆解`})]}),n?null:(0,M.jsx)(`ul`,{className:`divide-y divide-stone-50`,children:t.map(({story:t})=>(0,M.jsxs)(`li`,{className:`flex items-start gap-2 px-4 py-2 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(`input`,{type:`checkbox`,className:`mt-1`,"aria-label":`选中 ${t.id}`,checked:yn.has(t.id)&&H?.docId===e.id,onChange:()=>bn(e.id,t.id)}),(0,M.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:()=>hn(e,t.id),children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-stone-400`,children:t.id}),(0,M.jsx)(`span`,{className:`truncate text-sm text-stone-800`,children:t.title})]}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2.5 gap-y-0.5 text-[11px] text-stone-400`,children:[t.role?(0,M.jsxs)(`span`,{children:[`角色:`,t.role]}):null,(0,M.jsxs)(`span`,{children:[`优先级 `,t.priority]}),(0,M.jsxs)(`span`,{children:[`验收 `,t.acceptance.length]}),(0,M.jsxs)(`span`,{children:[`异常 `,t.exceptions.length]}),(0,M.jsxs)(`span`,{children:[`维度 `,t.dimensions.length]})]})]})]},`${e.id}-${t.id}`))})]},e.id)})}):(0,M.jsx)(Ge,{icon:`file`,title:V?`没有匹配的用户故事`:`还没有用户故事`,hint:V?`换个编号、标题或角色再试。`:`先按「需求说明书」选中一份文档拆解,故事会自动出现在这里。`})})]})]});return(0,M.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col p-3`,children:[lt===`list`?Qn:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center gap-2`,children:[(0,M.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center gap-1 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:border-stone-300 hover:text-stone-800`,onClick:()=>{Pe(``),I(``),dn(`list`)},children:[(0,M.jsx)(w,{name:`arrowLeft`,size:14}),`返回列表`]}),(0,M.jsx)(`span`,{className:`min-w-0 truncate text-xs text-stone-400`,children:S?`用户故事 · ${_(S)}`:`用户故事`})]}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,M.jsxs)(`aside`,{className:`flex w-[280px] shrink-0 flex-col gap-3 overflow-y-auto pb-1`,children:[(0,M.jsxs)(`section`,{"data-hint-width":!0,className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,M.jsx)(`p`,{className:Ut,children:`分析记录`}),(0,M.jsx)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:b.length})]}),(0,M.jsx)(`div`,{className:`px-2 py-2`,children:b.length?(0,M.jsx)(`ul`,{className:`space-y-0.5`,children:b.map(e=>{let t=e.id===x,n=an(e.status);return(0,M.jsx)(`li`,{children:(0,M.jsx)(`button`,{type:`button`,className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition-colors ${t?`bg-[#eef3ff]`:`hover:bg-stone-50`}`,onClick:()=>Q(e),children:(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(f,{text:_(e),matchAnchorWidth:!0,className:`block truncate text-xs ${t?`font-medium text-[#1f4fd8]`:`text-stone-700`}`}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-stone-400`,children:[(0,M.jsx)(C,{tone:n.tone,children:n.label}),(0,M.jsxs)(`span`,{children:[e.stories.length,` 个故事`]})]})]})})},e.id)})}):(0,M.jsx)(`p`,{className:`px-1.5 py-1 text-xs text-stone-400`,children:`还没有分析记录,选一份来源文档开始。`})})]}),(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,M.jsx)(`p`,{className:Ut,children:`提示词`})}),(0,M.jsxs)(`div`,{className:`px-3.5 py-3`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(Xt,{name:ce,ready:En}),(0,M.jsx)(Xt,{name:O?.file??`用户故事审查提示词.md`,ready:t.on&&!!O?.review.trim()&&!!O?.fix.trim()}),(0,M.jsx)(Xt,{name:De,ready:u.on&&!!k?.generate.trim()})]}),(0,M.jsx)(`p`,{className:`mt-2 text-[11px] ${An?`text-stone-400`:`text-amber-700`}`,children:An?`模型:${E?.model}`:`还没配置模型`})]})]}),(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,M.jsx)(`p`,{className:Ut,children:`动作`})}),(0,M.jsxs)(`div`,{className:`space-y-2 px-3.5 py-3`,children:[(0,M.jsx)(`button`,{type:`button`,className:`${Vt} w-full`,disabled:!S||!!j||!S.sourcePath,onClick:()=>{S?.stories.length?en(!0):Nn()},children:j===`decompose`?`拆解中…`:S?.stories.length?`重新拆解`:`开始拆解`}),t.on?(0,M.jsx)(`button`,{type:`button`,className:`${Ht} w-full`,disabled:!S||!!j||!S.stories.length,onClick:()=>void Pn(),children:j===`audit`?`审查中…`:S?.check?`重新审查用户故事`:`用户故事审查`}):null,u.on?(0,M.jsx)(`button`,{type:`button`,className:`${Ht} w-full`,disabled:!S||!!j||!S.stories.length,onClick:()=>void Ln(),children:j===`testpoints`?`生成中…`:S?.testPoints?`重新生成测试点`:`生成测试点`}):null,j?(0,M.jsx)(`button`,{type:`button`,className:`${Ht} w-full`,onClick:Yn,children:`中断`}):(0,M.jsx)(`button`,{type:`button`,className:`${Ht} w-full`,disabled:!S,onClick:qn,children:`导出 Markdown`}),S&&!j?(0,M.jsx)(`button`,{type:`button`,className:`h-8 w-full rounded-md text-xs text-stone-400 transition-colors hover:bg-red-50 hover:text-red-500`,onClick:()=>Qt(!0),children:`删除这份分析`}):null]})]}),(0,M.jsxs)(`section`,{className:`flex min-h-[140px] flex-1 flex-col rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,M.jsx)(`p`,{className:Ut,children:`活动日志`}),it.length?(0,M.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-400 transition-colors hover:text-stone-600`,onClick:()=>at([]),children:`清空`}):null]}),(0,M.jsx)(`div`,{ref:nn,className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-3.5 py-2.5`,children:it.length?it.map(e=>e.kind===`stage`?(0,M.jsxs)(`div`,{className:`flex items-center gap-2 pt-1.5 first:pt-0`,children:[(0,M.jsx)(`span`,{className:`h-px flex-1 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium text-stone-500`,children:e.text}),(0,M.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-stone-300`,children:qt(e.at)}),(0,M.jsx)(`span`,{className:`h-px flex-1 bg-stone-200`,"aria-hidden":`true`})]},e.id):(0,M.jsxs)(`div`,{className:`flex gap-1.5 text-[11px] leading-relaxed`,children:[(0,M.jsx)(`span`,{className:`mt-px shrink-0 text-[10px] tabular-nums text-stone-300`,children:qt(e.at)}),(0,M.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${e.kind===`error`?`bg-red-500`:e.kind===`done`?`bg-emerald-500`:e.kind===`tool`?`bg-[#3370ff]`:`bg-stone-300`}`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`span`,{className:e.kind===`error`?`text-red-600`:e.kind===`done`?`text-stone-700`:`text-stone-500`,children:e.text}),e.detail?(0,M.jsx)(`span`,{className:`mt-0.5 block break-all text-[10px] leading-relaxed text-stone-400`,children:e.detail}):null]})]},e.id)):(0,M.jsx)(`p`,{className:`text-[11px] leading-relaxed text-stone-400`,children:`拆解 / 审查的过程会记在这里:抽取需求条目、写故事、跑审查与补写。`})})]})]}),(0,M.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[st?(0,M.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[(0,M.jsx)(`span`,{className:`break-all`,children:st}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>I(``),children:`✕`})]}):null,P&&!j?(0,M.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2 rounded-lg border px-3 py-2 text-xs ${P.status===`done`?`border-emerald-200 bg-emerald-50 text-emerald-700`:P.status===`error`?`border-red-200 bg-red-50 text-red-700`:`border-amber-200 bg-amber-50 text-amber-700`}`,children:[(0,M.jsxs)(`span`,{className:`break-all`,children:[(0,M.jsxs)(`span`,{className:`font-medium`,children:[P.label,P.status===`done`?`已完成`:P.status===`error`?`失败`:`已中断`]}),(0,M.jsx)(`span`,{className:`ml-1.5 opacity-80`,children:P.message}),P.finishedAt?(0,M.jsxs)(`span`,{className:`ml-1.5 opacity-60`,children:[`· `,Kt(new Date(P.finishedAt).toISOString())]}):null]}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 opacity-60 transition-opacity hover:opacity-100`,"aria-label":`关闭上次任务提示`,onClick:cn,children:`✕`})]}):null,S?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`header`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`px-4 pt-3`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(f,{text:_(S),matchAnchorWidth:!0,className:`min-w-0 flex-1 truncate px-1 py-0.5 text-[15px] font-semibold text-stone-800`}),j?(0,M.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-xs text-stone-500`,children:[(0,M.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),N?N.message:j===`decompose`?`拆解中`:j===`audit`?`审查中`:j===`testpoints`?`生成测试点中`:j===`fix`?`补写中`:`处理中`,N&&N.total>0?(0,M.jsxs)(`span`,{className:`tabular-nums text-stone-400`,children:[Math.round(Math.min(N.done,N.total)/N.total*100),`%`]}):null]}):null,(0,M.jsx)(C,{tone:an(S.status).tone,children:an(S.status).label})]}),j?(0,M.jsx)(`div`,{className:`mt-2`,children:(0,M.jsx)(`div`,{className:`tw-run-track`,role:`progressbar`,"aria-label":`${N?.label??`任务`}进度`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":N&&N.total>0?Math.round(Math.min(N.done,N.total)/N.total*100):void 0,children:(0,M.jsx)(`div`,{className:N&&N.total>0?`tw-run-fill`:`tw-run-fill tw-run-fill--indeterminate`,style:N&&N.total>0?{width:`${Math.round(Math.min(N.done,N.total)/N.total*100)}%`}:void 0})})}):null,(0,M.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-2.5 text-[11px] text-stone-400`,children:[(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`故事`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:S.stories.length})]}),(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`条目`,` `,(0,M.jsxs)(`span`,{className:`font-medium text-stone-600`,children:[Xn,`/`,S.outline.length]}),` `,`覆盖`]}),t.on?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`缺口`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:Zn.length}),Dn?` · 已选 ${Dn}`:``]}),S.check?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`覆盖率`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:S.check.coverage.total?`${Math.round(S.check.coverage.rate*100)}%`:`—`})]})]}):null]}):null,u.on?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`测试点`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:S.testPoints?.points.length??0})]})]}):null,(0,M.jsxs)(`span`,{className:`ml-auto min-w-0 truncate pl-2`,children:[`来源:`,S.sourcePath]}),Cn?(0,M.jsx)(`span`,{className:`shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-700`,children:`源文档已更新`}):null]})]}),(0,M.jsx)(`div`,{role:`tablist`,"aria-label":`需求分析视图`,className:`mt-2.5 flex items-center gap-1 border-b border-stone-100 px-2`,children:[{id:`stories`,label:`用户故事`,count:S.stories.length},{id:`check`,label:`审查结果`,count:Zn.length},{id:`outline`,label:`需求条目`,count:S.outline.length},{id:`points`,label:`测试点`,count:S.testPoints?.points.length??0}].filter(e=>(e.id!==`check`||t.on)&&(e.id!==`points`||u.on)).map(e=>{let t=L===e.id;return(0,M.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,className:`-mb-px flex items-center gap-1.5 border-b-2 px-3 py-2 text-xs transition-colors ${t?`border-[#3370ff] font-medium text-[#3370ff]`:`border-transparent text-stone-500 hover:text-stone-800`}`,onClick:()=>R(e.id),children:[e.label,(0,M.jsx)(`span`,{className:`rounded-full px-1.5 text-[10px] leading-4 tabular-nums ${t?`bg-[#eaf1ff] text-[#3370ff]`:`bg-stone-100 text-stone-400`}`,children:e.count})]},e.id)})})]}),(0,M.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 overflow-y-auto pr-1`,children:[L===`stories`?S.stories.length?(0,M.jsx)(`ul`,{className:`space-y-2`,children:S.stories.map((e,t)=>(0,M.jsx)(vt,{story:e,index:t,total:S.stories.length,gaps:Zn.filter(t=>t.storyId===e.id),busy:!!j,onSave:e=>Vn(t,e),onDelete:()=>Hn(t),onMove:e=>Un(t,e),domId:e.id?`req-story-${e.id}`:void 0},`${e.id}-${t}`))}):(0,M.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ge,{icon:`file`,title:`还没有用户故事`,hint:`点左侧「开始拆解」,会先抽需求条目再拆故事。`})}):null,L===`check`&&t.on?(0,M.jsx)(rt,{check:S.check,stories:S.stories,busy:!!j,onToggleGap:Wn,onToggleAll:Gn,onFix:()=>void In(),onReview:()=>void Pn(),onExport:Jn}):null,L===`points`&&u.on?(0,M.jsx)(ct,{doc:S,idealTitles:jt,generating:j===`testpoints`,busy:!!j,promptReady:!!k?.generate.trim(),onExportXmind:()=>void Rn(),onExportMarkdown:()=>void zn()}):null,L===`outline`?S.outline.length?(0,M.jsx)(`ul`,{className:`space-y-2`,children:S.outline.map(e=>{let t=wn.has(e.id);return(0,M.jsx)(`li`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-2.5`,children:(0,M.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${t?`bg-emerald-500`:`bg-amber-400`}`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`p`,{className:`text-sm text-stone-800`,children:[(0,M.jsx)(`span`,{className:`mr-1.5 rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id}),e.title]}),e.quote?(0,M.jsx)(`p`,{className:`mt-1 border-l-2 border-stone-200 pl-2 text-xs leading-relaxed text-stone-400`,children:e.quote}):null]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-amber-600`}`,children:t?`已覆盖`:`未覆盖`})]})},e.id)})}):(0,M.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ge,{icon:`file`,title:`还没有需求条目`,hint:`拆解时模型会先抽条目,覆盖率按条目统计。`})}):null]}),ot?(0,M.jsxs)(`details`,{className:`mt-2 shrink-0 rounded-xl border border-stone-200 bg-white px-3 py-2`,children:[(0,M.jsx)(`summary`,{className:`cursor-pointer text-xs text-stone-500`,children:`模型说明(本轮)`}),(0,M.jsx)(`pre`,{className:`mt-1 max-h-[180px] overflow-y-auto whitespace-pre-wrap break-words text-[11px] leading-relaxed text-stone-600`,children:ot})]}):null]}):(0,M.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ge,{icon:`file`,title:`还没有选来源`,hint:`左侧选一份「需求文档库」里的 Word / Excel / Markdown / txt,系统会新建一份分析。`})})]})]})]}),(0,M.jsx)(d,{open:Zt,title:`删除分析记录`,message:`确认删除「${S?_(S):``}」?故事、需求条目、体检报告与测试点都会一起清掉,来源需求文档不受影响。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>Qt(!1),onConfirm:()=>void Kn()}),(0,M.jsx)(d,{open:$t,title:`重新拆解`,message:`重新拆解会用模型结果替换当前 ${S?.stories.length??0} 个用户故事,旧体检报告、测试点与需求条目也会一起清掉,编号从 US-001 重新开始。`,confirmLabel:`重新拆解`,onClose:()=>en(!1),onConfirm:()=>{en(!1),Nn()}})]})}export{Zt as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i,s as a}from"./plugins.CVM1IaoC.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.CsMwWevK.js";import{n as c,t as ee}from"./DocsPager.v4kQH163.js";import{showToast as l}from"./Toast.BO2NFckG.js";import{a as te,c as u,d as ne,g as re,h as ie,i as ae,l as d,m as oe,n as se,p as ce,r as le,s as f,t as ue,u as de}from"./project-docs.DAw9bzgk.js";import{n as fe}from"./doc-roots.DAJP9Svr.js";import{t as pe}from"./useListAnim.BoerpmsB.js";import{t as p}from"./NamePromptDialog.CS1pTTVl.js";var m=e(t(),1),h=o(),me=5;function g({className:e=`w-4 h-4`,open:t=!1}){return(0,h.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,h.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,h.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function _({className:e=`w-3 h-3`}){return(0,h.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,h.jsx)(`path`,{d:`m15 5 4 4`})]})}function v({className:e=`w-3 h-3`}){return(0,h.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M3 6h18`}),(0,h.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,h.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,h.jsx)(`path`,{d:`M10 11v6`}),(0,h.jsx)(`path`,{d:`M14 11v6`})]})}function y({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,h.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,h.jsx)(g,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,h.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,h.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,h.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,h.jsx)(y,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function he(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function b(){let[e,t]=(0,m.useState)(()=>r(`requirements`)),[o,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(null),[C,ge]=(0,m.useState)([]),[_e,ve]=(0,m.useState)(0),[w,T]=(0,m.useState)(`.`),[E,D]=(0,m.useState)([]),[ye,O]=(0,m.useState)({}),[k,be]=(0,m.useState)(!0),[A,j]=(0,m.useState)(null),[M,N]=(0,m.useState)(!1),[P,F]=(0,m.useState)(null),[xe,I]=(0,m.useState)(!1),[L,R]=(0,m.useState)(null),[z,B]=(0,m.useState)(null),[Se,V]=(0,m.useState)(1),[H,Ce]=c(me),[we,U]=(0,m.useState)(null),W=(0,m.useRef)(null),{cls:Te,play:G}=pe(),K=(0,m.useCallback)(async()=>{let e=await ae(`requirements`);ge(e.tree),ve(e.totalFiles)},[]),q=(0,m.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([u(`requirements`,e),K()]);D(t.entries),T(t.path)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,K]);(0,m.useEffect)(()=>{let e=i(e=>t(!!e.requirements));return n().then(()=>{t(r(`requirements`)),b(!0)}),e},[]),(0,m.useEffect)(()=>{o&&e&&(async()=>{if(!await le(`requirements`))S(!1);else try{let[e]=await Promise.all([u(`requirements`,`.`),K()]);D(e.entries),T(e.path),S(!0)}catch(e){j(e instanceof Error?e.message:String(e)),S(!0)}})()},[o,e,K]);function Ee(){be(e=>!e),O({})}async function J(e){G(),T(e),V(1),F(null),U(null),j(null);try{let t=await u(`requirements`,e);D(t.entries)}catch(e){j(e instanceof Error?e.message:String(e))}}async function De(e){I(!1),N(!0),j(null);try{await d(`requirements`,w,e),await q(w),l(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`新建文件夹失败:${t}`,`error`)}finally{N(!1)}}async function Oe(e){if(e.type===`file`){N(!0),j(null);try{await de(`requirements`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function ke(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await re(`requirements`,w,t);await q(w),l(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`上传失败:${t}`,`error`)}finally{N(!1),W.current&&(W.current.value=``)}}}function Ae(e){let t=te(C,e.path),n=t?.fileCount??0,r=t?ue(t):0;R({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function je(e){R({name:e.name,path:e.path,isDir:!1})}function Y(e,t){B({...e,isDir:t})}async function Me(){let e=L;if(e&&(R(null),!e.blocked)){N(!0),j(null);try{await se(`requirements`,e.path),P&&f(P.path,e.path)&&F(null);let t=f(w,e.path)?ne(e.path):w;await q(t),l(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`删除失败:${t}`,`error`)}finally{N(!1)}}}async function Ne(e){let t=z;if(t&&(B(null),e!==t.name)){N(!0),j(null);try{let n=await ie(`requirements`,t.path,e);await q(oe(w,t.path,n)),l(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`重命名失败:${t}`,`error`)}finally{N(!1)}}}let Pe=(()=>{if(!L)return``;if(!L.isDir)return`删除文件「${L.name}」?将移入系统废纸篓,可随时找回。`;if(L.blocked){let e=[];return L.files&&e.push(`${L.files} 个文件`),L.dirs&&e.push(`${L.dirs} 个子文件夹`),`文件夹「${L.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${L.name}」?将移入系统废纸篓。`})();async function Fe(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(t.endsWith(`.md`)||t.endsWith(`.txt`)){N(!0),j(null);try{let t=await ce(`requirements`,e.path);F({path:t.path,content:t.content})}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}if(!o)return(0,h.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,h.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,h.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(`requirements`)});if(x===null)return(0,h.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,h.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!x)return(0,h.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:`需求文档库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/H)),$=Math.min(Se,Q),Ie=X.slice(($-1)*H,$*H);function Le(e){G(),Ce(e),V(1)}return(0,h.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,h.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,h.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>I(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,h.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,h.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),Ee()},"aria-expanded":k,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${w===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,h.jsx)(g,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,h.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,_e,`)`]})]})}),(0,h.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,h.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:C.map(e=>(0,h.jsx)(y,{node:e,depth:0,activePath:w,expanded:ye,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,h.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,h.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,h.jsx)(`span`,{className:`text-stone-400`,children:fe(`requirements`)}),w===`.`?``:w]}),(0,h.jsx)(`input`,{ref:W,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,text/csv,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel`,className:`hidden`,onChange:e=>void ke(e.target.files)}),(0,h.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>W.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),A?(0,h.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,h.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,h.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,h.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,h.jsx)(g,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,h.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Ae({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,h.jsx)(v,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,h.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加需求文档(.md / .txt / .docx / .xlsx / .csv)`}):(0,h.jsx)(`ul`,{className:`${Te}space-y-1`,children:Ie.map(e=>{let t=we===e.path;return(0,h.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${t?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{U(e.path),Fe(e)},onDoubleClick:t=>{t.preventDefault(),Oe(e)},children:[(0,h.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,h.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:he(e.size)})]}),(0,h.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,h.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>je(e),className:`tw-icon-danger p-1.5 rounded`,children:(0,h.jsx)(v,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),P?(0,h.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:P.path}),(0,h.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>F(null),children:`关闭预览`})]}),(0,h.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:P.content})]}):null]}),X.length>0?(0,h.jsx)(ee,{page:$,totalPages:Q,pageSize:H,busy:M,onPage:e=>{G(),V(e)},onPageSize:Le}):null]}),(0,h.jsx)(p,{open:xe,title:`新建文件夹`,onClose:()=>I(!1),onConfirm:e=>void De(e)}),(0,h.jsx)(p,{open:z!=null,title:z?.isDir?`重命名文件夹`:`重命名文件`,label:z?.isDir?`文件夹名称`:`文件名称`,initialValue:z?.name??``,lockExtension:z!=null&&!z.isDir,confirmLabel:`保存`,onClose:()=>B(null),onConfirm:e=>void Ne(e)}),(0,h.jsx)(s,{open:L!=null,title:L?.blocked?`无法删除文件夹`:L?.isDir?`删除文件夹`:`删除需求文件`,message:Pe,confirmLabel:L?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!L?.blocked,hideCancel:!!L?.blocked,onClose:()=>R(null),onConfirm:()=>void Me()})]})}export{b as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./OverflowHint.pvo2Xc8R.js";import{t as i}from"./SelectDropdown.Cb-QtC-D.js";var a=e(t(),1),o=n();function s({options:e,values:t,onChange:n,placeholder:i=`选择…`,disabled:s=!1}){let[c,l]=(0,a.useState)(!1),u=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!c)return;function e(e){u.current?.contains(e.target)||l(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let d=e.filter(e=>t.includes(e.value)).map(e=>e.label),f=s||d.length===0?i:d.length<=2?d.join(`、`):`已选 ${d.length} 项`;function p(e){t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])}return(0,o.jsxs)(`div`,{className:`relative mt-1`,ref:u,children:[(0,o.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>l(e=>!e),className:s?`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`:`tw-field-trigger w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,children:[(0,o.jsx)(r,{text:f,className:`min-w-0 flex-1 truncate ${s||d.length?``:`text-stone-400`}`}),(0,o.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,o.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`})})]}),c?(0,o.jsx)(`div`,{className:`tw-select-menu tw-dsh-scroll tw-popover-anim absolute z-80 mt-1 max-h-72 w-full overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200`,children:e.length===0?(0,o.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`暂无可选项`}):e.map(e=>{let n=t.includes(e.value);return(0,o.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>p(e.value),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,o.jsx)(r,{text:e.label,className:`min-w-0 flex-1 truncate`})]},e.value)})}):null]})}function c({options:e,value:t,onChange:n,placeholder:s=`搜索并选择…`,disabled:c=!1,allowEmpty:l=!0,emptyLabel:u=`不选择`}){let d=(0,a.useMemo)(()=>{let t=e.map(e=>({value:e.value,label:e.label}));return l?[{value:``,label:u,muted:!0},...t]:t},[e,l,u]),f=t?d.find(e=>e.value===t):void 0;return(0,o.jsx)(i,{options:d,value:t,onChange:n,disabled:c,searchable:!0,searchPlaceholder:s,dimWhenOpen:!0,renderTrigger:(e,{open:t})=>f?(0,o.jsx)(`span`,{className:`min-w-0 flex-1 ${t?`text-stone-400`:``}`,children:(0,o.jsx)(r,{text:f.label,className:`block truncate`})}):(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-stone-400`,children:s})})}export{s as n,c as t};
|