|
@@ -1,9 +1,10 @@
|
|
|
import { useState, useEffect } from "react";
|
|
import { useState, useEffect } from "react";
|
|
|
|
|
|
|
|
import { useAppSelector } from "../../hooks";
|
|
import { useAppSelector } from "../../hooks";
|
|
|
-import { lookup, lookupWord } from "../../reducers/command";
|
|
|
|
|
|
|
+import { lookup, lookupWord, myDictIsDirty } from "../../reducers/command";
|
|
|
import store from "../../store";
|
|
import store from "../../store";
|
|
|
import Dictionary from "./Dictionary";
|
|
import Dictionary from "./Dictionary";
|
|
|
|
|
+import { notification } from "antd";
|
|
|
|
|
|
|
|
export interface IWidgetDict {
|
|
export interface IWidgetDict {
|
|
|
word?: string;
|
|
word?: string;
|
|
@@ -12,12 +13,18 @@ const DictComponentWidget = ({ word }: IWidgetDict) => {
|
|
|
const [wordSearch, setWordSearch] = useState(word);
|
|
const [wordSearch, setWordSearch] = useState(word);
|
|
|
//接收查字典消息
|
|
//接收查字典消息
|
|
|
const searchWord = useAppSelector(lookupWord);
|
|
const searchWord = useAppSelector(lookupWord);
|
|
|
|
|
+ const myDictDirty = useAppSelector(myDictIsDirty);
|
|
|
|
|
+
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
console.log("get command", searchWord);
|
|
console.log("get command", searchWord);
|
|
|
|
|
+ if (myDictDirty) {
|
|
|
|
|
+ notification.warning({ message: "用户词典有未保存内容,请保存后再查词" });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
if (typeof searchWord === "string" && searchWord !== wordSearch) {
|
|
if (typeof searchWord === "string" && searchWord !== wordSearch) {
|
|
|
setWordSearch(searchWord);
|
|
setWordSearch(searchWord);
|
|
|
}
|
|
}
|
|
|
- }, [searchWord]);
|
|
|
|
|
|
|
+ }, [searchWord, myDictDirty, wordSearch]);
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<Dictionary
|
|
<Dictionary
|