forked from Gitlink/forgeplus-react
个人中心关注-关注或者取消关注未更新状态
This commit is contained in:
parent
67d914ddb6
commit
4b304ead34
|
@ -5,6 +5,7 @@ import "./list.css";
|
|||
|
||||
function FocusButton({is_watch , fontClass, starText, is_block , id , successFunc}){
|
||||
const [ isSpin , setIsSpin ] = useState(false);
|
||||
const [ watchFlag , setWatchFlag ] = useState(is_watch);
|
||||
// 关注和取消关注
|
||||
function focusFunc(flag){
|
||||
setIsSpin(true);
|
||||
|
@ -18,6 +19,7 @@ function FocusButton({is_watch , fontClass, starText, is_block , id , successFun
|
|||
}).then((result) => {
|
||||
if (result && result.data.status === 0) {
|
||||
successFunc && successFunc();
|
||||
setWatchFlag(!watchFlag);
|
||||
}
|
||||
setIsSpin(false);
|
||||
})
|
||||
|
@ -25,8 +27,8 @@ function FocusButton({is_watch , fontClass, starText, is_block , id , successFun
|
|||
};
|
||||
|
||||
return (
|
||||
<Button type={is_watch ? "default" : "primary"} ghost={!is_watch} block={is_block} loading={isSpin} onClick={() => focusFunc(is_watch)}>
|
||||
{is_watch ? (
|
||||
<Button type={watchFlag ? "default" : "primary"} ghost={!watchFlag} block={is_block} loading={isSpin} onClick={() => focusFunc(watchFlag)}>
|
||||
{watchFlag ? (
|
||||
<span className="">
|
||||
<i className="iconfont icon-shixing font-15 text-yellow mr-4"></i>
|
||||
<span className={fontClass || "font-12"}>已关注</span>
|
||||
|
|
Loading…
Reference in New Issue