import{j as e,r as s}from"./jsx-runtime-BnbLqBWP.js";import{c as t}from"./utils-G3MRPmKb.js";import{N as a,F as o,u as r,k as n}from"./components-B5_r6Vif.js";import{c as l}from"./createLucideIcon-5uNZVGyg.js";import{U as i}from"./users-Bd57yQVv.js";import{C as m}from"./clipboard-list-mA7UxNRU.js";import{S as d}from"./settings-B1qOMCUt.js";import{a as c,O as x}from"./index-C4j0XBvN.js";import"./_commonjsHelpers-TUi1EdFu.js";import"./router-BXPf1XsM.js";import"./single-fetch-vTdWVr6V.js"; /** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h=l("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]),u=l("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);function p({isMobile:s,userRole:r="user"}){const n=[{to:"/my-tasks",icon:e.jsx(m,{className:s?"h-5 w-5":"h-4 w-4"}),label:"我的任务",roles:["admin","user","super-admin"]},{to:"/settings",icon:e.jsx(d,{className:s?"h-5 w-5":"h-4 w-4"}),label:"系统设置",roles:["admin","super-admin"]}],l=[...[{to:"/tasks",icon:e.jsx(h,{className:s?"h-5 w-5":"h-4 w-4"}),label:"任务管理",roles:["admin","super-admin"]},{to:"/users",icon:e.jsx(i,{className:s?"h-5 w-5":"h-4 w-4"}),label:"用户管理",roles:["admin","super-admin"]}],...n].filter((e=>e.roles.includes(r)));return s?e.jsxs("nav",{className:"flex items-center justify-around h-[4.5rem]",children:[l.map((s=>e.jsxs(a,{to:s.to,className:({isActive:e})=>t("flex flex-col items-center gap-1.5 py-2",e?"text-primary":"text-muted-foreground"),children:[s.icon,e.jsx("span",{className:"text-xs font-medium",children:s.label})]},s.to))),e.jsx(o,{method:"post",action:"/logout",children:e.jsxs("button",{type:"submit",className:"flex flex-col items-center gap-1.5 py-2 text-muted-foreground",children:[e.jsx(u,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"退出登录"})]})})]}):e.jsxs("nav",{className:"grid gap-0",children:[l.map((s=>e.jsxs(a,{to:s.to,className:({isActive:e})=>t("flex items-center gap-2 p-2 text-sm rounded-md hover:bg-muted",e&&"bg-muted font-medium"),children:[s.icon,s.label]},s.to))),e.jsx(o,{method:"post",action:"/logout",className:"mt-auto",children:e.jsxs("button",{type:"submit",className:"flex items-center gap-2 p-2 text-sm rounded-md hover:bg-muted text-red-500 w-full text-left",children:[e.jsx(u,{className:"h-4 w-4"}),"退出登录"]})})]})}function f(){const{user:t,envAvailable:a}=r(),o=n(),l=o[o.length-1],i=!!l?.handle&&l.handle.hideNavigation,[m,d]=s.useState(t?.name||null),[h,u]=s.useState(!!t),[f,j]=s.useState(t?.role||"user");return c(),s.useEffect((()=>{if(t)return d(t.name),u(!0),void j(t.role||"user");const e=()=>{const e=localStorage.getItem("userInfo");if(e)try{const s=JSON.parse(e);d(s.name||s.userName||"用户"),u(!0),j(s.role||"user")}catch(s){console.error("解析用户信息失败",s),u(!1),d(null),j("user")}else u(!1),d(null),j("user")};e();const s=()=>{e()};return window.addEventListener("storage",s),()=>{window.removeEventListener("storage",s)}}),[t]),s.useEffect((()=>{const e=document.createElement("style");return e.innerHTML="\n @media (max-width: 768px) {\n table {\n width: 100% !important;\n display: block;\n overflow-x: auto;\n }\n \n /* 确保表格单元格不会过宽 */\n table td, table th {\n white-space: nowrap;\n max-width: 150px;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n }\n ",document.head.appendChild(e),()=>{e&&e.parentNode===document.head&&document.head.removeChild(e)}}),[]),e.jsx("div",{className:"flex flex-col min-h-screen hunter-workers-app _app",children:e.jsxs("div",{className:"md:container md:mx-auto px-0 md:px-4 flex flex-col md:flex-row flex-1",children:[!i&&h&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden md:block w-56 py-4 border-r",children:[e.jsxs("div",{className:"flex items-center px-2 py-2 mb-6",children:[e.jsx("img",{src:"/logo.svg",alt:"Logo",className:"h-8 w-8 mr-2"}),e.jsx("h1",{className:"text-xl font-bold",children:"全民买手"})]}),e.jsx(p,{userRole:f})]}),e.jsx("div",{className:"md:hidden fixed bottom-0 left-0 right-0 border-t bg-white z-10",children:e.jsx(p,{isMobile:!0,userRole:f})})]}),e.jsx("div",{className:`flex-1 md:px-6 py-4 pb-20 md:pb-4 ${i?"":"md:ml-6"} bg-white`,children:e.jsx(x,{context:a})})]})})}export{f as default};