您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

reducer.ts 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import ReducerRegistry from '../redux/ReducerRegistry';
  2. import { equals } from '../redux/functions';
  3. import { SET_JWT } from './actionTypes';
  4. export interface IJwtState {
  5. callee?: {
  6. name: string;
  7. };
  8. group?: string;
  9. jwt?: string;
  10. server?: string;
  11. tenant?: string;
  12. }
  13. /**
  14. * Reduces redux actions which affect the JSON Web Token (JWT) stored in the
  15. * redux store.
  16. *
  17. * @param {Object} state - The current redux state.
  18. * @param {Object} action - The redux action to reduce.
  19. * @returns {Object} The next redux state which is the result of reducing the
  20. * specified {@code action}.
  21. */
  22. ReducerRegistry.register<IJwtState>(
  23. 'features/base/jwt',
  24. (state = {}, action): IJwtState => {
  25. switch (action.type) {
  26. case SET_JWT: {
  27. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  28. const { type, ...payload } = action;
  29. const nextState = {
  30. ...payload
  31. };
  32. return equals(state, nextState) ? state : nextState;
  33. }
  34. }
  35. return state;
  36. });