|
@@ -6,6 +6,9 @@ import { IChannel } from "../channel/Channel";
|
|
|
import ChannelPickerTable from "../channel/ChannelPickerTable";
|
|
import ChannelPickerTable from "../channel/ChannelPickerTable";
|
|
|
import DictComponent from "../dict/DictComponent";
|
|
import DictComponent from "../dict/DictComponent";
|
|
|
import { ArticleType } from "./Article";
|
|
import { ArticleType } from "./Article";
|
|
|
|
|
+import { useAppSelector } from "../../hooks";
|
|
|
|
|
+import { openPanel, rightPanel } from "../../reducers/right-panel";
|
|
|
|
|
+import store from "../../store";
|
|
|
|
|
|
|
|
export type TPanelName = "dict" | "channel" | "close" | "open";
|
|
export type TPanelName = "dict" | "channel" | "close" | "open";
|
|
|
interface IWidget {
|
|
interface IWidget {
|
|
@@ -15,6 +18,7 @@ interface IWidget {
|
|
|
selectedChannelKeys?: string[];
|
|
selectedChannelKeys?: string[];
|
|
|
onChannelSelect?: Function;
|
|
onChannelSelect?: Function;
|
|
|
onClose?: Function;
|
|
onClose?: Function;
|
|
|
|
|
+ onTabChange?: Function;
|
|
|
}
|
|
}
|
|
|
const RightPanelWidget = ({
|
|
const RightPanelWidget = ({
|
|
|
curr = "close",
|
|
curr = "close",
|
|
@@ -23,8 +27,22 @@ const RightPanelWidget = ({
|
|
|
onChannelSelect,
|
|
onChannelSelect,
|
|
|
selectedChannelKeys,
|
|
selectedChannelKeys,
|
|
|
onClose,
|
|
onClose,
|
|
|
|
|
+ onTabChange,
|
|
|
}: IWidget) => {
|
|
}: IWidget) => {
|
|
|
const [open, setOpen] = useState(false);
|
|
const [open, setOpen] = useState(false);
|
|
|
|
|
+ const [activeTab, setActiveTab] = useState<string>("dict");
|
|
|
|
|
+
|
|
|
|
|
+ const _openPanel = useAppSelector(rightPanel);
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ console.log("panel", _openPanel);
|
|
|
|
|
+ if (typeof _openPanel !== "undefined") {
|
|
|
|
|
+ if (typeof onTabChange !== "undefined") {
|
|
|
|
|
+ onTabChange(_openPanel);
|
|
|
|
|
+ }
|
|
|
|
|
+ store.dispatch(openPanel(undefined));
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [_openPanel]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
switch (curr) {
|
|
switch (curr) {
|
|
@@ -33,9 +51,11 @@ const RightPanelWidget = ({
|
|
|
break;
|
|
break;
|
|
|
case "dict":
|
|
case "dict":
|
|
|
setOpen(true);
|
|
setOpen(true);
|
|
|
|
|
+ setActiveTab(curr);
|
|
|
break;
|
|
break;
|
|
|
case "channel":
|
|
case "channel":
|
|
|
setOpen(true);
|
|
setOpen(true);
|
|
|
|
|
+ setActiveTab(curr);
|
|
|
break;
|
|
break;
|
|
|
case "close":
|
|
case "close":
|
|
|
setOpen(false);
|
|
setOpen(false);
|
|
@@ -59,6 +79,8 @@ const RightPanelWidget = ({
|
|
|
<Tabs
|
|
<Tabs
|
|
|
size="small"
|
|
size="small"
|
|
|
defaultActiveKey={curr}
|
|
defaultActiveKey={curr}
|
|
|
|
|
+ activeKey={activeTab}
|
|
|
|
|
+ onChange={(activeKey: string) => setActiveTab(activeKey)}
|
|
|
tabBarExtraContent={{
|
|
tabBarExtraContent={{
|
|
|
right: (
|
|
right: (
|
|
|
<Button
|
|
<Button
|