2026-05-13 12:43:01 +08:00
|
|
|
<template>
|
2026-10-26 01:19:23 +08:00
|
|
|
<div class="admin-layout">
|
|
|
|
|
<a-layout>
|
|
|
|
|
<a-layout-sider v-if="!isMobile" v-model:collapsed="collapsed" :trigger="null" collapsible class="sider" :width="236" :collapsed-width="76">
|
|
|
|
|
<div class="logo"><span class="logo-mark">S</span><strong v-if="!collapsed">Salon</strong></div>
|
|
|
|
|
<a-menu :selectedKeys="selectedKeys" mode="inline" theme="dark" @click="handleMenuClick">
|
|
|
|
|
<a-menu-item v-for="item in menuItems" :key="item.key">
|
|
|
|
|
<template #icon><component :is="item.icon" /></template>
|
|
|
|
|
<span>{{ item.label }}</span>
|
|
|
|
|
</a-menu-item>
|
|
|
|
|
</a-menu>
|
|
|
|
|
</a-layout-sider>
|
|
|
|
|
|
2026-05-13 12:43:01 +08:00
|
|
|
<a-layout>
|
2026-10-26 01:19:23 +08:00
|
|
|
<a-layout-header class="header">
|
|
|
|
|
<div class="header-shell">
|
|
|
|
|
<div class="header-left">
|
|
|
|
|
<button v-if="!isMobile" class="trigger" type="button" aria-label="收起导航" @click="collapsed = !collapsed">
|
|
|
|
|
<MenuUnfoldOutlined v-if="collapsed" /><MenuFoldOutlined v-else />
|
|
|
|
|
</button>
|
|
|
|
|
<button v-else class="trigger" type="button" aria-label="打开导航" @click="mobileDrawerOpen = true"><MenuOutlined /></button>
|
|
|
|
|
<div class="header-title"><span>Salon 管理驾驶舱</span><small>平台经营数据与运营事项</small></div>
|
|
|
|
|
</div>
|
|
|
|
|
<a-dropdown>
|
|
|
|
|
<button class="user-dropdown" type="button">
|
|
|
|
|
<a-avatar :size="32" :src="userInfo?.avatar || DEFAULT_AVATAR" />
|
|
|
|
|
<span>{{ userInfo?.nickname || '平台管理员' }}</span><DownOutlined />
|
|
|
|
|
</button>
|
|
|
|
|
<template #overlay>
|
|
|
|
|
<a-menu>
|
|
|
|
|
<a-menu-item key="profile" @click="router.push('/admin/profile')">个人设置</a-menu-item>
|
|
|
|
|
<a-menu-divider />
|
|
|
|
|
<a-menu-item key="logout" @click="handleLogout">退出登录</a-menu-item>
|
|
|
|
|
</a-menu>
|
2026-05-13 12:43:01 +08:00
|
|
|
</template>
|
2026-10-26 01:19:23 +08:00
|
|
|
</a-dropdown>
|
|
|
|
|
</div>
|
|
|
|
|
</a-layout-header>
|
|
|
|
|
<a-layout-content class="content"><router-view /></a-layout-content>
|
2026-05-13 12:43:01 +08:00
|
|
|
</a-layout>
|
2026-10-26 01:19:23 +08:00
|
|
|
</a-layout>
|
2026-05-13 12:43:01 +08:00
|
|
|
|
2026-10-26 01:19:23 +08:00
|
|
|
<a-drawer v-if="isMobile" v-model:open="mobileDrawerOpen" placement="left" :width="300" :closable="false">
|
|
|
|
|
<div class="drawer-brand"><span class="logo-mark">S</span><strong>Salon 管理后台</strong></div>
|
|
|
|
|
<a-menu :selectedKeys="selectedKeys" mode="inline" @click="openMobileMenu">
|
|
|
|
|
<a-menu-item v-for="item in menuItems" :key="item.key"><template #icon><component :is="item.icon" /></template>{{ item.label }}</a-menu-item>
|
|
|
|
|
</a-menu>
|
|
|
|
|
<a-button danger block class="drawer-logout" @click="handleLogout">退出登录</a-button>
|
|
|
|
|
</a-drawer>
|
2026-05-13 12:43:01 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-10-26 01:19:23 +08:00
|
|
|
import { onMounted, ref, watch } from 'vue'
|
2026-05-13 12:43:01 +08:00
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
|
|
import { message, Modal } from 'ant-design-vue'
|
2026-10-26 01:19:23 +08:00
|
|
|
import { DownOutlined, HomeOutlined, MenuFoldOutlined, MenuOutlined, MenuUnfoldOutlined, SafetyCertificateOutlined, TeamOutlined, ToolOutlined, UserOutlined } from '@ant-design/icons-vue'
|
2026-06-23 15:33:06 +08:00
|
|
|
import type { Component } from 'vue'
|
2026-10-26 01:19:23 +08:00
|
|
|
import { adminNavigationItems, type AdminNavIconKey } from '@/config/admin-navigation'
|
2026-05-13 12:43:01 +08:00
|
|
|
import { DEFAULT_AVATAR } from '@/constants'
|
2026-10-10 16:08:46 +08:00
|
|
|
import { completeAdminLogout } from '@/utils/admin-logout'
|
2026-10-26 01:19:23 +08:00
|
|
|
import { runWithGlobalLoading } from '@/utils/action-loading'
|
2026-05-13 12:43:01 +08:00
|
|
|
import { useAdminViewport } from '@/composables/useAdminViewport'
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const { isMobile } = useAdminViewport()
|
|
|
|
|
const collapsed = ref(false)
|
|
|
|
|
const mobileDrawerOpen = ref(false)
|
|
|
|
|
const selectedKeys = ref<string[]>([route.path])
|
2026-10-26 01:19:23 +08:00
|
|
|
const userInfo = ref<any>(null)
|
|
|
|
|
const iconMap: Record<AdminNavIconKey, Component> = { home: HomeOutlined, user: UserOutlined, shop: HomeOutlined, security: SafetyCertificateOutlined, tool: ToolOutlined, team: TeamOutlined, dashboard: HomeOutlined, gift: HomeOutlined, message: HomeOutlined, tag: HomeOutlined, shopping: HomeOutlined, calendar: HomeOutlined }
|
|
|
|
|
const menuItems = adminNavigationItems.map(item => ({ key: item.path, label: item.label, icon: iconMap[item.iconKey] }))
|
2026-05-13 12:43:01 +08:00
|
|
|
|
2026-10-26 01:19:23 +08:00
|
|
|
const handleMenuClick = ({ key }: { key: string | number }) => router.push(String(key))
|
|
|
|
|
const openMobileMenu = ({ key }: { key: string | number }) => { mobileDrawerOpen.value = false; router.push(String(key)) }
|
|
|
|
|
const handleLogout = () => Modal.confirm({ title: '确认退出登录', content: '退出后需要重新登录后台。', okText: '确认', cancelText: '取消', onOk: async () => { await runWithGlobalLoading(() => completeAdminLogout(router)); message.success('已退出登录') } })
|
2026-06-23 15:33:06 +08:00
|
|
|
|
2026-10-26 01:19:23 +08:00
|
|
|
watch(() => route.path, path => { selectedKeys.value = [path] }, { immediate: true })
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
try { userInfo.value = JSON.parse(localStorage.getItem('adminUserInfo') || 'null') } catch { userInfo.value = null }
|
2026-05-13 12:43:01 +08:00
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2026-10-26 01:19:23 +08:00
|
|
|
.admin-layout { min-height: 100vh; background: var(--theme-page-bg); }
|
|
|
|
|
.sider { position: fixed; inset: 0 auto 0 0; z-index: 10; overflow: auto; background: #173f3b; }
|
|
|
|
|
.logo, .drawer-brand { display: flex; align-items: center; gap: 10px; height: 72px; padding: 0 22px; color: #fff; font-size: 18px; letter-spacing: .02em; }
|
|
|
|
|
.logo-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: #5bc3a7; color: #17423c; font-weight: 900; }
|
|
|
|
|
.header { position: sticky; top: 0; z-index: 8; height: 72px; padding: 0 28px; background: rgba(255, 255, 255, .88); border-bottom: 1px solid var(--admin-mobile-border); backdrop-filter: blur(12px); }
|
|
|
|
|
.header-shell { display: flex; align-items: center; justify-content: space-between; height: 100%; gap: 20px; }
|
|
|
|
|
.header-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
|
|
|
|
|
.trigger { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: #54736e; cursor: pointer; font-size: 18px; }
|
|
|
|
|
.trigger:hover { background: #e7f5f0; color: #218d78; }
|
|
|
|
|
.header-title { display: grid; gap: 3px; color: #224d47; }
|
|
|
|
|
.header-title span { font-size: 15px; font-weight: 800; }
|
|
|
|
|
.header-title small { color: #89a09b; font-size: 11px; }
|
|
|
|
|
.user-dropdown { display: flex; align-items: center; gap: 9px; border: 0; background: transparent; color: #315650; cursor: pointer; font-weight: 700; }
|
|
|
|
|
.content { min-height: calc(100vh - 72px); padding: 30px clamp(20px, 4vw, 54px); }
|
|
|
|
|
.content :deep(.ant-table) { table-layout: auto; width: max-content; min-width: 100%; }
|
|
|
|
|
.content :deep(.ant-table-cell) { word-break: keep-all; }
|
|
|
|
|
.drawer-logout { margin-top: 28px; }
|
|
|
|
|
@media (max-width: 760px) { .header { padding: 0 16px; } .header-title small { display: none; } .content { padding: 18px 14px 28px; } }
|
2026-05-13 12:43:01 +08:00
|
|
|
</style>
|