| import React, { useState } from 'react'; |
| import { followUser, unfollowUser } from '../api/api_ljc'; |
| const FollowButton = ({ userId, isFollowing, onFollowChange, style }) => { |
| const [loading, setLoading] = useState(false); |
| const handleFollow = async () => { |
| console.log('FollowButton clicked, isFollowing:', isFollowing, 'userId:', userId); |
| const res = await unfollowUser(userId); |
| console.log('unfollowUser response:', res); |
| const res = await followUser(userId); |
| console.log('followUser response:', res); |
| console.error('关注操作失败:', error); |
| cursor: loading ? 'not-allowed' : 'pointer', |
| background: isFollowing ? '#f5f5f5' : 'linear-gradient(90deg,#ff4b2b,#ff416c)', |
| color: isFollowing ? '#888' : '#fff', |
| boxShadow: isFollowing ? 'none' : '0 2px 8px #ff416c22', |
| {loading ? '处理中...' : isFollowing ? '已关注' : '+ 关注'} |
| export default FollowButton; |