MdTpl.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import Exercise from "./Exercise";
  2. import Note from "./Note";
  3. import Quote from "./Quote";
  4. import SentEdit from "./SentEdit";
  5. import SentRead from "./SentRead";
  6. import Term from "./Term";
  7. import WbwSent from "./WbwSent";
  8. import Wd from "./Wd";
  9. interface IWidgetMdTpl {
  10. tpl?: string;
  11. props?: string;
  12. children?: React.ReactNode;
  13. }
  14. const Widget = ({ tpl, props, children }: IWidgetMdTpl) => {
  15. switch (tpl) {
  16. case "term":
  17. return <Term props={props ? props : ""} />;
  18. case "note":
  19. return <Note props={props ? props : ""}>{children}</Note>;
  20. case "sentread":
  21. return <SentRead props={props ? props : ""} />;
  22. case "sentedit":
  23. return <SentEdit props={props ? props : ""} />;
  24. case "wbw_sent":
  25. return <WbwSent props={props ? props : ""} />;
  26. case "wd":
  27. return <Wd props={props ? props : ""} />;
  28. case "quote":
  29. return <Quote props={props ? props : ""} />;
  30. case "exercise":
  31. return <Exercise props={props ? props : ""}>{children}</Exercise>;
  32. default:
  33. return <>未定义模版({tpl})</>;
  34. }
  35. };
  36. export default Widget;