visuddhinanda 2 лет назад
Родитель
Сommit
906c9d78a4
1 измененных файлов с 29 добавлено и 0 удалено
  1. 29 0
      dashboard/src/reducers/cart-mode.ts

+ 29 - 0
dashboard/src/reducers/cart-mode.ts

@@ -0,0 +1,29 @@
+/**
+ * 查字典,添加术语命令
+ */
+import { createSlice, PayloadAction } from "@reduxjs/toolkit";
+
+import type { RootState } from "../store";
+
+interface IState {
+  mode?: string;
+}
+
+const initialState: IState = {};
+
+export const slice = createSlice({
+  name: "cart-mode",
+  initialState,
+  reducers: {
+    modeChange: (state, action: PayloadAction<string>) => {
+      state.mode = action.payload;
+    },
+  },
+});
+
+export const { modeChange } = slice.actions;
+
+export const mode = (state: RootState): string | undefined =>
+  state.cartMode.mode;
+
+export default slice.reducer;