react-toolkits 2.13.9 → 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 +6 -0
- package/lib/index.d.ts +9 -7
- package/lib/index.js +57 -54
- 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, {
|
|
@@ -731,7 +727,7 @@ var init_RequireGame = __esm({
|
|
|
731
727
|
init_toolkitsProvider();
|
|
732
728
|
({ Spin: Spin3 } = Antd2);
|
|
733
729
|
RequireGame = ({ children }) => {
|
|
734
|
-
const { permissionVersion,
|
|
730
|
+
const { permissionVersion, gameId, isGlobal } = useToolkitsStore((s) => s);
|
|
735
731
|
const { isLoading } = useGames();
|
|
736
732
|
const { t } = useTranslation();
|
|
737
733
|
if (isLoading) {
|
|
@@ -751,10 +747,9 @@ var init_RequireGame = __esm({
|
|
|
751
747
|
if (permissionVersion === "v1" /* V1 */ || isGlobal) {
|
|
752
748
|
return children;
|
|
753
749
|
}
|
|
754
|
-
if (!
|
|
750
|
+
if (!gameId) {
|
|
755
751
|
return /* @__PURE__ */ jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE, description: t("RequireGame.description") });
|
|
756
752
|
}
|
|
757
|
-
const gameId = getGameId();
|
|
758
753
|
return /* @__PURE__ */ jsx(Fragment$1, { children }, gameId);
|
|
759
754
|
};
|
|
760
755
|
RequireGame_default = RequireGame;
|
|
@@ -836,28 +831,24 @@ var init_GameSelect = __esm({
|
|
|
836
831
|
GameSelect = (props) => {
|
|
837
832
|
const { filter } = props;
|
|
838
833
|
const { t } = useTranslation();
|
|
839
|
-
const { gameApiV2,
|
|
834
|
+
const { gameApiV2, gameId, setGameId } = useToolkitsStore((s) => s);
|
|
840
835
|
const { data, isLoading } = useGames();
|
|
841
|
-
const defaultValue = getGameId();
|
|
842
|
-
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
843
836
|
const options = data?.filter((item) => filter?.(item) ?? true)?.map((item) => ({
|
|
844
837
|
label: item.name,
|
|
845
838
|
value: gameApiV2 ? item.game_id : item.id
|
|
846
839
|
}));
|
|
847
|
-
const findGame = (value) => data?.find((item) => String(gameApiV2 ? item.game_id : item.id) === String(value));
|
|
848
840
|
const onChange = async (value) => {
|
|
849
|
-
|
|
850
|
-
setGame(game);
|
|
851
|
-
setInternalValue(value);
|
|
841
|
+
setGameId(value);
|
|
852
842
|
};
|
|
853
843
|
useEffect(() => {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
const game = findGame(gameId);
|
|
858
|
-
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;
|
|
859
847
|
}
|
|
860
|
-
|
|
848
|
+
if (id2 !== gameId) {
|
|
849
|
+
setGameId(id2);
|
|
850
|
+
}
|
|
851
|
+
}, [gameId, data, gameApiV2]);
|
|
861
852
|
return /* @__PURE__ */ jsxs(Space, { children: [
|
|
862
853
|
/* @__PURE__ */ jsx(Text, { children: t("GameSelect.label") }),
|
|
863
854
|
/* @__PURE__ */ jsx(
|
|
@@ -865,7 +856,7 @@ var init_GameSelect = __esm({
|
|
|
865
856
|
{
|
|
866
857
|
showSearch: true,
|
|
867
858
|
optionFilterProp: "label",
|
|
868
|
-
value:
|
|
859
|
+
value: gameId,
|
|
869
860
|
placeholder: t("GameSelect.placeholder"),
|
|
870
861
|
loading: isLoading,
|
|
871
862
|
style: { width: "200px" },
|
|
@@ -2665,9 +2656,11 @@ var init_userDetail = __esm({
|
|
|
2665
2656
|
"src/pages/permission/userDetail/index.tsx"() {
|
|
2666
2657
|
init_layout();
|
|
2667
2658
|
init_locale();
|
|
2659
|
+
init_permissionButton();
|
|
2668
2660
|
init_toolkitsProvider();
|
|
2669
2661
|
init_constants();
|
|
2670
2662
|
init_permission();
|
|
2663
|
+
init_hooks2();
|
|
2671
2664
|
UserDetail = () => {
|
|
2672
2665
|
const { message } = App.useApp();
|
|
2673
2666
|
const params = useParams();
|
|
@@ -2678,6 +2671,7 @@ var init_userDetail = __esm({
|
|
|
2678
2671
|
(url4) => axios2.get(url4).then((res) => res.data.data)
|
|
2679
2672
|
);
|
|
2680
2673
|
const { data: games } = useGames();
|
|
2674
|
+
const { accessible: roleViewable } = usePermission("200005");
|
|
2681
2675
|
const { show, modal } = useUpdateUserModalV2({
|
|
2682
2676
|
onSuccess() {
|
|
2683
2677
|
mutate2();
|
|
@@ -2709,7 +2703,7 @@ var init_userDetail = __esm({
|
|
|
2709
2703
|
title: t("global.role"),
|
|
2710
2704
|
dataIndex: "role",
|
|
2711
2705
|
render(value) {
|
|
2712
|
-
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;
|
|
2713
2707
|
}
|
|
2714
2708
|
}
|
|
2715
2709
|
];
|
|
@@ -2736,8 +2730,9 @@ var init_userDetail = __esm({
|
|
|
2736
2730
|
title: "\u7528\u6237\u8BE6\u60C5",
|
|
2737
2731
|
loading: isLoading,
|
|
2738
2732
|
extra: /* @__PURE__ */ jsx(
|
|
2739
|
-
|
|
2733
|
+
PermissionButton_default,
|
|
2740
2734
|
{
|
|
2735
|
+
code: "100003",
|
|
2741
2736
|
onClick: () => {
|
|
2742
2737
|
show({
|
|
2743
2738
|
initialValues: {
|
|
@@ -2941,6 +2936,7 @@ var RoleDetail, roleDetail_default;
|
|
|
2941
2936
|
var init_roleDetail = __esm({
|
|
2942
2937
|
"src/pages/permission/roleDetail/index.tsx"() {
|
|
2943
2938
|
init_locale();
|
|
2939
|
+
init_permissionButton();
|
|
2944
2940
|
init_toolkitsProvider();
|
|
2945
2941
|
init_permission();
|
|
2946
2942
|
RoleDetail = () => {
|
|
@@ -2982,14 +2978,21 @@ var init_roleDetail = __esm({
|
|
|
2982
2978
|
]
|
|
2983
2979
|
}
|
|
2984
2980
|
),
|
|
2985
|
-
/* @__PURE__ */ jsx(
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
/* @__PURE__ */ jsx(
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
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
|
+
),
|
|
2993
2996
|
modal
|
|
2994
2997
|
] });
|
|
2995
2998
|
};
|