杂务:打包并提交当前改动
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ref, onMounted, inject } from 'vue'
|
||||
import { ArrowLeft, Delete, StarFilled } from '@element-plus/icons-vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
@@ -55,6 +55,7 @@ import { cartApi } from '@/api/cart'
|
||||
import { fileApi } from '@/api/file'
|
||||
|
||||
const router = useRouter()
|
||||
const updateCartCount = inject<() => Promise<void>>('updateCartCount', async () => {})
|
||||
|
||||
const wishlistItems = ref<WishlistItem[]>([])
|
||||
const imageIdCache = ref<Record<string, string>>({})
|
||||
@@ -113,6 +114,7 @@ const getProductImages = (product: any): string[] => {
|
||||
const handleAddToCart = async (productId: number) => {
|
||||
try {
|
||||
await cartApi.addToCart({ productId, quantity: 1 })
|
||||
await updateCartCount()
|
||||
ElMessage.success('已添加到购物车')
|
||||
} catch (error) {
|
||||
console.error('添加到购物车失败:', error)
|
||||
@@ -257,4 +259,4 @@ onMounted(() => {
|
||||
margin: 20px 0;
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user