lantern-harness 0.2.2 → 0.2.4
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 +46 -0
- package/README.md +7 -7
- package/builtin/case-backup-contract.mjs +27 -0
- package/builtin/case-workflow-contract.mjs +158 -0
- package/builtin/session/lh-nav-groups.mjs +33 -1
- package/builtin/session/space-layout.mjs +8 -1
- package/builtin/session/space-skills.mjs +8 -1
- package/cli/mcp-server.mjs +1211 -72
- package/cli/server.mjs +2 -0
- package/dist/500.html +9 -4
- package/dist/_astro/Base.ANghvs5L.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.XUV2H6ea.js → Base.astro_astro_type_script_index_0_lang.f7BIL9Qf.js} +1 -1
- package/dist/_astro/{BusinessMapBoard.mRxl2G3D.js → BusinessMapBoard.CYxHcku_.js} +1 -1
- package/dist/_astro/{CaseExecBoard.Cqkxuf5c.js → CaseExecBoard.CK9aGPmH.js} +1 -1
- package/dist/_astro/CaseExecutionBoard.p6Y23xyH.js +4 -0
- package/dist/_astro/CaseGenerateApp.D5uj5bSb.js +10 -0
- package/dist/_astro/CasesLibrary.CY1PRdzc.js +21 -0
- package/dist/_astro/ChatApp.BnV7drSC.js +1 -0
- package/dist/_astro/ChatApp.CqyrMX90.js +262 -0
- package/dist/_astro/{DashboardBoard.CAJVE2G4.js → DashboardBoard.qgc1s7pG.js} +1 -1
- package/dist/_astro/{DefectSubmitEntry.BzKXJ-zq.js → DefectSubmitEntry.JI85N1-i.js} +1 -1
- package/dist/_astro/{DocsFileBrowser.apKMbGVf.js → DocsFileBrowser.z5JZ74cy.js} +1 -1
- package/dist/_astro/{DocsPager.DMN9-Tjg.js → DocsPager.Dg765uHW.js} +1 -1
- package/dist/_astro/{KnowledgeLibrary.BcoMQeUd.js → KnowledgeLibrary.mkShtVun.js} +1 -1
- package/dist/_astro/{LifeKrTasksBoard.DJU0-QI-.js → LifeKrTasksBoard.DpAwQffE.js} +1 -1
- package/dist/_astro/{LifeKrTodosBoard.GK7KRAO3.js → LifeKrTodosBoard.BIjPiZ8H.js} +1 -1
- package/dist/_astro/{LifeObjectivesBoard.DuKa6Q3k.js → LifeObjectivesBoard.DYwLHPEG.js} +1 -1
- package/dist/_astro/{LifePlanTypeSelect.Cm2lUmnH.js → LifePlanTypeSelect.CYaziESp.js} +1 -1
- package/dist/_astro/{LifeReviewsBoard.BWOOVMtz.js → LifeReviewsBoard.DIxoWBDA.js} +1 -1
- package/dist/_astro/{LifeShared.bY2l01Ha.js → LifeShared.DuFQsMEx.js} +1 -1
- package/dist/_astro/{LifeStagesBoard.CIzxPOJB.js → LifeStagesBoard.DtOri9EW.js} +1 -1
- package/dist/_astro/{LifeYearCycleSelect.BlsyPmmI.js → LifeYearCycleSelect.ByJ9-PGg.js} +1 -1
- package/dist/_astro/{LifeYearPlansBoard.DaA9O08j.js → LifeYearPlansBoard.BQN07wcv.js} +1 -1
- package/dist/_astro/NavLibraries.BO4ezcUc.js +1 -0
- package/dist/_astro/{PluginsPage.B063QIlQ.js → PluginsPage.Cb6977dz.js} +2 -2
- package/dist/_astro/{PmBugsBoard.Cu-v0Gfd.js → PmBugsBoard.Ddl3kqqt.js} +1 -1
- package/dist/_astro/{PmIterationsBoard.CgRzkP-j.js → PmIterationsBoard.BJN7disI.js} +1 -1
- package/dist/_astro/{PmProjectDetail.DVCEh0Lm.js → PmProjectDetail.D78gWhqk.js} +1 -1
- package/dist/_astro/{PmProjectsBoard.z-bQa98r.js → PmProjectsBoard.Bf8VB3t6.js} +1 -1
- package/dist/_astro/PmRequirementsBoard.CDyNHN2a.js +1 -0
- package/dist/_astro/{PmRequirementsBoard.CyfBI0u_.js → PmRequirementsBoard.DarfGIrL.js} +1 -1
- package/dist/_astro/{PmShared.BQVzwsiz.js → PmShared.TOjBbtV8.js} +1 -1
- package/dist/_astro/{ReportsPage.najSzJeT.js → ReportsPage.BXGduuY3.js} +1 -1
- package/dist/_astro/{ReqAnalysisBoard.BQb8dHFD.js → ReqAnalysisBoard.C7V_fEh9.js} +1 -1
- package/dist/_astro/{RequirementBreakdownLibrary.Cn6OV6xt.js → RequirementBreakdownLibrary.DMoeTeqX.js} +1 -1
- package/dist/_astro/{RequirementsLibrary.CqKNFVsP.js → RequirementsLibrary.Iv7zOqWe.js} +1 -1
- package/dist/_astro/{SettingsDialog.db3BpFw0.js → SettingsDialog.CRbfEiyw.js} +1 -1
- package/dist/_astro/SlideOverDrawer.CvyB-quk.js +1 -0
- package/dist/_astro/{SpaceSwitcher.DSUVAPOi.js → SpaceSwitcher.D9bBNQBZ.js} +1 -1
- package/dist/_astro/{TableFieldConfig.72AL-8p-.js → TableFieldConfig.DHj25OKN.js} +1 -1
- package/dist/_astro/{TasksBoard.CCDhCSR7.js → TasksBoard.CXmGdylV.js} +1 -1
- package/dist/_astro/TemplatesLibrary.DsL2q-wp.js +1 -0
- package/dist/_astro/{TestReportsLibrary.fWiEyCRx.js → TestReportsLibrary.BBC1TYgP.js} +1 -1
- package/dist/_astro/{TestStatsBoard.BSUBsWSu.js → TestStatsBoard.VXjP4hu6.js} +1 -1
- package/dist/_astro/{TodosBoard.By5YdlUe.js → TodosBoard.-yKgp06M.js} +1 -1
- package/dist/_astro/UiAutoBoard.BZkPzwi8.js +3 -0
- package/dist/_astro/UiAutoEnvPanel.DrHUOlmH.js +10 -0
- package/dist/_astro/UiAutoGenerationDialog.gypq1zP9.js +12 -0
- package/dist/_astro/UiAutoProjectsPage.Dhzr09E9.js +3 -0
- package/dist/_astro/app-config.BSO5r82v.js +1 -0
- package/dist/_astro/app-version.B7nd7uBP.js +1 -0
- package/dist/_astro/{bash-tools.CS2w8LOb.js → bash-tools.C4DJiRJs.js} +1 -1
- package/dist/_astro/case-fields.C03NY3zC.js +148 -0
- package/dist/_astro/case-gen-run.DQR6uvH5.js +26 -0
- package/dist/_astro/case-prompt.ByLTgz4r.js +2 -0
- package/dist/_astro/{case-review.DFWZkoR9.js → case-review.BodP2jKm.js} +1 -1
- package/dist/_astro/{case-template.Clb7HrDB.js → case-template.CC2eXegU.js} +2 -2
- package/dist/_astro/case-types.BjF1BivA.js +1 -0
- package/dist/_astro/case-workflow-contract.BBQ9bbKL.js +1 -0
- package/dist/_astro/{defect-workbench.CjTb4FDv.js → defect-workbench.DBmohR-y.js} +1 -1
- package/dist/_astro/{hydrate-cache.O4CIma9y.js → hydrate-cache.CMMErx63.js} +1 -1
- package/dist/_astro/{i18n.Cp4so7KR.js → i18n.CEWjL5GX.js} +2 -2
- package/dist/_astro/{open-docs-in-session.BpcAcBSI.js → open-docs-in-session.BoyV6R2A.js} +1 -1
- package/dist/_astro/plugins.ChGmBEkF.js +1 -0
- package/dist/_astro/{project-docs.bB9lQ1Ki.js → project-docs.BRgNjXhG.js} +1 -1
- package/dist/_astro/{req-analysis.C_gARMrB.js → req-analysis.efWkT7Gv.js} +1 -1
- package/dist/_astro/{settings.D02wZj3w.js → settings.BojKNwUC.js} +2 -2
- package/dist/_astro/{spaces-client.BAtG6PkW.js → spaces-client.B28rzu8J.js} +1 -1
- package/dist/_astro/{story-review.DTN91Vl9.js → story-review.Dm9VcR6v.js} +1 -1
- package/dist/_astro/{test-points.C7ZgggQT.js → test-points.BSfPfq8z.js} +1 -1
- package/dist/_astro/ui-auto.LUcREUMe.js +1 -0
- package/dist/_astro/{view-prefs.COAKEQtZ.js → view-prefs.CWc5cQ2q.js} +1 -1
- package/dist/business-map/index.html +10 -5
- package/dist/case-exec/index.html +10 -5
- package/dist/case-execution/index.html +10 -5
- package/dist/cases/api/index.html +988 -0
- package/dist/cases/automation/index.html +988 -0
- package/dist/cases/functional/index.html +988 -0
- package/dist/cases/generate/index.html +10 -5
- package/dist/cases/index.html +1 -1
- package/dist/cases/library/index.html +1 -983
- package/dist/cases/other/index.html +988 -0
- package/dist/cases/performance/index.html +988 -0
- package/dist/dashboard/index.html +10 -5
- package/dist/defect-rules/index.html +10 -5
- package/dist/defect-submit/index.html +10 -5
- package/dist/defect-submit/templates/index.html +10 -5
- package/dist/docs/changelog/index.html +105 -58
- package/dist/docs/install/index.html +12 -6
- package/dist/docs/manual/index.html +62 -40
- package/dist/knowledge/index.html +10 -5
- package/dist/life/kr-tasks/index.html +10 -5
- package/dist/life/kr-todos/index.html +10 -5
- package/dist/life/objectives/index.html +10 -5
- package/dist/life/reviews/index.html +10 -5
- package/dist/life/stages/index.html +10 -5
- package/dist/life/year-plans/index.html +10 -5
- package/dist/plugins/index.html +10 -5
- package/dist/pm/bugs/index.html +10 -5
- package/dist/pm/iterations/index.html +10 -5
- package/dist/pm/projects/detail/index.html +10 -5
- package/dist/pm/projects/index.html +10 -5
- package/dist/pm/requirements/index.html +10 -5
- package/dist/reports/index.html +10 -5
- package/dist/requirement-analysis/index.html +10 -5
- package/dist/requirement-breakdowns/index.html +10 -5
- package/dist/requirements/index.html +10 -5
- package/dist/tasks/index.html +10 -5
- package/dist/templates/index.html +10 -5
- package/dist/test-automation/index.html +10 -5
- package/dist/test-automation/projects/index.html +10 -5
- package/dist/test-reports/index.html +10 -5
- package/dist/test-stats/index.html +10 -5
- package/dist/todos/index.html +10 -5
- package/dist/workbench/index.html +10 -5
- package/docs/Codex-MCP/351/233/206/346/210/220.md +117 -53
- package/docs//344/274/232/350/257/235/346/217/222/344/273/266.md +14 -1
- package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +5 -1
- package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +4 -2
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +45 -36
- package/lh-plugins/case-automation/service.mjs +927 -0
- package/lh-plugins/case-automation/store.mjs +231 -0
- package/lh-plugins/case-automation/tables.mjs +115 -0
- package/lh-plugins/case-automation-prompt.mjs +57 -0
- package/lh-plugins/case-execution/assets.mjs +180 -0
- package/lh-plugins/case-execution/files.mjs +123 -23
- package/lh-plugins/case-execution/plans.mjs +318 -0
- package/lh-plugins/case-execution/service.mjs +80 -13
- package/lh-plugins/case-execution-prompt.mjs +4 -1
- package/lh-plugins/lh-case-automation.mjs +169 -0
- package/lh-plugins/lh-case-design.mjs +456 -0
- package/lh-plugins/lh-case-execution.mjs +53 -1
- package/lh-plugins/lh-case-review.mjs +29 -11
- package/lh-plugins/lh-project-docs.mjs +24 -0
- package/lh-plugins/lh-stats.mjs +65 -4
- package/lh-plugins/lh-uiauto.mjs +111 -2
- package/lh-plugins/plugin-prompts.mjs +1 -0
- package/lh-plugins/uiauto-adapters/playwright.mjs +44 -4
- package/lh-plugins/uiauto-adapters/shared.mjs +4 -0
- package/lh-plugins/uiauto-explorer/emit-files.mjs +16 -2
- package/lh-plugins/uiauto-explorer/ir.mjs +3 -0
- package/lh-plugins/uiauto-explorer/merge.mjs +37 -1
- package/lh-plugins/uiauto-explorer/navigation-guard.mjs +255 -0
- package/lh-plugins/uiauto-explorer/runner.mjs +65 -3
- package/lh-plugins/uiauto-explorer/sessions.mjs +29 -1
- package/package.json +1 -1
- package/skills/case-automation-bridge/SKILL.md +27 -0
- package/skills/case-execution/SKILL.md +19 -2
- package/skills/lantern-workflow/SKILL.md +39 -1
- package/dist/_astro/Base.Du_-4L-4.css +0 -1
- package/dist/_astro/CaseExecutionBoard.CjX4CoKd.js +0 -5
- package/dist/_astro/CaseGenerateApp.acgnxl79.js +0 -10
- package/dist/_astro/CasesLibrary.zmzOQwdn.js +0 -21
- package/dist/_astro/ChatApp.Ben9LFra.js +0 -1
- package/dist/_astro/ChatApp.DBi6q7Qv.js +0 -262
- package/dist/_astro/NavLibraries.DVR5Ua-S.js +0 -1
- package/dist/_astro/PmRequirementsBoard.B0W6bsW2.js +0 -1
- package/dist/_astro/SlideOverDrawer.BMg2tce6.js +0 -1
- package/dist/_astro/TemplatesLibrary.peYzrHZ2.js +0 -1
- package/dist/_astro/UiAutoBoard.BGdlp5Sr.js +0 -3
- package/dist/_astro/UiAutoEnvPanel.BUASgPLB.js +0 -10
- package/dist/_astro/UiAutoGenerationDialog.D1PyCgrD.js +0 -12
- package/dist/_astro/UiAutoProjectsPage.B6A9NlVK.js +0 -3
- package/dist/_astro/app-config.Dvfzl5_N.js +0 -1
- package/dist/_astro/app-version.CNpnKIb9.js +0 -1
- package/dist/_astro/case-fields.CmePqYfh.js +0 -148
- package/dist/_astro/case-gen-run.Cvvdv_kv.js +0 -26
- package/dist/_astro/case-prompt.CZ3vWUju.js +0 -2
- package/dist/_astro/plugins.Db9xoFZb.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,n as r,r as i,t as a}from"./dialog.XgRGNF_Q.js";import{i as o}from"./app-config.Dvfzl5_N.js";import{t as s}from"./jsx-runtime.DUg_B_vD.js";import{t as c}from"./ConfirmDialog.DQFd6g2r.js";import{a as l,o as u,r as d}from"./plugins.Db9xoFZb.js";import{n as f,o as p,r as m,s as h}from"./view-prefs.COAKEQtZ.js";import{t as g}from"./SelectDropdown.D7IeyHDI.js";import{E as _}from"./PmShared.BQVzwsiz.js";import{showToast as v}from"./Toast.BydY-X7T.js";import{t as y}from"./DatePicker.BRO_CjVQ.js";import{n as b,r as x,t as S}from"./TableFieldConfig.72AL-8p-.js";import{c as ee,d as C,i as te,l as ne,n as re,o as ie,t as w}from"./ColumnResize.CkE59sGq.js";import{C as T,F as ae,O as oe,a as E,b as D,c as se,f as ce,g as le,h as ue,i as O,j as k,m as A,n as j,o as de,p as fe,r as pe,s as me,t as M,u as he}from"./tasks.DEyD8pmq.js";import{a as N,l as P,n as F,o as I,r as L,s as R,t as z}from"./DrawerField.CLdvmHc6.js";var B=e(t(),1),V=s(),ge=8e3,_e=[{key:`title`,width:280,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],ve=new Set([`title`,`filler`,`action`]),ye=[{key:`status`,label:`任务状态`},{key:`priority`,label:`紧急程度`},{key:`start`,label:`开始日期`},{key:`due`,label:`截止日期`},{key:`cycle`,label:`任务周期`},{key:`todos`,label:`待办数量`},{key:`progress`,label:`完成进度`},{key:`note`,label:`备注`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],be=`tasks.fields`,xe={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`,cancelled:`bg-stone-100 text-stone-400 line-through`},Se={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},H={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},Ce={pool:`bg-stone-400`,in_progress:`bg-[#4176e6]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},we={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},Te=pe.map(e=>({value:e,label:O[e]})),Ee=M.map(e=>({value:e,label:j[e]})),De=`h-8 w-full justify-start rounded-md border border-stone-200 bg-white px-2 text-left text-sm font-normal text-stone-400 hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,Oe=`h-8 w-auto max-w-full justify-start bg-transparent px-0 text-left focus:ring-0`,ke=`未选择`,Ae=[{value:`all`,label:`全部优先级`},...M.map(e=>({value:e,label:j[e]}))],je=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],Me=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],Ne=`tasks.status-tab`,Pe=`tasks.priority-filter`,Fe=`tasks.search`,Ie=Ae.map(e=>e.value);function U(e){return(0,V.jsxs)(`div`,{"data-tone":e.tone,className:`tw-stat-card flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,V.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,V.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function Le(e){let{open:t,task:o,todos:s,onClose:c,onSaved:l}=e,[u,d]=(0,B.useState)({title:``}),[f,p]=(0,B.useState)(``),[m,h]=(0,B.useState)(!1);(0,B.useEffect)(()=>{t&&(p(``),h(!1),d(o?{title:o.title,status:o.status,priority:o.priority,startDate:o.startDate,dueDate:o.dueDate,note:o.note}:{title:``,status:`pool`,priority:``,startDate:k(),dueDate:k()}))},[t,o]);function g(e){d(t=>({...t,...e}))}let b=A({startDate:u.startDate??``,dueDate:u.dueDate??``}),x=o?s.filter(e=>e.taskId===o.id):[],S=x.filter(e=>e.status===`done`).length,ee=x.length?Math.round(S/x.length*100):0;async function C(){let e=(u.title??``).trim();if(!e)p(`请填写任务名称`);else if(u.startDate&&u.dueDate&&u.dueDate<u.startDate)p(`截止日期不能早于开始日期`);else{h(!0),p(``);try{o?await le(o.id,u):await E([{...u,title:e}],{mode:`manual`}),await l(),v(o?`已保存任务`:`已新建任务`,`success`),c()}catch(e){let t=e instanceof Error?e.message:String(e);p(t),v(`保存任务失败:${t}`,`error`)}finally{h(!1)}}}return(0,V.jsxs)(i,{open:t,onClose:c,transition:!0,className:`relative z-100`,children:[(0,V.jsx)(a,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,V.jsx)(`div`,{className:`fixed inset-0 flex justify-end overflow-hidden`,children:(0,V.jsxs)(n,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl duration-[280ms]`,children:[(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,V.jsx)(r,{className:`text-base font-semibold text-stone-900`,children:o?`任务详情`:`新建任务`}),(0,V.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,V.jsx)(F,{icon:(0,V.jsx)(P,{}),label:`任务名称`,children:(0,V.jsx)(`input`,{autoFocus:!0,value:u.title,onChange:e=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),C())},placeholder:`请输入内容`,className:z})}),(0,V.jsx)(F,{icon:(0,V.jsx)(R,{}),label:`任务状态`,children:(0,V.jsx)(L,{ariaLabel:`任务状态`,menuMinWidth:140,options:Te,value:u.status??`pool`,onChange:e=>g({status:e}),label:O[u.status??`pool`],optionDotClassName:e=>Ce[e]})}),(0,V.jsx)(F,{icon:(0,V.jsx)(R,{}),label:`紧急程度`,children:(0,V.jsx)(L,{ariaLabel:`紧急程度`,menuMinWidth:140,options:Ee,value:u.priority??``,onChange:e=>g({priority:e}),label:u.priority?j[u.priority]:ke,optionDotClassName:e=>we[e]})}),(0,V.jsx)(F,{icon:(0,V.jsx)(N,{}),label:`开始日期`,children:(0,V.jsx)(y,{value:u.startDate??``,onChange:e=>g({startDate:e}),className:`${z} tabular-nums`})}),(0,V.jsx)(F,{icon:(0,V.jsx)(N,{}),label:`截止日期`,children:(0,V.jsx)(y,{value:u.dueDate??``,onChange:e=>g({dueDate:e}),className:`${z} tabular-nums`})}),(0,V.jsx)(F,{icon:(0,V.jsx)(I,{}),label:`任务周期`,children:(0,V.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:b===null?`—`:`${b} 天`})}),(0,V.jsx)(F,{icon:(0,V.jsx)(I,{}),label:`待办进度`,children:(0,V.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:x.length?`${S}/${x.length} · ${ee}%`:`还没有关联待办`})}),(0,V.jsx)(F,{icon:(0,V.jsx)(P,{}),label:`备注`,children:(0,V.jsx)(`textarea`,{value:u.note??``,onChange:e=>g({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white placeholder:text-stone-400`})}),o?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(F,{icon:(0,V.jsx)(N,{}),label:`创建日期`,children:(0,V.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_(o.createdAt)})}),(0,V.jsx)(F,{icon:(0,V.jsx)(N,{}),label:`修改日期`,children:(0,V.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_(o.updatedAt)})})]}):null,o&&x.length?(0,V.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,V.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,V.jsx)(`ul`,{className:`space-y-1.5`,children:x.map(e=>{let t=T(e,k());return(0,V.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,V.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${H[t]}`,children:D[t]})]},e.id)})})]}):null,f?(0,V.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:f}):null]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:c,disabled:m,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:m,className:`h-8 rounded-lg bg-[#4176e6] px-4 text-sm font-medium text-white transition-colors hover:bg-[#3566d0] disabled:opacity-40`,children:m?`保存中…`:o?`保存`:`新建`})]})]})})]})}function Re(){let[e,t]=(0,B.useState)(!1),[n,r]=(0,B.useState)(!0),[i,a]=(0,B.useState)(!0),[s,T]=(0,B.useState)(null),[E,D]=(0,B.useState)([]),[k,pe]=(0,B.useState)([]),[M,N]=(0,B.useState)(null),[P,F]=(0,B.useState)(!1),[I,L]=(0,B.useState)(()=>m(Fe)),[R,z]=(0,B.useState)(()=>f(Ne,Me,`all`)),[H,Re]=(0,B.useState)(()=>f(Pe,Ie,`all`)),[ze,W]=(0,B.useState)(null),[G,K]=(0,B.useState)(null);function Be(e){p(Ne,e),z(e)}function Ve(e){h(Fe,e),L(e)}function He(e){p(Pe,e),Re(e)}let q=(0,B.useRef)(!0),J=x(be,ye,ve),Ue=(0,B.useMemo)(()=>b(_e,J.isVisible),[J.isVisible]),Y=ne(`lh:tasks:cols:v1`,Ue),We=C(`tasks`);(0,B.useEffect)(()=>(q.current=!0,()=>{q.current=!1}),[]);let X=(0,B.useCallback)(async()=>{try{let[e,t]=await Promise.all([he(),i?oe().catch(()=>[]):Promise.resolve([])]);if(!q.current)return;D(e),pe(t),N(null)}catch(e){if(!q.current)return;N(e instanceof Error?e.message:String(e))}},[i]);(0,B.useEffect)(()=>{let e=l(e=>{r(!!e.tasks),a(!!e.todos)});return o().then(()=>{r(d(`tasks`)),a(d(`todos`)),t(!0)}),e},[]),(0,B.useEffect)(()=>{e&&n&&(async()=>{let e=await me();q.current&&(e?(await X(),q.current&&T(!0)):T(!1))})()},[e,n,X]),(0,B.useEffect)(()=>{if(s!==!0)return;let e=window.setInterval(()=>void X(),ge),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[s,X]);let Ge=(0,B.useMemo)(()=>ue(k),[k]),Z=(0,B.useMemo)(()=>fe(E),[E]),Ke=(0,B.useMemo)(()=>se(E,{status:R,priority:H,keyword:I}),[E,R,H,I]),Q=(0,B.useMemo)(()=>ce(Ke),[Ke]);async function $(e,t){D(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await le(e,t);if(!q.current)return;D(t=>t.map(t=>t.id===e?n:t)),N(null)}catch(e){N(e instanceof Error?e.message:String(e)),await X()}}async function qe(){let e=G;if(e){K(null),F(!0);try{await de([e.id]),await Promise.all(k.filter(t=>t.taskId===e.id).map(e=>ae(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X(),v(`已删除任务「${e.title}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),v(`删除任务失败:${t}`,`error`)}finally{q.current&&F(!1)}}}return e?n?s===null?(0,V.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,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,V.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):s?(0,V.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,V.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-7`,children:[(0,V.jsx)(U,{label:`全部任务`,value:Z.total}),(0,V.jsx)(U,{label:`任务池`,value:Z.pool}),(0,V.jsx)(U,{label:`进行中`,value:Z.in_progress}),(0,V.jsx)(U,{label:`已完成`,value:Z.done}),(0,V.jsx)(U,{label:`已关闭`,value:Z.closed}),(0,V.jsx)(U,{label:`已取消`,value:Z.cancelled}),(0,V.jsx)(U,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,V.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,V.jsx)(`input`,{value:I,onChange:e=>Ve(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#4176e6]`}),(0,V.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:je.map(e=>(0,V.jsx)(`button`,{type:`button`,onClick:()=>Be(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${R===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,V.jsx)(g,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:Ae,value:H,onChange:e=>He(e)}),(0,V.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,V.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,V.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,V.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,V.jsx)(S,{fields:J.fields,isVisible:J.isVisible,onToggle:J.toggle}),(0,V.jsx)(`button`,{type:`button`,disabled:P,onClick:()=>W({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#3566d0] disabled:opacity-40`,children:`+ 新建任务`})]})]}),M?(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:M}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>N(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,V.jsx)(`div`,{ref:We,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,V.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:Y.tableStyle,children:[(0,V.jsx)(`colgroup`,{children:Ue.map(e=>(0,V.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,V.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsxs)(`th`,{className:ie,children:[`任务描述`,(0,V.jsx)(w,{...Y.resizeProps(`title`)})]}),J.isVisible(`status`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,V.jsx)(w,{...Y.resizeProps(`status`)})]}):null,J.isVisible(`priority`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,V.jsx)(w,{...Y.resizeProps(`priority`)})]}):null,J.isVisible(`start`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,V.jsx)(w,{...Y.resizeProps(`start`)})]}):null,J.isVisible(`due`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,V.jsx)(w,{...Y.resizeProps(`due`)})]}):null,J.isVisible(`cycle`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,V.jsx)(w,{...Y.resizeProps(`cycle`)})]}):null,J.isVisible(`todos`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,V.jsx)(w,{...Y.resizeProps(`todos`)})]}):null,J.isVisible(`progress`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,V.jsx)(w,{...Y.resizeProps(`progress`)})]}):null,J.isVisible(`note`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,V.jsx)(w,{...Y.resizeProps(`note`)})]}):null,J.isVisible(`createdAt`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,V.jsx)(w,{...Y.resizeProps(`createdAt`)})]}):null,J.isVisible(`updatedAt`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,V.jsx)(w,{...Y.resizeProps(`updatedAt`)})]}):null,(0,V.jsx)(`th`,{"aria-hidden":`true`}),(0,V.jsx)(`th`,{className:ee,children:`操作`})]})}),(0,V.jsxs)(`tbody`,{children:[Q.map(e=>{let t=A(e),n=Ge[e.id]??{total:0,done:0,percent:0};return(0,V.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,V.jsx)(`td`,{className:re,children:(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,V.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,V.jsx)(`button`,{type:`button`,onClick:()=>W({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),J.isVisible(`status`)?(0,V.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,V.jsx)(g,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:Te,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#4176e6]/30 ${xe[e.status]}`,renderTrigger:()=>(0,V.jsx)(`span`,{className:`truncate`,children:O[e.status]}),renderOptionPrefix:e=>(0,V.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ce[e.value]}`})})}):null,J.isVisible(`priority`)?(0,V.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,V.jsx)(g,{unstyled:!0,fitContent:!!e.priority,hideChevron:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ee,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:e.priority?Oe:De,renderTrigger:()=>e.priority?(0,V.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${Se[e.priority]}`,children:j[e.priority]}):(0,V.jsx)(`span`,{className:`truncate text-stone-400`,children:ke}),renderOptionPrefix:e=>(0,V.jsx)(`span`,{className:`h-2 w-2 rounded-full ${we[e.value]}`})})}):null,J.isVisible(`start`)?(0,V.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,V.jsx)(y,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}):null,J.isVisible(`due`)?(0,V.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,V.jsx)(y,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}):null,J.isVisible(`cycle`)?(0,V.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}):null,J.isVisible(`todos`)?(0,V.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:i?n.total?`${n.total} 条`:`0`:(0,V.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}):null,J.isVisible(`progress`)?(0,V.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:i?(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,V.jsx)(`span`,{className:`block h-full rounded-full bg-[#4176e6] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,V.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,V.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}):null,J.isVisible(`note`)?(0,V.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}):null,J.isVisible(`createdAt`)?(0,V.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:_(e.createdAt)}):null,J.isVisible(`updatedAt`)?(0,V.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:_(e.updatedAt)}):null,(0,V.jsx)(`td`,{"aria-hidden":`true`}),(0,V.jsx)(`td`,{className:te,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:()=>W({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,V.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,V.jsx)(`path`,{d:`M14 4h6v6`}),(0,V.jsx)(`path`,{d:`M20 4 13 11`}),(0,V.jsx)(`path`,{d:`M10 20H4v-6`}),(0,V.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,V.jsx)(`button`,{type:`button`,disabled:P,onClick:()=>K(e),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,V.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,V.jsx)(`path`,{d:`M3 6h18`}),(0,V.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,V.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,V.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,V.jsx)(`tr`,{children:(0,V.jsx)(`td`,{colSpan:11,className:`px-3 py-16 text-center text-sm text-stone-400`,children:E.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,V.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,V.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,V.jsx)(Le,{open:ze!==null,task:ze?.task??null,todos:k,onClose:()=>W(null),onSaved:X}),(0,V.jsx)(c,{open:G!=null,title:`删除任务`,message:`删除「${G?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>K(null),onConfirm:()=>void qe()})]}):(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:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(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:u(`tasks`)}):(0,V.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,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,V.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{Re as default};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,n as r,r as i,t as a}from"./dialog.XgRGNF_Q.js";import{i as o}from"./app-config.BSO5r82v.js";import{t as s}from"./jsx-runtime.DUg_B_vD.js";import{t as c}from"./ConfirmDialog.DQFd6g2r.js";import{a as l,o as u,r as d}from"./plugins.ChGmBEkF.js";import{n as f,o as p,r as m,s as h}from"./view-prefs.CWc5cQ2q.js";import{t as g}from"./SelectDropdown.D7IeyHDI.js";import{E as _}from"./PmShared.TOjBbtV8.js";import{showToast as v}from"./Toast.BydY-X7T.js";import{t as y}from"./DatePicker.BRO_CjVQ.js";import{n as b,r as x,t as S}from"./TableFieldConfig.DHj25OKN.js";import{c as ee,d as C,i as te,l as ne,n as re,o as ie,t as w}from"./ColumnResize.CkE59sGq.js";import{C as T,F as ae,O as oe,a as E,b as D,c as se,f as ce,g as le,h as ue,i as O,j as k,m as A,n as j,o as de,p as fe,r as pe,s as me,t as M,u as he}from"./tasks.DEyD8pmq.js";import{a as N,l as P,n as F,o as I,r as L,s as R,t as z}from"./DrawerField.CLdvmHc6.js";var B=e(t(),1),V=s(),ge=8e3,_e=[{key:`title`,width:280,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],ve=new Set([`title`,`filler`,`action`]),ye=[{key:`status`,label:`任务状态`},{key:`priority`,label:`紧急程度`},{key:`start`,label:`开始日期`},{key:`due`,label:`截止日期`},{key:`cycle`,label:`任务周期`},{key:`todos`,label:`待办数量`},{key:`progress`,label:`完成进度`},{key:`note`,label:`备注`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],be=`tasks.fields`,xe={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`,cancelled:`bg-stone-100 text-stone-400 line-through`},Se={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},H={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},Ce={pool:`bg-stone-400`,in_progress:`bg-[#4176e6]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},we={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},Te=pe.map(e=>({value:e,label:O[e]})),Ee=M.map(e=>({value:e,label:j[e]})),De=`h-8 w-full justify-start rounded-md border border-stone-200 bg-white px-2 text-left text-sm font-normal text-stone-400 hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,Oe=`h-8 w-auto max-w-full justify-start bg-transparent px-0 text-left focus:ring-0`,ke=`未选择`,Ae=[{value:`all`,label:`全部优先级`},...M.map(e=>({value:e,label:j[e]}))],je=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],Me=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],Ne=`tasks.status-tab`,Pe=`tasks.priority-filter`,Fe=`tasks.search`,Ie=Ae.map(e=>e.value);function U(e){return(0,V.jsxs)(`div`,{"data-tone":e.tone,className:`tw-stat-card flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,V.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,V.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function Le(e){let{open:t,task:o,todos:s,onClose:c,onSaved:l}=e,[u,d]=(0,B.useState)({title:``}),[f,p]=(0,B.useState)(``),[m,h]=(0,B.useState)(!1);(0,B.useEffect)(()=>{t&&(p(``),h(!1),d(o?{title:o.title,status:o.status,priority:o.priority,startDate:o.startDate,dueDate:o.dueDate,note:o.note}:{title:``,status:`pool`,priority:``,startDate:k(),dueDate:k()}))},[t,o]);function g(e){d(t=>({...t,...e}))}let b=A({startDate:u.startDate??``,dueDate:u.dueDate??``}),x=o?s.filter(e=>e.taskId===o.id):[],S=x.filter(e=>e.status===`done`).length,ee=x.length?Math.round(S/x.length*100):0;async function C(){let e=(u.title??``).trim();if(!e)p(`请填写任务名称`);else if(u.startDate&&u.dueDate&&u.dueDate<u.startDate)p(`截止日期不能早于开始日期`);else{h(!0),p(``);try{o?await le(o.id,u):await E([{...u,title:e}],{mode:`manual`}),await l(),v(o?`已保存任务`:`已新建任务`,`success`),c()}catch(e){let t=e instanceof Error?e.message:String(e);p(t),v(`保存任务失败:${t}`,`error`)}finally{h(!1)}}}return(0,V.jsxs)(i,{open:t,onClose:c,transition:!0,className:`relative z-100`,children:[(0,V.jsx)(a,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,V.jsx)(`div`,{className:`fixed inset-0 flex justify-end overflow-hidden`,children:(0,V.jsxs)(n,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl duration-[280ms]`,children:[(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,V.jsx)(r,{className:`text-base font-semibold text-stone-900`,children:o?`任务详情`:`新建任务`}),(0,V.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,V.jsx)(F,{icon:(0,V.jsx)(P,{}),label:`任务名称`,children:(0,V.jsx)(`input`,{autoFocus:!0,value:u.title,onChange:e=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),C())},placeholder:`请输入内容`,className:z})}),(0,V.jsx)(F,{icon:(0,V.jsx)(R,{}),label:`任务状态`,children:(0,V.jsx)(L,{ariaLabel:`任务状态`,menuMinWidth:140,options:Te,value:u.status??`pool`,onChange:e=>g({status:e}),label:O[u.status??`pool`],optionDotClassName:e=>Ce[e]})}),(0,V.jsx)(F,{icon:(0,V.jsx)(R,{}),label:`紧急程度`,children:(0,V.jsx)(L,{ariaLabel:`紧急程度`,menuMinWidth:140,options:Ee,value:u.priority??``,onChange:e=>g({priority:e}),label:u.priority?j[u.priority]:ke,optionDotClassName:e=>we[e]})}),(0,V.jsx)(F,{icon:(0,V.jsx)(N,{}),label:`开始日期`,children:(0,V.jsx)(y,{value:u.startDate??``,onChange:e=>g({startDate:e}),className:`${z} tabular-nums`})}),(0,V.jsx)(F,{icon:(0,V.jsx)(N,{}),label:`截止日期`,children:(0,V.jsx)(y,{value:u.dueDate??``,onChange:e=>g({dueDate:e}),className:`${z} tabular-nums`})}),(0,V.jsx)(F,{icon:(0,V.jsx)(I,{}),label:`任务周期`,children:(0,V.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:b===null?`—`:`${b} 天`})}),(0,V.jsx)(F,{icon:(0,V.jsx)(I,{}),label:`待办进度`,children:(0,V.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:x.length?`${S}/${x.length} · ${ee}%`:`还没有关联待办`})}),(0,V.jsx)(F,{icon:(0,V.jsx)(P,{}),label:`备注`,children:(0,V.jsx)(`textarea`,{value:u.note??``,onChange:e=>g({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white placeholder:text-stone-400`})}),o?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(F,{icon:(0,V.jsx)(N,{}),label:`创建日期`,children:(0,V.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_(o.createdAt)})}),(0,V.jsx)(F,{icon:(0,V.jsx)(N,{}),label:`修改日期`,children:(0,V.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_(o.updatedAt)})})]}):null,o&&x.length?(0,V.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,V.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,V.jsx)(`ul`,{className:`space-y-1.5`,children:x.map(e=>{let t=T(e,k());return(0,V.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,V.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${H[t]}`,children:D[t]})]},e.id)})})]}):null,f?(0,V.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:f}):null]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:c,disabled:m,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:m,className:`h-8 rounded-lg bg-[#4176e6] px-4 text-sm font-medium text-white transition-colors hover:bg-[#3566d0] disabled:opacity-40`,children:m?`保存中…`:o?`保存`:`新建`})]})]})})]})}function Re(){let[e,t]=(0,B.useState)(!1),[n,r]=(0,B.useState)(!0),[i,a]=(0,B.useState)(!0),[s,T]=(0,B.useState)(null),[E,D]=(0,B.useState)([]),[k,pe]=(0,B.useState)([]),[M,N]=(0,B.useState)(null),[P,F]=(0,B.useState)(!1),[I,L]=(0,B.useState)(()=>m(Fe)),[R,z]=(0,B.useState)(()=>f(Ne,Me,`all`)),[H,Re]=(0,B.useState)(()=>f(Pe,Ie,`all`)),[ze,W]=(0,B.useState)(null),[G,K]=(0,B.useState)(null);function Be(e){p(Ne,e),z(e)}function Ve(e){h(Fe,e),L(e)}function He(e){p(Pe,e),Re(e)}let q=(0,B.useRef)(!0),J=x(be,ye,ve),Ue=(0,B.useMemo)(()=>b(_e,J.isVisible),[J.isVisible]),Y=ne(`lh:tasks:cols:v1`,Ue),We=C(`tasks`);(0,B.useEffect)(()=>(q.current=!0,()=>{q.current=!1}),[]);let X=(0,B.useCallback)(async()=>{try{let[e,t]=await Promise.all([he(),i?oe().catch(()=>[]):Promise.resolve([])]);if(!q.current)return;D(e),pe(t),N(null)}catch(e){if(!q.current)return;N(e instanceof Error?e.message:String(e))}},[i]);(0,B.useEffect)(()=>{let e=l(e=>{r(!!e.tasks),a(!!e.todos)});return o().then(()=>{r(d(`tasks`)),a(d(`todos`)),t(!0)}),e},[]),(0,B.useEffect)(()=>{e&&n&&(async()=>{let e=await me();q.current&&(e?(await X(),q.current&&T(!0)):T(!1))})()},[e,n,X]),(0,B.useEffect)(()=>{if(s!==!0)return;let e=window.setInterval(()=>void X(),ge),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[s,X]);let Ge=(0,B.useMemo)(()=>ue(k),[k]),Z=(0,B.useMemo)(()=>fe(E),[E]),Ke=(0,B.useMemo)(()=>se(E,{status:R,priority:H,keyword:I}),[E,R,H,I]),Q=(0,B.useMemo)(()=>ce(Ke),[Ke]);async function $(e,t){D(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await le(e,t);if(!q.current)return;D(t=>t.map(t=>t.id===e?n:t)),N(null)}catch(e){N(e instanceof Error?e.message:String(e)),await X()}}async function qe(){let e=G;if(e){K(null),F(!0);try{await de([e.id]),await Promise.all(k.filter(t=>t.taskId===e.id).map(e=>ae(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X(),v(`已删除任务「${e.title}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),v(`删除任务失败:${t}`,`error`)}finally{q.current&&F(!1)}}}return e?n?s===null?(0,V.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,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,V.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):s?(0,V.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,V.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-7`,children:[(0,V.jsx)(U,{label:`全部任务`,value:Z.total}),(0,V.jsx)(U,{label:`任务池`,value:Z.pool}),(0,V.jsx)(U,{label:`进行中`,value:Z.in_progress}),(0,V.jsx)(U,{label:`已完成`,value:Z.done}),(0,V.jsx)(U,{label:`已关闭`,value:Z.closed}),(0,V.jsx)(U,{label:`已取消`,value:Z.cancelled}),(0,V.jsx)(U,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,V.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,V.jsx)(`input`,{value:I,onChange:e=>Ve(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#4176e6]`}),(0,V.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:je.map(e=>(0,V.jsx)(`button`,{type:`button`,onClick:()=>Be(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${R===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,V.jsx)(g,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:Ae,value:H,onChange:e=>He(e)}),(0,V.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,V.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,V.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,V.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,V.jsx)(S,{fields:J.fields,isVisible:J.isVisible,onToggle:J.toggle}),(0,V.jsx)(`button`,{type:`button`,disabled:P,onClick:()=>W({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#3566d0] disabled:opacity-40`,children:`+ 新建任务`})]})]}),M?(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:M}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>N(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,V.jsx)(`div`,{ref:We,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,V.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:Y.tableStyle,children:[(0,V.jsx)(`colgroup`,{children:Ue.map(e=>(0,V.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,V.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsxs)(`th`,{className:ie,children:[`任务描述`,(0,V.jsx)(w,{...Y.resizeProps(`title`)})]}),J.isVisible(`status`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,V.jsx)(w,{...Y.resizeProps(`status`)})]}):null,J.isVisible(`priority`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,V.jsx)(w,{...Y.resizeProps(`priority`)})]}):null,J.isVisible(`start`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,V.jsx)(w,{...Y.resizeProps(`start`)})]}):null,J.isVisible(`due`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,V.jsx)(w,{...Y.resizeProps(`due`)})]}):null,J.isVisible(`cycle`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,V.jsx)(w,{...Y.resizeProps(`cycle`)})]}):null,J.isVisible(`todos`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,V.jsx)(w,{...Y.resizeProps(`todos`)})]}):null,J.isVisible(`progress`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,V.jsx)(w,{...Y.resizeProps(`progress`)})]}):null,J.isVisible(`note`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,V.jsx)(w,{...Y.resizeProps(`note`)})]}):null,J.isVisible(`createdAt`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,V.jsx)(w,{...Y.resizeProps(`createdAt`)})]}):null,J.isVisible(`updatedAt`)?(0,V.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,V.jsx)(w,{...Y.resizeProps(`updatedAt`)})]}):null,(0,V.jsx)(`th`,{"aria-hidden":`true`}),(0,V.jsx)(`th`,{className:ee,children:`操作`})]})}),(0,V.jsxs)(`tbody`,{children:[Q.map(e=>{let t=A(e),n=Ge[e.id]??{total:0,done:0,percent:0};return(0,V.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,V.jsx)(`td`,{className:re,children:(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,V.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,V.jsx)(`button`,{type:`button`,onClick:()=>W({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),J.isVisible(`status`)?(0,V.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,V.jsx)(g,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:Te,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#4176e6]/30 ${xe[e.status]}`,renderTrigger:()=>(0,V.jsx)(`span`,{className:`truncate`,children:O[e.status]}),renderOptionPrefix:e=>(0,V.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ce[e.value]}`})})}):null,J.isVisible(`priority`)?(0,V.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,V.jsx)(g,{unstyled:!0,fitContent:!!e.priority,hideChevron:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ee,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:e.priority?Oe:De,renderTrigger:()=>e.priority?(0,V.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${Se[e.priority]}`,children:j[e.priority]}):(0,V.jsx)(`span`,{className:`truncate text-stone-400`,children:ke}),renderOptionPrefix:e=>(0,V.jsx)(`span`,{className:`h-2 w-2 rounded-full ${we[e.value]}`})})}):null,J.isVisible(`start`)?(0,V.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,V.jsx)(y,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}):null,J.isVisible(`due`)?(0,V.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,V.jsx)(y,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}):null,J.isVisible(`cycle`)?(0,V.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}):null,J.isVisible(`todos`)?(0,V.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:i?n.total?`${n.total} 条`:`0`:(0,V.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}):null,J.isVisible(`progress`)?(0,V.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:i?(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,V.jsx)(`span`,{className:`block h-full rounded-full bg-[#4176e6] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,V.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,V.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}):null,J.isVisible(`note`)?(0,V.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}):null,J.isVisible(`createdAt`)?(0,V.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:_(e.createdAt)}):null,J.isVisible(`updatedAt`)?(0,V.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:_(e.updatedAt)}):null,(0,V.jsx)(`td`,{"aria-hidden":`true`}),(0,V.jsx)(`td`,{className:te,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:()=>W({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,V.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,V.jsx)(`path`,{d:`M14 4h6v6`}),(0,V.jsx)(`path`,{d:`M20 4 13 11`}),(0,V.jsx)(`path`,{d:`M10 20H4v-6`}),(0,V.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,V.jsx)(`button`,{type:`button`,disabled:P,onClick:()=>K(e),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,V.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,V.jsx)(`path`,{d:`M3 6h18`}),(0,V.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,V.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,V.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,V.jsx)(`tr`,{children:(0,V.jsx)(`td`,{colSpan:11,className:`px-3 py-16 text-center text-sm text-stone-400`,children:E.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,V.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,V.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,V.jsx)(Le,{open:ze!==null,task:ze?.task??null,todos:k,onClose:()=>W(null),onSaved:X}),(0,V.jsx)(c,{open:G!=null,title:`删除任务`,message:`删除「${G?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>K(null),onConfirm:()=>void qe()})]}):(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:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(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:u(`tasks`)}):(0,V.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,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,V.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{Re as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.BSO5r82v.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.DQFd6g2r.js";import{a,o,r as s}from"./plugins.ChGmBEkF.js";import{showToast as c}from"./Toast.BydY-X7T.js";import{n as ee,t as te}from"./DocsPager.Dg765uHW.js";import{_ as ne,a as re,c as l,d as ie,f as ae,g as oe,h as u,i as se,l as ce,m as d,n as le,p as f,r as ue,s as de,t as fe}from"./project-docs.BRgNjXhG.js";import{i as p,n as m,r as h}from"./case-template.CC2eXegU.js";import{n as pe}from"./doc-roots.C-20VD0x.js";import{t as me}from"./ExcelFieldTags.CXif3Ilh.js";import{t as g}from"./NamePromptDialog.KPCeXmri.js";import{t as he}from"./useListAnim.BoerpmsB.js";var _=e(t(),1),v=r(),ge=5;async function _e(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await f(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64)return p(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await d(`templates`,e.path);return m(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await d(`templates`,e.path);return h(t.content).headers}}catch{}return[]}function y({className:e=`w-4 h-4`,open:t=!1}){return(0,v.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,v.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,v.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 b({className:e=`w-3 h-3`}){return(0,v.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,v.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,v.jsx)(`path`,{d:`m15 5 4 4`})]})}function x({className:e=`w-3 h-3`}){return(0,v.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,v.jsx)(`path`,{d:`M3 6h18`}),(0,v.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,v.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,v.jsx)(`path`,{d:`M10 11v6`}),(0,v.jsx)(`path`,{d:`M14 11v6`})]})}function S({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,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,v.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,v.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,v.jsx)(y,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,v.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,v.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,v.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,v.jsx)(S,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function ve(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function C(){let[e,t]=(0,_.useState)(()=>s(`templates`)),[r,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)([]),[C,ye]=(0,_.useState)(0),[w,T]=(0,_.useState)(`.`),[E,D]=(0,_.useState)([]),[be,xe]=(0,_.useState)({}),[Se,O]=(0,_.useState)({}),[k,Ce]=(0,_.useState)(!0),[A,j]=(0,_.useState)(null),[M,N]=(0,_.useState)(!1),[we,P]=(0,_.useState)(!1),[F,I]=(0,_.useState)(null),[L,R]=(0,_.useState)(null),[Te,z]=(0,_.useState)(1),[B,Ee]=ee(ge),[De,V]=(0,_.useState)(null),H=(0,_.useRef)(null),{cls:Oe,play:U}=he(),W=(0,_.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await _e(e);n.length&&(t[e.path]=n)})),xe(t)},[]),G=(0,_.useCallback)(async()=>{let e=await se(`templates`);h(e.tree),ye(e.totalFiles)},[]),K=(0,_.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([l(`templates`,e),G()]);D(t.entries),T(t.path);let n=t.entries.filter(e=>e.type===`file`);await W(n)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,W,G]);(0,_.useEffect)(()=>{let e=a(e=>t(!!e.templates));return n().then(()=>{t(s(`templates`)),d(!0)}),e},[]),(0,_.useEffect)(()=>{r&&e&&(async()=>{if(!await ue(`templates`))p(!1);else try{let[e]=await Promise.all([l(`templates`,`.`),G()]);D(e.entries),T(e.path),await W(e.entries.filter(e=>e.type===`file`)),p(!0)}catch(e){j(e instanceof Error?e.message:String(e)),p(!0)}})()},[r,e,W,G]);function ke(){Ce(e=>!e),O({})}async function q(e){U(),T(e),z(1),V(null),j(null);try{let t=await l(`templates`,e);D(t.entries),await W(t.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}}async function Ae(e){P(!1),N(!0),j(null);try{await ce(`templates`,w,e),await K(w),c(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),c(`新建文件夹失败:${t}`,`error`)}finally{N(!1)}}async function je(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await ne(`templates`,w,t);await K(w),c(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),c(`上传失败:${t}`,`error`)}finally{N(!1),H.current&&(H.current.value=``)}}}async function Me(e){if(e.type===`file`){N(!0),j(null);try{await ie(`templates`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}function Ne(e){let t=re(m,e.path),n=t?.fileCount??0,r=t?fe(t):0;I({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function J(e){I({name:e.name,path:e.path,isDir:!1})}function Y(e,t){R({...e,isDir:t})}async function Pe(){let e=F;if(e&&(I(null),!e.blocked)){N(!0),j(null);try{await le(`templates`,e.path);let t=de(w,e.path)?ae(e.path):w;await K(t),c(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),c(`删除失败:${t}`,`error`)}finally{N(!1)}}}async function Fe(e){let t=L;if(t&&(R(null),e!==t.name)){N(!0),j(null);try{let n=await oe(`templates`,t.path,e);await K(u(w,t.path,n)),c(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),c(`重命名失败:${t}`,`error`)}finally{N(!1)}}}let Ie=(()=>{if(!F)return``;if(!F.isDir)return`删除文件「${F.name}」?将移入系统废纸篓,可随时找回。`;if(F.blocked){let e=[];return F.files&&e.push(`${F.files} 个文件`),F.dirs&&e.push(`${F.dirs} 个子文件夹`),`文件夹「${F.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${F.name}」?将移入系统废纸篓。`})();if(!r)return(0,v.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!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:o(`templates`)});if(f===null)return(0,v.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!f)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:`模板库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/B)),$=Math.min(Te,Q),Le=X.slice(($-1)*B,$*B);function Re(e){U(),Ee(e),z(1)}return(0,v.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,v.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,v.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>P(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,v.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{q(`.`),ke()},"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,v.jsx)(y,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部模板`}),(0,v.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,C,`)`]})]})}),(0,v.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,v.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:m.map(e=>(0,v.jsx)(S,{node:e,depth:0,activePath:w,expanded:Se,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void q(e)},e.path))})})]})]}),(0,v.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,v.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,v.jsx)(`span`,{className:`text-stone-400`,children:pe(`templates`)}),w===`.`?``:w]}),(0,v.jsx)(`input`,{ref:H,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>void je(e.target.files)}),(0,v.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>H.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,v.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,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,v.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,v.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,v.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void q(e.path),children:[(0,v.jsx)(y,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,v.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,v.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,v.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Ne({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,v.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,v.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加模板(.md / .xlsx / .docx 等)`}):(0,v.jsx)(`ul`,{className:`${Oe}space-y-1`,children:Le.map(e=>{let t=be[e.path]??[],n=De===e.path;return(0,v.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 rounded-lg border transition-colors ${n?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,v.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:M,onClick:()=>V(e.path),onDoubleClick:()=>void Me(e),children:[(0,v.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,v.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:ve(e.size)}),t.length>0?(0,v.jsx)(me,{fields:t}):null]}),(0,v.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 shrink-0 mt-0.5`,children:(0,v.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,v.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>J(e),className:`tw-icon-danger p-1.5 rounded shrink-0 mt-0.5`,children:(0,v.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),X.length>0?(0,v.jsx)(te,{page:$,totalPages:Q,pageSize:B,busy:M,onPage:e=>{U(),z(e)},onPageSize:Re}):null]}),(0,v.jsx)(g,{open:we,title:`新建文件夹`,onClose:()=>P(!1),onConfirm:e=>void Ae(e)}),(0,v.jsx)(g,{open:L!=null,title:L?.isDir?`重命名文件夹`:`重命名文件`,label:L?.isDir?`文件夹名称`:`文件名称`,initialValue:L?.name??``,lockExtension:L!=null&&!L.isDir,confirmLabel:`保存`,onClose:()=>R(null),onConfirm:e=>void Fe(e)}),(0,v.jsx)(i,{open:F!=null,title:F?.blocked?`无法删除文件夹`:F?.isDir?`删除文件夹`:`删除模板`,message:Ie,confirmLabel:F?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!F?.blocked,hideCancel:!!F?.blocked,onClose:()=>I(null),onConfirm:()=>void Pe()})]})}export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Dvfzl5_N.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.DQFd6g2r.js";import{a,o,r as s}from"./plugins.Db9xoFZb.js";import{showToast as c}from"./Toast.BydY-X7T.js";import{n as ee,t as te}from"./DocsPager.DMN9-Tjg.js";import{t as ne}from"./open-docs-in-session.BpcAcBSI.js";import{a as re,c as l,d as ie,f as u,g as ae,h as oe,i as se,l as d,m as ce,n as le,p as f,r as ue,s as de,t as fe,u as pe}from"./project-docs.bB9lQ1Ki.js";import{i as p,n as m,r as h}from"./case-template.Clb7HrDB.js";import{n as me}from"./doc-roots.C-20VD0x.js";import{t as he}from"./ExcelFieldTags.CXif3Ilh.js";import{t as g}from"./NamePromptDialog.KPCeXmri.js";import{t as ge}from"./useListAnim.BoerpmsB.js";import{i as _,n as _e,r as ve,t as ye}from"./test-reports.0gr6-c_0.js";var v=e(t(),1),y=r(),be=5;async function xe(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await u(`testReports`,e.path);if(t.encoding===`base64`&&t.contentBase64)return p(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await f(`testReports`,e.path);return m(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await f(`testReports`,e.path);return h(t.content).headers}}catch{}return[]}function b({className:e=`w-4 h-4`,open:t=!1}){return(0,y.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,y.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,y.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 x({className:e=`w-3 h-3`}){return(0,y.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,y.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,y.jsx)(`path`,{d:`m15 5 4 4`})]})}function S({className:e=`w-3 h-3`}){return(0,y.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,y.jsx)(`path`,{d:`M3 6h18`}),(0,y.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,y.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,y.jsx)(`path`,{d:`M10 11v6`}),(0,y.jsx)(`path`,{d:`M14 11v6`})]})}function C({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,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,y.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,y.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,y.jsx)(b,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,y.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,y.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,y.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,y.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,y.jsx)(C,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function Se(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function w(){let[e,t]=(0,v.useState)(()=>s(`testReports`)),[r,u]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)([]),[w,Ce]=(0,v.useState)(0),[T,E]=(0,v.useState)(`.`),[D,O]=(0,v.useState)([]),[we,Te]=(0,v.useState)({}),[Ee,k]=(0,v.useState)({}),[A,j]=(0,v.useState)(!0),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)(!1),[De,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(null),[z,B]=(0,v.useState)(null),[Oe,V]=(0,v.useState)(1),[H,ke]=ee(be),[Ae,U]=(0,v.useState)(null),W=(0,v.useRef)(null),{cls:je,play:G}=ge(),Me=(0,v.useMemo)(()=>T===`.`||!T.trim()?null:_(T),[T]),K=(0,v.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await xe(e);n.length&&(t[e.path]=n)})),Te(t)},[]),q=(0,v.useCallback)(async()=>{let e=await se(`testReports`);h(e.tree),Ce(e.totalFiles)},[]),J=(0,v.useCallback)(async(e=T)=>{N(null);try{let[t]=await Promise.all([l(`testReports`,e),q()]);O(t.entries),E(t.path);let n=t.entries.filter(e=>e.type===`file`);await K(n)}catch(e){N(e instanceof Error?e.message:String(e))}},[T,K,q]);(0,v.useEffect)(()=>{let e=a(e=>t(!!e.testReports));return n().then(()=>{t(s(`testReports`)),u(!0)}),e},[]);let Ne=(0,v.useCallback)(async()=>{for(let e of ye)try{await d(`testReports`,`.`,e.folder)}catch{}await _e()},[]);(0,v.useEffect)(()=>{r&&e&&(async()=>{if(!await ue(`testReports`))p(!1);else try{await Ne();let[e]=await Promise.all([l(`testReports`,`.`),q()]);O(e.entries),E(e.path),await K(e.entries.filter(e=>e.type===`file`)),p(!0)}catch(e){N(e instanceof Error?e.message:String(e)),p(!0)}})()},[r,e,Ne,K,q]);function Pe(){j(e=>!e),k({})}async function Y(e){G(),E(e),V(1),U(null),N(null);try{let t=await l(`testReports`,e);O(t.entries),await K(t.entries.filter(e=>e.type===`file`))}catch(e){N(e instanceof Error?e.message:String(e))}}async function Fe(e){I(!1),F(!0),N(null);try{await d(`testReports`,T,e),await J(T),c(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),c(`新建文件夹失败:${t}`,`error`)}finally{F(!1)}}async function Ie(e){if(e?.length){F(!0),N(null);try{for(let t of Array.from(e))await ae(`testReports`,T,t);await J(T),c(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),c(`上传失败:${t}`,`error`)}finally{F(!1),W.current&&(W.current.value=``)}}}async function Le(e){let t=_(e.path)??Me,n=t?ve(t).defaultPrompt:``;F(!0),N(null);try{await ne(`testReports`,e,{attachPrompt:n||void 0})}catch(e){N(e instanceof Error?e.message:String(e)),F(!1)}}async function Re(e){if(e.type===`file`){F(!0),N(null);try{await pe(`testReports`,e.path)}catch(e){N(e instanceof Error?e.message:String(e))}finally{F(!1)}}}function ze(e){let t=re(m,e.path),n=t?.fileCount??0,r=t?fe(t):0;R({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Be(e){R({name:e.name,path:e.path,isDir:!1})}function X(e,t){B({...e,isDir:t})}async function Ve(){let e=L;if(e&&(R(null),!e.blocked)){F(!0),N(null);try{await le(`testReports`,e.path);let t=de(T,e.path)?ie(e.path):T;await J(t),c(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),c(`删除失败:${t}`,`error`)}finally{F(!1)}}}async function He(e){let t=z;if(t&&(B(null),e!==t.name)){F(!0),N(null);try{let n=await oe(`testReports`,t.path,e);await J(ce(T,t.path,n)),c(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),c(`重命名失败:${t}`,`error`)}finally{F(!1)}}}let Ue=(()=>{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}」?将移入系统废纸篓。`})();if(!r)return(0,y.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(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:o(`testReports`)});if(f===null)return(0,y.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!f)return(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:`报告管理需要本地文档服务,当前未就绪。`});let Z=D.filter(e=>e.type===`file`),We=D.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(Z.length/H)),$=Math.min(Oe,Q),Ge=Z.slice(($-1)*H,$*H);function Ke(e){G(),ke(e),V(1)}return(0,y.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,y.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,y.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,y.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,y.jsx)(`button`,{type:`button`,disabled:P,onClick:()=>I(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,y.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,y.jsx)(`div`,{className:`group flex items-center rounded-md ${T===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,y.jsxs)(`button`,{type:`button`,onClick:()=>{Y(`.`),T===`.`?Pe():(j(!0),k({}))},"aria-expanded":A,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${T===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,y.jsx)(b,{open:A,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,y.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部报告`}),(0,y.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,w,`)`]})]})}),(0,y.jsx)(`div`,{className:`tw-collapse ${A?`is-open`:``}`,children:(0,y.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:m.map(e=>(0,y.jsx)(C,{node:e,depth:0,activePath:T,expanded:Ee,globalOpen:A,onToggle:e=>k(t=>({...t,[e]:!(t[e]??A)})),onSelect:e=>void Y(e)},e.path))})})]})]}),(0,y.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,y.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,y.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,y.jsx)(`span`,{className:`text-stone-400`,children:me(`testReports`)}),T===`.`?``:T]}),(0,y.jsx)(`input`,{ref:W,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>void Ie(e.target.files)}),(0,y.jsx)(`button`,{type:`button`,disabled:P,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:`上传文件`})]}),M?(0,y.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:M}):null,(0,y.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[We.length>0&&(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,y.jsx)(`ul`,{className:`space-y-1`,children:We.map(e=>(0,y.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void Y(e.path),children:[(0,y.jsx)(b,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,y.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,y.jsx)(`button`,{type:`button`,disabled:P,"aria-label":`重命名 ${e.name}`,onClick:()=>X({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,y.jsx)(x,{className:`w-3.5 h-3.5`})}),(0,y.jsx)(`button`,{type:`button`,disabled:P,"aria-label":`删除 ${e.name}`,onClick:()=>ze({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,y.jsx)(S,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),Z.length===0?(0,y.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加报告(.md / .xlsx / .docx 等)`}):(0,y.jsx)(`ul`,{className:`${je}space-y-1`,children:Ge.map(e=>{let t=we[e.path]??[],n=Ae===e.path;return(0,y.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 rounded-lg border transition-colors ${n?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:P,onClick:()=>U(e.path),onDoubleClick:()=>void Re(e),children:[(0,y.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,y.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:Se(e.size)}),t.length>0?(0,y.jsx)(he,{fields:t}):null]}),(0,y.jsx)(`button`,{type:`button`,disabled:P,onClick:()=>void Le(e),className:`mt-0.5 shrink-0 cursor-pointer whitespace-nowrap rounded bg-[#4176e6] px-2 py-1 text-xs text-white hover:bg-[#3565c7] disabled:opacity-40`,children:`在会话中打开`}),(0,y.jsx)(`button`,{type:`button`,disabled:P,"aria-label":`重命名 ${e.name}`,onClick:()=>X({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40 shrink-0 mt-0.5`,children:(0,y.jsx)(x,{className:`w-3.5 h-3.5`})}),(0,y.jsx)(`button`,{type:`button`,disabled:P,"aria-label":`删除 ${e.name}`,onClick:()=>Be(e),className:`tw-icon-danger p-1.5 rounded shrink-0 mt-0.5`,children:(0,y.jsx)(S,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),Z.length>0?(0,y.jsx)(te,{page:$,totalPages:Q,pageSize:H,busy:P,onPage:e=>{G(),V(e)},onPageSize:Ke}):null]}),(0,y.jsx)(g,{open:De,title:`新建文件夹`,onClose:()=>I(!1),onConfirm:e=>void Fe(e)}),(0,y.jsx)(g,{open:z!=null,title:z?.isDir?`重命名文件夹`:`重命名文件`,label:z?.isDir?`文件夹名称`:`文件名称`,initialValue:z?.name??``,lockExtension:z!=null&&!z.isDir,confirmLabel:`保存`,onClose:()=>B(null),onConfirm:e=>void He(e)}),(0,y.jsx)(i,{open:L!=null,title:L?.blocked?`无法删除文件夹`:L?.isDir?`删除文件夹`:`删除报告`,message:Ue,confirmLabel:L?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!L?.blocked,hideCancel:!!L?.blocked,onClose:()=>R(null),onConfirm:()=>void Ve()})]})}export{w as default};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.BSO5r82v.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.DQFd6g2r.js";import{a,o,r as s}from"./plugins.ChGmBEkF.js";import{showToast as c}from"./Toast.BydY-X7T.js";import{n as ee,t as te}from"./DocsPager.Dg765uHW.js";import{t as ne}from"./open-docs-in-session.BoyV6R2A.js";import{_ as re,a as ie,c as l,d as ae,f as oe,g as se,h as ce,i as le,l as u,m as d,n as ue,p as f,r as de,s as fe,t as pe}from"./project-docs.BRgNjXhG.js";import{i as p,n as m,r as h}from"./case-template.CC2eXegU.js";import{n as me}from"./doc-roots.C-20VD0x.js";import{t as he}from"./ExcelFieldTags.CXif3Ilh.js";import{t as g}from"./NamePromptDialog.KPCeXmri.js";import{t as ge}from"./useListAnim.BoerpmsB.js";import{i as _,n as _e,r as ve,t as ye}from"./test-reports.0gr6-c_0.js";var v=e(t(),1),y=r(),be=5;async function xe(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await f(`testReports`,e.path);if(t.encoding===`base64`&&t.contentBase64)return p(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await d(`testReports`,e.path);return m(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await d(`testReports`,e.path);return h(t.content).headers}}catch{}return[]}function b({className:e=`w-4 h-4`,open:t=!1}){return(0,y.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,y.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,y.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 x({className:e=`w-3 h-3`}){return(0,y.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,y.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,y.jsx)(`path`,{d:`m15 5 4 4`})]})}function S({className:e=`w-3 h-3`}){return(0,y.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,y.jsx)(`path`,{d:`M3 6h18`}),(0,y.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,y.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,y.jsx)(`path`,{d:`M10 11v6`}),(0,y.jsx)(`path`,{d:`M14 11v6`})]})}function C({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,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,y.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,y.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,y.jsx)(b,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,y.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,y.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,y.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,y.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,y.jsx)(C,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function Se(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function w(){let[e,t]=(0,v.useState)(()=>s(`testReports`)),[r,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)([]),[w,Ce]=(0,v.useState)(0),[T,E]=(0,v.useState)(`.`),[D,O]=(0,v.useState)([]),[we,Te]=(0,v.useState)({}),[Ee,k]=(0,v.useState)({}),[A,j]=(0,v.useState)(!0),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)(!1),[De,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(null),[z,B]=(0,v.useState)(null),[Oe,V]=(0,v.useState)(1),[H,ke]=ee(be),[Ae,U]=(0,v.useState)(null),W=(0,v.useRef)(null),{cls:je,play:G}=ge(),Me=(0,v.useMemo)(()=>T===`.`||!T.trim()?null:_(T),[T]),K=(0,v.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await xe(e);n.length&&(t[e.path]=n)})),Te(t)},[]),q=(0,v.useCallback)(async()=>{let e=await le(`testReports`);h(e.tree),Ce(e.totalFiles)},[]),J=(0,v.useCallback)(async(e=T)=>{N(null);try{let[t]=await Promise.all([l(`testReports`,e),q()]);O(t.entries),E(t.path);let n=t.entries.filter(e=>e.type===`file`);await K(n)}catch(e){N(e instanceof Error?e.message:String(e))}},[T,K,q]);(0,v.useEffect)(()=>{let e=a(e=>t(!!e.testReports));return n().then(()=>{t(s(`testReports`)),d(!0)}),e},[]);let Ne=(0,v.useCallback)(async()=>{for(let e of ye)try{await u(`testReports`,`.`,e.folder)}catch{}await _e()},[]);(0,v.useEffect)(()=>{r&&e&&(async()=>{if(!await de(`testReports`))p(!1);else try{await Ne();let[e]=await Promise.all([l(`testReports`,`.`),q()]);O(e.entries),E(e.path),await K(e.entries.filter(e=>e.type===`file`)),p(!0)}catch(e){N(e instanceof Error?e.message:String(e)),p(!0)}})()},[r,e,Ne,K,q]);function Pe(){j(e=>!e),k({})}async function Y(e){G(),E(e),V(1),U(null),N(null);try{let t=await l(`testReports`,e);O(t.entries),await K(t.entries.filter(e=>e.type===`file`))}catch(e){N(e instanceof Error?e.message:String(e))}}async function Fe(e){I(!1),F(!0),N(null);try{await u(`testReports`,T,e),await J(T),c(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),c(`新建文件夹失败:${t}`,`error`)}finally{F(!1)}}async function Ie(e){if(e?.length){F(!0),N(null);try{for(let t of Array.from(e))await re(`testReports`,T,t);await J(T),c(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),c(`上传失败:${t}`,`error`)}finally{F(!1),W.current&&(W.current.value=``)}}}async function Le(e){let t=_(e.path)??Me,n=t?ve(t).defaultPrompt:``;F(!0),N(null);try{await ne(`testReports`,e,{attachPrompt:n||void 0})}catch(e){N(e instanceof Error?e.message:String(e)),F(!1)}}async function Re(e){if(e.type===`file`){F(!0),N(null);try{await ae(`testReports`,e.path)}catch(e){N(e instanceof Error?e.message:String(e))}finally{F(!1)}}}function ze(e){let t=ie(m,e.path),n=t?.fileCount??0,r=t?pe(t):0;R({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Be(e){R({name:e.name,path:e.path,isDir:!1})}function X(e,t){B({...e,isDir:t})}async function Ve(){let e=L;if(e&&(R(null),!e.blocked)){F(!0),N(null);try{await ue(`testReports`,e.path);let t=fe(T,e.path)?oe(e.path):T;await J(t),c(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),c(`删除失败:${t}`,`error`)}finally{F(!1)}}}async function He(e){let t=z;if(t&&(B(null),e!==t.name)){F(!0),N(null);try{let n=await se(`testReports`,t.path,e);await J(ce(T,t.path,n)),c(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),c(`重命名失败:${t}`,`error`)}finally{F(!1)}}}let Ue=(()=>{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}」?将移入系统废纸篓。`})();if(!r)return(0,y.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(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:o(`testReports`)});if(f===null)return(0,y.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!f)return(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:`报告管理需要本地文档服务,当前未就绪。`});let Z=D.filter(e=>e.type===`file`),We=D.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(Z.length/H)),$=Math.min(Oe,Q),Ge=Z.slice(($-1)*H,$*H);function Ke(e){G(),ke(e),V(1)}return(0,y.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,y.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,y.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,y.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,y.jsx)(`button`,{type:`button`,disabled:P,onClick:()=>I(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,y.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,y.jsx)(`div`,{className:`group flex items-center rounded-md ${T===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,y.jsxs)(`button`,{type:`button`,onClick:()=>{Y(`.`),T===`.`?Pe():(j(!0),k({}))},"aria-expanded":A,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${T===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,y.jsx)(b,{open:A,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,y.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部报告`}),(0,y.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,w,`)`]})]})}),(0,y.jsx)(`div`,{className:`tw-collapse ${A?`is-open`:``}`,children:(0,y.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:m.map(e=>(0,y.jsx)(C,{node:e,depth:0,activePath:T,expanded:Ee,globalOpen:A,onToggle:e=>k(t=>({...t,[e]:!(t[e]??A)})),onSelect:e=>void Y(e)},e.path))})})]})]}),(0,y.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,y.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,y.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,y.jsx)(`span`,{className:`text-stone-400`,children:me(`testReports`)}),T===`.`?``:T]}),(0,y.jsx)(`input`,{ref:W,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>void Ie(e.target.files)}),(0,y.jsx)(`button`,{type:`button`,disabled:P,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:`上传文件`})]}),M?(0,y.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:M}):null,(0,y.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[We.length>0&&(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,y.jsx)(`ul`,{className:`space-y-1`,children:We.map(e=>(0,y.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void Y(e.path),children:[(0,y.jsx)(b,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,y.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,y.jsx)(`button`,{type:`button`,disabled:P,"aria-label":`重命名 ${e.name}`,onClick:()=>X({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,y.jsx)(x,{className:`w-3.5 h-3.5`})}),(0,y.jsx)(`button`,{type:`button`,disabled:P,"aria-label":`删除 ${e.name}`,onClick:()=>ze({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,y.jsx)(S,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),Z.length===0?(0,y.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加报告(.md / .xlsx / .docx 等)`}):(0,y.jsx)(`ul`,{className:`${je}space-y-1`,children:Ge.map(e=>{let t=we[e.path]??[],n=Ae===e.path;return(0,y.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 rounded-lg border transition-colors ${n?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:P,onClick:()=>U(e.path),onDoubleClick:()=>void Re(e),children:[(0,y.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,y.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:Se(e.size)}),t.length>0?(0,y.jsx)(he,{fields:t}):null]}),(0,y.jsx)(`button`,{type:`button`,disabled:P,onClick:()=>void Le(e),className:`mt-0.5 shrink-0 cursor-pointer whitespace-nowrap rounded bg-[#4176e6] px-2 py-1 text-xs text-white hover:bg-[#3565c7] disabled:opacity-40`,children:`在会话中打开`}),(0,y.jsx)(`button`,{type:`button`,disabled:P,"aria-label":`重命名 ${e.name}`,onClick:()=>X({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40 shrink-0 mt-0.5`,children:(0,y.jsx)(x,{className:`w-3.5 h-3.5`})}),(0,y.jsx)(`button`,{type:`button`,disabled:P,"aria-label":`删除 ${e.name}`,onClick:()=>Be(e),className:`tw-icon-danger p-1.5 rounded shrink-0 mt-0.5`,children:(0,y.jsx)(S,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),Z.length>0?(0,y.jsx)(te,{page:$,totalPages:Q,pageSize:H,busy:P,onPage:e=>{G(),V(e)},onPageSize:Ke}):null]}),(0,y.jsx)(g,{open:De,title:`新建文件夹`,onClose:()=>I(!1),onConfirm:e=>void Fe(e)}),(0,y.jsx)(g,{open:z!=null,title:z?.isDir?`重命名文件夹`:`重命名文件`,label:z?.isDir?`文件夹名称`:`文件名称`,initialValue:z?.name??``,lockExtension:z!=null&&!z.isDir,confirmLabel:`保存`,onClose:()=>B(null),onConfirm:e=>void He(e)}),(0,y.jsx)(i,{open:L!=null,title:L?.blocked?`无法删除文件夹`:L?.isDir?`删除文件夹`:`删除报告`,message:Ue,confirmLabel:L?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!L?.blocked,hideCancel:!!L?.blocked,onClose:()=>R(null),onConfirm:()=>void Ve()})]})}export{w as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Dvfzl5_N.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.DQFd6g2r.js";import{a,o as ee,r as te}from"./plugins.Db9xoFZb.js";import{r as ne,s as re}from"./view-prefs.COAKEQtZ.js";import{E as o}from"./PmShared.BQVzwsiz.js";import{showToast as s}from"./Toast.BydY-X7T.js";import{t as ie}from"./DatePicker.BRO_CjVQ.js";import{n as ae,t as oe}from"./DocsPager.DMN9-Tjg.js";import{n as se,r as ce,t as le}from"./TableFieldConfig.72AL-8p-.js";import{t as ue}from"./TagSelect.B_r2p0fp.js";import{a as de,c as fe,d as pe,i as me,l as c,n as l,o as he,r as ge,t as u}from"./ColumnResize.CkE59sGq.js";import{a as _e,c as ve,d,f as ye,i as be,l as xe,n as Se,o as Ce,p as we,r as Te,s as Ee,t as De,u as Oe}from"./test-stats.Cf3_L4wu.js";var f=e(t(),1),p=r(),ke=8e3,m=600,Ae=20,je=`tw.test-stats.page-size.v1`,h=`test-stats.search`,g=[{key:`select`,width:32,min:28},{key:`date`,width:140,min:120},{key:`dimensions`,width:320,min:200},{key:`count`,width:120,min:90},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],_=new Set([`select`,`date`,`filler`,`action`]),v=[{key:`dimensions`,label:`测试统计维度`},{key:`count`,label:`统计数量`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],y=`test-stats.fields`,b=`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-[#4176e6] focus:bg-white placeholder:text-stone-300 tabular-nums`,x=(0,p.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,p.jsx)(`path`,{d:`M3 6h18`}),(0,p.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,p.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,p.jsx)(`path`,{d:`M10 11v6M14 11v6`})]});function S(e){let[t,n]=(0,f.useState)(e.value?String(e.value):``),r=(0,f.useRef)(e.value),i=(0,f.useRef)(e.onCommit);i.current=e.onCommit,(0,f.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,f.useEffect)(()=>{let e=t?d(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},m);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?d(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,p.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:b})}function C(){let[e,t]=(0,f.useState)(!1),[r,d]=(0,f.useState)(!0),[m,b]=(0,f.useState)(null),[C,w]=(0,f.useState)([]),[T,E]=(0,f.useState)([]),[D,O]=(0,f.useState)(null),[k,A]=(0,f.useState)(!1),[j,Me]=(0,f.useState)(()=>ne(h)),[M,N]=(0,f.useState)({}),[Ne,P]=(0,f.useState)(1),[F,Pe]=ae(Ae,je),[I,L]=(0,f.useState)(null),[R,z]=(0,f.useState)(null);function B(e){re(h,e),Me(e),P(1)}let V=(0,f.useRef)(!0),H=(0,f.useRef)(!1),U=ce(y,v,_),W=(0,f.useMemo)(()=>se(g,U.isVisible),[U.isVisible]),G=c(`lh:test-stats:cols:v1`,W),Fe=pe(`test-stats`);(0,f.useEffect)(()=>(V.current=!0,()=>{V.current=!1}),[]);let K=(0,f.useCallback)(async()=>{try{let e=await Ee();if(!V.current)return;w(e.items),E(e.dimensions),N(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}),O(null)}catch(e){if(!V.current)return;O(e instanceof Error?e.message:String(e))}},[]);(0,f.useEffect)(()=>{let e=a(e=>d(!!e.testStats));return n().then(()=>{d(te(`testStats`)),t(!0)}),e},[]),(0,f.useEffect)(()=>{e&&r&&(async()=>{let e=await _e();V.current&&(e?(await K(),V.current&&b(!0)):b(!1))})()},[e,r,K]),(0,f.useEffect)(()=>{if(m!==!0)return;let e=window.setInterval(()=>{H.current||K()},ke),t=()=>{H.current||K()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[m,K]);let Ie=ye(),q=(0,f.useMemo)(()=>xe(Ce(C,{keyword:j})),[C,j]),J=(0,f.useMemo)(()=>Oe(C),[C]),Y=Math.max(1,Math.ceil(q.length/F)),X=Math.min(Ne,Y),Z=(0,f.useMemo)(()=>q.slice((X-1)*F,X*F),[q,X,F]),Q=(0,f.useMemo)(()=>C.filter(e=>M[e.id]),[C,M]),Le=Z.length>0&&Z.every(e=>M[e.id]);(0,f.useEffect)(()=>{if(!I)return;let e=q.findIndex(e=>e.id===I);if(e<0)return;P(Math.floor(e/F)+1);let t=window.setTimeout(()=>L(null),2e3);return()=>window.clearTimeout(t)},[I,q,F]);async function Re(){if(!k){A(!0),O(null),B(``);try{let e=await Se([{date:Ie,dimensions:[],count:0}],{mode:`manual`});if(!V.current)return;let t=e.items[0];if(e.dimensions.length&&E(e.dimensions),await K(),!V.current||!t)return;L(t.id)}catch(e){V.current&&O(e instanceof Error?e.message:String(e))}finally{V.current&&A(!1)}}}async function $(e,t){w(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,dimensions:r}=await we(e,t);if(!V.current)return;w(t=>t.map(t=>t.id===e?n:t)),r.length&&E(r),O(null)}catch(e){if(!V.current)return;O(e instanceof Error?e.message:String(e)),await K()}}async function ze(e,t){let n=t.trim();if(n&&n!==e)try{let t=await ve(e,n);if(!V.current)return;w(t.items),E(t.dimensions),O(null),s(t.replaced>0?`已重命名,同步了 ${t.replaced} 条记录`:`已重命名测试统计维度`,`success`)}catch(e){if(!V.current)return;s(`重命名失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Be(e){let t=De(C,e);if(t>0)s(`还有 ${t} 条记录在用「${e}」,先改掉再删除`,`error`);else try{let t=await be(e);if(!V.current)return;w(t.items),E(t.dimensions),O(null),s(`已删除测试统计维度「${e}」`,`success`)}catch(e){if(!V.current)return;s(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Ve(){let e=R;if(e&&e.length!==0){z(null),A(!0);try{if(await Te(e.map(e=>e.id)),!V.current)return;N({}),O(null),await K()}catch(e){V.current&&O(e instanceof Error?e.message:String(e))}finally{V.current&&A(!1)}}}return e?r?m===null?(0,p.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,p.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,p.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):m?(0,p.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,p.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,p.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,p.jsx)(`span`,{className:`font-medium text-stone-800`,children:J.records}),` 条`,(0,p.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 覆盖 `,J.dimensions,` 个维度 · 数量合计 `,J.total,Q.length?` · 已选 ${Q.length} 条`:``]})]}),(0,p.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,p.jsx)(`input`,{value:j,onChange:e=>B(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-[#4176e6]`}),(0,p.jsx)(`button`,{type:`button`,disabled:k||Q.length===0,onClick:()=>z(Q),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,p.jsx)(le,{fields:U.fields,isVisible:U.isVisible,onToggle:U.toggle}),(0,p.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>void Re(),className:`h-9 shrink-0 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#3566d0] disabled:opacity-40`,children:`+ 添加记录`})]})]}),D?(0,p.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,p.jsx)(`span`,{className:`min-w-0 flex-1`,children:D}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>O(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,p.jsx)(`div`,{ref:Fe,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{H.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{H.current=!!document.activeElement?.closest(`.tw-data-table`)},0)},children:(0,p.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:G.tableStyle,children:[(0,p.jsx)(`colgroup`,{children:W.map(e=>(0,p.jsx)(`col`,{style:G.widthOf(e.key)?{width:G.widthOf(e.key)}:void 0},e.key))}),(0,p.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{className:de,children:(0,p.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:Le,disabled:Z.length===0,onChange:e=>{let t=e.target.checked;N(e=>{let n={...e};for(let e of Z)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,p.jsxs)(`th`,{className:he,style:{"--tw-sticky-left":`32px`},children:[`统计日期`,(0,p.jsx)(u,{...G.resizeProps(`date`)})]}),U.isVisible(`dimensions`)?(0,p.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`测试统计维度`,(0,p.jsx)(u,{...G.resizeProps(`dimensions`)})]}):null,U.isVisible(`count`)?(0,p.jsxs)(`th`,{className:`relative px-2 py-2 text-center font-medium whitespace-nowrap`,children:[`统计数量`,(0,p.jsx)(u,{...G.resizeProps(`count`)})]}):null,U.isVisible(`createdAt`)?(0,p.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,p.jsx)(u,{...G.resizeProps(`createdAt`)})]}):null,U.isVisible(`updatedAt`)?(0,p.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,p.jsx)(u,{...G.resizeProps(`updatedAt`)})]}):null,(0,p.jsx)(`th`,{"aria-hidden":`true`}),(0,p.jsx)(`th`,{className:fe,children:`操作`})]})}),(0,p.jsxs)(`tbody`,{children:[q.length===0?(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:W.length,className:`px-4 py-14 text-center text-sm text-stone-400`,children:`还没有测试统计记录,点右上角「+ 添加记录」开始。`})}):null,Z.map(e=>(0,p.jsxs)(`tr`,{className:`group/row ${e.id===I?`tw-new-row`:`hover:bg-[#f7f8fa]`}`,children:[(0,p.jsx)(`td`,{className:l,children:(0,p.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.date} ${e.dimensions.join(`/`)}`,checked:!!M[e.id],onChange:t=>N(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,p.jsx)(`td`,{className:ge,style:{"--tw-sticky-left":`32px`},children:(0,p.jsx)(ie,{value:e.date,onChange:t=>void $(e.id,{date:t}),placeholder:`选择日期`,className:`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-[#4176e6] focus:bg-white`})}),U.isVisible(`dimensions`)?(0,p.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,p.jsx)(ue,{compact:!0,ariaLabel:`测试统计维度`,options:T,value:e.dimensions[0]??``,onChange:t=>void $(e.id,{dimensions:t?[t]:[]}),onRenameOption:(e,t)=>void ze(e,t),onDeleteOption:e=>void Be(e),placeholder:`选择或创建维度`})}):null,U.isVisible(`count`)?(0,p.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,p.jsx)(S,{value:e.count,ariaLabel:`统计数量`,onCommit:t=>void $(e.id,{count:t})})}):null,U.isVisible(`createdAt`)?(0,p.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:o(e.createdAt)}):null,U.isVisible(`updatedAt`)?(0,p.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:o(e.updatedAt)}):null,(0,p.jsx)(`td`,{"aria-hidden":`true`}),(0,p.jsx)(`td`,{className:me,children:(0,p.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>z([e]),"aria-label":`删除 ${e.date} 的记录`,className:`tw-icon-danger rounded p-1`,children:x})})]},e.id))]})]})}),q.length>0?(0,p.jsx)(oe,{page:X,totalPages:Y,pageSize:F,busy:k,onPage:P,onPageSize:e=>{Pe(e),P(1)}}):(0,p.jsx)(`div`,{className:`pb-1`}),(0,p.jsx)(i,{open:R!==null,title:`删除测试统计`,message:R&&R.length>1?`确定删除选中的 ${R.length} 条记录吗?删除后不可恢复。`:`确定删除 ${R?.[0]?.date??``} 的这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>z(null),onConfirm:()=>void Ve()})]}):(0,p.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,p.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:ee(`testStats`)}):(0,p.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,p.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,p.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{C as default};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.BSO5r82v.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.DQFd6g2r.js";import{a,o as ee,r as te}from"./plugins.ChGmBEkF.js";import{r as ne,s as re}from"./view-prefs.CWc5cQ2q.js";import{E as o}from"./PmShared.TOjBbtV8.js";import{showToast as s}from"./Toast.BydY-X7T.js";import{t as ie}from"./DatePicker.BRO_CjVQ.js";import{n as ae,t as oe}from"./DocsPager.Dg765uHW.js";import{n as se,r as ce,t as le}from"./TableFieldConfig.DHj25OKN.js";import{t as ue}from"./TagSelect.B_r2p0fp.js";import{a as de,c as fe,d as pe,i as me,l as c,n as l,o as he,r as ge,t as u}from"./ColumnResize.CkE59sGq.js";import{a as _e,c as ve,d,f as ye,i as be,l as xe,n as Se,o as Ce,p as we,r as Te,s as Ee,t as De,u as Oe}from"./test-stats.Cf3_L4wu.js";var f=e(t(),1),p=r(),ke=8e3,m=600,Ae=20,je=`tw.test-stats.page-size.v1`,h=`test-stats.search`,g=[{key:`select`,width:32,min:28},{key:`date`,width:140,min:120},{key:`dimensions`,width:320,min:200},{key:`count`,width:120,min:90},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],_=new Set([`select`,`date`,`filler`,`action`]),v=[{key:`dimensions`,label:`测试统计维度`},{key:`count`,label:`统计数量`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],y=`test-stats.fields`,b=`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-[#4176e6] focus:bg-white placeholder:text-stone-300 tabular-nums`,x=(0,p.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,p.jsx)(`path`,{d:`M3 6h18`}),(0,p.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,p.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,p.jsx)(`path`,{d:`M10 11v6M14 11v6`})]});function S(e){let[t,n]=(0,f.useState)(e.value?String(e.value):``),r=(0,f.useRef)(e.value),i=(0,f.useRef)(e.onCommit);i.current=e.onCommit,(0,f.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,f.useEffect)(()=>{let e=t?d(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},m);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?d(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,p.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:b})}function C(){let[e,t]=(0,f.useState)(!1),[r,d]=(0,f.useState)(!0),[m,b]=(0,f.useState)(null),[C,w]=(0,f.useState)([]),[T,E]=(0,f.useState)([]),[D,O]=(0,f.useState)(null),[k,A]=(0,f.useState)(!1),[j,Me]=(0,f.useState)(()=>ne(h)),[M,N]=(0,f.useState)({}),[Ne,P]=(0,f.useState)(1),[F,Pe]=ae(Ae,je),[I,L]=(0,f.useState)(null),[R,z]=(0,f.useState)(null);function B(e){re(h,e),Me(e),P(1)}let V=(0,f.useRef)(!0),H=(0,f.useRef)(!1),U=ce(y,v,_),W=(0,f.useMemo)(()=>se(g,U.isVisible),[U.isVisible]),G=c(`lh:test-stats:cols:v1`,W),Fe=pe(`test-stats`);(0,f.useEffect)(()=>(V.current=!0,()=>{V.current=!1}),[]);let K=(0,f.useCallback)(async()=>{try{let e=await Ee();if(!V.current)return;w(e.items),E(e.dimensions),N(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}),O(null)}catch(e){if(!V.current)return;O(e instanceof Error?e.message:String(e))}},[]);(0,f.useEffect)(()=>{let e=a(e=>d(!!e.testStats));return n().then(()=>{d(te(`testStats`)),t(!0)}),e},[]),(0,f.useEffect)(()=>{e&&r&&(async()=>{let e=await _e();V.current&&(e?(await K(),V.current&&b(!0)):b(!1))})()},[e,r,K]),(0,f.useEffect)(()=>{if(m!==!0)return;let e=window.setInterval(()=>{H.current||K()},ke),t=()=>{H.current||K()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[m,K]);let Ie=ye(),q=(0,f.useMemo)(()=>xe(Ce(C,{keyword:j})),[C,j]),J=(0,f.useMemo)(()=>Oe(C),[C]),Y=Math.max(1,Math.ceil(q.length/F)),X=Math.min(Ne,Y),Z=(0,f.useMemo)(()=>q.slice((X-1)*F,X*F),[q,X,F]),Q=(0,f.useMemo)(()=>C.filter(e=>M[e.id]),[C,M]),Le=Z.length>0&&Z.every(e=>M[e.id]);(0,f.useEffect)(()=>{if(!I)return;let e=q.findIndex(e=>e.id===I);if(e<0)return;P(Math.floor(e/F)+1);let t=window.setTimeout(()=>L(null),2e3);return()=>window.clearTimeout(t)},[I,q,F]);async function Re(){if(!k){A(!0),O(null),B(``);try{let e=await Se([{date:Ie,dimensions:[],count:0}],{mode:`manual`});if(!V.current)return;let t=e.items[0];if(e.dimensions.length&&E(e.dimensions),await K(),!V.current||!t)return;L(t.id)}catch(e){V.current&&O(e instanceof Error?e.message:String(e))}finally{V.current&&A(!1)}}}async function $(e,t){w(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,dimensions:r}=await we(e,t);if(!V.current)return;w(t=>t.map(t=>t.id===e?n:t)),r.length&&E(r),O(null)}catch(e){if(!V.current)return;O(e instanceof Error?e.message:String(e)),await K()}}async function ze(e,t){let n=t.trim();if(n&&n!==e)try{let t=await ve(e,n);if(!V.current)return;w(t.items),E(t.dimensions),O(null),s(t.replaced>0?`已重命名,同步了 ${t.replaced} 条记录`:`已重命名测试统计维度`,`success`)}catch(e){if(!V.current)return;s(`重命名失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Be(e){let t=De(C,e);if(t>0)s(`还有 ${t} 条记录在用「${e}」,先改掉再删除`,`error`);else try{let t=await be(e);if(!V.current)return;w(t.items),E(t.dimensions),O(null),s(`已删除测试统计维度「${e}」`,`success`)}catch(e){if(!V.current)return;s(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Ve(){let e=R;if(e&&e.length!==0){z(null),A(!0);try{if(await Te(e.map(e=>e.id)),!V.current)return;N({}),O(null),await K()}catch(e){V.current&&O(e instanceof Error?e.message:String(e))}finally{V.current&&A(!1)}}}return e?r?m===null?(0,p.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,p.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,p.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):m?(0,p.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,p.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,p.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,p.jsx)(`span`,{className:`font-medium text-stone-800`,children:J.records}),` 条`,(0,p.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 覆盖 `,J.dimensions,` 个维度 · 数量合计 `,J.total,Q.length?` · 已选 ${Q.length} 条`:``]})]}),(0,p.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,p.jsx)(`input`,{value:j,onChange:e=>B(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-[#4176e6]`}),(0,p.jsx)(`button`,{type:`button`,disabled:k||Q.length===0,onClick:()=>z(Q),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,p.jsx)(le,{fields:U.fields,isVisible:U.isVisible,onToggle:U.toggle}),(0,p.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>void Re(),className:`h-9 shrink-0 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#3566d0] disabled:opacity-40`,children:`+ 添加记录`})]})]}),D?(0,p.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,p.jsx)(`span`,{className:`min-w-0 flex-1`,children:D}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>O(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,p.jsx)(`div`,{ref:Fe,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{H.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{H.current=!!document.activeElement?.closest(`.tw-data-table`)},0)},children:(0,p.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:G.tableStyle,children:[(0,p.jsx)(`colgroup`,{children:W.map(e=>(0,p.jsx)(`col`,{style:G.widthOf(e.key)?{width:G.widthOf(e.key)}:void 0},e.key))}),(0,p.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{className:de,children:(0,p.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:Le,disabled:Z.length===0,onChange:e=>{let t=e.target.checked;N(e=>{let n={...e};for(let e of Z)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,p.jsxs)(`th`,{className:he,style:{"--tw-sticky-left":`32px`},children:[`统计日期`,(0,p.jsx)(u,{...G.resizeProps(`date`)})]}),U.isVisible(`dimensions`)?(0,p.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`测试统计维度`,(0,p.jsx)(u,{...G.resizeProps(`dimensions`)})]}):null,U.isVisible(`count`)?(0,p.jsxs)(`th`,{className:`relative px-2 py-2 text-center font-medium whitespace-nowrap`,children:[`统计数量`,(0,p.jsx)(u,{...G.resizeProps(`count`)})]}):null,U.isVisible(`createdAt`)?(0,p.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,p.jsx)(u,{...G.resizeProps(`createdAt`)})]}):null,U.isVisible(`updatedAt`)?(0,p.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,p.jsx)(u,{...G.resizeProps(`updatedAt`)})]}):null,(0,p.jsx)(`th`,{"aria-hidden":`true`}),(0,p.jsx)(`th`,{className:fe,children:`操作`})]})}),(0,p.jsxs)(`tbody`,{children:[q.length===0?(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:W.length,className:`px-4 py-14 text-center text-sm text-stone-400`,children:`还没有测试统计记录,点右上角「+ 添加记录」开始。`})}):null,Z.map(e=>(0,p.jsxs)(`tr`,{className:`group/row ${e.id===I?`tw-new-row`:`hover:bg-[#f7f8fa]`}`,children:[(0,p.jsx)(`td`,{className:l,children:(0,p.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.date} ${e.dimensions.join(`/`)}`,checked:!!M[e.id],onChange:t=>N(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,p.jsx)(`td`,{className:ge,style:{"--tw-sticky-left":`32px`},children:(0,p.jsx)(ie,{value:e.date,onChange:t=>void $(e.id,{date:t}),placeholder:`选择日期`,className:`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-[#4176e6] focus:bg-white`})}),U.isVisible(`dimensions`)?(0,p.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,p.jsx)(ue,{compact:!0,ariaLabel:`测试统计维度`,options:T,value:e.dimensions[0]??``,onChange:t=>void $(e.id,{dimensions:t?[t]:[]}),onRenameOption:(e,t)=>void ze(e,t),onDeleteOption:e=>void Be(e),placeholder:`选择或创建维度`})}):null,U.isVisible(`count`)?(0,p.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,p.jsx)(S,{value:e.count,ariaLabel:`统计数量`,onCommit:t=>void $(e.id,{count:t})})}):null,U.isVisible(`createdAt`)?(0,p.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:o(e.createdAt)}):null,U.isVisible(`updatedAt`)?(0,p.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:o(e.updatedAt)}):null,(0,p.jsx)(`td`,{"aria-hidden":`true`}),(0,p.jsx)(`td`,{className:me,children:(0,p.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>z([e]),"aria-label":`删除 ${e.date} 的记录`,className:`tw-icon-danger rounded p-1`,children:x})})]},e.id))]})]})}),q.length>0?(0,p.jsx)(oe,{page:X,totalPages:Y,pageSize:F,busy:k,onPage:P,onPageSize:e=>{Pe(e),P(1)}}):(0,p.jsx)(`div`,{className:`pb-1`}),(0,p.jsx)(i,{open:R!==null,title:`删除测试统计`,message:R&&R.length>1?`确定删除选中的 ${R.length} 条记录吗?删除后不可恢复。`:`确定删除 ${R?.[0]?.date??``} 的这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>z(null),onConfirm:()=>void Ve()})]}):(0,p.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,p.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:ee(`testStats`)}):(0,p.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,p.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,p.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,n as r,r as i,t as a}from"./dialog.XgRGNF_Q.js";import{i as o}from"./app-config.Dvfzl5_N.js";import{t as s}from"./jsx-runtime.DUg_B_vD.js";import{t as c}from"./ConfirmDialog.DQFd6g2r.js";import{a as ee,o as l,r as te}from"./plugins.Db9xoFZb.js";import{n as u,o as d,r as ne,s as f}from"./view-prefs.COAKEQtZ.js";import{n as re,t as p}from"./SelectDropdown.D7IeyHDI.js";import{E as m}from"./PmShared.BQVzwsiz.js";import{showToast as h}from"./Toast.BydY-X7T.js";import{n as ie,t as g}from"./DatePicker.BRO_CjVQ.js";import{n as ae,r as oe,t as se}from"./TableFieldConfig.72AL-8p-.js";import{a as ce,c as le,d as _,i as ue,l as v,n as de,o as fe,r as pe,s as me,t as y}from"./ColumnResize.CkE59sGq.js";import{A as he,C as ge,D as b,E as x,F as S,M as _e,N as ve,O as ye,P as be,S as xe,T as Se,_ as Ce,b as C,f as we,g as Te,j as w,n as T,u as Ee,v as E,w as De,x as Oe,y as D}from"./tasks.DEyD8pmq.js";import{a as O,c as k,i as ke,l as Ae,n as A,o as j,r as je,s as M,t as N}from"./DrawerField.CLdvmHc6.js";var P=e(t(),1),F=s(),Me=8e3,Ne=[{key:`select`,width:32,min:28},{key:`index`,width:36,min:28},{key:`title`,width:300,min:160},{key:`status`,width:104,min:76},{key:`task`,width:156,min:96},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`end`,width:108,min:88},{key:`cycle`,width:64,min:52},{key:`remain`,width:86,min:64},{key:`note`,width:160,min:100},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],Pe=new Set([`select`,`index`,`title`,`filler`,`action`]),Fe=[{key:`status`,label:`待办状态`},{key:`task`,label:`所属任务`},{key:`priority`,label:`紧急程度`},{key:`start`,label:`开始日期`},{key:`due`,label:`截止日期`},{key:`end`,label:`结束日期`},{key:`cycle`,label:`周期`},{key:`remain`,label:`剩余`},{key:`note`,label:`备注`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Ie=`todos.fields`,Le=[`title`,`status`,`priority`,`linkedTask`,`startDate`,`dueDate`,`note`],Re={in_progress:`bg-[#4176e6] text-white`,pending:`bg-stone-400 text-white`,done:`bg-[#34c724] text-white`,cancelled:`bg-stone-300 text-stone-600`,overdue:`bg-[#f54a45] text-white`},ze={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,pending:`bg-stone-100 text-stone-600`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},I={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},Be={pending:`bg-stone-400`,in_progress:`bg-[#4176e6]`,done:`bg-[#34c724]`,overdue:`bg-[#f54a45]`,cancelled:`bg-stone-300`},Ve={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},L={status:`按状态分组`,priority:`按紧急程度分组`,none:`不分组`},He=[`status`,`priority`,`none`],Ue=`todos.group-by`,We=[`in_progress`,`pending`,`overdue`,`done`,`cancelled`],Ge=D.map(e=>({value:e,label:C[e]})),Ke=Ce.map(e=>({value:e,label:E[e]})),qe=`h-8 w-full justify-start rounded-md border border-stone-200 bg-white px-2 text-left text-sm font-normal text-stone-400 hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,Je=`h-8 w-auto max-w-full justify-start bg-transparent px-0 text-left focus:ring-0`,R=`未选择`,Ye=Object.keys(L).map(e=>({value:e,label:L[e]})),Xe=[{value:`all`,label:`全部紧急程度`},...Ce.map(e=>({value:e,label:E[e]}))],Ze=Xe.map(e=>e.value),Qe=`todos.priority-filter`,$e=`todos.search`,et=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white placeholder:text-stone-300`;function tt(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,F.jsx)(`input`,{type:`text`,value:t,placeholder:n,autoFocus:i,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),s(),e.currentTarget.blur())},className:`${et} ${r&&!t?`text-stone-300`:``}`})}function nt(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,P.useState)(!1);return a?(0,F.jsx)(tt,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,F.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`block h-8 w-full min-w-0 truncate rounded-md border border-transparent px-1.5 text-left text-sm leading-8 text-stone-700 transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:outline-none`,children:t||(0,F.jsx)(`span`,{className:`text-stone-300`,children:`—`})})}function rt(e){return(0,F.jsx)(g,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white`})}function it(e){let{open:t,item:o,preset:s,tasks:c,tasksOn:ee,onClose:l,onSaved:te}=e,[u,d]=(0,P.useState)({title:``}),[ne,f]=(0,P.useState)(``),[ae,oe]=(0,P.useState)(!1),[se,ce]=(0,P.useState)(!0);(0,P.useEffect)(()=>{t&&(f(``),oe(!1),ce(!0),d(o?{title:o.title,status:o.status,statusManual:o.statusManual,priority:o.priority,linkedTask:o.linkedTask,taskId:o.taskId,startDate:o.startDate,dueDate:o.dueDate,note:o.note}:(()=>{let e=w(),t=w(),n=x(e,t)??`in_progress`;return{title:``,status:s?.status??n,statusManual:!!s?.status,priority:s?.priority??``,startDate:e,dueDate:t}})()))},[t,o,s]);let le=[{value:``,label:`不关联`},...we(c.filter(e=>e.status!==`closed`&&e.status!==`cancelled`||e.id===o?.taskId)).map(e=>({value:e.id,label:e.title}))];function _(e){d(t=>{let n={...t,...e};if(`status`in e&&!(`startDate`in e||`dueDate`in e))n.statusManual=!0;else if((`startDate`in e||`dueDate`in e)&&!n.statusManual&&!b(n.status??`pending`)){let e=x(n.startDate??``,n.dueDate??``);e&&(n.status=e)}let r=n.dueDate??``,i=n.status??`pending`;return r&&r<w()&&!b(i)&&(n.status=`overdue`,n.statusManual=!1),n})}let ue=_e({startDate:u.startDate??``,dueDate:u.dueDate??``}),v=be({dueDate:u.dueDate??``}),de=b(u.status??`pending`),fe=de?ie((o&&b(o.status)?o.taskEndDate:``)||w()):``,pe=v===null?``:u.status===`done`?`已完成`:u.status===`cancelled`?`已取消`:v<0?`逾期 ${Math.abs(v)} 天`:v===0?`今天截止`:`${v} 天`;async function me(){let e=(u.title??``).trim();if(!e)f(`请填写待办名称`);else if(u.startDate&&u.dueDate&&u.dueDate<u.startDate)f(`截止日期不能早于开始日期`);else{oe(!0),f(``);try{let t={...u,title:e};o?await S(o.id,t):await Oe([t],{mode:`manual`}),await te(),h(o?`已保存待办`:`已新建待办`,`success`),l()}catch(e){let t=e instanceof Error?e.message:String(e);f(t),h(`保存待办失败:${t}`,`error`)}finally{oe(!1)}}}return(0,F.jsxs)(i,{open:t,onClose:l,transition:!0,className:`relative z-100`,children:[(0,F.jsx)(a,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,F.jsx)(`div`,{className:`fixed inset-0 flex justify-end overflow-hidden`,children:(0,F.jsxs)(n,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl duration-[280ms]`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,F.jsx)(r,{className:`text-base font-semibold text-stone-900`,children:o?`待办详情`:`新建待办`}),(0,F.jsx)(`button`,{type:`button`,onClick:l,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,F.jsx)(A,{icon:(0,F.jsx)(Ae,{}),label:`待办名称`,children:(0,F.jsx)(`input`,{autoFocus:!0,value:u.title,onChange:e=>_({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),me())},placeholder:`请输入内容`,className:N})}),(0,F.jsx)(A,{icon:(0,F.jsx)(M,{}),label:`待办状态`,children:(0,F.jsx)(je,{ariaLabel:`待办状态`,menuMinWidth:140,options:Ge,value:u.status??`pending`,onChange:e=>_({status:e}),label:C[u.status??`pending`],optionDotClassName:e=>Be[e]})}),(0,F.jsxs)(`button`,{type:`button`,onClick:()=>ce(e=>!e),"aria-expanded":se,className:`flex w-full items-center gap-2 px-6 py-2 text-left text-sm text-stone-600 hover:bg-stone-50`,children:[(0,F.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center text-stone-400`,children:(0,F.jsx)(k,{})}),(0,F.jsx)(`span`,{children:`任务详情`}),(0,F.jsx)(`span`,{className:`text-stone-400`,children:(0,F.jsx)(ke,{open:se})})]}),se?(0,F.jsxs)(`div`,{className:`ml-[42px] border-l border-stone-100 pl-1`,children:[(0,F.jsx)(A,{icon:(0,F.jsx)(k,{}),label:`所属任务`,children:ee?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(p,{flat:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:le,value:u.taskId??``,onChange:e=>{let t=c.find(t=>t.id===e);_({taskId:e,linkedTask:t?.title??``,...t?{priority:t.priority}:{}})},renderTrigger:()=>(0,F.jsx)(re,{text:u.taskId?c.find(e=>e.id===u.taskId)?.title??``:u.linkedTask||`请选择任务`,className:`min-w-0 truncate ${u.taskId||u.linkedTask?`text-stone-800`:`text-stone-400`}`})}),c.length===0?(0,F.jsx)(`p`,{className:`mt-1 px-2 text-xs text-stone-400`,children:`任务管理里还没有任务,可到「任务管理」新建后再关联。`}):null]}):(0,F.jsx)(`div`,{className:`flex h-9 items-center rounded-md bg-stone-50 px-2 text-sm text-stone-400`,children:(0,F.jsx)(`span`,{className:`truncate`,children:u.linkedTask?`${u.linkedTask}(任务管理插件未启用)`:`任务管理插件未启用,无法关联任务`})})}),(0,F.jsx)(A,{icon:(0,F.jsx)(M,{}),label:`重要紧急程度`,children:(()=>{let e=u.taskId?c.find(e=>e.id===u.taskId):void 0;return e?(0,F.jsxs)(`div`,{className:`flex h-9 items-center gap-2 px-2 text-sm`,children:[(0,F.jsx)(`span`,{className:e.priority?`text-stone-800`:`text-stone-400`,children:e.priority?T[e.priority]:`任务未设置`}),(0,F.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`跟随所属任务`})]}):(0,F.jsx)(je,{ariaLabel:`重要紧急程度`,menuMinWidth:140,options:Ke,value:u.priority??``,onChange:e=>_({priority:e}),label:u.priority?E[u.priority]:R,optionDotClassName:e=>Ve[e]})})()}),(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`结束日期`,children:(0,F.jsxs)(`div`,{className:`flex h-9 items-center px-2 text-sm tabular-nums`,"aria-readonly":`true`,children:[fe?(0,F.jsx)(`span`,{className:`text-stone-800`,children:fe}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`}),(0,F.jsx)(`span`,{className:`ml-2 text-[11px] text-stone-400`,children:de?`按完成日期自动记录`:`状态为已完成 / 已取消时自动记录`})]})})]}):null,(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`开始日期`,children:(0,F.jsx)(g,{value:u.startDate??``,onChange:e=>_({startDate:e}),className:`${N} tabular-nums`})}),(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`截止日期`,children:(0,F.jsx)(g,{value:u.dueDate??``,onChange:e=>_({dueDate:e}),className:`${N} tabular-nums`})}),(0,F.jsx)(A,{icon:(0,F.jsx)(j,{}),label:`待办周期`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:ue===null?`—`:`${ue} 天`})}),(0,F.jsx)(A,{icon:(0,F.jsx)(j,{}),label:`剩余天数`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:pe||`—`})}),(0,F.jsx)(A,{icon:(0,F.jsx)(Ae,{}),label:`备注`,children:(0,F.jsx)(`textarea`,{value:u.note??``,onChange:e=>_({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white placeholder:text-stone-400`})}),o?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`创建日期`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:m(o.createdAt)})}),(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`修改日期`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:m(o.updatedAt)})})]}):null,ne?(0,F.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:ne}):null]}),(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:l,disabled:ae,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>void me(),disabled:ae,className:`h-8 rounded-lg bg-[#4176e6] px-4 text-sm font-medium text-white transition-colors hover:bg-[#3566d0] disabled:opacity-40`,children:ae?`保存中…`:o?`保存`:`新建`})]})]})})]})}function z(){let[e,t]=(0,P.useState)(!1),[n,r]=(0,P.useState)(!0),[i,a]=(0,P.useState)(null),[s,T]=(0,P.useState)([]),[D,O]=(0,P.useState)([]),[k,ke]=(0,P.useState)(!1),[Ae,A]=(0,P.useState)(null),[j,je]=(0,P.useState)(!1),[M,N]=(0,P.useState)(()=>ne($e)),[L,et]=(0,P.useState)(()=>u(Qe,Ze,`all`)),[z,at]=(0,P.useState)(()=>u(Ue,He,`status`)),[ot,st]=(0,P.useState)({}),[B,ct]=(0,P.useState)({});function lt(e){d(Ue,e),at(e)}function ut(e){d(Qe,e),et(e)}function dt(e){f($e,e),N(e)}let[ft,pt]=(0,P.useState)({}),[V,H]=(0,P.useState)(null),[U,mt]=(0,P.useState)(null),[ht,gt]=(0,P.useState)(!1),[_t,vt]=(0,P.useState)(null),W=(0,P.useRef)(!0),yt=(0,P.useRef)(!1),G=(0,P.useRef)(!1),K=oe(Ie,Fe,Pe),bt=(0,P.useMemo)(()=>ae(Ne,K.isVisible),[K.isVisible]),xt=bt.length,q=v(`lh:todos:cols:v1`,bt),St=_(`todos`),Ct=V!==null,wt=(0,P.useRef)(V);wt.current=V;let Tt=(0,P.useRef)(!1),Et=(0,P.useRef)(async()=>{});Et.current=Pt,(0,P.useEffect)(()=>(W.current=!0,()=>{W.current=!1}),[]),(0,P.useEffect)(()=>{if(!Ct)return;let e=e=>{let t=e.target;if(!(t instanceof Element)||t.closest(`.tw-new-row`)||t.closest(`.tw-date-panel`)||t.closest(`.tw-select-menu`))return;let n=wt.current;if(!n)return;if(n.title.trim()){Et.current();return}let r=w();!n.note.trim()&&!n.taskId&&n.status===n.baseStatus&&n.priority===n.basePriority&&n.startDate===r&&n.dueDate===r&&H(null)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[Ct]);let J=(0,P.useCallback)(async()=>{try{let[e,t]=await Promise.all([ye(),k?Ee().catch(()=>[]):Promise.resolve([])]);if(!W.current)return;let n=t;if(!yt.current&&k){yt.current=!0;let r=new Set(e.filter(e=>e.status===`pending`||e.status===`in_progress`).map(e=>e.taskId).filter(Boolean)),i=t.filter(e=>r.has(e.id)&&(e.status===`pool`||e.status===`done`));if(i.length){let e=await Promise.all(i.map(e=>Te(e.id,{status:`in_progress`}).catch(()=>null))),r=new Map(e.filter(e=>!!e).map(e=>[e.id,e]));n=t.map(e=>r.get(e.id)??e)}}T(e),O(n),A(null)}catch(e){if(!W.current)return;A(e instanceof Error?e.message:String(e))}},[k]);(0,P.useEffect)(()=>{let e=ee(e=>{r(!!e.todos),ke(!!e.tasks)});return o().then(()=>{r(te(`todos`)),ke(te(`tasks`)),t(!0)}),e},[]),(0,P.useEffect)(()=>{e&&n&&(async()=>{let e=await De();W.current&&(e?(await J(),W.current&&a(!0)):a(!1))})()},[e,n,J]),(0,P.useEffect)(()=>{if(i!==!0)return;let e=window.setInterval(()=>{G.current||J()},Me),t=()=>{G.current||J()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[i,J]),(0,P.useEffect)(()=>{if(!k||i!==!0||D.length===0)return;let e=s.filter(e=>!e.taskId&&e.linkedTask.trim());if(!e.length)return;let t=!1;return(async()=>{let n=[];for(let t of e){let e=D.find(e=>e.title.trim()===t.linkedTask.trim());if(e)try{n.push(await S(t.id,{taskId:e.id}))}catch{}}!t&&n.length&&T(e=>e.map(e=>n.find(t=>t.id===e.id)??e))})(),()=>{t=!0}},[k,i,s,D]);function Dt(e,t,n){pt(r=>({...r,[e]:{...r[e],[t]:n}}))}function Y(e){pt(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}let Ot=(0,P.useMemo)(()=>[{value:``,label:`不关联`},...we(D.filter(e=>e.status!==`closed`&&e.status!==`cancelled`)).map(e=>({value:e.id,label:e.title}))],[D]);function kt(e){return e.taskId?D.find(t=>t.id===e.taskId)?.title??e.linkedTask:e.linkedTask}function At(e){return e.taskId?D.find(t=>t.id===e.taskId):void 0}function jt(e){let t=At(e);return t?t.priority:e.priority}async function X(e,t){let n=s.find(t=>t.id===e),r={...t};if(t.status!==void 0&&t.startDate===void 0&&t.dueDate===void 0)r.statusManual=!0;else if(n&&!n.statusManual&&!b(n.status)&&(t.startDate!==void 0||t.dueDate!==void 0)&&t.status===void 0){let e=x(t.startDate??n.startDate,t.dueDate??n.dueDate);e&&(r.status=e)}if(n){let e=r.dueDate??n.dueDate,t=r.status??n.status;e&&e<w()&&!b(t)&&(r.status=`overdue`,r.statusManual=!1)}T(t=>t.map(t=>t.id===e?{...t,...r,updatedAt:new Date().toISOString()}:t));try{let t=await S(e,r);if(!W.current)return;T(n=>n.map(n=>n.id===e?t:n)),A(null),r.taskId&&await J()}catch(e){A(e instanceof Error?e.message:String(e)),await J()}}async function Mt(e){let t=ft[e],n=s.find(t=>t.id===e);if(!t||!n)return;let r={},i=n;for(let e of Le){let n=t[e];n!==void 0&&String(i[e]??``)!==String(n)&&(r[e]=n)}if(!Object.keys(r).length)Y(e);else if(typeof r.title==`string`&&!r.title.trim())A(`待办名称不能为空`),Y(e);else try{let t=await S(e,r);if(!W.current)return;T(n=>n.map(n=>n.id===e?t:n)),pt(t=>{let n=t[e];if(!n)return t;let i={...n};for(let e of Object.keys(r))String(i[e]??``)===String(r[e]??``)&&delete i[e];if(!Object.keys(i).length){let n={...t};return delete n[e],n}return{...t,[e]:i}}),A(null)}catch(t){A(t instanceof Error?t.message:String(t)),Y(e)}}function Nt(e){let t=w(),n=w(),r=!!e.newStatus,i=x(t,n)??`in_progress`,a=e.newStatus??i,o=e.newPriority??``;H({groupKey:e.key,title:``,status:a,statusManual:r,priority:o,taskId:``,startDate:t,dueDate:n,note:``,baseStatus:a,basePriority:o}),st(t=>({...t,[e.key]:!1}))}async function Pt(){let e=wt.current;if(!e||Tt.current)return;let t=e.title.trim();if(t){Tt.current=!0,gt(!0);try{let n=D.find(t=>t.id===e.taskId);await Oe([{title:t,status:e.status,statusManual:e.statusManual,priority:e.priority,taskId:e.taskId,linkedTask:n?.title??``,startDate:e.startDate,dueDate:e.dueDate,note:e.note}],{mode:`manual`}),wt.current===e&&H(null),A(null),await J()}catch(e){A(e instanceof Error?e.message:String(e))}finally{Tt.current=!1,W.current&>(!1)}}}async function Ft(){let e=U;if(e){mt(null),je(!0),A(null);try{await xe(e.map(e=>e.id)),ct({}),await J(),h(e.length>1?`已删除 ${e.length} 条待办`:`已删除待办`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),h(`删除待办失败:${t}`,`error`)}finally{W.current&&je(!1)}}}let Z=w(),It=(0,P.useMemo)(()=>s.map(e=>{let t=e.taskId?D.find(t=>t.id===e.taskId):void 0;return t?{...e,priority:t.priority}:e}),[s,D]),Lt=(0,P.useMemo)(()=>Se(It,{status:`all`,priority:L,keyword:M,today:Z}),[It,L,M,Z]),Q=(0,P.useMemo)(()=>he(Lt),[Lt]),Rt=(0,P.useMemo)(()=>z===`none`?[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:Q}]:z===`priority`?[...Ce,``].map(e=>({key:`priority:${e||`none`}`,label:e?E[e]:R,pill:e?I[e]:`bg-stone-300 text-stone-600`,items:Q.filter(t=>t.priority===e),newPriority:e})):We.map(e=>({key:`status:${e}`,label:C[e],pill:Re[e],items:Q.filter(t=>ge(t,Z)===e),newStatus:e===`overdue`?`pending`:e})),[z,Q,Z]).filter(e=>e.items.length>0||V?.groupKey===e.key&&!!V),zt=Object.keys(B).filter(e=>B[e]),$=(0,P.useMemo)(()=>{let e={total:s.length,pending:0,in_progress:0,done:0,overdue:0};for(let t of s){let n=ge(t,Z);n===`overdue`?e.overdue+=1:n===`pending`?e.pending+=1:n===`in_progress`?e.in_progress+=1:n===`done`&&(e.done+=1)}return e},[s,Z]);return e?n?i===null?(0,F.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,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):i?(0,F.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,F.jsx)(`span`,{className:`font-medium text-stone-800`,children:$.total}),` 条`,(0,F.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 待开始 `,$.pending,` · 进行中 `,$.in_progress,` · 已完成 `,$.done,$.overdue?` · 已延期 ${$.overdue}`:``]})]}),(0,F.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`input`,{value:M,onChange:e=>dt(e.target.value),placeholder:`搜索待办…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#4176e6]`}),(0,F.jsx)(p,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Ye,value:z,onChange:e=>lt(e)}),(0,F.jsx)(p,{flat:!0,className:`w-[136px]`,ariaLabel:`紧急程度筛选`,options:Xe,value:L,onChange:e=>ut(e)}),(0,F.jsx)(`button`,{type:`button`,disabled:j||zt.length===0,onClick:()=>mt(s.filter(e=>B[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,F.jsx)(se,{fields:K.fields,isVisible:K.isVisible,onToggle:K.toggle}),(0,F.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>vt({item:null}),className:`h-9 shrink-0 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#3566d0] disabled:opacity-40`,children:`+ 新建待办`})]})]}),Ae?(0,F.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,F.jsx)(`span`,{className:`min-w-0 flex-1`,children:Ae}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>A(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,F.jsx)(`div`,{ref:St,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{G.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{G.current=!!document.activeElement?.closest(`.tw-todo-table`)},0)},children:(0,F.jsxs)(`table`,{className:`tw-todo-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,F.jsx)(`colgroup`,{children:bt.map(e=>(0,F.jsx)(`col`,{style:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,F.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:ce,children:(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`全选可见待办`,checked:Q.length>0&&Q.every(e=>B[e.id]),onChange:e=>{let t=e.target.checked;ct(e=>{let n={...e};for(let e of Q)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,F.jsx)(`th`,{className:me,style:{"--tw-sticky-left":`32px`},"aria-label":`行号`}),(0,F.jsxs)(`th`,{className:fe,style:{"--tw-sticky-left":`68px`},children:[`待办名称`,(0,F.jsx)(y,{...q.resizeProps(`title`)})]}),K.isVisible(`status`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办状态`,(0,F.jsx)(y,{...q.resizeProps(`status`)})]}):null,K.isVisible(`task`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属任务`,(0,F.jsx)(y,{...q.resizeProps(`task`)})]}):null,K.isVisible(`priority`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,F.jsx)(y,{...q.resizeProps(`priority`)})]}):null,K.isVisible(`start`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,F.jsx)(y,{...q.resizeProps(`start`)})]}):null,K.isVisible(`due`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,F.jsx)(y,{...q.resizeProps(`due`)})]}):null,K.isVisible(`end`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`结束日期`,(0,F.jsx)(y,{...q.resizeProps(`end`)})]}):null,K.isVisible(`cycle`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`周期`,(0,F.jsx)(y,{...q.resizeProps(`cycle`)})]}):null,K.isVisible(`remain`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`剩余`,(0,F.jsx)(y,{...q.resizeProps(`remain`)})]}):null,K.isVisible(`note`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,F.jsx)(y,{...q.resizeProps(`note`)})]}):null,K.isVisible(`createdAt`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,F.jsx)(y,{...q.resizeProps(`createdAt`)})]}):null,K.isVisible(`updatedAt`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,F.jsx)(y,{...q.resizeProps(`updatedAt`)})]}):null,(0,F.jsx)(`th`,{"aria-hidden":`true`}),(0,F.jsx)(`th`,{className:le,children:`操作`})]})}),Rt.map(e=>{let t=ot[e.key]===!0,n=()=>st(n=>({...n,[e.key]:!t}));return(0,F.jsxs)(`tbody`,{children:[(0,F.jsxs)(`tr`,{role:`button`,tabIndex:0,"aria-expanded":!t,"aria-label":t?`展开分组`:`收起分组`,className:`tw-life-group-head cursor-pointer bg-white`,style:{"--tw-row-bg":`#ffffff`,"--life-select-w":`68px`},onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},children:[(0,F.jsx)(`td`,{colSpan:3,className:`tw-sticky-l tw-life-group-sticky-lead border-b border-stone-100 px-0 pb-1.5 pt-3 align-middle`,style:{left:0,"--tw-sticky-left":`0px`},children:(0,F.jsxs)(`div`,{className:`flex w-full items-center gap-2 py-1.5 pr-2 text-left`,children:[(0,F.jsx)(`span`,{className:`flex h-7 w-9 shrink-0 items-center justify-center`,children:(0,F.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`shrink-0 text-stone-400 transition-transform duration-200 ease-out ${t?`-rotate-90`:`rotate-0`}`,children:(0,F.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}),(0,F.jsx)(`span`,{className:`inline-flex max-w-[min(100%,16rem)] shrink-0 items-center truncate rounded-full px-2.5 py-0.5 text-xs font-medium whitespace-nowrap ${e.pill}`,children:e.label}),(0,F.jsxs)(`span`,{className:`shrink-0 text-xs text-stone-400 tabular-nums`,children:[e.items.length,` 条记录`]})]})}),(0,F.jsx)(`td`,{colSpan:Math.max(xt-3,1),className:`border-b border-stone-100 bg-white pb-1.5 pt-3`,"aria-hidden":`true`})]}),t?null:e.items.map((e,t)=>{let n=ft[e.id]??{},r={...e,...n},i=ge(r,Z),a=_e(r),o=be(r,Z),s=o===null?`—`:i===`done`?`已完成`:i===`cancelled`?`已取消`:o<0?`逾期 ${Math.abs(o)} 天`:o===0?`今天截止`:`${o} 天`;return(0,F.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,F.jsx)(`td`,{className:de,children:(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.title}`,checked:!!B[e.id],onChange:t=>ct(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,F.jsx)(`td`,{className:`${pe} text-xs text-stone-400 tabular-nums`,style:{"--tw-sticky-left":`32px`},children:t+1}),(0,F.jsx)(`td`,{className:de,style:{"--tw-sticky-left":`68px`},children:(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.source===`ai`?(0,F.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,title:`AI 记录`,children:`AI`}):null,(0,F.jsx)(tt,{value:r.title,placeholder:`输入待办名称`,onChange:t=>Dt(e.id,`title`,t),onCommit:()=>void Mt(e.id),onCancel:()=>Y(e.id)})]})}),K.isVisible(`status`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(p,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Ge,value:i,onChange:t=>void X(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#4176e6]/30 ${ze[i]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`truncate`,children:C[i]}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Be[e.value]}`})})}):null,K.isVisible(`task`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,F.jsx)(p,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:Ot,value:r.taskId,onChange:t=>{let n=D.find(e=>e.id===t);X(e.id,{taskId:t,linkedTask:n?.title??``,...n?{priority:n.priority}:{}})},triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>(0,F.jsx)(re,{text:kt(r)||`未关联`,className:`min-w-0 truncate ${kt(r)?`text-stone-800`:`text-stone-300`}`})}):(0,F.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:kt(r)?`${kt(r)} · 插件未启用`:`任务管理插件未启用`})}):null,K.isVisible(`priority`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:At(r)?jt(r)?(0,F.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${I[jt(r)]}`,children:E[jt(r)]}):(0,F.jsx)(`span`,{className:`text-sm text-stone-400`,children:R}):(0,F.jsx)(p,{unstyled:!0,fitContent:!!e.priority,hideChevron:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ke,value:e.priority,onChange:t=>void X(e.id,{priority:t}),triggerClassName:e.priority?Je:qe,renderTrigger:()=>e.priority?(0,F.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${I[e.priority]}`,children:E[e.priority]}):(0,F.jsx)(`span`,{className:`truncate text-stone-400`,children:R}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ve[e.value]}`})})}):null,K.isVisible(`start`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(rt,{value:r.startDate,onChange:t=>void X(e.id,{startDate:t})})}):null,K.isVisible(`due`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(rt,{value:r.dueDate,onChange:t=>void X(e.id,{dueDate:t})})}):null,K.isVisible(`end`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:ve(r)?(0,F.jsx)(`span`,{className:`text-stone-500`,children:ie(ve(r))}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}):null,K.isVisible(`cycle`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:a===null?`—`:`${a} 天`}):null,K.isVisible(`remain`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums ${o!==null&&o<0&&i!==`done`&&i!==`cancelled`?`font-medium text-[#c02a26]`:`text-stone-500`}`,children:s}):null,K.isVisible(`note`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(nt,{value:r.note,onChange:t=>Dt(e.id,`note`,t),onCommit:()=>void Mt(e.id),onCancel:()=>Y(e.id)})}):null,K.isVisible(`createdAt`)?(0,F.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:m(e.createdAt)}):null,K.isVisible(`updatedAt`)?(0,F.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:m(e.updatedAt)}):null,(0,F.jsx)(`td`,{"aria-hidden":`true`}),(0,F.jsx)(`td`,{className:ue,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>vt({item:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,F.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,F.jsx)(`path`,{d:`M14 4h6v6`}),(0,F.jsx)(`path`,{d:`M20 4 13 11`}),(0,F.jsx)(`path`,{d:`M10 20H4v-6`}),(0,F.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,F.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>mt([e]),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,F.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,F.jsx)(`path`,{d:`M3 6h18`}),(0,F.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,F.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,F.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),t?null:V?.groupKey===e.key?(0,F.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:e.items.length+1}),(0,F.jsx)(`td`,{className:pe,children:(0,F.jsx)(`input`,{autoFocus:!0,value:V.title,disabled:ht,placeholder:`输入待办名称,回车或点空白处保存`,onChange:e=>H(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),Pt()):e.key===`Escape`&&(e.preventDefault(),H(null))},className:`h-8 w-full truncate rounded-md border border-[#4176e6]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#4176e6]`})}),K.isVisible(`status`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(p,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Ge,value:V.status,onChange:e=>H(t=>t&&{...t,status:e,statusManual:!0}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#4176e6]/30 ${ze[V.status]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`truncate`,children:C[V.status]})})}):null,K.isVisible(`task`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,F.jsx)(p,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:Ot,value:V.taskId,onChange:e=>H(t=>{if(!t)return t;let n=D.find(t=>t.id===e);return{...t,taskId:e,...n?{priority:n.priority}:{}}}),triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>{let e=D.find(e=>e.id===V.taskId);return(0,F.jsx)(re,{text:e?.title||`未关联`,className:`min-w-0 truncate ${e?`text-stone-800`:`text-stone-300`}`})}}):(0,F.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:`任务管理插件未启用`})}):null,K.isVisible(`priority`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(()=>{let e=D.find(e=>e.id===V.taskId);return e?(0,F.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${I[e.priority]??`text-stone-300`}`,children:e.priority?E[e.priority]:R}):(0,F.jsx)(p,{unstyled:!0,fitContent:!!V.priority,hideChevron:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ke,value:V.priority,onChange:e=>H(t=>t&&{...t,priority:e}),triggerClassName:V.priority?Je:qe,renderTrigger:()=>V.priority?(0,F.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${I[V.priority]}`,children:E[V.priority]}):(0,F.jsx)(`span`,{className:`truncate text-stone-400`,children:R})})})()}):null,K.isVisible(`start`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(g,{value:V.startDate,onChange:e=>H(t=>{if(!t)return t;let n=e,r={...t,startDate:n};if(!t.statusManual&&!b(t.status)){let e=x(n,t.dueDate);e&&(r.status=e)}return r.dueDate&&r.dueDate<w()&&!b(r.status)&&(r.status=`overdue`,r.statusManual=!1),r}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white`})}):null,K.isVisible(`due`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(g,{value:V.dueDate,onChange:e=>H(t=>{if(!t)return t;let n=e,r={...t,dueDate:n};if(!t.statusManual&&!b(t.status)){let e=x(t.startDate,n);e&&(r.status=e)}return n&&n<w()&&!b(r.status)&&(r.status=`overdue`,r.statusManual=!1),r}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white`})}):null,K.isVisible(`end`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:b(V.status)?(0,F.jsx)(`span`,{className:`text-stone-500`,children:ie(w())}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}):null,K.isVisible(`cycle`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}):null,K.isVisible(`remain`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}):null,K.isVisible(`note`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(`input`,{value:V.note,disabled:ht,placeholder:`—`,onChange:e=>H(t=>t&&{...t,note:e.target.value}),className:`h-8 w-full truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors placeholder:text-stone-300 hover:border-stone-200 focus:border-[#4176e6] focus:bg-white`})}):null,K.isVisible(`createdAt`)?(0,F.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-400`,children:`—`}):null,K.isVisible(`updatedAt`)?(0,F.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-400`,children:`—`}):null,(0,F.jsx)(`td`,{"aria-hidden":`true`}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`})]}):(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`td`,{className:`px-2 py-0.5`}),(0,F.jsx)(`td`,{className:`px-1 py-0.5`}),(0,F.jsx)(`td`,{className:`px-1 py-0.5`,colSpan:Math.max(xt-2,1),children:(0,F.jsxs)(`button`,{type:`button`,disabled:ht,onClick:()=>Nt(e),className:`flex items-center gap-1 rounded px-1 py-0.5 text-xs text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[(0,F.jsx)(`span`,{className:`text-sm leading-none`,children:`+`}),`新增记录`]})})]})]},e.key)}),Rt.length===0?(0,F.jsx)(`tbody`,{children:(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:xt,className:`px-3 py-16 text-center text-sm text-stone-400`,children:s.length===0?`还没有待办`:`没有匹配的待办,试试调整搜索或筛选`})})}):null]})}),(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,F.jsxs)(`span`,{children:[`共 `,Q.length,` 条`,zt.length?` · 已选 ${zt.length}`:``]}),(0,F.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`点击单元格直接编辑,回车或点空白处保存`})]}),(0,F.jsx)(it,{open:_t!==null,item:_t?.item??null,preset:_t?.preset,tasks:D,tasksOn:k,onClose:()=>vt(null),onSaved:J}),(0,F.jsx)(c,{open:U!=null,title:U&&U.length>1?`批量删除`:`删除待办`,message:U&&U.length>1?`确认删除已选中的 ${U.length} 条待办?此操作不可恢复。`:`删除「${U?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>mt(null),onConfirm:()=>void Ft()})]}):(0,F.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,F.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:l(`todos`)}):(0,F.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,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{z as default};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,n as r,r as i,t as a}from"./dialog.XgRGNF_Q.js";import{i as o}from"./app-config.BSO5r82v.js";import{t as s}from"./jsx-runtime.DUg_B_vD.js";import{t as c}from"./ConfirmDialog.DQFd6g2r.js";import{a as ee,o as l,r as te}from"./plugins.ChGmBEkF.js";import{n as u,o as d,r as ne,s as f}from"./view-prefs.CWc5cQ2q.js";import{n as re,t as p}from"./SelectDropdown.D7IeyHDI.js";import{E as m}from"./PmShared.TOjBbtV8.js";import{showToast as h}from"./Toast.BydY-X7T.js";import{n as ie,t as g}from"./DatePicker.BRO_CjVQ.js";import{n as ae,r as oe,t as se}from"./TableFieldConfig.DHj25OKN.js";import{a as ce,c as le,d as _,i as ue,l as v,n as de,o as fe,r as pe,s as me,t as y}from"./ColumnResize.CkE59sGq.js";import{A as he,C as ge,D as b,E as x,F as S,M as _e,N as ve,O as ye,P as be,S as xe,T as Se,_ as Ce,b as C,f as we,g as Te,j as w,n as T,u as Ee,v as E,w as De,x as Oe,y as D}from"./tasks.DEyD8pmq.js";import{a as O,c as k,i as ke,l as Ae,n as A,o as j,r as je,s as M,t as N}from"./DrawerField.CLdvmHc6.js";var P=e(t(),1),F=s(),Me=8e3,Ne=[{key:`select`,width:32,min:28},{key:`index`,width:36,min:28},{key:`title`,width:300,min:160},{key:`status`,width:104,min:76},{key:`task`,width:156,min:96},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`end`,width:108,min:88},{key:`cycle`,width:64,min:52},{key:`remain`,width:86,min:64},{key:`note`,width:160,min:100},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],Pe=new Set([`select`,`index`,`title`,`filler`,`action`]),Fe=[{key:`status`,label:`待办状态`},{key:`task`,label:`所属任务`},{key:`priority`,label:`紧急程度`},{key:`start`,label:`开始日期`},{key:`due`,label:`截止日期`},{key:`end`,label:`结束日期`},{key:`cycle`,label:`周期`},{key:`remain`,label:`剩余`},{key:`note`,label:`备注`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Ie=`todos.fields`,Le=[`title`,`status`,`priority`,`linkedTask`,`startDate`,`dueDate`,`note`],Re={in_progress:`bg-[#4176e6] text-white`,pending:`bg-stone-400 text-white`,done:`bg-[#34c724] text-white`,cancelled:`bg-stone-300 text-stone-600`,overdue:`bg-[#f54a45] text-white`},ze={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,pending:`bg-stone-100 text-stone-600`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},I={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},Be={pending:`bg-stone-400`,in_progress:`bg-[#4176e6]`,done:`bg-[#34c724]`,overdue:`bg-[#f54a45]`,cancelled:`bg-stone-300`},Ve={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},L={status:`按状态分组`,priority:`按紧急程度分组`,none:`不分组`},He=[`status`,`priority`,`none`],Ue=`todos.group-by`,We=[`in_progress`,`pending`,`overdue`,`done`,`cancelled`],Ge=D.map(e=>({value:e,label:C[e]})),Ke=Ce.map(e=>({value:e,label:E[e]})),qe=`h-8 w-full justify-start rounded-md border border-stone-200 bg-white px-2 text-left text-sm font-normal text-stone-400 hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,Je=`h-8 w-auto max-w-full justify-start bg-transparent px-0 text-left focus:ring-0`,R=`未选择`,Ye=Object.keys(L).map(e=>({value:e,label:L[e]})),Xe=[{value:`all`,label:`全部紧急程度`},...Ce.map(e=>({value:e,label:E[e]}))],Ze=Xe.map(e=>e.value),Qe=`todos.priority-filter`,$e=`todos.search`,et=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white placeholder:text-stone-300`;function tt(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,F.jsx)(`input`,{type:`text`,value:t,placeholder:n,autoFocus:i,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),s(),e.currentTarget.blur())},className:`${et} ${r&&!t?`text-stone-300`:``}`})}function nt(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,P.useState)(!1);return a?(0,F.jsx)(tt,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,F.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`block h-8 w-full min-w-0 truncate rounded-md border border-transparent px-1.5 text-left text-sm leading-8 text-stone-700 transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:outline-none`,children:t||(0,F.jsx)(`span`,{className:`text-stone-300`,children:`—`})})}function rt(e){return(0,F.jsx)(g,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white`})}function it(e){let{open:t,item:o,preset:s,tasks:c,tasksOn:ee,onClose:l,onSaved:te}=e,[u,d]=(0,P.useState)({title:``}),[ne,f]=(0,P.useState)(``),[ae,oe]=(0,P.useState)(!1),[se,ce]=(0,P.useState)(!0);(0,P.useEffect)(()=>{t&&(f(``),oe(!1),ce(!0),d(o?{title:o.title,status:o.status,statusManual:o.statusManual,priority:o.priority,linkedTask:o.linkedTask,taskId:o.taskId,startDate:o.startDate,dueDate:o.dueDate,note:o.note}:(()=>{let e=w(),t=w(),n=x(e,t)??`in_progress`;return{title:``,status:s?.status??n,statusManual:!!s?.status,priority:s?.priority??``,startDate:e,dueDate:t}})()))},[t,o,s]);let le=[{value:``,label:`不关联`},...we(c.filter(e=>e.status!==`closed`&&e.status!==`cancelled`||e.id===o?.taskId)).map(e=>({value:e.id,label:e.title}))];function _(e){d(t=>{let n={...t,...e};if(`status`in e&&!(`startDate`in e||`dueDate`in e))n.statusManual=!0;else if((`startDate`in e||`dueDate`in e)&&!n.statusManual&&!b(n.status??`pending`)){let e=x(n.startDate??``,n.dueDate??``);e&&(n.status=e)}let r=n.dueDate??``,i=n.status??`pending`;return r&&r<w()&&!b(i)&&(n.status=`overdue`,n.statusManual=!1),n})}let ue=_e({startDate:u.startDate??``,dueDate:u.dueDate??``}),v=be({dueDate:u.dueDate??``}),de=b(u.status??`pending`),fe=de?ie((o&&b(o.status)?o.taskEndDate:``)||w()):``,pe=v===null?``:u.status===`done`?`已完成`:u.status===`cancelled`?`已取消`:v<0?`逾期 ${Math.abs(v)} 天`:v===0?`今天截止`:`${v} 天`;async function me(){let e=(u.title??``).trim();if(!e)f(`请填写待办名称`);else if(u.startDate&&u.dueDate&&u.dueDate<u.startDate)f(`截止日期不能早于开始日期`);else{oe(!0),f(``);try{let t={...u,title:e};o?await S(o.id,t):await Oe([t],{mode:`manual`}),await te(),h(o?`已保存待办`:`已新建待办`,`success`),l()}catch(e){let t=e instanceof Error?e.message:String(e);f(t),h(`保存待办失败:${t}`,`error`)}finally{oe(!1)}}}return(0,F.jsxs)(i,{open:t,onClose:l,transition:!0,className:`relative z-100`,children:[(0,F.jsx)(a,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,F.jsx)(`div`,{className:`fixed inset-0 flex justify-end overflow-hidden`,children:(0,F.jsxs)(n,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl duration-[280ms]`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,F.jsx)(r,{className:`text-base font-semibold text-stone-900`,children:o?`待办详情`:`新建待办`}),(0,F.jsx)(`button`,{type:`button`,onClick:l,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,F.jsx)(A,{icon:(0,F.jsx)(Ae,{}),label:`待办名称`,children:(0,F.jsx)(`input`,{autoFocus:!0,value:u.title,onChange:e=>_({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),me())},placeholder:`请输入内容`,className:N})}),(0,F.jsx)(A,{icon:(0,F.jsx)(M,{}),label:`待办状态`,children:(0,F.jsx)(je,{ariaLabel:`待办状态`,menuMinWidth:140,options:Ge,value:u.status??`pending`,onChange:e=>_({status:e}),label:C[u.status??`pending`],optionDotClassName:e=>Be[e]})}),(0,F.jsxs)(`button`,{type:`button`,onClick:()=>ce(e=>!e),"aria-expanded":se,className:`flex w-full items-center gap-2 px-6 py-2 text-left text-sm text-stone-600 hover:bg-stone-50`,children:[(0,F.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center text-stone-400`,children:(0,F.jsx)(k,{})}),(0,F.jsx)(`span`,{children:`任务详情`}),(0,F.jsx)(`span`,{className:`text-stone-400`,children:(0,F.jsx)(ke,{open:se})})]}),se?(0,F.jsxs)(`div`,{className:`ml-[42px] border-l border-stone-100 pl-1`,children:[(0,F.jsx)(A,{icon:(0,F.jsx)(k,{}),label:`所属任务`,children:ee?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(p,{flat:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:le,value:u.taskId??``,onChange:e=>{let t=c.find(t=>t.id===e);_({taskId:e,linkedTask:t?.title??``,...t?{priority:t.priority}:{}})},renderTrigger:()=>(0,F.jsx)(re,{text:u.taskId?c.find(e=>e.id===u.taskId)?.title??``:u.linkedTask||`请选择任务`,className:`min-w-0 truncate ${u.taskId||u.linkedTask?`text-stone-800`:`text-stone-400`}`})}),c.length===0?(0,F.jsx)(`p`,{className:`mt-1 px-2 text-xs text-stone-400`,children:`任务管理里还没有任务,可到「任务管理」新建后再关联。`}):null]}):(0,F.jsx)(`div`,{className:`flex h-9 items-center rounded-md bg-stone-50 px-2 text-sm text-stone-400`,children:(0,F.jsx)(`span`,{className:`truncate`,children:u.linkedTask?`${u.linkedTask}(任务管理插件未启用)`:`任务管理插件未启用,无法关联任务`})})}),(0,F.jsx)(A,{icon:(0,F.jsx)(M,{}),label:`重要紧急程度`,children:(()=>{let e=u.taskId?c.find(e=>e.id===u.taskId):void 0;return e?(0,F.jsxs)(`div`,{className:`flex h-9 items-center gap-2 px-2 text-sm`,children:[(0,F.jsx)(`span`,{className:e.priority?`text-stone-800`:`text-stone-400`,children:e.priority?T[e.priority]:`任务未设置`}),(0,F.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`跟随所属任务`})]}):(0,F.jsx)(je,{ariaLabel:`重要紧急程度`,menuMinWidth:140,options:Ke,value:u.priority??``,onChange:e=>_({priority:e}),label:u.priority?E[u.priority]:R,optionDotClassName:e=>Ve[e]})})()}),(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`结束日期`,children:(0,F.jsxs)(`div`,{className:`flex h-9 items-center px-2 text-sm tabular-nums`,"aria-readonly":`true`,children:[fe?(0,F.jsx)(`span`,{className:`text-stone-800`,children:fe}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`}),(0,F.jsx)(`span`,{className:`ml-2 text-[11px] text-stone-400`,children:de?`按完成日期自动记录`:`状态为已完成 / 已取消时自动记录`})]})})]}):null,(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`开始日期`,children:(0,F.jsx)(g,{value:u.startDate??``,onChange:e=>_({startDate:e}),className:`${N} tabular-nums`})}),(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`截止日期`,children:(0,F.jsx)(g,{value:u.dueDate??``,onChange:e=>_({dueDate:e}),className:`${N} tabular-nums`})}),(0,F.jsx)(A,{icon:(0,F.jsx)(j,{}),label:`待办周期`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:ue===null?`—`:`${ue} 天`})}),(0,F.jsx)(A,{icon:(0,F.jsx)(j,{}),label:`剩余天数`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:pe||`—`})}),(0,F.jsx)(A,{icon:(0,F.jsx)(Ae,{}),label:`备注`,children:(0,F.jsx)(`textarea`,{value:u.note??``,onChange:e=>_({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white placeholder:text-stone-400`})}),o?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`创建日期`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:m(o.createdAt)})}),(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`修改日期`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:m(o.updatedAt)})})]}):null,ne?(0,F.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:ne}):null]}),(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:l,disabled:ae,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>void me(),disabled:ae,className:`h-8 rounded-lg bg-[#4176e6] px-4 text-sm font-medium text-white transition-colors hover:bg-[#3566d0] disabled:opacity-40`,children:ae?`保存中…`:o?`保存`:`新建`})]})]})})]})}function z(){let[e,t]=(0,P.useState)(!1),[n,r]=(0,P.useState)(!0),[i,a]=(0,P.useState)(null),[s,T]=(0,P.useState)([]),[D,O]=(0,P.useState)([]),[k,ke]=(0,P.useState)(!1),[Ae,A]=(0,P.useState)(null),[j,je]=(0,P.useState)(!1),[M,N]=(0,P.useState)(()=>ne($e)),[L,et]=(0,P.useState)(()=>u(Qe,Ze,`all`)),[z,at]=(0,P.useState)(()=>u(Ue,He,`status`)),[ot,st]=(0,P.useState)({}),[B,ct]=(0,P.useState)({});function lt(e){d(Ue,e),at(e)}function ut(e){d(Qe,e),et(e)}function dt(e){f($e,e),N(e)}let[ft,pt]=(0,P.useState)({}),[V,H]=(0,P.useState)(null),[U,mt]=(0,P.useState)(null),[ht,gt]=(0,P.useState)(!1),[_t,vt]=(0,P.useState)(null),W=(0,P.useRef)(!0),yt=(0,P.useRef)(!1),G=(0,P.useRef)(!1),K=oe(Ie,Fe,Pe),bt=(0,P.useMemo)(()=>ae(Ne,K.isVisible),[K.isVisible]),xt=bt.length,q=v(`lh:todos:cols:v1`,bt),St=_(`todos`),Ct=V!==null,wt=(0,P.useRef)(V);wt.current=V;let Tt=(0,P.useRef)(!1),Et=(0,P.useRef)(async()=>{});Et.current=Pt,(0,P.useEffect)(()=>(W.current=!0,()=>{W.current=!1}),[]),(0,P.useEffect)(()=>{if(!Ct)return;let e=e=>{let t=e.target;if(!(t instanceof Element)||t.closest(`.tw-new-row`)||t.closest(`.tw-date-panel`)||t.closest(`.tw-select-menu`))return;let n=wt.current;if(!n)return;if(n.title.trim()){Et.current();return}let r=w();!n.note.trim()&&!n.taskId&&n.status===n.baseStatus&&n.priority===n.basePriority&&n.startDate===r&&n.dueDate===r&&H(null)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[Ct]);let J=(0,P.useCallback)(async()=>{try{let[e,t]=await Promise.all([ye(),k?Ee().catch(()=>[]):Promise.resolve([])]);if(!W.current)return;let n=t;if(!yt.current&&k){yt.current=!0;let r=new Set(e.filter(e=>e.status===`pending`||e.status===`in_progress`).map(e=>e.taskId).filter(Boolean)),i=t.filter(e=>r.has(e.id)&&(e.status===`pool`||e.status===`done`));if(i.length){let e=await Promise.all(i.map(e=>Te(e.id,{status:`in_progress`}).catch(()=>null))),r=new Map(e.filter(e=>!!e).map(e=>[e.id,e]));n=t.map(e=>r.get(e.id)??e)}}T(e),O(n),A(null)}catch(e){if(!W.current)return;A(e instanceof Error?e.message:String(e))}},[k]);(0,P.useEffect)(()=>{let e=ee(e=>{r(!!e.todos),ke(!!e.tasks)});return o().then(()=>{r(te(`todos`)),ke(te(`tasks`)),t(!0)}),e},[]),(0,P.useEffect)(()=>{e&&n&&(async()=>{let e=await De();W.current&&(e?(await J(),W.current&&a(!0)):a(!1))})()},[e,n,J]),(0,P.useEffect)(()=>{if(i!==!0)return;let e=window.setInterval(()=>{G.current||J()},Me),t=()=>{G.current||J()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[i,J]),(0,P.useEffect)(()=>{if(!k||i!==!0||D.length===0)return;let e=s.filter(e=>!e.taskId&&e.linkedTask.trim());if(!e.length)return;let t=!1;return(async()=>{let n=[];for(let t of e){let e=D.find(e=>e.title.trim()===t.linkedTask.trim());if(e)try{n.push(await S(t.id,{taskId:e.id}))}catch{}}!t&&n.length&&T(e=>e.map(e=>n.find(t=>t.id===e.id)??e))})(),()=>{t=!0}},[k,i,s,D]);function Dt(e,t,n){pt(r=>({...r,[e]:{...r[e],[t]:n}}))}function Y(e){pt(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}let Ot=(0,P.useMemo)(()=>[{value:``,label:`不关联`},...we(D.filter(e=>e.status!==`closed`&&e.status!==`cancelled`)).map(e=>({value:e.id,label:e.title}))],[D]);function kt(e){return e.taskId?D.find(t=>t.id===e.taskId)?.title??e.linkedTask:e.linkedTask}function At(e){return e.taskId?D.find(t=>t.id===e.taskId):void 0}function jt(e){let t=At(e);return t?t.priority:e.priority}async function X(e,t){let n=s.find(t=>t.id===e),r={...t};if(t.status!==void 0&&t.startDate===void 0&&t.dueDate===void 0)r.statusManual=!0;else if(n&&!n.statusManual&&!b(n.status)&&(t.startDate!==void 0||t.dueDate!==void 0)&&t.status===void 0){let e=x(t.startDate??n.startDate,t.dueDate??n.dueDate);e&&(r.status=e)}if(n){let e=r.dueDate??n.dueDate,t=r.status??n.status;e&&e<w()&&!b(t)&&(r.status=`overdue`,r.statusManual=!1)}T(t=>t.map(t=>t.id===e?{...t,...r,updatedAt:new Date().toISOString()}:t));try{let t=await S(e,r);if(!W.current)return;T(n=>n.map(n=>n.id===e?t:n)),A(null),r.taskId&&await J()}catch(e){A(e instanceof Error?e.message:String(e)),await J()}}async function Mt(e){let t=ft[e],n=s.find(t=>t.id===e);if(!t||!n)return;let r={},i=n;for(let e of Le){let n=t[e];n!==void 0&&String(i[e]??``)!==String(n)&&(r[e]=n)}if(!Object.keys(r).length)Y(e);else if(typeof r.title==`string`&&!r.title.trim())A(`待办名称不能为空`),Y(e);else try{let t=await S(e,r);if(!W.current)return;T(n=>n.map(n=>n.id===e?t:n)),pt(t=>{let n=t[e];if(!n)return t;let i={...n};for(let e of Object.keys(r))String(i[e]??``)===String(r[e]??``)&&delete i[e];if(!Object.keys(i).length){let n={...t};return delete n[e],n}return{...t,[e]:i}}),A(null)}catch(t){A(t instanceof Error?t.message:String(t)),Y(e)}}function Nt(e){let t=w(),n=w(),r=!!e.newStatus,i=x(t,n)??`in_progress`,a=e.newStatus??i,o=e.newPriority??``;H({groupKey:e.key,title:``,status:a,statusManual:r,priority:o,taskId:``,startDate:t,dueDate:n,note:``,baseStatus:a,basePriority:o}),st(t=>({...t,[e.key]:!1}))}async function Pt(){let e=wt.current;if(!e||Tt.current)return;let t=e.title.trim();if(t){Tt.current=!0,gt(!0);try{let n=D.find(t=>t.id===e.taskId);await Oe([{title:t,status:e.status,statusManual:e.statusManual,priority:e.priority,taskId:e.taskId,linkedTask:n?.title??``,startDate:e.startDate,dueDate:e.dueDate,note:e.note}],{mode:`manual`}),wt.current===e&&H(null),A(null),await J()}catch(e){A(e instanceof Error?e.message:String(e))}finally{Tt.current=!1,W.current&>(!1)}}}async function Ft(){let e=U;if(e){mt(null),je(!0),A(null);try{await xe(e.map(e=>e.id)),ct({}),await J(),h(e.length>1?`已删除 ${e.length} 条待办`:`已删除待办`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),h(`删除待办失败:${t}`,`error`)}finally{W.current&&je(!1)}}}let Z=w(),It=(0,P.useMemo)(()=>s.map(e=>{let t=e.taskId?D.find(t=>t.id===e.taskId):void 0;return t?{...e,priority:t.priority}:e}),[s,D]),Lt=(0,P.useMemo)(()=>Se(It,{status:`all`,priority:L,keyword:M,today:Z}),[It,L,M,Z]),Q=(0,P.useMemo)(()=>he(Lt),[Lt]),Rt=(0,P.useMemo)(()=>z===`none`?[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:Q}]:z===`priority`?[...Ce,``].map(e=>({key:`priority:${e||`none`}`,label:e?E[e]:R,pill:e?I[e]:`bg-stone-300 text-stone-600`,items:Q.filter(t=>t.priority===e),newPriority:e})):We.map(e=>({key:`status:${e}`,label:C[e],pill:Re[e],items:Q.filter(t=>ge(t,Z)===e),newStatus:e===`overdue`?`pending`:e})),[z,Q,Z]).filter(e=>e.items.length>0||V?.groupKey===e.key&&!!V),zt=Object.keys(B).filter(e=>B[e]),$=(0,P.useMemo)(()=>{let e={total:s.length,pending:0,in_progress:0,done:0,overdue:0};for(let t of s){let n=ge(t,Z);n===`overdue`?e.overdue+=1:n===`pending`?e.pending+=1:n===`in_progress`?e.in_progress+=1:n===`done`&&(e.done+=1)}return e},[s,Z]);return e?n?i===null?(0,F.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,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):i?(0,F.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,F.jsx)(`span`,{className:`font-medium text-stone-800`,children:$.total}),` 条`,(0,F.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 待开始 `,$.pending,` · 进行中 `,$.in_progress,` · 已完成 `,$.done,$.overdue?` · 已延期 ${$.overdue}`:``]})]}),(0,F.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`input`,{value:M,onChange:e=>dt(e.target.value),placeholder:`搜索待办…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#4176e6]`}),(0,F.jsx)(p,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Ye,value:z,onChange:e=>lt(e)}),(0,F.jsx)(p,{flat:!0,className:`w-[136px]`,ariaLabel:`紧急程度筛选`,options:Xe,value:L,onChange:e=>ut(e)}),(0,F.jsx)(`button`,{type:`button`,disabled:j||zt.length===0,onClick:()=>mt(s.filter(e=>B[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,F.jsx)(se,{fields:K.fields,isVisible:K.isVisible,onToggle:K.toggle}),(0,F.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>vt({item:null}),className:`h-9 shrink-0 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#3566d0] disabled:opacity-40`,children:`+ 新建待办`})]})]}),Ae?(0,F.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,F.jsx)(`span`,{className:`min-w-0 flex-1`,children:Ae}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>A(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,F.jsx)(`div`,{ref:St,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{G.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{G.current=!!document.activeElement?.closest(`.tw-todo-table`)},0)},children:(0,F.jsxs)(`table`,{className:`tw-todo-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,F.jsx)(`colgroup`,{children:bt.map(e=>(0,F.jsx)(`col`,{style:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,F.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:ce,children:(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`全选可见待办`,checked:Q.length>0&&Q.every(e=>B[e.id]),onChange:e=>{let t=e.target.checked;ct(e=>{let n={...e};for(let e of Q)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,F.jsx)(`th`,{className:me,style:{"--tw-sticky-left":`32px`},"aria-label":`行号`}),(0,F.jsxs)(`th`,{className:fe,style:{"--tw-sticky-left":`68px`},children:[`待办名称`,(0,F.jsx)(y,{...q.resizeProps(`title`)})]}),K.isVisible(`status`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办状态`,(0,F.jsx)(y,{...q.resizeProps(`status`)})]}):null,K.isVisible(`task`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属任务`,(0,F.jsx)(y,{...q.resizeProps(`task`)})]}):null,K.isVisible(`priority`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,F.jsx)(y,{...q.resizeProps(`priority`)})]}):null,K.isVisible(`start`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,F.jsx)(y,{...q.resizeProps(`start`)})]}):null,K.isVisible(`due`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,F.jsx)(y,{...q.resizeProps(`due`)})]}):null,K.isVisible(`end`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`结束日期`,(0,F.jsx)(y,{...q.resizeProps(`end`)})]}):null,K.isVisible(`cycle`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`周期`,(0,F.jsx)(y,{...q.resizeProps(`cycle`)})]}):null,K.isVisible(`remain`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`剩余`,(0,F.jsx)(y,{...q.resizeProps(`remain`)})]}):null,K.isVisible(`note`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,F.jsx)(y,{...q.resizeProps(`note`)})]}):null,K.isVisible(`createdAt`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,F.jsx)(y,{...q.resizeProps(`createdAt`)})]}):null,K.isVisible(`updatedAt`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,F.jsx)(y,{...q.resizeProps(`updatedAt`)})]}):null,(0,F.jsx)(`th`,{"aria-hidden":`true`}),(0,F.jsx)(`th`,{className:le,children:`操作`})]})}),Rt.map(e=>{let t=ot[e.key]===!0,n=()=>st(n=>({...n,[e.key]:!t}));return(0,F.jsxs)(`tbody`,{children:[(0,F.jsxs)(`tr`,{role:`button`,tabIndex:0,"aria-expanded":!t,"aria-label":t?`展开分组`:`收起分组`,className:`tw-life-group-head cursor-pointer bg-white`,style:{"--tw-row-bg":`#ffffff`,"--life-select-w":`68px`},onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},children:[(0,F.jsx)(`td`,{colSpan:3,className:`tw-sticky-l tw-life-group-sticky-lead border-b border-stone-100 px-0 pb-1.5 pt-3 align-middle`,style:{left:0,"--tw-sticky-left":`0px`},children:(0,F.jsxs)(`div`,{className:`flex w-full items-center gap-2 py-1.5 pr-2 text-left`,children:[(0,F.jsx)(`span`,{className:`flex h-7 w-9 shrink-0 items-center justify-center`,children:(0,F.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`shrink-0 text-stone-400 transition-transform duration-200 ease-out ${t?`-rotate-90`:`rotate-0`}`,children:(0,F.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}),(0,F.jsx)(`span`,{className:`inline-flex max-w-[min(100%,16rem)] shrink-0 items-center truncate rounded-full px-2.5 py-0.5 text-xs font-medium whitespace-nowrap ${e.pill}`,children:e.label}),(0,F.jsxs)(`span`,{className:`shrink-0 text-xs text-stone-400 tabular-nums`,children:[e.items.length,` 条记录`]})]})}),(0,F.jsx)(`td`,{colSpan:Math.max(xt-3,1),className:`border-b border-stone-100 bg-white pb-1.5 pt-3`,"aria-hidden":`true`})]}),t?null:e.items.map((e,t)=>{let n=ft[e.id]??{},r={...e,...n},i=ge(r,Z),a=_e(r),o=be(r,Z),s=o===null?`—`:i===`done`?`已完成`:i===`cancelled`?`已取消`:o<0?`逾期 ${Math.abs(o)} 天`:o===0?`今天截止`:`${o} 天`;return(0,F.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,F.jsx)(`td`,{className:de,children:(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.title}`,checked:!!B[e.id],onChange:t=>ct(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,F.jsx)(`td`,{className:`${pe} text-xs text-stone-400 tabular-nums`,style:{"--tw-sticky-left":`32px`},children:t+1}),(0,F.jsx)(`td`,{className:de,style:{"--tw-sticky-left":`68px`},children:(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.source===`ai`?(0,F.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,title:`AI 记录`,children:`AI`}):null,(0,F.jsx)(tt,{value:r.title,placeholder:`输入待办名称`,onChange:t=>Dt(e.id,`title`,t),onCommit:()=>void Mt(e.id),onCancel:()=>Y(e.id)})]})}),K.isVisible(`status`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(p,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Ge,value:i,onChange:t=>void X(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#4176e6]/30 ${ze[i]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`truncate`,children:C[i]}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Be[e.value]}`})})}):null,K.isVisible(`task`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,F.jsx)(p,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:Ot,value:r.taskId,onChange:t=>{let n=D.find(e=>e.id===t);X(e.id,{taskId:t,linkedTask:n?.title??``,...n?{priority:n.priority}:{}})},triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>(0,F.jsx)(re,{text:kt(r)||`未关联`,className:`min-w-0 truncate ${kt(r)?`text-stone-800`:`text-stone-300`}`})}):(0,F.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:kt(r)?`${kt(r)} · 插件未启用`:`任务管理插件未启用`})}):null,K.isVisible(`priority`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:At(r)?jt(r)?(0,F.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${I[jt(r)]}`,children:E[jt(r)]}):(0,F.jsx)(`span`,{className:`text-sm text-stone-400`,children:R}):(0,F.jsx)(p,{unstyled:!0,fitContent:!!e.priority,hideChevron:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ke,value:e.priority,onChange:t=>void X(e.id,{priority:t}),triggerClassName:e.priority?Je:qe,renderTrigger:()=>e.priority?(0,F.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${I[e.priority]}`,children:E[e.priority]}):(0,F.jsx)(`span`,{className:`truncate text-stone-400`,children:R}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ve[e.value]}`})})}):null,K.isVisible(`start`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(rt,{value:r.startDate,onChange:t=>void X(e.id,{startDate:t})})}):null,K.isVisible(`due`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(rt,{value:r.dueDate,onChange:t=>void X(e.id,{dueDate:t})})}):null,K.isVisible(`end`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:ve(r)?(0,F.jsx)(`span`,{className:`text-stone-500`,children:ie(ve(r))}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}):null,K.isVisible(`cycle`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:a===null?`—`:`${a} 天`}):null,K.isVisible(`remain`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums ${o!==null&&o<0&&i!==`done`&&i!==`cancelled`?`font-medium text-[#c02a26]`:`text-stone-500`}`,children:s}):null,K.isVisible(`note`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(nt,{value:r.note,onChange:t=>Dt(e.id,`note`,t),onCommit:()=>void Mt(e.id),onCancel:()=>Y(e.id)})}):null,K.isVisible(`createdAt`)?(0,F.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:m(e.createdAt)}):null,K.isVisible(`updatedAt`)?(0,F.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:m(e.updatedAt)}):null,(0,F.jsx)(`td`,{"aria-hidden":`true`}),(0,F.jsx)(`td`,{className:ue,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>vt({item:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,F.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,F.jsx)(`path`,{d:`M14 4h6v6`}),(0,F.jsx)(`path`,{d:`M20 4 13 11`}),(0,F.jsx)(`path`,{d:`M10 20H4v-6`}),(0,F.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,F.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>mt([e]),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,F.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,F.jsx)(`path`,{d:`M3 6h18`}),(0,F.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,F.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,F.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),t?null:V?.groupKey===e.key?(0,F.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:e.items.length+1}),(0,F.jsx)(`td`,{className:pe,children:(0,F.jsx)(`input`,{autoFocus:!0,value:V.title,disabled:ht,placeholder:`输入待办名称,回车或点空白处保存`,onChange:e=>H(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),Pt()):e.key===`Escape`&&(e.preventDefault(),H(null))},className:`h-8 w-full truncate rounded-md border border-[#4176e6]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#4176e6]`})}),K.isVisible(`status`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(p,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Ge,value:V.status,onChange:e=>H(t=>t&&{...t,status:e,statusManual:!0}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#4176e6]/30 ${ze[V.status]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`truncate`,children:C[V.status]})})}):null,K.isVisible(`task`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,F.jsx)(p,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:Ot,value:V.taskId,onChange:e=>H(t=>{if(!t)return t;let n=D.find(t=>t.id===e);return{...t,taskId:e,...n?{priority:n.priority}:{}}}),triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>{let e=D.find(e=>e.id===V.taskId);return(0,F.jsx)(re,{text:e?.title||`未关联`,className:`min-w-0 truncate ${e?`text-stone-800`:`text-stone-300`}`})}}):(0,F.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:`任务管理插件未启用`})}):null,K.isVisible(`priority`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(()=>{let e=D.find(e=>e.id===V.taskId);return e?(0,F.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${I[e.priority]??`text-stone-300`}`,children:e.priority?E[e.priority]:R}):(0,F.jsx)(p,{unstyled:!0,fitContent:!!V.priority,hideChevron:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ke,value:V.priority,onChange:e=>H(t=>t&&{...t,priority:e}),triggerClassName:V.priority?Je:qe,renderTrigger:()=>V.priority?(0,F.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${I[V.priority]}`,children:E[V.priority]}):(0,F.jsx)(`span`,{className:`truncate text-stone-400`,children:R})})})()}):null,K.isVisible(`start`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(g,{value:V.startDate,onChange:e=>H(t=>{if(!t)return t;let n=e,r={...t,startDate:n};if(!t.statusManual&&!b(t.status)){let e=x(n,t.dueDate);e&&(r.status=e)}return r.dueDate&&r.dueDate<w()&&!b(r.status)&&(r.status=`overdue`,r.statusManual=!1),r}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white`})}):null,K.isVisible(`due`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(g,{value:V.dueDate,onChange:e=>H(t=>{if(!t)return t;let n=e,r={...t,dueDate:n};if(!t.statusManual&&!b(t.status)){let e=x(t.startDate,n);e&&(r.status=e)}return n&&n<w()&&!b(r.status)&&(r.status=`overdue`,r.statusManual=!1),r}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white`})}):null,K.isVisible(`end`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:b(V.status)?(0,F.jsx)(`span`,{className:`text-stone-500`,children:ie(w())}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}):null,K.isVisible(`cycle`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}):null,K.isVisible(`remain`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}):null,K.isVisible(`note`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(`input`,{value:V.note,disabled:ht,placeholder:`—`,onChange:e=>H(t=>t&&{...t,note:e.target.value}),className:`h-8 w-full truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors placeholder:text-stone-300 hover:border-stone-200 focus:border-[#4176e6] focus:bg-white`})}):null,K.isVisible(`createdAt`)?(0,F.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-400`,children:`—`}):null,K.isVisible(`updatedAt`)?(0,F.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-400`,children:`—`}):null,(0,F.jsx)(`td`,{"aria-hidden":`true`}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`})]}):(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`td`,{className:`px-2 py-0.5`}),(0,F.jsx)(`td`,{className:`px-1 py-0.5`}),(0,F.jsx)(`td`,{className:`px-1 py-0.5`,colSpan:Math.max(xt-2,1),children:(0,F.jsxs)(`button`,{type:`button`,disabled:ht,onClick:()=>Nt(e),className:`flex items-center gap-1 rounded px-1 py-0.5 text-xs text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[(0,F.jsx)(`span`,{className:`text-sm leading-none`,children:`+`}),`新增记录`]})})]})]},e.key)}),Rt.length===0?(0,F.jsx)(`tbody`,{children:(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:xt,className:`px-3 py-16 text-center text-sm text-stone-400`,children:s.length===0?`还没有待办`:`没有匹配的待办,试试调整搜索或筛选`})})}):null]})}),(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,F.jsxs)(`span`,{children:[`共 `,Q.length,` 条`,zt.length?` · 已选 ${zt.length}`:``]}),(0,F.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`点击单元格直接编辑,回车或点空白处保存`})]}),(0,F.jsx)(it,{open:_t!==null,item:_t?.item??null,preset:_t?.preset,tasks:D,tasksOn:k,onClose:()=>vt(null),onSaved:J}),(0,F.jsx)(c,{open:U!=null,title:U&&U.length>1?`批量删除`:`删除待办`,message:U&&U.length>1?`确认删除已选中的 ${U.length} 条待办?此操作不可恢复。`:`删除「${U?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>mt(null),onConfirm:()=>void Ft()})]}):(0,F.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,F.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:l(`todos`)}):(0,F.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,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{z as default};
|