Confidence.tsx 513 B

123456789101112131415161718192021222324
  1. import { Tag } from "antd";
  2. interface IQaCtl {
  3. value?: string;
  4. }
  5. const ConfidenceCtl = ({ value = "0%" }: IQaCtl) => {
  6. const confidence = parseFloat(value.replace("%", "")); // 结果为 90
  7. return <Tag color={confidence < 90 ? "red" : "green"}>{value}</Tag>;
  8. };
  9. interface IWidget {
  10. props: string;
  11. }
  12. const Widget = ({ props }: IWidget) => {
  13. const prop = JSON.parse(atob(props)) as IQaCtl;
  14. console.log(prop);
  15. return (
  16. <>
  17. <ConfidenceCtl {...prop} />
  18. </>
  19. );
  20. };
  21. export default Widget;