react-toolkits 2.9.17 → 2.9.19
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 +1 -2
- package/lib/index.js +13 -23
- package/lib/index.js.map +1 -1
- package/locale/hooks.js.map +1 -1
- package/locale/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -124,6 +124,7 @@ type Locale = {
|
|
|
124
124
|
interface ContextProps {
|
|
125
125
|
locale: Locale;
|
|
126
126
|
usePermissionApiV2: boolean;
|
|
127
|
+
gameApiV2: boolean;
|
|
127
128
|
interceptor?: {
|
|
128
129
|
response?: (response: Response, opts: RequestOptions) => Promise<any>;
|
|
129
130
|
};
|
|
@@ -223,7 +224,6 @@ interface Game {
|
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
interface GameSelectProps {
|
|
226
|
-
apiV2?: boolean;
|
|
227
227
|
filter?: (game: Game) => boolean;
|
|
228
228
|
onGameChange?: (game: Game) => void;
|
|
229
229
|
}
|
|
@@ -233,7 +233,6 @@ type HeaderExtra = {
|
|
|
233
233
|
children: ReactNode;
|
|
234
234
|
};
|
|
235
235
|
interface LayoutProps extends Pick<GameSelectProps, 'filter' | 'onGameChange'> {
|
|
236
|
-
gameApiV2?: boolean;
|
|
237
236
|
title?: ReactNode;
|
|
238
237
|
items?: NavMenuItem[];
|
|
239
238
|
hideGameSelect?: boolean;
|
package/lib/index.js
CHANGED
|
@@ -137,8 +137,9 @@ var init_Provider = __esm({
|
|
|
137
137
|
init_en_GB();
|
|
138
138
|
createContextStore = (initProps) => {
|
|
139
139
|
const DEFAULT_PROPS = {
|
|
140
|
+
locale: en_GB_default,
|
|
140
141
|
usePermissionApiV2: false,
|
|
141
|
-
|
|
142
|
+
gameApiV2: false
|
|
142
143
|
};
|
|
143
144
|
return createStore()((set) => ({
|
|
144
145
|
...DEFAULT_PROPS,
|
|
@@ -617,6 +618,7 @@ var init_stores2 = __esm({
|
|
|
617
618
|
"src/components/layout/stores.ts"() {
|
|
618
619
|
init_request();
|
|
619
620
|
init_storage();
|
|
621
|
+
init_contextProvider();
|
|
620
622
|
useLayoutStore = create()(
|
|
621
623
|
persist(
|
|
622
624
|
(set) => ({
|
|
@@ -637,7 +639,7 @@ var init_stores2 = __esm({
|
|
|
637
639
|
isLoading: false,
|
|
638
640
|
game: null,
|
|
639
641
|
games: [],
|
|
640
|
-
async fetchGames({ apiV2 =
|
|
642
|
+
async fetchGames({ apiV2 = contextStore.getState().gameApiV2, forceUpdate = false } = {}) {
|
|
641
643
|
if (!forceUpdate && get2().initialized) {
|
|
642
644
|
return get2().games;
|
|
643
645
|
}
|
|
@@ -673,18 +675,17 @@ var init_stores2 = __esm({
|
|
|
673
675
|
var Text, GameSelect, GameSelect_default;
|
|
674
676
|
var init_GameSelect = __esm({
|
|
675
677
|
"src/components/layout/GameSelect.tsx"() {
|
|
678
|
+
init_contextProvider();
|
|
676
679
|
init_locale();
|
|
677
680
|
init_stores2();
|
|
678
681
|
({ Text } = Typography);
|
|
679
682
|
GameSelect = (props) => {
|
|
680
|
-
const {
|
|
683
|
+
const { filter, onGameChange } = props;
|
|
681
684
|
const { t } = useTranslation();
|
|
682
685
|
const { game, games, isLoading, fetchGames } = useGameStore();
|
|
686
|
+
const apiV2 = useToolkitsContext((state) => state.gameApiV2);
|
|
683
687
|
useEffect(() => {
|
|
684
|
-
fetchGames({
|
|
685
|
-
apiV2: true,
|
|
686
|
-
forceUpdate: true
|
|
687
|
-
});
|
|
688
|
+
fetchGames({ apiV2 });
|
|
688
689
|
}, []);
|
|
689
690
|
const options = games?.filter((item) => filter?.(item) ?? true)?.map((item) => ({
|
|
690
691
|
label: item.name,
|
|
@@ -735,18 +736,7 @@ var init_Layout = __esm({
|
|
|
735
736
|
({ Spin: Spin3, theme: theme3 } = Antd2);
|
|
736
737
|
({ Header, Sider, Content } = Antd2.Layout);
|
|
737
738
|
Layout2 = (props) => {
|
|
738
|
-
const {
|
|
739
|
-
gameApiV2,
|
|
740
|
-
title,
|
|
741
|
-
items,
|
|
742
|
-
headerExtra,
|
|
743
|
-
hideGameSelect,
|
|
744
|
-
children,
|
|
745
|
-
navWidth,
|
|
746
|
-
logoutRedirectUrl,
|
|
747
|
-
filter,
|
|
748
|
-
onGameChange
|
|
749
|
-
} = props;
|
|
739
|
+
const { title, items, headerExtra, hideGameSelect, children, navWidth, logoutRedirectUrl, filter, onGameChange } = props;
|
|
750
740
|
const {
|
|
751
741
|
token: { colorBgContainer, colorBorder }
|
|
752
742
|
} = theme3.useToken();
|
|
@@ -799,7 +789,7 @@ var init_Layout = __esm({
|
|
|
799
789
|
onClick: onCollapse
|
|
800
790
|
}
|
|
801
791
|
),
|
|
802
|
-
usePermissionApiV2 && !hideGameSelect && /* @__PURE__ */ jsx(GameSelect_default, {
|
|
792
|
+
usePermissionApiV2 && !hideGameSelect && /* @__PURE__ */ jsx(GameSelect_default, { filter, onGameChange }),
|
|
803
793
|
headerExtra?.left?.map((extra) => /* @__PURE__ */ jsx("span", { children: extra.children }, extra.key))
|
|
804
794
|
] }),
|
|
805
795
|
/* @__PURE__ */ jsxs(Space, { size: "small", split: /* @__PURE__ */ jsx(Divider, { type: "vertical" }), children: [
|
|
@@ -877,7 +867,7 @@ async function request(url, opts = {}) {
|
|
|
877
867
|
if (!headers.has(APP_ID_HEADER_NAME) && contextStore.getState().usePermissionApiV2) {
|
|
878
868
|
const game = useGameStore.getState().game;
|
|
879
869
|
if (game) {
|
|
880
|
-
headers.set(APP_ID_HEADER_NAME, String(game.game_id
|
|
870
|
+
headers.set(APP_ID_HEADER_NAME, String(contextStore.getState().gameApiV2 ? game.game_id : game.id));
|
|
881
871
|
}
|
|
882
872
|
}
|
|
883
873
|
if (responseType === "blob") {
|
|
@@ -1113,7 +1103,7 @@ var init_QueryList = __esm({
|
|
|
1113
1103
|
});
|
|
1114
1104
|
const action = useRef(3 /* Init */);
|
|
1115
1105
|
const { game } = useGameStore();
|
|
1116
|
-
const usePermissionApiV2 = useToolkitsContext((state) => state
|
|
1106
|
+
const { gameApiV2, usePermissionApiV2 } = useToolkitsContext((state) => state);
|
|
1117
1107
|
const [isValid, setIsValid] = useState(false);
|
|
1118
1108
|
const { keyMap, getPayload, refetch } = useQueryListStore();
|
|
1119
1109
|
const { page, size = defaultSize, formValue } = getPayload(route3);
|
|
@@ -1137,7 +1127,7 @@ var init_QueryList = __esm({
|
|
|
1137
1127
|
if (isGlobal) {
|
|
1138
1128
|
newHeaders.set(APP_ID_HEADER_NAME, "global");
|
|
1139
1129
|
} else if (game) {
|
|
1140
|
-
newHeaders.set(APP_ID_HEADER_NAME, String(game.id));
|
|
1130
|
+
newHeaders.set(APP_ID_HEADER_NAME, String(gameApiV2 ? game.game_id : game.id));
|
|
1141
1131
|
}
|
|
1142
1132
|
}
|
|
1143
1133
|
return newHeaders;
|