主要变更: 1. 重构API目录结构,采用模块化设计,适配5.x后端接口规范 2. 优化布局组件,提升用户界面体验 3. 增强国际化支持,完善多语言配置 4. 新增权限控制功能,支持前端路由权限管理 5. 优化认证流程,支持JWT认证机制 6. 新增中间件和插件,提升系统扩展性 7. 优化状态管理,采用更清晰的模块化设计 8. 新增搜索框、广告等组件,丰富页面功能 9. 更改包管理工具从npm到pnpm,提升依赖管理效率 10. 完善配置系统,支持多环境配置 适配5.x后端特性: - 采用新的API接口规范 - 支持JWT认证机制 - 适配后端权限控制体系 - 支持后端国际化接口 - 优化数据交互方式
224 lines
5.4 KiB
Vue
224 lines
5.4 KiB
Vue
<template>
|
||
<div class="ma-header">
|
||
<div class="header-container">
|
||
<!-- 左侧logo -->
|
||
<div class="header-left">
|
||
<Logo clickable show-text size="medium" />
|
||
</div>
|
||
|
||
<!-- 中间菜单区域(靠右显示) -->
|
||
<div class="header-center">
|
||
<client-only>
|
||
<el-scrollbar class="hidden-sm-and-down" style="height: var(--el-header-height);">
|
||
<Menu class="frontend-header-menu" :ellipsis="false" mode="horizontal" :show-icon="true" />
|
||
</el-scrollbar>
|
||
</client-only>
|
||
</div>
|
||
|
||
<!-- 右侧功能区域 -->
|
||
<div class="header-right">
|
||
<client-only>
|
||
<div v-if="isMobile" class="mobile-menu-wrapper">
|
||
<div
|
||
v-if="!systemStore.$state.site.menu_expand"
|
||
@click="systemStore.toggleMenuExpand(true)"
|
||
class="mobile-menu-toggle mr-2"
|
||
>
|
||
<Icon icon="ant-design:menu-outlined" color="var(--el-color-primary)" size="20" />
|
||
</div>
|
||
</div>
|
||
<el-scrollbar class="hidden-sm-and-down" style="height: var(--el-header-height);">
|
||
<HeaderActions class="frontend-header-menu" :ellipsis="false" mode="horizontal" v-if="!isMobile"/>
|
||
</el-scrollbar>
|
||
</client-only>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 移动端抽屉菜单(仅在移动端显示) -->
|
||
<MobileDrawer
|
||
v-if="isMobile"
|
||
v-model="systemStore.$state.site.menu_expand"
|
||
@language-changed="handleLanguageChange"
|
||
@logged-out="handleLogout"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import Menu from './menu.vue'
|
||
import Logo from './logo.vue'
|
||
import MobileDrawer from './mobile-drawer.vue'
|
||
import HeaderActions from './header-actions.vue'
|
||
import { Icon } from '~/components/icon'
|
||
import { useSystemStore } from '~/stores/system'
|
||
|
||
|
||
// 判断是否为移动端
|
||
const isMobile = ref(false)
|
||
const systemStore = useSystemStore()
|
||
const checkMobile = () => {
|
||
isMobile.value = window.innerWidth <= 768
|
||
}
|
||
|
||
onMounted(() => {
|
||
checkMobile()
|
||
window.addEventListener('resize', checkMobile)
|
||
})
|
||
|
||
onUnmounted(() => {
|
||
window.removeEventListener('resize', checkMobile)
|
||
})
|
||
|
||
const handleLanguageChange = (languageName: string) => {
|
||
if (isMobile.value) {
|
||
useSystemStore().toggleMenuExpand(false)
|
||
}
|
||
}
|
||
|
||
const handleLogout = () => {
|
||
// 可以添加额外的登出处理逻辑
|
||
}
|
||
|
||
const toggleDarkMode = () => {
|
||
setDark(!getDark())
|
||
}
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.ma-header {
|
||
background-color: var(--ma-bg-color-overlay);
|
||
/* 暂时注释掉阴影,避免左右两边出现阴影线条 */
|
||
/* box-shadow: 0 2px 4px rgba(0 0 0 / 8%); */
|
||
position: relative;
|
||
z-index: 1000;
|
||
width: 100%;
|
||
}
|
||
|
||
.header-container {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
max-width: 1450px;
|
||
margin: 0 auto;
|
||
padding: 0 20px;
|
||
height: var(--el-header-height);
|
||
}
|
||
|
||
.header-left {
|
||
flex-shrink: 0;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.header-center {
|
||
flex: 1;
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
margin: 0 20px;
|
||
|
||
.frontend-header-menu {
|
||
height: var(--el-header-height);
|
||
background: transparent;
|
||
.el-menu-item,
|
||
.el-sub-menu .el-sub-menu__title {
|
||
&.is-active {
|
||
color: var(--el-color-primary) !important;
|
||
}
|
||
&:hover {
|
||
background-color: transparent !important;
|
||
color: var(--el-menu-hover-text-color) !important;
|
||
}
|
||
}
|
||
}
|
||
|
||
:deep(.el-menu--horizontal) {
|
||
border-bottom: none;
|
||
}
|
||
}
|
||
|
||
.header-right {
|
||
flex-shrink: 0;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: flex-end;
|
||
gap: 0;
|
||
|
||
.frontend-header-menu {
|
||
height: var(--el-header-height);
|
||
background: transparent;
|
||
.el-menu-item,
|
||
.el-sub-menu .el-sub-menu__title {
|
||
&.is-active {
|
||
color: var(--el-color-primary) !important;
|
||
}
|
||
&:hover {
|
||
background-color: transparent !important;
|
||
color: var(--el-menu-hover-text-color) !important;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
.header-actions {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: flex-end;
|
||
gap: 8px;
|
||
}
|
||
|
||
.header-action-item {
|
||
display: flex;
|
||
align-items: center;
|
||
padding: 8px 12px;
|
||
cursor: pointer;
|
||
border-radius: 6px;
|
||
transition: all 0.3s ease;
|
||
color: var(--el-text-color-primary);
|
||
|
||
&:hover {
|
||
background-color: var(--el-fill-color-light);
|
||
}
|
||
}
|
||
|
||
.mobile-menu-toggle {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 8px;
|
||
cursor: pointer;
|
||
border-radius: 6px;
|
||
height: 40px;
|
||
width: 40px;
|
||
|
||
&:hover {
|
||
background-color: var(--el-fill-color-light);
|
||
}
|
||
}
|
||
|
||
.mobile-menu-wrapper {
|
||
display: flex;
|
||
align-items: center;
|
||
height: 100%;
|
||
}
|
||
|
||
// 响应式设计
|
||
@media screen and (max-width: 768px) {
|
||
.header-container {
|
||
padding: 0 15px;
|
||
}
|
||
|
||
.header-center {
|
||
display: none;
|
||
}
|
||
|
||
.header-right {
|
||
justify-content: flex-start;
|
||
}
|
||
}
|
||
|
||
@media screen and (max-width: 414px) {
|
||
.header-container {
|
||
padding: 0 10px;
|
||
}
|
||
}
|
||
</style> |