react-toolkits 2.11.15 → 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,16 +592,17 @@ 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;
563
- const { data, isLoading } = usePermissions(Array.isArray(code) ? code : [code], { headers });
595
+ const { children, code, showLoading, disabled, ...restProps } = props;
596
+ const codes = code ? Array.isArray(code) ? code : [code] : [];
597
+ const { data, isLoading } = usePermissions(codes);
564
598
  const { t } = useTranslation();
565
599
  if (isLoading) {
566
600
  return /* @__PURE__ */ jsx(Button, { loading: showLoading, disabled: !showLoading, ...restProps, children });
567
601
  }
568
- if (!Object.values(data ?? {})?.some(Boolean)) {
569
- return /* @__PURE__ */ jsx(Tooltip, { defaultOpen: false, title: t("global.noEntitlement"), children: /* @__PURE__ */ jsx(Button, { disabled: true, ...restProps, children }) });
602
+ if (codes.length === 0 || Object.values(data).some(Boolean)) {
603
+ return /* @__PURE__ */ jsx(Button, { disabled, ...restProps, children });
570
604
  }
571
- return /* @__PURE__ */ jsx(Button, { disabled, ...restProps, children });
605
+ return /* @__PURE__ */ jsx(Tooltip, { defaultOpen: false, title: t("global.noEntitlement"), children: /* @__PURE__ */ jsx(Button, { disabled: true, ...restProps, children }) });
572
606
  };
573
607
  PermissionButton_default = PermissionButton;
574
608
  }
