Kaynağa Gözat

字典提交后刷新列表

visuddhinanda 2 yıl önce
ebeveyn
işleme
c03610a958
1 değiştirilmiş dosya ile 46 ekleme ve 11 silme
  1. 46 11
      dashboard/src/components/dict/DictContent.tsx

+ 46 - 11
dashboard/src/components/dict/DictContent.tsx

@@ -13,6 +13,7 @@ import DictGroupTitle from "./DictGroupTitle";
 import UserDictList from "./UserDictList";
 import { useAppSelector } from "../../hooks";
 import { currentUser } from "../../reducers/current-user";
+import { useState } from "react";
 
 export interface IDictWords {
   pass: string;
@@ -41,6 +42,50 @@ interface IWidget {
 const DictContentWidget = ({ word, data, compact }: IWidget) => {
   const intl = useIntl();
   const user = useAppSelector(currentUser);
+  const [myRefresh, setMyRefresh] = useState(false);
+
+  const MyDict = () => {
+    const [myTab, setMyTab] = useState<string>("list");
+    return (
+      <div>
+        <Tabs
+          size="small"
+          type="card"
+          style={{ backgroundColor: "white" }}
+          activeKey={myTab}
+          onChange={(activeKey: string) => setMyTab(activeKey)}
+          items={[
+            {
+              label: "列表",
+              key: "list",
+              children: (
+                <UserDictList
+                  studioName={user?.realName}
+                  word={word}
+                  compact={true}
+                  refresh={myRefresh}
+                  onRefresh={(value: boolean) => setMyRefresh(value)}
+                />
+              ),
+            },
+            {
+              label: "新建",
+              key: "new",
+              children: (
+                <MyCreate
+                  word={word}
+                  onSave={() => {
+                    setMyRefresh(true);
+                    setMyTab("list");
+                  }}
+                />
+              ),
+            },
+          ]}
+        />
+      </div>
+    );
+  };
 
   return (
     <>
@@ -106,17 +151,7 @@ const DictContentWidget = ({ word, data, compact }: IWidget) => {
               {
                 label: `单词本`,
                 key: "my",
-                children: (
-                  <div>
-                    <UserDictList
-                      studioName={user?.realName}
-                      word={word}
-                      compact={true}
-                    />
-                    <Divider>新建</Divider>
-                    <MyCreate word={word} />
-                  </div>
-                ),
+                children: <MyDict />,
               },
             ]}
           />