import { useIntl } from "react-intl"; import { useState } from "react"; import { Card, Space, Segmented } from "antd"; import store from "../../store"; import { modeChange } from "../../reducers/article-mode"; import type { ArticleMode } from "../article/Article" interface IWidgetArticleCard { title?: React.ReactNode; children?: React.ReactNode; onModeChange?: Function; } const AnchorCardWidget = ({ title, children, onModeChange, }: IWidgetArticleCard) => { const intl = useIntl(); const [mode, setMode] = useState("read"); const modeSwitch = ( { const newMode = value.toString(); if (typeof onModeChange !== "undefined") { if (mode === "read" || newMode === "read") { onModeChange(newMode); } } setMode(newMode); //发布mode变更 store.dispatch(modeChange({ mode: newMode as ArticleMode })); }} /> ); return ( {modeSwitch}}> {children} ); }; export default AnchorCardWidget;