From b5c9aa67bf49ccf2993b29eead6720aa1a0625cd Mon Sep 17 00:00:00 2001
From: Kunagisa <1549184870@qq.com>
Date: Thu, 5 Jun 2025 21:36:55 +0800
Subject: [PATCH] =?UTF-8?q?index=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/backend/Dashboard.vue | 139 +++++---------------------
src/views/index.vue | 167 ++++++++++++++++++++++++--------
2 files changed, 151 insertions(+), 155 deletions(-)
diff --git a/src/views/backend/Dashboard.vue b/src/views/backend/Dashboard.vue
index a7bc389..4fca733 100644
--- a/src/views/backend/Dashboard.vue
+++ b/src/views/backend/Dashboard.vue
@@ -37,24 +37,6 @@
-
-
-
欢迎回来!
-
- 您当前没有管理员权限。请选择以下操作:
-
-
-
-
-
-
-
@@ -67,7 +49,7 @@ import ServiceHallView from '../../components/backend/ServiceHallView.vue'
const router = useRouter()
const hasToken = ref(false)
-const userId = ref(null)
+const userId = ref(localStorage.getItem('user_id'))
const currentAdminView = ref('event-management')
const isMobileSidebarOpen = ref(false)
@@ -79,19 +61,26 @@ onMounted(() => {
// 检查是否有token
const token = localStorage.getItem('access_token')
hasToken.value = !!token
- console.log('检测到token')
if (!token) {
- console.log('未检测到token')
router.push('/')
+ return;
}
- // 获取用户ID
- const storedUserId = localStorage.getItem('user_id')
- if (storedUserId) {
- userId.value = storedUserId
- console.log('当前用户ID:', userId.value)
+ // userId 应该已经从 localStorage 初始化了
+ // 可以在这里再次检查或记录,以防 localStorage 在组件加载后发生变化
+ const currentStoredUserId = localStorage.getItem('user_id');
+ if (currentStoredUserId) {
+ // 如果 ref 中的值与当前 localStorage 中的值不同(例如,初始为 null,现在有值了)
+ if (userId.value !== currentStoredUserId) {
+ userId.value = currentStoredUserId;
+ console.log('Dashboard.vue - 用户ID已在 onMounted 中更新:', userId.value);
+ } else {
+ console.log('Dashboard.vue - 当前用户ID (onMounted, 与初始值一致):', userId.value);
+ }
} else {
- console.log('未检测到用户ID')
+ // 如果 userId.value 为 null(初始即为 null 且 onMounted 时 localStorage 仍为 null)
+ // 并且我们删除了非管理员视图,管理员内容将不会显示
+ console.log('Dashboard.vue - 未在 localStorage 中检测到用户ID (onMounted)');
}
})
@@ -129,7 +118,7 @@ const selectAdminView = (viewName) => {
box-sizing: border-box;
}
-html, body, .dashboard-wrapper, .admin-layout {
+.dashboard-wrapper, .admin-layout {
height: 100%;
width: 100%;
overflow-x: hidden; /* Prevent horizontal scroll on body/wrapper */
@@ -155,7 +144,7 @@ html, body, .dashboard-wrapper, .admin-layout {
height: 100%; /* Full height */
position: fixed; /* Fixed position */
left: 0;
- top: 0;
+ top: 0px; /* Stick to the top of the webpage */
z-index: 1000;
transition: transform 0.3s ease;
box-shadow: 2px 0 8px rgba(0,0,0,0.1);
@@ -244,87 +233,6 @@ html, body, .dashboard-wrapper, .admin-layout {
transition: margin-left 0.3s ease;
}
-/* Non-Admin View Enhancements */
-.dashboard-content.non-admin-view {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- min-height: 100vh; /* Use min-height to ensure it covers viewport even if content is small */
- width: 100%;
- padding: 30px;
- background-color: #f0f2f5; /* Consistent light background */
- text-align: center; /* Center text for any messages */
-}
-
-.non-admin-view .non-admin-card {
- background-color: #ffffff;
- padding: 40px 50px;
- border-radius: 12px;
- box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
- max-width: 450px;
- width: 100%;
- display: flex;
- flex-direction: column;
- align-items: center; /* Center buttons if they are directly in this card */
-}
-
-.non-admin-view .welcome-message {
- font-size: 1.5rem; /* Slightly larger welcome/info text */
- color: #333;
- margin-bottom: 15px;
- font-weight: 500;
-}
-
-.non-admin-view .info-text {
- font-size: 0.95rem;
- color: #666;
- margin-bottom: 30px;
- line-height: 1.6;
-}
-
-.non-admin-view .button-group {
- /* Removed background, padding, shadow from here as it's now on non-admin-card */
- width: 100%; /* Button group takes full width of the card */
- display: flex;
- flex-direction: column; /* Stack buttons vertically */
- gap: 15px; /* Space between buttons */
-}
-
-.non-admin-view .button-group button {
- padding: 12px 25px; /* Slightly larger padding */
- border-radius: 8px; /* Slightly more rounded */
- font-weight: 500;
- font-size: 1rem; /* Standardized font size */
- transition: background-color 0.2s, transform 0.1s;
- border: none;
- color: #fff;
- cursor: pointer;
- width: 100%; /* Make buttons take full width of their container */
- text-align: center;
- display: flex;
- align-items: center;
- justify-content: center;
-}
-
-.non-admin-view .button-group button:hover {
- transform: translateY(-2px); /* Subtle lift on hover */
-}
-
-.non-admin-view .button-group .home-button {
- background-color: #0ea5e9; /* Sky blue */
-}
-.non-admin-view .button-group .home-button:hover {
- background-color: #0284c7; /* Darker sky blue */
-}
-
-.non-admin-view .button-group .logout-button {
- background-color: #ef4444; /* Red */
-}
-.non-admin-view .button-group .logout-button:hover {
- background-color: #dc2626; /* Darker Red */
-}
-
/* Mobile Header Styles */
.mobile-header {
display: none; /* Hidden by default, shown on mobile */
@@ -333,7 +241,7 @@ html, body, .dashboard-wrapper, .admin-layout {
padding: 10px 15px;
align-items: center;
position: fixed;
- top: 0;
+ top: 0px; /* Stick to the top of the webpage */
left: 0;
right: 0;
z-index: 1001; /* Above sidebar when closed */
@@ -396,7 +304,7 @@ html, body, .dashboard-wrapper, .admin-layout {
.admin-main-content {
margin-left: 0; /* Content takes full width */
- padding-top: 70px; /* Space for fixed mobile header */
+ padding-top: 55px; /* Space for fixed mobile header (now at top:0), adjusted from 70px */
}
.mobile-header {
@@ -425,8 +333,9 @@ html, body, .dashboard-wrapper, .admin-layout {
}
/* Styles for the placeholder non-admin page if it's not the main content area */
-.dashboard-container { /* This class was used before, ensure it doesn't conflict or remove if not needed */
- /* If this is for the non-admin view specifically, and it's outside admin-layout */
+/*
+.dashboard-container {
+
}
-
+*/
\ No newline at end of file
diff --git a/src/views/index.vue b/src/views/index.vue
index 81312bb..9698867 100644
--- a/src/views/index.vue
+++ b/src/views/index.vue
@@ -1,17 +1,28 @@
@@ -48,13 +67,24 @@ onMounted(async () => {