@@ -613,11 +647,10 @@ var init_stores2 = __esm({
613
647
  var QueryListAction, InternalQueryList, QueryList, QueryList_default;
614
648
  var init_QueryList = __esm({
615
649
  "src/components/queryList/QueryList.tsx"() {
616
- init_constants();
617
650
  init_permission();
618
- init_axios();
619
651
  init_filterFormWrapper();
620
652
  init_locale();
653
+ init_toolkitsProvider();
621
654
  init_stores2();
622
655
  QueryListAction = /* @__PURE__ */ ((QueryListAction2) => {
623
656
  QueryListAction2[QueryListAction2["Confirm"] = 0] = "Confirm";
@@ -648,7 +681,6 @@ var init_QueryList = __esm({
648
681
  tableExtra,
649
682
  form,
650
683
  body,
651
- isGlobal,
652
684
  params,
653
685
  renderForm,
654
686
  afterSuccess,
@@ -663,23 +695,22 @@ var init_QueryList = __esm({
663
695
  const { t } = useTranslation();
664
696
  const [_form] = Form.useForm(form);
665
697
  const action = useRef(3 /* Init */);
666
- let _headers = typeof headers === "function" ? headers(_form) : headers;
667
- if (isGlobal) {
668
- _headers = { ..._headers, [APP_ID_HEADER]: "global" };
669
- }
670
- const { accessible, isLoading } = usePermission(code, { headers: _headers });
698
+ const _headers = typeof headers === "function" ? headers(_form) : headers;
699
+ const { accessible, isLoading } = usePermission(code);
671
700
  const [isValid, setIsValid] = useState(false);
672
701
  const { keyMap, getPayload, refetch } = useQueryListStore();
673
702
  const { page, size = defaultSize, formValue } = getPayload(url4);
674
703
  const payload = { page, size, formValue };
675
- 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" ? {
676
705
  ...formValue,
677
- ...!onePage ? { page, size } : void 0
678
- } : body;
679
- 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" ? {
680
710
  ...formValue,
681
- ...!onePage ? { page, size } : void 0
682
- } : void 0;
711
+ page: !onePage ? page : void 0,
712
+ size: !onePage ? size : void 0
713
+ } : void 0 : params;
683
714
  const shouldPoll = useRef(false);
684
715
  const requestConfig = {
685
716
  url: url4,
@@ -696,10 +727,11 @@ var init_QueryList = __esm({
696
727
  keyMap.set(url4, serializedKey);
697
728
  return serializedKey;
698
729
  }, [accessible, isValid, url4, requestConfig]);
730
+ const { axios: axios2 } = useToolkitsStore((s) => s);
699
731
  const { data, isValidating } = useSWR5(
700
732
  key,
701
733
  async () => {
702
- const response = await axiosInstance.request(requestConfig);
734
+ const response = await axios2.request(requestConfig);
703
735
  return response.data.data;
704
736
  },
705
737
  {
@@ -712,8 +744,8 @@ var init_QueryList = __esm({
712
744
  }
713
745
  }
714
746
  );
715
- const dataSource = useMemo(() => getDataSource(data, _form), [data, form, getDataSource]);
716
- const total = useMemo(() => getTotal(data), [data, getTotal]);
747
+ const dataSource = getDataSource(data, _form);
748
+ const total = getTotal(data);
717
749
  const pagination = !onePage && {
718
750
  showSizeChanger: true,
719
751
  showQuickJumper: true,
@@ -854,34 +886,36 @@ var init_constants2 = __esm({
854
886
  }
855
887
  });
856
888
  function useCreateMenu() {
889
+ const { axios: axios2 } = useToolkitsStore((s) => s);
857
890
  return useSWRMutation2(
858
891
  "/api/usystem/menu/set",
859
- (url4, { arg }) => axiosInstance.post(url4, { ...arg, id: 0, is_model: true })
892
+ (url4, { arg }) => axios2.post(url4, { ...arg, id: 0, is_model: true })
860
893
  );
861
894
  }
862
895
  function useUpdateMenu() {
896
+ const { axios: axios2 } = useToolkitsStore((s) => s);
863
897
  return useSWRMutation2(
864
898
  "/api/usystem/menu/set",
865
- (url4, { arg }) => axiosInstance.post(url4, { ...arg, is_model: true })
899
+ (url4, { arg }) => axios2.post(url4, { ...arg, is_model: true })
866
900
  );
867
901
  }
868
902
  function useMenuList() {
869
- const { game, signInPath } = useToolkitsStore((s) => s);
903
+ const { game, signInPath, axios: axios2 } = useToolkitsStore((s) => s);
870
904
  return useSWR5(
871
905
  window.location.pathname !== signInPath ? ["/api/usystem/menu/navbar", game] : null,
872
- ([url4]) => axiosInstance(url4).then((response) => response.data.data)
906
+ ([url4]) => axios2(url4).then((response) => response.data.data)
873
907
  );
874
908
  }
875
909
  function useRemoveMenu() {
910
+ const { axios: axios2 } = useToolkitsStore((s) => s);
876
911
  return useSWRMutation2(
877
912
  "/api/usystem/menu/delete",
878
- (url4, { arg }) => axiosInstance.post(url4, null, { params: { id: arg } })
913
+ (url4, { arg }) => axios2.post(url4, null, { params: { id: arg } })
879
914
  );
880
915
  }
881
916
  var init_hooks2 = __esm({
882
917
  "src/features/menu/hooks/index.ts"() {
883
918
  init_toolkitsProvider();
884
- init_axios();
885
919
  }
886
920
  });
887
921
 
@@ -902,6 +936,7 @@ var init_menu = __esm({
902
936
  function useModal(props) {
903
937
  const { content, onConfirm, ...modalProps } = props;
904
938
  const _id = useMemo(() => ++id, []);
939
+ console.log(typeof useModalStore);
905
940
  const modalStore = useModalStore();
906
941
  const open = modalStore.getOpen(_id);
907
942
  const [confirmLoading, setConfirmLoading] = useState(false);
@@ -1218,9 +1253,9 @@ __export(updateMenuItem_exports, {
1218
1253
  var EditMenuItem, updateMenuItem_default;
1219
1254
  var init_updateMenuItem = __esm({
1220
1255
  "src/pages/menu/updateMenuItem/index.tsx"() {
1256
+ init_toolkitsProvider();
1221
1257
  init_constants();
1222
1258
  init_menu();
1223
- init_axios();
1224
1259
  EditMenuItem = () => {
1225
1260
  const { message } = App.useApp();
1226
1261
  const [form] = Form.useForm();
@@ -1228,9 +1263,10 @@ var init_updateMenuItem = __esm({
1228
1263
  const { trigger } = useUpdateMenu();
1229
1264
  const params = useParams();
1230
1265
  const { mutate: mutate2 } = useMenuList();
1266
+ const { axios: axios2 } = useToolkitsStore((s) => s);
1231
1267
  const { data, isLoading } = useSWR5(
1232
1268
  `/api/usystem/menu/info?id=${params.id}`,
1233
- (url4) => axiosInstance(url4).then((response) => response.data.data)
1269
+ (url4) => axios2(url4).then((response) => response.data.data)
1234
1270
  );
1235
1271
  const onFinish = async (values) => {
1236
1272
  const { permissions, front_route, ...rest } = values;
@@ -1315,88 +1351,86 @@ var init_updateMenuItem = __esm({
1315
1351
  });
1316
1352
  function useAllPermissions() {
1317
1353
  return useSWR5({
1318
- url: "/api/usystem/user/allPermssions",
1319
- headers: { [APP_ID_HEADER]: "global" }
1354
+ url: "/api/usystem/user/allPermssions"
1320
1355
  });
1321
1356
  }
1322
1357
  function useAllPermissionsV2() {
1323
1358
  return useSWR5({
1324
- url: "/api/usystem/user/allPermissionsV2",
1325
- headers: { [APP_ID_HEADER]: "global" }
1359
+ url: "/api/usystem/user/allPermissionsV2"
1326
1360
  });
1327
1361
  }
1328
1362
  function useAllRoles() {
1329
- const { accessible } = usePermission("200005", { headers: { [APP_ID_HEADER]: "global" } });
1363
+ const { accessible } = usePermission("200005");
1330
1364
  return useSWR5(
1331
1365
  accessible ? {
1332
- url: "/api/usystem/role/all",
1333
- headers: { [APP_ID_HEADER]: "global" }
1366
+ url: "/api/usystem/role/all"
1334
1367
  } : null
1335
1368
  );
1336
1369
  }
1337
1370
  function useRole(name) {
1338
1371
  const usePermissionApiV2 = useToolkitsStore((state) => state.usePermissionApiV2);
1339
1372
  return useSWR5({
1340
- url: `/api/usystem/role/${usePermissionApiV2 ? "infoV2" : "info"}?name=${name}`,
1341
- headers: { [APP_ID_HEADER]: "global" }
1373
+ url: `/api/usystem/role/${usePermissionApiV2 ? "infoV2" : "info"}?name=${name}`
1342
1374
  });
1343
1375
  }
1344
1376
  function useCreateRole() {
1345
- const usePermissionApiV2 = useToolkitsStore((state) => state.usePermissionApiV2);
1377
+ const { axios: axios2, usePermissionApiV2 } = useToolkitsStore((s) => s);
1346
1378
  return useSWRMutation2(
1347
1379
  usePermissionApiV2 ? "/api/usystem/role/createV2" : "/api/usystem/role/create",
1348
1380
  (url4, {
1349
1381
  arg
1350
- }) => axiosInstance.post(url4, arg, { headers: { [APP_ID_HEADER]: "global" } })
1382
+ }) => axios2.post(url4, arg)
1351
1383
  );
1352
1384
  }
1353
1385
  function useUpdateRole() {
1354
- const usePermissionApiV2 = useToolkitsStore((state) => state.usePermissionApiV2);
1386
+ const { axios: axios2, usePermissionApiV2 } = useToolkitsStore((s) => s);
1355
1387
  return useSWRMutation2(
1356
1388
  usePermissionApiV2 ? "/api/usystem/role/updateV2" : "/api/usystem/role/update",
1357
1389
  (url4, {
1358
1390
  arg
1359
- }) => axiosInstance.post(url4, arg, { headers: { [APP_ID_HEADER]: "global" } })
1391
+ }) => axios2.post(url4, arg)
1360
1392
  );
1361
1393
  }
1362
1394
  function useRemoveRole() {
1395
+ const { axios: axios2 } = useToolkitsStore((s) => s);
1363
1396
  return useSWRMutation2(
1364
1397
  "/api/usystem/role/delete",
1365
1398
  (url4, {
1366
1399
  arg
1367
- }) => axiosInstance.post(url4, arg, { headers: { [APP_ID_HEADER]: "global" } })
1400
+ }) => axios2.post(url4, arg)
1368
1401
  );
1369
1402
  }
1370
1403
  function useCreateUser() {
1404
+ const { axios: axios2 } = useToolkitsStore((s) => s);
1371
1405
  return useSWRMutation2(
1372
1406
  "/api/usystem/user/create",
1373
1407
  (url4, {
1374
1408
  arg
1375
- }) => axiosInstance.post(url4, arg, { headers: { [APP_ID_HEADER]: "global" } })
1409
+ }) => axios2.post(url4, arg)
1376
1410
  );
1377
1411
  }
1378
1412
  function useUpdateUser() {
1413
+ const { axios: axios2 } = useToolkitsStore((s) => s);
1379
1414
  return useSWRMutation2(
1380
1415
  "/api/usystem/user/update",
1381
1416
  (url4, {
1382
1417
  arg
1383
- }) => axiosInstance.post(url4, arg, { headers: { [APP_ID_HEADER]: "global" } })
1418
+ }) => axios2.post(url4, arg)
1384
1419
  );
1385
1420
  }
1386
1421
  function useRemoveUser() {
1422
+ const { axios: axios2 } = useToolkitsStore((s) => s);
1387
1423
  return useSWRMutation2(
1388
1424
  "/api/usystem/user/delete",
1389
1425
  (url4, {
1390
1426
  arg
1391
- }) => axiosInstance.post(url4, arg, { headers: { [APP_ID_HEADER]: "global" } })
1427
+ }) => axios2.post(url4, arg)
1392
1428
  );
1393
1429
  }
1394
1430
  var init_hooks3 = __esm({
1395
1431
  "src/features/permission/hooks/index.ts"() {
1396
1432
  init_toolkitsProvider();
1397
- init_constants();
1398
1433
  init_permission();
1399
- init_axios();
1400
1434
  }
1401
1435
  });
1402
1436
  var PermissionCollapse, permissionCollapse_default;
@@ -1678,8 +1712,7 @@ var init_userList = __esm({
1678
1712
  init_locale();
1679
1713
  init_permissionButton();
1680
1714
  init_queryList();
1681
- init_stores2();
1682
- init_constants();
1715
+ init_toolkitsProvider();
1683
1716
  init_permission2();
1684
1717
  init_formModal();
1685
1718
  ({ Option: Option3 } = Select);
@@ -1772,7 +1805,6 @@ var init_userList = __esm({
1772
1805
  size: "small",
1773
1806
  type: "link",
1774
1807
  code: "100003",
1775
- headers: { [APP_ID_HEADER]: "global" },
1776
1808
  onClick: () => {
1777
1809
  showUpdateModal({
1778
1810
  initialValues: {
@@ -1794,7 +1826,6 @@ var init_userList = __esm({
1794
1826
  size: "small",
1795
1827
  code: "100004",
1796
1828
  type: "link",
1797
- headers: { [APP_ID_HEADER]: "global" },
1798
1829
  onClick: () => {
1799
1830
  modal.confirm({
1800
1831
  title: t("UserList.deleteTitle"),
@@ -1833,7 +1864,6 @@ var init_userList = __esm({
1833
1864
  type: "primary",
1834
1865
  icon: /* @__PURE__ */ jsx(UserAddOutlined, {}),
1835
1866
  code: "100002",
1836
- headers: { [APP_ID_HEADER]: "global" },
1837
1867
  onClick: () => {
1838
1868
  showCreateModal();
1839
1869
  },
@@ -1848,8 +1878,7 @@ var init_userList = __esm({
1848
1878
  rowKey: "id",
1849
1879
  columns,
1850
1880
  getTotal: (response) => response?.Total,
1851
- getDataSource: (response) => response?.List,
1852
- headers: { [APP_ID_HEADER]: "global" }
1881
+ getDataSource: (response) => response?.List
1853
1882
  }
1854
1883
  )
1855
1884
  }
@@ -1858,7 +1887,7 @@ var init_userList = __esm({
1858
1887
  updateModal
1859
1888
  ] });
1860
1889
  };
1861
- userList_default = UserList;
1890
+ userList_default = withContext(UserList, { isGlobal: true, hideGame: true });
1862
1891
  }
1863
1892
  });
1864
1893
 
@@ -1876,11 +1905,9 @@ var init_roleList = __esm({
1876
1905
  init_queryList();
1877
1906
  init_stores2();
1878
1907
  init_toolkitsProvider();
1879
- init_constants();
1880
1908
  init_permission2();
1881
1909
  init_formModal();
1882
1910
  init_permission();
1883
- init_axios();
1884
1911
  url3 = "/api/usystem/role/list";
1885
1912
  useModal3 = (isCreate) => {
1886
1913
  const { message } = App.useApp();
@@ -1932,20 +1959,17 @@ var init_roleList = __esm({
1932
1959
  });
1933
1960
  };
1934
1961
  RoleList = () => {
1935
- const { accessible: viewable } = usePermission("200005", { headers: { [APP_ID_HEADER]: "global" } });
1962
+ const { accessible: viewable } = usePermission("200005");
1936
1963
  const { modal, message } = App.useApp();
1937
1964
  const { t } = useTranslation();
1938
- const usePermissionApiV2 = useToolkitsStore((state) => state.usePermissionApiV2);
1965
+ const { axios: axios2, usePermissionApiV2 } = useToolkitsStore((s) => s);
1939
1966
  const { mutate: mutate2 } = useQueryListStore();
1940
1967
  const { show: showCreateModal, modal: createModal } = useModal3(true);
1941
1968
  const { show: showUpdateModal, modal: updateModal } = useModal3();
1942
1969
  const remove = useRemoveRole();
1943
1970
  const handleUpdateBtnClick = async (record) => {
1944
- const response = await axiosInstance.get(
1945
- `/api/usystem/role/info${usePermissionApiV2 ? "V2" : ""}?name=${record.name}`,
1946
- {
1947
- headers: { [APP_ID_HEADER]: "global" }
1948
- }
1971
+ const response = await axios2.get(
1972
+ `/api/usystem/role/info${usePermissionApiV2 ? "V2" : ""}?name=${record.name}`
1949
1973
  );
1950
1974
  const data = response.data.data;
1951
1975
  showUpdateModal({
@@ -1992,7 +2016,6 @@ var init_roleList = __esm({
1992
2016
  code: "200003",
1993
2017
  size: "small",
1994
2018
  type: "link",
1995
- headers: { [APP_ID_HEADER]: "global" },
1996
2019
  onClick: async () => {
1997
2020
  handleUpdateBtnClick(record);
1998
2021
  },
@@ -2006,7 +2029,6 @@ var init_roleList = __esm({
2006
2029
  code: "200004",
2007
2030
  size: "small",
2008
2031
  type: "link",
2009
- headers: { [APP_ID_HEADER]: "global" },
2010
2032
  onClick: () => {
2011
2033
  modal.confirm({
2012
2034
  title: t("RoleList.deleteTitle"),
@@ -2046,7 +2068,6 @@ var init_roleList = __esm({
2046
2068
  type: "primary",
2047
2069
  code: "200002",
2048
2070
  icon: /* @__PURE__ */ jsx(UsergroupAddOutlined, {}),
2049
- headers: { [APP_ID_HEADER]: "global" },
2050
2071
  onClick: () => {
2051
2072
  showCreateModal();
2052
2073
  },
@@ -2060,7 +2081,6 @@ var init_roleList = __esm({
2060
2081
  columns,
2061
2082
  code: "200001",
2062
2083
  url: url3,
2063
- headers: { [APP_ID_HEADER]: "global" },
2064
2084
  getTotal: (response) => response?.Total,
2065
2085
  getDataSource: (response) => response?.List
2066
2086
  }
@@ -2071,7 +2091,10 @@ var init_roleList = __esm({
2071
2091
  updateModal
2072
2092
  ] });
2073
2093
  };
2074
- roleList_default = RoleList;
2094
+ roleList_default = withContext(RoleList, {
2095
+ isGlobal: true,
2096
+ hideGame: true
2097
+ });
2075
2098
  }
2076
2099
  });
2077
2100
 
@@ -2084,6 +2107,7 @@ var RoleDetail, roleDetail_default;
2084
2107
  var init_roleDetail = __esm({
2085
2108
  "src/pages/permission/roleDetail/index.tsx"() {
2086
2109
  init_locale();
2110
+ init_toolkitsProvider();
2087
2111
  init_permission2();
2088
2112
  RoleDetail = () => {
2089
2113
  const params = useParams();
@@ -2116,7 +2140,7 @@ var init_roleDetail = __esm({
2116
2140
  ] }) })
2117
2141
  ] });
2118
2142
  };
2119
- roleDetail_default = RoleDetail;
2143
+ roleDetail_default = withContext(RoleDetail, { isGlobal: true, hideGame: true });
2120
2144
  }
2121
2145
  });
2122
2146
 
@@ -2276,15 +2300,16 @@ init_highlight();
2276
2300
 
2277
2301
  // src/components/infiniteList/InfiniteList.tsx
2278
2302
  init_permission();
2279
- init_axios();
2280
2303
  init_filterFormWrapper();
2281
2304
  init_locale();
2305
+ init_toolkitsProvider();
2282
2306
  var InfiniteList = (props) => {
2283
2307
  const { code, url: url4, extras, headers, getRowKey, getDataSource, hasMore, renderForm, transformArg, ...tableProps } = props;
2284
2308
  const { t } = useTranslation();
2285
2309
  const [form] = Form.useForm();
2286
2310
  const [isValid, setIsValid] = useState(false);
2287
2311
  const [formValues, setFormValues] = useState();
2312
+ const { axios: axios2 } = useToolkitsStore((s) => s);
2288
2313
  const getKey = (pageIndex, previousPageData) => {
2289
2314
  if (!isValid) return null;
2290
2315
  const rowKey = pageIndex !== 0 ? getRowKey(previousPageData) : void 0;
@@ -2293,9 +2318,7 @@ var InfiniteList = (props) => {
2293
2318
  return queryString ? `${url4}?${qs.stringify(args)}` : url4;
2294
2319
  };
2295
2320
  const _headers = typeof headers === "function" ? headers(form) : headers;
2296
- const { accessible, isLoading } = usePermission(code, {
2297
- headers: _headers
2298
- });
2321
+ const { accessible, isLoading } = usePermission(code);
2299
2322
  const {
2300
2323
  data,
2301
2324
  size,
@@ -2304,7 +2327,7 @@ var InfiniteList = (props) => {
2304
2327
  } = useSWRInfinite(
2305
2328
  getKey,
2306
2329
  async (arg) => {
2307
- const response = await axiosInstance({ url: arg, headers: _headers });
2330
+ const response = await axios2({ url: arg, headers: _headers });
2308
2331
  return response.data.data;
2309
2332
  },
2310
2333
  {
@@ -2498,45 +2521,16 @@ if (process.env.NODE_ENV === "development") {
2498
2521
  }
2499
2522
  var NavMenu_default = NavMenu;
2500
2523
 
2501
- // src/components/requireGame/RequireGame.tsx
2502
- init_locale();
2503
- init_toolkitsProvider();
2504
- var { Spin: Spin3 } = Antd2;
2505
- var RequireGame = ({ children }) => {
2506
- const { usePermissionApiV2, game, isLoading, isGlobal } = useToolkitsStore((s) => s);
2507
- const { t } = useTranslation();
2508
- if (isLoading) {
2509
- return /* @__PURE__ */ jsx(
2510
- "div",
2511
- {
2512
- style: {
2513
- display: "flex",
2514
- justifyContent: "center",
2515
- alignItems: "center",
2516
- height: 200
2517
- },
2518
- children: /* @__PURE__ */ jsx(Spin3, {})
2519
- }
2520
- );
2521
- }
2522
- if (usePermissionApiV2 && !isGlobal && !game) {
2523
- return /* @__PURE__ */ jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE, description: t("RequireGame.description") });
2524
- }
2525
- return /* @__PURE__ */ jsx(Fragment$1, { children }, game?.id ?? game?.game_id);
2526
- };
2527
- var RequireGame_default = RequireGame;
2528
-
2529
2524
  // src/components/layout/Layout.tsx
2530
2525
  init_toolkitsProvider();
2531
2526
 
2532
2527
  // src/components/userWidget/UserWidget.tsx
2533
2528
  init_locale();
2534
2529
  init_toolkitsProvider();
2535
- var UserWidget = (props) => {
2536
- const { logoutRedirectUrl } = props;
2530
+ var UserWidget = () => {
2537
2531
  const { t } = useTranslation();
2538
2532
  const navigate = useNavigate();
2539
- const { clearToken, getUser } = useToolkitsStore((state) => state);
2533
+ const { clearToken, getUser, signInPath } = useToolkitsStore((s) => s);
2540
2534
  const user = getUser();
2541
2535
  const items = [
2542
2536
  {
@@ -2547,7 +2541,7 @@ var UserWidget = (props) => {
2547
2541
  {
2548
2542
  onClick: () => {
2549
2543
  clearToken();
2550
- navigate(logoutRedirectUrl);
2544
+ navigate(signInPath);
2551
2545
  },
2552
2546
  children: t("UserWidget.signOutText")
2553
2547
  }
@@ -2631,31 +2625,19 @@ var useLayoutStore = create()(
2631
2625
  }
2632
2626
  )
2633
2627
  );
2634
- var { Spin: Spin4, theme: theme3 } = Antd2;
2635
- var { Header, Sider, Content } = Antd2.Layout;
2628
+ var { Spin: Spin3, theme: theme3 } = Antd;
2629
+ var { Header, Sider, Content } = Antd.Layout;
2636
2630
  var Layout2 = (props) => {
2637
- const {
2638
- menuCollapsible,
2639
- isMenuLoading,
2640
- title,
2641
- items,
2642
- headerExtra,
2643
- hideGameSelect,
2644
- children,
2645
- navWidth,
2646
- logoutRedirectUrl,
2647
- filter,
2648
- onGameChange
2649
- } = props;
2631
+ const { menuCollapsible, isMenuLoading, title, items, headerExtra, children, navWidth, filter, onGameChange } = props;
2650
2632
  const {
2651
2633
  token: { colorBgContainer, colorBorder }
2652
2634
  } = theme3.useToken();
2653
- const usePermissionApiV2 = useToolkitsStore((state) => state.usePermissionApiV2);
2635
+ const { usePermissionApiV2, hideGame } = useToolkitsStore((s) => s);
2654
2636
  const { collapsed, setCollapsed } = useLayoutStore();
2655
2637
  const onCollapse = async () => {
2656
2638
  setCollapsed(!collapsed);
2657
2639
  };
2658
- return /* @__PURE__ */ jsxs(Antd2.Layout, { children: [
2640
+ return /* @__PURE__ */ jsxs(Antd.Layout, { children: [
2659
2641
  /* @__PURE__ */ jsxs(
2660
2642
  Sider,
2661
2643
  {
@@ -2680,7 +2662,7 @@ var Layout2 = (props) => {
2680
2662
  ]
2681
2663
  }
2682
2664
  ),
2683
- /* @__PURE__ */ jsxs(Antd2.Layout, { children: [
2665
+ /* @__PURE__ */ jsxs(Antd.Layout, { children: [
2684
2666
  /* @__PURE__ */ jsx(
2685
2667
  Header,
2686
2668
  {
@@ -2699,12 +2681,12 @@ var Layout2 = (props) => {
2699
2681
  onClick: onCollapse
2700
2682
  }
2701
2683
  ),
2702
- usePermissionApiV2 && !hideGameSelect && /* @__PURE__ */ jsx(GameSelect_default, { filter, onGameChange }),
2684
+ usePermissionApiV2 && !hideGame && /* @__PURE__ */ jsx(GameSelect_default, { filter, onGameChange }),
2703
2685
  headerExtra?.left?.map((extra) => /* @__PURE__ */ jsx("span", { children: extra.children }, extra.key))
2704
2686
  ] }),
2705
2687
  /* @__PURE__ */ jsxs(Space, { size: "small", split: /* @__PURE__ */ jsx(Divider, { type: "vertical" }), children: [
2706
2688
  headerExtra?.right?.map((extra) => /* @__PURE__ */ jsx("span", { children: extra.children }, extra.key)),
2707
- /* @__PURE__ */ jsx(UserWidget_default, { logoutRedirectUrl })
2689
+ /* @__PURE__ */ jsx(UserWidget_default, {})
2708
2690
  ] })
2709
2691
  ] })
2710
2692
  }
@@ -2721,7 +2703,7 @@ var Layout2 = (props) => {
2721
2703
  Suspense,
2722
2704
  {
2723
2705
  fallback: /* @__PURE__ */ jsx(
2724
- Spin4,
2706
+ Spin3,
2725
2707
  {
2726
2708
  style: {
2727
2709
  display: "flex",
@@ -2731,7 +2713,7 @@ var Layout2 = (props) => {
2731
2713
  }
2732
2714
  }
2733
2715
  ),
2734
- children: /* @__PURE__ */ jsx(RequireGame_default, { children })
2716
+ children
2735
2717
  }
2736
2718
  )
2737
2719
  }
@@ -2746,15 +2728,11 @@ init_permissionButton();
2746
2728
  init_queryList();
2747
2729
 
2748
2730
  // src/components/requirePermission/RequirePermission.tsx
2749
- init_constants();
2750
2731
  init_permission();
2751
2732
  init_locale();
2752
2733
  var RequirePermission = (props) => {
2753
- const { code, isGlobal, children } = props;
2754
- const { accessible, isValidating } = usePermission(
2755
- code,
2756
- isGlobal ? { headers: { [APP_ID_HEADER]: "global" } } : void 0
2757
- );
2734
+ const { code, children } = props;
2735
+ const { accessible, isValidating } = usePermission(code);
2758
2736
  const { t } = useTranslation();
2759
2737
  if (isValidating) {
2760
2738
  return /* @__PURE__ */ jsx(
@@ -2780,9 +2758,6 @@ var RequirePermission_default = RequirePermission;
2780
2758
  init_toolkitsProvider();
2781
2759
  init_constants();
2782
2760
  init_menu();
2783
- init_formModal();
2784
- init_modal();
2785
- init_permission();
2786
2761
  var MenuItemList2 = lazy(() => Promise.resolve().then(() => (init_menuItemList(), menuItemList_exports)));
2787
2762
  var CreateMenuItem2 = lazy(() => Promise.resolve().then(() => (init_createMenuItem(), createMenuItem_exports)));
2788
2763
  var UpdateMenuItem = lazy(() => Promise.resolve().then(() => (init_updateMenuItem(), updateMenuItem_exports)));
@@ -2820,7 +2795,7 @@ var NotFound = (props) => {
2820
2795
  var notFound_default = NotFound;
2821
2796
  init_locale();
2822
2797
  init_queryList();
2823
- init_constants();
2798
+ init_toolkitsProvider();
2824
2799
  var { Option } = Select;
2825
2800
  var OperationLogList = () => {
2826
2801
  const { t } = useTranslation();
@@ -2883,7 +2858,6 @@ var OperationLogList = () => {
2883
2858
  columns,
2884
2859
  tableLayout: "fixed",
2885
2860
  url: "/api/usystem/log/list",
2886
- headers: { [APP_ID_HEADER]: "global" },
2887
2861
  getTotal: (response) => response?.Total,
2888
2862
  getDataSource: (response) => response?.List,
2889
2863
  renderForm: (form) => /* @__PURE__ */ jsxs(Form, { form, layout: "inline", children: [
@@ -2898,7 +2872,7 @@ var OperationLogList = () => {
2898
2872
  }
2899
2873
  ) });
2900
2874
  };
2901
- var operationLogList_default = OperationLogList;
2875
+ var operationLogList_default = withContext(OperationLogList, { isGlobal: true });
2902
2876
  var UserList2 = lazy(() => Promise.resolve().then(() => (init_userList(), userList_exports)));
2903
2877
  var RoleList2 = lazy(() => Promise.resolve().then(() => (init_roleList(), roleList_exports)));
2904
2878
  var RoleDetail2 = lazy(() => Promise.resolve().then(() => (init_roleDetail(), roleDetail_exports)));
@@ -2979,9 +2953,8 @@ var SignIn = (props) => {
2979
2953
  var signIn_default = SignIn;
2980
2954
 
2981
2955
  // src/index.ts
2982
- init_axios();
2983
2956
  init_storage();
2984
2957
 
2985
- 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 };
2986
2959
  //# sourceMappingURL=index.js.map
2987
2960
  //# sourceMappingURL=index.js.map