From ab6684227b4fc61fa54675e3a532a833ef6c5d84 Mon Sep 17 00:00:00 2001 From: xiaowang Date: Tue, 24 Feb 2026 10:57:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E7=99=BB=E5=BD=95=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E9=A1=B5=E9=9D=A2=E8=B7=B3=E8=BD=AC=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/src/router/index.ts | 4 +++- Frontend/src/views/AuthView.vue | 2 +- Frontend/src/views/HomeView.vue | 4 ++-- Frontend/src/views/ProductDetailView.vue | 2 +- Frontend/src/views/ProductListView.vue | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Frontend/src/router/index.ts b/Frontend/src/router/index.ts index 813ced6e..47f2da47 100644 --- a/Frontend/src/router/index.ts +++ b/Frontend/src/router/index.ts @@ -7,7 +7,7 @@ const router = createRouter({ path: '/', name: 'home', component: () => import('../views/HomeView.vue'), - meta: { requiresAuth: false } + meta: { requiresAuth: true } }, { path: '/auth', @@ -62,6 +62,8 @@ router.beforeEach((to, _from, next) => { next('/auth') } else if (to.path === '/auth' && token) { next('/') + } else if (to.path === '/' && !token) { + next('/auth') } else { next() } diff --git a/Frontend/src/views/AuthView.vue b/Frontend/src/views/AuthView.vue index c1ccc28c..e970c71d 100644 --- a/Frontend/src/views/AuthView.vue +++ b/Frontend/src/views/AuthView.vue @@ -209,7 +209,7 @@ const fetchShops = async () => { shops.value = response.data || [] } catch (error) { console.error('获取店铺列表失败:', error) - message.error('获取店铺列表失败') + message.error('未登录,请先登录') } finally { loadingShops.value = false } diff --git a/Frontend/src/views/HomeView.vue b/Frontend/src/views/HomeView.vue index 3e9783fb..34a2d82b 100644 --- a/Frontend/src/views/HomeView.vue +++ b/Frontend/src/views/HomeView.vue @@ -112,7 +112,7 @@ import { useRouter } from 'vue-router' import { BellOutlined, SearchOutlined, - FilterOutlined, + FilterOutlined, RightOutlined } from '@ant-design/icons-vue' @@ -419,4 +419,4 @@ const handleProductClick = (item: any) => { .popular-section { padding-bottom: 20px; } - \ No newline at end of file + diff --git a/Frontend/src/views/ProductDetailView.vue b/Frontend/src/views/ProductDetailView.vue index 604bddf5..da10814e 100644 --- a/Frontend/src/views/ProductDetailView.vue +++ b/Frontend/src/views/ProductDetailView.vue @@ -121,7 +121,7 @@ const fetchProductDetail = async () => { } } catch (error) { console.error('获取商品详情失败:', error) - ElMessage.error('获取商品详情失败,请稍后重试') + ElMessage.error('未登录,请先登录') } } diff --git a/Frontend/src/views/ProductListView.vue b/Frontend/src/views/ProductListView.vue index 08bde15d..064c1818 100644 --- a/Frontend/src/views/ProductListView.vue +++ b/Frontend/src/views/ProductListView.vue @@ -201,7 +201,7 @@ const fetchProducts = async () => { hasMore.value = false } catch (error) { console.error('获取商品失败:', error) - message.error('获取商品失败,请稍后重试') + message.error('未登录,请先登录') } finally { loading.value = false }