style(salon-admin): 管理后台移除页面说明块并改造面包屑与侧栏折叠按钮
自动发布开发环境 Nacos 配置 / publish (push) Successful in 19s

This commit is contained in:
2026-11-05 16:44:38 +08:00
parent 3a91246e0c
commit 6848491678
12 changed files with 171 additions and 149 deletions
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { adminNavigationItems, findAdminNavigationItemByPath, ADMIN_DASHBOARD_PATH } from './admin-navigation'
import { adminNavigationItems, findAdminNavigationItemByPath, getAdminBreadcrumbTrail, ADMIN_DASHBOARD_PATH } from './admin-navigation'
describe('admin-navigation', () => {
it('exposes a fixed Salon management menu without permission-based filtering', () => {
@@ -7,9 +7,17 @@ describe('admin-navigation', () => {
expect(findAdminNavigationItemByPath('/admin/shops')?.label).toBe('门店管理')
expect(findAdminNavigationItemByPath('/admin/products')).toBeUndefined()
expect(adminNavigationItems[0]?.path).toBe('/admin')
expect(adminNavigationItems.map(item => item.label)).toEqual([
expect(adminNavigationItems.filter(item => !item.menuHidden).map(item => item.label)).toEqual([
'首页', '账号管理', '注册审核', '隐私与内容复核', '门店管理', '系统设置', '个人设置'
])
expect(adminNavigationItems.every(item => !('permissionCode' in item))).toBe(true)
})
it('builds breadcrumb trails from the same menu hierarchy', () => {
expect(getAdminBreadcrumbTrail('/admin').map(item => item.label)).toEqual(['首页'])
expect(getAdminBreadcrumbTrail('/admin/registrations').map(item => item.label)).toEqual(['首页', '账号管理', '注册审核'])
expect(getAdminBreadcrumbTrail('/admin/orders').map(item => item.label)).toEqual(['首页', '门店管理', '订单管理'])
expect(getAdminBreadcrumbTrail('/admin/settings').map(item => item.label)).toEqual(['首页', '系统设置'])
expect(getAdminBreadcrumbTrail('/admin/unknown')).toEqual([])
})
})
@@ -16,6 +16,10 @@ export interface AdminNavigationItem {
path: string
iconKey: AdminNavIconKey
label: string
/** 面包屑上级路径,复用同一份菜单配置维护层级,避免页面与中文路径的重复映射表。 */
parentPath?: string
/** 不在侧边栏菜单展示,仅用于已注册路由的面包屑层级。 */
menuHidden?: boolean
}
export const ADMIN_HOME_PATH = '/admin'
@@ -24,12 +28,38 @@ export const ADMIN_DASHBOARD_PATH = ADMIN_HOME_PATH
export const adminNavigationItems: AdminNavigationItem[] = [
{ path: ADMIN_HOME_PATH, iconKey: 'home', label: '首页' },
{ path: '/admin/users', iconKey: 'user', label: '账号管理' },
{ path: '/admin/registrations', iconKey: 'team', label: '注册审核' },
{ path: '/admin/privacy', iconKey: 'security', label: '隐私与内容复核' },
{ path: '/admin/registrations', iconKey: 'team', label: '注册审核', parentPath: '/admin/users' },
{ path: '/admin/privacy', iconKey: 'security', label: '隐私与内容复核', parentPath: '/admin/users' },
{ path: '/admin/shops', iconKey: 'home', label: '门店管理' },
{ path: '/admin/orders', iconKey: 'shopping', label: '订单管理', parentPath: '/admin/shops', menuHidden: true },
{ path: '/admin/after-sales', iconKey: 'tool', label: '售后处理', parentPath: '/admin/shops', menuHidden: true },
{ path: '/admin/inventory', iconKey: 'tag', label: '库存管理', parentPath: '/admin/shops', menuHidden: true },
{ path: '/admin/settings', iconKey: 'tool', label: '系统设置' },
{ path: '/admin/profile', iconKey: 'user', label: '个人设置' }
]
export const findAdminNavigationItemByPath = (path: string) =>
adminNavigationItems.find(item => item.path === path)
/**
* 沿 parentPath 回溯生成面包屑链路(首页在前、当前页在后)。
* 未登记的路径返回空数组,由调用方用路由 meta 标题兜底。
*/
export const getAdminBreadcrumbTrail = (path: string): AdminNavigationItem[] => {
const chain: AdminNavigationItem[] = []
const visited = new Set<string>()
let current = findAdminNavigationItemByPath(path)
while (current && !visited.has(current.path)) {
chain.unshift(current)
visited.add(current.path)
current = current.parentPath ? findAdminNavigationItemByPath(current.parentPath) : undefined
}
if (!chain.length) {
return chain
}
if (chain[0]?.path !== ADMIN_HOME_PATH) {
const home = findAdminNavigationItemByPath(ADMIN_HOME_PATH)
if (home) chain.unshift(home)
}
return chain
}
+124 -44
View File
@@ -8,9 +8,14 @@
>
<a-layout>
<a-layout-sider v-if="!isMobile" v-model:collapsed="collapsed" :trigger="null" collapsible class="sider" :width="224" :collapsed-width="74">
<div class="logo">
<span class="logo-mark">S</span>
<strong v-if="!collapsed">Salon</strong>
<div class="sider-head">
<div class="logo">
<span class="logo-mark">S</span>
<strong v-if="!collapsed">Salon</strong>
</div>
<button class="sider-toggle" type="button" :aria-label="collapsed ? '展开导航' : '收起导航'" @click="collapsed = !collapsed">
<MenuUnfoldOutlined v-if="collapsed" /><MenuFoldOutlined v-else />
</button>
</div>
<div v-if="!collapsed" class="sider-section-label">工作台</div>
<a-menu :selectedKeys="selectedKeys" mode="inline" theme="dark" @click="handleMenuClick">
@@ -25,11 +30,13 @@
<a-layout-header class="header">
<div class="header-shell">
<div class="header-left">
<button v-if="!isMobile" class="trigger" type="button" :aria-label="collapsed ? '展开导航' : '收起导航'" @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>
<button v-if="isMobile" class="trigger" type="button" aria-label="打开导航" @click="mobileDrawerOpen = true"><MenuOutlined /></button>
<a-breadcrumb class="header-breadcrumb">
<a-breadcrumb-item v-for="(item, index) in breadcrumbItems" :key="item.path">
<router-link v-if="index < breadcrumbItems.length - 1" :to="item.path" class="breadcrumb-link">{{ item.label }}</router-link>
<span v-else class="breadcrumb-current">{{ item.label }}</span>
</a-breadcrumb-item>
</a-breadcrumb>
</div>
<a-dropdown>
<button class="user-dropdown" type="button">
@@ -74,12 +81,12 @@
</template>
<script setup lang="ts">
import { onMounted, ref, watch } from 'vue'
import { computed, onMounted, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { message, Modal } from 'ant-design-vue'
import { DownOutlined, HomeOutlined, LogoutOutlined, MenuFoldOutlined, MenuOutlined, MenuUnfoldOutlined, SafetyCertificateOutlined, TeamOutlined, ToolOutlined, UserOutlined } from '@ant-design/icons-vue'
import type { Component } from 'vue'
import { adminNavigationItems, type AdminNavIconKey } from '@/config/admin-navigation'
import { ADMIN_HOME_PATH, adminNavigationItems, findAdminNavigationItemByPath, getAdminBreadcrumbTrail, type AdminNavIconKey, type AdminNavigationItem } from '@/config/admin-navigation'
import { DEFAULT_AVATAR } from '@/constants'
import { completeAdminLogout } from '@/utils/admin-logout'
import { runWithGlobalLoading } from '@/utils/action-loading'
@@ -93,7 +100,21 @@ const mobileDrawerOpen = ref(false)
const selectedKeys = ref<string[]>([route.path])
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] }))
const menuItems = adminNavigationItems.filter(item => !item.menuHidden).map(item => ({ key: item.path, label: item.label, icon: iconMap[item.iconKey] }))
/**
* 面包屑层级直接来自菜单配置:沿 parentPath 回溯到首页,最后一项为当前页且不可点击。
* 未登记的路由用 meta.title 兜底,避免新增页面时出现空白面包屑。
*/
const breadcrumbItems = computed<AdminNavigationItem[]>(() => {
const trail = getAdminBreadcrumbTrail(route.path)
if (trail.length) return trail
const fallbackTitle = typeof route.meta.title === 'string' ? route.meta.title : ''
if (!fallbackTitle) return []
const home = findAdminNavigationItemByPath(ADMIN_HOME_PATH)
const currentItem: AdminNavigationItem = { path: route.path, iconKey: 'home', label: fallbackTitle, parentPath: ADMIN_HOME_PATH }
return home ? [home, currentItem] : [currentItem]
})
const handleMenuClick = ({ key }: { key: string | number }) => router.push(String(key))
const openMobileMenu = ({ key }: { key: string | number }) => { mobileDrawerOpen.value = false; router.push(String(key)) }
@@ -139,17 +160,59 @@ onMounted(() => {
transition: width 0.22s ease;
}
.sider-head {
display: flex;
align-items: center;
height: 68px;
padding: 0 10px 0 14px;
}
.logo,
.drawer-brand {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
color: #fff;
}
.logo {
flex: 1;
min-width: 0;
padding: 0;
}
.drawer-brand {
height: 68px;
padding: 0 14px;
}
.sider-toggle {
display: grid;
flex: 0 0 30px;
place-items: center;
width: 30px;
height: 30px;
padding: 0;
border: 1px solid rgba(255, 255, 255, 0.28);
border-radius: 9px;
background: rgba(255, 255, 255, 0.08);
color: rgba(255, 255, 255, 0.9);
cursor: pointer;
font-size: 15px;
}
.sider-toggle:hover {
border-color: rgba(255, 255, 255, 0.55);
background: rgba(255, 255, 255, 0.16);
color: #fff;
}
.sider-toggle:focus-visible {
outline: 2px solid rgba(255, 255, 255, 0.85);
outline-offset: 2px;
}
.logo strong,
.drawer-brand__copy strong {
color: #fff;
@@ -233,10 +296,30 @@ onMounted(() => {
background: #e5f8f1;
}
.admin-layout--collapsed .sider-head {
padding-inline: 6px;
gap: 4px;
}
.admin-layout--collapsed .logo {
padding-inline: 0;
}
.admin-layout--collapsed .logo-mark {
flex-basis: 30px;
width: 30px;
height: 30px;
border-radius: 10px;
font-size: 18px;
}
.admin-layout--collapsed .sider-toggle {
flex-basis: 28px;
width: 28px;
height: 28px;
font-size: 14px;
}
.admin-layout--collapsed .sider :deep(.ant-menu-item) {
width: 50px;
padding-inline: 0;
@@ -296,20 +379,37 @@ onMounted(() => {
outline-offset: 2px;
}
.header-title {
display: grid;
gap: 3px;
.header-breadcrumb {
min-width: 0;
overflow: hidden;
color: #5b746f;
font-size: 13px;
white-space: nowrap;
}
.header-breadcrumb :deep(.ant-breadcrumb) {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.header-breadcrumb :deep(.ant-breadcrumb-separator) {
margin-inline: 8px;
color: #9aada8;
}
.breadcrumb-link {
color: #5b746f;
font-weight: 600;
}
.breadcrumb-link:hover {
color: var(--theme-primary-action);
}
.breadcrumb-current {
color: #224d47;
}
.header-title span {
font-size: 15px;
font-weight: 750;
}
.header-title small {
color: #78918b;
font-size: 11px;
font-weight: 700;
}
.user-dropdown {
@@ -419,22 +519,6 @@ onMounted(() => {
color: #fff;
}
.agreement-gate {
display: grid;
gap: 14px;
color: #315650;
line-height: 1.7;
}
.agreement-gate p {
margin: 0;
}
.agreement-gate__links a {
color: var(--theme-primary-action);
font-weight: 700;
}
@media (max-width: 960px) {
.header,
.content {
@@ -447,10 +531,6 @@ onMounted(() => {
padding: 0 16px;
}
.header-title small {
display: none;
}
.content {
padding: 18px 14px 28px;
}
@@ -1,15 +1,5 @@
<template>
<div class="after-sales">
<a-page-header v-if="!isMobile" title="售后处理" sub-title="处理客户退款与售后申请" />
<section v-else class="admin-page-intro">
<span class="admin-page-intro__eyebrow">售后</span>
<h1 class="admin-page-intro__title">售后处理</h1>
<div class="admin-page-intro__meta">
<span class="admin-page-chip">申请 {{ pagination.total }}</span>
</div>
</section>
<a-card :bordered="false">
<template #title v-if="isMobile">售后列表</template>
@@ -1,16 +1,5 @@
<template>
<div class="inventory">
<a-page-header v-if="!isMobile" title="库存管理" sub-title="维护门店耗材库存和预警阈值" />
<section v-else class="admin-page-intro">
<span class="admin-page-intro__eyebrow">库存</span>
<h1 class="admin-page-intro__title">库存管理</h1>
<div class="admin-page-intro__meta">
<span class="admin-page-chip">物料 {{ pagination.total }}</span>
<span class="admin-page-chip">预警 {{ warningCount }}</span>
</div>
</section>
<a-card :bordered="false">
<template #title v-if="isMobile">库存列表</template>
<template #extra>
@@ -1,19 +1,5 @@
<template>
<div class="orders">
<a-page-header v-if="!isMobile" title="订单管理" sub-title="管理系统订单" />
<section v-else class="admin-page-intro">
<span class="admin-page-intro__eyebrow">订单</span>
<h1 class="admin-page-intro__title">订单工作台</h1>
<p class="admin-page-intro__subtitle">
手机端不再默认展示横向大表格,而是把筛选、状态和处理按钮压到单列卡片里。
</p>
<div class="admin-page-intro__meta">
<span class="admin-page-chip">订单 {{ filteredOrders.length }}</span>
<span class="admin-page-chip">{{ canProcessOrders ? '可处理订单' : '查看模式' }}</span>
</div>
</section>
<a-card :bordered="false">
<template #title v-if="isMobile">
订单列表
@@ -1,13 +1,5 @@
<template>
<div class="privacy-page">
<header class="admin-view-heading">
<div>
<span class="admin-view-heading__eyebrow">账号与内容安全</span>
<h1>隐私与内容复核</h1>
<p>处理账号注销、待审内容与历史手机号加密回填。</p>
</div>
</header>
<a-alert
:type="moderationNotice.type"
show-icon
@@ -1,14 +1,5 @@
<template>
<div class="admin-profile">
<header class="profile-head">
<div>
<span class="profile-eyebrow">管理员账号</span>
<h1>{{ userInfo?.nickname || '平台管理员' }}</h1>
<p>{{ userInfo?.account || '当前登录账号' }}</p>
</div>
<a-avatar :size="58" :src="userInfo?.avatar || DEFAULT_AVATAR" />
</header>
<section class="profile-section">
<div class="profile-section__head">
<div><h2>账号资料</h2><p>该后台只服务平台管理员,数据范围为 Salon 全平台。</p></div>
@@ -58,7 +49,6 @@ import { reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import { message, Modal } from 'ant-design-vue'
import type { Rule } from 'ant-design-vue/es/form'
import { DEFAULT_AVATAR } from '@/constants'
import { adminAuthApi } from '@/api/admin'
import { clearAdminBootstrapSession } from '@/utils/admin-auth-bootstrap'
import { completeAdminLogout } from '@/utils/admin-logout'
@@ -122,10 +112,7 @@ const handleLogout = () => Modal.confirm({
<style scoped>
.admin-profile { display: grid; gap: 18px; color: var(--admin-mobile-ink); }
.profile-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 8px 0 18px; border-bottom: 1px solid var(--admin-mobile-border); }
.profile-eyebrow { color: var(--theme-primary-action); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.profile-head h1 { margin: 7px 0 4px; font-size: 28px; }
.profile-head p, .profile-section__head p { margin: 0; color: var(--admin-mobile-muted); font-size: 13px; }
.profile-section__head p { margin: 0; color: var(--admin-mobile-muted); font-size: 13px; }
.profile-section { padding-top: 4px; border-top: 1px solid var(--admin-mobile-border); }
.profile-section__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; }
.profile-section__head h2 { margin: 0 0 4px; font-size: 17px; }
@@ -1,12 +1,7 @@
<template>
<main class="salon-dashboard">
<header class="dashboard-head">
<div>
<span class="dashboard-eyebrow">SALON PLATFORM</span>
<h1>Salon 管理后台</h1>
<p>用门店、员工、客户和服务数据掌握平台经营状态。</p>
<div class="dashboard-freshness"><span>系统日期 {{ currentDateLabel }}</span><span>最近刷新 {{ lastRefreshedAt || '尚未刷新' }}</span></div>
</div>
<div class="dashboard-freshness"><span>系统日期 {{ currentDateLabel }}</span><span>最近刷新 {{ lastRefreshedAt || '尚未刷新' }}</span></div>
<div class="dashboard-tools">
<label class="date-control"><span>统计日期</span><input v-model="date" type="date" @change="loadOverview" /></label>
<div class="range-control" role="group" aria-label="趋势范围">
@@ -154,11 +149,8 @@ onMounted(() => { void loadOverview() })
<style scoped>
.salon-dashboard { display: grid; gap: 22px; color: var(--admin-mobile-ink); }
.dashboard-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding-bottom: 5px; }
.dashboard-eyebrow { color: var(--theme-primary-action); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
.dashboard-head h1 { margin: 7px 0 5px; font-size: 32px; }
.dashboard-head p { margin: 0; color: var(--admin-mobile-muted); font-size: 13px; }
.dashboard-freshness { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; color: var(--admin-mobile-muted); font-size: 11px; }
.dashboard-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-bottom: 5px; }
.dashboard-freshness { display: flex; flex-wrap: wrap; gap: 14px; color: var(--admin-mobile-muted); font-size: 11px; }
.dashboard-tools { display: flex; align-items: flex-end; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.date-control { display: grid; gap: 5px; color: var(--admin-mobile-muted); font-size: 11px; }
.date-control input { height: 34px; padding: 0 9px; border: 1px solid var(--admin-mobile-border); border-radius: 8px; background: var(--theme-card-bg); color: var(--admin-mobile-ink); font: inherit; }
@@ -209,6 +201,5 @@ onMounted(() => { void loadOverview() })
.asset-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; min-height: 50px; border-bottom: 1px solid var(--admin-mobile-border); }.asset-row span { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; }.asset-row strong { font-size: 16px; }.asset-row small { width: 46px; color: var(--admin-mobile-muted); font-size: 10px; text-align: right; }.asset-mark { width: 7px; height: 7px; border-radius: 50%; background: var(--theme-primary); }.asset-mark--manager { background: #6f9fd1; }.asset-mark--staff { background: #a887d1; }.asset-mark--customer { background: #d89b64; }.asset-mark--style { background: #78a8a1; }
.empty-state { display: grid; place-items: center; min-height: 160px; color: var(--admin-mobile-muted); font-size: 12px; }.empty-state--inline { min-height: 180px; }.trend-chart--empty { opacity: .8; }
@media (max-width: 1000px) { .dashboard-head { align-items: flex-start; flex-direction: column; }.dashboard-tools { justify-content: flex-start; }.dashboard-grid, .dashboard-grid--lower { grid-template-columns: 1fr; } }
@media (max-width: 680px) { .dashboard-head h1 { font-size: 27px; } }
@media (max-width: 680px) { .dashboard-head h1 { font-size: 27px; }.kpi-strip { grid-template-columns: repeat(2, 1fr); }.kpi-item { min-height: 100px; padding: 15px 13px; }.kpi-item:nth-child(2n) { border-right: 0; }.kpi-item:nth-child(-n+3) { border-bottom: 1px solid var(--admin-mobile-border); }.kpi-item strong { font-size: 24px; }.trend-chart { gap: 3px; }.trend-bar { width: 6px; }.chart-legend { flex-wrap: wrap; }.legend-note { width: 100%; margin-left: 0; }.dashboard-tools { width: 100%; }.date-control { flex: 1; }.date-control input { width: 100%; }.range-control button { padding: 0 8px; } }
@media (max-width: 680px) { .kpi-strip { grid-template-columns: repeat(2, 1fr); }.kpi-item { min-height: 100px; padding: 15px 13px; }.kpi-item:nth-child(2n) { border-right: 0; }.kpi-item:nth-child(-n+3) { border-bottom: 1px solid var(--admin-mobile-border); }.kpi-item strong { font-size: 24px; }.trend-chart { gap: 3px; }.trend-bar { width: 6px; }.chart-legend { flex-wrap: wrap; }.legend-note { width: 100%; margin-left: 0; }.dashboard-tools { width: 100%; }.date-control { flex: 1; }.date-control input { width: 100%; }.range-control button { padding: 0 8px; } }
</style>
@@ -1,18 +1,5 @@
<template>
<div class="shops">
<a-page-header v-if="!isMobile" title="店铺管理" sub-title="管理美甲店铺" />
<section v-else class="admin-page-intro">
<span class="admin-page-intro__eyebrow">经营</span>
<h1 class="admin-page-intro__title">店铺管理</h1>
<p class="admin-page-intro__subtitle">
移动端优先展示 Banner、营业时间、地址和启停状态,让店铺信息在手机上也能完整维护。
</p>
<div class="admin-page-intro__meta">
<span class="admin-page-chip">店铺 {{ shopList.length }}</span>
</div>
</section>
<a-card :bordered="false">
<template #title v-if="isMobile">
店铺列表
@@ -1,15 +1,5 @@
<template>
<div class="users">
<a-page-header v-if="!isMobile" title="店长账号" sub-title="管理店长账号及店铺授权" />
<section v-else class="admin-page-intro">
<span class="admin-page-intro__eyebrow">经营</span>
<h1 class="admin-page-intro__title">店长账号</h1>
<div class="admin-page-intro__meta">
<span class="admin-page-chip">用户 {{ userList.length }}</span>
</div>
</section>
<a-card :bordered="false">
<template #title v-if="isMobile">
店长账号列表
@@ -1,13 +1,5 @@
<template>
<div class="registration-page">
<header class="admin-view-heading">
<div>
<span class="admin-view-heading__eyebrow">账号管理</span>
<h1>注册审核</h1>
<p>处理店长注册申请;员工加入申请由店长在小程序员工页面审核。</p>
</div>
<div class="admin-view-heading__count"><strong>{{ applications.length }}</strong><span>条申请记录</span></div>
</header>
<div class="registration-table">
<a-table
:columns="columns"