2
0

fix:修改菜单布局

This commit is contained in:
zhongzm
2025-01-17 16:20:10 +08:00
parent ebd243040f
commit 63439ad22c
16 changed files with 1004 additions and 774 deletions

View File

@@ -11,7 +11,7 @@ const { t } = useI18n();
const router = useRouter();
const handleBack = () => {
router.push('/userInfo/usercard');
router.push('/endpoint/clientservice');
};
// 设备列表数据

View File

@@ -1,8 +1,8 @@
<script setup lang="ts">
// 1. 简化导入方式,与 billservice 保持一致
import { useAuthStore } from '@/store/modules/auth';
import type { Router } from 'vue-router';
import { useRouter } from 'vue-router';
import { computed } from 'vue';
import { computed, type Component } from 'vue';
import { useI18n } from "vue-i18n";
import {
UserOutlined,
@@ -16,10 +16,17 @@ import {
} from '@ant-design/icons-vue';
const { t } = useI18n();
const router = useRouter();
const router: Router = useRouter();
const authStore = useAuthStore();
// 2. 保持类型定义
// 定义菜单项接口
interface MenuItem {
icon: Component;
title: string;
path: string;
}
// 定义用户信息接口
interface UserInfo {
avatar?: string;
nickName?: string;
@@ -29,12 +36,12 @@ interface UserInfo {
const user = computed<UserInfo | null>(() => authStore.userInfo?.user || null);
// 3. 简化 menuItems 结构,与 billservice 一致
const menuItems = [
// 使用类型注解定义 menuItems
const menuItems: MenuItem[] = [
{
icon: UserOutlined,
title: t('page.usercard.changeInfo'),
path: '/userInfo/profile' // 使用完整路径
path: '/userInfo/profile'
},
{
icon: LockOutlined,
@@ -46,30 +53,30 @@ const menuItems = [
title: t('page.usercard.kyc'),
path: '/userInfo/kyc'
},
{
icon: MobileOutlined,
title: t('page.usercard.deviceconsole'),
path: '/userInfo/device'
},
{
icon: LinkOutlined,
title: t('page.usercard.access'),
path: '/userInfo/access'
},
{
icon: ApiOutlined,
title: t('page.usercard.records'),
path: '/userInfo/records'
},
{
icon: CalendarOutlined,
title: t('page.usercard.cdrlrecords'),
path: '/userInfo/cdrlrecords'
},
// {
// icon: MobileOutlined,
// title: t('page.usercard.deviceconsole'),
// path: '/userInfo/device'
// },
// {
// icon: LinkOutlined,
// title: t('page.usercard.access'),
// path: '/userInfo/access'
// },
// {
// icon: ApiOutlined,
// title: t('page.usercard.records'),
// path: '/userInfo/records'
// },
// {
// icon: CalendarOutlined,
// title: t('page.usercard.cdrlrecords'),
// path: '/userInfo/cdrlrecords'
// },
];
// 4. 简化路由跳转方法
const handleMenuClick = (path: string) => {
// 添加类型注解
const handleMenuClick = (path: string): void => {
router.push(path);
};
</script>
@@ -77,13 +84,12 @@ const handleMenuClick = (path: string) => {
<template>
<div class="user-center">
<div class="user-center-content">
<!-- 顶部用户信息卡片 -->
<div class="user-card">
<div class="avatar">
<template v-if="user?.avatar">
<img
:src="user.avatar"
:alt="user.nickName"
:alt="user?.nickName || '用户'"
>
</template>
<template v-else>
@@ -96,7 +102,6 @@ const handleMenuClick = (path: string) => {
</div>
</div>
<!-- 采用 billservice 的菜单列表结构 -->
<div class="menu-list">
<div
v-for="item in menuItems"
@@ -118,7 +123,7 @@ const handleMenuClick = (path: string) => {
</template>
<style scoped>
/* 采用 billservice 的基础样式结构 */
/* 保持现有样式不变 */
.user-center {
width: 100%;
min-height: 100vh;