react-toolkits 2.11.6 → 2.11.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # react-toolkits
2
2
 
3
+ ## 2.11.8
4
+
5
+ ### Patch Changes
6
+
7
+ - ec15f55: fix: missing 'signInPath' in ToolkitsProvider
8
+
9
+ ## 2.11.7
10
+
11
+ ### Patch Changes
12
+
13
+ - 19cfebf: fix: useNavigate missing router
14
+
3
15
  ## 2.11.6
4
16
 
5
17
  ### Patch Changes
package/lib/index.js CHANGED
@@ -4,7 +4,7 @@ import { create, useStore, createStore } from 'zustand';
4
4
  import { persist, createJSONStorage } from 'zustand/middleware';
5
5
  import * as Antd2 from 'antd';
6
6
  import { Spin, Menu, Modal, Form, App, theme, Space, Input, Tag, Typography, Result, Table, Button, Empty, Dropdown, Divider, Card, Select, Alert, Switch, InputNumber, Row, Col, Breadcrumb, Skeleton, Descriptions, Tooltip, Popconfirm, Collapse, Checkbox } from 'antd';
7
- import { useLocation, Routes, Route, Navigate, useNavigate, Link, useParams } from 'react-router-dom';
7
+ import { useLocation, Routes, Route, Navigate, Link, useNavigate, useParams } from 'react-router-dom';
8
8
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
9
  import { memo, useMemo, useCallback, useEffect, lazy, useContext, useState, useRef, Fragment as Fragment$1, Suspense, createContext, forwardRef, useImperativeHandle, cloneElement } from 'react';
10
10
  import useSWR5, { mutate, SWRConfig, unstable_serialize } from 'swr';
@@ -283,7 +283,6 @@ var init_axios = __esm({
283
283
  Interceptor = ({ children }) => {
284
284
  const state = useToolkitsStore((s) => s);
285
285
  const { notification } = App.useApp();
286
- const navaigate = useNavigate();
287
286
  if (!state.token) {
288
287
  return /* @__PURE__ */ jsx(Navigate, { to: state.signInPath });
289
288
  }
@@ -348,7 +347,7 @@ var init_axios = __esm({
348
347
  if (response.status === 412) {
349
348
  state.setUnregistered();
350
349
  }
351
- navaigate(state.signInPath);
350
+ window.location.replace(state.signInPath);
352
351
  } else if (response.status === 403) {
353
352
  notification.error({
354
353
  message: "Forbidden",
@@ -383,14 +382,14 @@ var init_Provider = __esm({
383
382
  ToolkitsContext = createContext(null);
384
383
  ToolkitsProvider = (props) => {
385
384
  const { children, ...restProps } = props;
386
- if (!restProps.signInPath) {
387
- throw new Error('ToolkitsProvider: \u8BF7\u914D\u7F6E "signInPath"');
388
- }
389
385
  const storeRef = useRef();
390
386
  if (!storeRef.current) {
391
387
  storeRef.current = createToolkitsStore({ ...globalState, ...restProps });
392
388
  }
393
389
  globalState = storeRef.current.getState();
390
+ if (!globalState.signInPath) {
391
+ throw new Error('ToolkitsProvider: \u8BF7\u914D\u7F6E "signInPath"');
392
+ }
394
393
  return /* @__PURE__ */ jsx(ToolkitsContext.Provider, { value: storeRef.current, children: /* @__PURE__ */ jsx(App, { children: /* @__PURE__ */ jsx(
395
394
  SWRConfig,
396
395
  {