后台管理功能进行一些优化

This commit is contained in:
xiaowang
2026-02-28 14:32:28 +08:00
parent 36e2950a99
commit 725cb07fcf
23 changed files with 2297 additions and 92 deletions
+24 -3
View File
@@ -45,19 +45,40 @@
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import { computed, ref, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { HomeOutlined, ShoppingOutlined, ShoppingCartOutlined, UserOutlined } from '@ant-design/icons-vue'
import { cartApi } from '../api/cart'
import { message } from 'ant-design-vue'
const router = useRouter()
const route = useRoute()
// 购物车商品数量(示例数据)
const cartCount = ref(3)
// 购物车商品数量
const cartCount = ref(0)
// 是否有未读通知
const hasNotification = ref(true)
// 加载购物车数量
const loadCartCount = async () => {
try {
const data = await cartApi.getCartList()
cartCount.value = data.reduce((sum: number, item: any) => sum + item.quantity, 0)
} catch (error) {
console.error('获取购物车数量失败:', error)
}
}
// 页面加载时获取购物车数量
onMounted(() => {
// 检查当前是否是后台页面,如果是则不加载购物车数据
const isAdminPage = window.location.pathname.startsWith('/admin')
if (!isAdminPage) {
loadCartCount()
}
})
// 根据当前路由判断激活的导航项
const currentRoute = computed(() => {
const path = route.path