import{k as e,u as s,n as t,c as l,S as n,j as a,D as d,U as o,p as i,M as r,q as c,s as u,b as p,d as h,r as m,t as y,v as f,w as g,x as v,y as K,R as b}from"./vendor.98dba853.js";import{s as w}from"./index.f608f11e.js";const k=h=>{const m=e(),y=s(),f=t((()=>m.path)),g=t((()=>"string"==typeof h.logo?l("img",{src:h.logo,alt:"logo",class:"header-logo-img"},null):h.logo));return l("div",{class:"header"},[l("div",{class:"header-logo"},[g.value||l(n,{class:"header-logo-img"},null),l("span",{class:"header-logo-title"},[h.title])]),l("div",{class:"header-menu"},[h.menus&&h.menus.map((e=>l(a,{to:e.path,class:f.value.startsWith(e.path)?"menuItem active":"menuItem"},{default:()=>[e.title]})))]),h.hiddenUser?h.rightNode:l("div",{class:"header-user"},[l(d,{trigger:["click","hover"]},{default:()=>[l("a",{class:"ant-dropdown-link"},[l(o,{class:"circle"},null),h.user&&h.user.info?h.user.info.username:""," ",l(i,null,null)])],overlay:()=>l(r,{class:"header-user-menu"},{default:()=>[h.userLinks&&h.userLinks.map((e=>l(c,{onClick:()=>y.push(e.path)},{default:()=>[e.title]}))),l(u,null,null),l(c,{onClick:()=>h.user&&h.user.logout&&h.user.logout()},{default:()=>[p("退出")]})]})})])])};const j=h({name:"SiderBar",props:{menus:{type:Object,require:!1},classNames:{type:Array,required:!1},hidden:{type:Boolean,required:!1},width:{type:Number,required:!1},theme:{type:String,required:!1},collapsed:{type:Boolean,required:!1},title:{type:String,required:!1}},setup:(t,{slots:n})=>{var a;console.log("props:: ",t);const d=s(),o=e(),i=m({rootSubmenuKeys:(null==(a=t.menus)?void 0:a.filter((e=>e.children&&e.children.length)).map((e=>e.path)))||[],openKeys:[],selectedKeys:[]});y((()=>{if(i.selectedKeys.length>0||i.openKeys.length>0)return;const e=s=>{const t=s.find((s=>o.path==s.path||s.children&&s.children.length&&e(s.children)));if(t)return(null==t?void 0:t.path)==o.path?t:(i.openKeys=[t.path],e(null==t?void 0:t.children))},s=t.menus?e(t.menus):null,l=s&&s.path?[s.path]:[];l.toString()!=i.selectedKeys.toString()&&(i.selectedKeys=l)}));const u=e=>{const s=e.find((e=>-1===i.openKeys.indexOf(e)));-1===i.rootSubmenuKeys.indexOf(s)?i.openKeys=e:i.openKeys=s?[s]:[]};console.log("selectedKeys",o.path,i.selectedKeys,t.collapsed);const p=e=>{if(e&&e.children&&e.children.length){let t;return l(g,{title:e.title,icon:e.icon,key:e.path},"function"==typeof(s=t=e.children.map((e=>p(e))))||"[object Object]"===Object.prototype.toString.call(s)&&!f(s)?t:{default:()=>[t]})}{const s=e;return l(c,v({key:s.path},s,{onClick:()=>{s.path&&(i.selectedKeys=[s.path],d.push(s.path))}}),{default:()=>[s.title]})}var s};return()=>l("div",{class:"siderbar-menu"+(t.classNames?t.classNames.join(" "):""),style:{width:t.width||200,display:t.hidden?"none":"block"}},[l("h3",{style:{color:"dark"==t.theme?"#ffffff":"#212121"}},[t.title]),t.menus?l(r,{style:{width:t.width},mode:"inline",selectedKeys:i.selectedKeys,"onUpdate:selectedKeys":e=>i.selectedKeys=e,openKeys:i.openKeys,"onUpdate:openKeys":e=>i.openKeys=e,onOpenChange:u,selectable:!0,theme:t.theme,inlineCollapsed:t.collapsed},{default:()=>[t.menus&&t.menus.map((e=>p(e)))]}):null,n.default?n.default():null])}});const S=e=>{const s=t((()=>{const s=e.sider||{};return s.hidden?{content:{width:"100%",marginLeft:0},sider:{display:"none",width:0}}:{content:{width:`calc( 100% - ${s.width||200}px )`,marginLeft:`${s.width||200}px`},sider:{display:"block",width:`${s.width||200}px`}}}));return l("div",{class:e.classNames?e.classNames.join(" "):""},[l(k,e.header,null),l("div",{class:"home"},[l("div",{class:"home-siderbar",style:s.value.sider},[l(j,e.sider,null)]),l("div",{class:"home-content",style:s.value.content},[l("div",{class:"home-content-div"},[l(b,{name:"default"},null)])])])])};var q=h({setup:()=>(w.dispatch("app/getCurrent"),()=>w.state.app.loading?l("div",{class:"loading-page"},[l(K,null,null)]):l(S,{sider:w.state.app.sider,header:w.state.app.header},null))});export{q as default};
