提交Salon旧接口清理与安全配置基线
This commit is contained in:
@@ -19,15 +19,6 @@
|
||||
<span class="nav-label">作品集</span>
|
||||
</button>
|
||||
|
||||
<button class="nav-item" :class="{ active: currentRoute === 'cart' }" type="button" @click="handleNavClick('cart')">
|
||||
<a-badge :count="cartCount" :offset="[0, 0]">
|
||||
<div class="nav-icon">
|
||||
<ShoppingCartOutlined :style="{ fontSize: '25px' }" />
|
||||
</div>
|
||||
</a-badge>
|
||||
<span class="nav-label">购物车</span>
|
||||
</button>
|
||||
|
||||
<button class="nav-item" :class="{ active: currentRoute === 'profile' }" type="button" @click="handleNavClick('profile')">
|
||||
<a-badge :dot="hasNotification" :offset="[0, 0]">
|
||||
<div class="nav-icon">
|
||||
@@ -45,9 +36,9 @@
|
||||
* BottomNav page script.
|
||||
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
||||
*/
|
||||
import { computed, inject, onMounted, ref } from 'vue'
|
||||
import { computed } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { HomeOutlined, ShoppingOutlined, ShoppingCartOutlined, UserOutlined } from '@ant-design/icons-vue'
|
||||
import { HomeOutlined, ShoppingOutlined, UserOutlined } from '@ant-design/icons-vue'
|
||||
|
||||
/**
|
||||
* Purpose: router supports BottomNav.vue by holding or executing the router page or API role.
|
||||
@@ -60,38 +51,10 @@ const router = useRouter()
|
||||
*/
|
||||
const route = useRoute()
|
||||
|
||||
// 注入全局购物车数量状态
|
||||
const cartCount = inject('cartCount', ref(0))
|
||||
|
||||
// 注入更新购物车数量的方法
|
||||
const updateCartCount = inject<() => Promise<void>>('updateCartCount', async () => {})
|
||||
|
||||
// 是否有未读通知
|
||||
/** hasNotification is a reactive state variable used by the template and event handlers. */
|
||||
const hasNotification = computed(() => true)
|
||||
|
||||
// 加载购物车数量
|
||||
/** loadCartCount is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const loadCartCount = async () => {
|
||||
// 这里我们不需要做任何事情,因为全局状态会自动更新
|
||||
// 但我们仍然需要这个方法,因为 App.vue 会调用它
|
||||
}
|
||||
|
||||
// 页面加载时获取购物车数量
|
||||
onMounted(() => {
|
||||
// 检查当前是否是后台页面,如果是则不加载购物车数据
|
||||
const isAdminPage = window.location.pathname.startsWith('/admin')
|
||||
if (!isAdminPage) {
|
||||
// 调用全局更新方法
|
||||
updateCartCount()
|
||||
}
|
||||
})
|
||||
|
||||
// 提供一个方法让其他组件调用更新购物车数量
|
||||
defineExpose({
|
||||
loadCartCount
|
||||
})
|
||||
|
||||
// 根据当前路由判断激活的导航项
|
||||
/** currentRoute is a reactive state variable used by the template and event handlers. */
|
||||
const currentRoute = computed(() => {
|
||||
@@ -100,9 +63,7 @@ const currentRoute = computed(() => {
|
||||
if (path === '/') return 'home'
|
||||
if (path === '/products') return 'products'
|
||||
if (path === '/product') return 'products'
|
||||
if (path === '/cart') return 'cart'
|
||||
if (path === '/profile') return 'profile'
|
||||
if (path === '/wishlist') return 'profile'
|
||||
return 'home'
|
||||
})
|
||||
|
||||
@@ -113,8 +74,6 @@ const handleNavClick = (tab: string) => {
|
||||
router.push('/home')
|
||||
} else if (tab === 'products') {
|
||||
router.push('/products')
|
||||
} else if (tab === 'cart') {
|
||||
router.push('/cart')
|
||||
} else if (tab === 'profile') {
|
||||
router.push('/profile')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user