react-toolkits 2.11.16 → 2.11.17

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/lib/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import axios, { AxiosHeaders } from 'axios';
1
+ import axios, { AxiosHeaders, isAxiosError } from 'axios';
2
2
  import { jwtDecode } from 'jwt-decode';
3
3
  import { create, useStore, createStore } from 'zustand';
4
4
  import { persist, createJSONStorage } from 'zustand/middleware';
5
- import * as Antd2 from 'antd';
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 { memo, useMemo, useCallback, useEffect, lazy, useContext, useState, useRef, Fragment as Fragment$1, Suspense, createContext, forwardRef, useImperativeHandle, cloneElement } from 'react';
5
+ import * as Antd from 'antd';
6
+ import { Spin, Menu, Modal, Form, Card, Input, Select, theme, Space, Tag, Typography, Result, Table, Button, Dropdown, Divider, Alert, App, Switch, InputNumber, Row, Col, Breadcrumb, Skeleton, Descriptions, Tooltip, Popconfirm, Empty, Collapse, Checkbox } from 'antd';
7
+ import { memo, useMemo, useCallback, useEffect, lazy, useContext, useState, useRef, Suspense, createContext, forwardRef, Fragment as Fragment$1, useImperativeHandle, cloneElement } from 'react';
8
8
  import useSWR5, { mutate, SWRConfig, unstable_serialize } from 'swr';
9
9
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
10
  import { has, template, get, isEqual } from 'lodash-es';
@@ -50,6 +50,14 @@ var init_storage = __esm({
50
50
  };
51
51
  }
52
52
  });
53
+ var createAxiosSlice;
54
+ var init_axios = __esm({
55
+ "src/stores/axios.ts"() {
56
+ createAxiosSlice = () => ({
57
+ axios: axios.create()
58
+ });
59
+ }
60
+ });
53
61
 
54
62
  // src/components/locale/en_GB.ts
55
63
  var locale, en_GB_default;
@@ -157,7 +165,8 @@ var init_context = __esm({
157
165
  usePermissionApiV2: false,
158
166
  gameApiV2: false,
159
167
  isGlobal: false,
160
- signInPath: "/"
168
+ signInPath: "/",
169
+ hideGame: false
161
170
  });
162
171
  }
163
172
  });
