import{W as g,h as r,C as y,u as k,G as f}from"./index-BKsb6cIX.js";import{c as q}from"./client-BoY9t-gR.js";function S(a){const s=a?{periodId:a}:{};return q.get("/workspace/overview",{params:s})}const A=g("workspace",()=>{const a=r(null),s=r([]),c=r(null),l=r([]),i=r([]),d=r(null),v=r([]),m=r([]),n=r(!1),u=r(null),w=y(()=>!!a.value),h=y(()=>{var o;try{const t=f();if(t.query.periodId)return Number(t.query.periodId)}catch{}return((o=a.value)==null?void 0:o.id)||null});async function p(o){n.value=!0,u.value=null;try{const e=(await S(o)).data;a.value=e.recommendedPeriod,s.value=e.availablePeriods||[],c.value=e.currentPhase,l.value=e.myTodos||[],i.value=e.allowedActions||[],d.value=e.teamSummary,v.value=e.risks||[],m.value=e.upcomingDeadlines||[]}catch(t){u.value=t.message||"加载工作台失败"}finally{n.value=!1}}async function P(o){try{const t=k(),e=f();t.replace({query:{...e.query,periodId:o}})}catch{}await p(o)}return{currentPeriod:a,availablePeriods:s,currentPhase:c,todos:l,allowedActions:i,teamSummary:d,risks:v,deadlines:m,loading:n,error:u,hasPeriod:w,periodId:h,refreshOverview:p,selectPeriod:P}});export{A as u};
