Prechádzať zdrojové kódy

发布变更支持句子编号

visuddhinanda 2 rokov pred
rodič
commit
4a0a0e12c5

+ 1 - 1
dashboard/src/components/discussion/AnchorCard.tsx

@@ -42,7 +42,7 @@ const AnchorCardWidget = ({
         }
         setMode(newMode);
         //发布mode变更
-        store.dispatch(modeChange(newMode as ArticleMode));
+        store.dispatch(modeChange({ mode: newMode as ArticleMode }));
       }}
     />
   );

+ 1 - 1
dashboard/src/pages/library/article/show.tsx

@@ -141,7 +141,7 @@ const Widget = () => {
   useEffect(() => {
     //发布mode变更
     console.log("发布mode变更", currMode);
-    store.dispatch(modeChange(currMode as ArticleMode));
+    store.dispatch(modeChange({ mode: currMode as ArticleMode }));
   }, [currMode]);
 
   console.log(anchorNavOpen, anchorNavShow);

+ 8 - 3
dashboard/src/reducers/article-mode.ts

@@ -6,18 +6,23 @@ import { ArticleMode } from "../components/article/Article";
 
 import type { RootState } from "../store";
 
-interface IState {
+interface IMode {
   id?: string;
   mode?: ArticleMode;
 }
 
+interface IState {
+  id?: string;
+  mode?: IMode;
+}
+
 const initialState: IState = {};
 
 export const slice = createSlice({
   name: "articleMode",
   initialState,
   reducers: {
-    modeChange: (state, action: PayloadAction<ArticleMode>) => {
+    modeChange: (state, action: PayloadAction<IMode>) => {
       state.mode = action.payload;
       console.log("mode", action.payload);
     },
@@ -26,7 +31,7 @@ export const slice = createSlice({
 
 export const { modeChange } = slice.actions;
 
-export const mode = (state: RootState): ArticleMode | undefined =>
+export const mode = (state: RootState): IMode | undefined =>
   state.articleMode.mode;
 
 export default slice.reducer;