lantern-harness 0.1.8 → 0.1.9
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 +24 -0
- package/README.md +2 -2
- package/cli/server.mjs +2 -0
- package/config/app.defaults.json +1 -0
- package/dist/500.html +3 -3
- package/dist/_astro/Base.4X_wsSoR.css +1 -0
- package/dist/_astro/Base.astro_astro_type_script_index_0_lang.Dy7fJoxu.js +1 -0
- package/dist/_astro/{CaseExecBoard.BAV4EE3o.js → CaseExecBoard.DKdfW5fM.js} +1 -1
- package/dist/_astro/{CaseGenerateApp.Bz4ryNJG.js → CaseGenerateApp.Bm8AyH9s.js} +1 -1
- package/dist/_astro/{CasesLibrary.BPifyHUA.js → CasesLibrary.CvVJZ74h.js} +1 -1
- package/dist/_astro/{ChatApp.DLo31SYZ.js → ChatApp.BS-wLBRa.js} +3 -3
- package/dist/_astro/{DashboardBoard.Bd3eUPwZ.js → DashboardBoard.DCtfrrJz.js} +1 -1
- package/dist/_astro/{DocsFileBrowser.D3cKurQE.js → DocsFileBrowser.BtRoZ787.js} +1 -1
- package/dist/_astro/{DocsPager.rzu4mnzw.js → DocsPager.C20ue_JZ.js} +1 -1
- package/dist/_astro/{KnowledgeLibrary.B0sO4QR1.js → KnowledgeLibrary.CV4DyStj.js} +1 -1
- package/dist/_astro/{NavLibraries.Cvg3wery.js → NavLibraries.DmD2lZBZ.js} +1 -1
- package/dist/_astro/PluginsPage.B59AMDrB.js +1 -0
- package/dist/_astro/{PluginsPage.DIltPILi.js → PluginsPage.BEAPymNL.js} +1 -1
- package/dist/_astro/PmBugsBoard.CPEyBp0l.js +1 -0
- package/dist/_astro/PmIterationsBoard.zCeLpcBo.js +1 -0
- package/dist/_astro/{PmProjectDetail.DqDoIg8a.js → PmProjectDetail.ejIam5sD.js} +1 -1
- package/dist/_astro/{PmProjectsBoard.nOC1Hugt.js → PmProjectsBoard.DbXzir8o.js} +1 -1
- package/dist/_astro/PmRequirementsBoard.CynewRfv.js +1 -0
- package/dist/_astro/PmRequirementsBoard.D9eUMJWI.js +1 -0
- package/dist/_astro/{PmShared.CZnXaUq-.js → PmShared.BxTHKdjY.js} +1 -1
- package/dist/_astro/{PromptsLibrary.DU9EuSim.js → PromptsLibrary.Bkruu80b.js} +1 -1
- package/dist/_astro/{ReportsPage.Cr88iz8c.js → ReportsPage.BoBQshMQ.js} +1 -1
- package/dist/_astro/{RequirementsLibrary.BwriF8F0.js → RequirementsLibrary.BC0A8qdk.js} +1 -1
- package/dist/_astro/{SearchableSelect.Ctg8V1Z1.js → SearchableSelect.CXa1hiDd.js} +1 -1
- package/dist/_astro/SettingsDialog.Dc-9QNJI.js +1 -0
- package/dist/_astro/{SpaceSwitcher.BEJo5KFi.js → SpaceSwitcher.CI3KDBOA.js} +1 -1
- package/dist/_astro/{TasksBoard.BZi_GBPG.js → TasksBoard.Bb--oVV8.js} +1 -1
- package/dist/_astro/{TemplatesLibrary.T4K9jUex.js → TemplatesLibrary.D1wZq94E.js} +1 -1
- package/dist/_astro/{TestStatsBoard.Dd1Kcmx6.js → TestStatsBoard.DlVezlXl.js} +1 -1
- package/dist/_astro/{TodosBoard.C4yd_JFb.js → TodosBoard.S84wqcWY.js} +1 -1
- package/dist/_astro/UiAutoBoard.BKp9ifxg.js +1 -0
- package/dist/_astro/app-config.DUyozIL9.js +1 -0
- package/dist/_astro/i18n.B52gLzii.js +7 -0
- package/dist/_astro/{open-docs-in-session.B0ZdZNj2.js → open-docs-in-session.Xg3OSOfc.js} +1 -1
- package/dist/_astro/{plugins.D5ypJIXn.js → plugins.BDZqJNOy.js} +1 -1
- package/dist/_astro/{pm.BsnTv63L.js → pm.Bl3hz9fF.js} +4 -4
- package/dist/_astro/{settings.CnDCvwnQ.js → settings.C6NWuiFO.js} +2 -2
- package/dist/_astro/{spaces-client.Cai2tHEI.js → spaces-client.k_ciWMai.js} +1 -1
- package/dist/_astro/update.Bl_HfSe6.js +1 -0
- package/dist/_astro/{view-prefs.HCowOWXL.js → view-prefs.Dyu_lmN2.js} +1 -1
- package/dist/case-exec/index.html +4 -4
- package/dist/cases/generate/index.html +4 -4
- package/dist/cases/library/index.html +4 -4
- package/dist/dashboard/index.html +4 -4
- package/dist/docs/changelog/index.html +26 -4
- package/dist/docs/install/index.html +3 -3
- package/dist/docs/manual/index.html +24 -6
- package/dist/index.html +4 -4
- package/dist/knowledge/index.html +4 -4
- package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +3 -3
- package/dist/plugins/index.html +4 -4
- package/dist/pm/bugs/index.html +4 -4
- package/dist/pm/iterations/index.html +4 -4
- package/dist/pm/projects/detail/index.html +4 -4
- package/dist/pm/projects/index.html +4 -4
- package/dist/pm/requirements/index.html +4 -4
- package/dist/prompts/index.html +4 -4
- package/dist/reports/index.html +4 -4
- package/dist/requirements/index.html +4 -4
- package/dist/tasks/index.html +4 -4
- package/dist/templates/index.html +4 -4
- package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +3 -3
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +3 -3
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +3 -3
- package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +3 -3
- package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +3 -3
- package/dist/test-stats/index.html +4 -4
- package/dist/todos/index.html +4 -4
- package/dist/ui-automation/index.html +281 -0
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +17 -3
- package/lh-plugins/lh-uiauto.mjs +1237 -0
- package/lh-plugins/storage-domain.mjs +7 -0
- package/lh-plugins/uiauto-argv-guard.cjs +41 -0
- package/package.json +1 -1
- package/dist/_astro/Base.DjIEQkT7.css +0 -1
- package/dist/_astro/Base.astro_astro_type_script_index_0_lang.D0snmAJ_.js +0 -1
- package/dist/_astro/PluginsPage.uvmSuXzi.js +0 -1
- package/dist/_astro/PmBugsBoard.CiaIhCHv.js +0 -1
- package/dist/_astro/PmIterationsBoard.H67QwKFw.js +0 -1
- package/dist/_astro/PmRequirementsBoard.BPjZ7khP.js +0 -1
- package/dist/_astro/PmRequirementsBoard.CanxvcKg.js +0 -1
- package/dist/_astro/SettingsDialog.DEgsVfaL.js +0 -1
- package/dist/_astro/app-config.DKMxjv3g.js +0 -1
- package/dist/_astro/i18n.BXeGGutk.js +0 -7
- package/dist/_astro/update.DXCPfU4a.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{o as n}from"./plugins.BDZqJNOy.js";import{t as r}from"./jsx-runtime.BUXbF_vF.js";import{t as i}from"./ConfirmDialog.CBVsDJ8f.js";import{t as a}from"./DatePicker.CMfX7F6z.js";import{t as o}from"./SelectDropdown.Buv7rQJ_.js";import{D as ee,F as s,O as te,P as ne,a as c,g as re,h as ie,o as l,x as u}from"./pm.Bl3hz9fF.js";import{D as d,E as f,O as p,S as m,T as ae,_ as h,a as oe,c as se,d as ce,f as g,g as _,i as v,k as le,l as ue,m as y,r as b,s as de,u as x,v as S,y as C}from"./PmShared.BxTHKdjY.js";var w=e(t(),1),T=r(),E=10,fe=[`all`,...c],pe=`pm.iterations.project`,me=`pm.iterations.status`,D=`pm.iterations.keyword`,O=c.map(e=>({value:e,label:l[e]}));function k(e=``){return{projectId:e,name:``,startDate:``,endDate:``,status:`planning`,remark:``}}function A({scopeProjectId:e=``}={}){let t=!!e,r=p(`iterations`),{store:c,live:A,loading:j,error:M,setError:N,reload:P}=le(),[F,I]=d(pe,`all`),L=e||F,[R,he]=f(me,fe,`all`),[z,ge]=d(D),[_e,B]=(0,w.useState)(1),[V,H]=(0,w.useState)(null),[U,W]=(0,w.useState)(!1),[G,K]=(0,w.useState)(null),q=ne(),ve=(0,w.useMemo)(()=>{let e=new Map(c.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`未关联项目`},[c.projects]),ye=(0,w.useMemo)(()=>[{value:`all`,label:`全部项目`},...c.projects.map(e=>({value:e.id,label:e.name}))],[c.projects]),J=(0,w.useMemo)(()=>u(c.iterations,{projectId:L,status:R,keyword:z}),[c.iterations,L,R,z]),Y=t?c.iterations.filter(e=>e.projectId===L).length:c.iterations.length,X=Math.max(1,Math.ceil(J.length/E)),Z=Math.min(_e,X),Q=J.slice((Z-1)*E,Z*E);(0,w.useEffect)(()=>{t||A===!0&&F!==`all`&&!c.projects.some(e=>e.id===F)&&I(`all`)},[A,c.projects,F,I,t]);async function be(){if(!V)return;if(!V.projectId){N(`请先选择所属项目`);return}let e=V.name.trim();if(!e)N(`迭代名称不能为空`);else if(V.startDate&&V.endDate&&V.endDate<V.startDate)N(`迭代结束日期不能早于开始日期`);else{W(!0);try{let t={projectId:V.projectId,name:e,startDate:V.startDate,endDate:V.endDate,status:V.status,remark:V.remark};V.id?await s(`iterations`,V.id,t):await ie(`iterations`,[t]),H(null),N(``),await P(!0)}catch(e){N(e instanceof Error?e.message:String(e))}finally{W(!1)}}}async function $(e,t){W(!0);try{await s(`iterations`,e.id,{status:t}),await P(!0)}catch(e){N(e instanceof Error?e.message:String(e))}finally{W(!1)}}async function xe(){let e=G;if(e){K(null),W(!0);try{await re(`iterations`,[e.id]),await P(!0)}catch(e){N(e instanceof Error?e.message:String(e))}finally{W(!1)}}}return r.ready?r.on?A===null?(0,T.jsx)(_,{label:`正在连接项目管理服务`}):A?c.projects.length===0&&!j&&!t?(0,T.jsx)(h,{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:ye,value:F,onChange:e=>{I(e),B(1)}}),(0,T.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按状态筛选迭代`,className:`w-28`,options:[{value:`all`,label:`全部状态`},...O],value:R,onChange:e=>{he(e),B(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:z,onChange:e=>{ge(e.target.value),B(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:U,onClick:()=>H(k(L===`all`?``:L)),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}),`新建迭代`]})]})]}),M?(0,T.jsx)(ce,{message:M,onClose:()=>N(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pb-4`,children:j&&!c.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)(ue,{children:`没有符合筛选条件的迭代。`}):(0,T.jsx)(x,{icon:`calendar`,title:`暂无迭代`,hint:`新建一个迭代,用开始 / 截止日期跟踪进度。`,action:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>H(k(L===`all`?``:L)),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=te(e,q),r=ee(e,q),i=e.endDate&&e.status!==`done`?Math.round((Date.parse(`${e.endDate}T00:00:00`)-Date.parse(`${q}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)(m,{tone:b[e.status],children:l[e.status]})]}),(0,T.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-stone-500`,children:[t?null:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`a`,{href:ae(e.projectId),className:`transition-colors hover:text-[#3370ff]`,children:ve(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:U,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:U,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:()=>H({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:U,onClick:()=>K(e),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 disabled:opacity-40`,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)(S,{page:Z,totalPages:X,busy:U,onPage:B}):null,(0,T.jsx)(se,{open:V!==null,title:V?.id?`编辑迭代`:`新建迭代`,busy:U,submitLabel:V?.id?`保存`:`创建`,onClose:()=>H(null),onSubmit:()=>void be(),children:V?(0,T.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,T.jsx)(g,{label:`所属项目`,required:!0,children:(0,T.jsx)(C,{ariaLabel:`所属项目`,options:c.projects.map(e=>({value:e.id,label:e.name})),value:V.projectId,onChange:e=>H({...V,projectId:e}),disabled:c.projects.length===0})}),(0,T.jsx)(g,{label:`迭代名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),placeholder:`如:v1.0 迭代`,className:v})}),(0,T.jsx)(g,{label:`开始日期`,children:(0,T.jsx)(a,{value:V.startDate,onChange:e=>H({...V,startDate:e}),placeholder:`选择开始日期`,className:`${v} tabular-nums`})}),(0,T.jsx)(g,{label:`截止日期`,children:(0,T.jsx)(a,{value:V.endDate,onChange:e=>H({...V,endDate:e}),placeholder:`选择截止日期`,className:`${v} tabular-nums`})}),(0,T.jsx)(g,{label:`状态`,children:(0,T.jsx)(C,{ariaLabel:`迭代状态`,options:O,value:V.status,onChange:e=>H({...V,status:e}),renderOptionPrefix:e=>(0,T.jsx)(de,{tone:b[e.value]})})}),(0,T.jsx)(g,{label:`备注`,children:(0,T.jsx)(`textarea`,{value:V.remark,onChange:e=>H({...V,remark:e.target.value}),placeholder:`迭代目标、范围等(可选)`,rows:3,className:oe})})]}):null}),(0,T.jsx)(i,{open:G!==null,title:`删除迭代`,message:`确定删除「${G?.name??``}」?关联的需求与缺陷会保留,但不再关联到这个迭代。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>K(null),onConfirm:()=>void xe()})]}):(0,T.jsx)(h,{children:`迭代管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(h,{children:n(`iterations`)}):(0,T.jsx)(_,{label:`正在读取插件开关`})}export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{o as n}from"./plugins.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{o as n}from"./plugins.BDZqJNOy.js";import{t as r}from"./jsx-runtime.BUXbF_vF.js";import{c as i,j as a}from"./pm.Bl3hz9fF.js";import{E as o,O as s,S as c,_ as l,b as u,g as d,k as f,m as p,o as m,u as h,x as g}from"./PmShared.BxTHKdjY.js";import _ from"./PmBugsBoard.CPEyBp0l.js";import v from"./PmIterationsBoard.zCeLpcBo.js";import{t as y}from"./PmRequirementsBoard.CynewRfv.js";var b=e(t(),1),x=r(),S=[`iterations`,`requirements`,`bugs`],C=`pm.project.tab`,w=`/pm/projects/`;function T(){let e=s(`projects`);return e.ready?e.on?(0,x.jsx)(u,{children:(0,x.jsx)(E,{})}):(0,x.jsx)(l,{children:n(`projects`)}):(0,x.jsx)(d,{label:`正在读取插件开关`})}function E(){let{store:e,live:t,loading:n}=f(),[r,s]=(0,b.useState)(``),[u,T]=o(C,S,`iterations`);(0,b.useEffect)(()=>{s(new URLSearchParams(window.location.search).get(`id`)??``)},[]);let E=(0,b.useMemo)(()=>e.projects.find(e=>e.id===r),[e.projects,r]),O=(0,b.useMemo)(()=>a(e),[e]);if(t===null)return(0,x.jsx)(d,{label:`正在连接项目管理服务`});if(!t)return(0,x.jsx)(l,{children:`项目详情需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(!E)return n&&!e.projects.length?(0,x.jsx)(d,{label:`正在读取项目`}):(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsx)(D,{}),(0,x.jsx)(h,{icon:`folder`,title:`没有找到这个项目`,hint:`它可能已被删除,或链接里的项目 id 不正确。`})]});let k=O[E.id],A=[{value:`iterations`,label:`迭代`,count:k?.iterations??0},{value:`requirements`,label:`需求`,count:k?.requirements??0},{value:`bugs`,label:`缺陷`,count:k?.bugs??0}];return(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3`,children:[(0,x.jsx)(`a`,{href:w,"aria-label":`返回项目列表`,className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-stone-500 transition-colors hover:bg-stone-100 hover:text-stone-800`,children:(0,x.jsx)(p,{name:`arrowLeft`,size:18})}),(0,x.jsx)(`span`,{className:`tw-pm-tile flex h-9 w-9 shrink-0 items-center justify-center rounded-xl text-sm font-bold`,children:E.name.slice(0,1)}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`h1`,{className:`truncate text-lg font-semibold text-stone-800`,children:E.name}),(0,x.jsx)(c,{tone:m[E.status],children:i[E.status]})]}),(0,x.jsx)(`p`,{className:`mt-0.5 text-xs ${E.description?`text-stone-400`:`text-stone-300 italic`}`,children:E.description||`暂无描述`})]})]}),(0,x.jsxs)(`div`,{className:`mt-5 flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[(0,x.jsx)(g,{tabs:A,value:u,onChange:T,ariaLabel:`项目二级菜单`}),(0,x.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`需求完成 `,k?.requirementPercent??0,`% · 缺陷完成 `,k?.bugClosedPercent??100,`%`]})]}),(0,x.jsxs)(`div`,{className:`mt-4 flex min-h-0 flex-1 flex-col`,children:[u===`iterations`?(0,x.jsx)(v,{scopeProjectId:E.id}):null,u===`requirements`?(0,x.jsx)(y,{scopeProjectId:E.id}):null,u===`bugs`?(0,x.jsx)(_,{scopeProjectId:E.id}):null]})]})}function D(){return(0,x.jsxs)(`a`,{href:w,className:`mb-2 inline-flex w-fit items-center gap-1.5 text-sm text-stone-500 transition-colors hover:text-stone-800`,children:[(0,x.jsx)(p,{name:`arrowLeft`,size:16}),`返回项目列表`]})}export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{o as n}from"./plugins.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{o as n}from"./plugins.BDZqJNOy.js";import{t as r}from"./jsx-runtime.BUXbF_vF.js";import{t as i}from"./ConfirmDialog.CBVsDJ8f.js";import{t as ee}from"./SelectDropdown.Buv7rQJ_.js";import{F as a,S as o,c as s,g as te,h as ne,j as re,s as c}from"./pm.Bl3hz9fF.js";import{D as ie,E as l,O as u,S as d,T as f,_ as p,a as m,c as h,d as g,f as _,g as v,i as y,k as b,l as x,m as S,o as C,s as ae,u as oe,v as se,y as ce}from"./PmShared.BxTHKdjY.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=u(`projects`),{store:t,live:r,loading:c,error:M,setError:N,reload:P}=b(),[F,I]=l(k,O,`all`),[L,R]=ie(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),le=(0,w.useMemo)(()=>re(t),[t]),X=(0,w.useMemo)(()=>o(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 ue(){if(!V)return;let e=V.name.trim();if(!e)N(`项目名称不能为空`);else{W(!0);try{V.id?await a(`projects`,V.id,{name:e,description:V.description,status:V.status}):await ne(`projects`,[{name:e,description:V.description,status:V.status}]),H(null),N(``),await P(!0)}catch(e){N(e instanceof Error?e.message:String(e))}finally{W(!1)}}}async function de(e){J(null),W(!0);try{await a(`projects`,e.id,{status:e.status===`archived`?`planning`:`archived`}),await P(!0)}catch(e){N(e instanceof Error?e.message:String(e))}finally{W(!1)}}async function fe(){let e=G;if(e){K(null),W(!0);try{await te(`projects`,[e.id]),await P(!0)}catch(e){N(e instanceof Error?e.message:String(e))}finally{W(!1)}}}return e.ready?e.on?r===null?(0,T.jsx)(v,{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)(ee,{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)(S,{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)(S,{name:`plus`,size:14}),`新建项目`]})]})]}),M?(0,T.jsx)(g,{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)(x,{children:`没有符合筛选条件的项目。`}):(0,T.jsx)(oe,{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)(S,{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=le[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:f(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)(d,{tone:C[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)(S,{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)(S,{name:`pencil`,size:14}),`编辑`]}),(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>void de(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)(S,{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)(S,{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)(S,{name:`chevronRight`,size:14,className:`tw-pm-card-chevron text-stone-300`})]})]})]})]},e.id)})})}),X.length>0?(0,T.jsx)(se,{page:Q,totalPages:Z,busy:U,onPage:B}):null,(0,T.jsx)(h,{open:V!==null,title:V?.id?`编辑项目`:`新建项目`,busy:U,submitLabel:V?.id?`保存`:`创建`,onClose:()=>H(null),onSubmit:()=>void ue(),children:V?(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(_,{label:`项目名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),placeholder:`输入项目名称`,className:y})}),(0,T.jsx)(_,{label:`描述`,children:(0,T.jsx)(`textarea`,{value:V.description,onChange:e=>H({...V,description:e.target.value}),placeholder:`项目描述(可选)`,rows:4,className:m})}),(0,T.jsx)(_,{label:`状态`,children:(0,T.jsx)(ce,{ariaLabel:`项目状态`,options:D,value:V.status,onChange:e=>H({...V,status:e}),renderOptionPrefix:e=>(0,T.jsx)(ae,{tone:C[e.value]})})})]}):null}),(0,T.jsx)(i,{open:G!==null,title:`删除项目`,message:`确定删除「${G?.name??``}」?该项目下的迭代、需求与缺陷会一并删除,且无法恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:`solid`,onClose:()=>K(null),onConfirm:()=>void fe()})]}):(0,T.jsx)(p,{children:`项目列表需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(p,{children:n(`projects`)}):(0,T.jsx)(v,{label:`正在读取插件开关`})}export{M as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{o as n}from"./plugins.BDZqJNOy.js";import{t as r}from"./jsx-runtime.BUXbF_vF.js";import{t as i}from"./ConfirmDialog.CBVsDJ8f.js";import{n as a,t as ee}from"./DocsPager.C20ue_JZ.js";import{t as o}from"./SelectDropdown.Buv7rQJ_.js";import{A as s,C as c,E as l,F as u,I as d,d as f,f as p,g as m,h,k as g,l as _,m as te,u as v}from"./pm.Bl3hz9fF.js";import{C as y,D as b,E as x,O as ne,S as re,T as ie,_ as S,a as ae,c as oe,d as se,f as C,g as ce,h as w,k as le,l as ue,m as T,p as de,s as E,u as fe,w as D,y as O}from"./PmShared.BxTHKdjY.js";var k=e(t(),1),A=r();function pe({value:e,onChange:t,entity:n,recordId:r=``,seenUrls:i,onError:a,onPersisted:ee}){let o=s(e),[c,f]=(0,k.useState)(!1),[p,m]=(0,k.useState)(!1),[h,_]=(0,k.useState)(null),v=(0,k.useRef)(null);(0,k.useEffect)(()=>{for(let t of s(e))i.current.add(t.url)},[e,i]);let y=(0,k.useCallback)(async n=>{if(n&&n.length){f(!0);try{let r=await d(Array.from(n));t(g([...s(e),...r])),a(``)}catch(e){a(e instanceof Error?e.message:String(e))}finally{f(!1),v.current&&(v.current.value=``)}}},[t,a,e]);(0,k.useEffect)(()=>{let e=e=>{let t=Array.from(e.clipboardData?.files??[]);t.length&&(e.preventDefault(),y(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[y]);async function b(e){let i=g(o.filter(t=>t.url!==e));if(r)try{await u(n,r,{attachment:i}),ee?.()}catch(e){a(e instanceof Error?e.message:String(e));return}t(i),te([e],r)}return(0,A.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),y(e.dataTransfer?.files??null)},children:[o.length?(0,A.jsx)(`ul`,{className:`space-y-1.5`,children:o.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[l(e.url)?(0,A.jsx)(`button`,{type:`button`,onClick:()=>_(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,A.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,A.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,A.jsx)(T,{name:`file`,size:15})}),l(e.url)?(0,A.jsx)(`button`,{type:`button`,onClick:()=>_(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}):(0,A.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,A.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>void b(e.url),className:`flex h-6 w-6 shrink-0 items-center justify-center rounded text-stone-300 hover:bg-red-50 hover:text-red-600`,children:`✕`})]},e.url))}):null,(0,A.jsx)(`input`,{ref:v,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void y(e.target.files)}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>v.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-dashed border-stone-300 px-2.5 text-xs text-stone-500 transition-colors hover:border-stone-400 hover:text-stone-700 disabled:opacity-40`,children:[(0,A.jsx)(T,{name:c?`file`:`plus`,size:13}),c?`上传中…`:`上传文件 / 图片`]}),(0,A.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可拖拽到这里,或直接粘贴截图(⌘V / Ctrl+V),支持多张`})]}),(0,A.jsx)(w,{file:h,onClose:()=>_(null)})]})}var me=20,he=`tw.pm-requirements.page-size.v1`,ge=[`all`,...f],_e=[`all`,..._],ve=`pm.requirements.project`,ye=`pm.requirements.iteration`,be=`pm.requirements.status`,xe=`pm.requirements.priority`,Se=`pm.requirements.keyword`,j=_.map(e=>({value:e,label:v[e]})),M=f.map(e=>({value:e,label:p[e]}));function N(e=``){return{projectId:e,iterationId:``,title:``,priority:`medium`,status:`pending`,description:``,acceptanceCriteria:[],githubIssue:``,attachment:``}}function P({scopeProjectId:e=``}={}){let t=!!e,r=ne(`pmRequirements`),{store:l,live:d,loading:f,error:g,setError:_,reload:w}=le(),[P,F]=b(ve,`all`),I=e||P,[L,R]=b(ye,`all`),[z,Ce]=x(be,ge,`all`),[B,we]=x(xe,_e,`all`),[V,Te]=b(Se),[Ee,H]=(0,k.useState)(1),[U,De]=a(me,he),[W,G]=(0,k.useState)(null),[K,q]=(0,k.useState)(!1),[J,Y]=(0,k.useState)(null),X=(0,k.useRef)(new Set),Oe=(0,k.useMemo)(()=>[{value:`all`,label:`全部项目`},...l.projects.map(e=>({value:e.id,label:e.name}))],[l.projects]),ke=(0,k.useMemo)(()=>[{value:`all`,label:`全部迭代`},...l.iterations.filter(e=>I===`all`||e.projectId===I).map(e=>({value:e.id,label:e.name}))],[l.iterations,I]),Ae=(0,k.useMemo)(()=>{let e=new Map(l.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[l.projects]),je=(0,k.useMemo)(()=>{let e=new Map(l.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[l.iterations]),Z=(0,k.useMemo)(()=>c(l.requirements,{projectId:I,iterationId:L,status:z,priority:B,keyword:V}),[l.requirements,I,L,z,B,V]),Q=t?l.requirements.filter(e=>e.projectId===I).length:l.requirements.length,Me=Math.max(1,Math.ceil(Z.length/U)),$=Math.min(Ee,Me),Ne=Z.slice(($-1)*U,$*U);(0,k.useEffect)(()=>{t||d===!0&&P!==`all`&&!l.projects.some(e=>e.id===P)&&F(`all`)},[d,l.projects,P,F,t]),(0,k.useEffect)(()=>{d===!0&&L!==`all`&&!l.iterations.some(e=>e.id===L&&(I===`all`||e.projectId===I))&&R(`all`)},[d,l.iterations,I,L,R]);let Pe=W?l.iterations.filter(e=>e.projectId===W.projectId):[];async function Fe(){if(!W)return;if(!W.projectId){_(`请先选择所属项目`);return}let e=W.title.trim();if(!e)_(`需求描述不能为空`);else{q(!0);try{let t={projectId:W.projectId,iterationId:W.iterationId,title:e,priority:W.priority,status:W.status,description:W.description,acceptanceCriteria:W.acceptanceCriteria.filter(e=>e.text.trim()),githubIssue:W.githubIssue,attachment:W.attachment};W.id?await u(`requirements`,W.id,t):await h(`requirements`,[t]),G(null),X.current.clear(),_(``),await w(!0)}catch(e){_(e instanceof Error?e.message:String(e))}finally{q(!1)}}}function Ie(){let e=[...X.current,...s(W?.attachment??``).map(e=>e.url)];X.current.clear(),G(null),e.length&&te(e)}async function Le(e,t){q(!0);try{await u(`requirements`,e.id,{status:t}),await w(!0)}catch(e){_(e instanceof Error?e.message:String(e))}finally{q(!1)}}async function Re(){let e=J;if(e){Y(null),q(!0);try{await m(`requirements`,[e.id]),await w(!0)}catch(e){_(e instanceof Error?e.message:String(e))}finally{q(!1)}}}if(!r.ready)return(0,A.jsx)(ce,{label:`正在读取插件开关`});if(!r.on)return(0,A.jsx)(S,{children:n(`pmRequirements`)});if(d===null)return(0,A.jsx)(ce,{label:`正在连接项目管理服务`});if(!d)return(0,A.jsx)(S,{children:`需求管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(l.projects.length===0&&!f&&!t)return(0,A.jsx)(S,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护需求。`});let ze=[{value:`all`,label:`全部`},...M];return(0,A.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,A.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,A.jsx)(`span`,{className:`font-medium text-stone-600`,children:Q}),` 条需求`,Z.length===Q?``:` · 筛选出 ${Z.length} 条`]}),(0,A.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,A.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选需求`,className:`w-36`,options:Oe,value:P,onChange:e=>{F(e),R(`all`),H(1)}}),(0,A.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选需求`,className:`w-32`,options:ke,value:L,onChange:e=>{R(e),H(1)}}),(0,A.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按优先级筛选需求`,className:`w-28`,options:[{value:`all`,label:`全部优先级`},...j],value:B,onChange:e=>{we(e),H(1)}}),(0,A.jsxs)(`label`,{className:`relative block`,children:[(0,A.jsx)(T,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,A.jsx)(`input`,{value:V,onChange:e=>{Te(e.target.value),H(1)},placeholder:`搜索编号 / 名称…`,className:`h-9 w-44 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,A.jsxs)(`button`,{type:`button`,disabled:K,onClick:()=>G(N(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,A.jsx)(T,{name:`plus`,size:14}),`新建需求`]})]})]}),(0,A.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,A.jsx)(de,{ariaLabel:`按状态筛选需求`,options:ze,value:z,onChange:e=>{Ce(e),H(1)}})}),g?(0,A.jsx)(se,{message:g,onClose:()=>_(``)}):null,(0,A.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,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,A.jsxs)(`table`,{className:`tw-data-table w-full border-collapse text-sm`,children:[(0,A.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`th`,{className:`w-24 px-4 py-2.5 text-left font-medium whitespace-nowrap`,children:`ID`}),(0,A.jsx)(`th`,{className:`px-4 py-2.5 text-left font-medium`,children:`需求描述`}),(0,A.jsx)(`th`,{className:`w-24 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`优先级`}),(0,A.jsx)(`th`,{className:`w-32 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`需求状态`}),t?null:(0,A.jsx)(`th`,{className:`w-40 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`所属项目`}),(0,A.jsx)(`th`,{className:`w-40 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`所属迭代`}),(0,A.jsx)(`th`,{className:`w-24 px-3 py-2.5 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,A.jsxs)(`tbody`,{children:[f&&!l.requirements.length?(0,A.jsx)(`tr`,{children:(0,A.jsx)(`td`,{colSpan:t?6:7,className:`px-4 py-16 text-center`,children:(0,A.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):Ne.length===0?(0,A.jsx)(`tr`,{children:(0,A.jsx)(`td`,{colSpan:t?6:7,children:Q?(0,A.jsx)(ue,{children:`没有符合筛选条件的需求。`}):(0,A.jsx)(fe,{icon:`file`,title:`暂无需求`,hint:`拆出第一条需求,再关联迭代、补充描述。`,action:(0,A.jsxs)(`button`,{type:`button`,onClick:()=>G(N(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,A.jsx)(T,{name:`plus`,size:13}),`新建需求`]})})})}):null,Ne.map(e=>(0,A.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,A.jsx)(`td`,{className:`px-4 py-2.5 font-mono text-xs text-stone-400`,children:e.autoId}),(0,A.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,A.jsx)(`button`,{type:`button`,onClick:()=>G({id:e.id,projectId:e.projectId,iterationId:e.iterationId,title:e.title,priority:e.priority,status:e.status,description:e.description,acceptanceCriteria:e.acceptanceCriteria.map(e=>({...e})),githubIssue:e.githubIssue,attachment:e.attachment}),className:`max-w-full truncate text-left text-stone-800 hover:text-[#3370ff]`,children:e.title})}),(0,A.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,A.jsx)(re,{tone:y[e.priority],children:v[e.priority]})}),(0,A.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,A.jsx)(o,{unstyled:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:K,options:M,value:e.status,onChange:t=>void Le(e,t),renderOptionPrefix:e=>(0,A.jsx)(E,{tone:D[e.value]}),renderTrigger:()=>(0,A.jsx)(re,{tone:D[e.status],children:p[e.status]})})}),t?null:(0,A.jsx)(`td`,{className:`truncate px-3 py-2.5 text-sm text-stone-600`,children:(0,A.jsx)(`a`,{href:ie(e.projectId),className:`transition-colors hover:text-[#3370ff]`,children:Ae(e.projectId)})}),(0,A.jsx)(`td`,{className:`truncate px-3 py-2.5 text-sm text-stone-500`,children:je(e.iterationId)}),(0,A.jsx)(`td`,{className:`px-3 py-2.5 text-center`,children:(0,A.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:K,onClick:()=>Y(e),className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 disabled:opacity-40`,children:(0,A.jsx)(T,{name:`trash`,size:15})})})]},e.id))]})]})}),Z.length>0?(0,A.jsx)(ee,{page:$,totalPages:Me,pageSize:U,busy:K,onPage:H,onPageSize:e=>{De(e),H(1)}}):null]}),(0,A.jsx)(oe,{open:W!==null,title:W?.id?`编辑需求`:`新建需求`,busy:K,submitLabel:W?.id?`保存`:`创建`,onClose:()=>Ie(),onSubmit:()=>void Fe(),children:W?(0,A.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,A.jsx)(C,{label:`所属项目`,required:!0,children:(0,A.jsx)(O,{ariaLabel:`所属项目`,options:l.projects.map(e=>({value:e.id,label:e.name})),value:W.projectId,onChange:e=>{let t=l.iterations.some(t=>t.id===W.iterationId&&t.projectId===e);G({...W,projectId:e,iterationId:t?W.iterationId:``})}})}),(0,A.jsx)(C,{label:`所属迭代`,children:(0,A.jsx)(O,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...Pe.map(e=>({value:e.id,label:e.name}))],value:W.iterationId,onChange:e=>G({...W,iterationId:e}),disabled:Pe.length===0})}),(0,A.jsx)(C,{label:`需求描述`,required:!0,children:(0,A.jsx)(`textarea`,{autoFocus:!0,value:W.title,onChange:e=>G({...W,title:e.target.value}),placeholder:`一句话写清要做什么`,rows:3,className:ae})}),(0,A.jsx)(C,{label:`优先级`,children:(0,A.jsx)(O,{ariaLabel:`优先级`,options:j,value:W.priority,onChange:e=>G({...W,priority:e}),renderOptionPrefix:e=>(0,A.jsx)(E,{tone:y[e.value]})})}),(0,A.jsx)(C,{label:`需求状态`,children:(0,A.jsx)(O,{ariaLabel:`需求状态`,options:M,value:W.status,onChange:e=>G({...W,status:e}),renderOptionPrefix:e=>(0,A.jsx)(E,{tone:D[e.value]})})}),(0,A.jsx)(C,{label:`附件`,children:(0,A.jsx)(pe,{value:W.attachment,onChange:e=>G(t=>t&&{...t,attachment:e}),entity:`requirements`,recordId:W.id??``,seenUrls:X,onError:_,onPersisted:()=>void w(!0)})}),(0,A.jsx)(C,{label:`备注`,children:(0,A.jsx)(`textarea`,{value:W.description,onChange:e=>G({...W,description:e.target.value}),placeholder:`补充背景、目标与范围(可选)`,rows:4,className:ae})})]}):null}),(0,A.jsx)(i,{open:J!==null,title:`删除需求`,message:`确定删除「${J?.title??``}」?关联的缺陷会保留,但不再关联到这条需求。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>Y(null),onConfirm:()=>void Re()})]})}export{P as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{t as default}from"./PmRequirementsBoard.CynewRfv.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{i as r}from"./app-config.
|
|
1
|
+
import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{i as r}from"./app-config.DUyozIL9.js";import{a as i,r as a}from"./plugins.BDZqJNOy.js";import{a as o,n as s,o as c,r as l}from"./view-prefs.Dyu_lmN2.js";import{t as u}from"./jsx-runtime.BUXbF_vF.js";import{t as d}from"./SelectDropdown.Buv7rQJ_.js";import{_ as f,v as p,y as m}from"./pm.Bl3hz9fF.js";import{t as h}from"./SlideOverDrawer.TPbGEoWn.js";var g=e(t(),1),_=e(n(),1),v=u(),y=8e3;function b(e,t,n){let[r,i]=(0,g.useState)(()=>s(e,t,n));return[r,(0,g.useCallback)(t=>{i(t),o(e,t)},[e])]}function x(e,t=``){let[n,r]=(0,g.useState)(()=>l(e)||t);return[n,(0,g.useCallback)(n=>{r(n),c(e,n===t?``:n)},[e,t])]}function S(e){let[t,n]=(0,g.useState)(!1),[o,s]=(0,g.useState)(()=>a(e));return(0,g.useEffect)(()=>{let t=!0,o=i(()=>s(a(e)));return r().then(()=>{t&&(s(a(e)),n(!0))}),()=>{t=!1,o()}},[e]),{ready:t,on:o}}var C=(0,g.createContext)(null);function w(e){let[t,n]=(0,g.useState)(f),[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(!0),[s,c]=(0,g.useState)(``),l=(0,g.useRef)(!0),u=(0,g.useCallback)(async(e=!1)=>{e||o(!0);try{let e=await m();return l.current?(n(e),i(!0),c(``),e):null}catch(e){return l.current&&c(e instanceof Error?e.message:String(e)),null}finally{l.current&&!e&&o(!1)}},[]);return(0,g.useEffect)(()=>{if(!e){o(!1);return}l.current=!0;let t=null;return(async()=>{let e=await p();l.current&&(e?(i(!0),await u(),t=window.setInterval(()=>void u(!0),y)):(i(!1),o(!1)))})(),()=>{l.current=!1,t!==null&&window.clearInterval(t)}},[e,u]),{store:t,live:r,loading:a,error:s,setError:c,reload:u}}function T({children:e}){let t=w(!0);return(0,v.jsx)(C.Provider,{value:t,children:e})}function E(){let e=(0,g.useContext)(C),t=w(e===null);return e??t}var D={gray:`bg-stone-100 text-stone-600`,blue:`bg-[#e1eaff] text-[#1f4ec2]`,amber:`bg-[#fff1e3] text-[#a85b00]`,yellow:`bg-[#fff7d6] text-[#8a6100]`,red:`bg-[#fee4e3] text-[#c02a26]`,purple:`bg-[#efe7ff] text-[#5b32b4]`,green:`bg-[#d9f5d2] text-[#1d7a12]`,muted:`bg-stone-100 text-stone-400`},O={planning:`blue`,in_progress:`amber`,archived:`gray`},k={planning:`blue`,in_progress:`amber`,done:`green`},A={urgent:`red`,high:`amber`,medium:`yellow`,low:`gray`},j={pending:`gray`,todo:`blue`,in_progress:`blue`,testing:`purple`,done:`green`,cancelled:`muted`},M={critical:`red`,major:`amber`,minor:`yellow`,trivial:`gray`},N={pending:`gray`,todo:`blue`,fixed:`amber`,verifying:`purple`,passed:`green`,cancelled:`muted`},P={gray:`#a8a29e`,blue:`#3370ff`,amber:`#f59e0b`,yellow:`#eab308`,red:`#ef4444`,purple:`#8b5cf6`,green:`#22c55e`,muted:`#d6d3d1`};function F({tone:e}){return(0,v.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:P[e]}})}function I({tone:e,children:t}){return(0,v.jsx)(`span`,{className:`inline-flex h-6 shrink-0 items-center rounded-md px-2 text-xs font-medium ${D[e]}`,children:t})}var L={plus:[`M12 5v14`,`M5 12h14`],more:[],chevronRight:[`m9 5 7 7-7 7`],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`],check:[`m4.5 12.5 5 5 10-11`],play:[`M8 5.5v13l11-6.5Z`],search:[`M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14Z`,`m20 20-3.6-3.6`],folder:[`M3 7.5A2.5 2.5 0 0 1 5.5 5h3.2l2 2h7.8A2.5 2.5 0 0 1 21 9.5v7A2.5 2.5 0 0 1 18.5 19h-13A2.5 2.5 0 0 1 3 16.5Z`],calendar:[`M4 7.5A2.5 2.5 0 0 1 6.5 5h11A2.5 2.5 0 0 1 20 7.5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2Z`,`M8 3v4`,`M16 3v4`,`M4 10h16`],file:[`M7 3.5h6.5L18 8v12.5H7Z`,`M13.5 3.5V8H18`,`M10 12.5h5`,`M10 16h5`],bug:[`M8.5 9.5h7V14a3.5 3.5 0 0 1-7 0Z`,`M9.5 6.2 12 8l2.5-1.8`,`M4.5 13H8.5`,`M15.5 13h4`,`M6 18.5l2-2`,`M18 18.5l-2-2`]};function R({name:e,size:t=16,className:n=``}){return e===`more`?(0,v.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,className:n,children:[(0,v.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.6`}),(0,v.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.6`}),(0,v.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.6`})]}):(0,v.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:n,children:L[e].map(e=>(0,v.jsx)(`path`,{d:e},e))})}function z({tabs:e,value:t,onChange:n,ariaLabel:r}){return(0,v.jsx)(`div`,{className:`tw-pm-tabs`,role:`tablist`,"aria-label":r,children:e.map(e=>(0,v.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:`tw-pm-tab`,children:[e.label,typeof e.count==`number`?(0,v.jsx)(`span`,{className:`tw-pm-tab-count`,children:e.count}):null]},e.value))})}function B({options:e,value:t,onChange:n,ariaLabel:r}){return(0,v.jsx)(`div`,{className:`tw-pm-pills`,role:`group`,"aria-label":r,children:e.map(e=>(0,v.jsx)(`button`,{type:`button`,"aria-pressed":t===e.value,onClick:()=>n(e.value),children:e.label},e.value))})}function V({icon:e,title:t,hint:n,action:r}){return(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-4 py-20 text-center`,children:[(0,v.jsx)(`span`,{className:`tw-pm-tile mb-4 flex h-16 w-16 items-center justify-center rounded-2xl`,children:(0,v.jsx)(R,{name:e,size:30})}),(0,v.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:t}),(0,v.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:n}),r?(0,v.jsx)(`div`,{className:`mt-4`,children:r}):null]})}function H(e){return`/pm/projects/detail/?id=${encodeURIComponent(e)}`}var U=`h-9 w-full rounded-md border border-transparent bg-transparent px-2 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`,W=`min-h-[72px] w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`;function G(e){return(0,v.jsx)(d,{flat:!0,menuMatchTrigger:!0,ariaLabel:e.ariaLabel,options:e.options,value:e.value,onChange:e.onChange,disabled:e.disabled,renderOptionPrefix:e.renderOptionPrefix})}function K({page:e,totalPages:t,busy:n=!1,onPage:r}){let i=`h-7 shrink-0 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`;return(0,v.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-center gap-2 pt-3`,children:[(0,v.jsx)(`button`,{type:`button`,className:i,disabled:n||e<=1,onClick:()=>r(e-1),children:`上一页`}),(0,v.jsxs)(`span`,{className:`px-2 text-xs tabular-nums text-stone-400`,children:[e,` / `,t]}),(0,v.jsx)(`button`,{type:`button`,className:i,disabled:n||e>=t,onClick:()=>r(e+1),children:`下一页`})]})}function q({label:e}){return(0,v.jsx)(`div`,{className:`flex min-h-[240px] items-center justify-center rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":e,children:(0,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}function J({children:e}){return(0,v.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:e})}function Y({children:e}){return(0,v.jsx)(`div`,{className:`px-4 py-16 text-center text-sm text-stone-400`,children:e})}function X({open:e,title:t,busy:n,submitLabel:r,onClose:i,onSubmit:a,children:o}){return(0,v.jsx)(h,{open:e,onClose:i,title:t,footer:(0,v.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-stone-100 px-2 py-3`,children:[(0,v.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 hover:bg-stone-100`,children:`取消`}),(0,v.jsx)(`button`,{type:`button`,disabled:n,onClick:a,className:`h-8 rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:r})]}),children:o})}function Z({label:e,required:t,children:n}){return(0,v.jsxs)(`div`,{className:`flex items-start gap-3 px-2 py-2`,children:[(0,v.jsx)(`div`,{className:`flex h-9 w-[88px] shrink-0 items-center text-sm text-stone-600`,children:(0,v.jsxs)(`span`,{className:`truncate`,children:[e,t?(0,v.jsx)(`span`,{className:`ml-0.5 text-red-500`,children:`*`}):null]})}),(0,v.jsx)(`div`,{className:`min-w-0 flex-1 [&>div]:mt-0`,children:n})]})}function Q({file:e,onClose:t}){return e?(0,_.createPortal)((0,v.jsxs)(`div`,{className:`fixed inset-0 z-[70] flex items-center justify-center bg-stone-900/70 p-6 sm:p-10`,role:`dialog`,"aria-modal":`true`,"aria-label":e.name,onClick:t,children:[(0,v.jsx)(`img`,{src:e.url,alt:e.name,className:`max-h-full max-w-full rounded-lg bg-white object-contain shadow-2xl`,onClick:e=>e.stopPropagation()}),(0,v.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,onClick:t,className:`absolute right-4 top-4 flex h-9 w-9 items-center justify-center rounded-full bg-white/90 text-lg text-stone-600 shadow-md transition-colors hover:bg-white hover:text-stone-900`,children:`✕`})]}),document.body):null}function $({message:e,onClose:t}){return(0,v.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,v.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,v.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]})}export{A as C,x as D,b as E,S as O,I as S,H as T,J as _,W as a,T as b,X as c,$ as d,Z as f,q as g,Q as h,U as i,E as k,Y as l,R as m,N as n,O as o,B as p,k as r,F as s,M as t,V as u,K as v,j as w,z as x,G as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DUyozIL9.js";import{a as r,o as i,r as a}from"./plugins.BDZqJNOy.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{t as s}from"./ConfirmDialog.CBVsDJ8f.js";import{l as c,n as l,r as u,s as d}from"./project-docs.Cd2gKPKh.js";import{n as f}from"./doc-roots.DAJP9Svr.js";import{i as p}from"./prompts-meta.F4wwkjUA.js";import{i as m,n as h,r as g,t as _}from"./DocsFileBrowser.BtRoZ787.js";import{t as v,u as y}from"./open-docs-in-session.Xg3OSOfc.js";var b=e(t(),1),x=o(),S=10;async function C(e=`.`){let{entries:t}=await d(`prompts`,e),n=[];for(let e of t)e.type===`file`?n.push(e):n.push(...await C(e.path));return n}function w(){let e=g(`prompts`),[t,o]=(0,b.useState)(!1),[d,w]=(0,b.useState)(!0),[T,E]=(0,b.useState)(e?!0:null),[D,O]=(0,b.useState)(()=>e??[]),[k,A]=(0,b.useState)(null),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)({}),[F,I]=(0,b.useState)(null),L=h(D,S,`prompts`),R=(0,b.useCallback)(async()=>{A(null);try{let e=await C(`.`);O(e),m(`prompts`,e)}catch(e){A(e instanceof Error?e.message:String(e))}},[]);(0,b.useEffect)(()=>{let e=r(e=>w(!!e.prompts));return n().then(()=>{w(a(`prompts`)),o(!0)}),e},[]),(0,b.useEffect)(()=>{t&&d&&(async()=>{await u(`prompts`)?(await y().catch(()=>null),await R(),E(!0)):E(!1)})()},[t,d,R]);let z=(0,b.useMemo)(()=>Object.keys(N).filter(e=>N[e]),[N]);async function B(e){M(!0),A(null);try{await c(`prompts`,e.path)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}async function V(e){M(!0),A(null);try{await v(`prompts`,e)}catch(e){A(e instanceof Error?e.message:String(e)),M(!1)}}function H(e){p(e.path)?A(`默认提示词不可删除`):I({kind:`one`,entry:e})}async function U(){let e=F;if(e){I(null),M(!0),A(null);try{if(e.kind===`one`)await l(`prompts`,e.entry.path);else{for(let t of e.paths)p(t)||await l(`prompts`,t);P({})}await R()}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}function W(){a(`promptGen`)?window.location.href=`/?plugin=promptGen`:A(i(`promptGen`))}let G=F?.kind===`one`?`删除「${F.entry.name}」?将从 ${f(`prompts`)} 中移除。`:F?.kind===`batch`?`确认删除已选中的 ${F.paths.length} 个提示词?此操作不可恢复。`:``;return t?d?T===null?(0,x.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,x.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):T?(0,x.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,x.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,x.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[L.query.trim()?(0,x.jsxs)(x.Fragment,{children:[`匹配 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-800`,children:L.filtered.length}),` 个`,(0,x.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,D.length]})]}):(0,x.jsxs)(x.Fragment,{children:[`共 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-800`,children:D.length}),` 个提示词`]}),z.length>0?(0,x.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,z.length]}):null]}),(0,x.jsx)(`button`,{type:`button`,disabled:j||z.length===0,onClick:()=>I({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,x.jsx)(`button`,{type:`button`,disabled:j,onClick:W,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:`生成提示词`})]}),k?(0,x.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:k}):null,(0,x.jsx)(_,{files:D,filtered:L.filtered,pageFiles:L.pageFiles,query:L.query,onQuery:L.setQuery,sortBy:L.sortBy,onSortBy:L.setSortBy,page:L.page,totalPages:L.totalPages,pageSize:L.pageSize,onPage:L.setPage,onPageSize:L.setPageSize,busy:j,emptyText:`暂无提示词,点击「生成提示词」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selectable:e=>!p(e.path),selected:N,onToggleRow:e=>P(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>P(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void B(e),renderActions:e=>{let t=p(e.path);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>void V(e),className:`text-xs whitespace-nowrap text-white bg-[#4176e6] px-2 py-1 rounded hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,x.jsx)(`button`,{type:`button`,disabled:j||t,"data-hint":t?`默认提示词不可删除`:void 0,onClick:()=>H(e),className:`text-xs whitespace-nowrap text-red-600 hover:bg-red-50 px-2 py-1 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent`,children:`删除`})]})}}),(0,x.jsx)(s,{open:F!=null,title:F?.kind===`batch`?`批量删除`:`删除提示词`,message:G,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>I(null),onConfirm:()=>void U()})]}):(0,x.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,x.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:i(`prompts`)}):(0,x.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,x.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{w as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n,p as r}from"./app-config.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n,p as r}from"./app-config.DUyozIL9.js";import{a as i,o as a,r as ee}from"./plugins.BDZqJNOy.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{n as s,t as c}from"./DocsPager.C20ue_JZ.js";import{t as l}from"./SelectDropdown.Buv7rQJ_.js";import{a as u,i as d,o as f,r as te,s as ne,t as p}from"./report-prompt.Cmw4XzfY.js";var m=e(t(),1),h=`tw.reports.kind.v1`,g=Object.keys(p);function _(e){return typeof e==`string`&&g.includes(e)}function v(e=`day`){try{let t=localStorage.getItem(r(h));return _(t)?t:e}catch{return e}}function y(e){if(_(e))try{localStorage.setItem(r(h),e)}catch{}}var b=o(),x=[`day`,`week`,`month`],S=20,C=`tw.reports.page-size.v1`;function w(e){return e.replace(/\.(md|markdown|txt)$/i,``)}function T(e){return e.replace(/\.(md|markdown|txt|html?)$/i,``)}function E(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}/${n(t.getMonth()+1)}/${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function D(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 O={day:`日`,week:`周`,month:`月`};function k(){let[e,t]=(0,m.useState)(!1),[r,o]=(0,m.useState)(!0),[h,g]=(0,m.useState)(()=>v()),_=(0,m.useRef)(h),[k,A]=(0,m.useState)([]),[j,re]=(0,m.useState)(``),[M,N]=(0,m.useState)(!1),[P,F]=(0,m.useState)(null),[I,L]=(0,m.useState)(``),[R,z]=(0,m.useState)([]),[B,V]=(0,m.useState)(``),[H,U]=(0,m.useState)(!1),[W,G]=(0,m.useState)(1),[K,q]=s(S,C),J=(0,m.useCallback)(async(e,t)=>{N(!0),F(null);try{if(t?.ensure)try{await ne(!0)}catch{}let n=await d(e);A(n.items),re(n.dir)}catch(e){let t=e instanceof Error?e.message:String(e);F(t.includes(`404`)?`工作汇报需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`:t),A([])}finally{N(!1)}},[]);(0,m.useEffect)(()=>{let e=i(e=>o(!!e.reports));return n().then(()=>{o(ee(`reports`)),t(!0)}),e},[]);let Y=(0,m.useCallback)(async()=>{try{let e=await te();z(e.items),V(e.promptFile)}catch{}},[]);(0,m.useEffect)(()=>{e&&r&&(async()=>{await J(_.current,{ensure:!0}),await Y()})()},[e,r,J,Y]);function ie(e){y(e),e!==h&&(g(e),G(1),A([]),J(e))}async function ae(e){if(e&&e!==B){U(!0),F(null);try{let t=await f(e);V(t),z(e=>e.map(e=>({...e,selected:e.name===t})))}catch(e){F(e instanceof Error?e.message:String(e))}finally{U(!1)}}}let oe=(0,m.useMemo)(()=>R.length?R.map(e=>({value:e.name,label:w(e.name)})):[{value:``,label:`暂无提示词`}],[R]),X=(0,m.useMemo)(()=>[...k].sort((e,t)=>t.generatedAt-e.generatedAt),[k]),Z=Math.max(1,Math.ceil(X.length/K)),Q=Math.min(W,Z),se=(0,m.useMemo)(()=>X.slice((Q-1)*K,Q*K),[X,Q,K]),ce=`/?report=${h}`;async function le(e){if(!I){L(e.name),F(null);try{await u(e.kind,e.name)}catch(e){F(e instanceof Error?e.message:String(e))}finally{L(``)}}}if(!e)return(0,b.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex items-center justify-center min-h-[220px]`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,b.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!r)return(0,b.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`reports`)});let $=X[0];return(0,b.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,b.jsxs)(`div`,{className:`shrink-0 border-b border-stone-100 px-4 py-3`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:x.map(e=>(0,b.jsx)(`button`,{type:`button`,onClick:()=>ie(e),className:`h-8 rounded-md px-3 text-sm transition-colors ${h===e?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:p[e]},e))}),(0,b.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,b.jsx)(l,{className:`w-[172px]`,flat:!0,options:oe,value:B,onChange:e=>void ae(e),disabled:!R.length||H,ariaLabel:`选择工作汇报提示词`,menuMinWidth:200}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{await J(h),await Y()})(),disabled:M,"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800 disabled:opacity-40`,children:(0,b.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,b.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,b.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,b.jsx)(`a`,{href:ce,className:`inline-flex h-9 items-center whitespace-nowrap rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9]`,children:`去工作台写汇报`})]})]}),(0,b.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-stone-400`,children:[(0,b.jsxs)(`span`,{children:[p[h],` · 共 `,k.length,` 篇`]}),$?(0,b.jsxs)(`span`,{className:`tabular-nums`,children:[`最近生成 `,E($.generatedAt)]}):null,(0,b.jsx)(`span`,{className:`min-w-0 truncate`,children:j||`—`}),(0,b.jsx)(`span`,{className:`ml-auto hidden shrink-0 sm:inline`,children:`点击卡片用系统默认程序打开`})]})]}),P?(0,b.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,b.jsx)(`span`,{className:`min-w-0 flex-1`,children:P}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>F(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,b.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto bg-stone-50/60 p-3 sm:p-4`,children:M&&k.length===0?(0,b.jsx)(`div`,{className:`flex min-h-[180px] items-center justify-center`,"aria-busy":`true`,children:(0,b.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):k.length===0?(0,b.jsxs)(`div`,{className:`flex min-h-[260px] flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-stone-300 px-6 py-10 text-center`,children:[(0,b.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-xl bg-stone-100 text-stone-400`,children:(0,b.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,b.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,b.jsx)(`path`,{d:`M14 3v5h5`}),(0,b.jsx)(`path`,{d:`M9 13h6M9 17h4`})]})}),(0,b.jsxs)(`div`,{className:`text-sm font-medium text-stone-700`,children:[`还没有`,p[h]]}),(0,b.jsxs)(`p`,{className:`max-w-md text-xs leading-5 text-stone-400`,children:[`保存到 `,j||`工作汇报/${p[h]}`,` 后会自动出现在这里。`]})]}):(0,b.jsx)(`ul`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,380px),1fr))] gap-2.5`,children:se.map(e=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(`button`,{type:`button`,onClick:()=>void le(e),disabled:!!I,className:`group flex w-full items-center gap-3 rounded-xl border border-stone-200 bg-white px-3.5 py-3 text-left transition-colors hover:border-[#3370ff]/50 hover:bg-stone-50 disabled:cursor-progress disabled:opacity-60`,children:[(0,b.jsx)(`span`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-stone-100 text-[13px] font-semibold text-stone-600`,children:O[e.kind]}),(0,b.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`span`,{className:`block truncate text-sm font-medium text-stone-800 transition-colors group-hover:text-[#3370ff]`,children:T(e.name)}),(0,b.jsxs)(`span`,{className:`mt-0.5 block truncate text-xs text-stone-400 tabular-nums`,children:[E(e.generatedAt),` · `,D(e.size)]})]}),(0,b.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 text-xs text-stone-400 transition-colors group-hover:text-[#3370ff]`,children:[I===e.name?`打开中…`:`打开`,(0,b.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,b.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})]})},e.name))})}),k.length>0?(0,b.jsx)(c,{page:Q,totalPages:Z,pageSize:K,busy:M,onPage:G,onPageSize:e=>{q(e),G(1)}}):(0,b.jsx)(`div`,{className:`pb-2.5`})]})}export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DKMxjv3g.js";import{a as r,o as i,r as a}from"./plugins.D5ypJIXn.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{t as s}from"./ConfirmDialog.CBVsDJ8f.js";import{n as c,t as ee}from"./DocsPager.rzu4mnzw.js";import{a as te,c as ne,f as l,h as u,i as re,l as ie,m as ae,n as oe,o as d,p as se,r as ce,s as f,t as le,u as ue}from"./project-docs.Cd2gKPKh.js";import{n as de}from"./doc-roots.DAJP9Svr.js";import{t as fe}from"./useListAnim.CpGB1cft.js";import{t as p}from"./NamePromptDialog.Dl5kSnQI.js";var m=e(t(),1),h=o(),pe=5;function g({className:e=`w-4 h-4`,open:t=!1}){return(0,h.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,h.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,h.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function _({className:e=`w-3 h-3`}){return(0,h.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,h.jsx)(`path`,{d:`m15 5 4 4`})]})}function v({className:e=`w-3 h-3`}){return(0,h.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M3 6h18`}),(0,h.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,h.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,h.jsx)(`path`,{d:`M10 11v6`}),(0,h.jsx)(`path`,{d:`M14 11v6`})]})}function y({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,h.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,h.jsx)(g,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,h.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,h.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,h.jsx)(`div`,{className:`tw-collapse-inner`,children:e.children.map(e=>(0,h.jsx)(y,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function me(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function b(){let[e,t]=(0,m.useState)(()=>a(`requirements`)),[o,b]=(0,m.useState)(!1),[x,he]=(0,m.useState)(null),[S,ge]=(0,m.useState)([]),[_e,ve]=(0,m.useState)(0),[C,w]=(0,m.useState)(`.`),[T,E]=(0,m.useState)([]),[ye,D]=(0,m.useState)({}),[O,be]=(0,m.useState)(!0),[k,A]=(0,m.useState)(null),[j,M]=(0,m.useState)(!1),[N,P]=(0,m.useState)(null),[F,I]=(0,m.useState)(!1),[L,R]=(0,m.useState)(null),[z,B]=(0,m.useState)(null),[xe,V]=(0,m.useState)(1),[H,Se]=c(pe),[Ce,U]=(0,m.useState)(null),W=(0,m.useRef)(null),{cls:we,play:G}=fe(),K=(0,m.useCallback)(async()=>{let e=await re(`requirements`);ge(e.tree),ve(e.totalFiles)},[]),q=(0,m.useCallback)(async(e=C)=>{A(null);try{let[t]=await Promise.all([f(`requirements`,e),K()]);E(t.entries),w(t.path)}catch(e){A(e instanceof Error?e.message:String(e))}},[C,K]);(0,m.useEffect)(()=>{let e=r(e=>t(!!e.requirements));return n().then(()=>{t(a(`requirements`)),b(!0)}),e},[]),(0,m.useEffect)(()=>{o&&e&&(async()=>{let e=await ce(`requirements`);if(he(e),e)try{let[e]=await Promise.all([f(`requirements`,`.`),K()]);E(e.entries),w(e.path)}catch(e){A(e instanceof Error?e.message:String(e))}})()},[o,e,K]);function Te(){be(e=>!e),D({})}async function J(e){G(),w(e),V(1),P(null),U(null),A(null);try{let t=await f(`requirements`,e);E(t.entries)}catch(e){A(e instanceof Error?e.message:String(e))}}async function Ee(e){I(!1),M(!0),A(null);try{await ne(`requirements`,C,e),await q(C)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}async function De(e){if(e.type===`file`){M(!0),A(null);try{await ie(`requirements`,e.path)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}async function Oe(e){if(e?.length){M(!0),A(null);try{for(let t of Array.from(e))await u(`requirements`,C,t);await q(C)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1),W.current&&(W.current.value=``)}}}function ke(e){let t=te(S,e.path),n=t?.fileCount??0,r=t?le(t):0;R({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Ae(e){R({name:e.name,path:e.path,isDir:!1})}function Y(e,t){B({...e,isDir:t})}async function je(){let e=L;if(e&&(R(null),!e.blocked)){M(!0),A(null);try{await oe(`requirements`,e.path),N&&d(N.path,e.path)&&P(null);let t=d(C,e.path)?ue(e.path):C;await q(t)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}async function Me(e){let t=z;if(t&&(B(null),e!==t.name)){M(!0),A(null);try{let n=await ae(`requirements`,t.path,e);await q(se(C,t.path,n))}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}let Ne=(()=>{if(!L)return``;if(!L.isDir)return`删除文件「${L.name}」?将移入系统废纸篓,可随时找回。`;if(L.blocked){let e=[];return L.files&&e.push(`${L.files} 个文件`),L.dirs&&e.push(`${L.dirs} 个子文件夹`),`文件夹「${L.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${L.name}」?将移入系统废纸篓。`})();async function Pe(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(!t.endsWith(`.md`)&&!t.endsWith(`.txt`))A(`仅 .md / .txt 支持就地预览;docx 请双击用本机程序打开。`);else{M(!0),A(null);try{let t=await l(`requirements`,e.path);P({path:t.path,content:t.content})}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}if(!o)return(0,h.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,h.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,h.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`requirements`)});if(x===null)return(0,h.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,h.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!x)return(0,h.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`需求文档库需要本地文档服务,当前未就绪。`});let X=T.filter(e=>e.type===`file`),Z=T.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/H)),$=Math.min(xe,Q),Fe=X.slice(($-1)*H,$*H);function Ie(e){G(),Se(e),V(1)}return(0,h.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,h.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,h.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>I(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,h.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1`,children:[(0,h.jsx)(`div`,{className:`group flex items-center rounded-md ${C===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),Te()},"aria-expanded":O,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${C===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,h.jsx)(g,{open:O,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,h.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,_e,`)`]})]})}),(0,h.jsx)(`div`,{className:`tw-collapse ${O?`is-open`:``}`,children:(0,h.jsx)(`div`,{className:`tw-collapse-inner`,children:S.map(e=>(0,h.jsx)(y,{node:e,depth:0,activePath:C,expanded:ye,globalOpen:O,onToggle:e=>D(t=>({...t,[e]:!(t[e]??O)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,h.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,h.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,h.jsx)(`span`,{className:`text-stone-400`,children:de(`requirements`)}),C===`.`?``:C]}),(0,h.jsx)(`input`,{ref:W,type:`file`,multiple:!0,accept:`.md,.txt,.docx,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document`,className:`hidden`,onChange:e=>void Oe(e.target.files)}),(0,h.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>W.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),k?(0,h.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:k}):null,(0,h.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,h.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,h.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,h.jsx)(g,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,h.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>ke({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,h.jsx)(v,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,h.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加需求文档(.md / .txt / .docx)`}):(0,h.jsx)(`ul`,{className:`${we}space-y-1`,children:Fe.map(e=>{let t=Ce===e.path;return(0,h.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${t?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{U(e.path),Pe(e)},onDoubleClick:t=>{t.preventDefault(),De(e)},children:[(0,h.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,h.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:me(e.size)})]}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,h.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>Ae(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,h.jsx)(v,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),N?(0,h.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:N.path}),(0,h.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>P(null),children:`关闭预览`})]}),(0,h.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:N.content})]}):null]}),X.length>0?(0,h.jsx)(ee,{page:$,totalPages:Q,pageSize:H,busy:j,onPage:e=>{G(),V(e)},onPageSize:Ie}):null]}),(0,h.jsx)(p,{open:F,title:`新建文件夹`,onClose:()=>I(!1),onConfirm:e=>void Ee(e)}),(0,h.jsx)(p,{open:z!=null,title:z?.isDir?`重命名文件夹`:`重命名文件`,label:z?.isDir?`文件夹名称`:`文件名称`,initialValue:z?.name??``,lockExtension:z!=null&&!z.isDir,confirmLabel:`保存`,onClose:()=>B(null),onConfirm:e=>void Me(e)}),(0,h.jsx)(s,{open:L!=null,title:L?.blocked?`无法删除文件夹`:L?.isDir?`删除文件夹`:`删除需求文件`,message:Ne,confirmLabel:L?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!L?.blocked,hideCancel:!!L?.blocked,onClose:()=>R(null),onConfirm:()=>void je()})]})}export{b as default};
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DUyozIL9.js";import{a as r,o as i,r as a}from"./plugins.BDZqJNOy.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{t as s}from"./ConfirmDialog.CBVsDJ8f.js";import{n as c,t as ee}from"./DocsPager.C20ue_JZ.js";import{a as te,c as ne,f as l,h as u,i as re,l as ie,m as ae,n as oe,o as d,p as se,r as ce,s as f,t as le,u as ue}from"./project-docs.Cd2gKPKh.js";import{n as de}from"./doc-roots.DAJP9Svr.js";import{t as fe}from"./useListAnim.CpGB1cft.js";import{t as p}from"./NamePromptDialog.Dl5kSnQI.js";var m=e(t(),1),h=o(),pe=5;function g({className:e=`w-4 h-4`,open:t=!1}){return(0,h.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,h.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,h.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function _({className:e=`w-3 h-3`}){return(0,h.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,h.jsx)(`path`,{d:`m15 5 4 4`})]})}function v({className:e=`w-3 h-3`}){return(0,h.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M3 6h18`}),(0,h.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,h.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,h.jsx)(`path`,{d:`M10 11v6`}),(0,h.jsx)(`path`,{d:`M14 11v6`})]})}function y({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,h.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,h.jsx)(g,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,h.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,h.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,h.jsx)(`div`,{className:`tw-collapse-inner`,children:e.children.map(e=>(0,h.jsx)(y,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function me(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function b(){let[e,t]=(0,m.useState)(()=>a(`requirements`)),[o,b]=(0,m.useState)(!1),[x,he]=(0,m.useState)(null),[S,ge]=(0,m.useState)([]),[_e,ve]=(0,m.useState)(0),[C,w]=(0,m.useState)(`.`),[T,E]=(0,m.useState)([]),[ye,D]=(0,m.useState)({}),[O,be]=(0,m.useState)(!0),[k,A]=(0,m.useState)(null),[j,M]=(0,m.useState)(!1),[N,P]=(0,m.useState)(null),[F,I]=(0,m.useState)(!1),[L,R]=(0,m.useState)(null),[z,B]=(0,m.useState)(null),[xe,V]=(0,m.useState)(1),[H,Se]=c(pe),[Ce,U]=(0,m.useState)(null),W=(0,m.useRef)(null),{cls:we,play:G}=fe(),K=(0,m.useCallback)(async()=>{let e=await re(`requirements`);ge(e.tree),ve(e.totalFiles)},[]),q=(0,m.useCallback)(async(e=C)=>{A(null);try{let[t]=await Promise.all([f(`requirements`,e),K()]);E(t.entries),w(t.path)}catch(e){A(e instanceof Error?e.message:String(e))}},[C,K]);(0,m.useEffect)(()=>{let e=r(e=>t(!!e.requirements));return n().then(()=>{t(a(`requirements`)),b(!0)}),e},[]),(0,m.useEffect)(()=>{o&&e&&(async()=>{let e=await ce(`requirements`);if(he(e),e)try{let[e]=await Promise.all([f(`requirements`,`.`),K()]);E(e.entries),w(e.path)}catch(e){A(e instanceof Error?e.message:String(e))}})()},[o,e,K]);function Te(){be(e=>!e),D({})}async function J(e){G(),w(e),V(1),P(null),U(null),A(null);try{let t=await f(`requirements`,e);E(t.entries)}catch(e){A(e instanceof Error?e.message:String(e))}}async function Ee(e){I(!1),M(!0),A(null);try{await ne(`requirements`,C,e),await q(C)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}async function De(e){if(e.type===`file`){M(!0),A(null);try{await ie(`requirements`,e.path)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}async function Oe(e){if(e?.length){M(!0),A(null);try{for(let t of Array.from(e))await u(`requirements`,C,t);await q(C)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1),W.current&&(W.current.value=``)}}}function ke(e){let t=te(S,e.path),n=t?.fileCount??0,r=t?le(t):0;R({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Ae(e){R({name:e.name,path:e.path,isDir:!1})}function Y(e,t){B({...e,isDir:t})}async function je(){let e=L;if(e&&(R(null),!e.blocked)){M(!0),A(null);try{await oe(`requirements`,e.path),N&&d(N.path,e.path)&&P(null);let t=d(C,e.path)?ue(e.path):C;await q(t)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}async function Me(e){let t=z;if(t&&(B(null),e!==t.name)){M(!0),A(null);try{let n=await ae(`requirements`,t.path,e);await q(se(C,t.path,n))}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}let Ne=(()=>{if(!L)return``;if(!L.isDir)return`删除文件「${L.name}」?将移入系统废纸篓,可随时找回。`;if(L.blocked){let e=[];return L.files&&e.push(`${L.files} 个文件`),L.dirs&&e.push(`${L.dirs} 个子文件夹`),`文件夹「${L.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${L.name}」?将移入系统废纸篓。`})();async function Pe(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(!t.endsWith(`.md`)&&!t.endsWith(`.txt`))A(`仅 .md / .txt 支持就地预览;docx 请双击用本机程序打开。`);else{M(!0),A(null);try{let t=await l(`requirements`,e.path);P({path:t.path,content:t.content})}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}if(!o)return(0,h.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,h.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,h.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`requirements`)});if(x===null)return(0,h.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,h.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!x)return(0,h.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`需求文档库需要本地文档服务,当前未就绪。`});let X=T.filter(e=>e.type===`file`),Z=T.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/H)),$=Math.min(xe,Q),Fe=X.slice(($-1)*H,$*H);function Ie(e){G(),Se(e),V(1)}return(0,h.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,h.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,h.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>I(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,h.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1`,children:[(0,h.jsx)(`div`,{className:`group flex items-center rounded-md ${C===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),Te()},"aria-expanded":O,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${C===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,h.jsx)(g,{open:O,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,h.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,_e,`)`]})]})}),(0,h.jsx)(`div`,{className:`tw-collapse ${O?`is-open`:``}`,children:(0,h.jsx)(`div`,{className:`tw-collapse-inner`,children:S.map(e=>(0,h.jsx)(y,{node:e,depth:0,activePath:C,expanded:ye,globalOpen:O,onToggle:e=>D(t=>({...t,[e]:!(t[e]??O)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,h.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,h.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,h.jsx)(`span`,{className:`text-stone-400`,children:de(`requirements`)}),C===`.`?``:C]}),(0,h.jsx)(`input`,{ref:W,type:`file`,multiple:!0,accept:`.md,.txt,.docx,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document`,className:`hidden`,onChange:e=>void Oe(e.target.files)}),(0,h.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>W.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),k?(0,h.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:k}):null,(0,h.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,h.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,h.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,h.jsx)(g,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,h.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>ke({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,h.jsx)(v,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,h.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加需求文档(.md / .txt / .docx)`}):(0,h.jsx)(`ul`,{className:`${we}space-y-1`,children:Fe.map(e=>{let t=Ce===e.path;return(0,h.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${t?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{U(e.path),Pe(e)},onDoubleClick:t=>{t.preventDefault(),De(e)},children:[(0,h.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,h.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:me(e.size)})]}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,h.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>Ae(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,h.jsx)(v,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),N?(0,h.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:N.path}),(0,h.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>P(null),children:`关闭预览`})]}),(0,h.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:N.content})]}):null]}),X.length>0?(0,h.jsx)(ee,{page:$,totalPages:Q,pageSize:H,busy:j,onPage:e=>{G(),V(e)},onPageSize:Ie}):null]}),(0,h.jsx)(p,{open:F,title:`新建文件夹`,onClose:()=>I(!1),onConfirm:e=>void Ee(e)}),(0,h.jsx)(p,{open:z!=null,title:z?.isDir?`重命名文件夹`:`重命名文件`,label:z?.isDir?`文件夹名称`:`文件名称`,initialValue:z?.name??``,lockExtension:z!=null&&!z.isDir,confirmLabel:`保存`,onClose:()=>B(null),onConfirm:e=>void Me(e)}),(0,h.jsx)(s,{open:L!=null,title:L?.blocked?`无法删除文件夹`:L?.isDir?`删除文件夹`:`删除需求文件`,message:Ne,confirmLabel:L?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!L?.blocked,hideCancel:!!L?.blocked,onClose:()=>R(null),onConfirm:()=>void je()})]})}export{b as default};
|