react-toolkits 2.9.18 → 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 +6 -0
- package/lib/index.d.ts +1 -2
- package/lib/index.js +12 -19
- 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,13 +675,15 @@ 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
688
|
fetchGames({ apiV2 });
|
|
685
689
|
}, []);
|
|
@@ -732,18 +736,7 @@ var init_Layout = __esm({
|
|
|
732
736
|
({ Spin: Spin3, theme: theme3 } = Antd2);
|
|
733
737
|
({ Header, Sider, Content } = Antd2.Layout);
|
|
734
738
|
Layout2 = (props) => {
|
|
735
|
-
const {
|
|
736
|
-
gameApiV2,
|
|
737
|
-
title,
|
|
738
|
-
items,
|
|
739
|
-
headerExtra,
|
|
740
|
-
hideGameSelect,
|
|
741
|
-
children,
|
|
742
|
-
navWidth,
|
|
743
|
-
logoutRedirectUrl,
|
|
744
|
-
filter,
|
|
745
|
-
onGameChange
|
|
746
|
-
} = props;
|
|
739
|
+
const { title, items, headerExtra, hideGameSelect, children, navWidth, logoutRedirectUrl, filter, onGameChange } = props;
|
|
747
740
|
const {
|
|
748
741
|
token: { colorBgContainer, colorBorder }
|
|
749
742
|
} = theme3.useToken();
|
|
@@ -796,7 +789,7 @@ var init_Layout = __esm({
|
|
|
796
789
|
onClick: onCollapse
|
|
797
790
|
}
|
|
798
791
|
),
|
|
799
|
-
usePermissionApiV2 && !hideGameSelect && /* @__PURE__ */ jsx(GameSelect_default, {
|
|
792
|
+
usePermissionApiV2 && !hideGameSelect && /* @__PURE__ */ jsx(GameSelect_default, { filter, onGameChange }),
|
|
800
793
|
headerExtra?.left?.map((extra) => /* @__PURE__ */ jsx("span", { children: extra.children }, extra.key))
|
|
801
794
|
] }),
|
|
802
795
|
/* @__PURE__ */ jsxs(Space, { size: "small", split: /* @__PURE__ */ jsx(Divider, { type: "vertical" }), children: [
|
|
@@ -874,7 +867,7 @@ async function request(url, opts = {}) {
|
|
|
874
867
|
if (!headers.has(APP_ID_HEADER_NAME) && contextStore.getState().usePermissionApiV2) {
|
|
875
868
|
const game = useGameStore.getState().game;
|
|
876
869
|
if (game) {
|
|
877
|
-
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));
|
|
878
871
|
}
|
|
879
872
|
}
|
|
880
873
|
if (responseType === "blob") {
|
|
@@ -1110,7 +1103,7 @@ var init_QueryList = __esm({
|
|
|
1110
1103
|
});
|
|
1111
1104
|
const action = useRef(3 /* Init */);
|
|
1112
1105
|
const { game } = useGameStore();
|
|
1113
|
-
const usePermissionApiV2 = useToolkitsContext((state) => state
|
|
1106
|
+
const { gameApiV2, usePermissionApiV2 } = useToolkitsContext((state) => state);
|
|
1114
1107
|
const [isValid, setIsValid] = useState(false);
|
|
1115
1108
|
const { keyMap, getPayload, refetch } = useQueryListStore();
|
|
1116
1109
|
const { page, size = defaultSize, formValue } = getPayload(route3);
|
|
@@ -1134,7 +1127,7 @@ var init_QueryList = __esm({
|
|
|
1134
1127
|
if (isGlobal) {
|
|
1135
1128
|
newHeaders.set(APP_ID_HEADER_NAME, "global");
|
|
1136
1129
|
} else if (game) {
|
|
1137
|
-
newHeaders.set(APP_ID_HEADER_NAME, String(game.id));
|
|
1130
|
+
newHeaders.set(APP_ID_HEADER_NAME, String(gameApiV2 ? game.game_id : game.id));
|
|
1138
1131
|
}
|
|
1139
1132
|
}
|
|
1140
1133
|
return newHeaders;
|