import { Popover, Typography } from "antd"; import { ArticleCtl, type TDisplayStyle } from "./Article" import { type IWidgetTermCtl, TermCtl } from "./Term" import { useEffect, useState } from "react"; const { Text } = Typography; interface IWidgetQuoteLinkCtl { type: string; bookName?: string; volume?: number; page?: number; style: TDisplayStyle; book?: number; para?: number; term?: IWidgetTermCtl; title?: string; chapter?: string; found: boolean; } const QuoteLinkCtl = ({ type, bookName, volume, page, style, book, para, term, title, chapter, found, }: IWidgetQuoteLinkCtl) => { const [tpl, setTpl] = useState(); let textShow = volume === 0 ? ` ${page}` : ` ${volume}.${page}`; if (type === "c") { textShow = ` ${chapter}`; } console.debug("found", found); useEffect(() => { if (type === "c") { setTpl(`{{ql|type=${type}|book=${book}|para=${para}}}`); } }, [book, para, type]); useEffect(() => { if ( typeof type !== "undefined" && typeof bookName !== "undefined" && typeof volume !== "undefined" && typeof page !== "undefined" ) { setTpl( `{{ql|type=${type}|bookname=${bookName}|volume=${volume}|page=${page}}}` ); } }, [bookName, found, page, type, volume]); return ( <> {found ? ( {textShow} ) } type={type === "c" ? "para" : "page"} focus={book && para ? `${book}-${para}` : undefined} id={ type === "c" ? `${book}-${para}` : `${type}_${bookName}_${volume}_${page}` } style={style} modalExtra={ 复制模版 } /> ) : ( {" "} {page} } trigger="hover" > {title ? ( title ) : ( <> {textShow} )} )} ); }; interface IWidget { props: string; } const Widget = ({ props }: IWidget) => { const prop = JSON.parse(atob(props)) as IWidgetQuoteLinkCtl; console.debug("QuoteLink", prop); return ( <> ); }; export default Widget;