lantern-harness 0.1.32 → 0.1.33

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/500.html +4 -4
  3. package/dist/_astro/Base.Dlgbb4Ry.css +1 -0
  4. package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.4j--gBo-.js → Base.astro_astro_type_script_index_0_lang.BQ1EoZdo.js} +2 -2
  5. package/dist/_astro/{CaseExecBoard.CTuf_Nom.js → CaseExecBoard.CTVdi8MV.js} +1 -1
  6. package/dist/_astro/CaseGenerateApp.CJK7V6iA.js +10 -0
  7. package/dist/_astro/{CasesLibrary.C-T3VrPa.js → CasesLibrary.Don-Cnus.js} +10 -10
  8. package/dist/_astro/ChatApp.BTcAJ7PK.js +226 -0
  9. package/dist/_astro/{ColumnResize.BgYkV9Iy.js → ColumnResize._Iq05ix_.js} +1 -1
  10. package/dist/_astro/{DashboardBoard.B5Qo5Y3e.js → DashboardBoard.BaJyXPXA.js} +1 -1
  11. package/dist/_astro/{DocsFileBrowser.DnxVsmed.js → DocsFileBrowser.D2Cff2LP.js} +1 -1
  12. package/dist/_astro/{KnowledgeLibrary.DARUegK8.js → KnowledgeLibrary.CWxIHa8I.js} +1 -1
  13. package/dist/_astro/{NavLibraries.FAj9zUuq.js → NavLibraries.CZlA6Z1w.js} +1 -1
  14. package/dist/_astro/{PluginsPage.F0oMYJri.js → PluginsPage.CyjR13X6.js} +1 -1
  15. package/dist/_astro/PluginsPage.DMEvFLnP.js +1 -0
  16. package/dist/_astro/{PmBugsBoard.uNPzbw-N.js → PmBugsBoard.ChL0RBVn.js} +1 -1
  17. package/dist/_astro/{PmIterationsBoard.CjR8L71i.js → PmIterationsBoard.hTKVnMgh.js} +1 -1
  18. package/dist/_astro/{PmProjectDetail.Cpug99Lt.js → PmProjectDetail.Saj76lNM.js} +1 -1
  19. package/dist/_astro/{PmProjectsBoard.VLqrwucj.js → PmProjectsBoard.CCtClGM1.js} +1 -1
  20. package/dist/_astro/PmRequirementsBoard.BNNq671Z.js +1 -0
  21. package/dist/_astro/{PmRequirementsBoard.CdP4gEzq.js → PmRequirementsBoard.DGXYC1Te.js} +1 -1
  22. package/dist/_astro/{PmShared.ChKKU3Ww.js → PmShared.BuhrL7Gb.js} +1 -1
  23. package/dist/_astro/PromptsLibrary.DJtTAFz_.js +1 -0
  24. package/dist/_astro/{ReportsPage.iSM5TWMq.js → ReportsPage.BjD8w0zS.js} +1 -1
  25. package/dist/_astro/ReqAnalysisBoard.BsQ4A1Lt.js +39 -0
  26. package/dist/_astro/{RequirementsLibrary.X89V8-QF.js → RequirementsLibrary.WxAFCP3X.js} +1 -1
  27. package/dist/_astro/{SettingsDialog.BlokCWBn.js → SettingsDialog.CR7rv0mg.js} +1 -1
  28. package/dist/_astro/SpaceSwitcher.BCZbiL7o.js +7 -0
  29. package/dist/_astro/{TasksBoard.Z8rBCO1F.js → TasksBoard.CdWQSwlg.js} +1 -1
  30. package/dist/_astro/{TemplatesLibrary.DBHSAPQ0.js → TemplatesLibrary.y_RtSjYC.js} +1 -1
  31. package/dist/_astro/{TestStatsBoard.BtqoPuLc.js → TestStatsBoard.C3vkF9vc.js} +1 -1
  32. package/dist/_astro/{TodosBoard.ETI63YgA.js → TodosBoard.CSupMlTp.js} +1 -1
  33. package/dist/_astro/{UiAutoBoard.DxrlgvI7.js → UiAutoBoard._og5jRon.js} +3 -3
  34. package/dist/_astro/app-version.DpWEt8o3.js +1 -0
  35. package/dist/_astro/{case-gen-run.BNNfA12U.js → case-gen-run.DDhoxXlU.js} +1 -1
  36. package/dist/_astro/{plugins.SqANn3ZB.js → plugins.CVnHeKyf.js} +1 -1
  37. package/dist/_astro/prompts-meta.Dnmq-SnF.js +2 -0
  38. package/dist/_astro/req-analysis.D9EOpleR.js +31 -0
  39. package/dist/_astro/story-review.COs6QaUe.js +14 -0
  40. package/dist/case-exec/index.html +5 -5
  41. package/dist/cases/generate/index.html +5 -5
  42. package/dist/cases/library/index.html +5 -5
  43. package/dist/dashboard/index.html +5 -5
  44. package/dist/docs/changelog/index.html +57 -38
  45. package/dist/docs/install/index.html +4 -4
  46. package/dist/docs/manual/index.html +14 -14
  47. package/dist/knowledge/index.html +5 -5
  48. package/dist/plugins/index.html +5 -5
  49. package/dist/pm/bugs/index.html +5 -5
  50. package/dist/pm/iterations/index.html +5 -5
  51. package/dist/pm/projects/detail/index.html +5 -5
  52. package/dist/pm/projects/index.html +5 -5
  53. package/dist/pm/requirements/index.html +5 -5
  54. package/dist/prompts/index.html +5 -5
  55. package/dist/reports/index.html +5 -5
  56. package/dist/requirement-analysis/index.html +5 -5
  57. package/dist/requirements/index.html +5 -5
  58. package/dist/tasks/index.html +5 -5
  59. package/dist/templates/index.html +5 -5
  60. package/dist/test-automation/index.html +5 -5
  61. package/dist/test-stats/index.html +5 -5
  62. package/dist/todos/index.html +5 -5
  63. package/dist/workbench/index.html +5 -5
  64. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +10 -10
  65. package/lh-plugins/lh-req-analysis.mjs +60 -3
  66. package/lh-plugins/plugin-prompts.mjs +2 -0
  67. package/lh-plugins/req-analysis-prompt.mjs +30 -4
  68. package/package.json +1 -1
  69. package/dist/_astro/Base.9LLJ6KVG.css +0 -1
  70. package/dist/_astro/CaseGenerateApp.18SE0dLJ.js +0 -10
  71. package/dist/_astro/ChatApp.BpFXgd8K.js +0 -226
  72. package/dist/_astro/PluginsPage.DKPA2zw8.js +0 -1
  73. package/dist/_astro/PmRequirementsBoard.B5ypu68O.js +0 -1
  74. package/dist/_astro/PromptsLibrary.BlWPVm1Z.js +0 -1
  75. package/dist/_astro/ReqAnalysisBoard.CeQbq7Qh.js +0 -39
  76. package/dist/_astro/SpaceSwitcher.MmSkP3wb.js +0 -7
  77. package/dist/_astro/app-version.CLOjRiPN.js +0 -1
  78. package/dist/_astro/prompts-meta.C_MeYq8G.js +0 -2
  79. package/dist/_astro/req-analysis.Dbe_gqPz.js +0 -24
  80. package/dist/_astro/story-review.CNZnYMvW.js +0 -15
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Bg6v8zQQ.js";import{i as r,o as i,s as a}from"./plugins.SqANn3ZB.js";import{_ as o,a as s,b as ee,c as te,d as ne,f as re,g as ie,h as ae,i as c,l,m as oe,n as se,o as u,p as d,r as f,s as p,u as m,v as ce,y as le}from"./case-exec.BLqTXR7U.js";import{r as ue,s as de}from"./view-prefs.SdItxolG.js";import{t as fe}from"./jsx-runtime.DUg_B_vD.js";import{t as pe}from"./ConfirmDialog.D5qXeML0.js";import{t as h}from"./DatePicker.Bkl71M49.js";import{n as me,t as he}from"./DocsPager.CnXEnQqa.js";import{t as g}from"./TagSelect.UUXgkMqJ.js";import{showToast as _}from"./Toast.BO2NFckG.js";var v=e(t(),1),y=fe(),ge=8e3,b=600,_e=20,ve=`tw.case-exec.page-size.v1`,x=`case-exec.search`,S=[{key:`select`,width:`6%`},{key:`date`,width:`20%`},{key:`total`,width:`12%`},{key:`pending`,width:`12%`},{key:`executed`,width:`12%`},{key:`remaining`,width:`12%`},{key:`ratio`,width:`20%`},{key:`action`,width:`6%`}],C=`h-8 w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 text-center text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300 tabular-nums`,w=`h-8 w-full rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`,T=`h-7 shrink-0 rounded-md border bg-white px-2 text-xs font-medium whitespace-nowrap disabled:opacity-40`,E=(0,y.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,y.jsx)(`path`,{d:`M3 6h18`}),(0,y.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,y.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,y.jsx)(`path`,{d:`M10 11v6M14 11v6`})]}),D=(0,y.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,y.jsx)(`path`,{d:`M6 9l6 6 6-6`})});function O(e){let[t,n]=(0,v.useState)(e.value?String(e.value):``),r=(0,v.useRef)(e.value),i=(0,v.useRef)(e.onCommit);i.current=e.onCommit,(0,v.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,v.useEffect)(()=>{let e=t?o(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},b);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?o(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,y.jsx)(`input`,{type:`text`,inputMode:`numeric`,"aria-label":e.ariaLabel,value:t,placeholder:e.placeholder??`0`,onChange:e=>n(e.target.value.replace(/[^\d]/g,``)),onBlur:a,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),t.currentTarget.blur()):t.key===`Escape`&&(t.preventDefault(),r.current=e.value,n(e.value?String(e.value):``),t.currentTarget.blur())},className:C})}function k(e){return e>=80?{text:`text-[#4176e6]`,bar:`bg-[#3370ff]`}:e>=40?{text:`text-[#a85b00]`,bar:`bg-[#f5a524]`}:{text:`text-stone-500`,bar:`bg-stone-400`}}function A(e){let t=s(e.item,e.baseline),n=d(e.item,e.baseline),r=f(e.item,e.baseline),i=k(t);return(0,y.jsxs)(`div`,{className:`flex flex-col justify-center gap-1.5 px-1.5`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-1.5`,children:[(0,y.jsx)(`span`,{className:`shrink-0 text-[13px] font-semibold leading-none tabular-nums ${i.text}`,children:n}),(0,y.jsxs)(`span`,{className:`min-w-0 truncate text-right text-[10px] leading-none text-stone-400 tabular-nums`,children:[`已执行 `,r,` / `,e.baseline]})]}),(0,y.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-stone-200/70`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full ${i.bar}`,style:{width:`${t}%`},"aria-hidden":`true`})})]})}function j(){let[e,t]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!0),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)([]),[fe,h]=(0,v.useState)([]),[g,b]=(0,v.useState)(null),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(()=>ue(x)),[E,D]=(0,v.useState)({}),[O,k]=(0,v.useState)(1),[A,j]=me(_e,ve),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)({}),[I,L]=(0,v.useState)(null),[R,z]=(0,v.useState)(null);function be(e){de(x,e),T(e),k(1)}let B=(0,v.useRef)(!0),V=(0,v.useRef)(!1);(0,v.useEffect)(()=>(B.current=!0,()=>{B.current=!1}),[]);let H=(0,v.useCallback)(async()=>{try{let e=await ae();if(!B.current)return;p(e.items),h(e.projects),D(t=>{let n=new Set(e.items.map(e=>e.id)),r=!1,i={};for(let[e,a]of Object.entries(t))a&&(n.has(e)?i[e]=!0:r=!0);return r?i:t}),b(null)}catch(e){if(!B.current)return;b(e instanceof Error?e.message:String(e))}},[]);(0,v.useEffect)(()=>{let e=i(e=>s(!!e.caseExec));return n().then(()=>{s(r(`caseExec`)),t(!0)}),e},[]),(0,v.useEffect)(()=>{e&&o&&(async()=>{let e=await re();B.current&&(e?(await H(),B.current&&d(!0)):d(!1))})()},[e,o,H]),(0,v.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{V.current||H()},ge),t=()=>{V.current||H()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,H]);let U=ce(),W=(0,v.useMemo)(()=>se(f),[f]),G=(0,v.useMemo)(()=>oe(f,{keyword:w}),[f,w]),xe=Math.max(1,Math.ceil(G.length/A)),K=Math.min(O,xe),q=(0,v.useMemo)(()=>G.slice((K-1)*A,K*A),[G,K,A]),J=(0,v.useMemo)(()=>q.flatMap(e=>P[e.key]?[]:e.items),[q,P]),Y=(0,v.useMemo)(()=>f.filter(e=>E[e.id]),[f,E]),Se=J.length>0&&J.every(e=>E[e.id]);function Ce(e){F(t=>{let n={...t};return n[e]?delete n[e]:n[e]=!0,n})}function we(e){F(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})}function X(e,t){D(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r})}function Z(e){if(!e.project){let t=e.items[0];return t?[t.id]:[]}return f.filter(t=>t.project===e.project).map(e=>e.id)}(0,v.useEffect)(()=>{if(!M)return;let e=G.findIndex(e=>e.items.some(e=>e.id===M));if(e<0)return;k(Math.floor(e/A)+1);let t=window.setTimeout(()=>N(null),2e3);return()=>window.clearTimeout(t)},[M,G,A]);async function Te(){if(!S){C(!0),b(null),be(``);try{let e=await l([{date:U,project:``,startDate:U,endDate:U}],{mode:`manual`});if(!B.current)return;let t=e.items[0];if(e.projects.length&&h(e.projects),await H(),!B.current||!t)return;N(t.id)}catch(e){B.current&&b(e instanceof Error?e.message:String(e))}finally{B.current&&C(!1)}}}async function Ee(e){if(!S&&e.project){C(!0),b(null);try{let t=await l([{date:U,project:e.project,startDate:e.startDate,endDate:e.endDate}],{mode:`manual`});if(!B.current)return;let n=t.items[0];if(t.projects.length&&h(t.projects),we(e.key),await H(),!B.current||!n)return;N(n.id)}catch(e){B.current&&b(e instanceof Error?e.message:String(e))}finally{B.current&&C(!1)}}}async function Q(e,t){p(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,projects:r}=await le(e,t);if(!B.current)return;p(t=>t.map(t=>t.id===e?n:t)),h(r),b(null)}catch(e){if(!B.current)return;b(e instanceof Error?e.message:String(e)),await H()}}function De(e,t){let n=t.startDate??e.startDate,r=t.endDate??e.endDate;if(n&&r&&r<n){_(`结束日期不能早于开始日期`,`error`);return}if(!e.project){let n=e.items[0];n&&Q(n.id,t);return}let i=e.project;p(e=>e.map(e=>e.project===i?{...e,startDate:n,endDate:r}:e)),(async()=>{try{let e=await ee(i,{startDate:n,endDate:r});if(!B.current)return;p(e.items),h(e.projects),b(null)}catch(e){if(!B.current)return;b(e instanceof Error?e.message:String(e)),_(`修改周期失败:${e instanceof Error?e.message:String(e)}`,`error`),await H()}})()}function Oe(e,t){let n=t.trim();if(n&&n!==e.project){if(e.project)$(e.project,n);else{let t=e.items[0];t&&Q(t.id,{project:n})}}}function ke(e,t){e.pending>0?Q(e.id,{total:t,executed:c(t,e.pending)}):Q(e.id,{total:t})}function Ae(e,t){Q(e.id,{pending:t,executed:c(e.total,t)})}async function $(e,t){let n=t.trim();if(n&&n!==e)try{let t=await ie(e,n);if(!B.current)return;p(t.items),h(t.projects),b(null),_(t.replaced>0?`已重命名,同步了 ${t.replaced} 条记录`:`已重命名项目名称`,`success`)}catch(e){if(!B.current)return;_(`重命名失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function je(e){let t=te(f,e);if(t>0)_(`还有 ${t} 条记录在用「${e}」,先改掉再删除`,`error`);else try{let t=await ne(e);if(!B.current)return;p(t.items),h(t.projects),b(null),_(`已删除项目名称「${e}」`,`success`)}catch(e){if(!B.current)return;_(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Me(){let e=I;if(e&&e.length!==0){L(null),C(!0);try{if(await m(e.map(e=>e.id)),!B.current)return;D({}),b(null),await H(),_(e.length>1?`已删除 ${e.length} 条执行记录`:`已删除执行记录`,`success`)}catch(e){if(!B.current)return;let t=e instanceof Error?e.message:String(e);b(t),_(`删除失败:${t}`,`error`)}finally{B.current&&C(!1)}}}async function Ne(){let e=R;if(!e)return;z(null);let t=Z(e);if(t.length){C(!0);try{if(await m(t),!B.current)return;X(t,!1),b(null),await H(),_(e.project?`已删除「${e.project}」的 ${t.length} 条统计`:`已删除 ${t.length} 条执行记录`,`success`)}catch(e){if(!B.current)return;let t=e instanceof Error?e.message:String(e);b(t),_(`删除失败:${t}`,`error`)}finally{B.current&&C(!1)}}}return e?o?u===null?(0,y.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接用例执行统计服务`,children:(0,y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,y.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,y.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-800`,children:W.records}),` 条统计`,(0,y.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· `,W.projects,` 个项目 · 已执行 `,W.executed,` / `,W.baseline,` 个用例 · 整体执行率 `,W.percent.toFixed(2),`%`,Y.length?` · 已选 ${Y.length} 条`:``]})]}),(0,y.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`label`,{className:`flex h-9 shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap text-sm text-stone-600`,children:[(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:Se,disabled:J.length===0,onChange:e=>X(J.map(e=>e.id),e.target.checked)}),`全选本页`]}),(0,y.jsx)(`input`,{value:w,onChange:e=>be(e.target.value),placeholder:`搜索项目 / 统计日期…`,className:`h-9 w-44 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,y.jsx)(`button`,{type:`button`,disabled:S||Y.length===0,onClick:()=>L(Y),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,y.jsx)(`button`,{type:`button`,disabled:S,onClick:()=>void Te(),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 添加项目`})]})]}),g?(0,y.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,y.jsx)(`span`,{className:`min-w-0 flex-1`,children:g}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>b(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,y.jsxs)(`div`,{"data-case-exec":!0,className:`min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-4`,onFocusCapture:()=>{V.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{V.current=!!document.activeElement?.closest(`[data-case-exec]`)},0)},children:[G.length===0?(0,y.jsx)(`div`,{className:`rounded-lg border border-dashed border-stone-200 px-4 py-14 text-center text-sm text-stone-400`,children:`还没有用例执行统计记录,点右上角「+ 添加项目」开始。`}):null,q.map(e=>{let t=Z(e);return(0,y.jsx)(ye,{group:e,collapsed:!!P[e.key],groupSelected:t.length>0&&t.every(e=>!!E[e]),recordCount:t.length,projects:fe,addedId:M,selected:E,busy:S,onToggle:()=>Ce(e.key),onToggleGroupSelect:e=>X(t,e),onToggleRow:(e,t)=>X([e],t),onCommitProject:t=>Oe(e,t),onRenameProject:(e,t)=>void $(e,t),onRemoveProject:e=>void je(e),onCommitCycle:t=>De(e,t),onAddStatDate:()=>void Ee(e),onDeleteGroup:()=>z(e),onPatch:Q,onCommitTotal:ke,onCommitPending:Ae,onDeleteRow:e=>L([e])},e.key)})]}),G.length>0?(0,y.jsx)(he,{page:K,totalPages:xe,pageSize:A,busy:S,unit:`个项目`,onPage:k,onPageSize:e=>{j(e),k(1)}}):(0,y.jsx)(`div`,{className:`pb-1`}),(0,y.jsx)(pe,{open:I!==null,title:`删除用例执行统计`,message:I&&I.length>1?`确定删除选中的 ${I.length} 条记录吗?删除后不可恢复。`:`确定删除「${I?.[0]?.project??``} ${I?.[0]?.date??``}」这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>L(null),onConfirm:()=>void Me()}),(0,y.jsx)(pe,{open:R!==null,title:`删除整个项目的统计`,message:R?.project?`确定删除「${R.project}」的全部 ${Z(R).length} 条统计吗?删除后不可恢复(项目名称仍保留在下拉里)。`:`确定删除这条占位记录吗?删除后不可恢复。`,confirmLabel:`删除整组`,danger:!0,onClose:()=>z(null),onConfirm:()=>void Ne()})]}):(0,y.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`用例执行统计需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,y.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(`caseExec`)}):(0,y.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}function ye(e){let{group:t}=e,n=k(t.percent);return(0,y.jsxs)(`article`,{className:`overflow-hidden rounded-lg border border-stone-200 bg-white`,children:[(0,y.jsxs)(`div`,{onClick:t=>{t.target.closest(`button, input, a, select, textarea, label, [role="button"], [role="combobox"]`)||window.getSelection()?.toString()||e.onToggle()},className:`cursor-pointer border-b border-stone-100 bg-[#fbfbfc] px-3 py-2`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1.5`,children:[(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`选择项目 ${t.project||`未命名`}`,checked:e.groupSelected,disabled:e.recordCount===0,onChange:t=>e.onToggleGroupSelect(t.target.checked)}),(0,y.jsx)(`button`,{type:`button`,"aria-expanded":!e.collapsed,"aria-label":`${e.collapsed?`展开`:`收起`} ${t.project||`未命名项目`}`,onClick:e.onToggle,className:`flex h-6 w-6 shrink-0 items-center justify-center rounded text-stone-400 transition-colors hover:bg-stone-200/70 hover:text-stone-700`,children:(0,y.jsx)(`span`,{className:`transition-transform ${e.collapsed?`-rotate-90`:``}`,"aria-hidden":`true`,children:D})}),(0,y.jsx)(`div`,{className:`w-52 shrink-0`,children:(0,y.jsx)(g,{compact:!0,ariaLabel:`项目名称`,options:e.projects,value:t.project,onChange:e.onCommitProject,onRenameOption:e.onRenameProject,onDeleteOption:e.onRemoveProject,placeholder:`选择或创建项目`})}),t.draft?(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,children:`选好项目名称后就能在这条项目下按统计日期记录`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,y.jsx)(h,{value:t.startDate,onChange:t=>e.onCommitCycle({startDate:t}),placeholder:`开始日期`,className:w})}),(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,"aria-hidden":`true`,children:`~`}),(0,y.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,y.jsx)(h,{value:t.endDate,onChange:t=>e.onCommitCycle({endDate:t}),placeholder:`结束日期`,className:w})})]}),(0,y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,y.jsxs)(`span`,{className:`mr-1 whitespace-nowrap text-xs text-stone-400 tabular-nums`,children:[e.recordCount,` 条统计`]}),t.draft?null:(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:e.onAddStatDate,className:`${T} border-stone-200 text-stone-700 hover:border-[#3370ff] hover:text-[#3370ff]`,children:`添加统计`}),(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:e.onDeleteGroup,className:`${T} border-red-200 text-red-600 hover:bg-red-50`,children:`删除整组`})]})]}),t.draft?null:(0,y.jsxs)(`div`,{className:`mt-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs text-stone-500 tabular-nums`,children:[(0,y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`基线 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-700`,children:t.baseline}),(0,y.jsx)(`span`,{className:`mx-1.5 text-stone-300`,children:`·`}),`已执行`,` `,(0,y.jsxs)(`span`,{className:`font-medium text-stone-700`,children:[t.executed,` / `,t.baseline]})]}),(0,y.jsxs)(`span`,{className:`shrink-0 text-[13px] font-semibold ${n.text}`,children:[t.percent.toFixed(2),`%`]})]}),(0,y.jsx)(`div`,{className:`mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-stone-200/70`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full ${n.bar}`,style:{width:`${t.percent}%`},"aria-hidden":`true`})})]})]}),(0,y.jsx)(`div`,{className:`grid transition-[grid-template-rows,opacity] duration-200 ease-out ${e.collapsed?`grid-rows-[0fr] opacity-0`:`grid-rows-[1fr] opacity-100`}`,"aria-hidden":e.collapsed,children:(0,y.jsx)(`div`,{className:`min-h-0 overflow-hidden`,inert:e.collapsed,children:(0,y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,y.jsxs)(`table`,{className:`w-full min-w-[820px] table-fixed text-sm`,children:[(0,y.jsx)(`colgroup`,{children:S.map(e=>(0,y.jsx)(`col`,{style:{width:e.width}},e.key))}),(0,y.jsx)(`thead`,{className:`bg-stone-50 text-xs text-stone-500`,children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,"aria-label":`选择`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`统计日期`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`用例总数`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`待执行用例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,title:`自动计算:用例总数 − 待执行用例`,children:`已执行用例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`当前剩余用例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`执行比例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,y.jsx)(`tbody`,{children:t.items.map(n=>(0,y.jsxs)(`tr`,{className:`border-t border-stone-100 first:border-t-0 ${n.id===e.addedId?`bg-[#f2f6ff]`:`hover:bg-[#f7f8fa]`}`,children:[(0,y.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${t.project} ${n.date}`,checked:!!e.selected[n.id],onChange:t=>e.onToggleRow(n.id,t.target.checked)})}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(h,{value:n.date,onChange:t=>e.onPatch(n.id,{date:t}),placeholder:`选择日期`,className:w})}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(O,{value:n.total,ariaLabel:`用例总数`,onCommit:t=>e.onCommitTotal(n,t)})}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(O,{value:n.pending,ariaLabel:`待执行用例`,onCommit:t=>e.onCommitPending(n,t)})}),(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle text-sm text-stone-800 tabular-nums`,title:`自动计算:用例总数 − 待执行用例`,children:p(n)}),(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle text-xs text-stone-500 tabular-nums`,children:u(n)}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(A,{item:n,baseline:t.baseline||n.total})}),(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle`,children:(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:()=>e.onDeleteRow(n),"aria-label":`删除 ${t.project} ${n.date} 的记录`,className:`tw-icon-danger rounded p-1`,children:E})})]},n.id))})]})})})})]})}export{j as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Bg6v8zQQ.js";import{i as r,o as i,s as a}from"./plugins.CVnHeKyf.js";import{_ as o,a as s,b as ee,c as te,d as ne,f as re,g as ie,h as ae,i as c,l,m as oe,n as se,o as u,p as d,r as f,s as p,u as m,v as ce,y as le}from"./case-exec.BLqTXR7U.js";import{r as ue,s as de}from"./view-prefs.SdItxolG.js";import{t as fe}from"./jsx-runtime.DUg_B_vD.js";import{t as pe}from"./ConfirmDialog.D5qXeML0.js";import{t as h}from"./DatePicker.Bkl71M49.js";import{n as me,t as he}from"./DocsPager.CnXEnQqa.js";import{t as g}from"./TagSelect.UUXgkMqJ.js";import{showToast as _}from"./Toast.BO2NFckG.js";var v=e(t(),1),y=fe(),ge=8e3,b=600,_e=20,ve=`tw.case-exec.page-size.v1`,x=`case-exec.search`,S=[{key:`select`,width:`6%`},{key:`date`,width:`20%`},{key:`total`,width:`12%`},{key:`pending`,width:`12%`},{key:`executed`,width:`12%`},{key:`remaining`,width:`12%`},{key:`ratio`,width:`20%`},{key:`action`,width:`6%`}],C=`h-8 w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 text-center text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300 tabular-nums`,w=`h-8 w-full rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`,T=`h-7 shrink-0 rounded-md border bg-white px-2 text-xs font-medium whitespace-nowrap disabled:opacity-40`,E=(0,y.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,y.jsx)(`path`,{d:`M3 6h18`}),(0,y.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,y.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,y.jsx)(`path`,{d:`M10 11v6M14 11v6`})]}),D=(0,y.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,y.jsx)(`path`,{d:`M6 9l6 6 6-6`})});function O(e){let[t,n]=(0,v.useState)(e.value?String(e.value):``),r=(0,v.useRef)(e.value),i=(0,v.useRef)(e.onCommit);i.current=e.onCommit,(0,v.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,v.useEffect)(()=>{let e=t?o(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},b);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?o(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,y.jsx)(`input`,{type:`text`,inputMode:`numeric`,"aria-label":e.ariaLabel,value:t,placeholder:e.placeholder??`0`,onChange:e=>n(e.target.value.replace(/[^\d]/g,``)),onBlur:a,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),t.currentTarget.blur()):t.key===`Escape`&&(t.preventDefault(),r.current=e.value,n(e.value?String(e.value):``),t.currentTarget.blur())},className:C})}function k(e){return e>=80?{text:`text-[#4176e6]`,bar:`bg-[#3370ff]`}:e>=40?{text:`text-[#a85b00]`,bar:`bg-[#f5a524]`}:{text:`text-stone-500`,bar:`bg-stone-400`}}function A(e){let t=s(e.item,e.baseline),n=d(e.item,e.baseline),r=f(e.item,e.baseline),i=k(t);return(0,y.jsxs)(`div`,{className:`flex flex-col justify-center gap-1.5 px-1.5`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-1.5`,children:[(0,y.jsx)(`span`,{className:`shrink-0 text-[13px] font-semibold leading-none tabular-nums ${i.text}`,children:n}),(0,y.jsxs)(`span`,{className:`min-w-0 truncate text-right text-[10px] leading-none text-stone-400 tabular-nums`,children:[`已执行 `,r,` / `,e.baseline]})]}),(0,y.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-stone-200/70`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full ${i.bar}`,style:{width:`${t}%`},"aria-hidden":`true`})})]})}function j(){let[e,t]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!0),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)([]),[fe,h]=(0,v.useState)([]),[g,b]=(0,v.useState)(null),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(()=>ue(x)),[E,D]=(0,v.useState)({}),[O,k]=(0,v.useState)(1),[A,j]=me(_e,ve),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)({}),[I,L]=(0,v.useState)(null),[R,z]=(0,v.useState)(null);function be(e){de(x,e),T(e),k(1)}let B=(0,v.useRef)(!0),V=(0,v.useRef)(!1);(0,v.useEffect)(()=>(B.current=!0,()=>{B.current=!1}),[]);let H=(0,v.useCallback)(async()=>{try{let e=await ae();if(!B.current)return;p(e.items),h(e.projects),D(t=>{let n=new Set(e.items.map(e=>e.id)),r=!1,i={};for(let[e,a]of Object.entries(t))a&&(n.has(e)?i[e]=!0:r=!0);return r?i:t}),b(null)}catch(e){if(!B.current)return;b(e instanceof Error?e.message:String(e))}},[]);(0,v.useEffect)(()=>{let e=i(e=>s(!!e.caseExec));return n().then(()=>{s(r(`caseExec`)),t(!0)}),e},[]),(0,v.useEffect)(()=>{e&&o&&(async()=>{let e=await re();B.current&&(e?(await H(),B.current&&d(!0)):d(!1))})()},[e,o,H]),(0,v.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{V.current||H()},ge),t=()=>{V.current||H()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,H]);let U=ce(),W=(0,v.useMemo)(()=>se(f),[f]),G=(0,v.useMemo)(()=>oe(f,{keyword:w}),[f,w]),xe=Math.max(1,Math.ceil(G.length/A)),K=Math.min(O,xe),q=(0,v.useMemo)(()=>G.slice((K-1)*A,K*A),[G,K,A]),J=(0,v.useMemo)(()=>q.flatMap(e=>P[e.key]?[]:e.items),[q,P]),Y=(0,v.useMemo)(()=>f.filter(e=>E[e.id]),[f,E]),Se=J.length>0&&J.every(e=>E[e.id]);function Ce(e){F(t=>{let n={...t};return n[e]?delete n[e]:n[e]=!0,n})}function we(e){F(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})}function X(e,t){D(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r})}function Z(e){if(!e.project){let t=e.items[0];return t?[t.id]:[]}return f.filter(t=>t.project===e.project).map(e=>e.id)}(0,v.useEffect)(()=>{if(!M)return;let e=G.findIndex(e=>e.items.some(e=>e.id===M));if(e<0)return;k(Math.floor(e/A)+1);let t=window.setTimeout(()=>N(null),2e3);return()=>window.clearTimeout(t)},[M,G,A]);async function Te(){if(!S){C(!0),b(null),be(``);try{let e=await l([{date:U,project:``,startDate:U,endDate:U}],{mode:`manual`});if(!B.current)return;let t=e.items[0];if(e.projects.length&&h(e.projects),await H(),!B.current||!t)return;N(t.id)}catch(e){B.current&&b(e instanceof Error?e.message:String(e))}finally{B.current&&C(!1)}}}async function Ee(e){if(!S&&e.project){C(!0),b(null);try{let t=await l([{date:U,project:e.project,startDate:e.startDate,endDate:e.endDate}],{mode:`manual`});if(!B.current)return;let n=t.items[0];if(t.projects.length&&h(t.projects),we(e.key),await H(),!B.current||!n)return;N(n.id)}catch(e){B.current&&b(e instanceof Error?e.message:String(e))}finally{B.current&&C(!1)}}}async function Q(e,t){p(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,projects:r}=await le(e,t);if(!B.current)return;p(t=>t.map(t=>t.id===e?n:t)),h(r),b(null)}catch(e){if(!B.current)return;b(e instanceof Error?e.message:String(e)),await H()}}function De(e,t){let n=t.startDate??e.startDate,r=t.endDate??e.endDate;if(n&&r&&r<n){_(`结束日期不能早于开始日期`,`error`);return}if(!e.project){let n=e.items[0];n&&Q(n.id,t);return}let i=e.project;p(e=>e.map(e=>e.project===i?{...e,startDate:n,endDate:r}:e)),(async()=>{try{let e=await ee(i,{startDate:n,endDate:r});if(!B.current)return;p(e.items),h(e.projects),b(null)}catch(e){if(!B.current)return;b(e instanceof Error?e.message:String(e)),_(`修改周期失败:${e instanceof Error?e.message:String(e)}`,`error`),await H()}})()}function Oe(e,t){let n=t.trim();if(n&&n!==e.project){if(e.project)$(e.project,n);else{let t=e.items[0];t&&Q(t.id,{project:n})}}}function ke(e,t){e.pending>0?Q(e.id,{total:t,executed:c(t,e.pending)}):Q(e.id,{total:t})}function Ae(e,t){Q(e.id,{pending:t,executed:c(e.total,t)})}async function $(e,t){let n=t.trim();if(n&&n!==e)try{let t=await ie(e,n);if(!B.current)return;p(t.items),h(t.projects),b(null),_(t.replaced>0?`已重命名,同步了 ${t.replaced} 条记录`:`已重命名项目名称`,`success`)}catch(e){if(!B.current)return;_(`重命名失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function je(e){let t=te(f,e);if(t>0)_(`还有 ${t} 条记录在用「${e}」,先改掉再删除`,`error`);else try{let t=await ne(e);if(!B.current)return;p(t.items),h(t.projects),b(null),_(`已删除项目名称「${e}」`,`success`)}catch(e){if(!B.current)return;_(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Me(){let e=I;if(e&&e.length!==0){L(null),C(!0);try{if(await m(e.map(e=>e.id)),!B.current)return;D({}),b(null),await H(),_(e.length>1?`已删除 ${e.length} 条执行记录`:`已删除执行记录`,`success`)}catch(e){if(!B.current)return;let t=e instanceof Error?e.message:String(e);b(t),_(`删除失败:${t}`,`error`)}finally{B.current&&C(!1)}}}async function Ne(){let e=R;if(!e)return;z(null);let t=Z(e);if(t.length){C(!0);try{if(await m(t),!B.current)return;X(t,!1),b(null),await H(),_(e.project?`已删除「${e.project}」的 ${t.length} 条统计`:`已删除 ${t.length} 条执行记录`,`success`)}catch(e){if(!B.current)return;let t=e instanceof Error?e.message:String(e);b(t),_(`删除失败:${t}`,`error`)}finally{B.current&&C(!1)}}}return e?o?u===null?(0,y.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接用例执行统计服务`,children:(0,y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,y.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,y.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-800`,children:W.records}),` 条统计`,(0,y.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· `,W.projects,` 个项目 · 已执行 `,W.executed,` / `,W.baseline,` 个用例 · 整体执行率 `,W.percent.toFixed(2),`%`,Y.length?` · 已选 ${Y.length} 条`:``]})]}),(0,y.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`label`,{className:`flex h-9 shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap text-sm text-stone-600`,children:[(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:Se,disabled:J.length===0,onChange:e=>X(J.map(e=>e.id),e.target.checked)}),`全选本页`]}),(0,y.jsx)(`input`,{value:w,onChange:e=>be(e.target.value),placeholder:`搜索项目 / 统计日期…`,className:`h-9 w-44 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,y.jsx)(`button`,{type:`button`,disabled:S||Y.length===0,onClick:()=>L(Y),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,y.jsx)(`button`,{type:`button`,disabled:S,onClick:()=>void Te(),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 添加项目`})]})]}),g?(0,y.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,y.jsx)(`span`,{className:`min-w-0 flex-1`,children:g}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>b(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,y.jsxs)(`div`,{"data-case-exec":!0,className:`min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-4`,onFocusCapture:()=>{V.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{V.current=!!document.activeElement?.closest(`[data-case-exec]`)},0)},children:[G.length===0?(0,y.jsx)(`div`,{className:`rounded-lg border border-dashed border-stone-200 px-4 py-14 text-center text-sm text-stone-400`,children:`还没有用例执行统计记录,点右上角「+ 添加项目」开始。`}):null,q.map(e=>{let t=Z(e);return(0,y.jsx)(ye,{group:e,collapsed:!!P[e.key],groupSelected:t.length>0&&t.every(e=>!!E[e]),recordCount:t.length,projects:fe,addedId:M,selected:E,busy:S,onToggle:()=>Ce(e.key),onToggleGroupSelect:e=>X(t,e),onToggleRow:(e,t)=>X([e],t),onCommitProject:t=>Oe(e,t),onRenameProject:(e,t)=>void $(e,t),onRemoveProject:e=>void je(e),onCommitCycle:t=>De(e,t),onAddStatDate:()=>void Ee(e),onDeleteGroup:()=>z(e),onPatch:Q,onCommitTotal:ke,onCommitPending:Ae,onDeleteRow:e=>L([e])},e.key)})]}),G.length>0?(0,y.jsx)(he,{page:K,totalPages:xe,pageSize:A,busy:S,unit:`个项目`,onPage:k,onPageSize:e=>{j(e),k(1)}}):(0,y.jsx)(`div`,{className:`pb-1`}),(0,y.jsx)(pe,{open:I!==null,title:`删除用例执行统计`,message:I&&I.length>1?`确定删除选中的 ${I.length} 条记录吗?删除后不可恢复。`:`确定删除「${I?.[0]?.project??``} ${I?.[0]?.date??``}」这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>L(null),onConfirm:()=>void Me()}),(0,y.jsx)(pe,{open:R!==null,title:`删除整个项目的统计`,message:R?.project?`确定删除「${R.project}」的全部 ${Z(R).length} 条统计吗?删除后不可恢复(项目名称仍保留在下拉里)。`:`确定删除这条占位记录吗?删除后不可恢复。`,confirmLabel:`删除整组`,danger:!0,onClose:()=>z(null),onConfirm:()=>void Ne()})]}):(0,y.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`用例执行统计需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,y.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(`caseExec`)}):(0,y.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}function ye(e){let{group:t}=e,n=k(t.percent);return(0,y.jsxs)(`article`,{className:`overflow-hidden rounded-lg border border-stone-200 bg-white`,children:[(0,y.jsxs)(`div`,{onClick:t=>{t.target.closest(`button, input, a, select, textarea, label, [role="button"], [role="combobox"]`)||window.getSelection()?.toString()||e.onToggle()},className:`cursor-pointer border-b border-stone-100 bg-[#fbfbfc] px-3 py-2`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1.5`,children:[(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`选择项目 ${t.project||`未命名`}`,checked:e.groupSelected,disabled:e.recordCount===0,onChange:t=>e.onToggleGroupSelect(t.target.checked)}),(0,y.jsx)(`button`,{type:`button`,"aria-expanded":!e.collapsed,"aria-label":`${e.collapsed?`展开`:`收起`} ${t.project||`未命名项目`}`,onClick:e.onToggle,className:`flex h-6 w-6 shrink-0 items-center justify-center rounded text-stone-400 transition-colors hover:bg-stone-200/70 hover:text-stone-700`,children:(0,y.jsx)(`span`,{className:`transition-transform ${e.collapsed?`-rotate-90`:``}`,"aria-hidden":`true`,children:D})}),(0,y.jsx)(`div`,{className:`w-52 shrink-0`,children:(0,y.jsx)(g,{compact:!0,ariaLabel:`项目名称`,options:e.projects,value:t.project,onChange:e.onCommitProject,onRenameOption:e.onRenameProject,onDeleteOption:e.onRemoveProject,placeholder:`选择或创建项目`})}),t.draft?(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,children:`选好项目名称后就能在这条项目下按统计日期记录`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,y.jsx)(h,{value:t.startDate,onChange:t=>e.onCommitCycle({startDate:t}),placeholder:`开始日期`,className:w})}),(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,"aria-hidden":`true`,children:`~`}),(0,y.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,y.jsx)(h,{value:t.endDate,onChange:t=>e.onCommitCycle({endDate:t}),placeholder:`结束日期`,className:w})})]}),(0,y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,y.jsxs)(`span`,{className:`mr-1 whitespace-nowrap text-xs text-stone-400 tabular-nums`,children:[e.recordCount,` 条统计`]}),t.draft?null:(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:e.onAddStatDate,className:`${T} border-stone-200 text-stone-700 hover:border-[#3370ff] hover:text-[#3370ff]`,children:`添加统计`}),(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:e.onDeleteGroup,className:`${T} border-red-200 text-red-600 hover:bg-red-50`,children:`删除整组`})]})]}),t.draft?null:(0,y.jsxs)(`div`,{className:`mt-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs text-stone-500 tabular-nums`,children:[(0,y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`基线 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-700`,children:t.baseline}),(0,y.jsx)(`span`,{className:`mx-1.5 text-stone-300`,children:`·`}),`已执行`,` `,(0,y.jsxs)(`span`,{className:`font-medium text-stone-700`,children:[t.executed,` / `,t.baseline]})]}),(0,y.jsxs)(`span`,{className:`shrink-0 text-[13px] font-semibold ${n.text}`,children:[t.percent.toFixed(2),`%`]})]}),(0,y.jsx)(`div`,{className:`mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-stone-200/70`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full ${n.bar}`,style:{width:`${t.percent}%`},"aria-hidden":`true`})})]})]}),(0,y.jsx)(`div`,{className:`grid transition-[grid-template-rows,opacity] duration-200 ease-out ${e.collapsed?`grid-rows-[0fr] opacity-0`:`grid-rows-[1fr] opacity-100`}`,"aria-hidden":e.collapsed,children:(0,y.jsx)(`div`,{className:`min-h-0 overflow-hidden`,inert:e.collapsed,children:(0,y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,y.jsxs)(`table`,{className:`w-full min-w-[820px] table-fixed text-sm`,children:[(0,y.jsx)(`colgroup`,{children:S.map(e=>(0,y.jsx)(`col`,{style:{width:e.width}},e.key))}),(0,y.jsx)(`thead`,{className:`bg-stone-50 text-xs text-stone-500`,children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,"aria-label":`选择`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`统计日期`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`用例总数`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`待执行用例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,title:`自动计算:用例总数 − 待执行用例`,children:`已执行用例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`当前剩余用例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`执行比例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,y.jsx)(`tbody`,{children:t.items.map(n=>(0,y.jsxs)(`tr`,{className:`border-t border-stone-100 first:border-t-0 ${n.id===e.addedId?`bg-[#f2f6ff]`:`hover:bg-[#f7f8fa]`}`,children:[(0,y.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${t.project} ${n.date}`,checked:!!e.selected[n.id],onChange:t=>e.onToggleRow(n.id,t.target.checked)})}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(h,{value:n.date,onChange:t=>e.onPatch(n.id,{date:t}),placeholder:`选择日期`,className:w})}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(O,{value:n.total,ariaLabel:`用例总数`,onCommit:t=>e.onCommitTotal(n,t)})}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(O,{value:n.pending,ariaLabel:`待执行用例`,onCommit:t=>e.onCommitPending(n,t)})}),(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle text-sm text-stone-800 tabular-nums`,title:`自动计算:用例总数 − 待执行用例`,children:p(n)}),(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle text-xs text-stone-500 tabular-nums`,children:u(n)}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(A,{item:n,baseline:t.baseline||n.total})}),(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle`,children:(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:()=>e.onDeleteRow(n),"aria-label":`删除 ${t.project} ${n.date} 的记录`,className:`tw-icon-danger rounded p-1`,children:E})})]},n.id))})]})})})})]})}export{j as default};
@@ -0,0 +1,10 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/lib.S37S0T6S.js","_astro/react.Blvh0GOs.js","_astro/jszip.min.Bh2Mgo40.js"])))=>i.map(i=>d[i]);
2
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Bg6v8zQQ.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./SelectDropdown.apWlFGbA.js";import{showToast as a}from"./Toast.BO2NFckG.js";import{i as o,r as s}from"./case-types.CJ5PHz59.js";import{d as c,f as l,m as u,p as d,r as f,u as ee}from"./case-gen-run.DDhoxXlU.js";import{t as p}from"./export.joBT53eb.js";import{a as m,i as h,n as g,o as _,r as v,s as te,t as ne}from"./case-template.F1Nv08GV.js";import{b as y,m as re,p as b,u as x}from"./settings.Cu00if4D.js";import{_ as S,c as C,f as w,l as ie,p as T,r as E,u as D,v as ae}from"./project-docs.DAw9bzgk.js";import{o as oe}from"./llm.DyweO-KK.js";import{n as O}from"./doc-roots.DAJP9Svr.js";import{r as se}from"./prompts-meta.Dnmq-SnF.js";import{t as ce}from"./ExcelFieldTags.CXif3Ilh.js";import{t as le}from"./MultiSelectDropdown.BHxW9XLR.js";import{t as k}from"./SearchableSelect.D3ODywC4.js";var A=e(t(),1),j=r(),ue=[{value:`md`,label:`Markdown 表格`},{value:`xlsx`,label:`Excel`},{value:`csv`,label:`CSV`}];function de(e){let t=e.match(/```(?:json)?\s*([\s\S]*?)```/)?.[1]??e.match(/\{[\s\S]*\}/)?.[0]??e.match(/\[[\s\S]*\]/)?.[0];if(!t)return null;try{let e=JSON.parse(t);if(Array.isArray(e)&&e.length>0)return{docTitle:``,cases:e};if(e&&typeof e==`object`){let t=e,n=t.用例??t.cases??t.items;if(!Array.isArray(n)||n.length===0)return null;let r=t.需求名称??t.文档名称??t.docTitle??t.title;return{docTitle:typeof r==`string`?r.trim():``,cases:n}}}catch{return null}return null}function fe(e){return(e.split(`/`).pop()||e).replace(/\.[^.]+$/,``).trim()}function pe(e){let t=e.match(/^#\s+(.+)$/m);if(t?.[1])return t[1].trim().slice(0,48);let n=e.match(/^标题[::]\s*(.+)$/m);return n?.[1]?n[1].trim().slice(0,48):``}function me(e,t){let n=[];if(!e.length)return n.push(`未生成任何用例`),n;for(let r of t){let t=e.filter(e=>!String(e[r]??``).trim()).length;t===e.length?n.push(`字段「${r}」全部为空`):t>Math.max(2,Math.floor(e.length*.3))&&n.push(`字段「${r}」有 ${t}/${e.length} 条为空`)}e.length<15&&n.push(`用例数量偏少(${e.length} 条),建议核对需求覆盖`);let r=e.map(e=>{for(let t of[`用例标题`,`标题`,`测试分项目`,`测试项目`])if(e[t]?.trim())return e[t].trim();return``}).filter(Boolean),i=new Set(r);return r.length>=4&&i.size<r.length*.6&&n.push(`用例标题/分项重复偏多,可能覆盖不足`),n}function he(e){if(e==null||e<0)return`—`;if(e<1e3)return`${e} ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)} s`;let n=Math.floor(t/60);return`${n} 分 ${Math.round(t-n*60)} 秒`}function ge(e){if(!e)return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1})}catch{return`—`}}async function _e(e){let t=s(e).templateFolder;try{let{entries:e}=await C(`templates`,t),n=e.filter(e=>e.type===`file`).sort((e,t)=>(t.mtime??0)-(e.mtime??0)),r=[];for(let e of n){let t=e.name.toLowerCase(),n=[...p],i=``;try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await w(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64){let e=h(t.contentBase64);n=e.headers,i=e.body}}else if(t.endsWith(`.csv`)){let t=await T(`templates`,e.path),r=g(t.content);n=r.headers,i=r.body}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await T(`templates`,e.path),r=v(t.content);n=r.headers,i=r.body}}catch{i=``}r.push({id:e.path,title:e.name.replace(/\.[^.]+$/,``),body:i,headers:n})}return r}catch{return[]}}async function ve(t){let n=t.toLowerCase();if(n.endsWith(`.md`)||n.endsWith(`.txt`)||n.endsWith(`.csv`))return(await T(`requirements`,t)).content;if(n.endsWith(`.docx`)){let n=await w(`requirements`,t);if(n.encoding!==`base64`||!n.contentBase64)throw Error(`无法读取 docx`);let r=atob(n.contentBase64),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return((await(await y(()=>import(`./lib.S37S0T6S.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1,2]))).extractRawText({arrayBuffer:i.buffer})).value??``).trim()}throw Error(`该需求文件类型暂不支持正文提取`)}function M(){let[e,t]=(0,A.useState)(null),[r,h]=(0,A.useState)(!1),[g,v]=(0,A.useState)([]),[y,w]=(0,A.useState)(``),[M,N]=(0,A.useState)(`functional`),[P,ye]=(0,A.useState)([]),[be,F]=(0,A.useState)(``),[xe,Se]=(0,A.useState)([]),[I,L]=(0,A.useState)(``),[Ce,R]=(0,A.useState)(``),[we,Te]=(0,A.useState)([]),[z,B]=(0,A.useState)([]),[V,H]=(0,A.useState)(`md`),[U,Ee]=(0,A.useState)(``),[W,G]=(0,A.useState)(null),[K,De]=(0,A.useState)(!1),[Oe,q]=(0,A.useState)(null),[J,Y]=(0,A.useState)(null),X=(0,A.useRef)(null),ke=(0,A.useRef)(null),Z=(0,A.useMemo)(()=>P.find(e=>e.id===be)??P[0],[P,be]),Q=M,Ae=s(Q).label;(0,A.useEffect)(()=>{n().then(()=>t(x()));let e=b(()=>t(x()));return(async()=>{await c();let e=await E(`requirements`),t=await E(`cases`),n=await E(`templates`),r=await E(`prompts`),i=await E(`knowledge`);h(e&&t&&n&&r);async function a(e,t,n){let{entries:r}=await C(e,t);for(let t of r)t.type===`file`?n.push(t):await a(e,t.path,n)}if(e)try{let e=[];await a(`requirements`,`.`,e),v(e)}catch{}if(i)try{let e=[];await a(`knowledge`,`.`,e),e.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),Te(e)}catch{}if(r)try{let e=[];await a(`prompts`,`.`,e);let t=e.filter(e=>!se(e.path));t.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),Se(t);let n=t.find(e=>e.path.includes(`功能测试用例提示词`))?.path??t[0]?.path??``;L(e=>e&&!se(e)&&t.some(t=>t.path===e)?e:n)}catch{}let s=new URLSearchParams(window.location.search),d=s.get(`session`),f=s.get(`path`),p=l();if(d){let e=p.sessions.find(e=>e.id===d);e&&(G(e),N(e.caseType),H(e.outputFormat),w(e.reqPaths[0]??``),e.templateId&&F(e.templateId),e.promptPath&&L(e.promptPath),e.knowledgePaths?.length&&B([...e.knowledgePaths]),e.linkedCasePath&&Y({path:e.linkedCasePath,count:0}))}else if(f){let e=p.sessions.find(e=>e.linkedCasePath===f);if(e)G(e),N(e.caseType),H(e.outputFormat),w(e.reqPaths[0]??``),e.templateId&&F(e.templateId),e.promptPath&&L(e.promptPath),e.knowledgePaths?.length&&B([...e.knowledgePaths]),e.linkedCasePath&&Y({path:e.linkedCasePath,count:0});else{let e=f.split(`.`).pop()?.toLowerCase(),t=e===`csv`?`csv`:e===`xlsx`||e===`xls`?`xlsx`:`md`,n=f.split(`/`)[0]??``,r=o().find(e=>e.casesFolder===n)?.id??o()[0]?.id??`functional`,i=ee({title:f.split(`/`).pop()?.replace(/\.[^.]+$/,``)||`用例续改`,caseType:r,outputFormat:t,reqPaths:[]}),a=u(i.id,{linkedCasePath:f}).sessions.find(e=>e.id===i.id)??null;G(a),N(r),H(t),Y({path:f,count:0})}}})(),e},[]),(0,A.useEffect)(()=>{if(!r)return;let e=!1;return _e(M).then(t=>{e||(ye(t),F(e=>e&&t.some(t=>t.id===e)?e:W?.templateId&&t.some(e=>e.id===W.templateId)?W.templateId:t[0]?.id??``))}),()=>{e=!0}},[r,M,W?.templateId]),(0,A.useEffect)(()=>{I?T(`prompts`,I).then(e=>{let t=e.content??``;R(t),t.trim()||a(`「提示词管理/${I}」是空的,生成前请先补上提示词内容。`,`error`)}).catch(e=>{R(``);let t=e instanceof Error?e.message:String(e);a(`没有读到「提示词管理/${I}」:${t}`,`error`)}):R(``)},[I]),(0,A.useEffect)(()=>{ke.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[W?.messages,K]);function $(e){if(!W)return;let t=u(W.id,e);G(t.sessions.find(e=>e.id===W.id)??W)}async function je(){let e=``;if(y)try{let t=await ve(y);e+=`\n### 需求文档:${y}\n${t}\n`}catch{e+=`\n### 需求文档:${y}\n(无法读取正文)\n`}Z?.body?e+=`\n### 用例模板:${Z.title}\n${Z.body}\n`:Z&&(e+=`\n### 用例模板:${Z.title}\n字段:${(Z.headers.length?Z.headers:p).join(`、`)}\n`);for(let t of z)try{let n=await T(`knowledge`,t);e+=`\n### 知识库:${t}\n${n.content}\n`}catch{e+=`\n### 知识库:${t}\n(无法读取)\n`}return e}async function Me(e,t,n,r){let i=s(t.caseType),a=n||t.title||i.label,o=f(a,t.caseType),c=i.casesFolder;try{await ie(`cases`,`.`,c)}catch{}let l=`${c}/${o}${t.outputFormat===`md`?`.md`:t.outputFormat===`csv`?`.csv`:`.xlsx`}`,u=r.length?r:[...p];return t.outputFormat===`md`?await ae(`cases`,l,_(e,a,u)):t.outputFormat===`csv`?await ae(`cases`,l,m(e,u)):await S(`cases`,l,await te(e,u,i.label)),l}async function Ne(){if(!y)return``;let e=fe(y);try{return pe(await ve(y))||e}catch{return e}}async function Pe(t,n){if(!e){re(`model`);return}if(!r){q(`本地文档服务未就绪,无法读写用例 / 需求 / 模板库`);return}let i=await Ne(),o=n;o?(u(o.id,{caseType:M,outputFormat:V,reqPaths:y?[y]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:I||void 0,knowledgePaths:z.length?[...z]:void 0}),o={...o,caseType:M,outputFormat:V,reqPaths:y?[y]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:I||void 0,knowledgePaths:z.length?[...z]:void 0}):(o=ee({title:i||t.slice(0,24)||`用例生成`,caseType:M,outputFormat:V,reqPaths:y?[y]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:I||void 0,knowledgePaths:z.length?[...z]:void 0}),G(o));let c=await je(),l=s(M).label,d=Z?.headers?.length?Z.headers:[...p],f=V===`md`?`最终结果将保存为 Markdown 表格文件`:V===`csv`?`最终结果将保存为 CSV 文件`:`最终结果将保存为 Excel 文件`,m=Ce.trim();if(!m){let e=I?`「提示词管理/${I}」没读到内容,请先在提示词管理里补上`:`请先选择提示词`;q(e),a(e,`error`);return}let h=`${m}
3
+
4
+ 【运行时约束】
5
+ - 用例类型:${l}
6
+ - ${f}
7
+ - 需求名称默认可用「${i||`未命名需求`}」
8
+ - 「用例」对象键必须与模板字段完全一致(另可多写「备注」):${d.includes(`备注`)?d.join(`、`):[...d,`备注`].join(`、`)}
9
+ - 「待业务确认 / 待确认」项也要写成用例,在「备注」写「待业务确认:…」,不要只丢进未覆盖说明
10
+ - 仅输出 JSON 对象:{"需求名称":"...","覆盖需求率":0-100,"未覆盖说明":[],"编写说明":"...","用例":[...]},不要其他解释`,g=[{role:`system`,content:h},{role:`user`,content:`${c}\n\n【用户请求】\n${t}`}];if(n&&n.messages.length){g.length=0,g.push({role:`system`,content:h});for(let e of n.messages.slice(-8))(e.role===`user`||e.role===`assistant`)&&g.push({role:e.role,content:e.content});g.push({role:`user`,content:t})}let _=Date.now(),v={role:`user`,content:t,time:_},te={role:`assistant`,content:``,time:_,result:{ok:!1,count:0}},b=[...o.messages||[],v,te],x=o.messages.length>0?o.title:i||t.slice(0,24)||o.title;o={...o,messages:b,title:x},G(o),u(o.id,{messages:b,title:o.title}),De(!0),q(null);let S=new AbortController;X.current=S;let C=``;function w(e,t=``){let n=[...b];n[n.length-1]={role:`assistant`,content:t,time:Date.now(),result:e};let r={messages:n,outputFormat:o.outputFormat,caseType:o.caseType};e.ok&&e.path&&(r.linkedCasePath=e.path,e.path&&Y({path:e.path,count:e.count}));let i=u(o.id,r);G(i.sessions.find(e=>e.id===o.id)??null)}try{for await(let t of oe(e,g,S.signal,{thinking:!1}))t.type===`content`&&(C+=t.delta);let t=Date.now()-_,n=de(C);if(n){let e=Z?.headers?.length?Z.headers:[...p],r=ne(n.cases,e),a=i||o.title||n.docTitle||s(o.caseType).label,c=await Me(r,{...o,title:a},a,e),l=me(r,e);u(o.id,{title:a}),w({ok:!0,count:r.length,path:c,durationMs:t,finishedAt:Date.now(),omissions:l})}else{let e=`未能解析出用例 JSON`;q(`${e},可调整提示词或需求后重试。`),w({ok:!1,count:0,durationMs:t,finishedAt:Date.now(),error:e,omissions:[`输出无法解析,未写入用例文件`]})}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)w({ok:!1,count:0,durationMs:Date.now()-_,finishedAt:Date.now(),error:`已停止`,omissions:[`用户停止生成`]});else{let t=e instanceof Error?e.message:String(e);q(t),w({ok:!1,count:0,durationMs:Date.now()-_,finishedAt:Date.now(),error:t,omissions:[`生成过程中断或失败`]})}}finally{De(!1),X.current=null}}async function Fe(){let e=U.trim();e&&!K&&(Ee(``),await Pe(e,W??void 0))}let Ie=!!U.trim()&&!K,Le=g.map(e=>({value:e.path,label:e.path})),Re=P.map(e=>({value:e.id,label:e.title})),ze=xe.map(e=>({value:e.path,label:e.path.replace(/\.[^.]+$/,``)}));return(0,j.jsxs)(`div`,{className:`flex flex-col gap-4 max-w-4xl mx-auto`,children:[r?null:(0,j.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900`,children:`本地文档服务未就绪,无法读写需求 / 模板 / 提示词 / 用例库。`}),(0,j.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4 space-y-4`,children:[(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:`用例类型`}),(0,j.jsx)(i,{options:o().map(e=>({value:e.id,label:e.label})),value:Q,onChange:e=>{N(e),$({caseType:e})}})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:`输出格式`}),(0,j.jsx)(i,{options:ue,value:V,onChange:e=>{if(H(e),W?.linkedCasePath){let t=`${W.linkedCasePath.replace(/\.[^.]+$/,``)}${e===`md`?`.md`:e===`csv`?`.csv`:`.xlsx`}`;$({outputFormat:e,linkedCasePath:t}),Y(e=>e?{...e,path:t}:{path:t,count:0})}else $({outputFormat:e})}})]})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-0.5`,children:`需求文档`}),(0,j.jsx)(k,{options:Le,value:y,onChange:e=>{w(e),$({reqPaths:e?[e]:[]})},allowEmpty:!1,placeholder:`未选择需求文档`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`text-xs font-medium text-stone-500 mb-0.5`,children:[`用例模板`,(0,j.jsxs)(`span`,{className:`ml-1 font-normal text-stone-400`,children:[`(`,Ae,` · `,s(Q).templateFolder,`)`]})]}),(0,j.jsx)(k,{options:Re,value:Z?.id??``,onChange:e=>{F(e),$({templateId:e,templateTitle:P.find(t=>t.id===e)?.title})},allowEmpty:!1,placeholder:Re.length?`搜索并选择模板…`:`暂无「${s(Q).templateFolder}」模板`}),Z?.headers?.length?(0,j.jsx)(ce,{fields:Z.headers}):Z?(0,j.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400`,children:`未识别到模板字段`}):null]})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-0.5`,children:`提示词`}),(0,j.jsx)(k,{options:ze,value:I,onChange:e=>{L(e),$({promptPath:e||void 0})},allowEmpty:!1,placeholder:ze.length?`搜索并选择提示词…`:`请先在提示词管理中上传`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-0.5`,children:`引用知识库(可多选)`}),(0,j.jsx)(le,{options:we.map(e=>({value:e.path,label:e.path.replace(/\.[^.]+$/,``)})),values:z,onChange:e=>{B(e),$({knowledgePaths:e.length?e:void 0})},placeholder:we.length?`选择知识库文档…`:`暂无知识库文档`})]})]}),W?.linkedCasePath&&!J?(0,j.jsxs)(`p`,{className:`text-xs text-emerald-700 bg-emerald-50 border border-emerald-100 rounded-md px-3 py-2`,children:[`已关联用例文件:`,O(`cases`),W.linkedCasePath]}):null]}),(0,j.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-[#f8f9fb] flex flex-col h-[min(520px,60vh)]`,children:[(0,j.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-4 py-4 space-y-3`,children:[W?.messages.length?(()=>{let e=[];for(let t of W.messages)if(t.role===`user`)e.push({user:t});else if(t.role===`assistant`){let n=e[e.length-1];n&&!n.assistant?n.assistant=t:e.push({assistant:t})}return e.map((t,n)=>{let r=n===e.length-1,i=K&&r&&!t.assistant?.result?.finishedAt,a=t.assistant?.result;return(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 items-stretch`,children:[(0,j.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3 py-3 min-h-22`,children:[(0,j.jsx)(`div`,{className:`text-[11px] font-medium text-stone-400 mb-1.5`,children:`提问`}),(0,j.jsx)(`div`,{className:`text-sm text-stone-800 whitespace-pre-wrap leading-6`,children:t.user?.content||`—`})]}),(0,j.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3 py-3 min-h-22`,children:[(0,j.jsx)(`div`,{className:`text-[11px] font-medium text-stone-400 mb-1.5`,children:`生成结果`}),i?(0,j.jsx)(`div`,{className:`text-sm text-[#4176e6]`,children:`生成中…`}):a?(0,j.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,j.jsx)(`span`,{className:`inline-flex items-center h-6 px-2 rounded-md text-xs font-medium ${a.ok?`bg-emerald-50 text-emerald-700`:`bg-red-50 text-red-700`}`,children:a.ok?`成功`:`失败`}),(0,j.jsx)(`span`,{className:`text-xs text-stone-500`,children:ge(a.finishedAt??t.assistant?.time)}),(0,j.jsxs)(`span`,{className:`text-xs text-stone-500`,children:[`耗时 `,he(a.durationMs)]})]}),(0,j.jsxs)(`div`,{className:`text-stone-700`,children:[`用例数量:`,(0,j.jsx)(`span`,{className:`font-medium text-stone-900`,children:a.count}),` 条`]}),a.path?(0,j.jsxs)(`button`,{type:`button`,className:`text-xs text-[#4176e6] hover:underline text-left truncate max-w-full`,"data-hint":`本地打开`,onClick:()=>void D(`cases`,a.path).catch(e=>q(e instanceof Error?e.message:String(e))),children:[O(`cases`),a.path]}):null,a.error?(0,j.jsx)(`div`,{className:`text-xs text-red-600`,children:a.error}):null,(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1`,children:`遗漏检测`}),a.omissions&&a.omissions.length>0?(0,j.jsx)(`ul`,{className:`text-xs text-amber-800 bg-amber-50 border border-amber-100 rounded-md px-2.5 py-2 space-y-1`,children:a.omissions.map(e=>(0,j.jsxs)(`li`,{children:[`· `,e]},e))}):a.ok?(0,j.jsx)(`div`,{className:`text-xs text-emerald-700 bg-emerald-50 border border-emerald-100 rounded-md px-2.5 py-2`,children:`未发现明显遗漏`}):(0,j.jsx)(`div`,{className:`text-xs text-stone-400`,children:`—`})]})]}):(0,j.jsx)(`div`,{className:`text-sm text-stone-400`,children:`等待结果`})]})]},n)})})():(0,j.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-stone-400 py-16`,children:`选择上下文后,在下方输入需求说明并提交,将创建一条用例会话。`}),(0,j.jsx)(`div`,{ref:ke})]}),Oe?(0,j.jsx)(`div`,{className:`shrink-0 mx-4 mb-2 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:Oe}):null,J?(0,j.jsxs)(`div`,{className:`shrink-0 mx-4 mb-3`,children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:`生成的用例文件`}),(0,j.jsxs)(`button`,{type:`button`,"data-hint":`点击在本地打开`,onClick:()=>{D(`cases`,J.path).catch(e=>q(e instanceof Error?e.message:String(e)))},onDoubleClick:()=>{D(`cases`,J.path).catch(e=>q(e instanceof Error?e.message:String(e)))},className:`w-full flex items-center gap-3 rounded-lg border border-stone-200 bg-white px-3 py-2.5 text-left hover:border-[#4176e6] hover:bg-[#f5f8ff] transition-colors`,children:[(0,j.jsx)(`span`,{className:`w-9 h-9 rounded-lg bg-emerald-50 text-emerald-700 flex items-center justify-center text-xs font-semibold shrink-0`,children:J.path.split(`.`).pop()?.toUpperCase()||`FILE`}),(0,j.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,j.jsx)(`span`,{className:`block text-sm text-stone-800 truncate`,children:J.path.split(`/`).pop()}),(0,j.jsxs)(`span`,{className:`block text-[11px] text-stone-400 truncate`,children:[O(`cases`),J.path,J.count>0?` · ${J.count} 条`:``,` · 点击打开`]})]})]})]}):null,(0,j.jsxs)(`div`,{className:`shrink-0 p-3 border-t border-stone-200 bg-white rounded-b-xl`,children:[(0,j.jsxs)(`div`,{className:`rounded-2xl border border-stone-200 focus-within:ring-2 focus-within:ring-[#4176e6]/25`,children:[(0,j.jsx)(`textarea`,{value:U,onChange:e=>Ee(e.target.value),rows:3,placeholder:e?`描述要生成或修改的用例… Enter 发送,Shift+Enter 换行`:`请先配置模型`,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),Fe())},className:`w-full px-4 pt-3 pb-2 text-sm resize-none outline-none bg-transparent`}),(0,j.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-3 pb-2`,children:[e?null:(0,j.jsx)(`button`,{type:`button`,onClick:()=>re(`model`),className:`text-xs text-amber-700 hover:underline`,children:`配置模型`}),K?(0,j.jsx)(`button`,{type:`button`,onClick:()=>X.current?.abort(),className:`h-8 px-3 text-sm rounded-full bg-stone-200 text-stone-700`,children:`停止`}):null,(0,j.jsx)(`button`,{type:`button`,disabled:!Ie,onClick:()=>void Fe(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-full hover:bg-[#3565c7] disabled:opacity-40`,children:`提交`})]})]}),W?(0,j.jsx)(`button`,{type:`button`,className:`mt-2 text-xs text-stone-400 hover:text-stone-600`,onClick:()=>{G(null),Y(null),q(null);let e=l();d({...e,activeId:``})},children:`开始新的用例会话`}):null]})]})]})}export{M as default};