@@ -182,10 +191,11 @@ var init_game = __esm({
182
191
  if (token) {
183
192
  headers.setAuthorization("Bearer " + get2().token);
184
193
  }
185
- const games = apiV2 ? await axios({
194
+ const instance = get2().axios;
195
+ const games = apiV2 ? await instance({
186
196
  url: "/api/game/list",
187
197
  headers
188
- }).then((response) => response.data.data.list ?? []) : await axios({
198
+ }).then((response) => response.data.data.list ?? []) : await instance({
189
199
  url: "/api/usystem/game/all",
190
200
  headers
191
201
  }).then((response) => response.data.data ?? []);
@@ -224,6 +234,7 @@ var createToolkitsStore;
224
234
  var init_stores = __esm({
225
235
  "src/stores/index.ts"() {
226
236
  init_storage();
237
+ init_axios();
227
238
  init_context();
228
239
  init_game();
229
240
  init_token();
@@ -236,6 +247,7 @@ var init_stores = __esm({
236
247
  ...createTokenSlice(...args),
237
248
  ...createGameSlice(...args),
238
249
  ...createContextSlice(...args),
250
+ ...createAxiosSlice(...args),
239
251
  ...initProps,
240
252
  setContext: (props) => {
241
253
  set({ ...props });
@@ -272,43 +284,43 @@ var init_constants = __esm({
272
284
  FRONTEND_ROUTE_PREFIX = "/console/";
273
285
  }
274
286
  });
275
- var axiosInstance, requestInterceptorId, responseInterceptorId, Interceptor;
276
- var init_axios = __esm({
277
- "src/utils/axios.tsx"() {
278
- init_toolkitsProvider();
287
+ var Interceptors, Interceptors_default;
288
+ var init_Interceptors = __esm({
289
+ "src/components/interceptors/Interceptors.tsx"() {
279
290
  init_constants();
280
- axiosInstance = axios.create({
281
- baseURL: "/",
282
- headers: {
283
- "Content-Type": "application/json; charset=utf-8"
284
- }
285
- });
286
- Interceptor = ({ children }) => {
287
- const state = useToolkitsStore((s) => s);
291
+ init_toolkitsProvider();
292
+ Interceptors = ({ children }) => {
288
293
  const { notification } = App.useApp();
289
- if (requestInterceptorId) {
290
- axiosInstance.interceptors.request.eject(requestInterceptorId);
291
- }
292
- if (responseInterceptorId) {
293
- axiosInstance.interceptors.response.eject(responseInterceptorId);
294
- }
295
- const interceptors = state.interceptors;
294
+ const {
295
+ axios: axios2,
296
+ interceptors,
297
+ token,
298
+ usePermissionApiV2,
299
+ isGlobal,
300
+ game,
301
+ gameApiV2,
302
+ signInPath,
303
+ clearToken,
304
+ setUnregistered
305
+ } = useToolkitsStore((s) => s);
306
+ let requestInterceptorId;
307
+ let responseInterceptorId;
296
308
  if (interceptors?.request) {
297
- requestInterceptorId = axiosInstance.interceptors.request.use(...interceptors.request);
309
+ requestInterceptorId = axios2.interceptors.request.use(...interceptors.request);
298
310
  } else {
299
- requestInterceptorId = axiosInstance.interceptors.request.use((config) => {
311
+ requestInterceptorId = axios2.interceptors.request.use((config) => {
300
312
  const headers = new AxiosHeaders(config.headers);
301
313
  config.responseType = config.responseType || "json";
302
- if (state.token) {
303
- headers.set("Authorization", `Bearer ${state.token}`);
314
+ if (token) {
315
+ headers.setAuthorization(`Bearer ${token}`);
304
316
  }
305
- if (!headers.has(APP_ID_HEADER) && state.usePermissionApiV2) {
306
- if (state.isGlobal || !state.game) {
317
+ if (!headers.has(APP_ID_HEADER) && usePermissionApiV2) {
318
+ if (isGlobal || !game) {
307
319
  headers.set(APP_ID_HEADER, "global");
308
- } else if (state.gameApiV2) {
309
- headers.set(APP_ID_HEADER, state.game.game_id);
320
+ } else if (gameApiV2) {
321
+ headers.set(APP_ID_HEADER, game.game_id);
310
322
  } else {
311
- headers.set(APP_ID_HEADER, state.game.id);
323
+ headers.set(APP_ID_HEADER, game.id);
312
324
  }
313
325
  }
314
326
  headers.set("Accept", config.responseType === "blob" ? "application/octet-stream" : "application/json");
@@ -317,9 +329,9 @@ var init_axios = __esm({
317
329
  });
318
330
  }
319
331
  if (interceptors?.response) {
320
- responseInterceptorId = axiosInstance.interceptors.response.use(...interceptors.response);
332
+ responseInterceptorId = axios2.interceptors.response.use(...interceptors.response);
321
333
  } else {
322
- responseInterceptorId = axiosInstance.interceptors.response.use(
334
+ responseInterceptorId = axios2.interceptors.response.use(
323
335
  (response) => {
324
336
  const responseType = response.request.responseType || "json";
325
337
  if (responseType === "json") {
@@ -337,17 +349,17 @@ var init_axios = __esm({
337
349
  return response;
338
350
  },
339
351
  (error) => {
340
- if (axios.isAxiosError(error)) {
352
+ if (isAxiosError(error)) {
341
353
  const response = error.response;
342
354
  if (!response) {
343
355
  throw error;
344
356
  }
345
357
  if (response.status === 401 || response.status === 412) {
346
- state.clearToken?.();
358
+ clearToken?.();
347
359
  if (response.status === 412) {
348
- state.setUnregistered();
360
+ setUnregistered();
349
361
  }
350
- window.location.replace(state.signInPath);
362
+ window.location.replace(signInPath);
351
363
  } else if (response.status === 403) {
352
364
  notification.error({
353
365
  message: "Forbidden",
@@ -365,8 +377,22 @@ var init_axios = __esm({
365
377
  }
366
378
  );
367
379
  }
380
+ useEffect(() => {
381
+ return () => {
382
+ axios2.interceptors.request.eject(requestInterceptorId);
383
+ axios2.interceptors.response.eject(responseInterceptorId);
384
+ };
385
+ }, []);
368
386
  return children;
369
387
  };
388
+ Interceptors_default = Interceptors;
389
+ }
390
+ });
391
+
392
+ // src/components/interceptors/index.ts
393
+ var init_interceptors = __esm({
394
+ "src/components/interceptors/index.ts"() {
395
+ init_Interceptors();
370
396
  }
371
397
  });
372
398
  function useToolkitsStore(selector) {
@@ -374,36 +400,43 @@ function useToolkitsStore(selector) {
374
400
  if (!store) throw new Error("Missing ToolkitsProvider in the tree");
375
401
  return useStore(store, selector);
376
402
  }
377
- var ToolkitsContext, toolkitsStore, globalState, ToolkitsProvider, Provider_default;
403
+ var ToolkitsContext, toolkitsStore, globalState, ToolkitsProvider, withContext, Provider_default;
378
404
  var init_Provider = __esm({
379
405
  "src/components/toolkitsProvider/Provider.tsx"() {
380
406
  init_stores();
381
- init_axios();
407
+ init_interceptors();
382
408
  ToolkitsContext = createContext(null);
383
409
  ToolkitsProvider = (props) => {
384
410
  const { children, ...restProps } = props;
385
411
  const storeRef = useRef();
386
412
  if (!storeRef.current) {
387
- storeRef.current = createToolkitsStore({ ...globalState, ...restProps });
413
+ storeRef.current = createToolkitsStore({
414
+ ...globalState,
415
+ ...restProps
416
+ });
388
417
  }
389
418
  globalState = storeRef.current.getState();
390
419
  if (!globalState.signInPath) {
391
420
  throw new Error('ToolkitsProvider: \u8BF7\u914D\u7F6E "signInPath"');
392
421
  }
393
- return /* @__PURE__ */ jsx(ToolkitsContext.Provider, { value: storeRef.current, children: /* @__PURE__ */ jsx(App, { children: /* @__PURE__ */ jsx(
422
+ const { axios: axios2 } = globalState;
423
+ return /* @__PURE__ */ jsx(ToolkitsContext.Provider, { value: storeRef.current, children: /* @__PURE__ */ jsx(App, { children: /* @__PURE__ */ jsx(Interceptors_default, { children: /* @__PURE__ */ jsx(
394
424
  SWRConfig,
395
425
  {
396
426
  value: {
397
- fetcher: (arg) => {
398
- if (typeof arg === "string") {
399
- return axiosInstance.get(arg).then((res) => res.data.data);
400
- }
401
- return axiosInstance.request(arg).then((res) => res.data.data);
427
+ fetcher: async (arg) => {
428
+ const response = typeof arg === "string" ? await axios2.get(arg) : await axios2.request(arg);
429
+ return response.data.data;
402
430
  }
403
431
  },
404
- children: /* @__PURE__ */ jsx(Interceptor, { children })
432
+ children
405
433
  }
406
- ) }) });
434
+ ) }) }) });
435
+ };
436
+ withContext = (Component, providerProps) => {
437
+ return (props) => {
438
+ return /* @__PURE__ */ jsx(ToolkitsProvider, { ...providerProps, children: /* @__PURE__ */ jsx(Component, { ...props }) });
439
+ };
407
440
  };
408
441
  if (process.env.NODE_ENV !== "production") {
409
442
  ToolkitsProvider.displayName = "ToolkitsProvider";
@@ -522,10 +555,10 @@ var init_highlight = __esm({
522
555
  init_Highlight();
523
556
  }
524
557
  });
525
- function usePermissions(codes = [], config) {
558
+ function usePermissions(codes = []) {
526
559
  const usePermissionApiV2 = useToolkitsStore((state) => state.usePermissionApiV2);
527
560
  const url4 = usePermissionApiV2 ? "/api/usystem/user/checkV2" : "/api/usystem/user/check";
528
- const key = codes.length ? { ...config, method: "POST", url: url4, data: { permissions: codes } } : null;
561
+ const key = codes.length ? { method: "POST", url: url4, data: { permissions: codes } } : null;
529
562
  const { data, ...rest } = useSWR5(key);
530
563
  const newData = codes.reduce((acc, curr) => {
531
564
  acc[curr] = data?.has_all ? true : data?.[curr] ?? false;
@@ -533,8 +566,8 @@ function usePermissions(codes = [], config) {
533
566
  }, {});
534
567
  return { ...rest, data: newData };
535
568
  }
536
- function usePermission(code, config) {
537
- const { data, isValidating, isLoading } = usePermissions(code ? [code] : void 0, config);
569
+ function usePermission(code) {
570
+ const { data, isValidating, isLoading } = usePermissions(code ? [code] : void 0);
538
571
  if (code === void 0) {
539
572
  return {
540
573
  accessible: true,
@@ -559,9 +592,9 @@ var init_PermissionButton = __esm({
559
592
  init_permission();
560
593
  init_locale();
561
594
  PermissionButton = (props) => {
562
- const { children, code, showLoading, disabled, headers, ...restProps } = props;
595
+ const { children, code, showLoading, disabled, ...restProps } = props;
563
596
  const codes = code ? Array.isArray(code) ? code : [code] : [];
564
- const { data, isLoading } = usePermissions(codes, { headers });
597
+ const { data, isLoading } = usePermissions(codes);
565
598
  const { t } = useTranslation();
566
599
  if (isLoading) {
567
600
  return /* @__PURE__ */ jsx(Button, { loading: showLoading, disabled: !showLoading, ...restProps, children });
@@ -614,11 +647,10 @@ var init_stores2 = __esm({
614
647
  var QueryListAction, InternalQueryList, QueryList, QueryList_default;
615
648
  var init_QueryList = __esm({
616
649
  "src/components/queryList/QueryList.tsx"() {
617
- init_constants();
618
650
  init_permission();
619
- init_axios();
620
651
  init_filterFormWrapper();
621
652
  init_locale();
653
+ init_toolkitsProvider();
622
654
  init_stores2();
623
655
  QueryListAction = /* @__PURE__ */ ((QueryListAction2) => {
624
656
  QueryListAction2[QueryListAction2["Confirm"] = 0] = "Confirm";
@@ -649,7 +681,6 @@ var init_QueryList = __esm({
649
681
  tableExtra,
650
682
  form,
651
683
  body,
652
- isGlobal,
653
684
  params,
654
685
  renderForm,
655
686
  afterSuccess,
@@ -664,23 +695,22 @@ var init_QueryList = __esm({
664
695
  const { t } = useTranslation();
665
696
  const [_form] = Form.useForm(form);
666
697
  const action = useRef(3 /* Init */);
667
- let _headers = typeof headers === "function" ? headers(_form) : headers;
668
- if (isGlobal) {
669
- _headers = { ..._headers, [APP_ID_HEADER]: "global" };
670
- }
671
- const { accessible, isLoading } = usePermission(code, { headers: _headers });
698
+ const _headers = typeof headers === "function" ? headers(_form) : headers;
699
+ const { accessible, isLoading } = usePermission(code);
672
700
  const [isValid, setIsValid] = useState(false);
673
701
  const { keyMap, getPayload, refetch } = useQueryListStore();
674
702
  const { page, size = defaultSize, formValue } = getPayload(url4);
675
703
  const payload = { page, size, formValue };
676
- const _body = typeof body === "function" ? body(payload) : method === "POST" && typeof body === "undefined" ? {
704
+ const _body = typeof body === "function" ? body(payload) : typeof body === "undefined" ? method === "POST" ? {
677
705
  ...formValue,
678
- ...!onePage ? { page, size } : void 0
679
- } : body;
680
- const _params = typeof params === "function" ? params(payload) : method === "GET" && typeof params === "undefined" ? {
706
+ page: !onePage ? page : void 0,
707
+ size: !onePage ? size : void 0
708
+ } : void 0 : body;
709
+ const _params = typeof params === "function" ? params(payload) : typeof params === "undefined" ? method === "GET" ? {
681
710
  ...formValue,
682
- ...!onePage ? { page, size } : void 0
683
- } : void 0;
711
+ page: !onePage ? page : void 0,
712
+ size: !onePage ? size : void 0
713
+ } : void 0 : params;
684
714
  const shouldPoll = useRef(false);
685
715
  const requestConfig = {
686
716
  url: url4,
@@ -697,10 +727,11 @@ var init_QueryList = __esm({
697
727
  keyMap.set(url4, serializedKey);
698
728
  return serializedKey;
699
729
  }, [accessible, isValid, url4, requestConfig]);
730
+ const { axios: axios2 } = useToolkitsStore((s) => s);
700
731
  const { data, isValidating } = useSWR5(
701
732
  key,
702
733
  async () => {
703
- const response = await axiosInstance.request(requestConfig);
734
+ const response = await axios2.request(requestConfig);
704
735
  return response.data.data;
705
736
  },
706
737
  {
@@ -713,8 +744,8 @@ var init_QueryList = __esm({
713
744
  }
714
745
  }
715
746
  );
716
- const dataSource = useMemo(() => getDataSource(data, _form), [data, form, getDataSource]);
717
- const total = useMemo(() => getTotal(data), [data, getTotal]);
747
+ const dataSource = getDataSource(data, _form);
748
+ const total = getTotal(data);
718
749
  const pagination = !onePage && {
719
750
  showSizeChanger: true,
720
751
  showQuickJumper: true,
@@ -855,34 +886,36 @@ var init_constants2 = __esm({
855
886
  }
856
887
  });
857
888
  function useCreateMenu() {
889
+ const { axios: axios2 } = useToolkitsStore((s) => s);
858
890
  return useSWRMutation2(
859
891
  "/api/usystem/menu/set",
860
- (url4, { arg }) => axiosInstance.post(url4, { ...arg, id: 0, is_model: true })
892
+ (url4, { arg }) => axios2.post(url4, { ...arg, id: 0, is_model: true })
861
893
  );
862
894
  }
863
895
  function useUpdateMenu() {
896
+ const { axios: axios2 } = useToolkitsStore((s) => s);
864
897
  return useSWRMutation2(
865
898
  "/api/usystem/menu/set",
866
- (url4, { arg }) => axiosInstance.post(url4, { ...arg, is_model: true })
899
+ (url4, { arg }) => axios2.post(url4, { ...arg, is_model: true })
867
900
  );
868
901
  }
869
902
  function useMenuList() {
870
- const { game, signInPath } = useToolkitsStore((s) => s);
903
+ const { game, signInPath, axios: axios2 } = useToolkitsStore((s) => s);
871
904
  return useSWR5(
872
905
  window.location.pathname !== signInPath ? ["/api/usystem/menu/navbar", game] : null,
873
- ([url4]) => axiosInstance(url4).then((response) => response.data.data)
906
+ ([url4]) => axios2(url4).then((response) => response.data.data)
874
907
  );
875
908
  }
876
909
  function useRemoveMenu() {
910
+ const { axios: axios2 } = useToolkitsStore((s) => s);
877
911
  return useSWRMutation2(
878
912
  "/api/usystem/menu/delete",
879
- (url4, { arg }) => axiosInstance.post(url4, null, { params: { id: arg } })
913
+ (url4, { arg }) => axios2.post(url4, null, { params: { id: arg } })
880
914
  );
881
915
  }
882
916
  var init_hooks2 = __esm({
883
917
  "src/features/menu/hooks/index.ts"() {
884
918
  init_toolkitsProvider();
885
- init_axios();
886
919
  }
887
920
  });
888
921
 
@@ -903,6 +936,7 @@ var init_menu = __esm({
903
936
  function useModal(props) {
904
937
  const { content, onConfirm, ...modalProps } = props;
905
938
  const _id = useMemo(() => ++id, []);
939
+ console.log(typeof useModalStore);
906
940
  const modalStore = useModalStore();
907
941
  const open = modalStore.getOpen(_id);
908
942
  const [confirmLoading, setConfirmLoading] = useState(false);
@@ -1219,9 +1253,9 @@ __export(updateMenuItem_exports, {
1219
1253
  var EditMenuItem, updateMenuItem_default;
1220
1254
  var init_updateMenuItem = __esm({
1221
1255
  "src/pages/menu/updateMenuItem/index.tsx"() {
1256
+ init_toolkitsProvider();
1222
1257
  init_constants();
1223
1258
  init_menu();
1224
- init_axios();
1225
1259
  EditMenuItem = () => {
1226
1260
  const { message } = App.useApp();
1227
1261
  const [form] = Form.useForm();
@@ -1229,9 +1263,10 @@ var init_updateMenuItem = __esm({
1229
1263
  const { trigger } = useUpdateMenu();
1230
1264
  const params = useParams();
1231
1265
  const { mutate: mutate2 } = useMenuList();
1266
+ const { axios: axios2 } = useToolkitsStore((s) => s);
1232
1267
  const { data, isLoading } = useSWR5(
1233
1268
  `/api/usystem/menu/info?id=${params.id}`,
1234
- (url4) => axiosInstance(url4).then((response) => response.data.data)
1269
+ (url4) => axios2(url4).then((response) => response.data.data)
1235
1270
  );
1236
1271
  const onFinish = async (values) => {
1237
1272
  const { permissions, front_route, ...rest } = values;
@@ -1316,88 +1351,86 @@ var init_updateMenuItem = __esm({
1316
1351
  });
1317
1352
  function useAllPermissions() {
1318
1353
  return useSWR5({
1319
- url: "/api/usystem/user/allPermssions",
1320
- headers: { [APP_ID_HEADER]: "global" }
1354
+ url: "/api/usystem/user/allPermssions"
1321
1355
  });
1322
1356
  }
1323
1357
  function useAllPermissionsV2() {
1324
1358
  return useSWR5({
1325
- url: "/api/usystem/user/allPermissionsV2",
1326
- headers: { [APP_ID_HEADER]: "global" }
1359
+ url: "/api/usystem/user/allPermissionsV2"
1327
1360
  });
1328
1361
  }
1329
1362
  function useAllRoles() {
1330
- const { accessible } = usePermission("200005", { headers: { [APP_ID_HEADER]: "global" } });
1363
+ const { accessible } = usePermission("200005");
1331
1364
  return useSWR5(
1332
1365
  accessible ? {
1333
- url: "/api/usystem/role/all",
1334
- headers: { [APP_ID_HEADER]: "global" }
1366
+ url: "/api/usystem/role/all"
1335
1367
  } : null
1336
1368
  );
1337
1369
  }
1338
1370
  function useRole(name) {
1339
1371
  const usePermissionApiV2 = useToolkitsStore((state) => state.usePermissionApiV2);
1340
1372
  return useSWR5({
1341
- url: `/api/usystem/role/${usePermissionApiV2 ? "infoV2" : "info"}?name=${name}`,
1342
- headers: { [APP_ID_HEADER]: "global" }
1373
+ url: `/api/usystem/role/${usePermissionApiV2 ? "infoV2" : "info"}?name=${name}`
1343
1374
  });
1344
1375
  }
1345
1376
  function useCreateRole() {
1346
- const usePermissionApiV2 = useToolkitsStore((state) => state.usePermissionApiV2);
1377
+ const { axios: axios2, usePermissionApiV2 } = useToolkitsStore((s) => s);
1347
1378
  return useSWRMutation2(
1348
1379
  usePermissionApiV2 ? "/api/usystem/role/createV2" : "/api/usystem/role/create",
1349
1380
  (url4, {
1350
1381
  arg
1351
- }) => axiosInstance.post(url4, arg, { headers: { [APP_ID_HEADER]: "global" } })
1382
+ }) => axios2.post(url4, arg)
1352
1383
  );
1353
1384
  }
1354
1385
  function useUpdateRole() {
1355
- const usePermissionApiV2 = useToolkitsStore((state) => state.usePermissionApiV2);
1386
+ const { axios: axios2, usePermissionApiV2 } = useToolkitsStore((s) => s);
1356
1387
  return useSWRMutation2(
1357
1388
  usePermissionApiV2 ? "/api/usystem/role/updateV2" : "/api/usystem/role/update",
1358
1389
  (url4, {
1359
1390
  arg
1360
- }) => axiosInstance.post(url4, arg, { headers: { [APP_ID_HEADER]: "global" } })
1391
+ }) => axios2.post(url4, arg)
1361
1392
  );
1362
1393
  }
1363
1394
  function useRemoveRole() {
1395
+ const { axios: axios2 } = useToolkitsStore((s) => s);
1364
1396
  return useSWRMutation2(
1365
1397
  "/api/usystem/role/delete",
1366
1398
  (url4, {
1367
1399
  arg
1368
- }) => axiosInstance.post(url4, arg, { headers: { [APP_ID_HEADER]: "global" } })
1400
+ }) => axios2.post(url4, arg)
1369
1401
  );
1370
1402
  }
1371
1403
  function useCreateUser() {
1404
+ const { axios: axios2 } = useToolkitsStore((s) => s);
1372
1405
  return useSWRMutation2(
1373
1406
  "/api/usystem/user/create",
1374
1407
  (url4, {
1375
1408
  arg
1376
- }) => axiosInstance.post(url4, arg, { headers: { [APP_ID_HEADER]: "global" } })
1409
+ }) => axios2.post(url4, arg)
1377
1410
  );
1378
1411
  }
1379
1412
  function useUpdateUser() {
1413
+ const { axios: axios2 } = useToolkitsStore((s) => s);
1380
1414
  return useSWRMutation2(
1381
1415
  "/api/usystem/user/update",
1382
1416
  (url4, {
1383
1417
  arg
1384
- }) => axiosInstance.post(url4, arg, { headers: { [APP_ID_HEADER]: "global" } })
1418
+ }) => axios2.post(url4, arg)
1385
1419
  );
1386
1420
  }
1387
1421
  function useRemoveUser() {
1422
+ const { axios: axios2 } = useToolkitsStore((s) => s);
1388
1423
  return useSWRMutation2(
1389
1424
  "/api/usystem/user/delete",
1390
1425
  (url4, {
1391
1426
  arg
1392
- }) => axiosInstance.post(url4, arg, { headers: { [APP_ID_HEADER]: "global" } })
1427
+ }) => axios2.post(url4, arg)
1393
1428
  );
1394
1429
  }
1395
1430
  var init_hooks3 = __esm({
1396
1431
  "src/features/permission/hooks/index.ts"() {
1397
1432
  init_toolkitsProvider();
1398
- init_constants();
1399
1433
  init_permission();
1400
- init_axios();
1401
1434
  }
1402
1435
  });
1403
1436
  var PermissionCollapse, permissionCollapse_default;
@@ -1679,8 +1712,7 @@ var init_userList = __esm({
1679
1712
  init_locale();
1680
1713
  init_permissionButton();
1681
1714
  init_queryList();
1682
- init_stores2();
1683
- init_constants();
1715
+ init_toolkitsProvider();
1684
1716
  init_permission2();
1685
1717
  init_formModal();
1686
1718
  ({ Option: Option3 } = Select);
@@ -1773,7 +1805,6 @@ var init_userList = __esm({
1773
1805
  size: "small",
1774
1806
  type: "link",
1775
1807
  code: "100003",
1776
- headers: { [APP_ID_HEADER]: "global" },
1777
1808
  onClick: () => {
1778
1809
  showUpdateModal({
1779
1810
  initialValues: {
@@ -1795,7 +1826,6 @@ var init_userList = __esm({
1795
1826
  size: "small",
1796
1827
  code: "100004",
1797
1828
  type: "link",
1798
- headers: { [APP_ID_HEADER]: "global" },
1799
1829
  onClick: () => {
1800
1830
  modal.confirm({
1801
1831
  title: t("UserList.deleteTitle"),
@@ -1834,7 +1864,6 @@ var init_userList = __esm({
1834
1864
  type: "primary",
1835
1865
  icon: /* @__PURE__ */ jsx(UserAddOutlined, {}),
1836
1866
  code: "100002",
1837
- headers: { [APP_ID_HEADER]: "global" },
1838
1867
  onClick: () => {
1839
1868
  showCreateModal();
1840
1869
  },
@@ -1849,8 +1878,7 @@ var init_userList = __esm({
1849
1878
  rowKey: "id",
1850
1879
  columns,
1851
1880
  getTotal: (response) => response?.Total,
1852
- getDataSource: (response) => response?.List,
1853
- headers: { [APP_ID_HEADER]: "global" }
1881
+ getDataSource: (response) => response?.List
1854
1882
  }
1855
1883
  )
1856
1884
  }
@@ -1859,7 +1887,7 @@ var init_userList = __esm({
1859
1887
  updateModal
1860
1888
  ] });
1861
1889
  };
1862
- userList_default = UserList;
1890
+ userList_default = withContext(UserList, { isGlobal: true, hideGame: true });
1863
1891
  }
1864
1892
  });
1865
1893
 
@@ -1877,11 +1905,9 @@ var init_roleList = __esm({
1877
1905
  init_queryList();
1878
1906
  init_stores2();
1879
1907
  init_toolkitsProvider();
1880
- init_constants();
1881
1908
  init_permission2();
1882
1909
  init_formModal();
1883
1910
  init_permission();
1884
- init_axios();
1885
1911
  url3 = "/api/usystem/role/list";
1886
1912
  useModal3 = (isCreate) => {
1887
1913
  const { message } = App.useApp();
@@ -1933,20 +1959,17 @@ var init_roleList = __esm({
1933
1959
  });
1934
1960
  };
1935
1961
  RoleList = () => {
1936
- const { accessible: viewable } = usePermission("200005", { headers: { [APP_ID_HEADER]: "global" } });
1962
+ const { accessible: viewable } = usePermission("200005");
1937
1963
  const { modal, message } = App.useApp();
1938
1964
  const { t } = useTranslation();
1939
- const usePermissionApiV2 = useToolkitsStore((state) => state.usePermissionApiV2);
1965
+ const { axios: axios2, usePermissionApiV2 } = useToolkitsStore((s) => s);
1940
1966
  const { mutate: mutate2 } = useQueryListStore();
1941
1967
  const { show: showCreateModal, modal: createModal } = useModal3(true);
1942
1968
  const { show: showUpdateModal, modal: updateModal } = useModal3();
1943
1969
  const remove = useRemoveRole();
1944
1970
  const handleUpdateBtnClick = async (record) => {
1945
- const response = await axiosInstance.get(
1946
- `/api/usystem/role/info${usePermissionApiV2 ? "V2" : ""}?name=${record.name}`,
1947
- {
1948
- headers: { [APP_ID_HEADER]: "global" }
1949
- }
1971
+ const response = await axios2.get(
1972
+ `/api/usystem/role/info${usePermissionApiV2 ? "V2" : ""}?name=${record.name}`
1950
1973
  );
1951
1974
  const data = response.data.data;
1952
1975
  showUpdateModal({
@@ -1993,7 +2016,6 @@ var init_roleList = __esm({
1993
2016
  code: "200003",
1994
2017
  size: "small",
1995
2018
  type: "link",
1996
- headers: { [APP_ID_HEADER]: "global" },
1997
2019
  onClick: async () => {
1998
2020
  handleUpdateBtnClick(record);
1999
2021
  },
@@ -2007,7 +2029,6 @@ var init_roleList = __esm({
2007
2029
  code: "200004",
2008
2030
  size: "small",
2009
2031
  type: "link",
2010
- headers: { [APP_ID_HEADER]: "global" },
2011
2032
  onClick: () => {
2012
2033
  modal.confirm({
2013
2034
  title: t("RoleList.deleteTitle"),
@@ -2047,7 +2068,6 @@ var init_roleList = __esm({
2047
2068
  type: "primary",
2048
2069
  code: "200002",
2049
2070
  icon: /* @__PURE__ */ jsx(UsergroupAddOutlined, {}),
2050
- headers: { [APP_ID_HEADER]: "global" },
2051
2071
  onClick: () => {
2052
2072
  showCreateModal();
2053
2073
  },
@@ -2061,7 +2081,6 @@ var init_roleList = __esm({
2061
2081
  columns,
2062
2082
  code: "200001",
2063
2083
  url: url3,
2064
- headers: { [APP_ID_HEADER]: "global" },
2065
2084
  getTotal: (response) => response?.Total,
2066
2085
  getDataSource: (response) => response?.List
2067
2086
  }
@@ -2072,7 +2091,10 @@ var init_roleList = __esm({
2072
2091
  updateModal
2073
2092
  ] });
2074
2093
  };
2075
- roleList_default = RoleList;
2094
+ roleList_default = withContext(RoleList, {
2095
+ isGlobal: true,
2096
+ hideGame: true
2097
+ });
2076
2098
  }
2077
2099
  });
2078
2100
 
@@ -2085,6 +2107,7 @@ var RoleDetail, roleDetail_default;
2085
2107
  var init_roleDetail = __esm({
2086
2108
  "src/pages/permission/roleDetail/index.tsx"() {
2087
2109
  init_locale();
2110
+ init_toolkitsProvider();
2088
2111
  init_permission2();
2089
2112
  RoleDetail = () => {
2090
2113
  const params = useParams();
@@ -2117,7 +2140,7 @@ var init_roleDetail = __esm({
2117
2140
  ] }) })
2118
2141
  ] });
2119
2142
  };
2120
- roleDetail_default = RoleDetail;
2143
+ roleDetail_default = withContext(RoleDetail, { isGlobal: true, hideGame: true });
2121
2144
  }
2122
2145
  });
2123
2146
 
@@ -2277,15 +2300,16 @@ init_highlight();
2277
2300
 
2278
2301
  // src/components/infiniteList/InfiniteList.tsx
2279
2302
  init_permission();
2280
- init_axios();
2281
2303
  init_filterFormWrapper();
2282
2304
  init_locale();
2305
+ init_toolkitsProvider();
2283
2306
  var InfiniteList = (props) => {
2284
2307
  const { code, url: url4, extras, headers, getRowKey, getDataSource, hasMore, renderForm, transformArg, ...tableProps } = props;
2285
2308
  const { t } = useTranslation();
2286
2309
  const [form] = Form.useForm();
2287
2310
  const [isValid, setIsValid] = useState(false);
2288
2311
  const [formValues, setFormValues] = useState();
2312
+ const { axios: axios2 } = useToolkitsStore((s) => s);
2289
2313
  const getKey = (pageIndex, previousPageData) => {
2290
2314
  if (!isValid) return null;
2291
2315
  const rowKey = pageIndex !== 0 ? getRowKey(previousPageData) : void 0;
@@ -2294,9 +2318,7 @@ var InfiniteList = (props) => {
2294
2318
  return queryString ? `${url4}?${qs.stringify(args)}` : url4;
2295
2319
  };
2296
2320
  const _headers = typeof headers === "function" ? headers(form) : headers;
2297
- const { accessible, isLoading } = usePermission(code, {
2298
- headers: _headers
2299
- });
2321
+ const { accessible, isLoading } = usePermission(code);
2300
2322
  const {
2301
2323
  data,
2302
2324
  size,
@@ -2305,7 +2327,7 @@ var InfiniteList = (props) => {
2305
2327
  } = useSWRInfinite(
2306
2328
  getKey,
2307
2329
  async (arg) => {
2308
- const response = await axiosInstance({ url: arg, headers: _headers });
2330
+ const response = await axios2({ url: arg, headers: _headers });
2309
2331
  return response.data.data;
2310
2332
  },
2311
2333
  {
@@ -2499,45 +2521,16 @@ if (process.env.NODE_ENV === "development") {
2499
2521
  }
2500
2522
  var NavMenu_default = NavMenu;
2501
2523
 
2502
- // src/components/requireGame/RequireGame.tsx
2503
- init_locale();
2504
- init_toolkitsProvider();
2505
- var { Spin: Spin3 } = Antd2;
2506
- var RequireGame = ({ children }) => {
2507
- const { usePermissionApiV2, game, isLoading, isGlobal } = useToolkitsStore((s) => s);
2508
- const { t } = useTranslation();
2509
- if (isLoading) {
2510
- return /* @__PURE__ */ jsx(
2511
- "div",
2512
- {
2513
- style: {
2514
- display: "flex",
2515
- justifyContent: "center",
2516
- alignItems: "center",
2517
- height: 200
2518
- },
2519
- children: /* @__PURE__ */ jsx(Spin3, {})
2520
- }
2521
- );
2522
- }
2523
- if (usePermissionApiV2 && !isGlobal && !game) {
2524
- return /* @__PURE__ */ jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE, description: t("RequireGame.description") });
2525
- }
2526
- return /* @__PURE__ */ jsx(Fragment$1, { children }, game?.id ?? game?.game_id);
2527
- };
2528
- var RequireGame_default = RequireGame;
2529
-
2530
2524
  // src/components/layout/Layout.tsx
2531
2525
  init_toolkitsProvider();
2532
2526
 
2533
2527
  // src/components/userWidget/UserWidget.tsx
2534
2528
  init_locale();
2535
2529
  init_toolkitsProvider();
2536
- var UserWidget = (props) => {
2537
- const { logoutRedirectUrl } = props;
2530
+ var UserWidget = () => {
2538
2531
  const { t } = useTranslation();
2539
2532
  const navigate = useNavigate();
2540
- const { clearToken, getUser } = useToolkitsStore((state) => state);
2533
+ const { clearToken, getUser, signInPath } = useToolkitsStore((s) => s);
2541
2534
  const user = getUser();
2542
2535
  const items = [
2543
2536
  {
@@ -2548,7 +2541,7 @@ var UserWidget = (props) => {
2548
2541
  {
2549
2542
  onClick: () => {
2550
2543
  clearToken();
2551
- navigate(logoutRedirectUrl);
2544
+ navigate(signInPath);
2552
2545
  },
2553
2546
  children: t("UserWidget.signOutText")
2554
2547
  }
@@ -2632,31 +2625,19 @@ var useLayoutStore = create()(
2632
2625
  }
2633
2626
  )
2634
2627
  );
2635
- var { Spin: Spin4, theme: theme3 } = Antd2;
2636
- var { Header, Sider, Content } = Antd2.Layout;
2628
+ var { Spin: Spin3, theme: theme3 } = Antd;
2629
+ var { Header, Sider, Content } = Antd.Layout;
2637
2630
  var Layout2 = (props) => {
2638
- const {
2639
- menuCollapsible,
2640
- isMenuLoading,
2641
- title,
2642
- items,
2643
- headerExtra,
2644
- hideGameSelect,
2645
- children,
2646
- navWidth,
2647
- logoutRedirectUrl,
2648
- filter,
2649
- onGameChange
2650
- } = props;
2631
+ const { menuCollapsible, isMenuLoading, title, items, headerExtra, children, navWidth, filter, onGameChange } = props;
2651
2632
  const {
2652
2633
  token: { colorBgContainer, colorBorder }
2653
2634
  } = theme3.useToken();
2654
- const usePermissionApiV2 = useToolkitsStore((state) => state.usePermissionApiV2);
2635
+ const { usePermissionApiV2, hideGame } = useToolkitsStore((s) => s);
2655
2636
  const { collapsed, setCollapsed } = useLayoutStore();
2656
2637
  const onCollapse = async () => {
2657
2638
  setCollapsed(!collapsed);
2658
2639
  };
2659
- return /* @__PURE__ */ jsxs(Antd2.Layout, { children: [
2640
+ return /* @__PURE__ */ jsxs(Antd.Layout, { children: [
2660
2641
  /* @__PURE__ */ jsxs(
2661
2642
  Sider,
2662
2643
  {
@@ -2681,7 +2662,7 @@ var Layout2 = (props) => {
2681
2662
  ]
2682
2663
  }
2683
2664
  ),
2684
- /* @__PURE__ */ jsxs(Antd2.Layout, { children: [
2665
+ /* @__PURE__ */ jsxs(Antd.Layout, { children: [
2685
2666
  /* @__PURE__ */ jsx(
2686
2667
  Header,
2687
2668
  {
@@ -2700,12 +2681,12 @@ var Layout2 = (props) => {
2700
2681
  onClick: onCollapse
2701
2682
  }
2702
2683
  ),
2703
- usePermissionApiV2 && !hideGameSelect && /* @__PURE__ */ jsx(GameSelect_default, { filter, onGameChange }),
2684
+ usePermissionApiV2 && !hideGame && /* @__PURE__ */ jsx(GameSelect_default, { filter, onGameChange }),
2704
2685
  headerExtra?.left?.map((extra) => /* @__PURE__ */ jsx("span", { children: extra.children }, extra.key))
2705
2686
  ] }),
2706
2687
  /* @__PURE__ */ jsxs(Space, { size: "small", split: /* @__PURE__ */ jsx(Divider, { type: "vertical" }), children: [
2707
2688
  headerExtra?.right?.map((extra) => /* @__PURE__ */ jsx("span", { children: extra.children }, extra.key)),
2708
- /* @__PURE__ */ jsx(UserWidget_default, { logoutRedirectUrl })
2689
+ /* @__PURE__ */ jsx(UserWidget_default, {})
2709
2690
  ] })
2710
2691
  ] })
2711
2692
  }
@@ -2722,7 +2703,7 @@ var Layout2 = (props) => {
2722
2703
  Suspense,
2723
2704
  {
2724
2705
  fallback: /* @__PURE__ */ jsx(
2725
- Spin4,
2706
+ Spin3,
2726
2707
  {
2727
2708
  style: {
2728
2709
  display: "flex",
@@ -2732,7 +2713,7 @@ var Layout2 = (props) => {
2732
2713
  }
2733
2714
  }
2734
2715
  ),
2735
- children: /* @__PURE__ */ jsx(RequireGame_default, { children })
2716
+ children
2736
2717
  }
2737
2718
  )
2738
2719
  }
@@ -2747,15 +2728,11 @@ init_permissionButton();
2747
2728
  init_queryList();
2748
2729
 
2749
2730
  // src/components/requirePermission/RequirePermission.tsx
2750
- init_constants();
2751
2731
  init_permission();
2752
2732
  init_locale();
2753
2733
  var RequirePermission = (props) => {
2754
- const { code, isGlobal, children } = props;
2755
- const { accessible, isValidating } = usePermission(
2756
- code,
2757
- isGlobal ? { headers: { [APP_ID_HEADER]: "global" } } : void 0
2758
- );
2734
+ const { code, children } = props;
2735
+ const { accessible, isValidating } = usePermission(code);
2759
2736
  const { t } = useTranslation();
2760
2737
  if (isValidating) {
2761
2738
  return /* @__PURE__ */ jsx(
@@ -2781,9 +2758,6 @@ var RequirePermission_default = RequirePermission;
2781
2758
  init_toolkitsProvider();
2782
2759
  init_constants();
2783
2760
  init_menu();
2784
- init_formModal();
2785
- init_modal();
2786
- init_permission();
2787
2761
  var MenuItemList2 = lazy(() => Promise.resolve().then(() => (init_menuItemList(), menuItemList_exports)));
2788
2762
  var CreateMenuItem2 = lazy(() => Promise.resolve().then(() => (init_createMenuItem(), createMenuItem_exports)));
2789
2763
  var UpdateMenuItem = lazy(() => Promise.resolve().then(() => (init_updateMenuItem(), updateMenuItem_exports)));
@@ -2821,7 +2795,7 @@ var NotFound = (props) => {
2821
2795
  var notFound_default = NotFound;
2822
2796
  init_locale();
2823
2797
  init_queryList();
2824
- init_constants();
2798
+ init_toolkitsProvider();
2825
2799
  var { Option } = Select;
2826
2800
  var OperationLogList = () => {
2827
2801
  const { t } = useTranslation();
@@ -2884,7 +2858,6 @@ var OperationLogList = () => {
2884
2858
  columns,
2885
2859
  tableLayout: "fixed",
2886
2860
  url: "/api/usystem/log/list",
2887
- headers: { [APP_ID_HEADER]: "global" },
2888
2861
  getTotal: (response) => response?.Total,
2889
2862
  getDataSource: (response) => response?.List,
2890
2863
  renderForm: (form) => /* @__PURE__ */ jsxs(Form, { form, layout: "inline", children: [
@@ -2899,7 +2872,7 @@ var OperationLogList = () => {
2899
2872
  }
2900
2873
  ) });
2901
2874
  };
2902
- var operationLogList_default = OperationLogList;
2875
+ var operationLogList_default = withContext(OperationLogList, { isGlobal: true });
2903
2876
  var UserList2 = lazy(() => Promise.resolve().then(() => (init_userList(), userList_exports)));
2904
2877
  var RoleList2 = lazy(() => Promise.resolve().then(() => (init_roleList(), roleList_exports)));
2905
2878
  var RoleDetail2 = lazy(() => Promise.resolve().then(() => (init_roleDetail(), roleDetail_exports)));
@@ -2980,9 +2953,8 @@ var SignIn = (props) => {
2980
2953
  var signIn_default = SignIn;
2981
2954
 
2982
2955
  // src/index.ts
2983
- init_axios();
2984
2956
  init_storage();
2985
2957
 
2986
- export { APP_ID_HEADER, DynamicTags_default as DynamicTags, ExpandableParagraph_default as ExpandableParagraph, FRONTEND_ROUTE_PREFIX, FilterFormWrapper_default as FilterFormWrapper, Highlight_default as Highlight, InfiniteList_default as InfiniteList, Interceptor, Layout_default as Layout, NavMenu_default as NavMenu, notFound_default as NotFound, operationLogList_default as OperationLogList, PermissionButton_default as PermissionButton, QueryList_default as QueryList, QueryListAction, RequireGame_default as RequireGame, RequirePermission_default as RequirePermission, SSO_URL, signIn_default as SignIn, Provider_default as ToolkitsProvider, UserWidget_default as UserWidget, axiosInstance, menu_default as menuRoutes, mixedStorage, permission_default as permissionRoutes, toolkitsStore, useFormModal, useLayoutStore, useMenuList, useModal, useModalStore, usePermission, usePermissions, useQueryListStore, useToolkitsStore };
2958
+ export { APP_ID_HEADER, DynamicTags_default as DynamicTags, ExpandableParagraph_default as ExpandableParagraph, FRONTEND_ROUTE_PREFIX, FilterFormWrapper_default as FilterFormWrapper, Highlight_default as Highlight, InfiniteList_default as InfiniteList, Layout_default as Layout, NavMenu_default as NavMenu, notFound_default as NotFound, operationLogList_default as OperationLogList, PermissionButton_default as PermissionButton, QueryList_default as QueryList, QueryListAction, RequirePermission_default as RequirePermission, SSO_URL, signIn_default as SignIn, Provider_default as ToolkitsProvider, UserWidget_default as UserWidget, menu_default as menuRoutes, mixedStorage, permission_default as permissionRoutes, toolkitsStore, useFormModal, useLayoutStore, useMenuList, useModal, useModalStore, usePermission, usePermissions, useQueryListStore, useToolkitsStore, withContext };
2987
2959
  //# sourceMappingURL=index.js.map
2988
2960
  //# sourceMappingURL=index.js.map