consumer模块完成90%,前端完成supabase对接
This commit is contained in:
195
mall/layouts/admin/components/AdminAside.uvue
Normal file
195
mall/layouts/admin/components/AdminAside.uvue
Normal file
@@ -0,0 +1,195 @@
|
||||
<template>
|
||||
<view class="admin-aside" :class="{ collapsed: collapsed }" :style="{ width: asideWidth + 'px' }">
|
||||
<view class="aside-logo" @click="onLogoClick">
|
||||
<text class="logo-text">{{ collapsed ? 'M' : 'MALL' }}</text>
|
||||
</view>
|
||||
|
||||
<view class="aside-menu">
|
||||
<view
|
||||
v-for="menu in topMenus"
|
||||
:key="menu.id"
|
||||
class="menu-item"
|
||||
:class="{ active: menu.id === activeTopMenuId }"
|
||||
@click="onMenuClick(menu)"
|
||||
>
|
||||
<view class="menu-icon">
|
||||
<text class="icon-text">{{ getIconText(menu.icon) }}</text>
|
||||
</view>
|
||||
<view v-if="!collapsed" class="menu-title">
|
||||
<text>{{ menu.title }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="aside-footer" @click="onToggle">
|
||||
<view class="toggle-btn">
|
||||
<text class="toggle-icon">{{ collapsed ? '>' : '<' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import type { TopMenu } from '@/layouts/admin/router/adminRoutes.uts'
|
||||
|
||||
const props = defineProps<{
|
||||
collapsed: boolean
|
||||
topMenus: TopMenu[]
|
||||
activeTopMenuId: string
|
||||
asideWidth: number
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'toggle'): void
|
||||
(e: 'menu-click', menu: TopMenu): void
|
||||
}>()
|
||||
|
||||
function getIconText(icon: string): string {
|
||||
const iconMap: Record<string, string> = {
|
||||
'home': '🏠',
|
||||
'user': '👥',
|
||||
'product': '📦',
|
||||
'order': '📜',
|
||||
'marketing': '📉',
|
||||
'content': '📝',
|
||||
'finance': '💰',
|
||||
'statistic': '📊',
|
||||
'setting': '⚙️',
|
||||
'maintenance': '🛠️'
|
||||
}
|
||||
return iconMap[icon] || icon.charAt(0).toUpperCase()
|
||||
}
|
||||
|
||||
function onMenuClick(menu: TopMenu): void {
|
||||
emit('menu-click', menu)
|
||||
}
|
||||
|
||||
function onToggle(): void {
|
||||
emit('toggle')
|
||||
}
|
||||
|
||||
function onLogoClick(): void {
|
||||
const homeMenu = props.topMenus.find(m => m.id === 'home')
|
||||
if (homeMenu) {
|
||||
emit('menu-click', homeMenu)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.admin-aside {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
background: #001529;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transition: width 0.3s ease;
|
||||
z-index: 1000;
|
||||
box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.aside-logo {
|
||||
height: 64px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
|
||||
.logo-text {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.aside-menu {
|
||||
flex: 1;
|
||||
padding: 8px 0;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
height: 60px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
color: rgba(255, 255, 255, 0.65);
|
||||
transition: all 0.3s;
|
||||
position: relative;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: #1890ff;
|
||||
color: #fff;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 3px;
|
||||
background: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.menu-icon {
|
||||
font-size: 24px;
|
||||
margin-bottom: 4px;
|
||||
|
||||
.icon-text {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-title {
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
|
||||
text {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.aside-footer {
|
||||
height: 48px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
}
|
||||
|
||||
.toggle-btn {
|
||||
color: rgba(255, 255, 255, 0.65);
|
||||
font-size: 18px;
|
||||
|
||||
.toggle-icon {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.admin-aside.collapsed {
|
||||
.menu-item {
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.menu-icon {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user