添加 Info 非空判断

This commit is contained in:
mrbunker
2022-10-12 22:06:12 +08:00
parent 4efd43b329
commit 83b76175b4

View File

@@ -2,7 +2,7 @@ import { memo } from "preact/compat";
/** 从原 info panel 抄一点精简的信息 */
export type Infos = {
codeText: string;
codeText?: string;
actorList: {
text: string;
link: string;
@@ -16,20 +16,26 @@ const Info = memo(({ infos }: { infos: Infos }) => {
<span
className="jop-info-code"
title="点击复制"
onClick={() => navigator.clipboard.writeText(infos.codeText)}
onClick={() => infos.codeText && navigator.clipboard.writeText(infos.codeText)}
>
{infos.codeText}
{infos.codeText ? infos.codeText : "暂无"}
</span>
<div class="jop-info-actor">
<a
class="jop-info-actor-item"
target="_blank"
href={infos.actorList[0].link}
>
{infos.actorList[0].text}
</a>
<span> </span>
{infos.actorList.length !== 0 ? (
<>
<a
class="jop-info-actor-item"
target="_blank"
href={infos.actorList[0].link}
>
{infos.actorList[0].text}
</a>
<span> </span>
</>
) : (
<div></div>
)}
</div>
{/* {info.actorList.map((item, index) => { const length = info.actorList.length; return ( <a href={item.link} style={{ paddingRight: length !== 1 && index !== length - 1 ? 16 : 0 }} > {item.text} </a> ); })} */}