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}){
|
function FocusButton({is_watch , fontClass, starText, is_block , id , successFunc}){
|
||||||
const [ isSpin , setIsSpin ] = useState(false);
|
const [ isSpin , setIsSpin ] = useState(false);
|
||||||
|
const [ watchFlag , setWatchFlag ] = useState(is_watch);
|
||||||
// 关注和取消关注
|
// 关注和取消关注
|
||||||
function focusFunc(flag){
|
function focusFunc(flag){
|
||||||
setIsSpin(true);
|
setIsSpin(true);
|
||||||
|
@ -18,6 +19,7 @@ function FocusButton({is_watch , fontClass, starText, is_block , id , successFun
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
if (result && result.data.status === 0) {
|
if (result && result.data.status === 0) {
|
||||||
successFunc && successFunc();
|
successFunc && successFunc();
|
||||||
|
setWatchFlag(!watchFlag);
|
||||||
}
|
}
|
||||||
setIsSpin(false);
|
setIsSpin(false);
|
||||||
})
|
})
|
||||||
|
@ -25,8 +27,8 @@ function FocusButton({is_watch , fontClass, starText, is_block , id , successFun
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button type={is_watch ? "default" : "primary"} ghost={!is_watch} block={is_block} loading={isSpin} onClick={() => focusFunc(is_watch)}>
|
<Button type={watchFlag ? "default" : "primary"} ghost={!watchFlag} block={is_block} loading={isSpin} onClick={() => focusFunc(watchFlag)}>
|
||||||
{is_watch ? (
|
{watchFlag ? (
|
||||||
<span className="">
|
<span className="">
|
||||||
<i className="iconfont icon-shixing font-15 text-yellow mr-4"></i>
|
<i className="iconfont icon-shixing font-15 text-yellow mr-4"></i>
|
||||||
<span className={fontClass || "font-12"}>已关注</span>
|
<span className={fontClass || "font-12"}>已关注</span>
|
||||||
|
|
Loading…
Reference in New Issue