Просмотр исходного кода

查词自动打开字典面板

visuddhinanda 2 лет назад
Родитель
Сommit
15367dd396

+ 14 - 1
dashboard/src/components/article/RightToolsSwitch.tsx

@@ -1,6 +1,8 @@
 import { Segmented } from "antd";
-import { useState } from "react";
+import { useEffect, useState } from "react";
 import { useIntl } from "react-intl";
+import { useAppSelector } from "../../hooks";
+import { rightPanel } from "../../reducers/right-panel";
 import { TPanelName } from "./RightPanel";
 
 interface IWidget {
@@ -13,6 +15,17 @@ const RightToolsSwitchWidget = ({
 }: IWidget) => {
   const intl = useIntl();
   const [mode, setMode] = useState<string>(initMode);
+  const _openPanel = useAppSelector(rightPanel);
+
+  useEffect(() => {
+    if (typeof _openPanel !== "undefined") {
+      if (typeof onModeChange !== "undefined") {
+        onModeChange(_openPanel);
+      }
+      setMode(_openPanel);
+    }
+  }, [_openPanel]);
+
   return (
     <Segmented
       size="middle"

+ 2 - 0
dashboard/src/components/template/Wbw/WbwDetailFm.tsx

@@ -12,6 +12,7 @@ import { useAppSelector } from "../../../hooks";
 import { inlineDict as _inlineDict } from "../../../reducers/inline-dict";
 import store from "../../../store";
 import { lookup } from "../../../reducers/command";
+import { openPanel } from "../../../reducers/right-panel";
 
 interface IWFMI {
   pali: string;
@@ -68,6 +69,7 @@ const WbwFactorMeaningItem = ({ pali, meaning, onChange }: IWFMI) => {
         onClick: (e) => {
           if (e.key === "_lookup") {
             store.dispatch(lookup(pali));
+            store.dispatch(openPanel("dict"));
           } else if (typeof onChange !== "undefined") {
             onChange(e.key);
           }