Ver Fonte

add Confidence

visuddhinanda há 9 meses atrás
pai
commit
82a3448b4c

+ 24 - 0
dashboard-v4/dashboard/src/components/template/Confidence.tsx

@@ -0,0 +1,24 @@
+import { Tag } from "antd";
+
+interface IQaCtl {
+  value?: string;
+}
+const ConfidenceCtl = ({ value = "0%" }: IQaCtl) => {
+  const confidence = parseFloat(value.replace("%", "")); // 结果为 90
+  return <Tag color={confidence < 90 ? "red" : "green"}>{value}</Tag>;
+};
+
+interface IWidget {
+  props: string;
+}
+const Widget = ({ props }: IWidget) => {
+  const prop = JSON.parse(atob(props)) as IQaCtl;
+  console.log(prop);
+  return (
+    <>
+      <ConfidenceCtl {...prop} />
+    </>
+  );
+};
+
+export default Widget;

+ 3 - 0
dashboard-v4/dashboard/src/components/template/MdTpl.tsx

@@ -1,6 +1,7 @@
 import { GrammarPopShell } from "../dict/GrammarPop";
 import { GrammarPopShell } from "../dict/GrammarPop";
 import Ai from "./Ai";
 import Ai from "./Ai";
 import Article from "./Article";
 import Article from "./Article";
+import Confidence from "./Confidence";
 import DictPreferenceEditor from "./DictPreferenceEditor";
 import DictPreferenceEditor from "./DictPreferenceEditor";
 import Exercise from "./Exercise";
 import Exercise from "./Exercise";
 import GrammarTermLookup from "./GrammarTermLookup";
 import GrammarTermLookup from "./GrammarTermLookup";
@@ -72,6 +73,8 @@ const Widget = ({ tpl, props, children }: IWidgetMdTpl) => {
       return props ? <DictPreferenceEditor props={props} /> : <>无效的参数</>;
       return props ? <DictPreferenceEditor props={props} /> : <>无效的参数</>;
     case "ai":
     case "ai":
       return <Ai props={props ? props : ""} />;
       return <Ai props={props ? props : ""} />;
+    case "cf":
+      return <Confidence props={props ? props : ""} />;
     default:
     default:
       return <>未定义模版({tpl})</>;
       return <>未定义模版({tpl})</>;
   }
   }