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,4 +1,4 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,i as r,n as i,r as a,t as o}from"./dialog.XgRGNF_Q.js";import{p as s,w as c}from"./business-map.BiJ85oxm.js";import{i as l,p as u}from"./app-config.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,i as r,n as i,r as a,t as o}from"./dialog.XgRGNF_Q.js";import{p as s,w as c}from"./business-map.BiJ85oxm.js";import{i as l,p as u}from"./app-config.BSO5r82v.js";import"./settings.BojKNwUC.js";import{t as d}from"./jsx-runtime.DUg_B_vD.js";import{a as f,c as p,i as m,n as h,t as g}from"./plugins.ChGmBEkF.js";import{I as _,v}from"./pm.BXmOiFfW.js";import{n as y,o as b}from"./view-prefs.CWc5cQ2q.js";import{n as x,t as S}from"./SelectDropdown.D7IeyHDI.js";import{showToast as C}from"./Toast.BydY-X7T.js";import{f as w}from"./case-exec.BMNk9OyF.js";import{rt as T}from"./req-analysis.efWkT7Gv.js";import{n as E,o as D,s as O}from"./space-skills.CPucW8zt.js";import{t as k}from"./case-prompt.ByLTgz4r.js";import{N as A,P as j}from"./case-review.BodP2jKm.js";import{s as M}from"./fs-tools.3F9MFrLf.js";import{s as ee,w as N}from"./tasks.DEyD8pmq.js";import{S as te,a as P,c as F,d as I,f as L,i as R,l as z,n as B,r as V}from"./mcp-tools.Kf-lupGn.js";import{r as ne}from"./prompts-meta.VAjE4OET.js";import{o as H}from"./report-prompt.CwHuOcRN.js";import{a as U}from"./test-stats.Cf3_L4wu.js";import{d as W}from"./test-points.BSfPfq8z.js";import{o as G}from"./story-review.Dm9VcR6v.js";import{i as re}from"./ui-auto-prompt.BmO3ja2m.js";import{n as ie}from"./test-reports.0gr6-c_0.js";var K=e(t(),1),q=d(),ae=`mcp.list.cache`;function oe(){try{let e=sessionStorage.getItem(u(ae));if(!e)return null;let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function se(e){try{sessionStorage.setItem(u(ae),JSON.stringify(e))}catch{}}function ce(e){return e?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`
|
|
2
2
|
`):``}function J(e){let t={};for(let n of e.split(`
|
|
3
3
|
`)){let e=n.trim();if(!e||e.startsWith(`#`))continue;let r=e.indexOf(`=`);r<=0||(t[e.slice(0,r).trim()]=e.slice(r+1).trim())}return Object.keys(t).length?t:void 0}function Y(e){let t={};return e.authHeader.trim()&&(t.Authorization=e.authHeader.trim()),{name:e.name.trim()||(e.mode===`tencent`?B.name:`mcp`),transport:e.transport,command:e.command,args:e.argsText.trim().split(/\s+/).filter(Boolean),env:J(e.envText),url:e.url,headers:Object.keys(t).length?t:void 0}}function le(e=`create`){let t=e===`tencent`?{mode:e,view:`form`,name:B.name,transport:`http`,url:B.url,command:``,argsText:``,authHeader:``,envText:``,jsonText:``}:{mode:e,view:`form`,name:``,transport:`http`,url:``,command:``,argsText:``,authHeader:``,envText:``,jsonText:``};return{...t,jsonText:I(Y(t))}}function ue(e){let t={mode:`edit`,view:`form`,previousName:e.name,name:e.name,transport:e.transport===`stdio`?`stdio`:`http`,url:e.url||``,command:e.command||``,argsText:Array.isArray(e.args)?e.args.join(` `):``,authHeader:e.headers?.Authorization||e.headers?.authorization||``,envText:ce(e.env),jsonText:``};return t.jsonText=I(Y(t)),t}function de(e,t){return{...e,name:t.name,transport:t.transport,command:t.command||``,argsText:Array.isArray(t.args)?t.args.join(` `):``,envText:ce(t.env),url:t.url||``,authHeader:t.headers?.Authorization||t.headers?.authorization||``}}function fe({onServersChange:e}){let[t,r]=(0,K.useState)(()=>oe()),[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)([]),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(null),[_,v]=(0,K.useState)(null),y=(0,K.useRef)(null);_&&(y.current=_);let b=_??y.current,[x,S]=(0,K.useState)(null),w=(0,K.useRef)(null);x&&(w.current=x);let T=x??w.current,E=(0,K.useRef)(!1),D=(0,K.useCallback)(async()=>{E.current&&f(!0);try{let e=await P();r(e.servers),se(e.servers),c(e.path||``),u(e.errors||(e.error?[e.error]:[])),E.current=!0}finally{f(!1)}},[]);(0,K.useEffect)(()=>{D()},[D]);function O(e){if(!_||_.view===e)return;if(e===`json`){v({..._,view:`json`,jsonText:I(Y(_))});return}let t=F(_.jsonText);t.ok?t.servers.length>1&&_.mode===`edit`?C(`编辑时 JSON 里请只保留一台服务器`,`error`):v({...de(_,t.servers[0]),view:`form`,jsonText:_.jsonText}):C(t.error,`error`)}async function k(){if(_){m(!0);try{let e;if(_.view===`json`){let t=F(_.jsonText);if(!t.ok){C(t.error,`error`);return}if(t.servers.length>1&&_.mode===`edit`){C(`编辑时 JSON 里请只保留一台服务器`,`error`);return}e=t.servers}else{let t=Y(_),n=t.name.trim();if(!n){C(`请填写名称`,`error`);return}if(_.mode===`tencent`&&!_.authHeader.trim()){C(`请粘贴腾讯文档 MCP Token`,`error`);return}if(t.transport===`stdio`&&!t.command.trim()){C(`stdio 需要填写 command`,`error`);return}if(t.transport===`http`&&!t.url.trim()){C(`HTTP 需要填写 URL`,`error`);return}e=[t.transport===`stdio`?{name:n,transport:`stdio`,command:t.command.trim(),args:t.args,env:t.env}:{name:n,transport:`http`,url:t.url.trim(),headers:t.headers}]}let t=``;for(let n=0;n<e.length;n++){let r=e[n],i=_.mode===`edit`&&n===0?_.previousName:void 0,a=await L(r,i);if(!a.ok){t=a.error||`保存失败`;break}}if(t){C(t,`error`),await D();return}v(null),C(e.length>1?`已保存 ${e.length} 台并重新连接`:`已保存并重新连接`,`success`),await D()}finally{m(!1)}}}async function A(e){m(!0);try{let t=await V(e);if(!t.ok){C(t.error||`删除失败`,`error`);return}r(t=>{let n=(t??[]).filter(t=>t.name!==e);return se(n),n}),S(null),C(`已删除`,`success`),await D()}finally{m(!1)}}async function j(e){e?g(e):m(!0);try{let t=await z(e);if(!t.ok){C(t.error||`连接失败`,`error`);return}let n=t.errors?.find(t=>!e||t.startsWith(`${e}:`));if(n)C(n,`error`);else if(e){let n=t.connected?.includes(e);C(n?`「${e}」已连接`:`「${e}」未连上`,n?`success`:`error`)}else t.errors?.length?C(t.errors[0],`error`):C(e?`已重新连接`:`刷新成功`,`success`);await D()}finally{g(null),m(!1)}}let M=(0,K.useMemo)(()=>{if(t===null)return[{name:B.name,displayName:`腾讯文档`,transport:`http`,url:B.url,booting:!0,connected:!1,toolCount:0}];let e=t.some(e=>e.name===B.name),n=t.filter(e=>e.name!==B.name);return[e?{...t.find(e=>e.name===B.name),displayName:`腾讯文档`}:{name:B.name,displayName:`腾讯文档`,transport:`http`,url:B.url,pending:!0,connected:!1,toolCount:0},...n]},[t]);return(0,K.useEffect)(()=>{e?.(M.length)},[M.length,e]),(0,q.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,disabled:p||d,onClick:()=>v(le(`create`)),className:`h-8 rounded-lg bg-[#4176e6] px-3 text-[13px] font-medium text-white hover:bg-[#3566cc] disabled:opacity-60`,children:`添加 MCP`}),(0,q.jsx)(`button`,{type:`button`,disabled:p||d,onClick:()=>void j(),className:`h-8 rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-600 hover:bg-stone-50 disabled:opacity-60`,children:d&&!h?`刷新中…`:`刷新连接`}),s?(0,q.jsx)(`span`,{className:`ml-auto max-w-full truncate font-mono text-[11px] text-stone-400`,title:s,children:s}):null]}),l.length?(0,q.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] leading-5 text-amber-800`,children:l.map(e=>(0,q.jsx)(`p`,{children:e},e))}):null,(0,q.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-stone-200 bg-white`,children:(0,q.jsxs)(`table`,{className:`w-full min-w-[640px] border-collapse text-left text-[13px]`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{className:`border-b border-stone-100 bg-stone-50/80 text-[12px] text-stone-500`,children:[(0,q.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:`名称`}),(0,q.jsx)(`th`,{className:`w-20 px-3 py-2.5 font-medium`,children:`类型`}),(0,q.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:`地址 / 命令`}),(0,q.jsx)(`th`,{className:`w-16 px-3 py-2.5 font-medium tabular-nums`,children:`工具`}),(0,q.jsx)(`th`,{className:`w-24 px-3 py-2.5 font-medium`,children:`状态`}),(0,q.jsx)(`th`,{className:`w-32 px-3 py-2.5 font-medium text-right`,children:`操作`})]})}),(0,q.jsx)(`tbody`,{children:M.map(e=>{let t=e.transport===`stdio`?[e.command,...e.args||[]].filter(Boolean).join(` `):e.url||``;return(0,q.jsxs)(`tr`,{className:`border-b border-stone-100 last:border-b-0 hover:bg-stone-50/70`,children:[(0,q.jsxs)(`td`,{className:`max-w-[10rem] px-3 py-2.5`,children:[(0,q.jsx)(`div`,{className:`truncate font-medium text-stone-900`,children:e.displayName||e.name}),(0,q.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-stone-400`,children:[e.name,e.booting?``:e.pending?` · 待配置`:e.hasSecrets?` · 已配置密钥`:``]})]}),(0,q.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,q.jsx)(`span`,{className:`rounded border border-stone-200 px-1.5 py-0.5 text-[11px] uppercase text-stone-400`,children:e.transport})}),(0,q.jsx)(`td`,{className:`max-w-[18rem] px-3 py-2.5`,children:(0,q.jsx)(`span`,{className:`block truncate font-mono text-[12px] text-stone-500`,title:t,children:t||`—`})}),(0,q.jsx)(`td`,{className:`px-3 py-2.5 tabular-nums text-stone-600`,children:e.pending||e.booting?`—`:e.toolCount??0}),(0,q.jsx)(`td`,{className:`px-3 py-2.5`,children:e.booting?(0,q.jsx)(`span`,{className:`rounded-md bg-stone-100 px-2 py-0.5 text-[12px] text-stone-500`,children:`同步中…`}):e.pending?(0,q.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>v(le(`tencent`)),className:`rounded-md bg-amber-50 px-2 py-0.5 text-[12px] text-amber-700 hover:bg-amber-100`,children:`需配置`}):(0,q.jsx)(`button`,{type:`button`,disabled:p||h!==null||d,onClick:()=>void j(e.name),className:`rounded-md px-2 py-0.5 text-[12px] transition-colors ${h===e.name?`bg-sky-50 text-sky-700`:e.connected?`bg-emerald-50 text-emerald-700 hover:bg-emerald-100`:`bg-stone-100 text-stone-600 hover:bg-[#4176e6]/10 hover:text-[#4176e6]`} disabled:opacity-60`,children:h===e.name?`连接中…`:e.connected?`已连接`:`连接`})}),(0,q.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,q.jsx)(`button`,{type:`button`,disabled:p||!!e.booting,onClick:()=>v(e.pending?le(`tencent`):ue(e)),className:`text-[13px] text-[#4176e6] hover:underline disabled:opacity-60`,children:e.pending?`配置`:`编辑`}),e.pending||e.booting?null:(0,q.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>S(e.name),className:`text-[13px] text-rose-600 hover:underline disabled:opacity-60`,children:`删除`})]})})]},e.name)})})]})}),(0,q.jsxs)(a,{open:!!_,onClose:()=>{p||v(null)},className:`relative z-110`,children:[(0,q.jsx)(o,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,q.jsx)(n,{transition:!0,className:`tw-dialog-panel-anim flex max-h-[85vh] w-full max-w-lg flex-col rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:b?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(i,{className:`text-[15px] font-semibold text-stone-900`,children:b.mode===`tencent`?`配置腾讯文档 MCP`:b.mode===`edit`?`编辑 MCP`:`添加 MCP`}),b.mode===`tencent`?(0,q.jsx)(`p`,{className:`mt-1.5 text-[12px] leading-5 text-stone-500`,children:`在腾讯文档空间菜单「使用 MCP」复制 Token,粘贴到下方。Token 约一年有效,有日调用限额。`}):b.view===`json`?(0,q.jsx)(`p`,{className:`mt-1.5 text-[12px] leading-5 text-stone-500`,children:`可粘贴 Trae / Claude Desktop 的 mcpServers JSON,也支持灵光 servers[]。`}):null]}),(0,q.jsxs)(`div`,{className:`tw-plugins-pills shrink-0`,role:`group`,"aria-label":`编辑方式`,children:[(0,q.jsx)(`button`,{type:`button`,"aria-pressed":b.view===`form`,onClick:()=>O(`form`),children:`表单`}),(0,q.jsx)(`button`,{type:`button`,"aria-pressed":b.view===`json`,onClick:()=>O(`json`),children:`JSON`})]})]}),b.view===`json`?(0,q.jsx)(`div`,{className:`mt-4 min-h-0 flex-1`,children:(0,q.jsx)(`textarea`,{value:b.jsonText,onChange:e=>_&&v({..._,jsonText:e.target.value}),spellCheck:!1,className:`h-72 w-full resize-y rounded-lg border border-stone-200 bg-stone-50 px-3 py-2 font-mono text-[12px] leading-5 text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`{
|
|
4
4
|
"mcpServers": {
|
|
@@ -15,4 +15,4 @@ import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,i as r,n as i,r as a,t a
|
|
|
15
15
|
}`),[ee,N]=(0,K.useState)(``),[te,P]=(0,K.useState)(!1),[F,I]=(0,K.useState)(``),[L,R]=(0,K.useState)(``);async function z(){let t=await D(`list`);s(t.skills),e?.(new Set(t.skills.map(e=>e.group)).size)}(0,K.useEffect)(()=>{let t=!0;return D(`migrate`).then(()=>D(`list`)).then(n=>{t&&(s(n.skills),e?.(new Set(n.skills.map(e=>e.group)).size));let r=new URLSearchParams(location.search),i=r.get(`file`)||r.get(`path`),a=n.skills.find(e=>e.id===r.get(`skill`)||!!i&&e.legacyPath===i);t&&a&&B(a.id)}).catch(e=>{t&&h(String(e.message||e))}).finally(()=>{t&&y(!1)}),()=>{t=!1}},[e]);async function B(e){h(``),N(``);try{let[{skill:t},n]=await Promise.all([D(`read`,{id:e}),D(`history`,{id:e})]);l(t),T(n.versions),O(n.versions[0]?.toString()||``),x(`rules`),P(!1)}catch(e){h(e instanceof Error?e.message:String(e))}}async function V(e){_(!0),h(``);try{await e()}catch(e){h(e instanceof Error?e.message:String(e))}finally{_(!1)}}async function ne(e,t){A(e),h(``);try{await D(`set-enabled`,{group:e,enabled:t}),await z()}catch(e){h(e instanceof Error?e.message:String(e))}finally{A(``)}}let H=t.filter(e=>{let t=e.pluginRefs?.length?e.pluginRefs:e.owner?[e.owner]:[];return(!u||t.includes(u))&&`${e.name} ${e.variant} ${e.description} ${t.map(me).join(` `)}`.toLowerCase().includes(f.toLowerCase())}),U=[...new Set(H.map(e=>e.group))],W=c?t.filter(e=>e.group===c.group):[],G=c?.pluginRefs?.length?c.pluginRefs:c?.owner?[c.owner]:[],re=c?.system??!!G.length,ie=W.find(e=>!e.description.startsWith(`旧版变体`))?.description||c?.description||``;return(0,q.jsxs)(`section`,{className:`min-h-0 flex-1 overflow-auto p-5 text-(--tw-label-primary)`,children:[(0,q.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`text-xs text-(--tw-label-tertiary)`,children:[U.length,` 个技能 · `,H.length,` 个内部变体`]}),(0,q.jsx)(`label`,{className:`ml-auto min-w-0`,children:(0,q.jsx)(`input`,{className:Q+` h-9 py-1`,"aria-label":`搜索技能`,placeholder:`搜索技能或变体…`,autoComplete:`off`,value:f,onChange:e=>p(e.target.value)})}),(0,q.jsx)(`button`,{className:Z,onClick:()=>{P(!0),l(null),I(``),R(``)},children:`新建技能`}),(0,q.jsxs)(`label`,{className:Z+` cursor-pointer`,children:[`导入技能`,(0,q.jsx)(`input`,{className:`hidden`,type:`file`,accept:`.md,.json`,"aria-label":`导入技能文件`,disabled:g,onChange:e=>{let t=e.target.files?.[0];t&&(V(async()=>{if(t.size>2097152)throw Error(`文件超过2MB`);let e=await t.text(),n=t.name.endsWith(`.json`)?JSON.parse(e):{schemaVersion:1,name:t.name.replace(/\.md$/i,``),files:{"SKILL.md":e}},r=await D(`import`,{bundle:n});await z(),await B(r.skill.id),C(`技能已导入,脚本不会自动运行`,`success`)}),e.target.value=``)}})]})]}),(0,q.jsx)(`p`,{className:`mb-4 text-xs text-(--tw-label-secondary)`,children:`技能是独立能力包,包含业务规则、流程和资源。已关联业务的技能默认启用且保持常驻;未关联业务的自定义技能可独立启停。 加载技能不会自动执行脚本。`}),u?(0,q.jsxs)(`p`,{className:`mb-3 text-xs text-(--tw-label-secondary)`,children:[`当前仅显示推荐给该功能的技能。`,(0,q.jsx)(`button`,{className:`ml-2 text-(--tw-accent)`,onClick:()=>{d(``);let e=new URL(location.href);e.searchParams.delete(`owner`),history.replaceState(null,``,e)},children:`查看全部技能`})]}):null,m?(0,q.jsxs)(`div`,{role:`alert`,className:`mb-3 rounded-lg border border-red-300 p-3 text-sm text-red-600`,children:[m,(0,q.jsx)(`button`,{className:`ml-3 underline`,onClick:()=>void V(async()=>{await D(`migrate`),await z()}),children:`重试加载`})]}):null,v?(0,q.jsx)(`p`,{role:`status`,children:`正在准备当前空间技能…`}):null,!v&&H.length?(0,q.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-semibold`,children:`已安装`}),(0,q.jsx)(`span`,{className:`text-xs text-(--tw-label-tertiary)`,children:U.length})]}):null,te?(0,q.jsxs)(`div`,{className:`mb-4 space-y-3 rounded-xl border border-(--tw-border) p-4`,children:[(0,q.jsx)(`h3`,{className:`font-semibold`,children:`新建技能`}),(0,q.jsx)(`input`,{"aria-label":`技能名称`,placeholder:`技能名称`,className:Q,value:F,onChange:e=>I(e.target.value)}),(0,q.jsx)(`textarea`,{"aria-label":`技能业务规则`,placeholder:`填写提示词和业务规则;创建后可以继续维护流程。`,className:Q,rows:8,value:L,onChange:e=>R(e.target.value)}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`button`,{className:Z,disabled:g||!F.trim()||!L.trim(),onClick:()=>void V(async()=>{let e=await D(`create`,{name:F,content:L});await z(),await B(e.skill.id),C(`技能已创建`,`success`)}),children:`创建`}),(0,q.jsx)(`button`,{className:Z,onClick:()=>P(!1),children:`取消`})]})]}):null,c?(0,q.jsxs)(a,{open:!0,onClose:()=>l(null),className:`relative z-110`,children:[(0,q.jsx)(o,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/35`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,q.jsxs)(n,{transition:!0,className:`tw-dialog-panel-anim flex max-h-[min(88vh,900px)] w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-(--tw-border) bg-(--tw-surface-panel) shadow-2xl`,children:[(0,q.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-(--tw-border) p-5`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(i,{as:`h2`,className:`text-lg font-semibold`,children:c.name}),(0,q.jsxs)(`span`,{className:`rounded-full border border-(--tw-border) px-2 py-0.5 text-[11px] text-(--tw-label-tertiary)`,children:[`v`,c.version]})]}),(0,q.jsx)(r,{className:`mt-1 max-w-3xl text-sm leading-6 text-(--tw-label-secondary)`,children:ie}),(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`rounded-full border border-(--tw-border) px-2 py-0.5 text-[11px] text-(--tw-label-tertiary)`,children:re?`系统技能`:`用户技能`}),(0,q.jsxs)(`span`,{className:`rounded-full border border-(--tw-border) px-2 py-0.5 text-[11px] text-(--tw-label-tertiary)`,children:[W.length,` 个变体`]}),G.map(e=>(0,q.jsxs)(`span`,{className:`rounded-full bg-(--tw-accent-soft) px-2 py-0.5 text-[11px] text-(--tw-accent)`,children:[`推荐给 `,me(e)]},e))]}),(0,q.jsx)(`div`,{className:`mt-2`,children:c.kind===`foundation`?(0,q.jsx)(`span`,{className:`text-xs text-(--tw-label-tertiary)`,children:`当前空间常驻规则,无需重复关联`}):(0,q.jsx)(`a`,{className:`text-xs text-(--tw-accent)`,href:`/workbench/?skill=${encodeURIComponent(`space:`+c.id)}`,children:`在工作台使用此技能`})})]}),(0,q.jsx)(`button`,{"aria-label":`关闭技能详情`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-xl leading-none text-(--tw-label-tertiary) hover:bg-(--tw-surface-recessed) hover:text-(--tw-label-primary)`,onClick:()=>l(null),children:`✕`})]}),(0,q.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-5`,children:[W.length>1?(0,q.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3 rounded-lg border border-(--tw-border) p-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`block text-xs font-medium`,children:`当前变体`}),(0,q.jsx)(`span`,{className:`block text-xs text-(--tw-label-tertiary)`,children:`同一技能的规则或场景配置,编辑和版本独立保存。`})]}),(0,q.jsx)(S,{compact:!0,ariaLabel:`选择技能变体`,value:c.id,onChange:e=>void B(e),options:W.map(e=>({value:e.id,label:e.variant})),className:`w-full sm:w-72`})]}):null,(0,q.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:[[`rules`,`业务规则`],[`workflow`,`流程`],[`resources`,`资源与关联`],[`validate`,`输出校验`]].map(([e,t])=>(0,q.jsx)(`button`,{className:Z+(b===e?` bg-(--tw-accent-soft) text-(--tw-accent)`:``),onClick:()=>x(e),children:t},e))}),b===`rules`?(0,q.jsx)(`textarea`,{"aria-label":`编辑技能业务规则`,className:Q+` font-mono`,rows:14,value:c.content,onChange:e=>l({...c,content:e.target.value})}):null,b===`workflow`?(0,q.jsx)(`textarea`,{"aria-label":`编辑技能流程`,className:Q+` font-mono`,rows:14,value:c.instructions,onChange:e=>l({...c,instructions:e.target.value})}):null,b===`resources`?(0,q.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,q.jsx)(`p`,{children:c.description}),(0,q.jsxs)(`p`,{children:[`推荐给:`,G.length?G.map(me).join(`、`):`未关联业务插件`]}),(0,q.jsxs)(`p`,{children:[`当前变体:`,c.variant]}),(0,q.jsxs)(`p`,{children:[`兼容旧引用:`,c.legacyPath||`无`]}),c.resources.map(e=>(0,q.jsx)(`p`,{className:`font-mono text-xs`,children:e},e)),(0,q.jsx)(`p`,{className:`text-xs text-(--tw-label-secondary)`,children:`原文件作为迁移备份保留;业务读取与本页编辑使用同一份技能正文。校验脚本可独立读取标准输入 JSON;不会自动运行。`}),(0,q.jsx)(`button`,{className:Z,onClick:()=>{let e=new Blob([c.instructions+`
|
|
16
16
|
|
|
17
17
|
## 业务规则
|
|
18
|
-
`+c.content],{type:`text/markdown`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=c.id+`-SKILL.md`,n.click(),URL.revokeObjectURL(t)},children:`导出技能说明`}),(0,q.jsx)(`button`,{className:Z,disabled:g,onClick:()=>void V(async()=>{let e=await D(`export`,{id:c.id}),t=URL.createObjectURL(new Blob([JSON.stringify(e.bundle,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=c.id+`.json`,n.click(),URL.revokeObjectURL(t)}),children:`导出完整技能包`})]}):null,b===`validate`?(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(`p`,{className:`text-xs text-(--tw-label-secondary)`,children:`校验已有输出,不调用模型、不写业务数据。填写 rows、模板 columns、合法 sourceIds,可选 enums、stats。未提供的检查条件会明确提示。`}),(0,q.jsx)(`textarea`,{"aria-label":`输出校验JSON`,className:Q+` font-mono`,rows:9,value:j,onChange:e=>M(e.target.value)}),(0,q.jsx)(`button`,{className:Z,disabled:g,onClick:()=>void V(async()=>{let e=await D(`validate`,{id:c.id,input:JSON.parse(j)});N(JSON.stringify(e,null,2))}),children:`运行校验`}),ee?(0,q.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-(--tw-surface-recessed) p-3 text-xs`,role:`status`,children:ee}):null]}):null]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-(--tw-border) p-4`,children:[(0,q.jsx)(`button`,{className:Z+` bg-(--tw-accent) text-white`,disabled:g,onClick:()=>void V(async()=>{let e=await D(`save`,{id:c.id,patch:{content:c.content,instructions:c.instructions,hash:c.hash}});l(e.skill),await z();let t=await D(`history`,{id:c.id});T(t.versions),O(t.versions[0]?.toString()||``),C(`技能已保存,后续任务使用新版本`,`success`)}),children:`保存技能`}),w.length?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(S,{compact:!0,ariaLabel:`历史技能版本`,value:E,onChange:O,options:w.map(e=>({value:String(e),label:`恢复到 v${e}`}))}),(0,q.jsx)(`button`,{className:Z,disabled:g||!E,onClick:()=>void V(async()=>{await B((await D(`restore`,{id:c.id,version:Number(E),hash:c.hash})).skill.id),await z(),C(`已恢复内容并创建新版本`,`success`)}),children:`恢复版本`})]}):null]})]})})]}):null,!v&&!H.length?(0,q.jsx)(`p`,{className:`p-8 text-center text-sm text-(--tw-label-tertiary)`,children:`没有匹配的技能,可以新建或调整搜索词。`}):null,(0,q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3`,children:U.map(e=>{let t=H.filter(t=>t.group===e),n=t[0],r=t.find(e=>!e.description.startsWith(`旧版变体`))||n,i=t.every(e=>e.enabled),a=!i&&t.some(e=>e.enabled),o=t.some(e=>e.foundation),s=t.some(e=>e.pluginRefs?.length>0||!!e.owner),c=o||s,l=[...new Set(t.flatMap(e=>e.pluginRefs?.length?e.pluginRefs:e.owner?[e.owner]:[]))];return(0,q.jsx)(`article`,{className:`min-w-0 cursor-pointer rounded-xl border border-(--tw-border) bg-(--tw-surface-panel) p-4 transition-colors hover:border-(--tw-accent)`,onClick:e=>{e.target.closest(`button, a`)||B(r.id)},children:(0,q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,q.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-start gap-3 text-left`,"aria-haspopup":`dialog`,onClick:()=>void B(r.id),children:[(0,q.jsx)(pe,{}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`block truncate font-semibold`,children:r.name}),(0,q.jsx)(`span`,{className:`mt-1 line-clamp-2 block text-sm leading-5 text-(--tw-label-secondary)`,children:r.description}),(0,q.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-(--tw-label-tertiary)`,children:[(0,q.jsxs)(`span`,{className:`rounded-full border border-(--tw-border) px-2 py-0.5`,children:[t.length,` 个变体`]}),l.map(e=>(0,q.jsx)(`span`,{className:`rounded-full border border-(--tw-border) px-2 py-0.5`,children:me(e)},e)),c?(0,q.jsx)(`span`,{className:`rounded-full border border-(--tw-border) px-2 py-0.5`,children:`常驻启用`}):null]})]})]}),(0,q.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a?`mixed`:i,"aria-busy":k===e||void 0,"aria-label":o?`${r.name} 空间基础规则常驻启用`:s?`${r.name} 已关联业务,常驻启用`:`${i?`停用`:`启用`} ${r.name}`,title:o?`空间基础规则常驻,不能停用`:s?`已关联业务,不能停用`:void 0,className:`tw-toggle disabled:cursor-not-allowed disabled:opacity-45`,disabled:k===e||c,onClick:t=>{t.stopPropagation(),ne(e,!i)},children:(0,q.jsx)(`span`,{className:`tw-toggle-knob`})})]})},e)})})]})}var ge=[`extensions`,`mcp`,`skills`],_e=[{id:`extensions`,label:`扩展插件`},{id:`mcp`,label:`MCP`},{id:`skills`,label:`技能(Skill)`}],ve={tasks:`侧栏「任务管理」按状态列出任务;工作台可直接增删改`,todos:`侧栏「待办事项」按状态 / 紧急程度分组;工作台可直接增删改`,projects:`侧栏「项目列表」管理项目并汇总迭代 / 需求 / 缺陷;工作台可直接增删改`,iterations:`侧栏「迭代管理」按项目维护迭代周期、进度与逾期;工作台可直接增删改`,pmRequirements:`侧栏「需求管理」维护需求编号 / 优先级 / 状态与验收标准;工作台可直接增删改`,bugs:`侧栏「缺陷管理」记录严重程度 / 重现步骤与修复状态;工作台可直接增删改`,testStats:`侧栏「测试统计」按维度记录每天的统计数量`,caseExec:`侧栏「用例执行统计」按项目记录用例执行情况`,businessMap:`侧栏「业务地图」维护系统功能与业务流程,并审核 AI 识别提案`,dashboard:`侧栏「仪表盘」聚合待办 / 任务 / 测试统计;卡片可拖动排序、拖角改宽高,右上角编辑组件`},$={tasks:ee,todos:N,projects:v,iterations:v,pmRequirements:v,bugs:v,testStats:U,caseExec:w,businessMap:s,dashboard:N},ye=[{id:`all`,label:`全部`},{id:`on`,label:`已启用`},{id:`off`,label:`未启用`}],be=h();function xe({embedded:e=!1}){let[t,n]=(0,K.useState)(()=>(()=>{let e=new URLSearchParams(location.search).get(`tab`);return ge.includes(e)?e:y(`plugins.pageTab`,ge,`extensions`)})()),[r,i]=(0,K.useState)(()=>m()),[a,o]=(0,K.useState)(null),[s,u]=(0,K.useState)(null),[d,h]=(0,K.useState)(null),[v,x]=(0,K.useState)(!0),[S,w]=(0,K.useState)(``),[D,ee]=(0,K.useState)(`all`),[N,P]=(0,K.useState)(null),[F,I]=(0,K.useState)({}),[L,z]=(0,K.useState)(null),[B,V]=(0,K.useState)(null);function U(e){n(e);let t=new URL(location.href);t.searchParams.set(`tab`,e),history.replaceState(null,``,t),b(`plugins.pageTab`,e)}async function ae(){x(!0);try{let[e,t,n,r,i,a,s,c,l,d,f,p]=await Promise.all([te(),M(),$.tasks(),$.todos(),$.projects(),$.iterations(),$.pmRequirements(),$.bugs(),$.testStats(),$.caseExec(),$.businessMap(),$.dashboard()]);o(e),u(t),h({tasks:n,todos:r,projects:i,iterations:a,pmRequirements:s,bugs:c,testStats:l,caseExec:d,businessMap:f,dashboard:p})}finally{x(!1)}}(0,K.useEffect)(()=>{let e=f(e=>i(e));return l().then(()=>{i(m()),ae()}),R().then(e=>{e?.ok&&z(e.serversConfigured??0)}),E().then(V).catch(()=>V(null)),()=>{e()}},[]),(0,K.useEffect)(()=>{t===`mcp`&&R().then(e=>{e?.ok&&z(e.serversConfigured??0)})},[t]);function oe(e){if(e===`cases`)return{available:!0,detail:`侧栏「用例管理」浏览与维护本空间用例库`};if(e===`caseGen`)return r.cases?{available:!0,detail:`对话输入 / 打开配置面板,生成用例并写入用例库`}:{available:!1,detail:`需先启用「用例管理」,生成结果才能写入用例列表`};if(e===`knowledgeLib`)return{available:!0,detail:`侧栏「知识库管理」浏览与维护本空间知识库`};if(e===`requirements`)return{available:!0,detail:`侧栏「需求文档库」浏览与维护本空间需求文档`};if(e===`templates`)return{available:!0,detail:`侧栏「测试模板库」浏览与维护本空间用例模板`};if(e===`testReports`)return{available:!0,detail:`侧栏「报告管理」按功能 / 接口 / 性能归档报告,可关联技能并在会话中打开`};if(e===`reports`)return{available:!0,detail:`侧栏「工作汇报」按日报 / 周报 / 月报列出汇报文件`};if(e===`tasks`||e===`todos`||e===`projects`||e===`iterations`||e===`pmRequirements`||e===`bugs`||e===`testStats`||e===`caseExec`||e===`dashboard`){let t=d?.[e];return t===void 0?{available:v?null:!1,detail:v?`探测中…`:`需本地服务`}:t?{available:!0,detail:ve[e]}:{available:!1,detail:`需本地服务(npm run dev / lantern web)`}}return e===`knowledgeGen`?r.knowledgeLib?{available:!0,detail:`对话输入 / 打开配置面板,生成文档并写入知识库`}:{available:!1,detail:`需先启用「知识库管理」,生成结果才能写入知识库列表`}:e===`memory`?v&&a===null?{available:null,detail:`探测中…`}:a?.ok?{available:!0,detail:`已连接 · ${a.entryCount??a.entityCount??0} 条记忆 / 待确认 ${a.suggestionCount??0}`}:{available:!1,detail:`本地记忆服务未就绪`}:e===`knowledge`?{available:!0,detail:`对话输入 @ 可引用知识库与模板文档`}:e===`pluginDev`?v&&s===null?{available:null,detail:`探测中…`}:s?.ok?{available:!0,detail:`固定提示词开发扩展插件;先评估确认,再改代码并入「扩展插件」`}:{available:!1,detail:`需本地文件服务:开发要读写项目源码`}:{available:!1,detail:`未知`}}function se(e){let t=p(e,!r[e]),n=!!t[e],a=g.find(t=>t.id===e)?.name??e;i(t),O(e,n).catch(e=>C(`技能关联更新失败:${e instanceof Error?e.message:String(e)}`,`error`)),t.caseGen&&k().catch(e=>C(`用例生成技能没准备好:${e instanceof Error?e.message:String(e)}`,`error`)),t.testReports&&ie().catch(e=>C(`报告整理技能没准备好:${e instanceof Error?e.message:String(e)}`,`error`)),C(n?`已启用「${a}」`:`已停用「${a}」`,`success`),e===`reports`&&H(!!t.reports).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`工作汇报技能没准备好:${t}`,`error`)}),e===`uiAuto`&&re(!!t.uiAuto).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`自动化测试技能没准备好:${t}`,`error`)}),e===`reqAnalysis`&&T(!!t.reqAnalysis).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`需求分析技能没准备好:${t}`,`error`)}),e===`businessMap`&&c(!!t.businessMap).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`业务地图识别技能没准备好:${t}`,`error`)}),e===`storyReview`&&G(!!t.storyReview).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`用户故事审查技能没准备好:${t}`,`error`)}),e===`testPoints`&&W(!!t.testPoints).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`测试点生成技能没准备好:${t}`,`error`)}),(e===`caseReview`||e===`cases`)&&j(!!t.caseReview).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`用例质量评审技能没准备好:${t}`,`error`)}),(e===`caseBlindspot`||e===`cases`)&&A(!!t.caseBlindspot).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`场景遗漏补全技能没准备好:${t}`,`error`)}),(e===`projects`||e===`iterations`||e===`pmRequirements`||e===`bugs`)&&t[e]&&_().catch(e=>{console.warn(`[pm] 同步项目管理数据目录失败`,e)})}let ce=(0,K.useMemo)(()=>g.filter(e=>r[e.id]).length,[r]),J=S.trim().toLowerCase(),Y=(0,K.useMemo)(()=>be.map(e=>({...e,items:e.items.filter(e=>{let t=!J||e.name.toLowerCase().includes(J)||e.id.toLowerCase().includes(J)||e.description.toLowerCase().includes(J),n=D===`all`||(D===`on`?r[e.id]:!r[e.id]);return t&&n})})).filter(e=>e.items.length>0),[r,J,D]);return(0,q.jsx)(`div`,{className:`tw-plugins-page overflow-y-auto ${e?`h-full min-h-0 flex-1`:`min-h-screen`}`,children:(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-[1320px] ${e?`px-4 py-5`:`px-4 py-7 sm:px-5`}`,children:[(0,q.jsxs)(`header`,{className:`tw-plugins-head`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-[20px] font-semibold tracking-tight text-stone-900`,children:`插件仓库`}),(0,q.jsx)(`p`,{className:`mt-1.5 text-[13px] leading-6 text-stone-500`,children:t===`extensions`?(0,q.jsxs)(q.Fragment,{children:[`按用途分组的扩展能力,开关保存在本机;会话 / 全局内置能力在`,(0,q.jsx)(`span`,{className:`mx-1 rounded bg-stone-100 px-1 py-0.5 text-[12px] text-stone-600`,children:`设置 → 内置插件`}),`里查看。`]}):t===`skills`?(0,q.jsx)(q.Fragment,{children:`管理当前空间技能、业务规则、流程与资源,扩展插件启用时自动准备关联技能。`}):(0,q.jsxs)(q.Fragment,{children:[`管理当前数据空间的外接 MCP(写入`,(0,q.jsx)(`span`,{className:`mx-1 rounded bg-stone-100 px-1 py-0.5 font-mono text-[12px] text-stone-600`,children:`.lantern/local/mcp.json`}),`),对话里会出现对应工具。`]})})]}),(0,q.jsxs)(`div`,{className:`tw-plugins-stats`,"aria-label":`插件概览`,children:[(0,q.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,q.jsx)(`span`,{className:`tw-plugins-stat-num`,children:g.length}),(0,q.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`个插件`})]}),(0,q.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,q.jsx)(`span`,{className:`tw-plugins-stat-num is-on`,children:ce}),(0,q.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`已启用`})]}),(0,q.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,q.jsx)(`span`,{className:`tw-plugins-stat-num`,children:be.length}),(0,q.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`个分类`})]}),(0,q.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,q.jsx)(`span`,{className:`tw-plugins-stat-num`,children:L??`—`}),(0,q.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`MCP`})]})]})]}),(0,q.jsx)(`div`,{className:`tw-plugins-tabs`,role:`tablist`,"aria-label":`插件页分类`,children:_e.map(e=>(0,q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,className:t===e.id?`is-active`:void 0,onClick:()=>U(e.id),children:[e.label,(0,q.jsx)(`span`,{className:`tw-plugins-tab-count`,children:e.id===`extensions`?g.length:e.id===`mcp`?L??`—`:B??`—`})]},e.id))}),(0,q.jsx)(`div`,{className:`tw-plugins-tab-panel`,children:t===`skills`?(0,q.jsx)(he,{onCount:V}):t===`mcp`?(0,q.jsx)(fe,{onServersChange:z}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`tw-plugins-toolbar`,children:[(0,q.jsxs)(`label`,{className:`relative block w-full max-w-72`,children:[(0,q.jsxs)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-stone-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,children:[(0,q.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,q.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),(0,q.jsx)(`input`,{value:S,onChange:e=>w(e.target.value),placeholder:`搜索插件名 / 作用`,className:`h-9 w-full rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-[13px] text-stone-800 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]}),(0,q.jsx)(`div`,{className:`tw-plugins-pills`,role:`group`,"aria-label":`按状态筛选`,children:ye.map(e=>(0,q.jsx)(`button`,{type:`button`,"aria-pressed":D===e.id,onClick:()=>ee(e.id),children:e.label},e.id))})]}),(0,q.jsxs)(`div`,{className:`mt-4 space-y-6`,children:[Y.map(e=>{let t=!!F[e.category],n=e.items.filter(e=>r[e.id]).length;return(0,q.jsxs)(`section`,{children:[(0,q.jsxs)(`button`,{type:`button`,"aria-expanded":!t,onClick:()=>I(n=>({...n,[e.category]:!t})),className:`mb-2.5 flex w-full items-center gap-2 text-left`,children:[(0,q.jsx)(Ce,{className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform ${t?`-rotate-90`:``}`}),(0,q.jsx)(`span`,{className:`text-[13px] font-semibold text-stone-800`,children:e.category}),(0,q.jsxs)(`span`,{className:`rounded-full bg-stone-100 px-1.5 py-0.5 text-[11px] tabular-nums text-stone-500`,children:[n,`/`,e.items.length]}),(0,q.jsx)(`span`,{className:`ml-1 h-px flex-1 bg-stone-200/70`,"aria-hidden":`true`})]}),t?null:(0,q.jsx)(`ul`,{className:`tw-anim-list tw-plugin-grid`,children:e.items.map(e=>{let t=r[e.id],n=oe(e.id),i=N===`ext:${e.id}`;return(0,q.jsx)(`li`,{className:`relative z-0 min-w-0 overflow-visible hover:z-40 focus-within:z-40${i?` z-40`:``}`,children:(0,q.jsx)(Se,{open:i,onToggleOpen:()=>P(i?null:`ext:${e.id}`),title:e.name,subtitle:e.description,badge:(0,q.jsxs)(`span`,{className:`rounded border border-stone-200 px-1.5 py-0.5 text-[11px] tabular-nums text-stone-400`,children:[`v`,e.version]}),trailing:e.alwaysOn?(0,q.jsx)(`span`,{className:`rounded border border-stone-200 px-1.5 py-0.5 text-[11px] text-stone-500`,children:`内置`}):(0,q.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":`${t?`关闭`:`打开`} ${e.name}`,onClick:()=>se(e.id),className:`tw-toggle`,children:(0,q.jsx)(`span`,{className:`tw-toggle-knob`})}),fullName:`@lh-plugins/${e.id}`,configLabel:e.alwaysOn?`内置常开`:t?`已启用`:`未启用`,runLabel:t&&n.available===!0?`运行中`:`已停用`,extra:n.detail,skillOwner:Object.values(ne).includes(e.id)||e.id===`caseGen`?e.id:void 0})},e.id)})})]},e.category)}),Y.length?null:(0,q.jsxs)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-white/60 px-4 py-12 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm text-stone-600`,children:`没有匹配的插件`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`换个关键词,或把状态筛选切回「全部」。`})]})]})]})},t)]})})}function Se(e){let{open:t,onToggleOpen:n,title:r,subtitle:i,badge:a,trailing:o,fullName:s,configLabel:c,runLabel:l,extra:u,skillOwner:d}=e;return(0,q.jsxs)(`div`,{className:`tw-plugin-card group/card relative z-0 self-start w-full overflow-visible rounded-xl border bg-white transition-colors hover:z-40 focus-within:z-40 ${t?`z-40 border-[#4176e6]/50 shadow-sm`:`border-stone-200 hover:border-stone-300`}`,children:[(0,q.jsxs)(`div`,{className:`relative flex h-17 items-start gap-3 overflow-visible px-4 py-3`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:n,className:`relative h-full min-w-0 flex-1 overflow-visible text-left outline-none focus:outline-none`,"aria-expanded":t,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`h3`,{className:`min-w-0 truncate text-[14px] font-medium text-stone-900`,children:r}),a,(0,q.jsx)(Ce,{className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform duration-300 ease-out ${t?`rotate-180`:``}`})]}),(0,q.jsx)(x,{text:i,className:`mt-1 block min-w-0 truncate text-[13px] leading-5 text-stone-500`,disabled:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 self-start pt-0.5`,children:o})]}),(0,q.jsx)(`div`,{className:`tw-collapse ${t?`is-open`:``}`,"aria-hidden":!t,children:(0,q.jsx)(`div`,{className:`tw-collapse-inner`,children:(0,q.jsxs)(`div`,{className:`border-t border-stone-100 px-4 pb-3 pt-0`,children:[(0,q.jsxs)(`dl`,{className:`mt-2.5 space-y-1.5 text-[13px]`,children:[(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`完整名称`}),(0,q.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px] text-stone-700`,children:s})]}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`配置状态`}),(0,q.jsx)(`dd`,{className:`text-stone-700`,children:c})]}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`运行状态`}),(0,q.jsx)(`dd`,{className:l===`运行中`?`text-emerald-600`:`text-stone-500`,children:l})]}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`简介`}),(0,q.jsx)(`dd`,{className:`text-[12px] leading-5 text-stone-500`,children:i})]}),u?(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`说明`}),(0,q.jsx)(`dd`,{className:`text-[12px] leading-5 text-stone-500`,children:u})]}):null]}),d?(0,q.jsx)(`a`,{tabIndex:t?0:-1,className:`mt-3 inline-flex text-sm text-(--tw-accent)`,href:`/plugins/?tab=skills&owner=${encodeURIComponent(d)}`,children:`配置关联技能`}):null]})})})]})}function Ce({className:e}){return(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:e,"aria-hidden":!0,children:(0,q.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}export{xe as default};
|
|
18
|
+
`+c.content],{type:`text/markdown`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=c.id+`-SKILL.md`,n.click(),URL.revokeObjectURL(t)},children:`导出技能说明`}),(0,q.jsx)(`button`,{className:Z,disabled:g,onClick:()=>void V(async()=>{let e=await D(`export`,{id:c.id}),t=URL.createObjectURL(new Blob([JSON.stringify(e.bundle,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=c.id+`.json`,n.click(),URL.revokeObjectURL(t)}),children:`导出完整技能包`})]}):null,b===`validate`?(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(`p`,{className:`text-xs text-(--tw-label-secondary)`,children:`校验已有输出,不调用模型、不写业务数据。填写 rows、模板 columns、合法 sourceIds,可选 enums、stats。未提供的检查条件会明确提示。`}),(0,q.jsx)(`textarea`,{"aria-label":`输出校验JSON`,className:Q+` font-mono`,rows:9,value:j,onChange:e=>M(e.target.value)}),(0,q.jsx)(`button`,{className:Z,disabled:g,onClick:()=>void V(async()=>{let e=await D(`validate`,{id:c.id,input:JSON.parse(j)});N(JSON.stringify(e,null,2))}),children:`运行校验`}),ee?(0,q.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-(--tw-surface-recessed) p-3 text-xs`,role:`status`,children:ee}):null]}):null]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-(--tw-border) p-4`,children:[(0,q.jsx)(`button`,{className:Z+` bg-(--tw-accent) text-white`,disabled:g,onClick:()=>void V(async()=>{let e=await D(`save`,{id:c.id,patch:{content:c.content,instructions:c.instructions,hash:c.hash}});l(e.skill),await z();let t=await D(`history`,{id:c.id});T(t.versions),O(t.versions[0]?.toString()||``),C(`技能已保存,后续任务使用新版本`,`success`)}),children:`保存技能`}),w.length?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(S,{compact:!0,ariaLabel:`历史技能版本`,value:E,onChange:O,options:w.map(e=>({value:String(e),label:`恢复到 v${e}`}))}),(0,q.jsx)(`button`,{className:Z,disabled:g||!E,onClick:()=>void V(async()=>{await B((await D(`restore`,{id:c.id,version:Number(E),hash:c.hash})).skill.id),await z(),C(`已恢复内容并创建新版本`,`success`)}),children:`恢复版本`})]}):null]})]})})]}):null,!v&&!H.length?(0,q.jsx)(`p`,{className:`p-8 text-center text-sm text-(--tw-label-tertiary)`,children:`没有匹配的技能,可以新建或调整搜索词。`}):null,(0,q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3`,children:U.map(e=>{let t=H.filter(t=>t.group===e),n=t[0],r=t.find(e=>!e.description.startsWith(`旧版变体`))||n,i=t.every(e=>e.enabled),a=!i&&t.some(e=>e.enabled),o=t.some(e=>e.foundation),s=t.some(e=>e.pluginRefs?.length>0||!!e.owner),c=o||s,l=[...new Set(t.flatMap(e=>e.pluginRefs?.length?e.pluginRefs:e.owner?[e.owner]:[]))];return(0,q.jsx)(`article`,{className:`min-w-0 cursor-pointer rounded-xl border border-(--tw-border) bg-(--tw-surface-panel) p-4 transition-colors hover:border-(--tw-accent)`,onClick:e=>{e.target.closest(`button, a`)||B(r.id)},children:(0,q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,q.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-start gap-3 text-left`,"aria-haspopup":`dialog`,onClick:()=>void B(r.id),children:[(0,q.jsx)(pe,{}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`block truncate font-semibold`,children:r.name}),(0,q.jsx)(`span`,{className:`mt-1 line-clamp-2 block text-sm leading-5 text-(--tw-label-secondary)`,children:r.description}),(0,q.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-(--tw-label-tertiary)`,children:[(0,q.jsxs)(`span`,{className:`rounded-full border border-(--tw-border) px-2 py-0.5`,children:[t.length,` 个变体`]}),l.map(e=>(0,q.jsx)(`span`,{className:`rounded-full border border-(--tw-border) px-2 py-0.5`,children:me(e)},e)),c?(0,q.jsx)(`span`,{className:`rounded-full border border-(--tw-border) px-2 py-0.5`,children:`常驻启用`}):null]})]})]}),(0,q.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a?`mixed`:i,"aria-busy":k===e||void 0,"aria-label":o?`${r.name} 空间基础规则常驻启用`:s?`${r.name} 已关联业务,常驻启用`:`${i?`停用`:`启用`} ${r.name}`,title:o?`空间基础规则常驻,不能停用`:s?`已关联业务,不能停用`:void 0,className:`tw-toggle disabled:cursor-not-allowed disabled:opacity-45`,disabled:k===e||c,onClick:t=>{t.stopPropagation(),ne(e,!i)},children:(0,q.jsx)(`span`,{className:`tw-toggle-knob`})})]})},e)})})]})}var ge=[`extensions`,`mcp`,`skills`],_e=[{id:`extensions`,label:`扩展插件`},{id:`mcp`,label:`MCP`},{id:`skills`,label:`技能(Skill)`}],ve={tasks:`侧栏「任务管理」按状态列出任务;工作台可直接增删改`,todos:`侧栏「待办事项」按状态 / 紧急程度分组;工作台可直接增删改`,projects:`侧栏「项目列表」管理项目并汇总迭代 / 需求 / 缺陷;工作台可直接增删改`,iterations:`侧栏「迭代管理」按项目维护迭代周期、进度与逾期;工作台可直接增删改`,pmRequirements:`侧栏「需求管理」维护需求编号 / 优先级 / 状态与验收标准;工作台可直接增删改`,bugs:`侧栏「缺陷管理」记录严重程度 / 重现步骤与修复状态;工作台可直接增删改`,testStats:`侧栏「测试统计」按维度记录每天的统计数量`,caseExec:`侧栏「用例执行统计」按项目记录用例执行情况`,businessMap:`侧栏「业务地图」维护系统功能与业务流程,并审核 AI 识别提案`,dashboard:`侧栏「仪表盘」聚合待办 / 任务 / 测试统计;卡片可拖动排序、拖角改宽高,右上角编辑组件`},$={tasks:ee,todos:N,projects:v,iterations:v,pmRequirements:v,bugs:v,testStats:U,caseExec:w,businessMap:s,dashboard:N},ye=[{id:`all`,label:`全部`},{id:`on`,label:`已启用`},{id:`off`,label:`未启用`}],be=h();function xe({embedded:e=!1}){let[t,n]=(0,K.useState)(()=>(()=>{let e=new URLSearchParams(location.search).get(`tab`);return ge.includes(e)?e:y(`plugins.pageTab`,ge,`extensions`)})()),[r,i]=(0,K.useState)(()=>m()),[a,o]=(0,K.useState)(null),[s,u]=(0,K.useState)(null),[d,h]=(0,K.useState)(null),[v,x]=(0,K.useState)(!0),[S,w]=(0,K.useState)(``),[D,ee]=(0,K.useState)(`all`),[N,P]=(0,K.useState)(null),[F,I]=(0,K.useState)({}),[L,z]=(0,K.useState)(null),[B,V]=(0,K.useState)(null);function U(e){n(e);let t=new URL(location.href);t.searchParams.set(`tab`,e),history.replaceState(null,``,t),b(`plugins.pageTab`,e)}async function ae(){x(!0);try{let[e,t,n,r,i,a,s,c,l,d,f,p]=await Promise.all([te(),M(),$.tasks(),$.todos(),$.projects(),$.iterations(),$.pmRequirements(),$.bugs(),$.testStats(),$.caseExec(),$.businessMap(),$.dashboard()]);o(e),u(t),h({tasks:n,todos:r,projects:i,iterations:a,pmRequirements:s,bugs:c,testStats:l,caseExec:d,businessMap:f,dashboard:p})}finally{x(!1)}}(0,K.useEffect)(()=>{let e=f(e=>i(e));return l().then(()=>{i(m()),ae()}),R().then(e=>{e?.ok&&z(e.serversConfigured??0)}),E().then(V).catch(()=>V(null)),()=>{e()}},[]),(0,K.useEffect)(()=>{t===`mcp`&&R().then(e=>{e?.ok&&z(e.serversConfigured??0)})},[t]);function oe(e){if(e===`cases`)return{available:!0,detail:`侧栏四个用例菜单按功能 / 接口 / 性能 / 自动化分类浏览与维护用例库`};if(e===`caseGen`)return r.cases?{available:!0,detail:`对话输入 / 打开配置面板,生成用例并写入用例库`}:{available:!1,detail:`需先启用「用例管理」,生成结果才能写入用例列表`};if(e===`knowledgeLib`)return{available:!0,detail:`侧栏「知识库管理」浏览与维护本空间知识库`};if(e===`requirements`)return{available:!0,detail:`侧栏「需求文档库」浏览与维护本空间需求文档`};if(e===`templates`)return{available:!0,detail:`侧栏「测试模板库」浏览与维护本空间用例模板`};if(e===`testReports`)return{available:!0,detail:`侧栏「报告管理」按功能 / 接口 / 性能归档报告,可关联技能并在会话中打开`};if(e===`reports`)return{available:!0,detail:`侧栏「工作汇报」按日报 / 周报 / 月报列出汇报文件`};if(e===`tasks`||e===`todos`||e===`projects`||e===`iterations`||e===`pmRequirements`||e===`bugs`||e===`testStats`||e===`caseExec`||e===`dashboard`){let t=d?.[e];return t===void 0?{available:v?null:!1,detail:v?`探测中…`:`需本地服务`}:t?{available:!0,detail:ve[e]}:{available:!1,detail:`需本地服务(npm run dev / lantern web)`}}return e===`knowledgeGen`?r.knowledgeLib?{available:!0,detail:`对话输入 / 打开配置面板,生成文档并写入知识库`}:{available:!1,detail:`需先启用「知识库管理」,生成结果才能写入知识库列表`}:e===`memory`?v&&a===null?{available:null,detail:`探测中…`}:a?.ok?{available:!0,detail:`已连接 · ${a.entryCount??a.entityCount??0} 条记忆 / 待确认 ${a.suggestionCount??0}`}:{available:!1,detail:`本地记忆服务未就绪`}:e===`knowledge`?{available:!0,detail:`对话输入 @ 可引用知识库与模板文档`}:e===`pluginDev`?v&&s===null?{available:null,detail:`探测中…`}:s?.ok?{available:!0,detail:`固定提示词开发扩展插件;先评估确认,再改代码并入「扩展插件」`}:{available:!1,detail:`需本地文件服务:开发要读写项目源码`}:{available:!1,detail:`未知`}}function se(e){let t=p(e,!r[e]),n=!!t[e],a=g.find(t=>t.id===e)?.name??e;i(t),O(e,n).catch(e=>C(`技能关联更新失败:${e instanceof Error?e.message:String(e)}`,`error`)),t.caseGen&&k().catch(e=>C(`用例生成技能没准备好:${e instanceof Error?e.message:String(e)}`,`error`)),t.testReports&&ie().catch(e=>C(`报告整理技能没准备好:${e instanceof Error?e.message:String(e)}`,`error`)),C(n?`已启用「${a}」`:`已停用「${a}」`,`success`),e===`reports`&&H(!!t.reports).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`工作汇报技能没准备好:${t}`,`error`)}),e===`uiAuto`&&re(!!t.uiAuto).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`自动化测试技能没准备好:${t}`,`error`)}),e===`reqAnalysis`&&T(!!t.reqAnalysis).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`需求分析技能没准备好:${t}`,`error`)}),e===`businessMap`&&c(!!t.businessMap).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`业务地图识别技能没准备好:${t}`,`error`)}),e===`storyReview`&&G(!!t.storyReview).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`用户故事审查技能没准备好:${t}`,`error`)}),e===`testPoints`&&W(!!t.testPoints).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`测试点生成技能没准备好:${t}`,`error`)}),(e===`caseReview`||e===`cases`)&&j(!!t.caseReview).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`用例质量评审技能没准备好:${t}`,`error`)}),(e===`caseBlindspot`||e===`cases`)&&A(!!t.caseBlindspot).catch(e=>{let t=e instanceof Error?e.message:String(e);C(`场景遗漏补全技能没准备好:${t}`,`error`)}),(e===`projects`||e===`iterations`||e===`pmRequirements`||e===`bugs`)&&t[e]&&_().catch(e=>{console.warn(`[pm] 同步项目管理数据目录失败`,e)})}let ce=(0,K.useMemo)(()=>g.filter(e=>r[e.id]).length,[r]),J=S.trim().toLowerCase(),Y=(0,K.useMemo)(()=>be.map(e=>({...e,items:e.items.filter(e=>{let t=!J||e.name.toLowerCase().includes(J)||e.id.toLowerCase().includes(J)||e.description.toLowerCase().includes(J),n=D===`all`||(D===`on`?r[e.id]:!r[e.id]);return t&&n})})).filter(e=>e.items.length>0),[r,J,D]);return(0,q.jsx)(`div`,{className:`tw-plugins-page overflow-y-auto ${e?`h-full min-h-0 flex-1`:`min-h-screen`}`,children:(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-[1320px] ${e?`px-4 py-5`:`px-4 py-7 sm:px-5`}`,children:[(0,q.jsxs)(`header`,{className:`tw-plugins-head`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-[20px] font-semibold tracking-tight text-stone-900`,children:`插件仓库`}),(0,q.jsx)(`p`,{className:`mt-1.5 text-[13px] leading-6 text-stone-500`,children:t===`extensions`?(0,q.jsxs)(q.Fragment,{children:[`按用途分组的扩展能力,开关保存在本机;会话 / 全局内置能力在`,(0,q.jsx)(`span`,{className:`mx-1 rounded bg-stone-100 px-1 py-0.5 text-[12px] text-stone-600`,children:`设置 → 内置插件`}),`里查看。`]}):t===`skills`?(0,q.jsx)(q.Fragment,{children:`管理当前空间技能、业务规则、流程与资源,扩展插件启用时自动准备关联技能。`}):(0,q.jsxs)(q.Fragment,{children:[`管理当前数据空间的外接 MCP(写入`,(0,q.jsx)(`span`,{className:`mx-1 rounded bg-stone-100 px-1 py-0.5 font-mono text-[12px] text-stone-600`,children:`.lantern/local/mcp.json`}),`),对话里会出现对应工具。`]})})]}),(0,q.jsxs)(`div`,{className:`tw-plugins-stats`,"aria-label":`插件概览`,children:[(0,q.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,q.jsx)(`span`,{className:`tw-plugins-stat-num`,children:g.length}),(0,q.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`个插件`})]}),(0,q.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,q.jsx)(`span`,{className:`tw-plugins-stat-num is-on`,children:ce}),(0,q.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`已启用`})]}),(0,q.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,q.jsx)(`span`,{className:`tw-plugins-stat-num`,children:be.length}),(0,q.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`个分类`})]}),(0,q.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,q.jsx)(`span`,{className:`tw-plugins-stat-num`,children:L??`—`}),(0,q.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`MCP`})]})]})]}),(0,q.jsx)(`div`,{className:`tw-plugins-tabs`,role:`tablist`,"aria-label":`插件页分类`,children:_e.map(e=>(0,q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,className:t===e.id?`is-active`:void 0,onClick:()=>U(e.id),children:[e.label,(0,q.jsx)(`span`,{className:`tw-plugins-tab-count`,children:e.id===`extensions`?g.length:e.id===`mcp`?L??`—`:B??`—`})]},e.id))}),(0,q.jsx)(`div`,{className:`tw-plugins-tab-panel`,children:t===`skills`?(0,q.jsx)(he,{onCount:V}):t===`mcp`?(0,q.jsx)(fe,{onServersChange:z}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`tw-plugins-toolbar`,children:[(0,q.jsxs)(`label`,{className:`relative block w-full max-w-72`,children:[(0,q.jsxs)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-stone-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,children:[(0,q.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,q.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),(0,q.jsx)(`input`,{value:S,onChange:e=>w(e.target.value),placeholder:`搜索插件名 / 作用`,className:`h-9 w-full rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-[13px] text-stone-800 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]}),(0,q.jsx)(`div`,{className:`tw-plugins-pills`,role:`group`,"aria-label":`按状态筛选`,children:ye.map(e=>(0,q.jsx)(`button`,{type:`button`,"aria-pressed":D===e.id,onClick:()=>ee(e.id),children:e.label},e.id))})]}),(0,q.jsxs)(`div`,{className:`mt-4 space-y-6`,children:[Y.map(e=>{let t=!!F[e.category],n=e.items.filter(e=>r[e.id]).length;return(0,q.jsxs)(`section`,{children:[(0,q.jsxs)(`button`,{type:`button`,"aria-expanded":!t,onClick:()=>I(n=>({...n,[e.category]:!t})),className:`mb-2.5 flex w-full items-center gap-2 text-left`,children:[(0,q.jsx)(Ce,{className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform ${t?`-rotate-90`:``}`}),(0,q.jsx)(`span`,{className:`text-[13px] font-semibold text-stone-800`,children:e.category}),(0,q.jsxs)(`span`,{className:`rounded-full bg-stone-100 px-1.5 py-0.5 text-[11px] tabular-nums text-stone-500`,children:[n,`/`,e.items.length]}),(0,q.jsx)(`span`,{className:`ml-1 h-px flex-1 bg-stone-200/70`,"aria-hidden":`true`})]}),t?null:(0,q.jsx)(`ul`,{className:`tw-anim-list tw-plugin-grid`,children:e.items.map(e=>{let t=r[e.id],n=oe(e.id),i=N===`ext:${e.id}`;return(0,q.jsx)(`li`,{className:`relative z-0 min-w-0 overflow-visible hover:z-40 focus-within:z-40${i?` z-40`:``}`,children:(0,q.jsx)(Se,{open:i,onToggleOpen:()=>P(i?null:`ext:${e.id}`),title:e.name,subtitle:e.description,badge:(0,q.jsxs)(`span`,{className:`rounded border border-stone-200 px-1.5 py-0.5 text-[11px] tabular-nums text-stone-400`,children:[`v`,e.version]}),trailing:e.alwaysOn?(0,q.jsx)(`span`,{className:`rounded border border-stone-200 px-1.5 py-0.5 text-[11px] text-stone-500`,children:`内置`}):(0,q.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":`${t?`关闭`:`打开`} ${e.name}`,onClick:()=>se(e.id),className:`tw-toggle`,children:(0,q.jsx)(`span`,{className:`tw-toggle-knob`})}),fullName:`@lh-plugins/${e.id}`,configLabel:e.alwaysOn?`内置常开`:t?`已启用`:`未启用`,runLabel:t&&n.available===!0?`运行中`:`已停用`,extra:n.detail,skillOwner:Object.values(ne).includes(e.id)||e.id===`caseGen`?e.id:void 0})},e.id)})})]},e.category)}),Y.length?null:(0,q.jsxs)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-white/60 px-4 py-12 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm text-stone-600`,children:`没有匹配的插件`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`换个关键词,或把状态筛选切回「全部」。`})]})]})]})},t)]})})}function Se(e){let{open:t,onToggleOpen:n,title:r,subtitle:i,badge:a,trailing:o,fullName:s,configLabel:c,runLabel:l,extra:u,skillOwner:d}=e;return(0,q.jsxs)(`div`,{className:`tw-plugin-card group/card relative z-0 self-start w-full overflow-visible rounded-xl border bg-white transition-colors hover:z-40 focus-within:z-40 ${t?`z-40 border-[#4176e6]/50 shadow-sm`:`border-stone-200 hover:border-stone-300`}`,children:[(0,q.jsxs)(`div`,{className:`relative flex h-17 items-start gap-3 overflow-visible px-4 py-3`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:n,className:`relative h-full min-w-0 flex-1 overflow-visible text-left outline-none focus:outline-none`,"aria-expanded":t,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`h3`,{className:`min-w-0 truncate text-[14px] font-medium text-stone-900`,children:r}),a,(0,q.jsx)(Ce,{className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform duration-300 ease-out ${t?`rotate-180`:``}`})]}),(0,q.jsx)(x,{text:i,className:`mt-1 block min-w-0 truncate text-[13px] leading-5 text-stone-500`,disabled:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 self-start pt-0.5`,children:o})]}),(0,q.jsx)(`div`,{className:`tw-collapse ${t?`is-open`:``}`,"aria-hidden":!t,children:(0,q.jsx)(`div`,{className:`tw-collapse-inner`,children:(0,q.jsxs)(`div`,{className:`border-t border-stone-100 px-4 pb-3 pt-0`,children:[(0,q.jsxs)(`dl`,{className:`mt-2.5 space-y-1.5 text-[13px]`,children:[(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`完整名称`}),(0,q.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px] text-stone-700`,children:s})]}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`配置状态`}),(0,q.jsx)(`dd`,{className:`text-stone-700`,children:c})]}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`运行状态`}),(0,q.jsx)(`dd`,{className:l===`运行中`?`text-emerald-600`:`text-stone-500`,children:l})]}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`简介`}),(0,q.jsx)(`dd`,{className:`text-[12px] leading-5 text-stone-500`,children:i})]}),u?(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`说明`}),(0,q.jsx)(`dd`,{className:`text-[12px] leading-5 text-stone-500`,children:u})]}):null]}),d?(0,q.jsx)(`a`,{tabIndex:t?0:-1,className:`mt-3 inline-flex text-sm text-(--tw-accent)`,href:`/plugins/?tab=skills&owner=${encodeURIComponent(d)}`,children:`配置关联技能`}):null]})})})]})}function Ce({className:e}){return(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:e,"aria-hidden":!0,children:(0,q.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}export{xe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{p as n}from"./app-config.Dvfzl5_N.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.DQFd6g2r.js";import{o as te}from"./plugins.Db9xoFZb.js";import{A as ne,D as re,N as ie,P as ae,R as i,b as oe,g as se,h as ce,i as le,j as ue,m as a,n as o,p as de,r as s,t as c,x as fe,z as pe}from"./pm.BXmOiFfW.js";import{t as l}from"./SelectDropdown.D7IeyHDI.js";import{A as me,C as he,D as ge,E as u,O as _e,S as ve,_ as d,a as ye,c as be,d as xe,f,g as Se,h as Ce,j as we,k as p,l as Te,m,n as Ee,p as De,s as Oe,t as ke,u as Ae,y as h}from"./PmShared.BQVzwsiz.js";import{showToast as g}from"./Toast.BydY-X7T.js";import{n as je,t as Me}from"./DocsPager.DMN9-Tjg.js";import{n as Ne,r as Pe,t as Fe}from"./TableFieldConfig.72AL-8p-.js";import{c as Ie,d as Le,i as Re,l as ze,n as Be,o as Ve,r as He,s as Ue,t as _}from"./ColumnResize.CkE59sGq.js";var v=e(t(),1),y=r(),We=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`severity`,width:100,min:80},{key:`status`,width:120,min:96}],Ge={key:`project`,width:140,min:100},Ke=[{key:`iteration`,width:120,min:88},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],qe=new Set([`id`,`title`,`filler`,`action`]),b=[{key:`severity`,label:`严重程度`},{key:`status`,label:`缺陷状态`},{key:`iteration`,label:`所属迭代`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Je=`pm.bugs.fields`,Ye=20,Xe=`tw.pm-bugs.page-size.v1`,Ze=[`all`,...s],Qe=[`all`,...c],$e=`pm.bugs.project`,et=`pm.bugs.iteration`,tt=`pm.bugs.status`,nt=`pm.bugs.severity`,rt=`pm.bugs.keyword`,it=c.map(e=>({value:e,label:o[e]})),at=s.map(e=>({value:e,label:le[e]}));function x(e=``){return{projectId:e,iterationId:``,requirementId:``,title:``,severity:`minor`,status:`pending`,reproduceSteps:``,expectedResult:``,actualResult:``,environment:``,githubIssue:``,attachment:``,remark:``}}function S(){return n(`pm.bugs.create-draft.v1`)}function ot(e){return!!(e.reproduceSteps.trim()||e.attachment.trim()||e.remark.trim()||e.iterationId||e.requirementId||e.expectedResult.trim()||e.actualResult.trim()||e.environment.trim()||e.githubIssue.trim())}function C(){try{let e=sessionStorage.getItem(S());if(!e)return null;let t=JSON.parse(e);return!t||typeof t!=`object`||t.id?null:{...x(),...t,id:void 0}}catch{return null}}function w(e){try{let t=S();if(!e||e.id||!ot(e)){sessionStorage.removeItem(t);return}sessionStorage.setItem(t,JSON.stringify({...e,id:void 0}))}catch{}}function st(e){let t=C();return t?e&&t.projectId!==e?{...t,projectId:e,iterationId:``,requirementId:``}:t:x(e)}function T({scopeProjectId:e=``}={}){let t=!!e,n=me(`bugs`),{store:r,live:s,loading:c,error:x,setError:S,reload:C}=we(),[T,E]=p($e,`all`),D=e||T,[O,k]=p(et,`all`),[A,ct]=_e(tt,Ze,`all`),[j,lt]=_e(nt,Qe,`all`),[M,ut]=p(rt),[dt,N]=(0,v.useState)(1),[P,ft]=je(Ye,Xe),[F,I]=(0,v.useState)(null),[L,R]=(0,v.useState)(!1),[z,pt]=(0,v.useState)(!1),B=(0,v.useRef)(null),V=(0,v.useRef)(new Set),[H,U]=(0,v.useState)(null),[mt,W]=(0,v.useState)(null),G=(0,v.useMemo)(()=>ue(F?.attachment??``),[F?.attachment]),ht=(0,v.useMemo)(()=>t?b:[{key:`project`,label:`所属项目`},...b],[t]),K=Pe(Je,ht,qe),gt=(0,v.useMemo)(()=>t?[...We,...Ke]:[...We,Ge,...Ke],[t]),q=(0,v.useMemo)(()=>Ne(gt,K.isVisible),[gt,K.isVisible]),J=ze(t?`pm.bugs.cols.scoped.v2`:`pm.bugs.cols.v2`,q),_t=Le(t?`pm.bugs.scroll.scoped`:`pm.bugs.scroll`),vt=J.widthOf(`id`)??88;(0,v.useEffect)(()=>{for(let e of G)V.current.add(e.url)},[G]);let yt=(0,v.useMemo)(()=>[{value:`all`,label:`全部项目`},...r.projects.map(e=>({value:e.id,label:e.name}))],[r.projects]),bt=(0,v.useMemo)(()=>[{value:`all`,label:`全部迭代`},...r.iterations.filter(e=>D===`all`||e.projectId===D).map(e=>({value:e.id,label:e.name}))],[r.iterations,D]),xt=(0,v.useMemo)(()=>{let e=new Map(r.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[r.projects]),St=(0,v.useMemo)(()=>{let e=new Map(r.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[r.iterations]),Y=(0,v.useMemo)(()=>ie(fe(r.bugs,{projectId:D,iterationId:O,status:A,severity:j,keyword:M})),[r.bugs,D,O,A,j,M]),X=t?r.bugs.filter(e=>e.projectId===D).length:r.bugs.length,Ct=Math.max(1,Math.ceil(Y.length/P)),Z=Math.min(dt,Ct),wt=Y.slice((Z-1)*P,Z*P);(0,v.useEffect)(()=>{t||s===!0&&T!==`all`&&!r.projects.some(e=>e.id===T)&&E(`all`)},[s,r.projects,T,E,t]),(0,v.useEffect)(()=>{s===!0&&O!==`all`&&!r.iterations.some(e=>e.id===O&&(D===`all`||e.projectId===D))&&k(`all`)},[s,r.iterations,D,O,k]);let Tt=F?ae(r.iterations.filter(e=>e.projectId===F.projectId)):[],Et=F?r.requirements.filter(e=>e.projectId===F.projectId):[];async function Dt(){if(!F)return;if(!F.projectId){S(`请先选择所属项目`);return}let e=F.reproduceSteps.trim();if(!e){S(`缺陷描述不能为空`);return}let t=de(e);R(!0);try{let n={projectId:F.projectId,iterationId:F.iterationId,requirementId:F.requirementId,title:t,severity:F.severity,status:F.status,reproduceSteps:e,expectedResult:F.expectedResult,actualResult:F.actualResult,environment:F.environment,githubIssue:F.githubIssue,attachment:F.attachment,remark:F.remark};F.id?await i(`bugs`,F.id,n):await ce(`bugs`,[n]);let r=!!F.id;r||w(null),I(null),V.current.clear(),S(``),await C(!0),g(r?`已保存缺陷`:`已新建缺陷`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);S(t),g(`保存缺陷失败:${t}`,`error`)}finally{R(!1)}}let Q=(0,v.useCallback)(async e=>{if(e&&e.length){pt(!0);try{let t=await pe(Array.from(e));I(e=>{if(!e)return e;let n=ue(e.attachment);return{...e,attachment:ne([...n,...t])}}),S(``)}catch(e){S(e instanceof Error?e.message:String(e))}finally{pt(!1),B.current&&(B.current.value=``)}}},[S]),Ot=F!==null;(0,v.useEffect)(()=>{if(!Ot)return;let e=e=>{let t=oe(e.clipboardData);t.length&&(e.preventDefault(),Q(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[Ot,Q]);async function kt(e){if(!F)return;let t=ne(G.filter(t=>t.url!==e));if(F.id)try{await i(`bugs`,F.id,{attachment:t}),await C(!0)}catch(e){S(e instanceof Error?e.message:String(e));return}I(e=>{if(!e)return e;let n={...e,attachment:t};return n.id||w(n),n}),a([e],F.id??``)}function At(){if(F&&!F.id){if(w(F),V.current.clear(),I(null),!ot(F)){let e=G.map(e=>e.url);e.length&&a(e)}return}let e=[...V.current,...G.map(e=>e.url)];V.current.clear(),I(null),e.length&&a(e)}function $(){I(st(D===`all`?``:D))}async function jt(e,t){R(!0);try{await i(`bugs`,e.id,{status:t}),await C(!0)}catch(e){S(e instanceof Error?e.message:String(e))}finally{R(!1)}}async function Mt(){let e=H;if(e){U(null),R(!0);try{await se(`bugs`,[e.id]),await C(!0),g(`已删除缺陷`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);S(t),g(`删除缺陷失败:${t}`,`error`)}finally{R(!1)}}}if(!n.ready)return(0,y.jsx)(Se,{label:`正在读取插件开关`});if(!n.on)return(0,y.jsx)(d,{children:te(`bugs`)});if(s===null)return(0,y.jsx)(Se,{label:`正在连接项目管理服务`});if(!s)return(0,y.jsx)(d,{children:`缺陷管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(r.projects.length===0&&!c&&!t)return(0,y.jsx)(d,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来记录缺陷。`});let Nt=[{value:`all`,label:`全部`},...at];return(0,y.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-600`,children:X}),` 条缺陷`,Y.length===X?``:` · 筛选出 ${Y.length} 条`]}),(0,y.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,y.jsx)(l,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选缺陷`,className:`w-36`,options:yt,value:T,onChange:e=>{E(e),k(`all`),N(1)}}),(0,y.jsx)(l,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选缺陷`,className:`w-32`,options:bt,value:O,onChange:e=>{k(e),N(1)}}),(0,y.jsx)(l,{flat:!0,showCheck:!1,ariaLabel:`按严重程度筛选缺陷`,className:`w-32`,options:[{value:`all`,label:`全部严重程度`},...it],value:j,onChange:e=>{lt(e),N(1)}}),(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(m,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,y.jsx)(`input`,{value:M,onChange:e=>{ut(e.target.value),N(1)},placeholder:`搜索编号 / 标题…`,className:`h-9 w-48 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#4176e6]`})]}),(0,y.jsx)(Fe,{fields:K.fields,isVisible:K.isVisible,onToggle:K.toggle}),(0,y.jsxs)(`button`,{type:`button`,disabled:L,onClick:$,className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#3566d0] disabled:opacity-40`,children:[(0,y.jsx)(m,{name:`plus`,size:14}),`新建缺陷`]})]})]}),(0,y.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,y.jsx)(De,{ariaLabel:`按状态筛选缺陷`,options:Nt,value:A,onChange:e=>{ct(e),N(1)}})}),x?(0,y.jsx)(xe,{message:x,onClose:()=>S(``)}):null,(0,y.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,y.jsx)(`div`,{ref:_t,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,y.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:J.tableStyle,children:[(0,y.jsx)(`colgroup`,{children:q.map(e=>(0,y.jsx)(`col`,{style:J.widthOf(e.key)?{width:J.widthOf(e.key)}:void 0},e.key))}),(0,y.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,y.jsxs)(`tr`,{children:[(0,y.jsxs)(`th`,{className:`${Ue} relative`,children:[`ID`,(0,y.jsx)(_,{...J.resizeProps(`id`)})]}),(0,y.jsxs)(`th`,{className:Ve,style:{"--tw-sticky-left":`${vt}px`},children:[`缺陷标题`,(0,y.jsx)(_,{...J.resizeProps(`title`)})]}),K.isVisible(`severity`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`严重程度`,(0,y.jsx)(_,{...J.resizeProps(`severity`)})]}):null,K.isVisible(`status`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`缺陷状态`,(0,y.jsx)(_,{...J.resizeProps(`status`)})]}):null,!t&&K.isVisible(`project`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属项目`,(0,y.jsx)(_,{...J.resizeProps(`project`)})]}):null,K.isVisible(`iteration`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属迭代`,(0,y.jsx)(_,{...J.resizeProps(`iteration`)})]}):null,K.isVisible(`createdAt`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,y.jsx)(_,{...J.resizeProps(`createdAt`)})]}):null,K.isVisible(`updatedAt`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,y.jsx)(_,{...J.resizeProps(`updatedAt`)})]}):null,(0,y.jsx)(`th`,{"aria-hidden":`true`}),(0,y.jsx)(`th`,{className:Ie,children:`操作`})]})}),(0,y.jsxs)(`tbody`,{children:[c&&!r.bugs.length?(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:q.length,className:`px-4 py-16 text-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):wt.length===0?(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:q.length,children:X?(0,y.jsx)(Te,{children:`没有符合筛选条件的缺陷。`}):(0,y.jsx)(Ae,{icon:`bug`,title:`暂无缺陷`,hint:`记录第一个缺陷,跟踪严重程度与修复状态。`,action:(0,y.jsxs)(`button`,{type:`button`,onClick:$,className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,y.jsx)(m,{name:`plus`,size:13}),`新建缺陷`]})})})}):null,wt.map(e=>(0,y.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,y.jsx)(`td`,{className:`${He} font-mono text-xs text-stone-400`,children:e.autoId}),(0,y.jsx)(`td`,{className:Be,style:{"--tw-sticky-left":`${vt}px`},children:(0,y.jsx)(he,{text:e.title,onClick:()=>I({id:e.id,projectId:e.projectId,iterationId:e.iterationId,requirementId:e.requirementId,title:e.title,severity:e.severity,status:e.status,reproduceSteps:e.reproduceSteps||e.title,expectedResult:e.expectedResult,actualResult:e.actualResult,environment:e.environment,githubIssue:e.githubIssue,attachment:e.attachment,remark:e.remark})})}),K.isVisible(`severity`)?(0,y.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,y.jsx)(ve,{tone:ke[e.severity],children:o[e.severity]})}):null,K.isVisible(`status`)?(0,y.jsx)(`td`,{className:`min-w-0 overflow-hidden px-2 py-1 align-middle`,children:(0,y.jsx)(l,{unstyled:!0,fitContent:!0,hideChevron:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:L,options:at,value:e.status,onChange:t=>void jt(e,t),renderOptionPrefix:e=>(0,y.jsx)(Oe,{tone:Ee[e.value]}),renderTrigger:()=>(0,y.jsx)(ve,{tone:Ee[e.status],children:le[e.status]})})}):null,!t&&K.isVisible(`project`)?(0,y.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-600`,children:(0,y.jsx)(`a`,{href:ge(e.projectId),className:`block truncate transition-colors hover:text-[#4176e6]`,children:xt(e.projectId)})}):null,K.isVisible(`iteration`)?(0,y.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-500`,children:St(e.iterationId)}):null,K.isVisible(`createdAt`)?(0,y.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:u(e.createdAt)}):null,K.isVisible(`updatedAt`)?(0,y.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:u(e.updatedAt)}):null,(0,y.jsx)(`td`,{"aria-hidden":`true`}),(0,y.jsx)(`td`,{className:Re,children:(0,y.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:L,onClick:()=>U(e),className:`tw-icon-danger inline-flex h-7 w-7 items-center justify-center rounded-md`,children:(0,y.jsx)(m,{name:`trash`,size:15})})})]},e.id))]})]})}),Y.length>0?(0,y.jsx)(Me,{page:Z,totalPages:Ct,pageSize:P,busy:L,onPage:N,onPageSize:e=>{ft(e),N(1)}}):null]}),(0,y.jsx)(be,{open:F!==null,title:F?.id?`编辑缺陷`:`新建缺陷`,busy:L,submitLabel:F?.id?`保存`:`创建`,onClose:At,onSubmit:()=>void Dt(),children:F?(0,y.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,y.jsx)(f,{label:`所属项目`,required:!0,children:(0,y.jsx)(h,{ariaLabel:`所属项目`,options:r.projects.map(e=>({value:e.id,label:e.name})),value:F.projectId,onChange:e=>I({...F,projectId:e,iterationId:``,requirementId:``})})}),(0,y.jsx)(f,{label:`所属迭代`,children:(0,y.jsx)(h,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...Tt.map(e=>({value:e.id,label:e.name}))],value:F.iterationId,onChange:e=>I({...F,iterationId:e}),disabled:Tt.length===0})}),(0,y.jsx)(f,{label:`关联需求`,children:(0,y.jsx)(h,{ariaLabel:`关联需求`,options:[{value:``,label:`不关联需求`},...Et.map(e=>({value:e.id,label:`${e.autoId} ${e.title}`}))],value:F.requirementId,onChange:e=>I({...F,requirementId:e}),disabled:Et.length===0})}),(0,y.jsx)(f,{label:`缺陷描述`,required:!0,children:(0,y.jsx)(`textarea`,{autoFocus:!0,value:F.reproduceSteps,onChange:e=>I({...F,reproduceSteps:e.target.value}),placeholder:`描述问题现象、复现步骤与影响范围`,rows:5,className:ye})}),(0,y.jsx)(f,{label:`严重程度`,children:(0,y.jsx)(h,{ariaLabel:`严重程度`,options:it,value:F.severity,onChange:e=>I({...F,severity:e}),renderOptionPrefix:e=>(0,y.jsx)(Oe,{tone:ke[e.value]})})}),(0,y.jsx)(f,{label:`附件`,children:(0,y.jsxs)(`div`,{className:`space-y-2`,children:[G.length?(0,y.jsx)(`ul`,{className:`space-y-1.5`,children:G.map(e=>{let t=re(e.url);return(0,y.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[t?(0,y.jsx)(`button`,{type:`button`,onClick:()=>W(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,y.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,y.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,y.jsx)(m,{name:`file`,size:15})}),t?(0,y.jsx)(`button`,{type:`button`,onClick:()=>W(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#4176e6]`,children:e.name}):(0,y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`min-w-0 flex-1 truncate text-sm text-stone-700 hover:text-[#4176e6]`,children:e.name}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>kt(e.url),className:`tw-icon-danger flex h-6 w-6 shrink-0 items-center justify-center rounded`,children:`✕`})]},e.url)})}):null,(0,y.jsx)(`input`,{ref:B,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void Q(e.target.files)}),(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`button`,{type:`button`,disabled:z,onClick:()=>B.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-dashed border-stone-300 px-2.5 text-xs text-stone-500 transition-colors hover:border-stone-400 hover:text-stone-700 disabled:opacity-40`,children:[(0,y.jsx)(m,{name:z?`file`:`plus`,size:13}),z?`上传中…`:`上传文件 / 图片`]}),(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可直接粘贴截图 / 图片(⌘V / Ctrl+V),支持多张`})]})]})}),(0,y.jsx)(f,{label:`备注`,children:(0,y.jsx)(`textarea`,{value:F.remark,onChange:e=>I({...F,remark:e.target.value}),rows:2,className:ye})}),F.id?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f,{label:`创建日期`,children:(0,y.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:u(r.bugs.find(e=>e.id===F.id)?.createdAt)})}),(0,y.jsx)(f,{label:`修改日期`,children:(0,y.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:u(r.bugs.find(e=>e.id===F.id)?.updatedAt)})})]}):null]}):null}),(0,y.jsx)(ee,{open:H!==null,title:`删除缺陷`,message:`确定删除「${H?.title??``}」?此操作无法恢复。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>U(null),onConfirm:()=>void Mt()}),(0,y.jsx)(Ce,{file:mt,onClose:()=>W(null)})]})}export{T as default};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{p as n}from"./app-config.BSO5r82v.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.DQFd6g2r.js";import{o as te}from"./plugins.ChGmBEkF.js";import{A as ne,D as re,N as ie,P as ae,R as i,b as oe,g as se,h as ce,i as le,j as ue,m as a,n as o,p as de,r as s,t as c,x as fe,z as pe}from"./pm.BXmOiFfW.js";import{t as l}from"./SelectDropdown.D7IeyHDI.js";import{A as me,C as he,D as ge,E as u,O as _e,S as ve,_ as d,a as ye,c as be,d as xe,f,g as Se,h as Ce,j as we,k as p,l as Te,m,n as Ee,p as De,s as Oe,t as ke,u as Ae,y as h}from"./PmShared.TOjBbtV8.js";import{showToast as g}from"./Toast.BydY-X7T.js";import{n as je,t as Me}from"./DocsPager.Dg765uHW.js";import{n as Ne,r as Pe,t as Fe}from"./TableFieldConfig.DHj25OKN.js";import{c as Ie,d as Le,i as Re,l as ze,n as Be,o as Ve,r as He,s as Ue,t as _}from"./ColumnResize.CkE59sGq.js";var v=e(t(),1),y=r(),We=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`severity`,width:100,min:80},{key:`status`,width:120,min:96}],Ge={key:`project`,width:140,min:100},Ke=[{key:`iteration`,width:120,min:88},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],qe=new Set([`id`,`title`,`filler`,`action`]),b=[{key:`severity`,label:`严重程度`},{key:`status`,label:`缺陷状态`},{key:`iteration`,label:`所属迭代`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Je=`pm.bugs.fields`,Ye=20,Xe=`tw.pm-bugs.page-size.v1`,Ze=[`all`,...s],Qe=[`all`,...c],$e=`pm.bugs.project`,et=`pm.bugs.iteration`,tt=`pm.bugs.status`,nt=`pm.bugs.severity`,rt=`pm.bugs.keyword`,it=c.map(e=>({value:e,label:o[e]})),at=s.map(e=>({value:e,label:le[e]}));function x(e=``){return{projectId:e,iterationId:``,requirementId:``,title:``,severity:`minor`,status:`pending`,reproduceSteps:``,expectedResult:``,actualResult:``,environment:``,githubIssue:``,attachment:``,remark:``}}function S(){return n(`pm.bugs.create-draft.v1`)}function ot(e){return!!(e.reproduceSteps.trim()||e.attachment.trim()||e.remark.trim()||e.iterationId||e.requirementId||e.expectedResult.trim()||e.actualResult.trim()||e.environment.trim()||e.githubIssue.trim())}function C(){try{let e=sessionStorage.getItem(S());if(!e)return null;let t=JSON.parse(e);return!t||typeof t!=`object`||t.id?null:{...x(),...t,id:void 0}}catch{return null}}function w(e){try{let t=S();if(!e||e.id||!ot(e)){sessionStorage.removeItem(t);return}sessionStorage.setItem(t,JSON.stringify({...e,id:void 0}))}catch{}}function st(e){let t=C();return t?e&&t.projectId!==e?{...t,projectId:e,iterationId:``,requirementId:``}:t:x(e)}function T({scopeProjectId:e=``}={}){let t=!!e,n=me(`bugs`),{store:r,live:s,loading:c,error:x,setError:S,reload:C}=we(),[T,E]=p($e,`all`),D=e||T,[O,k]=p(et,`all`),[A,ct]=_e(tt,Ze,`all`),[j,lt]=_e(nt,Qe,`all`),[M,ut]=p(rt),[dt,N]=(0,v.useState)(1),[P,ft]=je(Ye,Xe),[F,I]=(0,v.useState)(null),[L,R]=(0,v.useState)(!1),[z,pt]=(0,v.useState)(!1),B=(0,v.useRef)(null),V=(0,v.useRef)(new Set),[H,U]=(0,v.useState)(null),[mt,W]=(0,v.useState)(null),G=(0,v.useMemo)(()=>ue(F?.attachment??``),[F?.attachment]),ht=(0,v.useMemo)(()=>t?b:[{key:`project`,label:`所属项目`},...b],[t]),K=Pe(Je,ht,qe),gt=(0,v.useMemo)(()=>t?[...We,...Ke]:[...We,Ge,...Ke],[t]),q=(0,v.useMemo)(()=>Ne(gt,K.isVisible),[gt,K.isVisible]),J=ze(t?`pm.bugs.cols.scoped.v2`:`pm.bugs.cols.v2`,q),_t=Le(t?`pm.bugs.scroll.scoped`:`pm.bugs.scroll`),vt=J.widthOf(`id`)??88;(0,v.useEffect)(()=>{for(let e of G)V.current.add(e.url)},[G]);let yt=(0,v.useMemo)(()=>[{value:`all`,label:`全部项目`},...r.projects.map(e=>({value:e.id,label:e.name}))],[r.projects]),bt=(0,v.useMemo)(()=>[{value:`all`,label:`全部迭代`},...r.iterations.filter(e=>D===`all`||e.projectId===D).map(e=>({value:e.id,label:e.name}))],[r.iterations,D]),xt=(0,v.useMemo)(()=>{let e=new Map(r.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[r.projects]),St=(0,v.useMemo)(()=>{let e=new Map(r.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[r.iterations]),Y=(0,v.useMemo)(()=>ie(fe(r.bugs,{projectId:D,iterationId:O,status:A,severity:j,keyword:M})),[r.bugs,D,O,A,j,M]),X=t?r.bugs.filter(e=>e.projectId===D).length:r.bugs.length,Ct=Math.max(1,Math.ceil(Y.length/P)),Z=Math.min(dt,Ct),wt=Y.slice((Z-1)*P,Z*P);(0,v.useEffect)(()=>{t||s===!0&&T!==`all`&&!r.projects.some(e=>e.id===T)&&E(`all`)},[s,r.projects,T,E,t]),(0,v.useEffect)(()=>{s===!0&&O!==`all`&&!r.iterations.some(e=>e.id===O&&(D===`all`||e.projectId===D))&&k(`all`)},[s,r.iterations,D,O,k]);let Tt=F?ae(r.iterations.filter(e=>e.projectId===F.projectId)):[],Et=F?r.requirements.filter(e=>e.projectId===F.projectId):[];async function Dt(){if(!F)return;if(!F.projectId){S(`请先选择所属项目`);return}let e=F.reproduceSteps.trim();if(!e){S(`缺陷描述不能为空`);return}let t=de(e);R(!0);try{let n={projectId:F.projectId,iterationId:F.iterationId,requirementId:F.requirementId,title:t,severity:F.severity,status:F.status,reproduceSteps:e,expectedResult:F.expectedResult,actualResult:F.actualResult,environment:F.environment,githubIssue:F.githubIssue,attachment:F.attachment,remark:F.remark};F.id?await i(`bugs`,F.id,n):await ce(`bugs`,[n]);let r=!!F.id;r||w(null),I(null),V.current.clear(),S(``),await C(!0),g(r?`已保存缺陷`:`已新建缺陷`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);S(t),g(`保存缺陷失败:${t}`,`error`)}finally{R(!1)}}let Q=(0,v.useCallback)(async e=>{if(e&&e.length){pt(!0);try{let t=await pe(Array.from(e));I(e=>{if(!e)return e;let n=ue(e.attachment);return{...e,attachment:ne([...n,...t])}}),S(``)}catch(e){S(e instanceof Error?e.message:String(e))}finally{pt(!1),B.current&&(B.current.value=``)}}},[S]),Ot=F!==null;(0,v.useEffect)(()=>{if(!Ot)return;let e=e=>{let t=oe(e.clipboardData);t.length&&(e.preventDefault(),Q(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[Ot,Q]);async function kt(e){if(!F)return;let t=ne(G.filter(t=>t.url!==e));if(F.id)try{await i(`bugs`,F.id,{attachment:t}),await C(!0)}catch(e){S(e instanceof Error?e.message:String(e));return}I(e=>{if(!e)return e;let n={...e,attachment:t};return n.id||w(n),n}),a([e],F.id??``)}function At(){if(F&&!F.id){if(w(F),V.current.clear(),I(null),!ot(F)){let e=G.map(e=>e.url);e.length&&a(e)}return}let e=[...V.current,...G.map(e=>e.url)];V.current.clear(),I(null),e.length&&a(e)}function $(){I(st(D===`all`?``:D))}async function jt(e,t){R(!0);try{await i(`bugs`,e.id,{status:t}),await C(!0)}catch(e){S(e instanceof Error?e.message:String(e))}finally{R(!1)}}async function Mt(){let e=H;if(e){U(null),R(!0);try{await se(`bugs`,[e.id]),await C(!0),g(`已删除缺陷`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);S(t),g(`删除缺陷失败:${t}`,`error`)}finally{R(!1)}}}if(!n.ready)return(0,y.jsx)(Se,{label:`正在读取插件开关`});if(!n.on)return(0,y.jsx)(d,{children:te(`bugs`)});if(s===null)return(0,y.jsx)(Se,{label:`正在连接项目管理服务`});if(!s)return(0,y.jsx)(d,{children:`缺陷管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(r.projects.length===0&&!c&&!t)return(0,y.jsx)(d,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来记录缺陷。`});let Nt=[{value:`all`,label:`全部`},...at];return(0,y.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-600`,children:X}),` 条缺陷`,Y.length===X?``:` · 筛选出 ${Y.length} 条`]}),(0,y.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,y.jsx)(l,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选缺陷`,className:`w-36`,options:yt,value:T,onChange:e=>{E(e),k(`all`),N(1)}}),(0,y.jsx)(l,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选缺陷`,className:`w-32`,options:bt,value:O,onChange:e=>{k(e),N(1)}}),(0,y.jsx)(l,{flat:!0,showCheck:!1,ariaLabel:`按严重程度筛选缺陷`,className:`w-32`,options:[{value:`all`,label:`全部严重程度`},...it],value:j,onChange:e=>{lt(e),N(1)}}),(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(m,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,y.jsx)(`input`,{value:M,onChange:e=>{ut(e.target.value),N(1)},placeholder:`搜索编号 / 标题…`,className:`h-9 w-48 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#4176e6]`})]}),(0,y.jsx)(Fe,{fields:K.fields,isVisible:K.isVisible,onToggle:K.toggle}),(0,y.jsxs)(`button`,{type:`button`,disabled:L,onClick:$,className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#3566d0] disabled:opacity-40`,children:[(0,y.jsx)(m,{name:`plus`,size:14}),`新建缺陷`]})]})]}),(0,y.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,y.jsx)(De,{ariaLabel:`按状态筛选缺陷`,options:Nt,value:A,onChange:e=>{ct(e),N(1)}})}),x?(0,y.jsx)(xe,{message:x,onClose:()=>S(``)}):null,(0,y.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,y.jsx)(`div`,{ref:_t,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,y.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:J.tableStyle,children:[(0,y.jsx)(`colgroup`,{children:q.map(e=>(0,y.jsx)(`col`,{style:J.widthOf(e.key)?{width:J.widthOf(e.key)}:void 0},e.key))}),(0,y.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,y.jsxs)(`tr`,{children:[(0,y.jsxs)(`th`,{className:`${Ue} relative`,children:[`ID`,(0,y.jsx)(_,{...J.resizeProps(`id`)})]}),(0,y.jsxs)(`th`,{className:Ve,style:{"--tw-sticky-left":`${vt}px`},children:[`缺陷标题`,(0,y.jsx)(_,{...J.resizeProps(`title`)})]}),K.isVisible(`severity`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`严重程度`,(0,y.jsx)(_,{...J.resizeProps(`severity`)})]}):null,K.isVisible(`status`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`缺陷状态`,(0,y.jsx)(_,{...J.resizeProps(`status`)})]}):null,!t&&K.isVisible(`project`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属项目`,(0,y.jsx)(_,{...J.resizeProps(`project`)})]}):null,K.isVisible(`iteration`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属迭代`,(0,y.jsx)(_,{...J.resizeProps(`iteration`)})]}):null,K.isVisible(`createdAt`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,y.jsx)(_,{...J.resizeProps(`createdAt`)})]}):null,K.isVisible(`updatedAt`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,y.jsx)(_,{...J.resizeProps(`updatedAt`)})]}):null,(0,y.jsx)(`th`,{"aria-hidden":`true`}),(0,y.jsx)(`th`,{className:Ie,children:`操作`})]})}),(0,y.jsxs)(`tbody`,{children:[c&&!r.bugs.length?(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:q.length,className:`px-4 py-16 text-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):wt.length===0?(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:q.length,children:X?(0,y.jsx)(Te,{children:`没有符合筛选条件的缺陷。`}):(0,y.jsx)(Ae,{icon:`bug`,title:`暂无缺陷`,hint:`记录第一个缺陷,跟踪严重程度与修复状态。`,action:(0,y.jsxs)(`button`,{type:`button`,onClick:$,className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,y.jsx)(m,{name:`plus`,size:13}),`新建缺陷`]})})})}):null,wt.map(e=>(0,y.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,y.jsx)(`td`,{className:`${He} font-mono text-xs text-stone-400`,children:e.autoId}),(0,y.jsx)(`td`,{className:Be,style:{"--tw-sticky-left":`${vt}px`},children:(0,y.jsx)(he,{text:e.title,onClick:()=>I({id:e.id,projectId:e.projectId,iterationId:e.iterationId,requirementId:e.requirementId,title:e.title,severity:e.severity,status:e.status,reproduceSteps:e.reproduceSteps||e.title,expectedResult:e.expectedResult,actualResult:e.actualResult,environment:e.environment,githubIssue:e.githubIssue,attachment:e.attachment,remark:e.remark})})}),K.isVisible(`severity`)?(0,y.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,y.jsx)(ve,{tone:ke[e.severity],children:o[e.severity]})}):null,K.isVisible(`status`)?(0,y.jsx)(`td`,{className:`min-w-0 overflow-hidden px-2 py-1 align-middle`,children:(0,y.jsx)(l,{unstyled:!0,fitContent:!0,hideChevron:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:L,options:at,value:e.status,onChange:t=>void jt(e,t),renderOptionPrefix:e=>(0,y.jsx)(Oe,{tone:Ee[e.value]}),renderTrigger:()=>(0,y.jsx)(ve,{tone:Ee[e.status],children:le[e.status]})})}):null,!t&&K.isVisible(`project`)?(0,y.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-600`,children:(0,y.jsx)(`a`,{href:ge(e.projectId),className:`block truncate transition-colors hover:text-[#4176e6]`,children:xt(e.projectId)})}):null,K.isVisible(`iteration`)?(0,y.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-500`,children:St(e.iterationId)}):null,K.isVisible(`createdAt`)?(0,y.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:u(e.createdAt)}):null,K.isVisible(`updatedAt`)?(0,y.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:u(e.updatedAt)}):null,(0,y.jsx)(`td`,{"aria-hidden":`true`}),(0,y.jsx)(`td`,{className:Re,children:(0,y.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:L,onClick:()=>U(e),className:`tw-icon-danger inline-flex h-7 w-7 items-center justify-center rounded-md`,children:(0,y.jsx)(m,{name:`trash`,size:15})})})]},e.id))]})]})}),Y.length>0?(0,y.jsx)(Me,{page:Z,totalPages:Ct,pageSize:P,busy:L,onPage:N,onPageSize:e=>{ft(e),N(1)}}):null]}),(0,y.jsx)(be,{open:F!==null,title:F?.id?`编辑缺陷`:`新建缺陷`,busy:L,submitLabel:F?.id?`保存`:`创建`,onClose:At,onSubmit:()=>void Dt(),children:F?(0,y.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,y.jsx)(f,{label:`所属项目`,required:!0,children:(0,y.jsx)(h,{ariaLabel:`所属项目`,options:r.projects.map(e=>({value:e.id,label:e.name})),value:F.projectId,onChange:e=>I({...F,projectId:e,iterationId:``,requirementId:``})})}),(0,y.jsx)(f,{label:`所属迭代`,children:(0,y.jsx)(h,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...Tt.map(e=>({value:e.id,label:e.name}))],value:F.iterationId,onChange:e=>I({...F,iterationId:e}),disabled:Tt.length===0})}),(0,y.jsx)(f,{label:`关联需求`,children:(0,y.jsx)(h,{ariaLabel:`关联需求`,options:[{value:``,label:`不关联需求`},...Et.map(e=>({value:e.id,label:`${e.autoId} ${e.title}`}))],value:F.requirementId,onChange:e=>I({...F,requirementId:e}),disabled:Et.length===0})}),(0,y.jsx)(f,{label:`缺陷描述`,required:!0,children:(0,y.jsx)(`textarea`,{autoFocus:!0,value:F.reproduceSteps,onChange:e=>I({...F,reproduceSteps:e.target.value}),placeholder:`描述问题现象、复现步骤与影响范围`,rows:5,className:ye})}),(0,y.jsx)(f,{label:`严重程度`,children:(0,y.jsx)(h,{ariaLabel:`严重程度`,options:it,value:F.severity,onChange:e=>I({...F,severity:e}),renderOptionPrefix:e=>(0,y.jsx)(Oe,{tone:ke[e.value]})})}),(0,y.jsx)(f,{label:`附件`,children:(0,y.jsxs)(`div`,{className:`space-y-2`,children:[G.length?(0,y.jsx)(`ul`,{className:`space-y-1.5`,children:G.map(e=>{let t=re(e.url);return(0,y.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[t?(0,y.jsx)(`button`,{type:`button`,onClick:()=>W(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,y.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,y.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,y.jsx)(m,{name:`file`,size:15})}),t?(0,y.jsx)(`button`,{type:`button`,onClick:()=>W(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#4176e6]`,children:e.name}):(0,y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`min-w-0 flex-1 truncate text-sm text-stone-700 hover:text-[#4176e6]`,children:e.name}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>kt(e.url),className:`tw-icon-danger flex h-6 w-6 shrink-0 items-center justify-center rounded`,children:`✕`})]},e.url)})}):null,(0,y.jsx)(`input`,{ref:B,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void Q(e.target.files)}),(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`button`,{type:`button`,disabled:z,onClick:()=>B.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-dashed border-stone-300 px-2.5 text-xs text-stone-500 transition-colors hover:border-stone-400 hover:text-stone-700 disabled:opacity-40`,children:[(0,y.jsx)(m,{name:z?`file`:`plus`,size:13}),z?`上传中…`:`上传文件 / 图片`]}),(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可直接粘贴截图 / 图片(⌘V / Ctrl+V),支持多张`})]})]})}),(0,y.jsx)(f,{label:`备注`,children:(0,y.jsx)(`textarea`,{value:F.remark,onChange:e=>I({...F,remark:e.target.value}),rows:2,className:ye})}),F.id?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f,{label:`创建日期`,children:(0,y.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:u(r.bugs.find(e=>e.id===F.id)?.createdAt)})}),(0,y.jsx)(f,{label:`修改日期`,children:(0,y.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:u(r.bugs.find(e=>e.id===F.id)?.updatedAt)})})]}):null]}):null}),(0,y.jsx)(ee,{open:H!==null,title:`删除缺陷`,message:`确定删除「${H?.title??``}」?此操作无法恢复。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>U(null),onConfirm:()=>void Mt()}),(0,y.jsx)(Ce,{file:mt,onClose:()=>W(null)})]})}export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.DQFd6g2r.js";import{o as i}from"./plugins.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.DQFd6g2r.js";import{o as i}from"./plugins.ChGmBEkF.js";import{L as ee,O as te,P as ne,R as a,S as re,a as o,g as s,h as c,k as ie,o as l}from"./pm.BXmOiFfW.js";import{t as u}from"./SelectDropdown.D7IeyHDI.js";import{A as ae,D as oe,O as se,S as ce,_ as d,a as f,c as le,d as ue,f as p,g as m,i as h,j as de,k as g,l as fe,m as _,r as v,s as pe,u as y,v as b,y as x}from"./PmShared.TOjBbtV8.js";import{showToast as S}from"./Toast.BydY-X7T.js";import{t as C}from"./DatePicker.BRO_CjVQ.js";var w=e(t(),1),T=n(),E=10,me=[`all`,...o],he=`pm.iterations.project`,ge=`pm.iterations.status`,_e=`pm.iterations.keyword`,D=o.map(e=>({value:e,label:l[e]}));function O(e=``){return{projectId:e,name:``,startDate:``,endDate:``,status:`planning`,remark:``}}function k({scopeProjectId:e=``}={}){let t=!!e,n=ae(`iterations`),{store:o,live:k,loading:A,error:j,setError:M,reload:N}=de(),[P,F]=g(he,`all`),I=e||P,[L,ve]=se(ge,me,`all`),[R,ye]=g(_e),[be,z]=(0,w.useState)(1),[B,V]=(0,w.useState)(null),[H,U]=(0,w.useState)(!1),[W,G]=(0,w.useState)(null),K=ee(),q=(0,w.useMemo)(()=>{let e=new Map(o.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`未关联项目`},[o.projects]),xe=(0,w.useMemo)(()=>[{value:`all`,label:`全部项目`},...o.projects.map(e=>({value:e.id,label:e.name}))],[o.projects]),J=(0,w.useMemo)(()=>ne(re(o.iterations,{projectId:I,status:L,keyword:R})),[o.iterations,I,L,R]),Y=t?o.iterations.filter(e=>e.projectId===I).length:o.iterations.length,X=Math.max(1,Math.ceil(J.length/E)),Z=Math.min(be,X),Q=J.slice((Z-1)*E,Z*E);(0,w.useEffect)(()=>{t||k===!0&&P!==`all`&&!o.projects.some(e=>e.id===P)&&F(`all`)},[k,o.projects,P,F,t]);async function Se(){if(!B)return;if(!B.projectId){M(`请先选择所属项目`);return}let e=B.name.trim();if(!e)M(`迭代名称不能为空`);else if(B.startDate&&B.endDate&&B.endDate<B.startDate)M(`迭代结束日期不能早于开始日期`);else{U(!0);try{let t={projectId:B.projectId,name:e,startDate:B.startDate,endDate:B.endDate,status:B.status,remark:B.remark};B.id?await a(`iterations`,B.id,t):await c(`iterations`,[t]),V(null),M(``),await N(!0),S(B.id?`已保存迭代`:`已新建迭代`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),S(`保存迭代失败:${t}`,`error`)}finally{U(!1)}}}async function $(e,t){U(!0);try{await a(`iterations`,e.id,{status:t}),await N(!0),S(`已更新迭代状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),S(`更新迭代失败:${t}`,`error`)}finally{U(!1)}}async function Ce(){let e=W;if(e){G(null),U(!0);try{await s(`iterations`,[e.id]),await N(!0),S(`已删除迭代`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),S(`删除迭代失败:${t}`,`error`)}finally{U(!1)}}}return n.ready?n.on?k===null?(0,T.jsx)(m,{label:`正在连接项目管理服务`}):k?o.projects.length===0&&!A&&!t?(0,T.jsx)(d,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护迭代。`}):(0,T.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-600`,children:Y}),` 个迭代`,J.length===Y?``:` · 筛选出 ${J.length} 个`]}),(0,T.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,T.jsx)(u,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选迭代`,className:`w-36`,options:xe,value:P,onChange:e=>{F(e),z(1)}}),(0,T.jsx)(u,{flat:!0,showCheck:!1,ariaLabel:`按状态筛选迭代`,className:`w-28`,options:[{value:`all`,label:`全部状态`},...D],value:L,onChange:e=>{ve(e),z(1)}}),(0,T.jsxs)(`label`,{className:`relative block`,children:[(0,T.jsx)(_,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,T.jsx)(`input`,{value:R,onChange:e=>{ye(e.target.value),z(1)},placeholder:`搜索迭代名称…`,className:`h-9 w-44 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#4176e6]`})]}),(0,T.jsxs)(`button`,{type:`button`,disabled:H,onClick:()=>V(O(I===`all`?``:I)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#3566d0] disabled:opacity-40`,children:[(0,T.jsx)(_,{name:`plus`,size:14}),`新建迭代`]})]})]}),j?(0,T.jsx)(ue,{message:j,onClose:()=>M(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pb-4`,children:A&&!o.iterations.length?(0,T.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):Q.length===0?Y?(0,T.jsx)(fe,{children:`没有符合筛选条件的迭代。`}):(0,T.jsx)(y,{icon:`calendar`,title:`暂无迭代`,hint:`新建一个迭代,用开始 / 截止日期跟踪进度。`,action:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>V(O(I===`all`?``:I)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,T.jsx)(_,{name:`plus`,size:13}),`新建迭代`]})}):(0,T.jsx)(`div`,{className:`space-y-3`,children:Q.map(e=>{let n=ie(e,K),r=te(e,K),i=e.endDate&&e.status!==`done`?Math.round((Date.parse(`${e.endDate}T00:00:00`)-Date.parse(`${K}T00:00:00`))/864e5):null;return(0,T.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3.5 transition-[border-color,box-shadow] hover:border-[#ddd6fe] hover:shadow-sm`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`truncate text-[15px] font-medium text-stone-800`,children:e.name}),(0,T.jsx)(ce,{tone:v[e.status],children:l[e.status]})]}),(0,T.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-stone-500`,children:[t?null:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`a`,{href:oe(e.projectId),className:`transition-colors hover:text-[#4176e6]`,children:q(e.projectId)}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`})]}),(0,T.jsxs)(`span`,{className:`tabular-nums`,children:[e.startDate||`—`,` → `,e.endDate||`—`]}),r===null?i!==null&&i>=0&&e.endDate?(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[`还剩 `,i,` 天`]}):null:(0,T.jsxs)(`span`,{className:`text-red-500`,children:[`逾期 `,r,` 天`]})]}),e.remark?(0,T.jsx)(`p`,{className:`mt-1 line-clamp-1 text-xs text-stone-400`,children:e.remark}):null]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.status===`planning`?(0,T.jsxs)(`button`,{type:`button`,disabled:H,onClick:()=>void $(e,`in_progress`),className:`inline-flex h-8 items-center gap-1 rounded-lg px-2 text-xs text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:[(0,T.jsx)(_,{name:`play`,size:12}),`开始`]}):null,e.status===`in_progress`?(0,T.jsxs)(`button`,{type:`button`,disabled:H,onClick:()=>void $(e,`done`),className:`inline-flex h-8 items-center gap-1 rounded-lg px-2 text-xs text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:[(0,T.jsx)(_,{name:`check`,size:12}),`完成`]}):null,(0,T.jsx)(`button`,{type:`button`,"aria-label":`编辑 ${e.name}`,onClick:()=>V({id:e.id,projectId:e.projectId,name:e.name,startDate:e.startDate,endDate:e.endDate,status:e.status,remark:e.remark}),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,children:(0,T.jsx)(_,{name:`pencil`,size:15})}),(0,T.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.name}`,disabled:H,onClick:()=>G(e),className:`tw-icon-danger flex h-8 w-8 items-center justify-center rounded-lg`,children:(0,T.jsx)(_,{name:`trash`,size:15})})]})]}),(0,T.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,T.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,T.jsx)(`div`,{className:`h-full rounded-full bg-[#4176e6] transition-[width] duration-300`,style:{width:`${n}%`}})}),(0,T.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs tabular-nums text-stone-500`,children:[n,`%`]})]})]},e.id)})})}),J.length>0?(0,T.jsx)(b,{page:Z,totalPages:X,busy:H,onPage:z}):null,(0,T.jsx)(le,{open:B!==null,title:B?.id?`编辑迭代`:`新建迭代`,busy:H,submitLabel:B?.id?`保存`:`创建`,onClose:()=>V(null),onSubmit:()=>void Se(),children:B?(0,T.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,T.jsx)(p,{label:`所属项目`,required:!0,children:(0,T.jsx)(x,{ariaLabel:`所属项目`,options:o.projects.map(e=>({value:e.id,label:e.name})),value:B.projectId,onChange:e=>V({...B,projectId:e}),disabled:o.projects.length===0})}),(0,T.jsx)(p,{label:`迭代名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:B.name,onChange:e=>V({...B,name:e.target.value}),placeholder:`如:v1.0 迭代`,className:h})}),(0,T.jsx)(p,{label:`开始日期`,children:(0,T.jsx)(C,{value:B.startDate,onChange:e=>V({...B,startDate:e}),placeholder:`选择开始日期`,className:`${h} tabular-nums`})}),(0,T.jsx)(p,{label:`截止日期`,children:(0,T.jsx)(C,{value:B.endDate,onChange:e=>V({...B,endDate:e}),placeholder:`选择截止日期`,className:`${h} tabular-nums`})}),(0,T.jsx)(p,{label:`状态`,children:(0,T.jsx)(x,{ariaLabel:`迭代状态`,options:D,value:B.status,onChange:e=>V({...B,status:e}),renderOptionPrefix:e=>(0,T.jsx)(pe,{tone:v[e.value]})})}),(0,T.jsx)(p,{label:`备注`,children:(0,T.jsx)(`textarea`,{value:B.remark,onChange:e=>V({...B,remark:e.target.value}),placeholder:`迭代目标、范围等(可选)`,rows:3,className:f})})]}):null}),(0,T.jsx)(r,{open:W!==null,title:`删除迭代`,message:`确定删除「${W?.name??``}」?关联的需求与缺陷会保留,但不再关联到这个迭代。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>G(null),onConfirm:()=>void Ce()})]}):(0,T.jsx)(d,{children:`迭代管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(d,{children:i(`iterations`)}):(0,T.jsx)(m,{label:`正在读取插件开关`})}export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{o as r}from"./plugins.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{o as r}from"./plugins.ChGmBEkF.js";import{M as i,c as a}from"./pm.BXmOiFfW.js";import{A as o,O as s,S as c,_ as l,b as u,g as d,j as f,m as p,o as m,u as h,x as g}from"./PmShared.TOjBbtV8.js";import _ from"./PmBugsBoard.Ddl3kqqt.js";import v from"./PmIterationsBoard.BJN7disI.js";import{t as y}from"./PmRequirementsBoard.DarfGIrL.js";var b=e(t(),1),x=n(),S=[`iterations`,`requirements`,`bugs`],C=`pm.project.tab`,w=`/pm/projects/`;function T(){let e=o(`projects`);return e.ready?e.on?(0,x.jsx)(u,{children:(0,x.jsx)(E,{})}):(0,x.jsx)(l,{children:r(`projects`)}):(0,x.jsx)(d,{label:`正在读取插件开关`})}function E(){let{store:e,live:t,loading:n}=f(),[r,o]=(0,b.useState)(``),[u,T]=s(C,S,`iterations`);(0,b.useEffect)(()=>{o(new URLSearchParams(window.location.search).get(`id`)??``)},[]);let E=(0,b.useMemo)(()=>e.projects.find(e=>e.id===r),[e.projects,r]),O=(0,b.useMemo)(()=>i(e),[e]);if(t===null)return(0,x.jsx)(d,{label:`正在连接项目管理服务`});if(!t)return(0,x.jsx)(l,{children:`项目详情需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(!E)return n&&!e.projects.length?(0,x.jsx)(d,{label:`正在读取项目`}):(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsx)(D,{}),(0,x.jsx)(h,{icon:`folder`,title:`没有找到这个项目`,hint:`它可能已被删除,或链接里的项目 id 不正确。`})]});let k=O[E.id],A=[{value:`iterations`,label:`迭代`,count:k?.iterations??0},{value:`requirements`,label:`需求`,count:k?.requirements??0},{value:`bugs`,label:`缺陷`,count:k?.bugs??0}];return(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3`,children:[(0,x.jsx)(`a`,{href:w,"aria-label":`返回项目列表`,className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-stone-500 transition-colors hover:bg-stone-100 hover:text-stone-800`,children:(0,x.jsx)(p,{name:`arrowLeft`,size:18})}),(0,x.jsx)(`span`,{className:`tw-pm-tile flex h-9 w-9 shrink-0 items-center justify-center rounded-xl text-sm font-bold`,children:E.name.slice(0,1)}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`h1`,{className:`truncate text-lg font-semibold text-stone-800`,children:E.name}),(0,x.jsx)(c,{tone:m[E.status],children:a[E.status]})]}),(0,x.jsx)(`p`,{className:`mt-0.5 text-xs ${E.description?`text-stone-400`:`text-stone-300 italic`}`,children:E.description||`暂无描述`})]})]}),(0,x.jsxs)(`div`,{className:`mt-5 flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[(0,x.jsx)(g,{tabs:A,value:u,onChange:T,ariaLabel:`项目二级菜单`}),(0,x.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`需求完成 `,k?.requirementPercent??0,`% · 缺陷完成 `,k?.bugClosedPercent??100,`%`]})]}),(0,x.jsxs)(`div`,{className:`mt-4 flex min-h-0 flex-1 flex-col`,children:[u===`iterations`?(0,x.jsx)(v,{scopeProjectId:E.id}):null,u===`requirements`?(0,x.jsx)(y,{scopeProjectId:E.id}):null,u===`bugs`?(0,x.jsx)(_,{scopeProjectId:E.id}):null]})]})}function D(){return(0,x.jsxs)(`a`,{href:w,className:`mb-2 inline-flex w-fit items-center gap-1.5 text-sm text-stone-500 transition-colors hover:text-stone-800`,children:[(0,x.jsx)(p,{name:`arrowLeft`,size:16}),`返回项目列表`]})}export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.DQFd6g2r.js";import{o as r}from"./plugins.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.DQFd6g2r.js";import{o as r}from"./plugins.ChGmBEkF.js";import{C as te,M as i,R as a,c as o,g as ne,h as re,s}from"./pm.BXmOiFfW.js";import{t as c}from"./SelectDropdown.D7IeyHDI.js";import{A as l,D as u,O as d,S as f,_ as p,a as m,c as h,d as ie,f as g,g as _,i as ae,j as oe,k as se,l as ce,m as v,o as y,s as le,u as b,v as x,y as S}from"./PmShared.TOjBbtV8.js";import{showToast as C}from"./Toast.BydY-X7T.js";var w=e(t(),1),T=n(),E=10,D=s.map(e=>({value:e,label:o[e]})),O=[`all`,...s],k=`pm.projects.status`,A=`pm.projects.keyword`;function j(){return{name:``,description:``,status:`planning`}}function M(){let e=l(`projects`),{store:t,live:n,loading:s,error:M,setError:N,reload:P}=oe(),[F,I]=d(k,O,`all`),[L,R]=se(A),[z,B]=(0,w.useState)(1),[V,H]=(0,w.useState)(null),[U,W]=(0,w.useState)(!1),[G,K]=(0,w.useState)(null),[q,J]=(0,w.useState)(null),Y=(0,w.useRef)(null),ue=(0,w.useMemo)(()=>i(t),[t]),X=(0,w.useMemo)(()=>te(t.projects,{status:F,keyword:L}),[t.projects,F,L]),Z=Math.max(1,Math.ceil(X.length/E)),Q=Math.min(z,Z),$=X.slice((Q-1)*E,Q*E);(0,w.useEffect)(()=>{if(!q)return;function e(e){Y.current?.contains(e.target)||J(null)}function t(e){e.key===`Escape`&&J(null)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[q]);async function de(){if(!V)return;let e=V.name.trim();if(!e)N(`项目名称不能为空`);else{W(!0);try{V.id?await a(`projects`,V.id,{name:e,description:V.description,status:V.status}):await re(`projects`,[{name:e,description:V.description,status:V.status}]),H(null),N(``),await P(!0),C(V.id?`已保存项目`:`已新建项目`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),C(`保存项目失败:${t}`,`error`)}finally{W(!1)}}}async function fe(e){J(null),W(!0);try{let t=e.status!==`archived`;await a(`projects`,e.id,{status:t?`archived`:`planning`}),await P(!0),C(t?`已归档「${e.name}」`:`已取消归档「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),C(`更新项目失败:${t}`,`error`)}finally{W(!1)}}async function pe(){let e=G;if(e){K(null),W(!0);try{await ne(`projects`,[e.id]),await P(!0),C(`已删除项目`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),C(`删除项目失败:${t}`,`error`)}finally{W(!1)}}}return e.ready?e.on?n===null?(0,T.jsx)(_,{label:`正在连接项目管理服务`}):n?(0,T.jsxs)(`section`,{className:`flex min-h-0 flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsx)(`div`,{className:`text-xs text-stone-400`,children:t.projects.length?(0,T.jsxs)(T.Fragment,{children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-600`,children:t.projects.length}),` 个项目`,X.length===t.projects.length?``:` · 筛选出 ${X.length} 个`]}):`暂无项目`}),(0,T.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(c,{flat:!0,showCheck:!1,ariaLabel:`按状态筛选项目`,className:`w-32`,options:[{value:`all`,label:`全部状态`},...D],value:F,onChange:e=>{I(e),B(1)}}),(0,T.jsxs)(`label`,{className:`relative block`,children:[(0,T.jsx)(v,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,T.jsx)(`input`,{value:L,onChange:e=>{R(e.target.value),B(1)},placeholder:`搜索项目名称 / 描述…`,className:`h-9 w-52 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#4176e6]`})]}),(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>H(j()),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#3566d0] disabled:opacity-40`,children:[(0,T.jsx)(v,{name:`plus`,size:14}),`新建项目`]})]})]}),M?(0,T.jsx)(ie,{message:M,onClose:()=>N(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pt-1 pb-4`,children:s&&!t.projects.length?(0,T.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):$.length===0?t.projects.length?(0,T.jsx)(ce,{children:`没有符合筛选条件的项目。`}):(0,T.jsx)(b,{icon:`folder`,title:`暂无项目`,hint:`创建第一个项目开始吧`,action:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>H(j()),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,T.jsx)(v,{name:`plus`,size:13}),`新建项目`]})}):(0,T.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3`,children:$.map(e=>{let t=ue[e.id];return(0,T.jsxs)(`article`,{className:`tw-pm-card group relative rounded-2xl border border-stone-200 bg-white`,children:[(0,T.jsx)(`span`,{className:`pointer-events-none absolute inset-0 overflow-hidden rounded-2xl`,"aria-hidden":`true`,children:(0,T.jsx)(`span`,{className:`tw-pm-card-accent absolute -right-6 -top-6 h-20 w-20 rounded-full bg-[#f1edff]`})}),(0,T.jsx)(`a`,{href:u(e.id),"aria-label":`打开项目 ${e.name}`,className:`absolute inset-0 z-0 rounded-2xl`}),(0,T.jsxs)(`div`,{className:`pointer-events-none relative z-10 flex h-full flex-col p-5`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,T.jsx)(`span`,{className:`tw-pm-tile flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-xs font-bold`,children:e.name.slice(0,1)}),(0,T.jsx)(`h3`,{className:`truncate text-[15px] font-semibold text-stone-800`,children:e.name})]}),(0,T.jsx)(f,{tone:y[e.status],children:o[e.status]})]}),(0,T.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-[40px] text-sm ${e.description?`text-stone-500`:`italic text-stone-300`}`,children:e.description||`暂无描述`}),(0,T.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-xs text-stone-500`,children:[(0,T.jsxs)(`span`,{children:[t?.iterations??0,` 迭代`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.requirements??0,` 需求`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.bugs??0,` 缺陷`]})]}),(0,T.jsxs)(`div`,{className:`mt-auto flex items-center justify-between pt-4`,children:[(0,T.jsxs)(`div`,{className:`pointer-events-auto relative`,ref:q===e.id?Y:void 0,children:[(0,T.jsx)(`button`,{type:`button`,"aria-label":`${e.name} 的操作`,"aria-haspopup":`menu`,"aria-expanded":q===e.id,onClick:()=>J(q===e.id?null:e.id),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,children:(0,T.jsx)(v,{name:`more`,size:18})}),q===e.id?(0,T.jsxs)(`div`,{role:`menu`,className:`absolute left-0 top-9 z-30 w-36 overflow-hidden rounded-lg border border-stone-200 bg-white py-1 shadow-lg`,children:[(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{J(null),H({id:e.id,name:e.name,description:e.description,status:e.status})},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-stone-700 hover:bg-stone-50`,children:[(0,T.jsx)(v,{name:`pencil`,size:14}),`编辑`]}),(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>void fe(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-stone-700 hover:bg-stone-50`,children:[(0,T.jsx)(v,{name:`folder`,size:14}),e.status===`archived`?`取消归档`:`归档`]}),(0,T.jsx)(`div`,{className:`my-1 border-t border-stone-100`}),(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{J(null),K(e)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-red-600 hover:bg-red-50`,children:[(0,T.jsx)(v,{name:`trash`,size:14}),`删除`]})]}):null]}),(0,T.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-stone-400`,children:[`需求完成 `,t?.requirementPercent??0,`%`,(0,T.jsx)(v,{name:`chevronRight`,size:14,className:`tw-pm-card-chevron text-stone-300`})]})]})]})]},e.id)})})}),X.length>0?(0,T.jsx)(x,{page:Q,totalPages:Z,busy:U,onPage:B}):null,(0,T.jsx)(h,{open:V!==null,title:V?.id?`编辑项目`:`新建项目`,busy:U,submitLabel:V?.id?`保存`:`创建`,onClose:()=>H(null),onSubmit:()=>void de(),children:V?(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(g,{label:`项目名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),placeholder:`输入项目名称`,className:ae})}),(0,T.jsx)(g,{label:`描述`,children:(0,T.jsx)(`textarea`,{value:V.description,onChange:e=>H({...V,description:e.target.value}),placeholder:`项目描述(可选)`,rows:4,className:m})}),(0,T.jsx)(g,{label:`状态`,children:(0,T.jsx)(S,{ariaLabel:`项目状态`,options:D,value:V.status,onChange:e=>H({...V,status:e}),renderOptionPrefix:e=>(0,T.jsx)(le,{tone:y[e.value]})})})]}):null}),(0,T.jsx)(ee,{open:G!==null,title:`删除项目`,message:`确定删除「${G?.name??``}」?该项目下的迭代、需求与缺陷会一并删除,且无法恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:`solid`,onClose:()=>K(null),onConfirm:()=>void pe()})]}):(0,T.jsx)(p,{children:`项目列表需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(p,{children:r(`projects`)}):(0,T.jsx)(_,{label:`正在读取插件开关`})}export{M as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{t as default}from"./PmRequirementsBoard.DarfGIrL.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.DQFd6g2r.js";import{o as i}from"./plugins.Db9xoFZb.js";import{A as a,D as o,F as s,P as c,R as l,b as u,d,f,g as ee,h as te,j as p,l as m,m as ne,u as h,w as g,z as _}from"./pm.BXmOiFfW.js";import{t as v}from"./SelectDropdown.D7IeyHDI.js";import{A as y,C as re,D as ie,E as b,O as ae,S as oe,T as x,_ as S,a as se,c as ce,d as le,f as C,g as ue,h as w,j as de,k as T,l as fe,m as E,p as pe,s as D,u as me,w as he,y as O}from"./PmShared.BQVzwsiz.js";import{showToast as k}from"./Toast.BydY-X7T.js";import{n as ge,t as _e}from"./DocsPager.DMN9-Tjg.js";import{n as ve,r as ye,t as be}from"./TableFieldConfig.72AL-8p-.js";import{c as xe,d as Se,i as Ce,l as we,n as Te,o as Ee,r as De,s as Oe,t as A}from"./ColumnResize.CkE59sGq.js";var j=e(t(),1),M=n();function ke({value:e,onChange:t,entity:n,recordId:r=``,seenUrls:i,onError:s,onPersisted:c}){let d=p(e),[f,ee]=(0,j.useState)(!1),[te,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(null),v=(0,j.useRef)(null);(0,j.useEffect)(()=>{for(let t of p(e))i.current.add(t.url)},[e,i]);let y=(0,j.useCallback)(async n=>{if(n&&n.length){ee(!0);try{let r=await _(Array.from(n));t(a([...p(e),...r])),s(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{ee(!1),v.current&&(v.current.value=``)}}},[t,s,e]);(0,j.useEffect)(()=>{let e=e=>{let t=u(e.clipboardData);t.length&&(e.preventDefault(),y(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[y]);async function re(e){let i=a(d.filter(t=>t.url!==e));if(r)try{await l(n,r,{attachment:i}),c?.()}catch(e){s(e instanceof Error?e.message:String(e));return}t(i),ne([e],r)}return(0,M.jsxs)(`div`,{className:`space-y-2 rounded-lg transition-colors ${te?`bg-[#4176e6]/5 ring-1 ring-[#4176e6]/40`:``}`,onDragOver:e=>{e.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:e=>{e.preventDefault(),m(!1),y(e.dataTransfer?.files??null)},children:[d.length?(0,M.jsx)(`ul`,{className:`space-y-1.5`,children:d.map(e=>(0,M.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[o(e.url)?(0,M.jsx)(`button`,{type:`button`,onClick:()=>g(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,M.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,M.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,M.jsx)(E,{name:`file`,size:15})}),o(e.url)?(0,M.jsx)(`button`,{type:`button`,onClick:()=>g(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#4176e6]`,children:e.name}):(0,M.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`min-w-0 flex-1 truncate text-sm text-stone-700 hover:text-[#4176e6]`,children:e.name}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>void re(e.url),className:`tw-icon-danger flex h-6 w-6 shrink-0 items-center justify-center rounded`,children:`✕`})]},e.url))}):null,(0,M.jsx)(`input`,{ref:v,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void y(e.target.files)}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsxs)(`button`,{type:`button`,disabled:f,onClick:()=>v.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-dashed border-stone-300 px-2.5 text-xs text-stone-500 transition-colors hover:border-stone-400 hover:text-stone-700 disabled:opacity-40`,children:[(0,M.jsx)(E,{name:f?`file`:`plus`,size:13}),f?`上传中…`:`上传文件 / 图片`]}),(0,M.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可拖拽到这里,或直接粘贴截图(⌘V / Ctrl+V),支持多张`})]}),(0,M.jsx)(w,{file:h,onClose:()=>g(null)})]})}var Ae=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`priority`,width:100,min:80},{key:`status`,width:120,min:96}],je={key:`project`,width:140,min:100},Me=[{key:`iteration`,width:120,min:88},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],Ne=new Set([`id`,`title`,`filler`,`action`]),Pe=[{key:`priority`,label:`优先级`},{key:`status`,label:`需求状态`},{key:`iteration`,label:`所属迭代`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Fe=`pm.requirements.fields`,Ie=20,Le=`tw.pm-requirements.page-size.v1`,Re=[`all`,...d],ze=[`all`,...m],Be=`pm.requirements.project`,Ve=`pm.requirements.iteration`,He=`pm.requirements.status`,Ue=`pm.requirements.priority`,We=`pm.requirements.keyword`,Ge=m.map(e=>({value:e,label:h[e]})),N=d.map(e=>({value:e,label:f[e]}));function Ke(e=``){return{projectId:e,iterationId:``,title:``,priority:`medium`,status:`pending`,description:``,acceptanceCriteria:[],githubIssue:``,attachment:``}}function P({scopeProjectId:e=``}={}){let t=!!e,n=y(`pmRequirements`),{store:a,live:o,loading:u,error:d,setError:m,reload:_}=de(),[w,P]=T(Be,`all`),F=e||w,[I,L]=T(Ve,`all`),[R,qe]=ae(He,Re,`all`),[z,Je]=ae(Ue,ze,`all`),[B,Ye]=T(We),[Xe,V]=(0,j.useState)(1),[H,Ze]=ge(Ie,Le),[U,W]=(0,j.useState)(null),[G,K]=(0,j.useState)(!1),[q,J]=(0,j.useState)(null),Y=(0,j.useRef)(new Set),Qe=(0,j.useMemo)(()=>t?Pe:[{key:`project`,label:`所属项目`},...Pe],[t]),X=ye(Fe,Qe,Ne),$e=(0,j.useMemo)(()=>t?[...Ae,...Me]:[...Ae,je,...Me],[t]),Z=(0,j.useMemo)(()=>ve($e,X.isVisible),[$e,X.isVisible]),Q=we(t?`pm.requirements.cols.scoped.v2`:`pm.requirements.cols.v2`,Z),et=Se(t?`pm.requirements.scroll.scoped`:`pm.requirements.scroll`),tt=Q.widthOf(`id`)??88,nt=(0,j.useMemo)(()=>[{value:`all`,label:`全部项目`},...a.projects.map(e=>({value:e.id,label:e.name}))],[a.projects]),rt=(0,j.useMemo)(()=>[{value:`all`,label:`全部迭代`},...c(a.iterations.filter(e=>F===`all`||e.projectId===F)).map(e=>({value:e.id,label:e.name}))],[a.iterations,F]),it=(0,j.useMemo)(()=>{let e=new Map(a.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[a.projects]),at=(0,j.useMemo)(()=>{let e=new Map(a.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[a.iterations]),$=(0,j.useMemo)(()=>s(g(a.requirements,{projectId:F,iterationId:I,status:R,priority:z,keyword:B})),[a.requirements,F,I,R,z,B]),ot=t?a.requirements.filter(e=>e.projectId===F).length:a.requirements.length,st=Math.max(1,Math.ceil($.length/H)),ct=Math.min(Xe,st),lt=$.slice((ct-1)*H,ct*H);(0,j.useEffect)(()=>{t||o===!0&&w!==`all`&&!a.projects.some(e=>e.id===w)&&P(`all`)},[o,a.projects,w,P,t]),(0,j.useEffect)(()=>{o===!0&&I!==`all`&&!a.iterations.some(e=>e.id===I&&(F===`all`||e.projectId===F))&&L(`all`)},[o,a.iterations,F,I,L]);let ut=U?c(a.iterations.filter(e=>e.projectId===U.projectId)):[];async function dt(){if(!U)return;if(!U.projectId){m(`请先选择所属项目`);return}let e=U.title.trim();if(!e)m(`需求描述不能为空`);else{K(!0);try{let t={projectId:U.projectId,iterationId:U.iterationId,title:e,priority:U.priority,status:U.status,description:U.description,acceptanceCriteria:U.acceptanceCriteria.filter(e=>e.text.trim()),githubIssue:U.githubIssue,attachment:U.attachment};U.id?await l(`requirements`,U.id,t):await te(`requirements`,[t]);let n=!!U.id;W(null),Y.current.clear(),m(``),await _(!0),k(n?`已保存需求`:`已新建需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);m(t),k(`保存需求失败:${t}`,`error`)}finally{K(!1)}}}function ft(){let e=[...Y.current,...p(U?.attachment??``).map(e=>e.url)];Y.current.clear(),W(null),e.length&&ne(e)}async function pt(e,t){K(!0);try{await l(`requirements`,e.id,{status:t}),await _(!0),k(`已更新需求状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);m(t),k(`更新状态失败:${t}`,`error`)}finally{K(!1)}}async function mt(){let e=q;if(e){J(null),K(!0);try{await ee(`requirements`,[e.id]),await _(!0),k(`已删除需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);m(t),k(`删除需求失败:${t}`,`error`)}finally{K(!1)}}}if(!n.ready)return(0,M.jsx)(ue,{label:`正在读取插件开关`});if(!n.on)return(0,M.jsx)(S,{children:i(`pmRequirements`)});if(o===null)return(0,M.jsx)(ue,{label:`正在连接项目管理服务`});if(!o)return(0,M.jsx)(S,{children:`需求管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(a.projects.length===0&&!u&&!t)return(0,M.jsx)(S,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护需求。`});let ht=[{value:`all`,label:`全部`},...N];return(0,M.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,M.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:ot}),` 条需求`,$.length===ot?``:` · 筛选出 ${$.length} 条`]}),(0,M.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,M.jsx)(v,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选需求`,className:`w-36`,options:nt,value:w,onChange:e=>{P(e),L(`all`),V(1)}}),(0,M.jsx)(v,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选需求`,className:`w-32`,options:rt,value:I,onChange:e=>{L(e),V(1)}}),(0,M.jsx)(v,{flat:!0,showCheck:!1,ariaLabel:`按优先级筛选需求`,className:`w-28`,options:[{value:`all`,label:`全部优先级`},...Ge],value:z,onChange:e=>{Je(e),V(1)}}),(0,M.jsxs)(`label`,{className:`relative block`,children:[(0,M.jsx)(E,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,M.jsx)(`input`,{value:B,onChange:e=>{Ye(e.target.value),V(1)},placeholder:`搜索编号 / 名称…`,className:`h-9 w-44 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#4176e6]`})]}),(0,M.jsx)(be,{fields:X.fields,isVisible:X.isVisible,onToggle:X.toggle}),(0,M.jsxs)(`button`,{type:`button`,disabled:G,onClick:()=>W(Ke(F===`all`?``:F)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#3566d0] disabled:opacity-40`,children:[(0,M.jsx)(E,{name:`plus`,size:14}),`新建需求`]})]})]}),(0,M.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,M.jsx)(pe,{ariaLabel:`按状态筛选需求`,options:ht,value:R,onChange:e=>{qe(e),V(1)}})}),d?(0,M.jsx)(le,{message:d,onClose:()=>m(``)}):null,(0,M.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{ref:et,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,M.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:Q.tableStyle,children:[(0,M.jsx)(`colgroup`,{children:Z.map(e=>(0,M.jsx)(`col`,{style:Q.widthOf(e.key)?{width:Q.widthOf(e.key)}:void 0},e.key))}),(0,M.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,M.jsxs)(`tr`,{children:[(0,M.jsxs)(`th`,{className:`${Oe} relative`,children:[`ID`,(0,M.jsx)(A,{...Q.resizeProps(`id`)})]}),(0,M.jsxs)(`th`,{className:Ee,style:{"--tw-sticky-left":`${tt}px`},children:[`需求描述`,(0,M.jsx)(A,{...Q.resizeProps(`title`)})]}),X.isVisible(`priority`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`优先级`,(0,M.jsx)(A,{...Q.resizeProps(`priority`)})]}):null,X.isVisible(`status`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`需求状态`,(0,M.jsx)(A,{...Q.resizeProps(`status`)})]}):null,!t&&X.isVisible(`project`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属项目`,(0,M.jsx)(A,{...Q.resizeProps(`project`)})]}):null,X.isVisible(`iteration`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属迭代`,(0,M.jsx)(A,{...Q.resizeProps(`iteration`)})]}):null,X.isVisible(`createdAt`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,M.jsx)(A,{...Q.resizeProps(`createdAt`)})]}):null,X.isVisible(`updatedAt`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,M.jsx)(A,{...Q.resizeProps(`updatedAt`)})]}):null,(0,M.jsx)(`th`,{"aria-hidden":`true`}),(0,M.jsx)(`th`,{className:xe,children:`操作`})]})}),(0,M.jsxs)(`tbody`,{children:[u&&!a.requirements.length?(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{colSpan:Z.length,className:`px-4 py-16 text-center`,children:(0,M.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):lt.length===0?(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{colSpan:Z.length,children:ot?(0,M.jsx)(fe,{children:`没有符合筛选条件的需求。`}):(0,M.jsx)(me,{icon:`file`,title:`暂无需求`,hint:`拆出第一条需求,再关联迭代、补充描述。`,action:(0,M.jsxs)(`button`,{type:`button`,onClick:()=>W(Ke(F===`all`?``:F)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(E,{name:`plus`,size:13}),`新建需求`]})})})}):null,lt.map(e=>(0,M.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,M.jsx)(`td`,{className:`${De} font-mono text-xs text-stone-400`,children:e.autoId}),(0,M.jsx)(`td`,{className:Te,style:{"--tw-sticky-left":`${tt}px`},children:(0,M.jsx)(re,{text:e.title,onClick:()=>W({id:e.id,projectId:e.projectId,iterationId:e.iterationId,title:e.title,priority:e.priority,status:e.status,description:e.description,acceptanceCriteria:e.acceptanceCriteria.map(e=>({...e})),githubIssue:e.githubIssue,attachment:e.attachment})})}),X.isVisible(`priority`)?(0,M.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,M.jsx)(oe,{tone:he[e.priority],children:h[e.priority]})}):null,X.isVisible(`status`)?(0,M.jsx)(`td`,{className:`min-w-0 overflow-hidden px-2 py-1 align-middle`,children:(0,M.jsx)(v,{unstyled:!0,fitContent:!0,hideChevron:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:G,options:N,value:e.status,onChange:t=>void pt(e,t),renderOptionPrefix:e=>(0,M.jsx)(D,{tone:x[e.value]}),renderTrigger:()=>(0,M.jsx)(oe,{tone:x[e.status],children:f[e.status]})})}):null,!t&&X.isVisible(`project`)?(0,M.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-600`,children:(0,M.jsx)(`a`,{href:ie(e.projectId),className:`block truncate transition-colors hover:text-[#4176e6]`,children:it(e.projectId)})}):null,X.isVisible(`iteration`)?(0,M.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-500`,children:at(e.iterationId)}):null,X.isVisible(`createdAt`)?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:b(e.createdAt)}):null,X.isVisible(`updatedAt`)?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:b(e.updatedAt)}):null,(0,M.jsx)(`td`,{"aria-hidden":`true`}),(0,M.jsx)(`td`,{className:Ce,children:(0,M.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:G,onClick:()=>J(e),className:`tw-icon-danger inline-flex h-7 w-7 items-center justify-center rounded-md`,children:(0,M.jsx)(E,{name:`trash`,size:15})})})]},e.id))]})]})}),$.length>0?(0,M.jsx)(_e,{page:ct,totalPages:st,pageSize:H,busy:G,onPage:V,onPageSize:e=>{Ze(e),V(1)}}):null]}),(0,M.jsx)(ce,{open:U!==null,title:U?.id?`编辑需求`:`新建需求`,busy:G,submitLabel:U?.id?`保存`:`创建`,onClose:()=>ft(),onSubmit:()=>void dt(),children:U?(0,M.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,M.jsx)(C,{label:`所属项目`,required:!0,children:(0,M.jsx)(O,{ariaLabel:`所属项目`,options:a.projects.map(e=>({value:e.id,label:e.name})),value:U.projectId,onChange:e=>{let t=a.iterations.some(t=>t.id===U.iterationId&&t.projectId===e);W({...U,projectId:e,iterationId:t?U.iterationId:``})}})}),(0,M.jsx)(C,{label:`所属迭代`,children:(0,M.jsx)(O,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...ut.map(e=>({value:e.id,label:e.name}))],value:U.iterationId,onChange:e=>W({...U,iterationId:e}),disabled:ut.length===0})}),(0,M.jsx)(C,{label:`需求描述`,required:!0,children:(0,M.jsx)(`textarea`,{autoFocus:!0,value:U.title,onChange:e=>W({...U,title:e.target.value}),placeholder:`一句话写清要做什么`,rows:3,className:se})}),(0,M.jsx)(C,{label:`优先级`,children:(0,M.jsx)(O,{ariaLabel:`优先级`,options:Ge,value:U.priority,onChange:e=>W({...U,priority:e}),renderOptionPrefix:e=>(0,M.jsx)(D,{tone:he[e.value]})})}),(0,M.jsx)(C,{label:`需求状态`,children:(0,M.jsx)(O,{ariaLabel:`需求状态`,options:N,value:U.status,onChange:e=>W({...U,status:e}),renderOptionPrefix:e=>(0,M.jsx)(D,{tone:x[e.value]})})}),(0,M.jsx)(C,{label:`附件`,children:(0,M.jsx)(ke,{value:U.attachment,onChange:e=>W(t=>t&&{...t,attachment:e}),entity:`requirements`,recordId:U.id??``,seenUrls:Y,onError:m,onPersisted:()=>void _(!0)})}),(0,M.jsx)(C,{label:`备注`,children:(0,M.jsx)(`textarea`,{value:U.description,onChange:e=>W({...U,description:e.target.value}),placeholder:`补充背景、目标与范围(可选)`,rows:4,className:se})}),U.id?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(C,{label:`创建日期`,children:(0,M.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:b(a.requirements.find(e=>e.id===U.id)?.createdAt)})}),(0,M.jsx)(C,{label:`修改日期`,children:(0,M.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:b(a.requirements.find(e=>e.id===U.id)?.updatedAt)})})]}):null]}):null}),(0,M.jsx)(r,{open:q!==null,title:`删除需求`,message:`确定删除「${q?.title??``}」?关联的缺陷会保留,但不再关联到这条需求。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>J(null),onConfirm:()=>void mt()})]})}export{P as t};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.DQFd6g2r.js";import{o as i}from"./plugins.ChGmBEkF.js";import{A as a,D as o,F as s,P as c,R as l,b as u,d,f,g as ee,h as te,j as p,l as m,m as ne,u as h,w as g,z as _}from"./pm.BXmOiFfW.js";import{t as v}from"./SelectDropdown.D7IeyHDI.js";import{A as y,C as re,D as ie,E as b,O as ae,S as oe,T as x,_ as S,a as se,c as ce,d as le,f as C,g as ue,h as w,j as de,k as T,l as fe,m as E,p as pe,s as D,u as me,w as he,y as O}from"./PmShared.TOjBbtV8.js";import{showToast as k}from"./Toast.BydY-X7T.js";import{n as ge,t as _e}from"./DocsPager.Dg765uHW.js";import{n as ve,r as ye,t as be}from"./TableFieldConfig.DHj25OKN.js";import{c as xe,d as Se,i as Ce,l as we,n as Te,o as Ee,r as De,s as Oe,t as A}from"./ColumnResize.CkE59sGq.js";var j=e(t(),1),M=n();function ke({value:e,onChange:t,entity:n,recordId:r=``,seenUrls:i,onError:s,onPersisted:c}){let d=p(e),[f,ee]=(0,j.useState)(!1),[te,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(null),v=(0,j.useRef)(null);(0,j.useEffect)(()=>{for(let t of p(e))i.current.add(t.url)},[e,i]);let y=(0,j.useCallback)(async n=>{if(n&&n.length){ee(!0);try{let r=await _(Array.from(n));t(a([...p(e),...r])),s(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{ee(!1),v.current&&(v.current.value=``)}}},[t,s,e]);(0,j.useEffect)(()=>{let e=e=>{let t=u(e.clipboardData);t.length&&(e.preventDefault(),y(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[y]);async function re(e){let i=a(d.filter(t=>t.url!==e));if(r)try{await l(n,r,{attachment:i}),c?.()}catch(e){s(e instanceof Error?e.message:String(e));return}t(i),ne([e],r)}return(0,M.jsxs)(`div`,{className:`space-y-2 rounded-lg transition-colors ${te?`bg-[#4176e6]/5 ring-1 ring-[#4176e6]/40`:``}`,onDragOver:e=>{e.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:e=>{e.preventDefault(),m(!1),y(e.dataTransfer?.files??null)},children:[d.length?(0,M.jsx)(`ul`,{className:`space-y-1.5`,children:d.map(e=>(0,M.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[o(e.url)?(0,M.jsx)(`button`,{type:`button`,onClick:()=>g(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,M.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,M.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,M.jsx)(E,{name:`file`,size:15})}),o(e.url)?(0,M.jsx)(`button`,{type:`button`,onClick:()=>g(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#4176e6]`,children:e.name}):(0,M.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`min-w-0 flex-1 truncate text-sm text-stone-700 hover:text-[#4176e6]`,children:e.name}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>void re(e.url),className:`tw-icon-danger flex h-6 w-6 shrink-0 items-center justify-center rounded`,children:`✕`})]},e.url))}):null,(0,M.jsx)(`input`,{ref:v,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void y(e.target.files)}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsxs)(`button`,{type:`button`,disabled:f,onClick:()=>v.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-dashed border-stone-300 px-2.5 text-xs text-stone-500 transition-colors hover:border-stone-400 hover:text-stone-700 disabled:opacity-40`,children:[(0,M.jsx)(E,{name:f?`file`:`plus`,size:13}),f?`上传中…`:`上传文件 / 图片`]}),(0,M.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可拖拽到这里,或直接粘贴截图(⌘V / Ctrl+V),支持多张`})]}),(0,M.jsx)(w,{file:h,onClose:()=>g(null)})]})}var Ae=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`priority`,width:100,min:80},{key:`status`,width:120,min:96}],je={key:`project`,width:140,min:100},Me=[{key:`iteration`,width:120,min:88},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],Ne=new Set([`id`,`title`,`filler`,`action`]),Pe=[{key:`priority`,label:`优先级`},{key:`status`,label:`需求状态`},{key:`iteration`,label:`所属迭代`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Fe=`pm.requirements.fields`,Ie=20,Le=`tw.pm-requirements.page-size.v1`,Re=[`all`,...d],ze=[`all`,...m],Be=`pm.requirements.project`,Ve=`pm.requirements.iteration`,He=`pm.requirements.status`,Ue=`pm.requirements.priority`,We=`pm.requirements.keyword`,Ge=m.map(e=>({value:e,label:h[e]})),N=d.map(e=>({value:e,label:f[e]}));function Ke(e=``){return{projectId:e,iterationId:``,title:``,priority:`medium`,status:`pending`,description:``,acceptanceCriteria:[],githubIssue:``,attachment:``}}function P({scopeProjectId:e=``}={}){let t=!!e,n=y(`pmRequirements`),{store:a,live:o,loading:u,error:d,setError:m,reload:_}=de(),[w,P]=T(Be,`all`),F=e||w,[I,L]=T(Ve,`all`),[R,qe]=ae(He,Re,`all`),[z,Je]=ae(Ue,ze,`all`),[B,Ye]=T(We),[Xe,V]=(0,j.useState)(1),[H,Ze]=ge(Ie,Le),[U,W]=(0,j.useState)(null),[G,K]=(0,j.useState)(!1),[q,J]=(0,j.useState)(null),Y=(0,j.useRef)(new Set),Qe=(0,j.useMemo)(()=>t?Pe:[{key:`project`,label:`所属项目`},...Pe],[t]),X=ye(Fe,Qe,Ne),$e=(0,j.useMemo)(()=>t?[...Ae,...Me]:[...Ae,je,...Me],[t]),Z=(0,j.useMemo)(()=>ve($e,X.isVisible),[$e,X.isVisible]),Q=we(t?`pm.requirements.cols.scoped.v2`:`pm.requirements.cols.v2`,Z),et=Se(t?`pm.requirements.scroll.scoped`:`pm.requirements.scroll`),tt=Q.widthOf(`id`)??88,nt=(0,j.useMemo)(()=>[{value:`all`,label:`全部项目`},...a.projects.map(e=>({value:e.id,label:e.name}))],[a.projects]),rt=(0,j.useMemo)(()=>[{value:`all`,label:`全部迭代`},...c(a.iterations.filter(e=>F===`all`||e.projectId===F)).map(e=>({value:e.id,label:e.name}))],[a.iterations,F]),it=(0,j.useMemo)(()=>{let e=new Map(a.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[a.projects]),at=(0,j.useMemo)(()=>{let e=new Map(a.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[a.iterations]),$=(0,j.useMemo)(()=>s(g(a.requirements,{projectId:F,iterationId:I,status:R,priority:z,keyword:B})),[a.requirements,F,I,R,z,B]),ot=t?a.requirements.filter(e=>e.projectId===F).length:a.requirements.length,st=Math.max(1,Math.ceil($.length/H)),ct=Math.min(Xe,st),lt=$.slice((ct-1)*H,ct*H);(0,j.useEffect)(()=>{t||o===!0&&w!==`all`&&!a.projects.some(e=>e.id===w)&&P(`all`)},[o,a.projects,w,P,t]),(0,j.useEffect)(()=>{o===!0&&I!==`all`&&!a.iterations.some(e=>e.id===I&&(F===`all`||e.projectId===F))&&L(`all`)},[o,a.iterations,F,I,L]);let ut=U?c(a.iterations.filter(e=>e.projectId===U.projectId)):[];async function dt(){if(!U)return;if(!U.projectId){m(`请先选择所属项目`);return}let e=U.title.trim();if(!e)m(`需求描述不能为空`);else{K(!0);try{let t={projectId:U.projectId,iterationId:U.iterationId,title:e,priority:U.priority,status:U.status,description:U.description,acceptanceCriteria:U.acceptanceCriteria.filter(e=>e.text.trim()),githubIssue:U.githubIssue,attachment:U.attachment};U.id?await l(`requirements`,U.id,t):await te(`requirements`,[t]);let n=!!U.id;W(null),Y.current.clear(),m(``),await _(!0),k(n?`已保存需求`:`已新建需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);m(t),k(`保存需求失败:${t}`,`error`)}finally{K(!1)}}}function ft(){let e=[...Y.current,...p(U?.attachment??``).map(e=>e.url)];Y.current.clear(),W(null),e.length&&ne(e)}async function pt(e,t){K(!0);try{await l(`requirements`,e.id,{status:t}),await _(!0),k(`已更新需求状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);m(t),k(`更新状态失败:${t}`,`error`)}finally{K(!1)}}async function mt(){let e=q;if(e){J(null),K(!0);try{await ee(`requirements`,[e.id]),await _(!0),k(`已删除需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);m(t),k(`删除需求失败:${t}`,`error`)}finally{K(!1)}}}if(!n.ready)return(0,M.jsx)(ue,{label:`正在读取插件开关`});if(!n.on)return(0,M.jsx)(S,{children:i(`pmRequirements`)});if(o===null)return(0,M.jsx)(ue,{label:`正在连接项目管理服务`});if(!o)return(0,M.jsx)(S,{children:`需求管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(a.projects.length===0&&!u&&!t)return(0,M.jsx)(S,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护需求。`});let ht=[{value:`all`,label:`全部`},...N];return(0,M.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,M.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:ot}),` 条需求`,$.length===ot?``:` · 筛选出 ${$.length} 条`]}),(0,M.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,M.jsx)(v,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选需求`,className:`w-36`,options:nt,value:w,onChange:e=>{P(e),L(`all`),V(1)}}),(0,M.jsx)(v,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选需求`,className:`w-32`,options:rt,value:I,onChange:e=>{L(e),V(1)}}),(0,M.jsx)(v,{flat:!0,showCheck:!1,ariaLabel:`按优先级筛选需求`,className:`w-28`,options:[{value:`all`,label:`全部优先级`},...Ge],value:z,onChange:e=>{Je(e),V(1)}}),(0,M.jsxs)(`label`,{className:`relative block`,children:[(0,M.jsx)(E,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,M.jsx)(`input`,{value:B,onChange:e=>{Ye(e.target.value),V(1)},placeholder:`搜索编号 / 名称…`,className:`h-9 w-44 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#4176e6]`})]}),(0,M.jsx)(be,{fields:X.fields,isVisible:X.isVisible,onToggle:X.toggle}),(0,M.jsxs)(`button`,{type:`button`,disabled:G,onClick:()=>W(Ke(F===`all`?``:F)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#3566d0] disabled:opacity-40`,children:[(0,M.jsx)(E,{name:`plus`,size:14}),`新建需求`]})]})]}),(0,M.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,M.jsx)(pe,{ariaLabel:`按状态筛选需求`,options:ht,value:R,onChange:e=>{qe(e),V(1)}})}),d?(0,M.jsx)(le,{message:d,onClose:()=>m(``)}):null,(0,M.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{ref:et,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,M.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:Q.tableStyle,children:[(0,M.jsx)(`colgroup`,{children:Z.map(e=>(0,M.jsx)(`col`,{style:Q.widthOf(e.key)?{width:Q.widthOf(e.key)}:void 0},e.key))}),(0,M.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,M.jsxs)(`tr`,{children:[(0,M.jsxs)(`th`,{className:`${Oe} relative`,children:[`ID`,(0,M.jsx)(A,{...Q.resizeProps(`id`)})]}),(0,M.jsxs)(`th`,{className:Ee,style:{"--tw-sticky-left":`${tt}px`},children:[`需求描述`,(0,M.jsx)(A,{...Q.resizeProps(`title`)})]}),X.isVisible(`priority`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`优先级`,(0,M.jsx)(A,{...Q.resizeProps(`priority`)})]}):null,X.isVisible(`status`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`需求状态`,(0,M.jsx)(A,{...Q.resizeProps(`status`)})]}):null,!t&&X.isVisible(`project`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属项目`,(0,M.jsx)(A,{...Q.resizeProps(`project`)})]}):null,X.isVisible(`iteration`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属迭代`,(0,M.jsx)(A,{...Q.resizeProps(`iteration`)})]}):null,X.isVisible(`createdAt`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,M.jsx)(A,{...Q.resizeProps(`createdAt`)})]}):null,X.isVisible(`updatedAt`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,M.jsx)(A,{...Q.resizeProps(`updatedAt`)})]}):null,(0,M.jsx)(`th`,{"aria-hidden":`true`}),(0,M.jsx)(`th`,{className:xe,children:`操作`})]})}),(0,M.jsxs)(`tbody`,{children:[u&&!a.requirements.length?(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{colSpan:Z.length,className:`px-4 py-16 text-center`,children:(0,M.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):lt.length===0?(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{colSpan:Z.length,children:ot?(0,M.jsx)(fe,{children:`没有符合筛选条件的需求。`}):(0,M.jsx)(me,{icon:`file`,title:`暂无需求`,hint:`拆出第一条需求,再关联迭代、补充描述。`,action:(0,M.jsxs)(`button`,{type:`button`,onClick:()=>W(Ke(F===`all`?``:F)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(E,{name:`plus`,size:13}),`新建需求`]})})})}):null,lt.map(e=>(0,M.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,M.jsx)(`td`,{className:`${De} font-mono text-xs text-stone-400`,children:e.autoId}),(0,M.jsx)(`td`,{className:Te,style:{"--tw-sticky-left":`${tt}px`},children:(0,M.jsx)(re,{text:e.title,onClick:()=>W({id:e.id,projectId:e.projectId,iterationId:e.iterationId,title:e.title,priority:e.priority,status:e.status,description:e.description,acceptanceCriteria:e.acceptanceCriteria.map(e=>({...e})),githubIssue:e.githubIssue,attachment:e.attachment})})}),X.isVisible(`priority`)?(0,M.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,M.jsx)(oe,{tone:he[e.priority],children:h[e.priority]})}):null,X.isVisible(`status`)?(0,M.jsx)(`td`,{className:`min-w-0 overflow-hidden px-2 py-1 align-middle`,children:(0,M.jsx)(v,{unstyled:!0,fitContent:!0,hideChevron:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:G,options:N,value:e.status,onChange:t=>void pt(e,t),renderOptionPrefix:e=>(0,M.jsx)(D,{tone:x[e.value]}),renderTrigger:()=>(0,M.jsx)(oe,{tone:x[e.status],children:f[e.status]})})}):null,!t&&X.isVisible(`project`)?(0,M.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-600`,children:(0,M.jsx)(`a`,{href:ie(e.projectId),className:`block truncate transition-colors hover:text-[#4176e6]`,children:it(e.projectId)})}):null,X.isVisible(`iteration`)?(0,M.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-500`,children:at(e.iterationId)}):null,X.isVisible(`createdAt`)?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:b(e.createdAt)}):null,X.isVisible(`updatedAt`)?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:b(e.updatedAt)}):null,(0,M.jsx)(`td`,{"aria-hidden":`true`}),(0,M.jsx)(`td`,{className:Ce,children:(0,M.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:G,onClick:()=>J(e),className:`tw-icon-danger inline-flex h-7 w-7 items-center justify-center rounded-md`,children:(0,M.jsx)(E,{name:`trash`,size:15})})})]},e.id))]})]})}),$.length>0?(0,M.jsx)(_e,{page:ct,totalPages:st,pageSize:H,busy:G,onPage:V,onPageSize:e=>{Ze(e),V(1)}}):null]}),(0,M.jsx)(ce,{open:U!==null,title:U?.id?`编辑需求`:`新建需求`,busy:G,submitLabel:U?.id?`保存`:`创建`,onClose:()=>ft(),onSubmit:()=>void dt(),children:U?(0,M.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,M.jsx)(C,{label:`所属项目`,required:!0,children:(0,M.jsx)(O,{ariaLabel:`所属项目`,options:a.projects.map(e=>({value:e.id,label:e.name})),value:U.projectId,onChange:e=>{let t=a.iterations.some(t=>t.id===U.iterationId&&t.projectId===e);W({...U,projectId:e,iterationId:t?U.iterationId:``})}})}),(0,M.jsx)(C,{label:`所属迭代`,children:(0,M.jsx)(O,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...ut.map(e=>({value:e.id,label:e.name}))],value:U.iterationId,onChange:e=>W({...U,iterationId:e}),disabled:ut.length===0})}),(0,M.jsx)(C,{label:`需求描述`,required:!0,children:(0,M.jsx)(`textarea`,{autoFocus:!0,value:U.title,onChange:e=>W({...U,title:e.target.value}),placeholder:`一句话写清要做什么`,rows:3,className:se})}),(0,M.jsx)(C,{label:`优先级`,children:(0,M.jsx)(O,{ariaLabel:`优先级`,options:Ge,value:U.priority,onChange:e=>W({...U,priority:e}),renderOptionPrefix:e=>(0,M.jsx)(D,{tone:he[e.value]})})}),(0,M.jsx)(C,{label:`需求状态`,children:(0,M.jsx)(O,{ariaLabel:`需求状态`,options:N,value:U.status,onChange:e=>W({...U,status:e}),renderOptionPrefix:e=>(0,M.jsx)(D,{tone:x[e.value]})})}),(0,M.jsx)(C,{label:`附件`,children:(0,M.jsx)(ke,{value:U.attachment,onChange:e=>W(t=>t&&{...t,attachment:e}),entity:`requirements`,recordId:U.id??``,seenUrls:Y,onError:m,onPersisted:()=>void _(!0)})}),(0,M.jsx)(C,{label:`备注`,children:(0,M.jsx)(`textarea`,{value:U.description,onChange:e=>W({...U,description:e.target.value}),placeholder:`补充背景、目标与范围(可选)`,rows:4,className:se})}),U.id?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(C,{label:`创建日期`,children:(0,M.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:b(a.requirements.find(e=>e.id===U.id)?.createdAt)})}),(0,M.jsx)(C,{label:`修改日期`,children:(0,M.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:b(a.requirements.find(e=>e.id===U.id)?.updatedAt)})})]}):null]}):null}),(0,M.jsx)(r,{open:q!==null,title:`删除需求`,message:`确定删除「${q?.title??``}」?关联的缺陷会保留,但不再关联到这条需求。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>J(null),onConfirm:()=>void mt()})]})}export{P as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{i as r}from"./app-config.Dvfzl5_N.js";import{t as i}from"./jsx-runtime.DUg_B_vD.js";import{a,r as o}from"./plugins.Db9xoFZb.js";import{_ as s,v as c,y as l}from"./pm.BXmOiFfW.js";import{n as u,o as d,r as f,s as p}from"./view-prefs.COAKEQtZ.js";import{n as m,t as h}from"./SelectDropdown.D7IeyHDI.js";import{t as g}from"./SlideOverDrawer.BMg2tce6.js";var _=e(t(),1),v=e(n(),1),y=i(),b=8e3;function x(e,t,n){let[r,i]=(0,_.useState)(()=>u(e,t,n));return[r,(0,_.useCallback)(t=>{i(t),d(e,t)},[e])]}function S(e,t=``){let[n,r]=(0,_.useState)(()=>f(e)||t);return[n,(0,_.useCallback)(n=>{r(n),p(e,n===t?``:n)},[e,t])]}function C(e){let[t,n]=(0,_.useState)(!1),[i,s]=(0,_.useState)(()=>o(e));return(0,_.useEffect)(()=>{let t=!0,i=a(()=>s(o(e)));return r().then(()=>{t&&(s(o(e)),n(!0))}),()=>{t=!1,i()}},[e]),{ready:t,on:i}}var w=(0,_.createContext)(null);function T(e){let[t,n]=(0,_.useState)(s),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!0),[u,d]=(0,_.useState)(``),f=(0,_.useRef)(!0),p=(0,_.useCallback)(async(e=!1)=>{e||o(!0);try{let e=await l();return f.current?(n(e),i(!0),d(``),e):null}catch(e){return f.current&&d(e instanceof Error?e.message:String(e)),null}finally{f.current&&!e&&o(!1)}},[]);return(0,_.useEffect)(()=>{if(!e){o(!1);return}f.current=!0;let t=null;return(async()=>{let e=await c();f.current&&(e?(await p(),f.current&&(i(!0),t=window.setInterval(()=>void p(!0),b))):(i(!1),o(!1)))})(),()=>{f.current=!1,t!==null&&window.clearInterval(t)}},[e,p]),{store:t,live:r,loading:a,error:u,setError:d,reload:p}}function E({children:e}){let t=T(!0);return(0,y.jsx)(w.Provider,{value:t,children:e})}function D(){let e=(0,_.useContext)(w),t=T(e===null);return e??t}var O={gray:`bg-stone-100 text-stone-600`,blue:`bg-[#e1eaff] text-[#1f4ec2]`,amber:`bg-[#fff1e3] text-[#a85b00]`,yellow:`bg-[#fff7d6] text-[#8a6100]`,red:`bg-[#fee4e3] text-[#c02a26]`,purple:`bg-[#efe7ff] text-[#5b32b4]`,green:`bg-[#d9f5d2] text-[#1d7a12]`,muted:`bg-stone-100 text-stone-400`},k={planning:`blue`,in_progress:`amber`,archived:`gray`},A={planning:`blue`,in_progress:`amber`,done:`green`},j={urgent:`red`,high:`amber`,medium:`yellow`,low:`gray`},M={pending:`gray`,todo:`blue`,in_progress:`blue`,testing:`purple`,done:`green`,cancelled:`muted`},N={critical:`red`,major:`amber`,minor:`yellow`,trivial:`gray`},P={pending:`gray`,todo:`blue`,fixed:`amber`,verifying:`purple`,passed:`green`,cancelled:`muted`},ee={gray:`#a8a29e`,blue:`#4176e6`,amber:`#f59e0b`,yellow:`#eab308`,red:`#ef4444`,purple:`#8b5cf6`,green:`#22c55e`,muted:`#d6d3d1`};function F({tone:e}){return(0,y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:ee[e]}})}function I({tone:e,children:t}){return(0,y.jsx)(`span`,{className:`inline-flex h-6 shrink-0 items-center rounded-md px-2 text-xs font-medium ${O[e]}`,children:t})}var L={plus:[`M12 5v14`,`M5 12h14`],more:[],chevronRight:[`m9 5 7 7-7 7`],chevronDown:[`m5 9 7 7 7-7`],arrowLeft:[`M19 12H5`,`m11 18-6-6 6-6`],pencil:[`M12 20h9`,`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`],trash:[`M3 6h18`,`M8 6V4h8v2`,`M19 6l-1 14H6L5 6`,`M10 11v6`,`M14 11v6`],copy:[`M9 9.5A1.5 1.5 0 0 1 10.5 8h7A1.5 1.5 0 0 1 19 9.5v7A1.5 1.5 0 0 1 17.5 18h-7A1.5 1.5 0 0 1 9 16.5Z`,`M5 15V5.5A1.5 1.5 0 0 1 6.5 4H15`],check:[`m4.5 12.5 5 5 10-11`],play:[`M8 5.5v13l11-6.5Z`],search:[`M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14Z`,`m20 20-3.6-3.6`],folder:[`M3 7.5A2.5 2.5 0 0 1 5.5 5h3.2l2 2h7.8A2.5 2.5 0 0 1 21 9.5v7A2.5 2.5 0 0 1 18.5 19h-13A2.5 2.5 0 0 1 3 16.5Z`],calendar:[`M4 7.5A2.5 2.5 0 0 1 6.5 5h11A2.5 2.5 0 0 1 20 7.5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2Z`,`M8 3v4`,`M16 3v4`,`M4 10h16`],file:[`M7 3.5h6.5L18 8v12.5H7Z`,`M13.5 3.5V8H18`,`M10 12.5h5`,`M10 16h5`],bug:[`M8.5 9.5h7V14a3.5 3.5 0 0 1-7 0Z`,`M9.5 6.2 12 8l2.5-1.8`,`M4.5 13H8.5`,`M15.5 13h4`,`M6 18.5l2-2`,`M18 18.5l-2-2`],chat:[`M4 6.5A2.5 2.5 0 0 1 6.5 4h11A2.5 2.5 0 0 1 20 6.5v7a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 3.5V16H6.5A2.5 2.5 0 0 1 4 13.5Z`],terminal:[`m5 8 4 4-4 4`,`M13 16h6`],paste:[`M9 3.5h6v2.5H9Z`,`M8 4.8H6.6A1.6 1.6 0 0 0 5 6.4v12.5a1.6 1.6 0 0 0 1.6 1.6h10.8a1.6 1.6 0 0 0 1.6-1.6V6.4a1.6 1.6 0 0 0-1.6-1.6H16`,`M8.5 11h7`,`M8.5 15h7`],download:[`M12 4v10`,`m7.5 10 4.5 4.5 4.5-4.5`,`M5 20h14`],sliders:[`M4 8h6`,`M14 8h6`,`M4 16h10`,`M18 16h2`,`M10 8a2 2 0 1 0 4 0 2 2 0 1 0-4 0`,`M14 16a2 2 0 1 0 4 0 2 2 0 1 0-4 0`]};function R({name:e,size:t=16,className:n=``}){return e===`more`?(0,y.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,className:n,children:[(0,y.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.6`}),(0,y.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.6`}),(0,y.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.6`})]}):(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:n,children:L[e].map(e=>(0,y.jsx)(`path`,{d:e},e))})}function z({tabs:e,value:t,onChange:n,ariaLabel:r}){return(0,y.jsx)(`div`,{className:`tw-pm-tabs`,role:`tablist`,"aria-label":r,children:e.map(e=>(0,y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:`tw-pm-tab`,children:[e.label,typeof e.count==`number`?(0,y.jsx)(`span`,{className:`tw-pm-tab-count`,children:e.count}):null]},e.value))})}function B({options:e,value:t,onChange:n,ariaLabel:r}){return(0,y.jsx)(`div`,{className:`tw-pm-pills`,role:`group`,"aria-label":r,children:e.map(e=>(0,y.jsx)(`button`,{type:`button`,"aria-pressed":t===e.value,onClick:()=>n(e.value),children:e.label},e.value))})}function V({icon:e,title:t,hint:n,action:r}){return(0,y.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-4 py-20 text-center`,children:[(0,y.jsx)(`span`,{className:`tw-pm-tile mb-4 flex h-16 w-16 items-center justify-center rounded-2xl`,children:(0,y.jsx)(R,{name:e,size:30})}),(0,y.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:t}),(0,y.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:n}),r?(0,y.jsx)(`div`,{className:`mt-4`,children:r}):null]})}function H(e){return`/pm/projects/detail/?id=${encodeURIComponent(e)}`}var U=`h-9 w-full rounded-md border border-transparent bg-transparent px-2 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white placeholder:text-stone-400`,W=`min-h-[72px] w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#4176e6] placeholder:text-stone-400`;function G(e){return(0,y.jsx)(h,{flat:!0,menuMatchTrigger:!0,ariaLabel:e.ariaLabel,options:e.options,value:e.value,onChange:e.onChange,disabled:e.disabled,renderOptionPrefix:e.renderOptionPrefix})}function K({page:e,totalPages:t,busy:n=!1,onPage:r}){let i=`h-7 shrink-0 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`;return(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-center gap-2 pt-3`,children:[(0,y.jsx)(`button`,{type:`button`,className:i,disabled:n||e<=1,onClick:()=>r(e-1),children:`上一页`}),(0,y.jsxs)(`span`,{className:`px-2 text-xs tabular-nums text-stone-400`,children:[e,` / `,t]}),(0,y.jsx)(`button`,{type:`button`,className:i,disabled:n||e>=t,onClick:()=>r(e+1),children:`下一页`})]})}function q({label:e}){return(0,y.jsx)(`div`,{className:`flex min-h-[240px] w-full items-center justify-center rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":e,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}function J({children: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:e})}function Y({children:e}){return(0,y.jsx)(`div`,{className:`px-4 py-16 text-center text-sm text-stone-400`,children:e})}function X({open:e,title:t,busy:n,submitLabel:r,onClose:i,onSubmit:a,children:o}){return(0,y.jsx)(g,{open:e,onClose:i,title:t,footer:(0,y.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-stone-100 px-2 py-3`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 hover:bg-stone-100`,children:`取消`}),(0,y.jsx)(`button`,{type:`button`,disabled:n,onClick:a,className:`h-8 rounded-lg bg-[#4176e6] px-3 text-sm font-medium text-white hover:bg-[#3566d0] disabled:opacity-40`,children:r})]}),children:o})}function Z({label:e,required:t,children:n}){return(0,y.jsxs)(`div`,{className:`flex items-start gap-3 px-2 py-2`,children:[(0,y.jsx)(`div`,{className:`flex h-9 w-[88px] shrink-0 items-center text-sm text-stone-600`,children:(0,y.jsxs)(`span`,{className:`truncate`,children:[e,t?(0,y.jsx)(`span`,{className:`ml-0.5 text-red-500`,children:`*`}):null]})}),(0,y.jsx)(`div`,{className:`min-w-0 flex-1 [&>div]:mt-0`,children:n})]})}var Q=180;function $({file:e,onClose:t}){let n=!!e,[r,i]=(0,_.useState)(n),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(e);return(0,_.useEffect)(()=>{if(e){c(e),i(!0);let t=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>o(!0))});return()=>window.cancelAnimationFrame(t)}o(!1);let t=window.setTimeout(()=>{i(!1),c(null)},Q);return()=>window.clearTimeout(t)},[e]),(0,_.useEffect)(()=>{if(!n)return;function e(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t())}return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t]),!r||!s?null:(0,v.createPortal)((0,y.jsxs)(`div`,{"data-pm-image-preview":``,className:`fixed inset-0 z-[70] flex items-center justify-center p-6 sm:p-10`,role:`dialog`,"aria-modal":`true`,"aria-label":s.name,onClick:t,children:[(0,y.jsx)(`div`,{className:`absolute inset-0 bg-stone-900/70 transition-opacity duration-[180ms] ease-out ${a?`opacity-100`:`opacity-0`}`,"aria-hidden":`true`}),(0,y.jsx)(`img`,{src:s.url,alt:s.name,className:`relative max-h-full max-w-full rounded-lg bg-white object-contain shadow-2xl transition-[opacity,scale] duration-[180ms] ease-out ${a?`scale-100 opacity-100`:`scale-95 opacity-0`}`,onClick:e=>e.stopPropagation()}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,onClick:t,className:`absolute right-4 top-4 flex h-9 w-9 items-center justify-center rounded-full bg-white/90 text-lg text-stone-600 shadow-md transition-opacity duration-[180ms] ease-out hover:bg-white hover:text-stone-900 ${a?`opacity-100`:`opacity-0`}`,children:`✕`})]}),document.body)}function te({message:e,onClose:t}){return(0,y.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,y.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]})}function ne(e){let t=(e??``).trim();if(!t)return`—`;let n=Date.parse(t);if(!Number.isFinite(n)){let e=t.slice(0,10);return/^\d{4}-\d{2}-\d{2}$/.test(e)?e.replace(/-/g,`/`):`—`}let r=new Date(n);return`${r.getFullYear()}/${String(r.getMonth()+1).padStart(2,`0`)}/${String(r.getDate()).padStart(2,`0`)} ${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`}function re({text:e,onClick:t}){let n=(0,y.jsx)(m,{text:e,className:`block min-w-0 truncate text-sm text-stone-800 group-hover/pm-title:text-[#4176e6]`});return t?(0,y.jsx)(`button`,{type:`button`,onClick:t,className:`group/pm-title block min-w-0 max-w-full text-left`,children:n}):n}export{C as A,re as C,H as D,ne as E,x as O,I as S,M as T,J as _,W as a,E as b,X as c,te as d,Z as f,q as g,$ as h,U as i,D as j,S as k,Y as l,R as m,P as n,k as o,B as p,A as r,F as s,N as t,V as u,K as v,j as w,z as x,G as y};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{i as r}from"./app-config.BSO5r82v.js";import{t as i}from"./jsx-runtime.DUg_B_vD.js";import{a,r as o}from"./plugins.ChGmBEkF.js";import{_ as s,v as c,y as l}from"./pm.BXmOiFfW.js";import{n as u,o as d,r as f,s as p}from"./view-prefs.CWc5cQ2q.js";import{n as m,t as h}from"./SelectDropdown.D7IeyHDI.js";import{t as g}from"./SlideOverDrawer.CvyB-quk.js";var _=e(t(),1),v=e(n(),1),y=i(),b=8e3;function x(e,t,n){let[r,i]=(0,_.useState)(()=>u(e,t,n));return[r,(0,_.useCallback)(t=>{i(t),d(e,t)},[e])]}function S(e,t=``){let[n,r]=(0,_.useState)(()=>f(e)||t);return[n,(0,_.useCallback)(n=>{r(n),p(e,n===t?``:n)},[e,t])]}function C(e){let[t,n]=(0,_.useState)(!1),[i,s]=(0,_.useState)(()=>o(e));return(0,_.useEffect)(()=>{let t=!0,i=a(()=>s(o(e)));return r().then(()=>{t&&(s(o(e)),n(!0))}),()=>{t=!1,i()}},[e]),{ready:t,on:i}}var w=(0,_.createContext)(null);function T(e){let[t,n]=(0,_.useState)(s),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!0),[u,d]=(0,_.useState)(``),f=(0,_.useRef)(!0),p=(0,_.useCallback)(async(e=!1)=>{e||o(!0);try{let e=await l();return f.current?(n(e),i(!0),d(``),e):null}catch(e){return f.current&&d(e instanceof Error?e.message:String(e)),null}finally{f.current&&!e&&o(!1)}},[]);return(0,_.useEffect)(()=>{if(!e){o(!1);return}f.current=!0;let t=null;return(async()=>{let e=await c();f.current&&(e?(await p(),f.current&&(i(!0),t=window.setInterval(()=>void p(!0),b))):(i(!1),o(!1)))})(),()=>{f.current=!1,t!==null&&window.clearInterval(t)}},[e,p]),{store:t,live:r,loading:a,error:u,setError:d,reload:p}}function E({children:e}){let t=T(!0);return(0,y.jsx)(w.Provider,{value:t,children:e})}function D(){let e=(0,_.useContext)(w),t=T(e===null);return e??t}var O={gray:`bg-stone-100 text-stone-600`,blue:`bg-[#e1eaff] text-[#1f4ec2]`,amber:`bg-[#fff1e3] text-[#a85b00]`,yellow:`bg-[#fff7d6] text-[#8a6100]`,red:`bg-[#fee4e3] text-[#c02a26]`,purple:`bg-[#efe7ff] text-[#5b32b4]`,green:`bg-[#d9f5d2] text-[#1d7a12]`,muted:`bg-stone-100 text-stone-400`},k={planning:`blue`,in_progress:`amber`,archived:`gray`},A={planning:`blue`,in_progress:`amber`,done:`green`},j={urgent:`red`,high:`amber`,medium:`yellow`,low:`gray`},M={pending:`gray`,todo:`blue`,in_progress:`blue`,testing:`purple`,done:`green`,cancelled:`muted`},N={critical:`red`,major:`amber`,minor:`yellow`,trivial:`gray`},P={pending:`gray`,todo:`blue`,fixed:`amber`,verifying:`purple`,passed:`green`,cancelled:`muted`},ee={gray:`#a8a29e`,blue:`#4176e6`,amber:`#f59e0b`,yellow:`#eab308`,red:`#ef4444`,purple:`#8b5cf6`,green:`#22c55e`,muted:`#d6d3d1`};function F({tone:e}){return(0,y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:ee[e]}})}function I({tone:e,children:t}){return(0,y.jsx)(`span`,{className:`inline-flex h-6 shrink-0 items-center rounded-md px-2 text-xs font-medium ${O[e]}`,children:t})}var L={plus:[`M12 5v14`,`M5 12h14`],more:[],chevronRight:[`m9 5 7 7-7 7`],chevronDown:[`m5 9 7 7 7-7`],arrowLeft:[`M19 12H5`,`m11 18-6-6 6-6`],pencil:[`M12 20h9`,`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`],trash:[`M3 6h18`,`M8 6V4h8v2`,`M19 6l-1 14H6L5 6`,`M10 11v6`,`M14 11v6`],copy:[`M9 9.5A1.5 1.5 0 0 1 10.5 8h7A1.5 1.5 0 0 1 19 9.5v7A1.5 1.5 0 0 1 17.5 18h-7A1.5 1.5 0 0 1 9 16.5Z`,`M5 15V5.5A1.5 1.5 0 0 1 6.5 4H15`],check:[`m4.5 12.5 5 5 10-11`],play:[`M8 5.5v13l11-6.5Z`],search:[`M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14Z`,`m20 20-3.6-3.6`],folder:[`M3 7.5A2.5 2.5 0 0 1 5.5 5h3.2l2 2h7.8A2.5 2.5 0 0 1 21 9.5v7A2.5 2.5 0 0 1 18.5 19h-13A2.5 2.5 0 0 1 3 16.5Z`],calendar:[`M4 7.5A2.5 2.5 0 0 1 6.5 5h11A2.5 2.5 0 0 1 20 7.5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2Z`,`M8 3v4`,`M16 3v4`,`M4 10h16`],file:[`M7 3.5h6.5L18 8v12.5H7Z`,`M13.5 3.5V8H18`,`M10 12.5h5`,`M10 16h5`],bug:[`M8.5 9.5h7V14a3.5 3.5 0 0 1-7 0Z`,`M9.5 6.2 12 8l2.5-1.8`,`M4.5 13H8.5`,`M15.5 13h4`,`M6 18.5l2-2`,`M18 18.5l-2-2`],chat:[`M4 6.5A2.5 2.5 0 0 1 6.5 4h11A2.5 2.5 0 0 1 20 6.5v7a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 3.5V16H6.5A2.5 2.5 0 0 1 4 13.5Z`],terminal:[`m5 8 4 4-4 4`,`M13 16h6`],paste:[`M9 3.5h6v2.5H9Z`,`M8 4.8H6.6A1.6 1.6 0 0 0 5 6.4v12.5a1.6 1.6 0 0 0 1.6 1.6h10.8a1.6 1.6 0 0 0 1.6-1.6V6.4a1.6 1.6 0 0 0-1.6-1.6H16`,`M8.5 11h7`,`M8.5 15h7`],download:[`M12 4v10`,`m7.5 10 4.5 4.5 4.5-4.5`,`M5 20h14`],sliders:[`M4 8h6`,`M14 8h6`,`M4 16h10`,`M18 16h2`,`M10 8a2 2 0 1 0 4 0 2 2 0 1 0-4 0`,`M14 16a2 2 0 1 0 4 0 2 2 0 1 0-4 0`]};function R({name:e,size:t=16,className:n=``}){return e===`more`?(0,y.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,className:n,children:[(0,y.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.6`}),(0,y.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.6`}),(0,y.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.6`})]}):(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:n,children:L[e].map(e=>(0,y.jsx)(`path`,{d:e},e))})}function z({tabs:e,value:t,onChange:n,ariaLabel:r}){return(0,y.jsx)(`div`,{className:`tw-pm-tabs`,role:`tablist`,"aria-label":r,children:e.map(e=>(0,y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:`tw-pm-tab`,children:[e.label,typeof e.count==`number`?(0,y.jsx)(`span`,{className:`tw-pm-tab-count`,children:e.count}):null]},e.value))})}function B({options:e,value:t,onChange:n,ariaLabel:r}){return(0,y.jsx)(`div`,{className:`tw-pm-pills`,role:`group`,"aria-label":r,children:e.map(e=>(0,y.jsx)(`button`,{type:`button`,"aria-pressed":t===e.value,onClick:()=>n(e.value),children:e.label},e.value))})}function V({icon:e,title:t,hint:n,action:r}){return(0,y.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-4 py-20 text-center`,children:[(0,y.jsx)(`span`,{className:`tw-pm-tile mb-4 flex h-16 w-16 items-center justify-center rounded-2xl`,children:(0,y.jsx)(R,{name:e,size:30})}),(0,y.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:t}),(0,y.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:n}),r?(0,y.jsx)(`div`,{className:`mt-4`,children:r}):null]})}function H(e){return`/pm/projects/detail/?id=${encodeURIComponent(e)}`}var U=`h-9 w-full rounded-md border border-transparent bg-transparent px-2 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white placeholder:text-stone-400`,W=`min-h-[72px] w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#4176e6] placeholder:text-stone-400`;function G(e){return(0,y.jsx)(h,{flat:!0,menuMatchTrigger:!0,ariaLabel:e.ariaLabel,options:e.options,value:e.value,onChange:e.onChange,disabled:e.disabled,renderOptionPrefix:e.renderOptionPrefix})}function K({page:e,totalPages:t,busy:n=!1,onPage:r}){let i=`h-7 shrink-0 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`;return(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-center gap-2 pt-3`,children:[(0,y.jsx)(`button`,{type:`button`,className:i,disabled:n||e<=1,onClick:()=>r(e-1),children:`上一页`}),(0,y.jsxs)(`span`,{className:`px-2 text-xs tabular-nums text-stone-400`,children:[e,` / `,t]}),(0,y.jsx)(`button`,{type:`button`,className:i,disabled:n||e>=t,onClick:()=>r(e+1),children:`下一页`})]})}function q({label:e}){return(0,y.jsx)(`div`,{className:`flex min-h-[240px] w-full items-center justify-center rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":e,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}function J({children: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:e})}function Y({children:e}){return(0,y.jsx)(`div`,{className:`px-4 py-16 text-center text-sm text-stone-400`,children:e})}function X({open:e,title:t,busy:n,submitLabel:r,onClose:i,onSubmit:a,children:o}){return(0,y.jsx)(g,{open:e,onClose:i,title:t,footer:(0,y.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-stone-100 px-2 py-3`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 hover:bg-stone-100`,children:`取消`}),(0,y.jsx)(`button`,{type:`button`,disabled:n,onClick:a,className:`h-8 rounded-lg bg-[#4176e6] px-3 text-sm font-medium text-white hover:bg-[#3566d0] disabled:opacity-40`,children:r})]}),children:o})}function Z({label:e,required:t,children:n}){return(0,y.jsxs)(`div`,{className:`flex items-start gap-3 px-2 py-2`,children:[(0,y.jsx)(`div`,{className:`flex h-9 w-[88px] shrink-0 items-center text-sm text-stone-600`,children:(0,y.jsxs)(`span`,{className:`truncate`,children:[e,t?(0,y.jsx)(`span`,{className:`ml-0.5 text-red-500`,children:`*`}):null]})}),(0,y.jsx)(`div`,{className:`min-w-0 flex-1 [&>div]:mt-0`,children:n})]})}var Q=180;function $({file:e,onClose:t}){let n=!!e,[r,i]=(0,_.useState)(n),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(e);return(0,_.useEffect)(()=>{if(e){c(e),i(!0);let t=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>o(!0))});return()=>window.cancelAnimationFrame(t)}o(!1);let t=window.setTimeout(()=>{i(!1),c(null)},Q);return()=>window.clearTimeout(t)},[e]),(0,_.useEffect)(()=>{if(!n)return;function e(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t())}return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t]),!r||!s?null:(0,v.createPortal)((0,y.jsxs)(`div`,{"data-pm-image-preview":``,className:`fixed inset-0 z-[70] flex items-center justify-center p-6 sm:p-10`,role:`dialog`,"aria-modal":`true`,"aria-label":s.name,onClick:t,children:[(0,y.jsx)(`div`,{className:`absolute inset-0 bg-stone-900/70 transition-opacity duration-[180ms] ease-out ${a?`opacity-100`:`opacity-0`}`,"aria-hidden":`true`}),(0,y.jsx)(`img`,{src:s.url,alt:s.name,className:`relative max-h-full max-w-full rounded-lg bg-white object-contain shadow-2xl transition-[opacity,scale] duration-[180ms] ease-out ${a?`scale-100 opacity-100`:`scale-95 opacity-0`}`,onClick:e=>e.stopPropagation()}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,onClick:t,className:`absolute right-4 top-4 flex h-9 w-9 items-center justify-center rounded-full bg-white/90 text-lg text-stone-600 shadow-md transition-opacity duration-[180ms] ease-out hover:bg-white hover:text-stone-900 ${a?`opacity-100`:`opacity-0`}`,children:`✕`})]}),document.body)}function te({message:e,onClose:t}){return(0,y.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,y.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]})}function ne(e){let t=(e??``).trim();if(!t)return`—`;let n=Date.parse(t);if(!Number.isFinite(n)){let e=t.slice(0,10);return/^\d{4}-\d{2}-\d{2}$/.test(e)?e.replace(/-/g,`/`):`—`}let r=new Date(n);return`${r.getFullYear()}/${String(r.getMonth()+1).padStart(2,`0`)}/${String(r.getDate()).padStart(2,`0`)} ${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`}function re({text:e,onClick:t}){let n=(0,y.jsx)(m,{text:e,className:`block min-w-0 truncate text-sm text-stone-800 group-hover/pm-title:text-[#4176e6]`});return t?(0,y.jsx)(`button`,{type:`button`,onClick:t,className:`group/pm-title block min-w-0 max-w-full text-left`,children:n}):n}export{C as A,re as C,H as D,ne as E,x as O,I as S,M as T,J as _,W as a,E as b,X as c,te as d,Z as f,q as g,$ as h,U as i,D as j,S as k,Y as l,R as m,P as n,k as o,B as p,A as r,F as s,N as t,V as u,K as v,j as w,z as x,G as y};
|