react-toolkits 2.13.8 → 2.13.10
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 +9 -7
- package/lib/index.js +59 -55
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -170,7 +170,7 @@ declare function useFormModal<Values extends AnyObject = AnyObject, ExtraValues
|
|
|
170
170
|
id: number;
|
|
171
171
|
show: (options?: {
|
|
172
172
|
initialValues?: RecursivePartial<Values>;
|
|
173
|
-
extraValues
|
|
173
|
+
extraValues?: ExtraValues;
|
|
174
174
|
}) => void;
|
|
175
175
|
hide: () => void;
|
|
176
176
|
modal: react_jsx_runtime.JSX.Element;
|
|
@@ -385,9 +385,13 @@ interface ContextSlice {
|
|
|
385
385
|
}
|
|
386
386
|
|
|
387
387
|
interface GameSlice {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
388
|
+
gameId?: string | number;
|
|
389
|
+
setGameId: (id?: string | number) => void;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
interface SignInSlice {
|
|
393
|
+
unregistered: boolean;
|
|
394
|
+
setUnregistered: () => void;
|
|
391
395
|
}
|
|
392
396
|
|
|
393
397
|
interface UserInfo {
|
|
@@ -400,10 +404,8 @@ interface TokenSlice {
|
|
|
400
404
|
setToken: (token: string) => void;
|
|
401
405
|
}
|
|
402
406
|
|
|
403
|
-
type ToolkitsState = TokenSlice & GameSlice & ContextSlice & AxiosSlice & {
|
|
404
|
-
unregistered: boolean;
|
|
407
|
+
type ToolkitsState = TokenSlice & GameSlice & ContextSlice & AxiosSlice & SignInSlice & {
|
|
405
408
|
clearToken: () => void;
|
|
406
|
-
setUnregistered: () => void;
|
|
407
409
|
};
|
|
408
410
|
|
|
409
411
|
declare function useToolkitsStore<T>(selector: (state: ToolkitsState) => T): T;
|
package/lib/index.js
CHANGED
|
@@ -192,12 +192,22 @@ var init_context = __esm({
|
|
|
192
192
|
var createGameSlice;
|
|
193
193
|
var init_game = __esm({
|
|
194
194
|
"src/stores/game.ts"() {
|
|
195
|
-
createGameSlice = (set
|
|
196
|
-
|
|
197
|
-
set({
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
195
|
+
createGameSlice = (set) => ({
|
|
196
|
+
setGameId: (id2) => {
|
|
197
|
+
set({ gameId: id2 });
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// src/stores/signIn.ts
|
|
204
|
+
var createSignInSlice;
|
|
205
|
+
var init_signIn = __esm({
|
|
206
|
+
"src/stores/signIn.ts"() {
|
|
207
|
+
createSignInSlice = (set) => ({
|
|
208
|
+
unregistered: false,
|
|
209
|
+
setUnregistered() {
|
|
210
|
+
set({ unregistered: true });
|
|
201
211
|
}
|
|
202
212
|
});
|
|
203
213
|
}
|
|
@@ -228,26 +238,24 @@ var init_stores = __esm({
|
|
|
228
238
|
init_axios();
|
|
229
239
|
init_context();
|
|
230
240
|
init_game();
|
|
241
|
+
init_signIn();
|
|
231
242
|
init_token();
|
|
232
243
|
createToolkitsStore = (initProps) => {
|
|
233
244
|
return createStore()(
|
|
234
245
|
persist(
|
|
235
246
|
(...args) => {
|
|
236
|
-
const [
|
|
247
|
+
const [_set, get2, store] = args;
|
|
237
248
|
return {
|
|
238
249
|
...createTokenSlice(...args),
|
|
239
250
|
...createGameSlice(...args),
|
|
240
251
|
...createContextSlice(...args),
|
|
241
252
|
...createAxiosSlice(...args),
|
|
242
|
-
...
|
|
243
|
-
unregistered: false,
|
|
253
|
+
...createSignInSlice(...args),
|
|
244
254
|
clearToken() {
|
|
245
255
|
get2().setToken("");
|
|
246
256
|
store.persist.clearStorage();
|
|
247
257
|
},
|
|
248
|
-
|
|
249
|
-
set({ unregistered: true });
|
|
250
|
-
}
|
|
258
|
+
...initProps
|
|
251
259
|
};
|
|
252
260
|
},
|
|
253
261
|
{
|
|
@@ -255,7 +263,7 @@ var init_stores = __esm({
|
|
|
255
263
|
storage: createJSONStorage(() => mixedStorage),
|
|
256
264
|
partialize: (state) => ({
|
|
257
265
|
token: state.token,
|
|
258
|
-
|
|
266
|
+
gameId: state.gameId
|
|
259
267
|
})
|
|
260
268
|
}
|
|
261
269
|
)
|
|
@@ -270,17 +278,7 @@ var init_Interceptors = __esm({
|
|
|
270
278
|
init_toolkitsProvider();
|
|
271
279
|
Interceptors = ({ children }) => {
|
|
272
280
|
const { notification } = App.useApp();
|
|
273
|
-
const {
|
|
274
|
-
axios: axios2,
|
|
275
|
-
interceptors,
|
|
276
|
-
token,
|
|
277
|
-
isGlobal,
|
|
278
|
-
signInPath,
|
|
279
|
-
clearToken,
|
|
280
|
-
setUnregistered,
|
|
281
|
-
getGameId,
|
|
282
|
-
permissionVersion
|
|
283
|
-
} = useToolkitsStore((s) => s);
|
|
281
|
+
const { axios: axios2, interceptors, token, isGlobal, signInPath, gameId, clearToken, setUnregistered, permissionVersion } = useToolkitsStore((s) => s);
|
|
284
282
|
let requestInterceptorId;
|
|
285
283
|
let responseInterceptorId;
|
|
286
284
|
if (interceptors?.request) {
|
|
@@ -293,7 +291,6 @@ var init_Interceptors = __esm({
|
|
|
293
291
|
headers.setAuthorization(`Bearer ${token}`);
|
|
294
292
|
}
|
|
295
293
|
if (!headers.has(APP_ID_HEADER) && permissionVersion !== "v1" /* V1 */) {
|
|
296
|
-
const gameId = getGameId();
|
|
297
294
|
if (isGlobal || !gameId) {
|
|
298
295
|
headers.set(APP_ID_HEADER, "global");
|
|
299
296
|
} else {
|
|
@@ -521,8 +518,7 @@ var init_highlight = __esm({
|
|
|
521
518
|
}
|
|
522
519
|
});
|
|
523
520
|
function useMenuList() {
|
|
524
|
-
const {
|
|
525
|
-
const gameId = getGameId();
|
|
521
|
+
const { signInPath, axios: axios2, token, gameId } = useToolkitsStore((s) => s);
|
|
526
522
|
return useSWR5(
|
|
527
523
|
window.location.pathname !== signInPath ? ["/api/usystem/menu/navbar", gameId] : null,
|
|
528
524
|
([url4]) => axios2(url4, {
|
|
@@ -540,7 +536,8 @@ var init_hooks2 = __esm({
|
|
|
540
536
|
const { data, ...rest } = useSWR5(
|
|
541
537
|
codes.length ? [
|
|
542
538
|
permissionVersion !== "v1" /* V1 */ ? "/api/usystem/user/checkV2" : "/api/usystem/user/check",
|
|
543
|
-
{ permissions: codes }
|
|
539
|
+
{ permissions: codes },
|
|
540
|
+
config
|
|
544
541
|
] : null,
|
|
545
542
|
([url4, body]) => axios2.post(url4, body, config).then((response) => response.data.data)
|
|
546
543
|
);
|
|
@@ -730,7 +727,7 @@ var init_RequireGame = __esm({
|
|
|
730
727
|
init_toolkitsProvider();
|
|
731
728
|
({ Spin: Spin3 } = Antd2);
|
|
732
729
|
RequireGame = ({ children }) => {
|
|
733
|
-
const { permissionVersion,
|
|
730
|
+
const { permissionVersion, gameId, isGlobal } = useToolkitsStore((s) => s);
|
|
734
731
|
const { isLoading } = useGames();
|
|
735
732
|
const { t } = useTranslation();
|
|
736
733
|
if (isLoading) {
|
|
@@ -750,10 +747,9 @@ var init_RequireGame = __esm({
|
|
|
750
747
|
if (permissionVersion === "v1" /* V1 */ || isGlobal) {
|
|
751
748
|
return children;
|
|
752
749
|
}
|
|
753
|
-
if (!
|
|
750
|
+
if (!gameId) {
|
|
754
751
|
return /* @__PURE__ */ jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE, description: t("RequireGame.description") });
|
|
755
752
|
}
|
|
756
|
-
const gameId = getGameId();
|
|
757
753
|
return /* @__PURE__ */ jsx(Fragment$1, { children }, gameId);
|
|
758
754
|
};
|
|
759
755
|
RequireGame_default = RequireGame;
|
|
@@ -835,28 +831,24 @@ var init_GameSelect = __esm({
|
|
|
835
831
|
GameSelect = (props) => {
|
|
836
832
|
const { filter } = props;
|
|
837
833
|
const { t } = useTranslation();
|
|
838
|
-
const { gameApiV2,
|
|
834
|
+
const { gameApiV2, gameId, setGameId } = useToolkitsStore((s) => s);
|
|
839
835
|
const { data, isLoading } = useGames();
|
|
840
|
-
const defaultValue = getGameId();
|
|
841
|
-
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
842
836
|
const options = data?.filter((item) => filter?.(item) ?? true)?.map((item) => ({
|
|
843
837
|
label: item.name,
|
|
844
838
|
value: gameApiV2 ? item.game_id : item.id
|
|
845
839
|
}));
|
|
846
|
-
const findGame = (value) => data?.find((item) => String(gameApiV2 ? item.game_id : item.id) === String(value));
|
|
847
840
|
const onChange = async (value) => {
|
|
848
|
-
|
|
849
|
-
setGame(game);
|
|
850
|
-
setInternalValue(value);
|
|
841
|
+
setGameId(value);
|
|
851
842
|
};
|
|
852
843
|
useEffect(() => {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
const game = findGame(gameId);
|
|
857
|
-
setGame(game);
|
|
844
|
+
let id2 = gameId;
|
|
845
|
+
if (data?.every((item) => String(gameApiV2 ? item.game_id : item.id) !== String(id2))) {
|
|
846
|
+
id2 = gameApiV2 ? data?.[0]?.game_id : data?.[0]?.id;
|
|
858
847
|
}
|
|
859
|
-
|
|
848
|
+
if (id2 !== gameId) {
|
|
849
|
+
setGameId(id2);
|
|
850
|
+
}
|
|
851
|
+
}, [gameId, data, gameApiV2]);
|
|
860
852
|
return /* @__PURE__ */ jsxs(Space, { children: [
|
|
861
853
|
/* @__PURE__ */ jsx(Text, { children: t("GameSelect.label") }),
|
|
862
854
|
/* @__PURE__ */ jsx(
|
|
@@ -864,7 +856,7 @@ var init_GameSelect = __esm({
|
|
|
864
856
|
{
|
|
865
857
|
showSearch: true,
|
|
866
858
|
optionFilterProp: "label",
|
|
867
|
-
value:
|
|
859
|
+
value: gameId,
|
|
868
860
|
placeholder: t("GameSelect.placeholder"),
|
|
869
861
|
loading: isLoading,
|
|
870
862
|
style: { width: "200px" },
|
|
@@ -2664,9 +2656,11 @@ var init_userDetail = __esm({
|
|
|
2664
2656
|
"src/pages/permission/userDetail/index.tsx"() {
|
|
2665
2657
|
init_layout();
|
|
2666
2658
|
init_locale();
|
|
2659
|
+
init_permissionButton();
|
|
2667
2660
|
init_toolkitsProvider();
|
|
2668
2661
|
init_constants();
|
|
2669
2662
|
init_permission();
|
|
2663
|
+
init_hooks2();
|
|
2670
2664
|
UserDetail = () => {
|
|
2671
2665
|
const { message } = App.useApp();
|
|
2672
2666
|
const params = useParams();
|
|
@@ -2677,6 +2671,7 @@ var init_userDetail = __esm({
|
|
|
2677
2671
|
(url4) => axios2.get(url4).then((res) => res.data.data)
|
|
2678
2672
|
);
|
|
2679
2673
|
const { data: games } = useGames();
|
|
2674
|
+
const { accessible: roleViewable } = usePermission("200005");
|
|
2680
2675
|
const { show, modal } = useUpdateUserModalV2({
|
|
2681
2676
|
onSuccess() {
|
|
2682
2677
|
mutate2();
|
|
@@ -2708,7 +2703,7 @@ var init_userDetail = __esm({
|
|
|
2708
2703
|
title: t("global.role"),
|
|
2709
2704
|
dataIndex: "role",
|
|
2710
2705
|
render(value) {
|
|
2711
|
-
return /* @__PURE__ */ jsx(Link, { to: `../../role/${value}`, relative: "path", children: value });
|
|
2706
|
+
return roleViewable ? /* @__PURE__ */ jsx(Link, { to: `../../role/${value}`, relative: "path", children: value }) : value;
|
|
2712
2707
|
}
|
|
2713
2708
|
}
|
|
2714
2709
|
];
|
|
@@ -2735,8 +2730,9 @@ var init_userDetail = __esm({
|
|
|
2735
2730
|
title: "\u7528\u6237\u8BE6\u60C5",
|
|
2736
2731
|
loading: isLoading,
|
|
2737
2732
|
extra: /* @__PURE__ */ jsx(
|
|
2738
|
-
|
|
2733
|
+
PermissionButton_default,
|
|
2739
2734
|
{
|
|
2735
|
+
code: "100003",
|
|
2740
2736
|
onClick: () => {
|
|
2741
2737
|
show({
|
|
2742
2738
|
initialValues: {
|
|
@@ -2940,6 +2936,7 @@ var RoleDetail, roleDetail_default;
|
|
|
2940
2936
|
var init_roleDetail = __esm({
|
|
2941
2937
|
"src/pages/permission/roleDetail/index.tsx"() {
|
|
2942
2938
|
init_locale();
|
|
2939
|
+
init_permissionButton();
|
|
2943
2940
|
init_toolkitsProvider();
|
|
2944
2941
|
init_permission();
|
|
2945
2942
|
RoleDetail = () => {
|
|
@@ -2981,14 +2978,21 @@ var init_roleDetail = __esm({
|
|
|
2981
2978
|
]
|
|
2982
2979
|
}
|
|
2983
2980
|
),
|
|
2984
|
-
/* @__PURE__ */ jsx(
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
/* @__PURE__ */ jsx(
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2981
|
+
/* @__PURE__ */ jsx(
|
|
2982
|
+
Card,
|
|
2983
|
+
{
|
|
2984
|
+
title: t("RoleDetail.title"),
|
|
2985
|
+
extra: /* @__PURE__ */ jsx(PermissionButton_default, { code: "200003", onClick: handleUpdateBtnClick, children: t("global.update") }),
|
|
2986
|
+
children: /* @__PURE__ */ jsxs(Skeleton, { loading: isLoading, children: [
|
|
2987
|
+
/* @__PURE__ */ jsxs(Descriptions, { column: 2, layout: "vertical", className: "mb-6", children: [
|
|
2988
|
+
/* @__PURE__ */ jsx(Descriptions.Item, { label: t("global.name"), children: data?.name }),
|
|
2989
|
+
/* @__PURE__ */ jsx(Descriptions.Item, { label: "ID", children: data?.id }),
|
|
2990
|
+
/* @__PURE__ */ jsx(Descriptions.Item, { label: t("global.creationTime"), children: data?.ctime })
|
|
2991
|
+
] }),
|
|
2992
|
+
/* @__PURE__ */ jsx(permissionList_default, { readonly: true, value: data?.permissions })
|
|
2993
|
+
] })
|
|
2994
|
+
}
|
|
2995
|
+
),
|
|
2992
2996
|
modal
|
|
2993
2997
|
] });
|
|
2994
2998
|
};
|