fixed add to cart bugs
This commit is contained in:
@@ -44,6 +44,20 @@ categories.get()
|
||||
|
||||
const user = useUserStore()
|
||||
user.get()
|
||||
|
||||
const token = useCookie("token");
|
||||
const cart = useCartStore();
|
||||
if (import.meta.client && localStorage.getItem("cart"))
|
||||
cart.items = JSON.parse(localStorage.getItem("cart") || "{}");
|
||||
watch(
|
||||
() => cart.items,
|
||||
(value) => {
|
||||
if (!token.value) {
|
||||
localStorage.setItem("cart", JSON.stringify(value));
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user