react-toolkits 2.9.12 → 2.9.14
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 +12 -0
- package/lib/index.d.ts +13 -6
- package/lib/index.js +134 -92
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -26,7 +26,6 @@ interface RequestOptions extends Omit<RequestInit, 'body'> {
|
|
|
26
26
|
body?: Record<string | number, any> | FormData | null;
|
|
27
27
|
params?: Record<string | number, any> | URLSearchParams | null;
|
|
28
28
|
responseType?: 'json' | 'blob' | 'text';
|
|
29
|
-
isGlobal?: boolean;
|
|
30
29
|
}
|
|
31
30
|
type RequestResponse<T> = Pick<Response, 'headers' | 'status' | 'statusText' | 'url'> & {
|
|
32
31
|
data: T;
|
|
@@ -206,13 +205,13 @@ interface NavMenuProps {
|
|
|
206
205
|
declare const NavMenu: react.NamedExoticComponent<NavMenuProps>;
|
|
207
206
|
|
|
208
207
|
type Area = 'all' | 'cn' | 'global';
|
|
209
|
-
type
|
|
208
|
+
type ScreenOrientation = 0 | 1;
|
|
210
209
|
interface Game {
|
|
211
210
|
id: number;
|
|
212
211
|
game_id: string | number;
|
|
213
212
|
game_group: string;
|
|
214
213
|
name: string;
|
|
215
|
-
screen_type:
|
|
214
|
+
screen_type: ScreenOrientation;
|
|
216
215
|
area: Area;
|
|
217
216
|
icon: string;
|
|
218
217
|
auth: string;
|
|
@@ -344,6 +343,11 @@ interface QueryListState {
|
|
|
344
343
|
}
|
|
345
344
|
declare const useQueryListStore: zustand.UseBoundStore<zustand.StoreApi<QueryListState>>;
|
|
346
345
|
|
|
346
|
+
interface RequireGameProps extends PropsWithChildren {
|
|
347
|
+
hideGameSelect?: boolean;
|
|
348
|
+
}
|
|
349
|
+
declare const RequireGame: FC<RequireGameProps>;
|
|
350
|
+
|
|
347
351
|
interface RequirePermissionProps {
|
|
348
352
|
code: string;
|
|
349
353
|
isGlobal?: boolean;
|
|
@@ -355,6 +359,9 @@ interface UserWidgetProps {
|
|
|
355
359
|
}
|
|
356
360
|
declare const UserWidget: FC<UserWidgetProps>;
|
|
357
361
|
|
|
362
|
+
declare const SSO_URL = "https://idaas.ifunplus.cn/enduser/api/application/plugin_FunPlus/sso/v1";
|
|
363
|
+
declare const APP_ID_HEADER_NAME = "App-ID";
|
|
364
|
+
|
|
358
365
|
interface ModalState {
|
|
359
366
|
open: Map<number, boolean>;
|
|
360
367
|
getOpen: (uuid: number) => boolean;
|
|
@@ -396,12 +403,12 @@ declare function useFormModal<Values extends AnyObject = AnyObject, ExtraValues
|
|
|
396
403
|
modal: react_jsx_runtime.JSX.Element;
|
|
397
404
|
};
|
|
398
405
|
|
|
399
|
-
declare function usePermissions(codes: string[],
|
|
406
|
+
declare function usePermissions(codes: string[], options?: Omit<RequestOptions, 'method' | 'body'>): {
|
|
400
407
|
data: Record<string, boolean> | undefined;
|
|
401
408
|
isValidating: boolean;
|
|
402
409
|
isLoading: boolean;
|
|
403
410
|
};
|
|
404
|
-
declare function usePermission(code: string | undefined,
|
|
411
|
+
declare function usePermission(code: string | undefined, options?: Omit<RequestOptions, 'method' | 'body'>): {
|
|
405
412
|
accessible: boolean;
|
|
406
413
|
isValidating: boolean;
|
|
407
414
|
isLoading: boolean;
|
|
@@ -455,4 +462,4 @@ declare const SignIn: FC<SignInProps>;
|
|
|
455
462
|
|
|
456
463
|
declare const mixedStorage: StateStorage;
|
|
457
464
|
|
|
458
|
-
export { ContextProvider, type ContextState, DynamicTags, type DynamicTagsProps, ExpandableParagraph, type ExpandableParagraphProps, FilterFormWrapper, type FilterFormWrapperProps, type Game, Highlight, type HighlightProps, InfiniteList, type InfiniteListProps, Layout, type LayoutState, NavMenu, type NavMenuItem, NotFound, OperationLogList, PermissionButton, type PermissionButtonProps, QueryList, QueryListAction, type QueryListProps, type QueryListRef, RequestError, type RequestOptions, type RequestResponse, RequirePermission, type RequirePermissionProps, SignIn, type TokenState, type UseFormModalProps, type UseModalOperation, type UseModalProps, UserWidget, type UserWidgetProps, contextStore, mixedStorage, _default as permissionRoutes, request, useFormModal, useGameStore, useLayoutStore, useModal, useModalStore, usePermission, usePermissions, useQueryListStore, useTokenStore, useTokenValidation, useToolkitsContext };
|
|
465
|
+
export { APP_ID_HEADER_NAME, ContextProvider, type ContextState, DynamicTags, type DynamicTagsProps, ExpandableParagraph, type ExpandableParagraphProps, FilterFormWrapper, type FilterFormWrapperProps, type Game, Highlight, type HighlightProps, InfiniteList, type InfiniteListProps, Layout, type LayoutState, NavMenu, type NavMenuItem, NotFound, OperationLogList, PermissionButton, type PermissionButtonProps, QueryList, QueryListAction, type QueryListProps, type QueryListRef, RequestError, type RequestOptions, type RequestResponse, RequireGame, RequirePermission, type RequirePermissionProps, SSO_URL, SignIn, type TokenState, type UseFormModalProps, type UseModalOperation, type UseModalProps, UserWidget, type UserWidgetProps, contextStore, mixedStorage, _default as permissionRoutes, request, useFormModal, useGameStore, useLayoutStore, useModal, useModalStore, usePermission, usePermissions, useQueryListStore, useTokenStore, useTokenValidation, useToolkitsContext };
|
package/lib/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useStore, create, createStore } from 'zustand';
|
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { pick, has, template, get, isEqual } from 'lodash-es';
|
|
5
5
|
import * as Antd2 from 'antd';
|
|
6
|
-
import { Modal, Form, theme, Space, Input, Tag, Typography, Spin, Result, Table, Button, Card, Select, Alert, Divider, Menu, App, Row, Col, Breadcrumb, Skeleton, Descriptions, Dropdown, Tooltip,
|
|
6
|
+
import { Modal, Form, theme, Space, Input, Tag, Typography, Spin, Result, Table, Button, Card, Select, Alert, Divider, Menu, App, Row, Col, Breadcrumb, Skeleton, Descriptions, Empty, Dropdown, Tooltip, Collapse, Checkbox } from 'antd';
|
|
7
7
|
import { flushSync } from 'react-dom';
|
|
8
8
|
import { createRoot } from 'react-dom/client';
|
|
9
9
|
import logoUrl from './logo-L6MFCL6M.png';
|
|
@@ -275,6 +275,15 @@ var init_highlight = __esm({
|
|
|
275
275
|
init_Highlight();
|
|
276
276
|
}
|
|
277
277
|
});
|
|
278
|
+
|
|
279
|
+
// src/constants.ts
|
|
280
|
+
var SSO_URL, APP_ID_HEADER_NAME;
|
|
281
|
+
var init_constants = __esm({
|
|
282
|
+
"src/constants.ts"() {
|
|
283
|
+
SSO_URL = "https://idaas.ifunplus.cn/enduser/api/application/plugin_FunPlus/sso/v1";
|
|
284
|
+
APP_ID_HEADER_NAME = "App-ID";
|
|
285
|
+
}
|
|
286
|
+
});
|
|
278
287
|
var Logo, Logo_default;
|
|
279
288
|
var init_Logo = __esm({
|
|
280
289
|
"src/components/logo/Logo.tsx"() {
|
|
@@ -389,7 +398,7 @@ var init_NavMenu = __esm({
|
|
|
389
398
|
const location = useLocation();
|
|
390
399
|
const flattenItems = useMemo(() => flatItems(items ?? []), [items]);
|
|
391
400
|
const codes = useMemo(() => flattenItems.map((item) => item.code).filter(Boolean), [flattenItems]);
|
|
392
|
-
const { data: permissions, isLoading } = usePermissions(codes,
|
|
401
|
+
const { data: permissions, isLoading } = usePermissions(codes, { headers: { APP_ID_HEADER_NAME: "global" } });
|
|
393
402
|
const internalItems = useMemo(() => transformItems(items ?? [], permissions), [items, permissions]);
|
|
394
403
|
const { openKeys, selectedKeys, setOpenKeys, setSelectedKeys } = useNavStore();
|
|
395
404
|
const onOpenChange = useCallback(
|
|
@@ -438,6 +447,47 @@ var init_navMenu = __esm({
|
|
|
438
447
|
init_NavMenu();
|
|
439
448
|
}
|
|
440
449
|
});
|
|
450
|
+
var Spin2, RequireGame, RequireGame_default;
|
|
451
|
+
var init_RequireGame = __esm({
|
|
452
|
+
"src/components/requireGame/RequireGame.tsx"() {
|
|
453
|
+
init_contextProvider();
|
|
454
|
+
init_layout();
|
|
455
|
+
init_locale();
|
|
456
|
+
({ Spin: Spin2 } = Antd2);
|
|
457
|
+
RequireGame = (props) => {
|
|
458
|
+
const { hideGameSelect, children } = props;
|
|
459
|
+
const usePermissionApiV2 = useToolkitsContext((state) => state.usePermissionApiV2);
|
|
460
|
+
const { game, isLoading } = useGameStore();
|
|
461
|
+
const { t } = useTranslation();
|
|
462
|
+
if (isLoading) {
|
|
463
|
+
return /* @__PURE__ */ jsx(
|
|
464
|
+
"div",
|
|
465
|
+
{
|
|
466
|
+
style: {
|
|
467
|
+
display: "flex",
|
|
468
|
+
justifyContent: "center",
|
|
469
|
+
alignItems: "center",
|
|
470
|
+
height: 200
|
|
471
|
+
},
|
|
472
|
+
children: /* @__PURE__ */ jsx(Spin2, {})
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
if (usePermissionApiV2 && !hideGameSelect && !game) {
|
|
477
|
+
return /* @__PURE__ */ jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE, description: t("RequireGame.description") });
|
|
478
|
+
}
|
|
479
|
+
return children;
|
|
480
|
+
};
|
|
481
|
+
RequireGame_default = RequireGame;
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
// src/components/requireGame/index.ts
|
|
486
|
+
var init_requireGame = __esm({
|
|
487
|
+
"src/components/requireGame/index.ts"() {
|
|
488
|
+
init_RequireGame();
|
|
489
|
+
}
|
|
490
|
+
});
|
|
441
491
|
function useTokenValidation(options) {
|
|
442
492
|
const usePermissionApiV2 = useToolkitsContext((state) => state.usePermissionApiV2);
|
|
443
493
|
return useSWRImmutable(
|
|
@@ -447,7 +497,7 @@ function useTokenValidation(options) {
|
|
|
447
497
|
body: {
|
|
448
498
|
permissions: ["100001"]
|
|
449
499
|
},
|
|
450
|
-
|
|
500
|
+
headers: { [APP_ID_HEADER_NAME]: "global" }
|
|
451
501
|
})
|
|
452
502
|
);
|
|
453
503
|
}
|
|
@@ -455,6 +505,7 @@ var useTokenStore;
|
|
|
455
505
|
var init_token = __esm({
|
|
456
506
|
"src/hooks/token.ts"() {
|
|
457
507
|
init_contextProvider();
|
|
508
|
+
init_constants();
|
|
458
509
|
init_request();
|
|
459
510
|
useTokenStore = create()(
|
|
460
511
|
persist(
|
|
@@ -588,21 +639,22 @@ var init_stores2 = __esm({
|
|
|
588
639
|
games: [],
|
|
589
640
|
async refetchGames(apiV2) {
|
|
590
641
|
if (!get2().isLoading) {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
set({
|
|
602
|
-
initialized: true,
|
|
603
|
-
isLoading: false
|
|
604
|
-
});
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
try {
|
|
645
|
+
set({ isLoading: true });
|
|
646
|
+
if (!apiV2) {
|
|
647
|
+
const response = await request("/api/usystem/game/all");
|
|
648
|
+
set({ games: response.data ?? [] });
|
|
649
|
+
} else {
|
|
650
|
+
const response = await request("/api/game/list");
|
|
651
|
+
set({ games: response.data?.list ?? [] });
|
|
605
652
|
}
|
|
653
|
+
} finally {
|
|
654
|
+
set({
|
|
655
|
+
initialized: true,
|
|
656
|
+
isLoading: false
|
|
657
|
+
});
|
|
606
658
|
}
|
|
607
659
|
}
|
|
608
660
|
}),
|
|
@@ -657,39 +709,6 @@ var init_GameSelect = __esm({
|
|
|
657
709
|
GameSelect_default = GameSelect;
|
|
658
710
|
}
|
|
659
711
|
});
|
|
660
|
-
var Spin2, RequireGame, RequireGame_default;
|
|
661
|
-
var init_RequireGame = __esm({
|
|
662
|
-
"src/components/layout/RequireGame.tsx"() {
|
|
663
|
-
init_contextProvider();
|
|
664
|
-
init_locale();
|
|
665
|
-
init_stores2();
|
|
666
|
-
({ Spin: Spin2 } = Antd2);
|
|
667
|
-
RequireGame = (props) => {
|
|
668
|
-
const { hideGameSelect, children } = props;
|
|
669
|
-
const usePermissionApiV2 = useToolkitsContext((state) => state.usePermissionApiV2);
|
|
670
|
-
const { game, isLoading } = useGameStore();
|
|
671
|
-
const { t } = useTranslation();
|
|
672
|
-
if (isLoading) {
|
|
673
|
-
return /* @__PURE__ */ jsx(
|
|
674
|
-
Spin2,
|
|
675
|
-
{
|
|
676
|
-
style: {
|
|
677
|
-
display: "flex",
|
|
678
|
-
justifyContent: "center",
|
|
679
|
-
alignItems: "center",
|
|
680
|
-
height: 200
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
);
|
|
684
|
-
}
|
|
685
|
-
if (usePermissionApiV2 && !hideGameSelect && !game) {
|
|
686
|
-
return /* @__PURE__ */ jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE, description: t("RequireGame.description") });
|
|
687
|
-
}
|
|
688
|
-
return children;
|
|
689
|
-
};
|
|
690
|
-
RequireGame_default = RequireGame;
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
712
|
|
|
694
713
|
// src/components/layout/style.css
|
|
695
714
|
var init_style = __esm({
|
|
@@ -702,9 +721,9 @@ var init_Layout = __esm({
|
|
|
702
721
|
init_contextProvider();
|
|
703
722
|
init_logo();
|
|
704
723
|
init_navMenu();
|
|
724
|
+
init_requireGame();
|
|
705
725
|
init_userWidget();
|
|
706
726
|
init_GameSelect();
|
|
707
|
-
init_RequireGame();
|
|
708
727
|
init_stores2();
|
|
709
728
|
init_style();
|
|
710
729
|
({ Spin: Spin3, theme: theme3 } = Antd2);
|
|
@@ -827,7 +846,7 @@ var init_layout = __esm({
|
|
|
827
846
|
});
|
|
828
847
|
async function request(url, opts = {}) {
|
|
829
848
|
const _opts = Object.assign(opts, { responseType: opts.responseType ?? "json" });
|
|
830
|
-
const { body, params, responseType,
|
|
849
|
+
const { body, params, responseType, ...rest } = _opts;
|
|
831
850
|
if (!url) {
|
|
832
851
|
throw new RequestError({
|
|
833
852
|
status: 400,
|
|
@@ -849,14 +868,10 @@ async function request(url, opts = {}) {
|
|
|
849
868
|
if (token) {
|
|
850
869
|
headers.set("Authorization", `Bearer ${token}`);
|
|
851
870
|
}
|
|
852
|
-
if (contextStore.getState().usePermissionApiV2) {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
const game = useGameStore.getState().game;
|
|
857
|
-
if (game) {
|
|
858
|
-
headers.set("App-ID", String(game.game_id ?? game.id));
|
|
859
|
-
}
|
|
871
|
+
if (!headers.has(APP_ID_HEADER_NAME) && contextStore.getState().usePermissionApiV2) {
|
|
872
|
+
const game = useGameStore.getState().game;
|
|
873
|
+
if (game) {
|
|
874
|
+
headers.set(APP_ID_HEADER_NAME, String(game.game_id ?? game.id));
|
|
860
875
|
}
|
|
861
876
|
}
|
|
862
877
|
if (responseType === "blob") {
|
|
@@ -908,6 +923,7 @@ var init_request = __esm({
|
|
|
908
923
|
"src/utils/request.ts"() {
|
|
909
924
|
init_contextProvider();
|
|
910
925
|
init_layout();
|
|
926
|
+
init_constants();
|
|
911
927
|
init_token();
|
|
912
928
|
RequestError = class extends Error {
|
|
913
929
|
constructor(opts) {
|
|
@@ -920,16 +936,16 @@ var init_request = __esm({
|
|
|
920
936
|
};
|
|
921
937
|
}
|
|
922
938
|
});
|
|
923
|
-
function usePermissions(codes,
|
|
939
|
+
function usePermissions(codes, options) {
|
|
924
940
|
const usePermissionApiV2 = useToolkitsContext((state) => state.usePermissionApiV2);
|
|
925
941
|
const { data, isValidating, isLoading } = useSWR3(
|
|
926
942
|
codes.length > 0 ? [usePermissionApiV2 ? "/api/usystem/user/checkV2" : "/api/usystem/user/check", codes] : null,
|
|
927
943
|
([url]) => request(url, {
|
|
944
|
+
...options,
|
|
928
945
|
method: "POST",
|
|
929
946
|
body: {
|
|
930
947
|
permissions: codes
|
|
931
|
-
}
|
|
932
|
-
isGlobal
|
|
948
|
+
}
|
|
933
949
|
}).then((response) => {
|
|
934
950
|
if (response.data?.has_all) {
|
|
935
951
|
return codes.reduce(
|
|
@@ -954,8 +970,8 @@ function usePermissions(codes, isGlobal) {
|
|
|
954
970
|
);
|
|
955
971
|
return { data, isValidating, isLoading };
|
|
956
972
|
}
|
|
957
|
-
function usePermission(code,
|
|
958
|
-
const { data, isValidating, isLoading } = usePermissions(code ? [code] : [],
|
|
973
|
+
function usePermission(code, options) {
|
|
974
|
+
const { data, isValidating, isLoading } = usePermissions(code ? [code] : [], options);
|
|
959
975
|
if (code === void 0) {
|
|
960
976
|
return {
|
|
961
977
|
accessible: true,
|
|
@@ -978,11 +994,14 @@ var init_permission = __esm({
|
|
|
978
994
|
var PermissionButton, PermissionButton_default;
|
|
979
995
|
var init_PermissionButton = __esm({
|
|
980
996
|
"src/components/permissionButton/PermissionButton.tsx"() {
|
|
981
|
-
|
|
997
|
+
init_constants();
|
|
982
998
|
init_permission();
|
|
999
|
+
init_locale();
|
|
983
1000
|
PermissionButton = (props) => {
|
|
984
1001
|
const { children, code, showLoading, isGlobal, disabled, ...restProps } = props;
|
|
985
|
-
const { data, isLoading } = usePermissions(Array.isArray(code) ? code : [code],
|
|
1002
|
+
const { data, isLoading } = usePermissions(Array.isArray(code) ? code : [code], {
|
|
1003
|
+
headers: { [APP_ID_HEADER_NAME]: "global" }
|
|
1004
|
+
});
|
|
986
1005
|
const { t } = useTranslation();
|
|
987
1006
|
if (isLoading) {
|
|
988
1007
|
return /* @__PURE__ */ jsx(Button, { loading: showLoading, disabled: !showLoading, ...restProps, children });
|
|
@@ -1035,6 +1054,7 @@ var init_stores3 = __esm({
|
|
|
1035
1054
|
var QueryListAction, InternalQueryList, QueryList, QueryList_default;
|
|
1036
1055
|
var init_QueryList = __esm({
|
|
1037
1056
|
"src/components/queryList/QueryList.tsx"() {
|
|
1057
|
+
init_constants();
|
|
1038
1058
|
init_permission();
|
|
1039
1059
|
init_request();
|
|
1040
1060
|
init_contextProvider();
|
|
@@ -1082,7 +1102,9 @@ var init_QueryList = __esm({
|
|
|
1082
1102
|
const { notification } = App.useApp();
|
|
1083
1103
|
const { t } = useTranslation();
|
|
1084
1104
|
const [_form] = Form.useForm(form);
|
|
1085
|
-
const { accessible, isLoading } = usePermission(code,
|
|
1105
|
+
const { accessible, isLoading } = usePermission(code, {
|
|
1106
|
+
headers: isGlobal ? { [APP_ID_HEADER_NAME]: "global" } : void 0
|
|
1107
|
+
});
|
|
1086
1108
|
const action = useRef(3 /* Init */);
|
|
1087
1109
|
const { game } = useGameStore();
|
|
1088
1110
|
const usePermissionApiV2 = useToolkitsContext((state) => state.usePermissionApiV2);
|
|
@@ -1107,9 +1129,9 @@ var init_QueryList = __esm({
|
|
|
1107
1129
|
const newHeaders = new Headers(headers);
|
|
1108
1130
|
if (usePermissionApiV2) {
|
|
1109
1131
|
if (isGlobal) {
|
|
1110
|
-
newHeaders.set(
|
|
1132
|
+
newHeaders.set(APP_ID_HEADER_NAME, "global");
|
|
1111
1133
|
} else if (game) {
|
|
1112
|
-
newHeaders.set(
|
|
1134
|
+
newHeaders.set(APP_ID_HEADER_NAME, String(game.id));
|
|
1113
1135
|
}
|
|
1114
1136
|
}
|
|
1115
1137
|
return newHeaders;
|
|
@@ -1377,27 +1399,27 @@ var init_formModal = __esm({
|
|
|
1377
1399
|
function useAllPermissions() {
|
|
1378
1400
|
return useSWR3(
|
|
1379
1401
|
"/api/usystem/user/allPermssions",
|
|
1380
|
-
(url) => request(url, {
|
|
1402
|
+
(url) => request(url, { headers: { [APP_ID_HEADER_NAME]: "global" } }).then((response) => response.data)
|
|
1381
1403
|
);
|
|
1382
1404
|
}
|
|
1383
1405
|
function useAllPermissionsV2() {
|
|
1384
1406
|
return useSWR3(
|
|
1385
1407
|
"/api/usystem/user/allPermissionsV2",
|
|
1386
|
-
(url) => request(url, {
|
|
1408
|
+
(url) => request(url, { headers: { [APP_ID_HEADER_NAME]: "global" } }).then((response) => response.data)
|
|
1387
1409
|
);
|
|
1388
1410
|
}
|
|
1389
1411
|
function useAllRoles() {
|
|
1390
|
-
const { accessible } = usePermission("200005",
|
|
1412
|
+
const { accessible } = usePermission("200005", { headers: { [APP_ID_HEADER_NAME]: "global" } });
|
|
1391
1413
|
return useSWR3(
|
|
1392
1414
|
accessible ? "/api/usystem/role/all" : null,
|
|
1393
|
-
(url) => request(url, {
|
|
1415
|
+
(url) => request(url, { headers: { [APP_ID_HEADER_NAME]: "global" } }).then((response) => response.data)
|
|
1394
1416
|
);
|
|
1395
1417
|
}
|
|
1396
1418
|
function useRole(name) {
|
|
1397
1419
|
const usePermissionApiV2 = useToolkitsContext((state) => state.usePermissionApiV2);
|
|
1398
1420
|
return useSWR3(
|
|
1399
1421
|
`/api/usystem/role/${usePermissionApiV2 ? "infoV2" : "info"}?name=${name}`,
|
|
1400
|
-
(url) => request(url, {
|
|
1422
|
+
(url) => request(url, { headers: { [APP_ID_HEADER_NAME]: "global" } }).then((response) => response.data)
|
|
1401
1423
|
);
|
|
1402
1424
|
}
|
|
1403
1425
|
function useCreateRole() {
|
|
@@ -1409,7 +1431,7 @@ function useCreateRole() {
|
|
|
1409
1431
|
}) => request(url, {
|
|
1410
1432
|
method: "post",
|
|
1411
1433
|
body: arg,
|
|
1412
|
-
|
|
1434
|
+
headers: { [APP_ID_HEADER_NAME]: "global" }
|
|
1413
1435
|
})
|
|
1414
1436
|
);
|
|
1415
1437
|
}
|
|
@@ -1422,7 +1444,7 @@ function useUpdateRole() {
|
|
|
1422
1444
|
}) => request(url, {
|
|
1423
1445
|
method: "post",
|
|
1424
1446
|
body: arg,
|
|
1425
|
-
|
|
1447
|
+
headers: { [APP_ID_HEADER_NAME]: "global" }
|
|
1426
1448
|
})
|
|
1427
1449
|
);
|
|
1428
1450
|
}
|
|
@@ -1434,7 +1456,7 @@ function useRemoveRole() {
|
|
|
1434
1456
|
}) => request(url, {
|
|
1435
1457
|
method: "post",
|
|
1436
1458
|
body: arg,
|
|
1437
|
-
|
|
1459
|
+
headers: { [APP_ID_HEADER_NAME]: "global" }
|
|
1438
1460
|
})
|
|
1439
1461
|
);
|
|
1440
1462
|
}
|
|
@@ -1446,7 +1468,7 @@ function useCreateUser() {
|
|
|
1446
1468
|
}) => request(url, {
|
|
1447
1469
|
method: "post",
|
|
1448
1470
|
body: arg,
|
|
1449
|
-
|
|
1471
|
+
headers: { [APP_ID_HEADER_NAME]: "global" }
|
|
1450
1472
|
})
|
|
1451
1473
|
);
|
|
1452
1474
|
}
|
|
@@ -1458,7 +1480,7 @@ function useUpdateUser() {
|
|
|
1458
1480
|
}) => request(url, {
|
|
1459
1481
|
method: "post",
|
|
1460
1482
|
body: arg,
|
|
1461
|
-
|
|
1483
|
+
headers: { [APP_ID_HEADER_NAME]: "global" }
|
|
1462
1484
|
})
|
|
1463
1485
|
);
|
|
1464
1486
|
}
|
|
@@ -1470,13 +1492,14 @@ function useRemoveUser() {
|
|
|
1470
1492
|
}) => request(url, {
|
|
1471
1493
|
method: "post",
|
|
1472
1494
|
body: arg,
|
|
1473
|
-
|
|
1495
|
+
headers: { [APP_ID_HEADER_NAME]: "global" }
|
|
1474
1496
|
})
|
|
1475
1497
|
);
|
|
1476
1498
|
}
|
|
1477
1499
|
var init_hooks2 = __esm({
|
|
1478
1500
|
"src/features/permission/hooks/index.ts"() {
|
|
1479
1501
|
init_contextProvider();
|
|
1502
|
+
init_constants();
|
|
1480
1503
|
init_permission();
|
|
1481
1504
|
init_request();
|
|
1482
1505
|
}
|
|
@@ -1949,6 +1972,7 @@ var init_roleList = __esm({
|
|
|
1949
1972
|
init_permissionButton();
|
|
1950
1973
|
init_queryList();
|
|
1951
1974
|
init_stores3();
|
|
1975
|
+
init_constants();
|
|
1952
1976
|
init_permission2();
|
|
1953
1977
|
init_formModal();
|
|
1954
1978
|
init_permission();
|
|
@@ -2004,7 +2028,7 @@ var init_roleList = __esm({
|
|
|
2004
2028
|
});
|
|
2005
2029
|
};
|
|
2006
2030
|
RoleList = () => {
|
|
2007
|
-
const { accessible: viewable } = usePermission("200005",
|
|
2031
|
+
const { accessible: viewable } = usePermission("200005", { headers: { [APP_ID_HEADER_NAME]: "global" } });
|
|
2008
2032
|
const { modal, message } = App.useApp();
|
|
2009
2033
|
const { t } = useTranslation();
|
|
2010
2034
|
const usePermissionApiV2 = useToolkitsContext((state) => state.usePermissionApiV2);
|
|
@@ -2015,7 +2039,7 @@ var init_roleList = __esm({
|
|
|
2015
2039
|
const handleUpdateBtnClick = async (record) => {
|
|
2016
2040
|
const { data: role } = await request(
|
|
2017
2041
|
`/api/usystem/role/info${usePermissionApiV2 ? "V2" : ""}?name=${record.name}`,
|
|
2018
|
-
{
|
|
2042
|
+
{ headers: { [APP_ID_HEADER_NAME]: "global" } }
|
|
2019
2043
|
);
|
|
2020
2044
|
showUpdateModal({
|
|
2021
2045
|
initialValues: {
|
|
@@ -2347,9 +2371,12 @@ init_filterFormWrapper();
|
|
|
2347
2371
|
init_highlight();
|
|
2348
2372
|
|
|
2349
2373
|
// src/components/infiniteList/InfiniteList.tsx
|
|
2374
|
+
init_constants();
|
|
2350
2375
|
init_permission();
|
|
2351
2376
|
init_request();
|
|
2377
|
+
init_contextProvider();
|
|
2352
2378
|
init_filterFormWrapper();
|
|
2379
|
+
init_layout();
|
|
2353
2380
|
init_locale();
|
|
2354
2381
|
var InfiniteList = (props) => {
|
|
2355
2382
|
const {
|
|
@@ -2377,6 +2404,19 @@ var InfiniteList = (props) => {
|
|
|
2377
2404
|
const queryString = qs.stringify(args);
|
|
2378
2405
|
return queryString ? `${action}?${qs.stringify(args)}` : action;
|
|
2379
2406
|
};
|
|
2407
|
+
const { game } = useGameStore();
|
|
2408
|
+
const usePermissionApiV2 = useToolkitsContext((state) => state.usePermissionApiV2);
|
|
2409
|
+
const _headers = useMemo(() => {
|
|
2410
|
+
const newHeaders = new Headers(typeof headers === "function" ? headers(form) : headers);
|
|
2411
|
+
if (usePermissionApiV2) {
|
|
2412
|
+
if (isGlobal) {
|
|
2413
|
+
newHeaders.set(APP_ID_HEADER_NAME, "global");
|
|
2414
|
+
} else if (game) {
|
|
2415
|
+
newHeaders.set(APP_ID_HEADER_NAME, String(game.id));
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
return newHeaders;
|
|
2419
|
+
}, [usePermissionApiV2, isGlobal, game, headers]);
|
|
2380
2420
|
const {
|
|
2381
2421
|
data,
|
|
2382
2422
|
size,
|
|
@@ -2386,8 +2426,7 @@ var InfiniteList = (props) => {
|
|
|
2386
2426
|
getKey,
|
|
2387
2427
|
(arg) => {
|
|
2388
2428
|
return request(arg, {
|
|
2389
|
-
headers:
|
|
2390
|
-
isGlobal
|
|
2429
|
+
headers: _headers
|
|
2391
2430
|
}).then((response) => response.data);
|
|
2392
2431
|
},
|
|
2393
2432
|
{
|
|
@@ -2485,13 +2524,18 @@ init_layout();
|
|
|
2485
2524
|
init_navMenu();
|
|
2486
2525
|
init_permissionButton();
|
|
2487
2526
|
init_queryList();
|
|
2527
|
+
init_requireGame();
|
|
2488
2528
|
|
|
2489
2529
|
// src/components/requirePermission/RequirePermission.tsx
|
|
2530
|
+
init_constants();
|
|
2490
2531
|
init_permission();
|
|
2491
2532
|
init_locale();
|
|
2492
2533
|
var RequirePermission = (props) => {
|
|
2493
2534
|
const { code, isGlobal, children } = props;
|
|
2494
|
-
const { accessible, isValidating } = usePermission(
|
|
2535
|
+
const { accessible, isValidating } = usePermission(
|
|
2536
|
+
code,
|
|
2537
|
+
isGlobal ? { headers: { [APP_ID_HEADER_NAME]: "global" } } : void 0
|
|
2538
|
+
);
|
|
2495
2539
|
const { t } = useTranslation();
|
|
2496
2540
|
if (isValidating) {
|
|
2497
2541
|
return /* @__PURE__ */ jsx(
|
|
@@ -2515,6 +2559,7 @@ var RequirePermission_default = RequirePermission;
|
|
|
2515
2559
|
|
|
2516
2560
|
// src/index.ts
|
|
2517
2561
|
init_userWidget();
|
|
2562
|
+
init_constants();
|
|
2518
2563
|
init_formModal();
|
|
2519
2564
|
init_modal();
|
|
2520
2565
|
init_permission();
|
|
@@ -2605,6 +2650,7 @@ var OperationLogList = () => {
|
|
|
2605
2650
|
return /* @__PURE__ */ jsx(Card, { title: "\u64CD\u4F5C\u65E5\u5FD7", children: /* @__PURE__ */ jsx(
|
|
2606
2651
|
QueryList_default,
|
|
2607
2652
|
{
|
|
2653
|
+
isGlobal: true,
|
|
2608
2654
|
rowKey: "id",
|
|
2609
2655
|
code: "300001",
|
|
2610
2656
|
columns,
|
|
@@ -2638,11 +2684,7 @@ var permission_default = /* @__PURE__ */ jsxs(Routes, { children: [
|
|
|
2638
2684
|
// src/pages/signIn/index.tsx
|
|
2639
2685
|
init_locale();
|
|
2640
2686
|
init_logo();
|
|
2641
|
-
|
|
2642
|
-
// src/constants.ts
|
|
2643
|
-
var SSO_URL = "https://idaas.ifunplus.cn/enduser/api/application/plugin_FunPlus/sso/v1";
|
|
2644
|
-
|
|
2645
|
-
// src/pages/signIn/index.tsx
|
|
2687
|
+
init_constants();
|
|
2646
2688
|
init_token();
|
|
2647
2689
|
init_request();
|
|
2648
2690
|
|
|
@@ -2704,6 +2746,6 @@ var signIn_default = SignIn;
|
|
|
2704
2746
|
init_request();
|
|
2705
2747
|
init_storage();
|
|
2706
2748
|
|
|
2707
|
-
export { Provider_default as ContextProvider, DynamicTags_default as DynamicTags, ExpandableParagraph_default as ExpandableParagraph, 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, RequestError, RequirePermission_default as RequirePermission, signIn_default as SignIn, UserWidget_default as UserWidget, contextStore, mixedStorage, permission_default as permissionRoutes, request, useFormModal, useGameStore, useLayoutStore, useModal, useModalStore, usePermission, usePermissions, useQueryListStore, useTokenStore, useTokenValidation, useToolkitsContext };
|
|
2749
|
+
export { APP_ID_HEADER_NAME, Provider_default as ContextProvider, DynamicTags_default as DynamicTags, ExpandableParagraph_default as ExpandableParagraph, 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, RequestError, RequireGame_default as RequireGame, RequirePermission_default as RequirePermission, SSO_URL, signIn_default as SignIn, UserWidget_default as UserWidget, contextStore, mixedStorage, permission_default as permissionRoutes, request, useFormModal, useGameStore, useLayoutStore, useModal, useModalStore, usePermission, usePermissions, useQueryListStore, useTokenStore, useTokenValidation, useToolkitsContext };
|
|
2708
2750
|
//# sourceMappingURL=index.js.map
|
|
2709
2751
|
//# sourceMappingURL=index.js.map
|