294 lines
6.4 KiB
Vue
294 lines
6.4 KiB
Vue
|
|
<template>
|
||
|
|
<div v-if="isLoggedIn">
|
||
|
|
<!-- 移动端布局 -->
|
||
|
|
<div v-if="isMobile" class="mobile-layout">
|
||
|
|
<MobileNav ref="mobileNavRef" />
|
||
|
|
<div class="mobile-content">
|
||
|
|
<router-view />
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- 桌面端布局 -->
|
||
|
|
<a-layout v-else style="min-height: 100vh">
|
||
|
|
<a-layout-header class="header">
|
||
|
|
<div class="logo">
|
||
|
|
<a-button
|
||
|
|
type="text"
|
||
|
|
@click="settingsStore.toggleSidebar"
|
||
|
|
style="color: white; margin-right: 8px;"
|
||
|
|
>
|
||
|
|
<menu-unfold-outlined v-if="sidebarCollapsed" />
|
||
|
|
<menu-fold-outlined v-else />
|
||
|
|
</a-button>
|
||
|
|
银行管理后台系统
|
||
|
|
</div>
|
||
|
|
<div class="user-info">
|
||
|
|
<a-dropdown>
|
||
|
|
<a-button type="text" style="color: white;">
|
||
|
|
<user-outlined />
|
||
|
|
{{ userData?.real_name || userData?.username }}
|
||
|
|
<down-outlined />
|
||
|
|
</a-button>
|
||
|
|
<template #overlay>
|
||
|
|
<a-menu>
|
||
|
|
<a-menu-item key="profile" @click="goToProfile">
|
||
|
|
<user-outlined />
|
||
|
|
个人中心
|
||
|
|
</a-menu-item>
|
||
|
|
<a-menu-item key="settings" @click="goToSettings">
|
||
|
|
<setting-outlined />
|
||
|
|
系统设置
|
||
|
|
</a-menu-item>
|
||
|
|
<a-menu-divider />
|
||
|
|
<a-menu-item key="logout" @click="handleLogout">
|
||
|
|
<logout-outlined />
|
||
|
|
退出登录
|
||
|
|
</a-menu-item>
|
||
|
|
</a-menu>
|
||
|
|
</template>
|
||
|
|
</a-dropdown>
|
||
|
|
</div>
|
||
|
|
</a-layout-header>
|
||
|
|
|
||
|
|
<a-layout>
|
||
|
|
<a-layout-sider
|
||
|
|
width="200"
|
||
|
|
style="background: #001529"
|
||
|
|
:collapsed="sidebarCollapsed"
|
||
|
|
collapsible
|
||
|
|
>
|
||
|
|
<DynamicMenu :collapsed="sidebarCollapsed" />
|
||
|
|
</a-layout-sider>
|
||
|
|
|
||
|
|
<a-layout style="padding: 0 24px 24px">
|
||
|
|
<a-layout-content
|
||
|
|
:style="{ background: '#fff', padding: '24px', margin: '16px 0' }"
|
||
|
|
>
|
||
|
|
<router-view />
|
||
|
|
</a-layout-content>
|
||
|
|
|
||
|
|
<a-layout-footer style="text-align: center">
|
||
|
|
银行管理后台系统 ©2025
|
||
|
|
</a-layout-footer>
|
||
|
|
</a-layout>
|
||
|
|
</a-layout>
|
||
|
|
</a-layout>
|
||
|
|
</div>
|
||
|
|
<div v-else>
|
||
|
|
<router-view />
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script setup>
|
||
|
|
import { ref, onMounted, onUnmounted, computed } from 'vue'
|
||
|
|
import { useRouter } from 'vue-router'
|
||
|
|
import DynamicMenu from './components/DynamicMenu.vue'
|
||
|
|
import MobileNav from './components/MobileNav.vue'
|
||
|
|
import { useUserStore, useSettingsStore } from './stores'
|
||
|
|
import {
|
||
|
|
MenuFoldOutlined,
|
||
|
|
MenuUnfoldOutlined,
|
||
|
|
UserOutlined,
|
||
|
|
DownOutlined,
|
||
|
|
SettingOutlined,
|
||
|
|
LogoutOutlined
|
||
|
|
} from '@ant-design/icons-vue'
|
||
|
|
|
||
|
|
// 使用Pinia状态管理
|
||
|
|
const userStore = useUserStore()
|
||
|
|
const settingsStore = useSettingsStore()
|
||
|
|
const router = useRouter()
|
||
|
|
|
||
|
|
// 移动端导航引用
|
||
|
|
const mobileNavRef = ref()
|
||
|
|
|
||
|
|
// 响应式检测
|
||
|
|
const isMobile = ref(false)
|
||
|
|
|
||
|
|
// 检测屏幕尺寸
|
||
|
|
const checkScreenSize = () => {
|
||
|
|
isMobile.value = window.innerWidth <= 768
|
||
|
|
}
|
||
|
|
|
||
|
|
// 计算属性
|
||
|
|
const isLoggedIn = computed(() => userStore.isLoggedIn)
|
||
|
|
const userData = computed(() => userStore.userData)
|
||
|
|
const sidebarCollapsed = computed(() => settingsStore.sidebarCollapsed)
|
||
|
|
|
||
|
|
// 监听多标签页登录状态同步
|
||
|
|
const handleStorageChange = (event) => {
|
||
|
|
if (event.key === 'bank_token' || event.key === 'bank_user') {
|
||
|
|
userStore.checkLoginStatus()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 登出处理
|
||
|
|
const handleLogout = async () => {
|
||
|
|
try {
|
||
|
|
await userStore.logout()
|
||
|
|
router.push('/login')
|
||
|
|
} catch (error) {
|
||
|
|
console.error('登出失败:', error)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 跳转到个人中心
|
||
|
|
const goToProfile = () => {
|
||
|
|
router.push('/profile')
|
||
|
|
}
|
||
|
|
|
||
|
|
// 跳转到系统设置
|
||
|
|
const goToSettings = () => {
|
||
|
|
router.push('/settings')
|
||
|
|
}
|
||
|
|
|
||
|
|
onMounted(() => {
|
||
|
|
userStore.checkLoginStatus()
|
||
|
|
checkScreenSize()
|
||
|
|
window.addEventListener('storage', handleStorageChange)
|
||
|
|
window.addEventListener('resize', checkScreenSize)
|
||
|
|
})
|
||
|
|
|
||
|
|
onUnmounted(() => {
|
||
|
|
window.removeEventListener('storage', handleStorageChange)
|
||
|
|
window.removeEventListener('resize', checkScreenSize)
|
||
|
|
})
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style scoped>
|
||
|
|
/* 桌面端样式 */
|
||
|
|
.header {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: space-between;
|
||
|
|
background: #001529;
|
||
|
|
color: white;
|
||
|
|
padding: 0 24px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.logo {
|
||
|
|
font-size: 18px;
|
||
|
|
font-weight: bold;
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
}
|
||
|
|
|
||
|
|
.user-info {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 16px;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* 移动端布局样式 */
|
||
|
|
.mobile-layout {
|
||
|
|
min-height: 100vh;
|
||
|
|
background: #f0f2f5;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-content {
|
||
|
|
padding: 12px;
|
||
|
|
padding-top: 68px; /* 为固定头部留出空间 */
|
||
|
|
min-height: calc(100vh - 56px);
|
||
|
|
}
|
||
|
|
|
||
|
|
/* 移动端页面内容优化 */
|
||
|
|
.mobile-layout :deep(.page-header) {
|
||
|
|
flex-direction: column;
|
||
|
|
gap: 12px;
|
||
|
|
align-items: stretch;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-layout :deep(.search-area) {
|
||
|
|
flex-direction: column;
|
||
|
|
gap: 8px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-layout :deep(.search-input) {
|
||
|
|
width: 100%;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-layout :deep(.search-buttons) {
|
||
|
|
display: flex;
|
||
|
|
gap: 8px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-layout :deep(.search-buttons .ant-btn) {
|
||
|
|
flex: 1;
|
||
|
|
height: 40px;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* 移动端表格优化 */
|
||
|
|
.mobile-layout :deep(.ant-table-wrapper) {
|
||
|
|
overflow-x: auto;
|
||
|
|
-webkit-overflow-scrolling: touch;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-layout :deep(.ant-table) {
|
||
|
|
min-width: 600px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-layout :deep(.ant-table-thead > tr > th) {
|
||
|
|
padding: 8px 4px;
|
||
|
|
font-size: 12px;
|
||
|
|
white-space: nowrap;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-layout :deep(.ant-table-tbody > tr > td) {
|
||
|
|
padding: 8px 4px;
|
||
|
|
font-size: 12px;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* 移动端模态框优化 */
|
||
|
|
.mobile-layout :deep(.ant-modal) {
|
||
|
|
margin: 0 !important;
|
||
|
|
width: 100vw !important;
|
||
|
|
max-width: 100vw !important;
|
||
|
|
top: 0 !important;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-layout :deep(.ant-modal-content) {
|
||
|
|
border-radius: 0;
|
||
|
|
height: 100vh;
|
||
|
|
display: flex;
|
||
|
|
flex-direction: column;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-layout :deep(.ant-modal-body) {
|
||
|
|
flex: 1;
|
||
|
|
overflow-y: auto;
|
||
|
|
padding: 16px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-layout :deep(.ant-modal-footer) {
|
||
|
|
border-top: 1px solid #f0f0f0;
|
||
|
|
padding: 12px 16px;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* 移动端卡片优化 */
|
||
|
|
.mobile-layout :deep(.ant-card) {
|
||
|
|
margin-bottom: 12px;
|
||
|
|
border-radius: 8px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-layout :deep(.ant-card-body) {
|
||
|
|
padding: 12px;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* 移动端按钮优化 */
|
||
|
|
.mobile-layout :deep(.ant-btn) {
|
||
|
|
min-height: 40px;
|
||
|
|
border-radius: 6px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-layout :deep(.ant-space) {
|
||
|
|
width: 100%;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-layout :deep(.ant-space-item) {
|
||
|
|
flex: 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile-layout :deep(.ant-space-item .ant-btn) {
|
||
|
|
width: 100%;
|
||
|
|
}
|
||
|
|
</style>
|