瀏覽代碼

套一个模版的组件外壳

visuddhinanda 3 年之前
父節點
當前提交
a3bd6fb361

+ 2 - 2
dashboard/src/components/nut/WbwTest.tsx

@@ -1,5 +1,5 @@
 import { IWbw } from "../template/Wbw/WbwWord";
 import { IWbw } from "../template/Wbw/WbwWord";
-import WbwSent from "../template/WbwSent";
+import { WbwSentCtl } from "../template/WbwSent";
 
 
 const Widget = () => {
 const Widget = () => {
   let wbwData: IWbw[] = [];
   let wbwData: IWbw[] = [];
@@ -26,7 +26,7 @@ const Widget = () => {
   return (
   return (
     <div>
     <div>
       <div style={{ width: 700 }}>
       <div style={{ width: 700 }}>
-        <WbwSent
+        <WbwSentCtl
           data={wbwData}
           data={wbwData}
           display="block"
           display="block"
           fields={{
           fields={{

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

@@ -3,6 +3,7 @@ import Quote from "./Quote";
 import SentEdit from "./SentEdit";
 import SentEdit from "./SentEdit";
 import SentRead from "./SentRead";
 import SentRead from "./SentRead";
 import Term from "./Term";
 import Term from "./Term";
+import WbwSent from "./WbwSent";
 import Wd from "./Wd";
 import Wd from "./Wd";
 
 
 interface IWidgetMdTpl {
 interface IWidgetMdTpl {
@@ -19,6 +20,8 @@ const Widget = ({ tpl, props }: IWidgetMdTpl) => {
       return <SentRead props={props ? props : ""} />;
       return <SentRead props={props ? props : ""} />;
     case "sentedit":
     case "sentedit":
       return <SentEdit props={props ? props : ""} />;
       return <SentEdit props={props ? props : ""} />;
+	  case "wbw_sent":
+		return <WbwSent props={props ? props : ""} />;
     case "wd":
     case "wd":
       return <Wd props={props ? props : ""} />;
       return <Wd props={props ? props : ""} />;
     case "quote":
     case "quote":

+ 9 - 1
dashboard/src/components/template/WbwSent.tsx

@@ -6,7 +6,7 @@ interface IWidget {
   display?: "block" | "inline";
   display?: "block" | "inline";
   fields?: IWbwFields;
   fields?: IWbwFields;
 }
 }
-const Widget = ({ data, display, fields }: IWidget) => {
+export const WbwSentCtl = ({ data, display, fields }: IWidget) => {
   const [wordData, setWordData] = useState(data);
   const [wordData, setWordData] = useState(data);
 
 
   return (
   return (
@@ -53,4 +53,12 @@ const Widget = ({ data, display, fields }: IWidget) => {
   );
   );
 };
 };
 
 
+interface IWidgetWbwSent {
+  props: string;
+}
+const Widget = ({ props }: IWidgetWbwSent) => {
+  const prop = JSON.parse(atob(props)) as IWidget;
+  return <WbwSentCtl {...prop} />;
+};
+
 export default Widget;
 export default Widget;