Jelajahi Sumber

目录支持多选

visuddhinanda 3 tahun lalu
induk
melakukan
8a1bb49b59

+ 4 - 5
dashboard/src/components/corpus/BookTree.tsx

@@ -14,6 +14,7 @@ const { Text } = Typography;
 interface IWidgetBookTree {
   root?: string;
   path?: string[];
+  multiSelect?: boolean;
   onChange?: Function;
   onSelect?: Function;
   onRootChange?: Function;
@@ -21,6 +22,7 @@ interface IWidgetBookTree {
 const Widget = ({
   root = "default",
   path,
+  multiSelect = false,
   onChange,
   onSelect,
   onRootChange,
@@ -75,6 +77,7 @@ const Widget = ({
         />
       </Space>
       <Tree
+        multiple={multiSelect}
         showLine
         switcherIcon={<DownOutlined />}
         defaultExpandedKeys={["sutta"]}
@@ -83,11 +86,7 @@ const Widget = ({
           const node: ITocTree = info.node as unknown as ITocTree;
           console.log("tree selected", selectedKeys, node.path);
           if (typeof onChange !== "undefined") {
-            if (selectedKeys.length > 0) {
-              onChange(selectedKeys[0], node.path);
-            } else {
-              onChange("", []);
-            }
+            onChange(selectedKeys, node.path);
           }
           if (typeof onSelect !== "undefined") {
             onSelect(selectedKeys.length > 0 ? selectedKeys[0] : undefined);

+ 4 - 3
dashboard/src/pages/library/community/list.tsx

@@ -28,9 +28,10 @@ const Widget = () => {
               onRootChange={(root: string) =>
                 navigate("/palicanon/list/" + root)
               }
-              onChange={(key: string, path: string[]) => {
-                setTags(key.split(","));
-                console.log(key);
+              onChange={(key: string[], path: string[]) => {
+                if (key.length > 0) {
+                  setTags(key[0].split(","));
+                }
               }}
             />
           </div>

+ 4 - 2
dashboard/src/pages/library/palicanon/bypath.tsx

@@ -55,14 +55,16 @@ const Widget = () => {
                     onRootChange={(root: string) =>
                       navigate("/palicanon/list/" + root)
                     }
-                    onChange={(key: string, path: string[]) => {
+                    onChange={(key: string[], path: string[]) => {
                       navigate(
                         `/palicanon/list/${bookRoot}/${path
                           .join("-")
                           .toLowerCase()}`
                       );
                       console.log("key", key);
-                      setBookTag(key.split(","));
+                      if (key.length > 0) {
+                        setBookTag(key[0].split(","));
+                      }
                       setBookPath(path);
                     }}
                   />

+ 4 - 3
dashboard/src/pages/library/search/search.tsx

@@ -33,14 +33,15 @@ const Widget = () => {
           <Row>
             <Col xs={0} sm={6} md={5}>
               <BookTree
+                multiSelect={true}
                 root={bookRoot}
                 path={bookPath}
-                onChange={(key: string, path: string[]) => {
+                onChange={(key: string[], path: string[]) => {
                   console.log("key", key);
-                  if (key === "") {
+                  if (key.length === 0) {
                     searchParams.delete("tags");
                   } else {
-                    searchParams.set("tags", key);
+                    searchParams.set("tags", key.join(";"));
                   }
                   searchParams.delete("book");
                   setSearchParams(searchParams);