From 08f1482313a2e75c65f751497e78878acc443a77 Mon Sep 17 00:00:00 2001 From: Kunagisa <1549184870@qq.com> Date: Wed, 9 Jul 2025 00:08:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E9=97=B2=E7=9A=84=E6=B2=A1?= =?UTF-8?q?=E4=BA=8B=E7=9E=8E=E5=87=A0=E6=8A=8A=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8D=E6=8B=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/index.vue | 108 +++++++++++++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 36 deletions(-) diff --git a/src/views/index.vue b/src/views/index.vue index 85e9af2..793073a 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -190,18 +190,18 @@ onUnmounted(() => { } }) -// 判断每个一级菜单是否有可见项 -const showTerrainList = true // 地形图列表始终可见 -const showTerrainGenerate = computed(() => isLoggedIn.value && currentUserData.value) -const showWeaponMatch = computed(() => isLoggedIn.value && currentUserData.value && hasPrivilegeWithTemp(currentUserData.value, ['lv-admin', 'lv-mod'])) -const showPic2Tga = computed(() => isLoggedIn.value && currentUserData.value) -const showDemands = computed(() => isLoggedIn.value && currentUserData.value) -const showCompetition = computed(() => isLoggedIn.value && currentUserData.value && hasPrivilegeWithTemp(currentUserData.value, ['lv-admin', 'lv-competitor'])) +// const showTerrainList = true // 地形图列表始终可见 +// const showTerrainGenerate = computed(() => isLoggedIn.value && currentUserData.value) +// const showWeaponMatch = computed(() => isLoggedIn.value && currentUserData.value && hasPrivilegeWithTemp(currentUserData.value, ['lv-admin', 'lv-mod'])) +// const showPic2Tga = computed(() => isLoggedIn.value && currentUserData.value) +// const showDemands = computed(() => isLoggedIn.value && currentUserData.value) +// const showCompetition = computed(() => isLoggedIn.value && currentUserData.value && hasPrivilegeWithTemp(currentUserData.value, ['lv-admin', 'lv-competitor'])) + +// const showTerrainMenu = computed(() => showTerrainList || showTerrainGenerate.value) +// const showOnlineToolsMenu = computed(() => showWeaponMatch.value || showPic2Tga.value) +// const showPublicMenu = computed(() => showDemands.value) +// const showCompetitionMenu = computed(() => showCompetition.value) -const showTerrainMenu = computed(() => showTerrainList || showTerrainGenerate.value) -const showOnlineToolsMenu = computed(() => showWeaponMatch.value || showPic2Tga.value) -const showPublicMenu = computed(() => showDemands.value) -const showCompetitionMenu = computed(() => showCompetition.value) const errorDialogVisible = ref(false) const errorDialogMessage = ref('') @@ -240,7 +240,17 @@ async function handlePrivilegeApply() { } function handleNavClick(route, privilegeList) { - if (!isLoggedIn.value || !currentUserData.value || !hasPrivilegeWithTemp(currentUserData.value, privilegeList)) { + if (!isLoggedIn.value || !currentUserData.value) { + // 未登录,直接跳转到登录页 + router.push('/backend/login') + return + } + // 如果没有传权限数组,登录即可访问 + if (!privilegeList) { + router.push(route) + return + } + if (!hasPrivilegeWithTemp(currentUserData.value, privilegeList)) { // 取权限数组中优先级最高的非lv-admin权限(如有),排除lv-user const order = ['lv-mod', 'lv-competitor', 'lv-map'] let privilegeKey = '' @@ -312,35 +322,61 @@ function handleUsernameChangeError(errorMessage) { 地形与纹理 - - + +