|
@@ -1,7 +1,7 @@
|
|
|
import { useState, useEffect } from "react";
|
|
import { useState, useEffect } from "react";
|
|
|
|
|
|
|
|
import { useAppSelector } from "../../hooks";
|
|
import { useAppSelector } from "../../hooks";
|
|
|
-import { message } from "../../reducers/command";
|
|
|
|
|
|
|
+import { lookupWord } from "../../reducers/command";
|
|
|
import Dictionary from "./Dictionary";
|
|
import Dictionary from "./Dictionary";
|
|
|
|
|
|
|
|
export interface IWidgetDict {
|
|
export interface IWidgetDict {
|
|
@@ -10,13 +10,13 @@ export interface IWidgetDict {
|
|
|
const DictComponentWidget = ({ word }: IWidgetDict) => {
|
|
const DictComponentWidget = ({ word }: IWidgetDict) => {
|
|
|
const [wordSearch, setWordSearch] = useState(word);
|
|
const [wordSearch, setWordSearch] = useState(word);
|
|
|
//接收查字典消息
|
|
//接收查字典消息
|
|
|
- const commandMsg = useAppSelector(message);
|
|
|
|
|
|
|
+ const searchWord = useAppSelector(lookupWord);
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
- console.log("get command", commandMsg);
|
|
|
|
|
- if (commandMsg?.type === "dict") {
|
|
|
|
|
- setWordSearch(commandMsg.prop?.word);
|
|
|
|
|
|
|
+ console.log("get command", searchWord);
|
|
|
|
|
+ if (typeof searchWord === "string") {
|
|
|
|
|
+ setWordSearch(searchWord);
|
|
|
}
|
|
}
|
|
|
- }, [commandMsg]);
|
|
|
|
|
|
|
+ }, [searchWord]);
|
|
|
|
|
|
|
|
return <Dictionary word={wordSearch} compact={true} />;
|
|
return <Dictionary word={wordSearch} compact={true} />;
|
|
|
};
|
|
};
|