1 line
9.0 KiB
JavaScript
1 line
9.0 KiB
JavaScript
import{$ as e,L as t,U as n,Ut as r,V as i,Vt as a,Wt as o,_ as s,_t as c,d as l,f as u,i as d,l as f,lt as p,p as m,u as h,v as g,z as _}from"./runtime-core.esm-bundler-DbRZbT7v.js";import{c as v,i as y,o as b,r as x,s as S,u as C}from"./index-3YculFMX.js";import"./request-DD5g7hLU.js";import{t as w}from"./user-BFl2lhly.js";import{t as T}from"./iconify-f5JHLb1p.js";var E={class:`flex flex-col h-full bg-white border-r border-gray-100 overflow-hidden`},D={class:`flex items-center gap-3 px-5 py-4 border-b border-gray-50 flex-shrink-0`,style:{height:`64px`}},O={class:`w-9 h-9 bg-rose-500 rounded-xl flex items-center justify-center flex-shrink-0 shadow-sm`},k={key:0,class:`overflow-hidden`},A={class:`text-[10px] bg-rose-100 text-rose-600 px-1.5 py-0.5 rounded font-bold tracking-wider`},ee={class:`flex-1 overflow-y-auto no-scrollbar py-3 px-3 space-y-0.5`},j={key:0,class:`text-sm font-medium truncate`},M={key:1,class:`ml-auto w-1.5 h-1.5 rounded-full bg-rose-500 flex-shrink-0`},N={key:0,class:`text-[10px] font-bold text-gray-300 uppercase tracking-widest px-3 pt-4 pb-1.5`},P={key:1,class:`my-2 mx-2 h-px bg-gray-100`},F=[`onClick`],I={key:0,class:`text-sm font-medium truncate`},L={key:1,class:`ml-auto w-1.5 h-1.5 rounded-full bg-rose-500 flex-shrink-0`},R=[`onClick`],z={key:0,class:`text-sm font-medium truncate`},B={key:1,class:`ml-auto w-1.5 h-1.5 rounded-full bg-rose-500 flex-shrink-0`},V={class:`flex-shrink-0 p-3 border-t border-gray-50`},H={class:`w-9 h-9 rounded-full bg-rose-100 flex items-center justify-center flex-shrink-0 text-rose-500 font-bold text-sm`},U={key:0,class:`flex-1 overflow-hidden`},W={class:`text-sm font-bold text-gray-800 truncate`},G={class:`text-[11px] text-gray-400 truncate`},K={__name:`Sidebar`,props:{collapsed:{type:Boolean,default:!1}},setup(e){let n=x(),r=y(),i=w(),s=f(()=>n.path),l=f(()=>i.menus),p=f(()=>i.userInfo?.name||i.userInfo?.username||`用户`),v=f(()=>i.userInfo?.store?.name||``),b=f(()=>i.userInfo?.is_super?`SUPER ADMIN`:`STORE ADMIN`),S={Odometer:`solar:widget-add-bold-duotone`,House:`solar:home-bold-duotone`,User:`solar:users-group-rounded-bold-duotone`,UserFilled:`solar:users-group-rounded-bold-duotone`,ShoppingCart:`solar:cart-large-bold-duotone`,Goods:`solar:cart-large-bold-duotone`,OfficeBuilding:`solar:bed-bold-duotone`,HeartPulse:`solar:heart-pulse-bold-duotone`,Food:`solar:cup-bold`,Trophy:`solar:health-bold`,Avatar:`solar:user-speak-bold-duotone`,Box:`solar:box-bold-duotone`,Money:`solar:money-bag-bold-duotone`,Wallet:`solar:money-bag-bold-duotone`,Suitcase:`solar:users-group-two-rounded-bold-duotone`,Connection:`solar:streets-navigation-bold-duotone`,DataLine:`solar:chart-2-bold-duotone`,Reading:`solar:book-bookmark-bold-duotone`,Setting:`solar:settings-bold-duotone`,Tools:`solar:settings-bold-duotone`,Menu:`solar:list-bold-duotone`};function K(e){return S[e]||`solar:circle-bold-duotone`}function q(e){return e.path&&s.value.startsWith(e.path)?!0:e.children?e.children.some(e=>q(e)):!1}function J(e){e&&r.push(e)}async function Y(){await i.logout(),r.push(`/login`)}return(n,r)=>(t(),m(`div`,E,[h(`div`,D,[h(`div`,O,[g(c(T),{icon:`solar:heart-bold`,class:`text-white text-lg`})]),e.collapsed?u(``,!0):(t(),m(`div`,k,[r[1]||=h(`h2`,{class:`font-bold text-gray-800 text-sm leading-tight`},`宫中有喜`,-1),h(`span`,A,o(b.value),1)]))]),h(`nav`,ee,[h(`button`,{class:a([`w-full flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-150 text-left`,s.value===`/dashboard`?`bg-rose-50 text-rose-500`:`text-gray-500 hover:bg-gray-50 hover:text-gray-700`]),onClick:r[0]||=e=>J(`/dashboard`)},[g(c(T),{icon:`solar:widget-add-bold-duotone`,class:`text-xl flex-shrink-0`}),e.collapsed?u(``,!0):(t(),m(`span`,j,`工作台`)),!e.collapsed&&s.value===`/dashboard`?(t(),m(`div`,M)):u(``,!0)],2),(t(!0),m(d,null,_(l.value,n=>(t(),m(d,{key:n.id||n.path},[n.children&&n.children.length>0&&n.visible!==0?(t(),m(d,{key:0},[e.collapsed?(t(),m(`div`,P)):(t(),m(`div`,N,o(n.name),1)),(t(!0),m(d,null,_(n.children.filter(e=>e.visible!==0),n=>(t(),m(`button`,{key:n.id||n.path,class:a([`w-full flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-150 text-left`,q(n)?`bg-rose-50 text-rose-500`:`text-gray-500 hover:bg-gray-50 hover:text-gray-700`]),onClick:e=>J(n.path)},[g(c(T),{icon:K(n.icon),class:`text-xl flex-shrink-0`},null,8,[`icon`]),e.collapsed?u(``,!0):(t(),m(`span`,I,o(n.name),1)),!e.collapsed&&q(n)?(t(),m(`div`,L)):u(``,!0)],10,F))),128))],64)):n.visible===0?u(``,!0):(t(),m(`button`,{key:1,class:a([`w-full flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-150 text-left`,q(n)?`bg-rose-50 text-rose-500`:`text-gray-500 hover:bg-gray-50 hover:text-gray-700`]),onClick:e=>J(n.path)},[g(c(T),{icon:K(n.icon),class:`text-xl flex-shrink-0`},null,8,[`icon`]),e.collapsed?u(``,!0):(t(),m(`span`,z,o(n.name),1)),!e.collapsed&&q(n)?(t(),m(`div`,B)):u(``,!0)],10,R))],64))),128))]),h(`div`,V,[h(`div`,{class:a([`flex items-center gap-3 p-3 bg-gray-50 rounded-2xl`,e.collapsed?`justify-center`:``])},[h(`div`,H,o(p.value.charAt(0)),1),e.collapsed?u(``,!0):(t(),m(`div`,U,[h(`p`,W,o(p.value),1),h(`p`,G,o(v.value||`总部管理`),1)])),e.collapsed?u(``,!0):(t(),m(`button`,{key:1,class:`flex-shrink-0 p-1.5 text-rose-400 hover:bg-rose-100 rounded-lg transition-colors`,title:`退出登录`,onClick:C(Y,[`stop`])},[g(c(T),{icon:`solar:logout-bold-duotone`,class:`text-lg`})]))],2)])]))}},q={class:`flex items-center justify-between h-full px-8 bg-white border-b border-gray-100`},J={class:`flex items-center gap-4`},Y={class:`text-base font-bold text-gray-800`},X={class:`flex items-center text-xs text-gray-400 gap-1.5`},Z={class:`flex items-center gap-5`},Q={class:`relative cursor-pointer`},te={class:`flex items-center gap-1.5 text-sm text-gray-500 cursor-pointer hover:text-gray-700`},ne={class:`flex items-center gap-2.5 cursor-pointer px-3 py-1.5 rounded-xl hover:bg-gray-50 transition-colors`},re={class:`w-8 h-8 rounded-full bg-rose-100 flex items-center justify-center text-rose-500 font-bold text-sm`},ie={class:`text-sm font-medium text-gray-700`},ae={__name:`Header`,props:{collapsed:{type:Boolean,default:!1}},emits:[`toggle-sidebar`],setup(n,{emit:r}){let a=r,l=y(),u=x(),d=w(),p=f(()=>d.userInfo?.name||d.userInfo?.username||`用户`),_=f(()=>d.userInfo?.store?.name||`所有门店 (总览)`),v=f(()=>{let e=u.matched.filter(e=>e.meta?.title&&!e.meta?.hidden);return e.length?e[e.length-1].meta.title:`工作台`}),C=f(()=>{let e=new Date;return`${e.getFullYear()}年${e.getMonth()+1}月${e.getDate()}日 ${[`星期日`,`星期一`,`星期二`,`星期三`,`星期四`,`星期五`,`星期六`][e.getDay()]}`});async function E(){await b.confirm(`确定要退出登录吗?`,`提示`,{confirmButtonText:`确定`,cancelButtonText:`取消`,type:`warning`}),await d.logout(),l.push(`/login`),S.success(`已安全退出`)}return(r,l)=>{let u=i(`el-dropdown-item`),d=i(`el-dropdown-menu`),f=i(`el-dropdown`);return t(),m(`div`,q,[h(`div`,J,[h(`button`,{class:`p-2 rounded-xl hover:bg-gray-50 text-gray-400 hover:text-gray-600 transition-colors`,onClick:l[0]||=e=>a(`toggle-sidebar`)},[g(c(T),{icon:(n.collapsed,`solar:sidebar-minimalistic-bold`),class:`text-xl`},null,8,[`icon`])]),h(`h3`,Y,o(v.value),1),l[1]||=h(`div`,{class:`h-4 w-px bg-gray-200`},null,-1),h(`div`,X,[g(c(T),{icon:`solar:calendar-bold`,class:`text-sm`}),h(`span`,null,o(C.value),1)])]),h(`div`,Z,[h(`div`,Q,[g(c(T),{icon:`solar:bell-bing-bold-duotone`,class:`text-2xl text-gray-400 hover:text-rose-500 transition-colors`}),l[2]||=h(`span`,{class:`absolute -top-1 -right-1 w-4 h-4 bg-rose-500 text-white text-[9px] rounded-full flex items-center justify-center font-bold border-2 border-white`},`3`,-1)]),h(`div`,te,[h(`span`,null,o(_.value),1),g(c(T),{icon:`solar:alt-arrow-down-bold-duotone`,class:`text-xs text-gray-400`})]),g(f,{trigger:`click`,placement:`bottom-end`},{dropdown:e(()=>[g(d,null,{default:e(()=>[g(u,null,{default:e(()=>[g(c(T),{icon:`solar:user-bold-duotone`,class:`mr-2`}),l[3]||=s(` 个人信息 `,-1)]),_:1}),g(u,{divided:``,onClick:E},{default:e(()=>[g(c(T),{icon:`solar:logout-bold-duotone`,class:`mr-2`}),l[4]||=s(` 退出登录 `,-1)]),_:1})]),_:1})]),default:e(()=>[h(`div`,ne,[h(`div`,re,o(p.value.charAt(0)),1),h(`span`,ie,o(p.value),1),g(c(T),{icon:`solar:alt-arrow-down-bold-duotone`,class:`text-xs text-gray-400`})])]),_:1})])])}}},oe={class:`flex h-screen overflow-hidden`},$={class:`flex flex-col flex-1 overflow-hidden`},se={class:`flex-shrink-0`,style:{height:`64px`}},ce={class:`flex-1 overflow-y-auto no-scrollbar`,style:{background:`#f8fafc`}},le={__name:`index`,setup(a){let o=p(!1);function s(){o.value=!o.value}return(a,c)=>{let u=i(`router-view`);return t(),m(`div`,oe,[h(`aside`,{class:`flex-shrink-0 z-10`,style:r({width:o.value?`64px`:`256px`,transition:`width 0.25s ease`})},[g(K,{collapsed:o.value},null,8,[`collapsed`])],4),h(`div`,$,[h(`header`,se,[g(ae,{collapsed:o.value,onToggleSidebar:s},null,8,[`collapsed`])]),h(`main`,ce,[g(u,null,{default:e(({Component:r,route:i})=>[g(v,{name:`fade-slide`,mode:`out-in`},{default:e(()=>[(t(),l(n(r),{key:i.fullPath}))]),_:2},1024)]),_:1})])])])}}};export{le as default}; |