添加首页的导航菜单是否显示
This commit is contained in:
1 parent
9821ae2345
commit
29e9f30eb7
3 files changed
+9
-15
No files matched your search
+2
-2
@@ -8,13 +8,13 @@ VITE_OPEN = true
|
||||
ENV = 'development'
|
||||
|
||||
# ADMIN 服务地址
|
||||
VITE_ADMIN_PROXY_PATH = http://123.156.230.15:8089/api/
|
||||
VITE_ADMIN_PROXY_PATH = http://123.156.230.15:8089/api/ # 线上
|
||||
# VITE_ADMIN_PROXY_PATH = http://pjcloud.center.takin.cc/
|
||||
# VITE_ADMIN_PROXY_PATH = http://localhost:9999/
|
||||
# VITE_ADMIN_PROXY_PATH = http://192.168.101.29:9999/ # 邓-本地
|
||||
|
||||
# 图片访问基础地址
|
||||
VITE_IMAGE_BASE_PATH = http://123.156.230.15:8089/api
|
||||
VITE_IMAGE_BASE_PATH = http://123.156.230.15:8089/api # 线上
|
||||
# VITE_IMAGE_BASE_PATH = http://pjcloud.center.takin.cc
|
||||
# VITE_IMAGE_BASE_PATH = http://localhost:9999
|
||||
# VITE_IMAGE_BASE_PATH = http://192.168.101.29:9999 # 邓-本地
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="dashboard">
|
||||
import navMmenu from './navMenu/index.vue';
|
||||
const navMmenu = defineAsyncComponent(() => import('./navMenu/index.vue'));
|
||||
|
||||
// const Widgets = defineAsyncComponent(() => import('./widgets/index.vue'));
|
||||
// const pageLoading = ref(true);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<el-card class="card" v-loading="loading">
|
||||
<el-row>
|
||||
<el-col :span="4" v-for="(item, index) in navMenuListTop" :key="index">
|
||||
<el-col :span="4" v-for="(item, index) in navMenuList" :key="index">
|
||||
<div :class="['nav-menu-item-top', item.id == currentActiveMenuId ? 'nav-menu-item-active' : '']" @click="currentActiveMenuId = item.id">
|
||||
<el-image class="nav-menu-item-icon" :src="imageBaseUrl + item.menuPic" fit="cover" />
|
||||
<div class="nav-menu-item-name">{{ $t(item.name) }}</div>
|
||||
@@ -10,8 +10,8 @@
|
||||
</el-row>
|
||||
<br />
|
||||
<el-row v-if="currentActiveMenuId" style="background-color: #e2eff677; border-radius: 1rem; padding: 2rem 6rem">
|
||||
<el-col :span="3" v-for="(item, index) in navMenuListBottom" :key="index">
|
||||
<div class="nav-menu-item-bottom" @click="handleClickBottomMenu(item)">
|
||||
<el-col v-for="(item, index) in navMenuListBottom" :key="index" :span="!item.meta?.isHide ? 3 : 0">
|
||||
<div v-if="!item.meta?.isHide" class="nav-menu-item-bottom" @click="handleClickBottomMenu(item)">
|
||||
<el-image class="nav-menu-item-icon" :src="imageBaseUrl + item.menuPic" fit="cover" />
|
||||
<div class="nav-menu-item-name">{{ $t(item.name) }}</div>
|
||||
</div>
|
||||
@@ -29,7 +29,6 @@ const router = useRouter();
|
||||
const menuApi = useMenuApi();
|
||||
const loading = ref(false);
|
||||
const navMenuList = ref<any>([]);
|
||||
const navMenuListTop = ref<any>([]);
|
||||
const currentActiveMenuId = ref('');
|
||||
const imageBaseUrl = import.meta.env.VITE_IMAGE_BASE_PATH;
|
||||
|
||||
@@ -37,16 +36,12 @@ const imageBaseUrl = import.meta.env.VITE_IMAGE_BASE_PATH;
|
||||
const getNavMenuList = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await menuApi.getAdminMenu().finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
const res = await menuApi.getAdminMenu().finally(() => (loading.value = false));
|
||||
if (res.code == 0 && res.data.length > 0) {
|
||||
navMenuList.value = res.data;
|
||||
navMenuListTop.value = res.data.map((item: any) => ({ id: item.id, name: item.name, path: item.path, menuPic: item.menuPic }));
|
||||
}
|
||||
} catch (error) {
|
||||
navMenuList.value = [];
|
||||
navMenuListTop.value = [];
|
||||
ElMessage.error('加载错误');
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -55,9 +50,7 @@ const getNavMenuList = async () => {
|
||||
const navMenuListBottom = computed(() => {
|
||||
if (navMenuList.value) {
|
||||
const currentMenuItem = navMenuList.value.find((item: any) => item.id == currentActiveMenuId.value);
|
||||
if (currentMenuItem && currentMenuItem.children) {
|
||||
return currentMenuItem.children.map((item: any) => ({ id: item.id, name: item.name, path: item.path, menuPic: item.menuPic }));
|
||||
}
|
||||
if (currentMenuItem && currentMenuItem.children) return currentMenuItem.children;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
@@ -67,6 +60,7 @@ const navMenuListBottom = computed(() => {
|
||||
const handleClickBottomMenu = (item: any) => {
|
||||
router.push(item.path);
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await getNavMenuList();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user