fix: button not opening default link
This commit is contained in:
@@ -13,22 +13,22 @@ const SiteBtn = ({ siteItem, CODE, multipleNavi, hiddenError }: Props) => {
|
|||||||
const { name, codeFormater } = siteItem;
|
const { name, codeFormater } = siteItem;
|
||||||
/** 格式化 CODE */
|
/** 格式化 CODE */
|
||||||
const formatCode = codeFormater ? codeFormater(CODE) : CODE;
|
const formatCode = codeFormater ? codeFormater(CODE) : CODE;
|
||||||
const link = siteItem.url.replace("{{code}}", formatCode);
|
const originLink = siteItem.url.replace("{{code}}", formatCode);
|
||||||
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [fetchRes, setFetchRes] = useState<FetchResult>();
|
const [fetchRes, setFetchRes] = useState<FetchResult>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
fetcher({ siteItem, targetLink: link, CODE: formatCode }).then((res) => {
|
fetcher({ siteItem, targetLink: originLink, CODE: formatCode }).then((res) => {
|
||||||
setFetchRes(res);
|
setFetchRes(res);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
}, [fetcher, siteItem, CODE, link]);
|
}, [fetcher, siteItem, CODE, originLink]);
|
||||||
|
|
||||||
const multipleFlag = multipleNavi && fetchRes?.multipleRes;
|
const multipleFlag = multipleNavi && fetchRes?.multipleRes;
|
||||||
const tag = multipleFlag ? "多结果" : fetchRes?.tag;
|
const tag = multipleFlag ? "多结果" : fetchRes?.tag;
|
||||||
const resultLink = multipleFlag ? fetchRes.multipResLink : fetchRes?.targetLink;
|
const resultLink = (multipleFlag ? fetchRes.multipResLink : fetchRes?.targetLink) ?? originLink;
|
||||||
const colorClass = fetchRes?.isSuccess ? "jop-button_green " : "jop-button_red ";
|
const colorClass = fetchRes?.isSuccess ? "jop-button_green " : "jop-button_red ";
|
||||||
|
|
||||||
if (hiddenError && !fetchRes?.isSuccess) {
|
if (hiddenError && !fetchRes?.isSuccess) {
|
||||||
@@ -38,7 +38,7 @@ const SiteBtn = ({ siteItem, CODE, multipleNavi, hiddenError }: Props) => {
|
|||||||
<a
|
<a
|
||||||
className={"jop-button " + (loading ? " " : colorClass)}
|
className={"jop-button " + (loading ? " " : colorClass)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href={resultLink === "" ? link : resultLink}
|
href={resultLink === "" ? originLink : resultLink}
|
||||||
>
|
>
|
||||||
{tag && <div className="jop-button_label">{tag}</div>}
|
{tag && <div className="jop-button_label">{tag}</div>}
|
||||||
|
|
||||||
|
|||||||
@@ -119,8 +119,8 @@ export const siteList: SiteItem[] = [
|
|||||||
url: "https://netflav5.com/search?type=title&keyword={{code}}",
|
url: "https://netflav5.com/search?type=title&keyword={{code}}",
|
||||||
fetchType: "parser",
|
fetchType: "parser",
|
||||||
domQuery: {
|
domQuery: {
|
||||||
linkQuery: ".grid_cell>a",
|
linkQuery: ".video_grid_container a",
|
||||||
titleQuery: ".grid_cell>a>.grid_title",
|
titleQuery: ".video_grid_container",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user