lantern-harness 0.1.42 → 0.1.43
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 +15 -0
- package/README.md +2 -2
- package/builtin/session/lh-nav-groups.mjs +2 -0
- package/builtin/session/session-runs.mjs +179 -32
- package/cli/server.mjs +2 -0
- package/config/app.defaults.json +1 -0
- package/config/seeds//346/212/245/345/221/212/347/256/241/347/220/206//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/.gitkeep +0 -0
- package/config/seeds//346/212/245/345/221/212/347/256/241/347/220/206//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/.gitkeep +0 -0
- package/config/seeds//346/212/245/345/221/212/347/256/241/347/220/206//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/.gitkeep +0 -0
- package/config/seeds//346/217/220/347/244/272/350/257/215/347/256/241/347/220/206//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/217/220/347/244/272/350/257/215.md +18 -0
- package/config/seeds//346/217/220/347/244/272/350/257/215/347/256/241/347/220/206//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/217/220/347/244/272/350/257/215.md +18 -0
- package/config/seeds//346/217/220/347/244/272/350/257/215/347/256/241/347/220/206//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/217/220/347/244/272/350/257/215.md +18 -0
- package/dist/500.html +7 -4
- package/dist/_astro/Base.BnVp5Mf8.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.BqOtiCPG.js → Base.astro_astro_type_script_index_0_lang.Chv7r8_9.js} +2 -2
- package/dist/_astro/{CaseExecBoard.1aCJ_MsC.js → CaseExecBoard.DUMjSunb.js} +1 -1
- package/dist/_astro/{CaseGenerateApp.DW0HJj-e.js → CaseGenerateApp.DtuOyQuv.js} +1 -1
- package/dist/_astro/{CasesLibrary.BNgrULER.js → CasesLibrary.B9o_jvXb.js} +1 -1
- package/dist/_astro/ChatApp.CKPGFibd.js +227 -0
- package/dist/_astro/{DashboardBoard.DW_kipSk.js → DashboardBoard.DEvgMoqo.js} +1 -1
- package/dist/_astro/{DocsFileBrowser.DceJyP9V.js → DocsFileBrowser.D66pN9rp.js} +1 -1
- package/dist/_astro/{DocsPager.D0TMvJ67.js → DocsPager.ceBEecmd.js} +1 -1
- package/dist/_astro/{KnowledgeLibrary.C-_UybI5.js → KnowledgeLibrary.DYqE2mRi.js} +1 -1
- package/dist/_astro/{LifeKrTasksBoard.DktIT_uO.js → LifeKrTasksBoard.B7UiEutA.js} +1 -1
- package/dist/_astro/{LifeKrTodosBoard.DVUmgRmh.js → LifeKrTodosBoard.VL7HdhNY.js} +1 -1
- package/dist/_astro/{LifeObjectivesBoard.Cjg3hCkJ.js → LifeObjectivesBoard.lLBPOHEZ.js} +1 -1
- package/dist/_astro/{LifePlanTypeSelect.C63oD8zZ.js → LifePlanTypeSelect.CdKQmlEK.js} +1 -1
- package/dist/_astro/{LifeReviewsBoard.Bj4otl26.js → LifeReviewsBoard.AjO4SbsR.js} +1 -1
- package/dist/_astro/{LifeShared.-pwCbSyP.js → LifeShared.CtdsQI43.js} +1 -1
- package/dist/_astro/{LifeStagesBoard.DJpc4f7A.js → LifeStagesBoard.Dl-kTZ6K.js} +1 -1
- package/dist/_astro/{LifeYearCycleSelect.CObXQA5s.js → LifeYearCycleSelect.BILJOKXK.js} +1 -1
- package/dist/_astro/{LifeYearPlansBoard.Bt6Hc8M9.js → LifeYearPlansBoard.BzJmi7Hw.js} +1 -1
- package/dist/_astro/{NavLibraries.D9EKoN80.js → NavLibraries.BnaL-km5.js} +1 -1
- package/dist/_astro/PluginsPage.CMW4hEFr.js +1 -0
- package/dist/_astro/{PluginsPage.DwmK_UF-.js → PluginsPage.D2OrUGY3.js} +2 -2
- package/dist/_astro/{PmBugsBoard.NUiKlz46.js → PmBugsBoard.BynUocbE.js} +1 -1
- package/dist/_astro/{PmIterationsBoard.C8F55feg.js → PmIterationsBoard.CvFblvfX.js} +1 -1
- package/dist/_astro/{PmProjectDetail.CMiWhGxn.js → PmProjectDetail.Dlm6flwk.js} +1 -1
- package/dist/_astro/{PmProjectsBoard.-g9KAiZJ.js → PmProjectsBoard.B5vaWuax.js} +1 -1
- package/dist/_astro/PmRequirementsBoard.B8KTeso8.js +1 -0
- package/dist/_astro/{PmRequirementsBoard.C5_NcAzj.js → PmRequirementsBoard.piRWjiYA.js} +1 -1
- package/dist/_astro/{PmShared.D6iq_Z9g.js → PmShared.86HEsdd_.js} +1 -1
- package/dist/_astro/PromptMountDialog.DYojFMok.js +1 -0
- package/dist/_astro/PromptsLibrary.GpNbBTj1.js +1 -0
- package/dist/_astro/ReportsPage.B-xhGVEU.js +16 -0
- package/dist/_astro/{ReqAnalysisBoard.LSxbIIWk.js → ReqAnalysisBoard.B3sAOuAq.js} +1 -1
- package/dist/_astro/{RequirementsLibrary.Dat8rP5c.js → RequirementsLibrary.BGys7DeN.js} +1 -1
- package/dist/_astro/{SettingsDialog.D21ojRGF.js → SettingsDialog.CEyjZuxq.js} +1 -1
- package/dist/_astro/{SpaceSwitcher.Bw13MkIw.js → SpaceSwitcher.DJqvw5Lw.js} +1 -1
- package/dist/_astro/{TableFieldConfig.C_NeWm8L.js → TableFieldConfig.D0v9S2g3.js} +1 -1
- package/dist/_astro/{TasksBoard.wGJOOJpR.js → TasksBoard.DZ9LLl_c.js} +1 -1
- package/dist/_astro/{TemplatesLibrary.YIgI089k.js → TemplatesLibrary.iyj_kFMO.js} +1 -1
- package/dist/_astro/TestReportsLibrary.B6pf0d7W.js +1 -0
- package/dist/_astro/{TestStatsBoard.ETea2KcX.js → TestStatsBoard.DS_2bqWI.js} +1 -1
- package/dist/_astro/{TodosBoard.OfBeAGWO.js → TodosBoard.CYAVDD1W.js} +1 -1
- package/dist/_astro/UiAutoBoard.DSsiMfx2.js +9 -0
- package/dist/_astro/{app-config.C4rpn1Ix.js → app-config.DwpFFa5D.js} +1 -1
- package/dist/_astro/app-version.Dabxyva-.js +1 -0
- package/dist/_astro/{bash-tools.RQcI4_42.js → bash-tools.CfNj2sh0.js} +1 -1
- package/dist/_astro/{case-gen-run.FzgC_1Ki.js → case-gen-run.nrr97yK3.js} +1 -1
- package/dist/_astro/{case-template.C-GBxgBC.js → case-template.Cd2xNbgy.js} +1 -1
- package/dist/_astro/{case-types.CprZTsyX.js → case-types.B51yDRdf.js} +1 -1
- package/dist/_astro/{doc-roots.DAJP9Svr.js → doc-roots.CO3IBiY6.js} +1 -1
- package/dist/_astro/{hydrate-cache.DI6vqM0o.js → hydrate-cache.CoD1FB3T.js} +1 -1
- package/dist/_astro/{i18n.BJeTr39S.js → i18n.vo2aElR9.js} +2 -2
- package/dist/_astro/llm.DN5S1KBK.js +7 -0
- package/dist/_astro/markdown-client.BS19nLL3.js +62 -0
- package/dist/_astro/open-docs-in-session.DJtuI1C4.js +1 -0
- package/dist/_astro/plugins.BmKRnp4a.js +1 -0
- package/dist/_astro/project-docs.CCjtiFjB.js +1 -0
- package/dist/_astro/prompts-meta.bF2q5SUy.js +2 -0
- package/dist/_astro/{req-analysis.BqvytN69.js → req-analysis.qmyv5cBw.js} +1 -1
- package/dist/_astro/{settings.NTeTjmxg.js → settings.CYERib3l.js} +2 -2
- package/dist/_astro/{spaces-client.CMGNsQJ-.js → spaces-client.DvIgFink.js} +1 -1
- package/dist/_astro/{story-review.D8FfhzAi.js → story-review.2UUlN3p-.js} +1 -1
- package/dist/_astro/test-reports.DPQ-FMsQ.js +19 -0
- package/dist/_astro/{ui-auto-prompt.l_EXfDs5.js → ui-auto-prompt.COBTt5Gd.js} +1 -1
- package/dist/_astro/{view-prefs.8MPl3A7e.js → view-prefs.GnvelRDj.js} +1 -1
- package/dist/case-exec/index.html +8 -5
- package/dist/cases/generate/index.html +8 -5
- package/dist/cases/library/index.html +8 -5
- package/dist/dashboard/index.html +8 -5
- package/dist/docs/changelog/index.html +64 -48
- package/dist/docs/install/index.html +7 -4
- package/dist/docs/manual/index.html +32 -11
- package/dist/knowledge/index.html +8 -5
- package/dist/life/kr-tasks/index.html +8 -5
- package/dist/life/kr-todos/index.html +8 -5
- package/dist/life/objectives/index.html +8 -5
- package/dist/life/reviews/index.html +8 -5
- package/dist/life/stages/index.html +8 -5
- package/dist/life/year-plans/index.html +8 -5
- package/dist/plugins/index.html +8 -5
- package/dist/pm/bugs/index.html +8 -5
- package/dist/pm/iterations/index.html +8 -5
- package/dist/pm/projects/detail/index.html +8 -5
- package/dist/pm/projects/index.html +8 -5
- package/dist/pm/requirements/index.html +8 -5
- package/dist/prompts/index.html +8 -5
- package/dist/reports/index.html +8 -5
- package/dist/requirement-analysis/index.html +8 -5
- package/dist/requirements/index.html +8 -5
- package/dist/tasks/index.html +8 -5
- package/dist/templates/index.html +8 -5
- package/dist/test-automation/index.html +8 -5
- package/dist/test-reports/index.html +924 -0
- package/dist/test-stats/index.html +8 -5
- package/dist/todos/index.html +8 -5
- package/dist/workbench/index.html +8 -5
- package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +1 -1
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +17 -6
- package/lh-plugins/lh-project-docs.mjs +10 -0
- package/lh-plugins/plugin-prompts.mjs +3 -0
- package/package.json +1 -1
- package/dist/_astro/Base.C-vZfmS4.css +0 -1
- package/dist/_astro/ChatApp.DzYFE67-.js +0 -226
- package/dist/_astro/PluginsPage.DayC2eOs.js +0 -1
- package/dist/_astro/PmRequirementsBoard.C0_6ye63.js +0 -1
- package/dist/_astro/PromptMountDialog.CpTT6L0a.js +0 -62
- package/dist/_astro/PromptsLibrary.DspwabiJ.js +0 -1
- package/dist/_astro/ReportsPage.DFsDsjow.js +0 -1
- package/dist/_astro/UiAutoBoard.Df2ky1Cs.js +0 -9
- package/dist/_astro/app-version.BEerieT3.js +0 -1
- package/dist/_astro/llm.DyweO-KK.js +0 -7
- package/dist/_astro/open-docs-in-session.5cTowYAC.js +0 -1
- package/dist/_astro/plugins.C0NrHGZv.js +0 -1
- package/dist/_astro/project-docs.DAw9bzgk.js +0 -1
- package/dist/_astro/prompts-meta.Dnmq-SnF.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.DwpFFa5D.js";import{a as i,l as a,o,r as s,t as c}from"./plugins.BmKRnp4a.js";import{f as l}from"./case-exec.BMNk9OyF.js";import{n as u,o as d}from"./view-prefs.GnvelRDj.js";import{i as f,n as p,r as m,t as h}from"./dialog.DZHZCe_T.js";import{t as g}from"./jsx-runtime.DUg_B_vD.js";import{t as _}from"./OverflowHint.pvo2Xc8R.js";import{I as v,v as y}from"./pm.BXmOiFfW.js";import{showToast as b}from"./Toast.BO2NFckG.js";import"./settings.CYERib3l.js";import{at as x}from"./req-analysis.qmyv5cBw.js";import{F as S,I as C}from"./case-review.TdDs1WFM.js";import{s as w}from"./fs-tools.3F9MFrLf.js";import{s as T,w as E}from"./tasks.DEyD8pmq.js";import{l as D}from"./report-prompt.B9C4cv84.js";import{a as O}from"./test-stats.Cf3_L4wu.js";import{a as k}from"./ui-auto-prompt.COBTt5Gd.js";import{s as ee,y as A}from"./story-review.2UUlN3p-.js";var j=e(t(),1),M=`/__tb_memory`,N=3e3,P=`你可以使用跨会话长期记忆(本机五轨:user / memory / key / project / daily):
|
|
2
2
|
- 系统可能已在 <memory_snapshot> 注入用户档案、全局事实与项目关键记忆;优先参考。
|
|
3
3
|
- 查历史进展:memory_search 或 memory_read(project / daily 不自动注入)。
|
|
4
4
|
- 用户明确要求记住偏好/全局事实/项目约定:调用 memory_suggest(进待确认,确认后才注入)。
|
|
@@ -14,4 +14,4 @@ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config
|
|
|
14
14
|
"env": {}
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
}`})}):(0,Y.jsxs)(`div`,{className:`mt-4 space-y-3 overflow-y-auto`,children:[(0,Y.jsx)(Q,{label:`名称`,children:(0,Y.jsx)(`input`,{value:x.name,disabled:x.mode===`tencent`,onChange:e=>_&&v({..._,name:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`tencent-docs`})}),x.mode===`tencent`?null:(0,Y.jsx)(Q,{label:`传输`,children:(0,Y.jsx)(`div`,{className:`flex gap-2`,children:[`http`,`stdio`].map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":x.transport===e,onClick:()=>_&&v({..._,transport:e}),className:`h-8 rounded-md border px-3 text-[12px] ${x.transport===e?`border-[#4176e6] bg-[#4176e6]/10 text-[#4176e6]`:`border-stone-200 text-stone-600`}`,children:e},e))})}),x.transport===`http`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:`URL`,children:(0,Y.jsx)(`input`,{value:x.url,disabled:x.mode===`tencent`,onChange:e=>_&&v({..._,url:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`https://…`})}),(0,Y.jsx)(Q,{label:x.mode===`tencent`?`MCP Token(Authorization)`:`Authorization`,children:(0,Y.jsx)(`input`,{value:x.authHeader,onChange:e=>_&&v({..._,authHeader:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:x.mode===`edit`&&x.authHeader.startsWith(`••••`)?`留脱敏值表示不改密钥`:`粘贴 Token`,autoComplete:`off`})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:`command`,children:(0,Y.jsx)(`input`,{value:x.command,onChange:e=>_&&v({..._,command:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`npx`})}),(0,Y.jsx)(Q,{label:`args(空格分隔)`,children:(0,Y.jsx)(`input`,{value:x.argsText,onChange:e=>_&&v({..._,argsText:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`-y some-mcp-server`})}),(0,Y.jsx)(Q,{label:`env(每行 KEY=VALUE)`,children:(0,Y.jsx)(`textarea`,{value:x.envText,onChange:e=>_&&v({..._,envText:e.target.value}),spellCheck:!1,rows:3,className:`w-full resize-y rounded-lg border border-stone-200 bg-white px-3 py-2 font-mono text-[12px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`TAVILY_API_KEY=…`})})]})]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>v(null),className:`h-9 rounded-lg border border-stone-200 px-3 text-[13px] text-stone-600`,children:`取消`}),(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>void k(),className:`h-9 rounded-lg bg-[#4176e6] px-3 text-[13px] font-medium text-white disabled:opacity-60`,children:l?`保存中…`:`保存`})]})]}):null})})]}),(0,Y.jsxs)(m,{open:!!S,onClose:()=>{l||C(null)},className:`relative z-110`,children:[(0,Y.jsx)(h,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,Y.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,Y.jsxs)(f,{transition:!0,className:`tw-dialog-panel-anim w-full max-w-sm rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,Y.jsx)(p,{className:`text-[15px] font-semibold text-stone-900`,children:`删除 MCP?`}),(0,Y.jsxs)(`p`,{className:`mt-2 text-[13px] text-stone-500`,children:[`将从当前空间配置中移除「`,T,`」,对话里对应工具会立即消失。`]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>C(null),className:`h-9 rounded-lg border border-stone-200 px-3 text-[13px] text-stone-600`,children:`取消`}),(0,Y.jsx)(`button`,{type:`button`,disabled:l||!T,onClick:()=>T&&void ee(T),className:`h-9 rounded-lg bg-rose-600 px-3 text-[13px] font-medium text-white disabled:opacity-60`,children:`删除`})]})]})})]})]})}function Q({label:e,children:t}){return(0,Y.jsxs)(`label`,{className:`block`,children:[(0,Y.jsx)(`span`,{className:`mb-1 block text-[12px] text-stone-500`,children:e}),t]})}var Ae=[`extensions`,`mcp`],je=[{id:`extensions`,label:`扩展插件`},{id:`mcp`,label:`MCP`}],Me={tasks:`侧栏「任务管理」按状态列出任务;工作台可直接增删改`,todos:`侧栏「待办事项」按状态 / 紧急程度分组;工作台可直接增删改`,projects:`侧栏「项目列表」管理项目并汇总迭代 / 需求 / 缺陷;工作台可直接增删改`,iterations:`侧栏「迭代管理」按项目维护迭代周期、进度与逾期;工作台可直接增删改`,pmRequirements:`侧栏「需求管理」维护需求编号 / 优先级 / 状态与验收标准;工作台可直接增删改`,bugs:`侧栏「缺陷管理」记录严重程度 / 重现步骤与修复状态;工作台可直接增删改`,testStats:`侧栏「测试统计」按维度记录每天的统计数量`,caseExec:`侧栏「用例执行统计」按项目记录用例执行情况`,dashboard:`侧栏「仪表盘」聚合待办 / 任务 / 测试统计;卡片可拖动排序、拖角改宽高,右上角编辑组件`},$={tasks:T,todos:E,projects:y,iterations:y,pmRequirements:y,bugs:y,testStats:O,caseExec:l,dashboard:E},Ne=[{id:`all`,label:`全部`},{id:`on`,label:`已启用`},{id:`off`,label:`未启用`}],Pe=s();function Fe({embedded:e=!1}){let[t,r]=(0,j.useState)(()=>u(`plugins.pageTab`,Ae,`extensions`)),[s,l]=(0,j.useState)(()=>i()),[f,p]=(0,j.useState)(null),[m,h]=(0,j.useState)(null),[g,_]=(0,j.useState)(null),[y,T]=(0,j.useState)(!0),[E,O]=(0,j.useState)(``),[M,N]=(0,j.useState)(`all`),[P,te]=(0,j.useState)(null),[F,I]=(0,j.useState)({}),[R,z]=(0,j.useState)(null);function B(e){r(e),d(`plugins.pageTab`,e)}async function ne(){T(!0);try{let[e,t,n,r,i,a,o,s,c,l,u]=await Promise.all([L(),w(),$.tasks(),$.todos(),$.projects(),$.iterations(),$.pmRequirements(),$.bugs(),$.testStats(),$.caseExec(),$.dashboard()]);p(e),h(t),_({tasks:n,todos:r,projects:i,iterations:a,pmRequirements:o,bugs:s,testStats:c,caseExec:l,dashboard:u})}finally{T(!1)}}(0,j.useEffect)(()=>{let e=o(e=>l(e));return n().then(()=>{l(i()),ne()}),J().then(e=>{e?.ok&&z(e.serversConfigured??0)}),()=>{e()}},[]),(0,j.useEffect)(()=>{t===`mcp`&&J().then(e=>{e?.ok&&z(e.serversConfigured??0)})},[t]);function V(e){if(e===`cases`)return{available:!0,detail:`侧栏「用例管理」浏览与维护本空间用例库`};if(e===`caseGen`)return s.cases?{available:!0,detail:`对话输入 / 打开配置面板,生成用例并写入用例库`}:{available:!1,detail:`需先启用「用例管理」,生成结果才能写入用例列表`};if(e===`prompts`)return{available:!0,detail:`侧栏「提示词管理」浏览与维护本空间提示词库`};if(e===`promptGen`)return s.prompts?{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===`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=g?.[e];return t===void 0?{available:y?null:!1,detail:y?`探测中…`:`需本地服务`}:t?{available:!0,detail:Me[e]}:{available:!1,detail:`需本地服务(npm run dev / lantern web)`}}return e===`knowledgeGen`?s.knowledgeLib?{available:!0,detail:`对话输入 / 打开配置面板,生成文档并写入知识库`}:{available:!1,detail:`需先启用「知识库管理」,生成结果才能写入知识库列表`}:e===`memory`?y&&f===null?{available:null,detail:`探测中…`}:f?.ok?{available:!0,detail:`已连接 · ${f.entryCount??f.entityCount??0} 条记忆 / 待确认 ${f.suggestionCount??0}`}:{available:!1,detail:`本地记忆服务未就绪`}:e===`knowledge`?{available:!0,detail:`对话输入 @ 可引用知识库与模板文档`}:e===`pluginDev`?y&&m===null?{available:null,detail:`探测中…`}:m?.ok?{available:!0,detail:`固定提示词开发扩展插件;先评估确认,再改代码并入「扩展插件」`}:{available:!1,detail:`需本地文件服务:开发要读写项目源码`}:{available:!1,detail:`未知`}}function re(e){let t=a(e,!s[e]),n=!!t[e],r=c.find(t=>t.id===e)?.name??e;l(t),b(n?`已启用「${r}」`:`已停用「${r}」`,`success`),e===`reports`&&D(!!t.reports).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`工作汇报提示词没生成成功:${t}`,`error`)}),e===`uiAuto`&&k(!!t.uiAuto).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`UI自动化测试提示词没生成成功:${t}`,`error`)}),e===`reqAnalysis`&&x(!!t.reqAnalysis).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`需求分析提示词没生成成功:${t}`,`error`)}),e===`storyReview`&&ee(!!t.storyReview).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`用户故事审查提示词没生成成功:${t}`,`error`)}),e===`testPoints`&&A(!!t.testPoints).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`测试点生成提示词没生成成功:${t}`,`error`)}),(e===`caseReview`||e===`cases`)&&C(!!t.caseReview).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`用例质量评审提示词没生成成功:${t}`,`error`)}),(e===`caseBlindspot`||e===`cases`)&&S(!!t.caseBlindspot).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`场景遗漏补全提示词没生成成功:${t}`,`error`)}),(e===`projects`||e===`iterations`||e===`pmRequirements`||e===`bugs`)&&t[e]&&v().catch(e=>{console.warn(`[pm] 同步项目管理数据目录失败`,e)})}let ie=(0,j.useMemo)(()=>c.filter(e=>s[e.id]).length,[s]),H=E.trim().toLowerCase(),U=(0,j.useMemo)(()=>Pe.map(e=>({...e,items:e.items.filter(e=>{let t=!H||e.name.toLowerCase().includes(H)||e.id.toLowerCase().includes(H)||e.description.toLowerCase().includes(H),n=M===`all`||(M===`on`?s[e.id]:!s[e.id]);return t&&n})})).filter(e=>e.items.length>0),[s,H,M]);return(0,Y.jsx)(`div`,{className:`tw-plugins-page overflow-y-auto ${e?`h-full min-h-0 flex-1`:`min-h-screen`}`,children:(0,Y.jsxs)(`div`,{className:`mx-auto w-full max-w-[1320px] ${e?`px-4 py-5`:`px-4 py-7 sm:px-5`}`,children:[(0,Y.jsxs)(`header`,{className:`tw-plugins-head`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{className:`text-[20px] font-semibold tracking-tight text-stone-900`,children:`我的插件`}),(0,Y.jsx)(`p`,{className:`mt-1.5 text-[13px] leading-6 text-stone-500`,children:t===`extensions`?(0,Y.jsxs)(Y.Fragment,{children:[`按用途分组的扩展能力,开关保存在本机;会话 / 全局内置能力在`,(0,Y.jsx)(`span`,{className:`mx-1 rounded bg-stone-100 px-1 py-0.5 text-[12px] text-stone-600`,children:`设置 → 内置插件`}),`里查看。`]}):(0,Y.jsxs)(Y.Fragment,{children:[`管理当前数据空间的外接 MCP(写入`,(0,Y.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,Y.jsxs)(`div`,{className:`tw-plugins-stats`,"aria-label":`插件概览`,children:[(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num`,children:c.length}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`个插件`})]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num is-on`,children:ie}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`已启用`})]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num`,children:Pe.length}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`个分类`})]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num`,children:R??`—`}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`MCP`})]})]})]}),(0,Y.jsx)(`div`,{className:`tw-plugins-tabs`,role:`tablist`,"aria-label":`插件页分类`,children:je.map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,className:t===e.id?`is-active`:void 0,onClick:()=>B(e.id),children:[e.label,(0,Y.jsx)(`span`,{className:`tw-plugins-tab-count`,children:e.id===`extensions`?c.length:R??`—`})]},e.id))}),(0,Y.jsx)(`div`,{className:`tw-plugins-tab-panel`,children:t===`mcp`?(0,Y.jsx)(ke,{onServersChange:z}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`tw-plugins-toolbar`,children:[(0,Y.jsxs)(`label`,{className:`relative block w-full max-w-72`,children:[(0,Y.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,Y.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,Y.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),(0,Y.jsx)(`input`,{value:E,onChange:e=>O(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,Y.jsx)(`div`,{className:`tw-plugins-pills`,role:`group`,"aria-label":`按状态筛选`,children:Ne.map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":M===e.id,onClick:()=>N(e.id),children:e.label},e.id))})]}),(0,Y.jsxs)(`div`,{className:`mt-4 space-y-6`,children:[U.map(e=>{let t=!!F[e.category],n=e.items.filter(e=>s[e.id]).length;return(0,Y.jsxs)(`section`,{children:[(0,Y.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,Y.jsx)(Le,{className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform ${t?`-rotate-90`:``}`}),(0,Y.jsx)(`span`,{className:`text-[13px] font-semibold text-stone-800`,children:e.category}),(0,Y.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,Y.jsx)(`span`,{className:`ml-1 h-px flex-1 bg-stone-200/70`,"aria-hidden":`true`})]}),t?null:(0,Y.jsx)(`ul`,{className:`tw-anim-list tw-plugin-grid`,children:e.items.map(e=>{let t=s[e.id],n=V(e.id),r=P===`ext:${e.id}`;return(0,Y.jsx)(`li`,{className:`relative z-0 min-w-0 overflow-visible hover:z-40 focus-within:z-40${r?` z-40`:``}`,children:(0,Y.jsx)(Ie,{open:r,onToggleOpen:()=>te(r?null:`ext:${e.id}`),title:e.name,subtitle:e.description,badge:(0,Y.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,Y.jsx)(`span`,{className:`rounded border border-stone-200 px-1.5 py-0.5 text-[11px] text-stone-500`,children:`内置`}):(0,Y.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":`${t?`关闭`:`打开`} ${e.name}`,onClick:()=>re(e.id),className:`tw-toggle`,children:(0,Y.jsx)(`span`,{className:`tw-toggle-knob`})}),fullName:`@lh-plugins/${e.id}`,configLabel:e.alwaysOn?`内置常开`:t?`已启用`:`未启用`,runLabel:t&&n.available===!0?`运行中`:`已停用`,extra:n.detail})},e.id)})})]},e.category)}),U.length?null:(0,Y.jsxs)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-white/60 px-4 py-12 text-center`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-stone-600`,children:`没有匹配的插件`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`换个关键词,或把状态筛选切回「全部」。`})]})]})]})},t)]})})}function Ie(e){let{open:t,onToggleOpen:n,title:r,subtitle:i,badge:a,trailing:o,fullName:s,configLabel:c,runLabel:l,extra:u}=e;return(0,Y.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,Y.jsxs)(`div`,{className:`relative flex h-17 items-start gap-3 overflow-visible px-4 py-3`,children:[(0,Y.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,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`min-w-0 truncate text-[14px] font-medium text-stone-900`,children:r}),a,(0,Y.jsx)(Le,{className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform duration-300 ease-out ${t?`rotate-180`:``}`})]}),(0,Y.jsx)(_,{text:i,className:`mt-1 block min-w-0 truncate text-[13px] leading-5 text-stone-500`,disabled:t})]}),(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 self-start pt-0.5`,children:o})]}),(0,Y.jsx)(`div`,{className:`tw-collapse ${t?`is-open`:``}`,"aria-hidden":!t,children:(0,Y.jsx)(`div`,{className:`tw-collapse-inner`,children:(0,Y.jsx)(`div`,{className:`border-t border-stone-100 px-4 pb-3 pt-0`,children:(0,Y.jsxs)(`dl`,{className:`mt-2.5 space-y-1.5 text-[13px]`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`完整名称`}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px] text-stone-700`,children:s})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`配置状态`}),(0,Y.jsx)(`dd`,{className:`text-stone-700`,children:c})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`运行状态`}),(0,Y.jsx)(`dd`,{className:l===`运行中`?`text-emerald-600`:`text-stone-500`,children:l})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`简介`}),(0,Y.jsx)(`dd`,{className:`text-[12px] leading-5 text-stone-500`,children:i})]}),u?(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`说明`}),(0,Y.jsx)(`dd`,{className:`text-[12px] leading-5 text-stone-500`,children:u})]}):null]})})})})]})}function Le({className:e}){return(0,Y.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:e,"aria-hidden":!0,children:(0,Y.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}export{fe as C,ie as S,V as _,xe as a,se as b,re as c,U as d,pe as f,ne as g,L as h,be as i,H as l,R as m,me as n,P as o,oe as p,ye as r,te as s,Fe as t,ae as u,ce as v,z as w,le as x,de as y};
|
|
17
|
+
}`})}):(0,Y.jsxs)(`div`,{className:`mt-4 space-y-3 overflow-y-auto`,children:[(0,Y.jsx)(Q,{label:`名称`,children:(0,Y.jsx)(`input`,{value:x.name,disabled:x.mode===`tencent`,onChange:e=>_&&v({..._,name:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`tencent-docs`})}),x.mode===`tencent`?null:(0,Y.jsx)(Q,{label:`传输`,children:(0,Y.jsx)(`div`,{className:`flex gap-2`,children:[`http`,`stdio`].map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":x.transport===e,onClick:()=>_&&v({..._,transport:e}),className:`h-8 rounded-md border px-3 text-[12px] ${x.transport===e?`border-[#4176e6] bg-[#4176e6]/10 text-[#4176e6]`:`border-stone-200 text-stone-600`}`,children:e},e))})}),x.transport===`http`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:`URL`,children:(0,Y.jsx)(`input`,{value:x.url,disabled:x.mode===`tencent`,onChange:e=>_&&v({..._,url:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`https://…`})}),(0,Y.jsx)(Q,{label:x.mode===`tencent`?`MCP Token(Authorization)`:`Authorization`,children:(0,Y.jsx)(`input`,{value:x.authHeader,onChange:e=>_&&v({..._,authHeader:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:x.mode===`edit`&&x.authHeader.startsWith(`••••`)?`留脱敏值表示不改密钥`:`粘贴 Token`,autoComplete:`off`})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:`command`,children:(0,Y.jsx)(`input`,{value:x.command,onChange:e=>_&&v({..._,command:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`npx`})}),(0,Y.jsx)(Q,{label:`args(空格分隔)`,children:(0,Y.jsx)(`input`,{value:x.argsText,onChange:e=>_&&v({..._,argsText:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`-y some-mcp-server`})}),(0,Y.jsx)(Q,{label:`env(每行 KEY=VALUE)`,children:(0,Y.jsx)(`textarea`,{value:x.envText,onChange:e=>_&&v({..._,envText:e.target.value}),spellCheck:!1,rows:3,className:`w-full resize-y rounded-lg border border-stone-200 bg-white px-3 py-2 font-mono text-[12px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`TAVILY_API_KEY=…`})})]})]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>v(null),className:`h-9 rounded-lg border border-stone-200 px-3 text-[13px] text-stone-600`,children:`取消`}),(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>void k(),className:`h-9 rounded-lg bg-[#4176e6] px-3 text-[13px] font-medium text-white disabled:opacity-60`,children:l?`保存中…`:`保存`})]})]}):null})})]}),(0,Y.jsxs)(m,{open:!!S,onClose:()=>{l||C(null)},className:`relative z-110`,children:[(0,Y.jsx)(h,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,Y.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,Y.jsxs)(f,{transition:!0,className:`tw-dialog-panel-anim w-full max-w-sm rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,Y.jsx)(p,{className:`text-[15px] font-semibold text-stone-900`,children:`删除 MCP?`}),(0,Y.jsxs)(`p`,{className:`mt-2 text-[13px] text-stone-500`,children:[`将从当前空间配置中移除「`,T,`」,对话里对应工具会立即消失。`]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>C(null),className:`h-9 rounded-lg border border-stone-200 px-3 text-[13px] text-stone-600`,children:`取消`}),(0,Y.jsx)(`button`,{type:`button`,disabled:l||!T,onClick:()=>T&&void ee(T),className:`h-9 rounded-lg bg-rose-600 px-3 text-[13px] font-medium text-white disabled:opacity-60`,children:`删除`})]})]})})]})]})}function Q({label:e,children:t}){return(0,Y.jsxs)(`label`,{className:`block`,children:[(0,Y.jsx)(`span`,{className:`mb-1 block text-[12px] text-stone-500`,children:e}),t]})}var Ae=[`extensions`,`mcp`],je=[{id:`extensions`,label:`扩展插件`},{id:`mcp`,label:`MCP`}],Me={tasks:`侧栏「任务管理」按状态列出任务;工作台可直接增删改`,todos:`侧栏「待办事项」按状态 / 紧急程度分组;工作台可直接增删改`,projects:`侧栏「项目列表」管理项目并汇总迭代 / 需求 / 缺陷;工作台可直接增删改`,iterations:`侧栏「迭代管理」按项目维护迭代周期、进度与逾期;工作台可直接增删改`,pmRequirements:`侧栏「需求管理」维护需求编号 / 优先级 / 状态与验收标准;工作台可直接增删改`,bugs:`侧栏「缺陷管理」记录严重程度 / 重现步骤与修复状态;工作台可直接增删改`,testStats:`侧栏「测试统计」按维度记录每天的统计数量`,caseExec:`侧栏「用例执行统计」按项目记录用例执行情况`,dashboard:`侧栏「仪表盘」聚合待办 / 任务 / 测试统计;卡片可拖动排序、拖角改宽高,右上角编辑组件`},$={tasks:T,todos:E,projects:y,iterations:y,pmRequirements:y,bugs:y,testStats:O,caseExec:l,dashboard:E},Ne=[{id:`all`,label:`全部`},{id:`on`,label:`已启用`},{id:`off`,label:`未启用`}],Pe=s();function Fe({embedded:e=!1}){let[t,r]=(0,j.useState)(()=>u(`plugins.pageTab`,Ae,`extensions`)),[s,l]=(0,j.useState)(()=>i()),[f,p]=(0,j.useState)(null),[m,h]=(0,j.useState)(null),[g,_]=(0,j.useState)(null),[y,T]=(0,j.useState)(!0),[E,O]=(0,j.useState)(``),[M,N]=(0,j.useState)(`all`),[P,te]=(0,j.useState)(null),[F,I]=(0,j.useState)({}),[R,z]=(0,j.useState)(null);function B(e){r(e),d(`plugins.pageTab`,e)}async function ne(){T(!0);try{let[e,t,n,r,i,a,o,s,c,l,u]=await Promise.all([L(),w(),$.tasks(),$.todos(),$.projects(),$.iterations(),$.pmRequirements(),$.bugs(),$.testStats(),$.caseExec(),$.dashboard()]);p(e),h(t),_({tasks:n,todos:r,projects:i,iterations:a,pmRequirements:o,bugs:s,testStats:c,caseExec:l,dashboard:u})}finally{T(!1)}}(0,j.useEffect)(()=>{let e=o(e=>l(e));return n().then(()=>{l(i()),ne()}),J().then(e=>{e?.ok&&z(e.serversConfigured??0)}),()=>{e()}},[]),(0,j.useEffect)(()=>{t===`mcp`&&J().then(e=>{e?.ok&&z(e.serversConfigured??0)})},[t]);function V(e){if(e===`cases`)return{available:!0,detail:`侧栏「用例管理」浏览与维护本空间用例库`};if(e===`caseGen`)return s.cases?{available:!0,detail:`对话输入 / 打开配置面板,生成用例并写入用例库`}:{available:!1,detail:`需先启用「用例管理」,生成结果才能写入用例列表`};if(e===`prompts`)return{available:!0,detail:`侧栏「提示词管理」浏览与维护本空间提示词库`};if(e===`promptGen`)return s.prompts?{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=g?.[e];return t===void 0?{available:y?null:!1,detail:y?`探测中…`:`需本地服务`}:t?{available:!0,detail:Me[e]}:{available:!1,detail:`需本地服务(npm run dev / lantern web)`}}return e===`knowledgeGen`?s.knowledgeLib?{available:!0,detail:`对话输入 / 打开配置面板,生成文档并写入知识库`}:{available:!1,detail:`需先启用「知识库管理」,生成结果才能写入知识库列表`}:e===`memory`?y&&f===null?{available:null,detail:`探测中…`}:f?.ok?{available:!0,detail:`已连接 · ${f.entryCount??f.entityCount??0} 条记忆 / 待确认 ${f.suggestionCount??0}`}:{available:!1,detail:`本地记忆服务未就绪`}:e===`knowledge`?{available:!0,detail:`对话输入 @ 可引用知识库与模板文档`}:e===`pluginDev`?y&&m===null?{available:null,detail:`探测中…`}:m?.ok?{available:!0,detail:`固定提示词开发扩展插件;先评估确认,再改代码并入「扩展插件」`}:{available:!1,detail:`需本地文件服务:开发要读写项目源码`}:{available:!1,detail:`未知`}}function re(e){let t=a(e,!s[e]),n=!!t[e],r=c.find(t=>t.id===e)?.name??e;l(t),b(n?`已启用「${r}」`:`已停用「${r}」`,`success`),e===`reports`&&D(!!t.reports).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`工作汇报提示词没生成成功:${t}`,`error`)}),e===`uiAuto`&&k(!!t.uiAuto).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`UI自动化测试提示词没生成成功:${t}`,`error`)}),e===`reqAnalysis`&&x(!!t.reqAnalysis).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`需求分析提示词没生成成功:${t}`,`error`)}),e===`storyReview`&&ee(!!t.storyReview).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`用户故事审查提示词没生成成功:${t}`,`error`)}),e===`testPoints`&&A(!!t.testPoints).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`测试点生成提示词没生成成功:${t}`,`error`)}),(e===`caseReview`||e===`cases`)&&C(!!t.caseReview).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`用例质量评审提示词没生成成功:${t}`,`error`)}),(e===`caseBlindspot`||e===`cases`)&&S(!!t.caseBlindspot).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`场景遗漏补全提示词没生成成功:${t}`,`error`)}),(e===`projects`||e===`iterations`||e===`pmRequirements`||e===`bugs`)&&t[e]&&v().catch(e=>{console.warn(`[pm] 同步项目管理数据目录失败`,e)})}let ie=(0,j.useMemo)(()=>c.filter(e=>s[e.id]).length,[s]),H=E.trim().toLowerCase(),U=(0,j.useMemo)(()=>Pe.map(e=>({...e,items:e.items.filter(e=>{let t=!H||e.name.toLowerCase().includes(H)||e.id.toLowerCase().includes(H)||e.description.toLowerCase().includes(H),n=M===`all`||(M===`on`?s[e.id]:!s[e.id]);return t&&n})})).filter(e=>e.items.length>0),[s,H,M]);return(0,Y.jsx)(`div`,{className:`tw-plugins-page overflow-y-auto ${e?`h-full min-h-0 flex-1`:`min-h-screen`}`,children:(0,Y.jsxs)(`div`,{className:`mx-auto w-full max-w-[1320px] ${e?`px-4 py-5`:`px-4 py-7 sm:px-5`}`,children:[(0,Y.jsxs)(`header`,{className:`tw-plugins-head`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{className:`text-[20px] font-semibold tracking-tight text-stone-900`,children:`我的插件`}),(0,Y.jsx)(`p`,{className:`mt-1.5 text-[13px] leading-6 text-stone-500`,children:t===`extensions`?(0,Y.jsxs)(Y.Fragment,{children:[`按用途分组的扩展能力,开关保存在本机;会话 / 全局内置能力在`,(0,Y.jsx)(`span`,{className:`mx-1 rounded bg-stone-100 px-1 py-0.5 text-[12px] text-stone-600`,children:`设置 → 内置插件`}),`里查看。`]}):(0,Y.jsxs)(Y.Fragment,{children:[`管理当前数据空间的外接 MCP(写入`,(0,Y.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,Y.jsxs)(`div`,{className:`tw-plugins-stats`,"aria-label":`插件概览`,children:[(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num`,children:c.length}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`个插件`})]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num is-on`,children:ie}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`已启用`})]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num`,children:Pe.length}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`个分类`})]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num`,children:R??`—`}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`MCP`})]})]})]}),(0,Y.jsx)(`div`,{className:`tw-plugins-tabs`,role:`tablist`,"aria-label":`插件页分类`,children:je.map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,className:t===e.id?`is-active`:void 0,onClick:()=>B(e.id),children:[e.label,(0,Y.jsx)(`span`,{className:`tw-plugins-tab-count`,children:e.id===`extensions`?c.length:R??`—`})]},e.id))}),(0,Y.jsx)(`div`,{className:`tw-plugins-tab-panel`,children:t===`mcp`?(0,Y.jsx)(ke,{onServersChange:z}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`tw-plugins-toolbar`,children:[(0,Y.jsxs)(`label`,{className:`relative block w-full max-w-72`,children:[(0,Y.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,Y.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,Y.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),(0,Y.jsx)(`input`,{value:E,onChange:e=>O(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,Y.jsx)(`div`,{className:`tw-plugins-pills`,role:`group`,"aria-label":`按状态筛选`,children:Ne.map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":M===e.id,onClick:()=>N(e.id),children:e.label},e.id))})]}),(0,Y.jsxs)(`div`,{className:`mt-4 space-y-6`,children:[U.map(e=>{let t=!!F[e.category],n=e.items.filter(e=>s[e.id]).length;return(0,Y.jsxs)(`section`,{children:[(0,Y.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,Y.jsx)(Le,{className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform ${t?`-rotate-90`:``}`}),(0,Y.jsx)(`span`,{className:`text-[13px] font-semibold text-stone-800`,children:e.category}),(0,Y.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,Y.jsx)(`span`,{className:`ml-1 h-px flex-1 bg-stone-200/70`,"aria-hidden":`true`})]}),t?null:(0,Y.jsx)(`ul`,{className:`tw-anim-list tw-plugin-grid`,children:e.items.map(e=>{let t=s[e.id],n=V(e.id),r=P===`ext:${e.id}`;return(0,Y.jsx)(`li`,{className:`relative z-0 min-w-0 overflow-visible hover:z-40 focus-within:z-40${r?` z-40`:``}`,children:(0,Y.jsx)(Ie,{open:r,onToggleOpen:()=>te(r?null:`ext:${e.id}`),title:e.name,subtitle:e.description,badge:(0,Y.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,Y.jsx)(`span`,{className:`rounded border border-stone-200 px-1.5 py-0.5 text-[11px] text-stone-500`,children:`内置`}):(0,Y.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":`${t?`关闭`:`打开`} ${e.name}`,onClick:()=>re(e.id),className:`tw-toggle`,children:(0,Y.jsx)(`span`,{className:`tw-toggle-knob`})}),fullName:`@lh-plugins/${e.id}`,configLabel:e.alwaysOn?`内置常开`:t?`已启用`:`未启用`,runLabel:t&&n.available===!0?`运行中`:`已停用`,extra:n.detail})},e.id)})})]},e.category)}),U.length?null:(0,Y.jsxs)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-white/60 px-4 py-12 text-center`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-stone-600`,children:`没有匹配的插件`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`换个关键词,或把状态筛选切回「全部」。`})]})]})]})},t)]})})}function Ie(e){let{open:t,onToggleOpen:n,title:r,subtitle:i,badge:a,trailing:o,fullName:s,configLabel:c,runLabel:l,extra:u}=e;return(0,Y.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,Y.jsxs)(`div`,{className:`relative flex h-17 items-start gap-3 overflow-visible px-4 py-3`,children:[(0,Y.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,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`min-w-0 truncate text-[14px] font-medium text-stone-900`,children:r}),a,(0,Y.jsx)(Le,{className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform duration-300 ease-out ${t?`rotate-180`:``}`})]}),(0,Y.jsx)(_,{text:i,className:`mt-1 block min-w-0 truncate text-[13px] leading-5 text-stone-500`,disabled:t})]}),(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 self-start pt-0.5`,children:o})]}),(0,Y.jsx)(`div`,{className:`tw-collapse ${t?`is-open`:``}`,"aria-hidden":!t,children:(0,Y.jsx)(`div`,{className:`tw-collapse-inner`,children:(0,Y.jsx)(`div`,{className:`border-t border-stone-100 px-4 pb-3 pt-0`,children:(0,Y.jsxs)(`dl`,{className:`mt-2.5 space-y-1.5 text-[13px]`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`完整名称`}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px] text-stone-700`,children:s})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`配置状态`}),(0,Y.jsx)(`dd`,{className:`text-stone-700`,children:c})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`运行状态`}),(0,Y.jsx)(`dd`,{className:l===`运行中`?`text-emerald-600`:`text-stone-500`,children:l})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`简介`}),(0,Y.jsx)(`dd`,{className:`text-[12px] leading-5 text-stone-500`,children:i})]}),u?(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`说明`}),(0,Y.jsx)(`dd`,{className:`text-[12px] leading-5 text-stone-500`,children:u})]}):null]})})})})]})}function Le({className:e}){return(0,Y.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:e,"aria-hidden":!0,children:(0,Y.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}export{fe as C,ie as S,V as _,xe as a,se as b,re as c,U as d,pe as f,ne as g,L as h,be as i,H as l,R as m,me as n,P as o,oe as p,ye as r,te as s,Fe as t,ae as u,ce as v,z as w,le as x,de as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{p as n}from"./app-config.C4rpn1Ix.js";import{s as r}from"./plugins.C0NrHGZv.js";import{t as i}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.D5qXeML0.js";import{n as te,t as ne}from"./DocsPager.D0TMvJ67.js";import{t as a}from"./SelectDropdown.Dmk5n225.js";import{A as re,D as ie,N as ae,P as oe,R as o,b as se,g as ce,h as le,i as ue,j as de,m as s,n as fe,p as pe,r as c,t as l,x as me,z as he}from"./pm.BXmOiFfW.js";import{A as ge,C as _e,D as ve,E as u,O as ye,S as be,_ as d,a as xe,c as Se,d as Ce,f,g as we,h as Te,j as Ee,k as p,l as De,m,n as Oe,p as ke,s as Ae,t as je,u as Me,y as h}from"./PmShared.D6iq_Z9g.js";import{n as Ne,r as Pe,t as Fe}from"./TableFieldConfig.C_NeWm8L.js";import{showToast as g}from"./Toast.BO2NFckG.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=i(),b=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`severity`,width:100,min:80},{key:`status`,width:120,min:96}],We={key:`project`,width:140,min:100},Ge=[{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}],Ke=new Set([`id`,`title`,`filler`,`action`]),qe=[{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`,...c],Qe=[`all`,...l],$e=`pm.bugs.project`,et=`pm.bugs.iteration`,tt=`pm.bugs.status`,nt=`pm.bugs.severity`,rt=`pm.bugs.keyword`,it=l.map(e=>({value:e,label:fe[e]})),at=c.map(e=>({value:e,label:ue[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=ge(`bugs`),{store:i,live:c,loading:l,error:x,setError:S,reload:C}=Ee(),[T,E]=p($e,`all`),D=e||T,[O,k]=p(et,`all`),[A,ct]=ye(tt,Ze,`all`),[j,lt]=ye(nt,Qe,`all`),[M,ut]=p(rt),[dt,N]=(0,v.useState)(1),[P,ft]=te(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)(()=>de(F?.attachment??``),[F?.attachment]),ht=(0,v.useMemo)(()=>t?qe:[{key:`project`,label:`所属项目`},...qe],[t]),K=Pe(Je,ht,Ke),gt=(0,v.useMemo)(()=>t?[...b,...Ge]:[...b,We,...Ge],[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:`全部项目`},...i.projects.map(e=>({value:e.id,label:e.name}))],[i.projects]),bt=(0,v.useMemo)(()=>[{value:`all`,label:`全部迭代`},...i.iterations.filter(e=>D===`all`||e.projectId===D).map(e=>({value:e.id,label:e.name}))],[i.iterations,D]),xt=(0,v.useMemo)(()=>{let e=new Map(i.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[i.projects]),St=(0,v.useMemo)(()=>{let e=new Map(i.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[i.iterations]),Y=(0,v.useMemo)(()=>ae(me(i.bugs,{projectId:D,iterationId:O,status:A,severity:j,keyword:M})),[i.bugs,D,O,A,j,M]),X=t?i.bugs.filter(e=>e.projectId===D).length:i.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||c===!0&&T!==`all`&&!i.projects.some(e=>e.id===T)&&E(`all`)},[c,i.projects,T,E,t]),(0,v.useEffect)(()=>{c===!0&&O!==`all`&&!i.iterations.some(e=>e.id===O&&(D===`all`||e.projectId===D))&&k(`all`)},[c,i.iterations,D,O,k]);let Tt=F?oe(i.iterations.filter(e=>e.projectId===F.projectId)):[],Et=F?i.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=pe(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 o(`bugs`,F.id,n):await le(`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 he(Array.from(e));I(e=>{if(!e)return e;let n=de(e.attachment);return{...e,attachment:re([...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=se(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=re(G.filter(t=>t.url!==e));if(F.id)try{await o(`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}),s([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&&s(e)}return}let e=[...V.current,...G.map(e=>e.url)];V.current.clear(),I(null),e.length&&s(e)}function $(){I(st(D===`all`?``:D))}async function jt(e,t){R(!0);try{await o(`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 ce(`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)(we,{label:`正在读取插件开关`});if(!n.on)return(0,y.jsx)(d,{children:r(`bugs`)});if(c===null)return(0,y.jsx)(we,{label:`正在连接项目管理服务`});if(!c)return(0,y.jsx)(d,{children:`缺陷管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(i.projects.length===0&&!l&&!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)(a,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选缺陷`,className:`w-36`,options:yt,value:T,onChange:e=>{E(e),k(`all`),N(1)}}),(0,y.jsx)(a,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选缺陷`,className:`w-32`,options:bt,value:O,onChange:e=>{k(e),N(1)}}),(0,y.jsx)(a,{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-[#3370ff]`})]}),(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-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] 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)(ke,{ariaLabel:`按状态筛选缺陷`,options:Nt,value:A,onChange:e=>{ct(e),N(1)}})}),x?(0,y.jsx)(Ce,{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:[l&&!i.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)(De,{children:`没有符合筛选条件的缺陷。`}):(0,y.jsx)(Me,{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)(_e,{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)(be,{tone:je[e.severity],children:fe[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)(a,{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)(Ae,{tone:Oe[e.value]}),renderTrigger:()=>(0,y.jsx)(be,{tone:Oe[e.status],children:ue[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:ve(e.projectId),className:`block truncate transition-colors hover:text-[#3370ff]`,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)(ne,{page:Z,totalPages:Ct,pageSize:P,busy:L,onPage:N,onPageSize:e=>{ft(e),N(1)}}):null]}),(0,y.jsx)(Se,{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:i.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:xe})}),(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)(Ae,{tone:je[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=ie(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-[#3370ff]`,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-[#3370ff]`,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:xe})}),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(i.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(i.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)(Te,{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.DwpFFa5D.js";import{s as r}from"./plugins.BmKRnp4a.js";import{t as i}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.D5qXeML0.js";import{n as te,t as ne}from"./DocsPager.ceBEecmd.js";import{t as a}from"./SelectDropdown.Dmk5n225.js";import{A as re,D as ie,N as ae,P as oe,R as o,b as se,g as ce,h as le,i as ue,j as de,m as s,n as fe,p as pe,r as c,t as l,x as me,z as he}from"./pm.BXmOiFfW.js";import{A as ge,C as _e,D as ve,E as u,O as ye,S as be,_ as d,a as xe,c as Se,d as Ce,f,g as we,h as Te,j as Ee,k as p,l as De,m,n as Oe,p as ke,s as Ae,t as je,u as Me,y as h}from"./PmShared.86HEsdd_.js";import{n as Ne,r as Pe,t as Fe}from"./TableFieldConfig.D0v9S2g3.js";import{showToast as g}from"./Toast.BO2NFckG.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=i(),b=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`severity`,width:100,min:80},{key:`status`,width:120,min:96}],We={key:`project`,width:140,min:100},Ge=[{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}],Ke=new Set([`id`,`title`,`filler`,`action`]),qe=[{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`,...c],Qe=[`all`,...l],$e=`pm.bugs.project`,et=`pm.bugs.iteration`,tt=`pm.bugs.status`,nt=`pm.bugs.severity`,rt=`pm.bugs.keyword`,it=l.map(e=>({value:e,label:fe[e]})),at=c.map(e=>({value:e,label:ue[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=ge(`bugs`),{store:i,live:c,loading:l,error:x,setError:S,reload:C}=Ee(),[T,E]=p($e,`all`),D=e||T,[O,k]=p(et,`all`),[A,ct]=ye(tt,Ze,`all`),[j,lt]=ye(nt,Qe,`all`),[M,ut]=p(rt),[dt,N]=(0,v.useState)(1),[P,ft]=te(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)(()=>de(F?.attachment??``),[F?.attachment]),ht=(0,v.useMemo)(()=>t?qe:[{key:`project`,label:`所属项目`},...qe],[t]),K=Pe(Je,ht,Ke),gt=(0,v.useMemo)(()=>t?[...b,...Ge]:[...b,We,...Ge],[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:`全部项目`},...i.projects.map(e=>({value:e.id,label:e.name}))],[i.projects]),bt=(0,v.useMemo)(()=>[{value:`all`,label:`全部迭代`},...i.iterations.filter(e=>D===`all`||e.projectId===D).map(e=>({value:e.id,label:e.name}))],[i.iterations,D]),xt=(0,v.useMemo)(()=>{let e=new Map(i.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[i.projects]),St=(0,v.useMemo)(()=>{let e=new Map(i.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[i.iterations]),Y=(0,v.useMemo)(()=>ae(me(i.bugs,{projectId:D,iterationId:O,status:A,severity:j,keyword:M})),[i.bugs,D,O,A,j,M]),X=t?i.bugs.filter(e=>e.projectId===D).length:i.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||c===!0&&T!==`all`&&!i.projects.some(e=>e.id===T)&&E(`all`)},[c,i.projects,T,E,t]),(0,v.useEffect)(()=>{c===!0&&O!==`all`&&!i.iterations.some(e=>e.id===O&&(D===`all`||e.projectId===D))&&k(`all`)},[c,i.iterations,D,O,k]);let Tt=F?oe(i.iterations.filter(e=>e.projectId===F.projectId)):[],Et=F?i.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=pe(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 o(`bugs`,F.id,n):await le(`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 he(Array.from(e));I(e=>{if(!e)return e;let n=de(e.attachment);return{...e,attachment:re([...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=se(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=re(G.filter(t=>t.url!==e));if(F.id)try{await o(`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}),s([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&&s(e)}return}let e=[...V.current,...G.map(e=>e.url)];V.current.clear(),I(null),e.length&&s(e)}function $(){I(st(D===`all`?``:D))}async function jt(e,t){R(!0);try{await o(`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 ce(`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)(we,{label:`正在读取插件开关`});if(!n.on)return(0,y.jsx)(d,{children:r(`bugs`)});if(c===null)return(0,y.jsx)(we,{label:`正在连接项目管理服务`});if(!c)return(0,y.jsx)(d,{children:`缺陷管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(i.projects.length===0&&!l&&!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)(a,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选缺陷`,className:`w-36`,options:yt,value:T,onChange:e=>{E(e),k(`all`),N(1)}}),(0,y.jsx)(a,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选缺陷`,className:`w-32`,options:bt,value:O,onChange:e=>{k(e),N(1)}}),(0,y.jsx)(a,{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-[#3370ff]`})]}),(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-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] 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)(ke,{ariaLabel:`按状态筛选缺陷`,options:Nt,value:A,onChange:e=>{ct(e),N(1)}})}),x?(0,y.jsx)(Ce,{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:[l&&!i.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)(De,{children:`没有符合筛选条件的缺陷。`}):(0,y.jsx)(Me,{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)(_e,{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)(be,{tone:je[e.severity],children:fe[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)(a,{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)(Ae,{tone:Oe[e.value]}),renderTrigger:()=>(0,y.jsx)(be,{tone:Oe[e.status],children:ue[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:ve(e.projectId),className:`block truncate transition-colors hover:text-[#3370ff]`,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)(ne,{page:Z,totalPages:Ct,pageSize:P,busy:L,onPage:N,onPageSize:e=>{ft(e),N(1)}}):null]}),(0,y.jsx)(Se,{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:i.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:xe})}),(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)(Ae,{tone:je[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=ie(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-[#3370ff]`,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-[#3370ff]`,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:xe})}),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(i.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(i.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)(Te,{file:mt,onClose:()=>W(null)})]})}export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.BmKRnp4a.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.D5qXeML0.js";import{t as a}from"./DatePicker.Bkl71M49.js";import{t as o}from"./SelectDropdown.Dmk5n225.js";import{L as s,O as ee,P as te,R as c,S as l,a as u,g as ne,h as re,k as ie,o as d}from"./pm.BXmOiFfW.js";import{A as ae,D as oe,O as se,S as f,_ as p,a as ce,c as le,d as ue,f as m,g as h,i as g,j as _,k as v,l as de,m as y,r as b,s as fe,u as pe,v as x,y as S}from"./PmShared.86HEsdd_.js";import{showToast as C}from"./Toast.BO2NFckG.js";var w=e(t(),1),T=r(),E=10,me=[`all`,...u],he=`pm.iterations.project`,ge=`pm.iterations.status`,_e=`pm.iterations.keyword`,D=u.map(e=>({value:e,label:d[e]}));function O(e=``){return{projectId:e,name:``,startDate:``,endDate:``,status:`planning`,remark:``}}function k({scopeProjectId:e=``}={}){let t=!!e,r=ae(`iterations`),{store:u,live:k,loading:A,error:j,setError:M,reload:N}=_(),[P,F]=v(he,`all`),I=e||P,[L,ve]=se(ge,me,`all`),[R,ye]=v(_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=s(),q=(0,w.useMemo)(()=>{let e=new Map(u.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`未关联项目`},[u.projects]),xe=(0,w.useMemo)(()=>[{value:`all`,label:`全部项目`},...u.projects.map(e=>({value:e.id,label:e.name}))],[u.projects]),J=(0,w.useMemo)(()=>te(l(u.iterations,{projectId:I,status:L,keyword:R})),[u.iterations,I,L,R]),Y=t?u.iterations.filter(e=>e.projectId===I).length:u.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`&&!u.projects.some(e=>e.id===P)&&F(`all`)},[k,u.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 c(`iterations`,B.id,t):await re(`iterations`,[t]),V(null),M(``),await N(!0),C(B.id?`已保存迭代`:`已新建迭代`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),C(`保存迭代失败:${t}`,`error`)}finally{U(!1)}}}async function $(e,t){U(!0);try{await c(`iterations`,e.id,{status:t}),await N(!0),C(`已更新迭代状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),C(`更新迭代失败:${t}`,`error`)}finally{U(!1)}}async function Ce(){let e=W;if(e){G(null),U(!0);try{await ne(`iterations`,[e.id]),await N(!0),C(`已删除迭代`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),C(`删除迭代失败:${t}`,`error`)}finally{U(!1)}}}return r.ready?r.on?k===null?(0,T.jsx)(h,{label:`正在连接项目管理服务`}):k?u.projects.length===0&&!A&&!t?(0,T.jsx)(p,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护迭代。`}):(0,T.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-600`,children:Y}),` 个迭代`,J.length===Y?``:` · 筛选出 ${J.length} 个`]}),(0,T.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,T.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选迭代`,className:`w-36`,options:xe,value:P,onChange:e=>{F(e),z(1)}}),(0,T.jsx)(o,{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)(y,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,T.jsx)(`input`,{value: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-[#3370ff]`})]}),(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-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`plus`,size:14}),`新建迭代`]})]})]}),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&&!u.iterations.length?(0,T.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):Q.length===0?Y?(0,T.jsx)(de,{children:`没有符合筛选条件的迭代。`}):(0,T.jsx)(pe,{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)(y,{name:`plus`,size:13}),`新建迭代`]})}):(0,T.jsx)(`div`,{className:`space-y-3`,children:Q.map(e=>{let n=ie(e,K),r=ee(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)(f,{tone:b[e.status],children:d[e.status]})]}),(0,T.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-stone-500`,children:[t?null:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`a`,{href:oe(e.projectId),className:`transition-colors hover:text-[#3370ff]`,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)(y,{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)(y,{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)(y,{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)(y,{name:`trash`,size:15})})]})]}),(0,T.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,T.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,T.jsx)(`div`,{className:`h-full rounded-full bg-[#3370ff] transition-[width] duration-300`,style:{width:`${n}%`}})}),(0,T.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs tabular-nums text-stone-500`,children:[n,`%`]})]})]},e.id)})})}),J.length>0?(0,T.jsx)(x,{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)(m,{label:`所属项目`,required:!0,children:(0,T.jsx)(S,{ariaLabel:`所属项目`,options:u.projects.map(e=>({value:e.id,label:e.name})),value:B.projectId,onChange:e=>V({...B,projectId:e}),disabled:u.projects.length===0})}),(0,T.jsx)(m,{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:g})}),(0,T.jsx)(m,{label:`开始日期`,children:(0,T.jsx)(a,{value:B.startDate,onChange:e=>V({...B,startDate:e}),placeholder:`选择开始日期`,className:`${g} tabular-nums`})}),(0,T.jsx)(m,{label:`截止日期`,children:(0,T.jsx)(a,{value:B.endDate,onChange:e=>V({...B,endDate:e}),placeholder:`选择截止日期`,className:`${g} tabular-nums`})}),(0,T.jsx)(m,{label:`状态`,children:(0,T.jsx)(S,{ariaLabel:`迭代状态`,options:D,value:B.status,onChange:e=>V({...B,status:e}),renderOptionPrefix:e=>(0,T.jsx)(fe,{tone:b[e.value]})})}),(0,T.jsx)(m,{label:`备注`,children:(0,T.jsx)(`textarea`,{value:B.remark,onChange:e=>V({...B,remark:e.target.value}),placeholder:`迭代目标、范围等(可选)`,rows:3,className:ce})})]}):null}),(0,T.jsx)(i,{open:W!==null,title:`删除迭代`,message:`确定删除「${W?.name??``}」?关联的需求与缺陷会保留,但不再关联到这个迭代。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>G(null),onConfirm:()=>void Ce()})]}):(0,T.jsx)(p,{children:`迭代管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(p,{children:n(`iterations`)}):(0,T.jsx)(h,{label:`正在读取插件开关`})}export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.BmKRnp4a.js";import{t as r}from"./jsx-runtime.DUg_B_vD.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.86HEsdd_.js";import _ from"./PmBugsBoard.BynUocbE.js";import v from"./PmIterationsBoard.CvFblvfX.js";import{t as y}from"./PmRequirementsBoard.piRWjiYA.js";var b=e(t(),1),x=r(),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:n(`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{s as n}from"./plugins.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.BmKRnp4a.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.D5qXeML0.js";import{t as te}from"./SelectDropdown.Dmk5n225.js";import{C as i,M as a,R as o,c as s,g as ne,h as re,s as c}from"./pm.BXmOiFfW.js";import{A as ie,D as ae,O as l,S as u,_ as d,a as f,c as p,d as m,f as h,g,i as _,j as v,k as y,l as b,m as x,o as S,s as oe,u as se,v as ce,y as le}from"./PmShared.86HEsdd_.js";import{showToast as C}from"./Toast.BO2NFckG.js";var w=e(t(),1),T=r(),E=10,D=c.map(e=>({value:e,label:s[e]})),O=[`all`,...c],k=`pm.projects.status`,A=`pm.projects.keyword`;function j(){return{name:``,description:``,status:`planning`}}function M(){let e=ie(`projects`),{store:t,live:r,loading:c,error:M,setError:N,reload:P}=v(),[F,I]=l(k,O,`all`),[L,R]=y(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)(()=>a(t),[t]),X=(0,w.useMemo)(()=>i(t.projects,{status:F,keyword:L}),[t.projects,F,L]),Z=Math.max(1,Math.ceil(X.length/E)),Q=Math.min(z,Z),$=X.slice((Q-1)*E,Q*E);(0,w.useEffect)(()=>{if(!q)return;function e(e){Y.current?.contains(e.target)||J(null)}function t(e){e.key===`Escape`&&J(null)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[q]);async function de(){if(!V)return;let e=V.name.trim();if(!e)N(`项目名称不能为空`);else{W(!0);try{V.id?await o(`projects`,V.id,{name:e,description:V.description,status:V.status}):await 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 o(`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?r===null?(0,T.jsx)(g,{label:`正在连接项目管理服务`}):r?(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)(te,{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)(x,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,T.jsx)(`input`,{value:L,onChange:e=>{R(e.target.value),B(1)},placeholder:`搜索项目名称 / 描述…`,className:`h-9 w-52 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>H(j()),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,T.jsx)(x,{name:`plus`,size:14}),`新建项目`]})]})]}),M?(0,T.jsx)(m,{message:M,onClose:()=>N(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pt-1 pb-4`,children:c&&!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)(b,{children:`没有符合筛选条件的项目。`}):(0,T.jsx)(se,{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)(x,{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:ae(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)(u,{tone:S[e.status],children:s[e.status]})]}),(0,T.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-[40px] text-sm ${e.description?`text-stone-500`:`italic text-stone-300`}`,children:e.description||`暂无描述`}),(0,T.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-xs text-stone-500`,children:[(0,T.jsxs)(`span`,{children:[t?.iterations??0,` 迭代`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.requirements??0,` 需求`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.bugs??0,` 缺陷`]})]}),(0,T.jsxs)(`div`,{className:`mt-auto flex items-center justify-between pt-4`,children:[(0,T.jsxs)(`div`,{className:`pointer-events-auto relative`,ref:q===e.id?Y:void 0,children:[(0,T.jsx)(`button`,{type:`button`,"aria-label":`${e.name} 的操作`,"aria-haspopup":`menu`,"aria-expanded":q===e.id,onClick:()=>J(q===e.id?null:e.id),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,children:(0,T.jsx)(x,{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)(x,{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)(x,{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)(x,{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)(x,{name:`chevronRight`,size:14,className:`tw-pm-card-chevron text-stone-300`})]})]})]})]},e.id)})})}),X.length>0?(0,T.jsx)(ce,{page:Q,totalPages:Z,busy:U,onPage:B}):null,(0,T.jsx)(p,{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)(h,{label:`项目名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),placeholder:`输入项目名称`,className:_})}),(0,T.jsx)(h,{label:`描述`,children:(0,T.jsx)(`textarea`,{value:V.description,onChange:e=>H({...V,description:e.target.value}),placeholder:`项目描述(可选)`,rows:4,className:f})}),(0,T.jsx)(h,{label:`状态`,children:(0,T.jsx)(le,{ariaLabel:`项目状态`,options:D,value:V.status,onChange:e=>H({...V,status:e}),renderOptionPrefix:e=>(0,T.jsx)(oe,{tone:S[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)(d,{children:`项目列表需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(d,{children:n(`projects`)}):(0,T.jsx)(g,{label:`正在读取插件开关`})}export{M as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{t as default}from"./PmRequirementsBoard.piRWjiYA.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.C0NrHGZv.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.D5qXeML0.js";import{n as a,t as ee}from"./DocsPager.D0TMvJ67.js";import{t as o}from"./SelectDropdown.Dmk5n225.js";import{A as s,D as c,F as l,P as u,R as d,b as f,d as p,f as m,g as te,h,j as g,l as _,m as ne,u as v,w as re,z as y}from"./pm.BXmOiFfW.js";import{A as ie,C as ae,D as oe,E as b,O as se,S as ce,T as x,_ as S,a as le,c as ue,d as de,f as C,g as fe,h as w,j as pe,k as T,l as me,m as E,p as he,s as D,u as ge,w as _e,y as O}from"./PmShared.D6iq_Z9g.js";import{n as ve,r as ye,t as be}from"./TableFieldConfig.C_NeWm8L.js";import{showToast as k}from"./Toast.BO2NFckG.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=r();function ke({value:e,onChange:t,entity:n,recordId:r=``,seenUrls:i,onError:a,onPersisted:ee}){let o=g(e),[l,u]=(0,j.useState)(!1),[p,m]=(0,j.useState)(!1),[te,h]=(0,j.useState)(null),_=(0,j.useRef)(null);(0,j.useEffect)(()=>{for(let t of g(e))i.current.add(t.url)},[e,i]);let v=(0,j.useCallback)(async n=>{if(n&&n.length){u(!0);try{let r=await y(Array.from(n));t(s([...g(e),...r])),a(``)}catch(e){a(e instanceof Error?e.message:String(e))}finally{u(!1),_.current&&(_.current.value=``)}}},[t,a,e]);(0,j.useEffect)(()=>{let e=e=>{let t=f(e.clipboardData);t.length&&(e.preventDefault(),v(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[v]);async function re(e){let i=s(o.filter(t=>t.url!==e));if(r)try{await d(n,r,{attachment:i}),ee?.()}catch(e){a(e instanceof Error?e.message:String(e));return}t(i),ne([e],r)}return(0,M.jsxs)(`div`,{className:`space-y-2 rounded-lg transition-colors ${p?`bg-[#3370ff]/5 ring-1 ring-[#3370ff]/40`:``}`,onDragOver:e=>{e.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:e=>{e.preventDefault(),m(!1),v(e.dataTransfer?.files??null)},children:[o.length?(0,M.jsx)(`ul`,{className:`space-y-1.5`,children:o.map(e=>(0,M.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[c(e.url)?(0,M.jsx)(`button`,{type:`button`,onClick:()=>h(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})}),c(e.url)?(0,M.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#3370ff]`,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-[#3370ff]`,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:_,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void v(e.target.files)}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>_.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:l?`file`:`plus`,size:13}),l?`上传中…`:`上传文件 / 图片`]}),(0,M.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可拖拽到这里,或直接粘贴截图(⌘V / Ctrl+V),支持多张`})]}),(0,M.jsx)(w,{file:te,onClose:()=>h(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`,...p],ze=[`all`,..._],Be=`pm.requirements.project`,Ve=`pm.requirements.iteration`,He=`pm.requirements.status`,Ue=`pm.requirements.priority`,We=`pm.requirements.keyword`,Ge=_.map(e=>({value:e,label:v[e]})),N=p.map(e=>({value:e,label:m[e]}));function Ke(e=``){return{projectId:e,iterationId:``,title:``,priority:`medium`,status:`pending`,description:``,acceptanceCriteria:[],githubIssue:``,attachment:``}}function P({scopeProjectId:e=``}={}){let t=!!e,r=ie(`pmRequirements`),{store:s,live:c,loading:f,error:p,setError:_,reload:y}=pe(),[w,P]=T(Be,`all`),F=e||w,[I,L]=T(Ve,`all`),[R,qe]=se(He,Re,`all`),[z,Je]=se(Ue,ze,`all`),[B,Ye]=T(We),[Xe,V]=(0,j.useState)(1),[H,Ze]=a(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:`全部项目`},...s.projects.map(e=>({value:e.id,label:e.name}))],[s.projects]),rt=(0,j.useMemo)(()=>[{value:`all`,label:`全部迭代`},...u(s.iterations.filter(e=>F===`all`||e.projectId===F)).map(e=>({value:e.id,label:e.name}))],[s.iterations,F]),it=(0,j.useMemo)(()=>{let e=new Map(s.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[s.projects]),at=(0,j.useMemo)(()=>{let e=new Map(s.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[s.iterations]),$=(0,j.useMemo)(()=>l(re(s.requirements,{projectId:F,iterationId:I,status:R,priority:z,keyword:B})),[s.requirements,F,I,R,z,B]),ot=t?s.requirements.filter(e=>e.projectId===F).length:s.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||c===!0&&w!==`all`&&!s.projects.some(e=>e.id===w)&&P(`all`)},[c,s.projects,w,P,t]),(0,j.useEffect)(()=>{c===!0&&I!==`all`&&!s.iterations.some(e=>e.id===I&&(F===`all`||e.projectId===F))&&L(`all`)},[c,s.iterations,F,I,L]);let ut=U?u(s.iterations.filter(e=>e.projectId===U.projectId)):[];async function dt(){if(!U)return;if(!U.projectId){_(`请先选择所属项目`);return}let e=U.title.trim();if(!e)_(`需求描述不能为空`);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 d(`requirements`,U.id,t):await h(`requirements`,[t]);let n=!!U.id;W(null),Y.current.clear(),_(``),await y(!0),k(n?`已保存需求`:`已新建需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),k(`保存需求失败:${t}`,`error`)}finally{K(!1)}}}function ft(){let e=[...Y.current,...g(U?.attachment??``).map(e=>e.url)];Y.current.clear(),W(null),e.length&&ne(e)}async function pt(e,t){K(!0);try{await d(`requirements`,e.id,{status:t}),await y(!0),k(`已更新需求状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),k(`更新状态失败:${t}`,`error`)}finally{K(!1)}}async function mt(){let e=q;if(e){J(null),K(!0);try{await te(`requirements`,[e.id]),await y(!0),k(`已删除需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),k(`删除需求失败:${t}`,`error`)}finally{K(!1)}}}if(!r.ready)return(0,M.jsx)(fe,{label:`正在读取插件开关`});if(!r.on)return(0,M.jsx)(S,{children:n(`pmRequirements`)});if(c===null)return(0,M.jsx)(fe,{label:`正在连接项目管理服务`});if(!c)return(0,M.jsx)(S,{children:`需求管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(s.projects.length===0&&!f&&!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)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选需求`,className:`w-36`,options:nt,value:w,onChange:e=>{P(e),L(`all`),V(1)}}),(0,M.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选需求`,className:`w-32`,options:rt,value:I,onChange:e=>{L(e),V(1)}}),(0,M.jsx)(o,{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-[#3370ff]`})]}),(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-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] 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)(he,{ariaLabel:`按状态筛选需求`,options:ht,value:R,onChange:e=>{qe(e),V(1)}})}),p?(0,M.jsx)(de,{message:p,onClose:()=>_(``)}):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:[f&&!s.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)(me,{children:`没有符合筛选条件的需求。`}):(0,M.jsx)(ge,{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)(ae,{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)(ce,{tone:_e[e.priority],children:v[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)(o,{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)(ce,{tone:x[e.status],children:m[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:oe(e.projectId),className:`block truncate transition-colors hover:text-[#3370ff]`,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)(ee,{page:ct,totalPages:st,pageSize:H,busy:G,onPage:V,onPageSize:e=>{Ze(e),V(1)}}):null]}),(0,M.jsx)(ue,{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:s.projects.map(e=>({value:e.id,label:e.name})),value:U.projectId,onChange:e=>{let t=s.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:le})}),(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:_e[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:_,onPersisted:()=>void y(!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:le})}),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(s.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(s.requirements.find(e=>e.id===U.id)?.updatedAt)})})]}):null]}):null}),(0,M.jsx)(i,{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{s as n}from"./plugins.BmKRnp4a.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.D5qXeML0.js";import{n as a,t as ee}from"./DocsPager.ceBEecmd.js";import{t as o}from"./SelectDropdown.Dmk5n225.js";import{A as s,D as c,F as l,P as u,R as d,b as f,d as p,f as m,g as te,h,j as g,l as _,m as ne,u as v,w as re,z as y}from"./pm.BXmOiFfW.js";import{A as ie,C as ae,D as oe,E as b,O as se,S as ce,T as x,_ as S,a as le,c as ue,d as de,f as C,g as fe,h as w,j as pe,k as T,l as me,m as E,p as he,s as D,u as ge,w as _e,y as O}from"./PmShared.86HEsdd_.js";import{n as ve,r as ye,t as be}from"./TableFieldConfig.D0v9S2g3.js";import{showToast as k}from"./Toast.BO2NFckG.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=r();function ke({value:e,onChange:t,entity:n,recordId:r=``,seenUrls:i,onError:a,onPersisted:ee}){let o=g(e),[l,u]=(0,j.useState)(!1),[p,m]=(0,j.useState)(!1),[te,h]=(0,j.useState)(null),_=(0,j.useRef)(null);(0,j.useEffect)(()=>{for(let t of g(e))i.current.add(t.url)},[e,i]);let v=(0,j.useCallback)(async n=>{if(n&&n.length){u(!0);try{let r=await y(Array.from(n));t(s([...g(e),...r])),a(``)}catch(e){a(e instanceof Error?e.message:String(e))}finally{u(!1),_.current&&(_.current.value=``)}}},[t,a,e]);(0,j.useEffect)(()=>{let e=e=>{let t=f(e.clipboardData);t.length&&(e.preventDefault(),v(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[v]);async function re(e){let i=s(o.filter(t=>t.url!==e));if(r)try{await d(n,r,{attachment:i}),ee?.()}catch(e){a(e instanceof Error?e.message:String(e));return}t(i),ne([e],r)}return(0,M.jsxs)(`div`,{className:`space-y-2 rounded-lg transition-colors ${p?`bg-[#3370ff]/5 ring-1 ring-[#3370ff]/40`:``}`,onDragOver:e=>{e.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:e=>{e.preventDefault(),m(!1),v(e.dataTransfer?.files??null)},children:[o.length?(0,M.jsx)(`ul`,{className:`space-y-1.5`,children:o.map(e=>(0,M.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[c(e.url)?(0,M.jsx)(`button`,{type:`button`,onClick:()=>h(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})}),c(e.url)?(0,M.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#3370ff]`,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-[#3370ff]`,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:_,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void v(e.target.files)}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>_.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:l?`file`:`plus`,size:13}),l?`上传中…`:`上传文件 / 图片`]}),(0,M.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可拖拽到这里,或直接粘贴截图(⌘V / Ctrl+V),支持多张`})]}),(0,M.jsx)(w,{file:te,onClose:()=>h(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`,...p],ze=[`all`,..._],Be=`pm.requirements.project`,Ve=`pm.requirements.iteration`,He=`pm.requirements.status`,Ue=`pm.requirements.priority`,We=`pm.requirements.keyword`,Ge=_.map(e=>({value:e,label:v[e]})),N=p.map(e=>({value:e,label:m[e]}));function Ke(e=``){return{projectId:e,iterationId:``,title:``,priority:`medium`,status:`pending`,description:``,acceptanceCriteria:[],githubIssue:``,attachment:``}}function P({scopeProjectId:e=``}={}){let t=!!e,r=ie(`pmRequirements`),{store:s,live:c,loading:f,error:p,setError:_,reload:y}=pe(),[w,P]=T(Be,`all`),F=e||w,[I,L]=T(Ve,`all`),[R,qe]=se(He,Re,`all`),[z,Je]=se(Ue,ze,`all`),[B,Ye]=T(We),[Xe,V]=(0,j.useState)(1),[H,Ze]=a(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:`全部项目`},...s.projects.map(e=>({value:e.id,label:e.name}))],[s.projects]),rt=(0,j.useMemo)(()=>[{value:`all`,label:`全部迭代`},...u(s.iterations.filter(e=>F===`all`||e.projectId===F)).map(e=>({value:e.id,label:e.name}))],[s.iterations,F]),it=(0,j.useMemo)(()=>{let e=new Map(s.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[s.projects]),at=(0,j.useMemo)(()=>{let e=new Map(s.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[s.iterations]),$=(0,j.useMemo)(()=>l(re(s.requirements,{projectId:F,iterationId:I,status:R,priority:z,keyword:B})),[s.requirements,F,I,R,z,B]),ot=t?s.requirements.filter(e=>e.projectId===F).length:s.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||c===!0&&w!==`all`&&!s.projects.some(e=>e.id===w)&&P(`all`)},[c,s.projects,w,P,t]),(0,j.useEffect)(()=>{c===!0&&I!==`all`&&!s.iterations.some(e=>e.id===I&&(F===`all`||e.projectId===F))&&L(`all`)},[c,s.iterations,F,I,L]);let ut=U?u(s.iterations.filter(e=>e.projectId===U.projectId)):[];async function dt(){if(!U)return;if(!U.projectId){_(`请先选择所属项目`);return}let e=U.title.trim();if(!e)_(`需求描述不能为空`);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 d(`requirements`,U.id,t):await h(`requirements`,[t]);let n=!!U.id;W(null),Y.current.clear(),_(``),await y(!0),k(n?`已保存需求`:`已新建需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),k(`保存需求失败:${t}`,`error`)}finally{K(!1)}}}function ft(){let e=[...Y.current,...g(U?.attachment??``).map(e=>e.url)];Y.current.clear(),W(null),e.length&&ne(e)}async function pt(e,t){K(!0);try{await d(`requirements`,e.id,{status:t}),await y(!0),k(`已更新需求状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),k(`更新状态失败:${t}`,`error`)}finally{K(!1)}}async function mt(){let e=q;if(e){J(null),K(!0);try{await te(`requirements`,[e.id]),await y(!0),k(`已删除需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),k(`删除需求失败:${t}`,`error`)}finally{K(!1)}}}if(!r.ready)return(0,M.jsx)(fe,{label:`正在读取插件开关`});if(!r.on)return(0,M.jsx)(S,{children:n(`pmRequirements`)});if(c===null)return(0,M.jsx)(fe,{label:`正在连接项目管理服务`});if(!c)return(0,M.jsx)(S,{children:`需求管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(s.projects.length===0&&!f&&!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)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选需求`,className:`w-36`,options:nt,value:w,onChange:e=>{P(e),L(`all`),V(1)}}),(0,M.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选需求`,className:`w-32`,options:rt,value:I,onChange:e=>{L(e),V(1)}}),(0,M.jsx)(o,{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-[#3370ff]`})]}),(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-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] 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)(he,{ariaLabel:`按状态筛选需求`,options:ht,value:R,onChange:e=>{qe(e),V(1)}})}),p?(0,M.jsx)(de,{message:p,onClose:()=>_(``)}):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:[f&&!s.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)(me,{children:`没有符合筛选条件的需求。`}):(0,M.jsx)(ge,{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)(ae,{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)(ce,{tone:_e[e.priority],children:v[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)(o,{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)(ce,{tone:x[e.status],children:m[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:oe(e.projectId),className:`block truncate transition-colors hover:text-[#3370ff]`,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)(ee,{page:ct,totalPages:st,pageSize:H,busy:G,onPage:V,onPageSize:e=>{Ze(e),V(1)}}):null]}),(0,M.jsx)(ue,{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:s.projects.map(e=>({value:e.id,label:e.name})),value:U.projectId,onChange:e=>{let t=s.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:le})}),(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:_e[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:_,onPersisted:()=>void y(!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:le})}),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(s.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(s.requirements.find(e=>e.id===U.id)?.updatedAt)})})]}):null]}):null}),(0,M.jsx)(i,{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{i as n}from"./app-config.C4rpn1Ix.js";import{i as r,o as i}from"./plugins.C0NrHGZv.js";import{n as a,o,r as s,s as c}from"./view-prefs.8MPl3A7e.js";import{t as l}from"./react-dom.DLW9pGCF.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./OverflowHint.pvo2Xc8R.js";import{t as f}from"./SelectDropdown.Dmk5n225.js";import{_ as p,v as m,y as h}from"./pm.BXmOiFfW.js";import{t as g}from"./SlideOverDrawer.C1IVOc_8.js";var _=e(t(),1),v=e(l(),1),y=u(),b=8e3;function x(e,t,n){let[r,i]=(0,_.useState)(()=>a(e,t,n));return[r,(0,_.useCallback)(t=>{i(t),o(e,t)},[e])]}function S(e,t=``){let[n,r]=(0,_.useState)(()=>s(e)||t);return[n,(0,_.useCallback)(n=>{r(n),c(e,n===t?``:n)},[e,t])]}function C(e){let[t,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(()=>r(e));return(0,_.useEffect)(()=>{let t=!0,o=i(()=>s(r(e)));return n().then(()=>{t&&(s(r(e)),a(!0))}),()=>{t=!1,o()}},[e]),{ready:t,on:o}}var w=(0,_.createContext)(null);function T(e){let[t,n]=(0,_.useState)(p),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(``),l=(0,_.useRef)(!0),u=(0,_.useCallback)(async(e=!1)=>{e||o(!0);try{let e=await h();return l.current?(n(e),i(!0),c(``),e):null}catch(e){return l.current&&c(e instanceof Error?e.message:String(e)),null}finally{l.current&&!e&&o(!1)}},[]);return(0,_.useEffect)(()=>{if(!e){o(!1);return}l.current=!0;let t=null;return(async()=>{let e=await m();l.current&&(e?(await u(),l.current&&(i(!0),t=window.setInterval(()=>void u(!0),b))):(i(!1),o(!1)))})(),()=>{l.current=!1,t!==null&&window.clearInterval(t)}},[e,u]),{store:t,live:r,loading:a,error:s,setError:c,reload:u}}function 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`},F={gray:`#a8a29e`,blue:`#3370ff`,amber:`#f59e0b`,yellow:`#eab308`,red:`#ef4444`,purple:`#8b5cf6`,green:`#22c55e`,muted:`#d6d3d1`};function I({tone:e}){return(0,y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:F[e]}})}function ee({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`]};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-[#3370ff] focus:bg-white placeholder:text-stone-400`,W=`min-h-[72px] w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`;function G(e){return(0,y.jsx)(f,{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] 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-[#3370ff] px-3 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:r})]}),children:o})}function Z({label:e,required:t,children:n}){return(0,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)(d,{text:e,className:`block min-w-0 truncate text-sm text-stone-800 group-hover/pm-title:text-[#3370ff]`});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,ee 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,I 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{i as n}from"./app-config.DwpFFa5D.js";import{i as r,o as i}from"./plugins.BmKRnp4a.js";import{n as a,o,r as s,s as c}from"./view-prefs.GnvelRDj.js";import{t as l}from"./react-dom.DLW9pGCF.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./OverflowHint.pvo2Xc8R.js";import{t as f}from"./SelectDropdown.Dmk5n225.js";import{_ as p,v as m,y as h}from"./pm.BXmOiFfW.js";import{t as g}from"./SlideOverDrawer.C1IVOc_8.js";var _=e(t(),1),v=e(l(),1),y=u(),b=8e3;function x(e,t,n){let[r,i]=(0,_.useState)(()=>a(e,t,n));return[r,(0,_.useCallback)(t=>{i(t),o(e,t)},[e])]}function S(e,t=``){let[n,r]=(0,_.useState)(()=>s(e)||t);return[n,(0,_.useCallback)(n=>{r(n),c(e,n===t?``:n)},[e,t])]}function C(e){let[t,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(()=>r(e));return(0,_.useEffect)(()=>{let t=!0,o=i(()=>s(r(e)));return n().then(()=>{t&&(s(r(e)),a(!0))}),()=>{t=!1,o()}},[e]),{ready:t,on:o}}var w=(0,_.createContext)(null);function T(e){let[t,n]=(0,_.useState)(p),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(``),l=(0,_.useRef)(!0),u=(0,_.useCallback)(async(e=!1)=>{e||o(!0);try{let e=await h();return l.current?(n(e),i(!0),c(``),e):null}catch(e){return l.current&&c(e instanceof Error?e.message:String(e)),null}finally{l.current&&!e&&o(!1)}},[]);return(0,_.useEffect)(()=>{if(!e){o(!1);return}l.current=!0;let t=null;return(async()=>{let e=await m();l.current&&(e?(await u(),l.current&&(i(!0),t=window.setInterval(()=>void u(!0),b))):(i(!1),o(!1)))})(),()=>{l.current=!1,t!==null&&window.clearInterval(t)}},[e,u]),{store:t,live:r,loading:a,error:s,setError:c,reload:u}}function 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`},F={gray:`#a8a29e`,blue:`#3370ff`,amber:`#f59e0b`,yellow:`#eab308`,red:`#ef4444`,purple:`#8b5cf6`,green:`#22c55e`,muted:`#d6d3d1`};function I({tone:e}){return(0,y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:F[e]}})}function ee({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`]};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-[#3370ff] focus:bg-white placeholder:text-stone-400`,W=`min-h-[72px] w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`;function G(e){return(0,y.jsx)(f,{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] 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-[#3370ff] px-3 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:r})]}),children:o})}function Z({label:e,required:t,children:n}){return(0,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)(d,{text:e,className:`block min-w-0 truncate text-sm text-stone-800 group-hover/pm-title:text-[#3370ff]`});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,ee 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,I as s,N as t,V as u,K as v,j as w,z as x,G as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,n as r,r as i,t as a}from"./dialog.DZHZCe_T.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./OverflowHint.pvo2Xc8R.js";var c=e(t(),1),l=o(),u=`bg-[var(--tw-surface-panel)] border-[var(--tw-border)]`,d=`text-[var(--tw-label-primary)]`,f=`text-[var(--tw-label-secondary)]`,p=`text-[var(--tw-label-tertiary)]`,m=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-[#4176e6] px-3 text-sm font-medium text-white transition-colors hover:bg-[#3566d0] disabled:cursor-not-allowed disabled:opacity-50`,h=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg border border-[var(--tw-border)] px-3 text-sm text-[var(--tw-label-secondary)] transition-colors hover:bg-[var(--tw-session-hover-bg)] disabled:cursor-not-allowed disabled:opacity-50`,g=`h-8 w-full rounded-lg border border-[var(--tw-border)] bg-[var(--tw-surface-panel)] px-2.5 text-sm text-[var(--tw-label-primary)] outline-none transition-colors placeholder:text-[var(--tw-label-tertiary)] focus:border-[#4176e6]`;function _({open:e,prompts:t,value:o,force:_=!1,onClose:v,onMount:y,onCreate:b,target:x=`项目`,createHint:S=`会按插件自带的模板生成(规划 / 探索 / 生成代码三段),之后可在「提示词管理」里改。`}){let[C,w]=(0,c.useState)(o),[T,E]=(0,c.useState)(``),[D,O]=(0,c.useState)(!1),[k,A]=(0,c.useState)(``),[j,M]=(0,c.useState)(!1),[N,P]=(0,c.useState)(``);(0,c.useEffect)(()=>{e&&(w(o),O(!1),A(``),M(!1),P(``),E(``))},[e,o]);let F=T.trim()?t.filter(e=>e.toLowerCase().includes(T.trim().toLowerCase())):t,I=e=>{w(e),M(!1),P(``),A(``)},L=()=>{w(``),M(!0),P(`我的提示词.md`),A(``)},R=()=>{M(!1),P(``),A(``),w(o)},z=async()=>{if(!D&&C){O(!0),A(``);try{await y(C)}catch(e){A(e instanceof Error?e.message:String(e))}finally{O(!1)}}},B=async()=>{if(!b||D)return;let e=N.trim();if(!e)A(`先给新提示词起个文件名`);else{O(!0),A(``);try{await y(await b(e)),M(!1),P(``)}catch(e){A(e instanceof Error?e.message:String(e))}finally{O(!1)}}};return(0,l.jsxs)(i,{open:e,onClose:D?()=>void 0:v,className:`relative z-110`,children:[(0,l.jsx)(a,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,l.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,l.jsxs)(n,{transition:!0,className:`tw-dialog-panel-anim flex max-h-[min(80vh,620px)] w-full max-w-xl flex-col overflow-hidden rounded-xl border shadow-xl ${u}`,children:[(0,l.jsxs)(`div`,{className:`shrink-0 border-b border-[var(--tw-border)] px-5 py-4`,children:[(0,l.jsx)(r,{className:`text-base font-semibold ${d}`,children:_?`先挂载提示词`:`挂载提示词`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${f}`,children:_?`这个${x}还没有挂载提示词,选一份挂上才能开始生成;也可以先取消,稍后再挂。`:`一个${x}只挂一份提示词,换新的会立即取消上一份的引用`})]}),(0,l.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[t.length?(0,l.jsx)(`input`,{className:`${g} shrink-0`,value:T,onChange:e=>E(e.target.value),placeholder:`搜索提示词文件名`,"aria-label":`搜索提示词`,disabled:D}):null,t.length?(0,l.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto overscroll-contain rounded-lg border border-[var(--tw-border)] p-1`,children:[F.map(e=>{let t=C===e;return(0,l.jsxs)(`button`,{type:`button`,disabled:D,onClick:()=>I(e),"aria-pressed":t,className:`flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed ${t?`bg-(--tw-accent-soft) font-medium text-(--tw-accent)`:`text-[var(--tw-label-primary)] hover:bg-[var(--tw-session-hover-bg)]`}`,children:[(0,l.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-3 shrink-0 rounded-full border ${t?`border-[#4176e6] bg-[#4176e6] shadow-[inset_0_0_0_2px_var(--tw-surface-panel)]`:`border-[var(--tw-border)]`}`}),(0,l.jsx)(s,{text:e,className:`min-w-0 flex-1 truncate`})]},e)}),F.length?null:(0,l.jsxs)(`p`,{className:`px-2.5 py-6 text-center text-xs ${p}`,children:[`没有匹配「`,T.trim(),`」的提示词`]})]}):(0,l.jsx)(`p`,{className:`rounded-lg border border-dashed border-[var(--tw-border)] px-3 py-6 text-center text-xs ${p}`,children:`「提示词管理」里还没有可用的提示词,用下面的卡片新建一份再挂上。`}),b?j?(0,l.jsxs)(`div`,{className:`shrink-0 rounded-lg border border-[var(--tw-border)] p-3`,children:[(0,l.jsx)(`p`,{className:`text-xs font-medium ${d}`,children:`新建提示词并挂载`}),(0,l.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed ${f}`,children:S}),(0,l.jsx)(`input`,{className:`${g} mt-2`,value:N,autoFocus:!0,placeholder:`文件名,例如 我的登录流程.md`,"aria-label":`新提示词文件名`,onChange:e=>P(e.target.value),onKeyDown:e=>{e.key===`Enter`&&B()}})]}):(0,l.jsxs)(`button`,{type:`button`,disabled:D,onClick:L,className:`flex w-full shrink-0 items-center gap-3 rounded-lg border border-dashed border-[var(--tw-border)] px-3 py-3 text-left transition-colors hover:border-[#4176e6] hover:bg-[var(--tw-session-hover-bg)] disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,l.jsx)(`span`,{"aria-hidden":`true`,className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-(--tw-accent-soft) text-(--tw-accent)`,children:(0,l.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:(0,l.jsx)(`path`,{d:`M12 5v14M5 12h14`})})}),(0,l.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,l.jsx)(`span`,{className:`block text-sm font-medium ${d}`,children:`新建提示词并挂载`}),(0,l.jsx)(`span`,{className:`mt-0.5 block text-[11px] ${f}`,children:`按插件模板生成一份新的,建完直接挂到当前项目`})]})]}):null,k?(0,l.jsx)(`p`,{className:`mt-3 rounded-lg bg-red-50 px-3 py-2 text-[11px] leading-relaxed break-words text-red-600`,children:k}):null]}),(0,l.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-[var(--tw-border)] px-5 py-3`,children:[_&&!j?(0,l.jsx)(`span`,{className:`mr-auto text-[11px] ${p}`,children:`不挂载时生成会被拦下`}):null,j?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{type:`button`,className:h,onClick:R,disabled:D,children:`取消`}),(0,l.jsx)(`button`,{type:`button`,className:m,onClick:()=>void B(),disabled:D||!N.trim(),children:D?`创建中…`:`创建并挂载`})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{type:`button`,className:h,onClick:v,disabled:D,children:`取消`}),(0,l.jsx)(`button`,{type:`button`,className:m,onClick:()=>void z(),disabled:D||!C||!t.length,children:D?`保存中…`:`挂载`})]})]})]})})]})}export{_ as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.DwpFFa5D.js";import{a as i,i as a,n as o,o as s,s as c}from"./plugins.BmKRnp4a.js";import{t as l}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.D5qXeML0.js";import{m as u}from"./PmShared.86HEsdd_.js";import{showToast as d}from"./Toast.BO2NFckG.js";import{i as te}from"./case-types.B51yDRdf.js";import{c as f,d as p,h as ne,n as m,p as re,r as ie,u as ae,v as oe}from"./project-docs.CCjtiFjB.js";import{a as se,at as ce,c as le}from"./req-analysis.qmyv5cBw.js";import{n as ue}from"./doc-roots.CO3IBiY6.js";import{a as h,c as g,d as de,i as _,l as v,o as y,s as b,u as x}from"./prompts-meta.bF2q5SUy.js";import{i as fe,n as pe,r as me,t as he}from"./DocsFileBrowser.D66pN9rp.js";import{d as ge,t as _e}from"./open-docs-in-session.DJtuI1C4.js";import{F as ve,I as ye,i as be,r as xe}from"./case-review.TdDs1WFM.js";import{t as S}from"./NamePromptDialog.Csfnh5eM.js";import{i as Se}from"./report-prompt.B9C4cv84.js";import{g as Ce,s as we}from"./ui-auto.BmC9JJ_X.js";import{f as Te,s as Ee,t as De,y as Oe}from"./story-review.2UUlN3p-.js";import{o as ke,t as Ae}from"./test-reports.DPQ-FMsQ.js";var C=e(t(),1),w=`tw.prompts.mounted.v1`;function je(){try{let e=sessionStorage.getItem(r(w));if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t))typeof e==`string`&&typeof r==`string`&&(n[e]=r);return n}catch{return{}}}function Me(e){try{sessionStorage.setItem(r(w),JSON.stringify(e))}catch{}}var T=l(),Ne=10;async function E(e=`.`){let{entries:t}=await f(`prompts`,e),n=[];for(let e of t)e.type===`file`?n.push(e):n.push(...await E(e.path));return n}function Pe({path:e,enabled:t,mounted:n}){let r=x(e,n);if(!r)return(0,T.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`未关联`});if(r===`system`)return(0,T.jsx)(`span`,{className:`text-[11px] text-stone-600`,children:`系统默认`});let i=o(r)?.name??r,a=t[r]===!0,s=y(e,n);return(0,T.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,T.jsx)(`span`,{className:`truncate text-[11px] text-stone-600`,children:i}),s&&a?(0,T.jsx)(`span`,{className:`shrink-0 rounded bg-(--tw-accent-soft) px-1 text-[10px] text-(--tw-accent)`,children:`引用中`}):null]})}function D(){let e=me(`prompts`),[t,r]=(0,C.useState)(!1),[l,f]=(0,C.useState)(!0),[y,w]=(0,C.useState)(e?!0:null),[D,Fe]=(0,C.useState)(()=>e??[]),[O,k]=(0,C.useState)(null),[A,j]=(0,C.useState)(!1),[M,N]=(0,C.useState)({}),[P,F]=(0,C.useState)(null),[I,L]=(0,C.useState)(()=>i()),[R,Ie]=(0,C.useState)(()=>je()),[z,B]=(0,C.useState)(null),[V,H]=(0,C.useState)(null),[U,W]=(0,C.useState)(``),G=pe(D,Ne,`prompts`),K=(0,C.useRef)(!1),q=(0,C.useRef)(!1),J=(0,C.useRef)(!1),Le=(0,C.useRef)(!1),Re=(0,C.useRef)(!1),Y=(0,C.useCallback)(async()=>{k(null);try{let e=await E(`.`);Fe(e),fe(`prompts`,e)}catch(e){k(e instanceof Error?e.message:String(e))}},[]);(0,C.useEffect)(()=>{if(!y||I.reqAnalysis!==!0||K.current)return;let e=new Set(D.map(e=>e.name));e.has(`需求分析提示词.md`)&&e.has(`原文结构提示词.md`)||(K.current=!0,ce(!0).then(()=>Y()).catch(()=>void 0))},[y,I.reqAnalysis,D,Y]),(0,C.useEffect)(()=>{y&&I.storyReview===!0&&!q.current&&(D.some(e=>e.name===`用户故事审查提示词.md`)||(q.current=!0,Ee(!0).then(()=>Y()).catch(()=>void 0)))},[y,I.storyReview,D,Y]),(0,C.useEffect)(()=>{y&&I.testPoints===!0&&!J.current&&(D.some(e=>e.name===`测试点生成提示词.md`)||(J.current=!0,Oe(!0).then(()=>Y()).catch(()=>void 0)))},[y,I.testPoints,D,Y]),(0,C.useEffect)(()=>{y&&I.caseReview===!0&&!Le.current&&(D.some(e=>e.name===`用例质量评审提示词.md`)||(Le.current=!0,ye(!0).then(()=>Y()).catch(()=>void 0)))},[y,I.caseReview,D,Y]),(0,C.useEffect)(()=>{y&&I.caseBlindspot===!0&&!Re.current&&(D.some(e=>e.name===`场景遗漏补全提示词.md`)||(Re.current=!0,ve(!0).then(()=>Y()).catch(()=>void 0)))},[y,I.caseBlindspot,D,Y]),(0,C.useEffect)(()=>{let e=s(e=>{f(!!e.prompts),L(e)});return n().then(()=>{f(a(`prompts`)),L(i()),r(!0)}),e},[]),(0,C.useEffect)(()=>{t&&l&&(async()=>{await ie(`prompts`)?(await ge().catch(()=>null),await Y(),w(!0)):w(!1)})()},[t,l,Y]);let X=(0,C.useCallback)(async()=>{let e=await we(),t=a(`reports`),n=a(`testReports`),r=t?await Se().catch(()=>null):null;Ie(i=>{let a={};if(e)for(let t of e)a[g(t)]=`uiAuto`;else for(let[e,t]of Object.entries(i))t===`uiAuto`&&(a[e]=t);if(t){if(r?.promptFile)a[g(r.promptFile)]=`reports`;else for(let[e,t]of Object.entries(i))t===`reports`&&(a[e]=t)}if(n){let e=ke();for(let t of Ae){let n=(e[t.id]??t.defaultPrompt).trim();n&&(a[g(n)]=`testReports`)}}if(I.reqAnalysis&&(a[g(se)]=`reqAnalysis`,a[g(le)]=`reqAnalysis`),I.storyReview&&(a[g(De)]=`storyReview`),I.testPoints&&(a[g(Te)]=`testPoints`),I.caseReview&&(a[g(be)]=`caseReview`),I.caseBlindspot&&(a[g(xe)]=`caseBlindspot`),I.caseGen)for(let e of te()){let t=(e.promptPath??``).trim();t&&(a[g(t)]=`caseGen`)}return Me(a),a})},[I.reqAnalysis,I.storyReview,I.testPoints,I.caseReview,I.caseBlindspot,I.caseGen]);(0,C.useEffect)(()=>{if(!t||!l)return;X();let e=()=>{document.visibilityState===`visible`&&X()};document.addEventListener(`visibilitychange`,e);let n=Ce(()=>void X());return()=>{document.removeEventListener(`visibilitychange`,e),n()}},[t,l,I.uiAuto,I.reports,I.testReports,I.reqAnalysis,I.storyReview,I.testPoints,I.caseReview,I.caseBlindspot,I.caseGen,X]);let Z=(0,C.useMemo)(()=>Object.keys(M).filter(e=>M[e]),[M]),Q=(0,C.useCallback)(e=>{let t=x(e,R);return!t||t===`system`||de(e)?``:I[t]===!0?t:``},[R,I]);async function ze(e){j(!0),k(null);try{await ae(`prompts`,e.path)}catch(e){k(e instanceof Error?e.message:String(e))}finally{j(!1)}}async function Be(e){j(!0),k(null);try{await _e(`prompts`,e)}catch(e){k(e instanceof Error?e.message:String(e)),j(!1)}}function Ve(e){if(b(e.path)){k(`默认提示词不可删除`);return}if(_(e.path,I)){k(v(e.path,I));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;k(`这份提示词正被「${e}」的项目挂载,先在那里换一份再删除`)}else F({kind:`one`,entry:e})}function He(e){if(b(e.path)){k(`默认提示词不可改名`);return}if(_(e.path,I)){k(v(e.path,I));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;k(`这份提示词正被「${e}」的项目挂载,先在那里换一份再改名`)}else B(e),W(``)}function Ue(e){H(e),W(``)}async function We(){let e=P;if(e){F(null),j(!0),k(null);try{if(e.kind===`one`)await m(`prompts`,e.entry.path);else{let t=0;for(let n of e.paths)b(n)||_(n,I)||Q(n)?t+=1:await m(`prompts`,n);t&&k(`有 ${t} 个提示词仍被插件或项目引用,已跳过;先解除引用再删。`),N({})}await Y(),d(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个提示词`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);k(t),d(`删除失败:${t}`,`error`)}finally{j(!1)}}}function Ge(){a(`promptGen`)?window.location.href=`/workbench/?plugin=promptGen`:k(c(`promptGen`))}let $=(0,C.useCallback)((e,t,n=``)=>{let r=(e===`.`?t:`${e}/${t}`).toLowerCase(),i=D.find(e=>e.path.toLowerCase()===r&&e.path.toLowerCase()!==n.toLowerCase());return i?i.name:``},[D]);async function Ke(e){let t=z;if(!t)return;let n=e.trim();if(!n||n===t.name){B(null),W(``);return}let r=$(p(t.path),n,t.path);if(r)W(`已存在同名文件「${r}」,换个名字再试`);else{j(!0),W(``);try{await ne(`prompts`,t.path,n),B(null),await Y(),d(`已重命名为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);W(t),d(`重命名失败:${t}`,`error`)}finally{j(!1)}}}async function qe(e){let t=V;if(!t)return;let n=e.trim();if(!n)return;let r=$(p(t.path),n);if(r)W(`已存在同名文件「${r}」,换个名字再试`);else{j(!0),W(``);try{let{content:e}=await re(`prompts`,t.path);await oe(`prompts`,p(t.path)===`.`?n:`${p(t.path)}/${n}`,e),H(null),await Y(),d(`已复制为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);W(t),d(`复制失败:${t}`,`error`)}finally{j(!1)}}}let Je=P?.kind===`one`?`删除「${P.entry.name}」?将从 ${ue(`prompts`)} 中移除。`:P?.kind===`batch`?`确认删除已选中的 ${P.paths.length} 个提示词?此操作不可恢复。`:``;return t?l?y===null?(0,T.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,T.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):y?(0,T.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,T.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,T.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[G.query.trim()?(0,T.jsxs)(T.Fragment,{children:[`匹配 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-800`,children:G.filtered.length}),` 个`,(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,D.length]})]}):(0,T.jsxs)(T.Fragment,{children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-800`,children:D.length}),` 个提示词`]}),Z.length>0?(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,Z.length]}):null]}),(0,T.jsx)(`button`,{type:`button`,disabled:A||Z.length===0,onClick:()=>F({kind:`batch`,paths:Z}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,T.jsx)(`button`,{type:`button`,disabled:A,onClick:Ge,className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`生成提示词`})]}),O?(0,T.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:O}):null,(0,T.jsx)(he,{resizeKey:`docs:prompts:cols:v1`,files:D,filtered:G.filtered,pageFiles:G.pageFiles,query:G.query,onQuery:G.setQuery,sortBy:G.sortBy,onSortBy:G.setSortBy,page:G.page,totalPages:G.totalPages,pageSize:G.pageSize,onPage:G.setPage,onPageSize:G.setPageSize,busy:A,emptyText:`暂无提示词,点击「生成提示词」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selectable:e=>!h(e.path,I)&&!Q(e.path),selected:M,onToggleRow:e=>N(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>N(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void ze(e),extraColumn:{header:`关联插件`,render:e=>(0,T.jsx)(Pe,{path:e.path,enabled:I,mounted:R})},renderNameAction:e=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,disabled:A,"aria-label":`重命名 ${e.name}`,onClick:()=>He(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,T.jsx)(u,{name:`pencil`,size:12})}),(0,T.jsx)(`button`,{type:`button`,disabled:A,"aria-label":`复制 ${e.name}`,onClick:()=>Ue(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,T.jsx)(u,{name:`copy`,size:12})})]}),renderActions:e=>{let t=h(e.path,I)||!!Q(e.path);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>void Be(e),className:`cursor-pointer whitespace-nowrap rounded bg-[#4176e6] px-2 py-1 text-xs text-white hover:bg-[#3565c7] disabled:opacity-40`,children:`在会话中打开`}),(0,T.jsx)(`button`,{type:`button`,disabled:A||t,"aria-label":`删除 ${e.name}`,onClick:()=>Ve(e),className:`tw-icon-danger inline-flex h-6 w-6 items-center justify-center rounded`,children:(0,T.jsx)(u,{name:`trash`,size:12})})]})}}),(0,T.jsx)(S,{open:z!=null,title:`重命名提示词`,label:`文件名称`,initialValue:z?.name??``,lockExtension:!0,confirmLabel:`保存`,error:U,onClose:()=>{B(null),W(``)},onConfirm:e=>void Ke(e)}),(0,T.jsx)(S,{open:V!=null,title:`复制提示词`,label:`新文件名称`,initialValue:V?V.name.replace(/(\.[^.]+)?$/,e=>`(副本)${e}`):``,lockExtension:!0,confirmLabel:`复制`,error:U,onClose:()=>{H(null),W(``)},onConfirm:e=>void qe(e)}),(0,T.jsx)(ee,{open:P!=null,title:P?.kind===`batch`?`批量删除`:`删除提示词`,message:Je,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>F(null),onConfirm:()=>void We()})]}):(0,T.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`提示词管理需要本地文档服务,当前未就绪。`}):(0,T.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:c(`prompts`)}):(0,T.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,T.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{D as default};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.DwpFFa5D.js";import{i,o as ee,s as te}from"./plugins.BmKRnp4a.js";import{t as a}from"./jsx-runtime.DUg_B_vD.js";import{t as ne}from"./ConfirmDialog.D5qXeML0.js";import{n as re,t as o}from"./DocsPager.ceBEecmd.js";import{t as ie}from"./OverflowHint.pvo2Xc8R.js";import{showToast as s}from"./Toast.BO2NFckG.js";import{v as ae}from"./project-docs.CCjtiFjB.js";import{a as oe,c,l as se,n as ce,o as le,s as ue,t as l}from"./report-prompt.B9C4cv84.js";import{t as de}from"./PromptMountDialog.DYojFMok.js";var u=e(t(),1),d=`tw.reports.kind.v1`,f=Object.keys(l);function p(e){return typeof e==`string`&&f.includes(e)}function fe(e=`day`){try{let t=localStorage.getItem(r(d));return p(t)?t:e}catch{return e}}function pe(e){if(p(e))try{localStorage.setItem(r(d),e)}catch{}}var m=a(),me=[`day`,`week`,`month`],he=20,ge=`tw.reports.page-size.v1`,_e=`# 工作汇报提示词
|
|
2
|
+
|
|
3
|
+
> 由「工作汇报」插件引用。日常增删改请只改本空间「提示词管理」里的本文件。
|
|
4
|
+
|
|
5
|
+
## 角色
|
|
6
|
+
|
|
7
|
+
(请在提示词管理中维护汇报角色说明。)
|
|
8
|
+
|
|
9
|
+
## 任务
|
|
10
|
+
|
|
11
|
+
(请在提示词管理中维护:按周期生成并落盘。)
|
|
12
|
+
|
|
13
|
+
## 限制
|
|
14
|
+
|
|
15
|
+
(请在提示词管理中维护限制条款。)
|
|
16
|
+
`;function h(e){return e.replace(/\.(md|markdown|txt|html?)$/i,``)}function g(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}/${n(t.getMonth()+1)}/${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function ve(e){return!Number.isFinite(e)||e<=0?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var ye={day:`日`,week:`周`,month:`月`};function be(e){let t=!!e.indeterminate&&!e.checked;return(0,m.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t?`mixed`:e.checked,"aria-label":e.label,disabled:e.disabled,onClick:t=>{t.stopPropagation(),!e.disabled&&e.onChange()},className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-[5px] border transition-colors disabled:opacity-40 ${e.checked||t?`border-[#3370ff] bg-[#3370ff] text-white`:`border-stone-300 bg-white text-transparent hover:border-[#3370ff]/70`}`,children:t?(0,m.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`10`,height:`10`,"aria-hidden":`true`,children:(0,m.jsx)(`path`,{d:`M3.5 8h9`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})}):(0,m.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`10`,height:`10`,"aria-hidden":`true`,children:(0,m.jsx)(`path`,{d:`m3.5 8.2 2.8 2.8 6.2-6.4`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})})}function _(){let[e,t]=(0,u.useState)(!1),[r,a]=(0,u.useState)(!0),[d,f]=(0,u.useState)(()=>fe()),p=(0,u.useRef)(d),[_,v]=(0,u.useState)([]),[y,b]=(0,u.useState)(``),[x,S]=(0,u.useState)(!1),[C,w]=(0,u.useState)(null),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)([]),[k,A]=(0,u.useState)(``),[xe,j]=(0,u.useState)(!1),[M,N]=(0,u.useState)(!1),[Se,P]=(0,u.useState)(1),[F,Ce]=re(he,ge),[I,L]=(0,u.useState)({}),[R,z]=(0,u.useState)(null),[B,V]=(0,u.useState)(!1),H=(0,u.useCallback)(async(e,t)=>{S(!0),w(null);try{if(t?.ensure)try{await se(!0)}catch{}let n=await le(e);v(n.items),b(n.dir)}catch(e){let t=e instanceof Error?e.message:String(e);w(t.includes(`404`)?`工作汇报需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`:t),v([])}finally{S(!1)}},[]);(0,u.useEffect)(()=>{let e=ee(e=>a(!!e.reports));return n().then(()=>{a(i(`reports`)),t(!0)}),e},[]);let U=(0,u.useCallback)(async()=>{try{let e=await oe();O(e.items),A(e.promptFile),e.promptFile||s(`没有读到「提示词管理」里的工作汇报提示词,写汇报前请先挂载一份。`,`error`)}catch(e){let t=e instanceof Error?e.message:String(e);s(`读取工作汇报提示词失败:${t}`,`error`)}},[]);(0,u.useEffect)(()=>{e&&r&&(async()=>{await H(p.current,{ensure:!0}),await U()})()},[e,r,H,U]);function we(e){pe(e),e!==d&&(f(e),P(1),L({}),v([]),H(e))}async function Te(e){if(e){j(!0),w(null);try{let t=await c(e);A(t),O(e=>e.map(e=>({...e,selected:e.name===t}))),N(!1)}catch(e){let t=e instanceof Error?e.message:String(e);throw w(t),s(`挂载提示词失败:${t}`,`error`),e}finally{j(!1)}}}async function Ee(e){let t=e.trim().replace(/[\\/]/g,``);if(!t)throw Error(`请填写提示词文件名`);/\.(md|markdown|txt)$/i.test(t)||(t=`${t}.md`),await ae(`prompts`,t,_e);let n=await c(t);return await U(),A(n),n}let De=(0,u.useMemo)(()=>D.map(e=>e.name),[D]),W=!k,G=(0,u.useMemo)(()=>[..._].sort((e,t)=>t.generatedAt-e.generatedAt),[_]),K=Math.max(1,Math.ceil(G.length/F)),q=Math.min(Se,K),J=(0,u.useMemo)(()=>G.slice((q-1)*F,q*F),[G,q,F]),Y=(0,u.useMemo)(()=>Object.keys(I).filter(e=>I[e]&&_.some(t=>t.name===e)),[I,_]),X=J.length>0&&J.every(e=>!!I[e.name]),Oe=J.some(e=>!!I[e.name])&&!X,ke=`/workbench/?report=${d}`;function Z(e){L(t=>{let n={...t};return n[e]?delete n[e]:n[e]=!0,n})}function Q(){L(e=>{let t={...e};if(X)for(let e of J)delete t[e.name];else for(let e of J)t[e.name]=!0;return t})}async function Ae(e){if(!(T||B)){E(e.name),w(null);try{await ue(e.kind,e.name)}catch(e){w(e instanceof Error?e.message:String(e))}finally{E(``)}}}async function je(){let e=R;if(e?.length){V(!0),w(null);try{let t=await ce(d,e);z(null),L(e=>{let n={...e};for(let e of t.deleted)delete n[e];return n}),s(t.deleted.length>1?`已删除 ${t.deleted.length} 篇${l[d]}`:`已删除「${h(t.deleted[0]||e[0]||``)}」`,`success`),t.missing.length&&s(`${t.missing.length} 篇未找到或已删除`,`error`),await H(d)}catch(e){let t=e instanceof Error?e.message:String(e);w(t),s(`删除失败:${t}`,`error`)}finally{V(!1)}}}if(!e)return(0,m.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex items-center justify-center min-h-[220px]`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!r)return(0,m.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:te(`reports`)});let $=G[0];return(0,m.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,m.jsxs)(`div`,{className:`shrink-0 border-b border-stone-100 px-4 py-3`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,m.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:me.map(e=>(0,m.jsx)(`button`,{type:`button`,onClick:()=>we(e),className:`h-8 rounded-md px-3 text-sm transition-colors ${d===e?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:l[e]},e))}),(0,m.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[_.length>0?(0,m.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-1.5 whitespace-nowrap text-sm text-stone-600`,children:[(0,m.jsx)(be,{checked:X,indeterminate:Oe,disabled:J.length===0||B,label:`全选本页汇报`,onChange:Q}),(0,m.jsx)(`button`,{type:`button`,disabled:J.length===0||B,onClick:()=>Q(),className:`disabled:opacity-40`,children:`全选本页`})]}):null,(0,m.jsxs)(`button`,{type:`button`,disabled:B||Y.length===0,onClick:()=>z(Y),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:[`批量删除`,Y.length?` (${Y.length})`:``]}),(0,m.jsx)(`button`,{type:`button`,disabled:xe,onClick:()=>N(!0),"aria-label":`挂载提示词`,className:`flex h-9 w-40 min-w-0 items-center rounded-lg border bg-white px-2.5 text-left transition-colors hover:border-stone-300 focus:border-[#4176e6] focus:outline-none focus-visible:ring-2 focus-visible:ring-[#4176e6]/30 disabled:opacity-40 ${W?`border-amber-300 text-amber-700`:`border-stone-200`}`,children:(0,m.jsx)(ie,{text:W?`未挂载提示词 · 点击挂载`:k,className:`min-w-0 flex-1 truncate text-sm ${W?`text-amber-700`:`text-stone-700`}`})}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{await H(d),await U()})(),disabled:x||B,"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800 disabled:opacity-40`,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,m.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,m.jsx)(`a`,{href:ke,className:`inline-flex h-9 items-center whitespace-nowrap rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9]`,children:`去工作台写汇报`})]})]}),(0,m.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-stone-400`,children:[(0,m.jsxs)(`span`,{children:[l[d],` · 共 `,_.length,` 篇`,Y.length?` · 已选 ${Y.length}`:``]}),$?(0,m.jsxs)(`span`,{className:`tabular-nums`,children:[`最近生成 `,g($.generatedAt)]}):null,(0,m.jsx)(`span`,{className:`min-w-0 truncate`,children:y||`—`}),(0,m.jsx)(`span`,{className:`ml-auto hidden shrink-0 sm:inline`,children:`单击选中 · 双击打开`})]})]}),C?(0,m.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,m.jsx)(`span`,{className:`min-w-0 flex-1`,children:C}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>w(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,m.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto bg-stone-50/60 p-3 sm:p-4`,children:x&&_.length===0?(0,m.jsx)(`div`,{className:`flex min-h-[180px] items-center justify-center`,"aria-busy":`true`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):_.length===0?(0,m.jsxs)(`div`,{className:`flex min-h-[260px] flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-stone-300 px-6 py-10 text-center`,children:[(0,m.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-xl bg-stone-100 text-stone-400`,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,m.jsx)(`path`,{d:`M14 3v5h5`}),(0,m.jsx)(`path`,{d:`M9 13h6M9 17h4`})]})}),(0,m.jsxs)(`div`,{className:`text-sm font-medium text-stone-700`,children:[`还没有`,l[d]]}),(0,m.jsxs)(`p`,{className:`max-w-md text-xs leading-5 text-stone-400`,children:[`保存到 `,y||`工作汇报/${l[d]}`,` 后会自动出现在这里。`]})]}):(0,m.jsx)(`ul`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,380px),1fr))] gap-2.5`,children:J.map(e=>{let t=!!I[e.name],n=!!T||B,r=t||Y.length>0,i=!r||t;return(0,m.jsx)(`li`,{children:(0,m.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-pressed":t,"aria-label":`${t?`取消选中`:`选中`} ${h(e.name)},双击打开`,onClick:()=>{n||Z(e.name)},onDoubleClick:t=>{t.preventDefault(),!n&&Ae(e)},onKeyDown:t=>{n||(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),Z(e.name))},className:`group relative flex w-full cursor-pointer items-center gap-3 overflow-hidden rounded-xl border bg-white px-3.5 py-3 text-left transition-colors select-none ${t?`border-[#3370ff] shadow-[0_0_0_1px_rgba(51,112,255,0.12)]`:i?`border-stone-200 hover:border-[#3370ff]/45`:`border-stone-200`} ${n?`opacity-60`:``}`,children:[(0,m.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-0 bg-[#3370ff]/[0.07] transition-opacity ${t?`opacity-100`:`opacity-0`}`}),(0,m.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t,"aria-label":`选择 ${h(e.name)}`,disabled:B,onClick:t=>{t.stopPropagation(),B||Z(e.name)},className:`absolute left-0 top-0 z-10 h-[22px] w-[22px] disabled:opacity-40 ${t||r?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,children:[(0,m.jsxs)(`svg`,{viewBox:`0 0 22 22`,className:`absolute inset-0 h-full w-full`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M0 0h22L0 22z`,fill:`#3370ff`}),t?null:(0,m.jsx)(`path`,{d:`M0 0h22L0 22z`,fill:`#fff`,fillOpacity:.45})]}),(0,m.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`9`,height:`9`,className:`absolute left-[3px] top-[3px] text-white ${t?`opacity-100`:`opacity-70`}`,"aria-hidden":`true`,children:(0,m.jsx)(`path`,{d:`m3.4 8 2.8 2.8 6.2-6.4`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,m.jsx)(`span`,{className:`relative z-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-stone-100 text-[13px] font-semibold text-stone-600`,children:ye[e.kind]}),(0,m.jsxs)(`span`,{className:`relative z-1 min-w-0 flex-1`,children:[(0,m.jsx)(`span`,{className:`block truncate text-sm font-medium text-stone-800 transition-colors ${i?`group-hover:text-[#3370ff]`:``}`,children:h(e.name)}),(0,m.jsxs)(`span`,{className:`mt-0.5 block truncate text-xs text-stone-400 tabular-nums`,children:[g(e.generatedAt),` · `,ve(e.size),T===e.name?` · 打开中…`:``]})]}),(0,m.jsx)(`button`,{type:`button`,"aria-label":`删除 ${h(e.name)}`,disabled:B,onClick:t=>{t.stopPropagation(),z([e.name])},className:`relative z-1 flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:opacity-40`,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`15`,height:`15`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M3 6h18`}),(0,m.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,m.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,m.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})},e.name)})})}),_.length>0?(0,m.jsx)(o,{page:q,totalPages:K,pageSize:F,busy:x||B,onPage:P,onPageSize:e=>{Ce(e),P(1)}}):(0,m.jsx)(`div`,{className:`pb-2.5`}),(0,m.jsx)(ne,{open:R!=null,title:R&&R.length>1?`批量删除`:`删除汇报`,message:R&&R.length>1?`确认删除已选中的 ${R.length} 篇${l[d]}?此操作不可恢复。`:`删除「${h(R?.[0]||``)}」?此操作不可恢复。`,confirmLabel:B?`删除中…`:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>{B||z(null)},onConfirm:()=>void je()}),(0,m.jsx)(de,{open:M,prompts:De,value:k,force:W,onClose:()=>N(!1),onMount:Te,onCreate:Ee,target:`工作汇报`,createHint:`会按工作汇报短种子生成一份,之后可在「提示词管理」里改。`})]})}export{_ as default};
|