react-toolkits 2.13.34 → 2.13.35
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 -1
- package/lib/index.js +25 -12
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -439,7 +439,7 @@ interface MenuListItem {
|
|
|
439
439
|
}
|
|
440
440
|
|
|
441
441
|
declare function usePermission(code?: string, config?: AxiosRequestConfig): SWRResponse<boolean>;
|
|
442
|
-
declare function usePermission(code?: string[], config?: AxiosRequestConfig): SWRResponse<
|
|
442
|
+
declare function usePermission(code?: string[], config?: AxiosRequestConfig): SWRResponse<Record<string, boolean>>;
|
|
443
443
|
declare function useMenuList(): SWRResponse<MenuListItem[], any, any>;
|
|
444
444
|
|
|
445
445
|
declare const _default$2: react_jsx_runtime.JSX.Element;
|
package/lib/index.js
CHANGED
|
@@ -634,15 +634,21 @@ function usePermission(code, config) {
|
|
|
634
634
|
(args) => axios2.post(...args).then((response) => response.data.data)
|
|
635
635
|
);
|
|
636
636
|
let newData;
|
|
637
|
-
if (
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
637
|
+
if (data !== void 0) {
|
|
638
|
+
if (typeof code === "undefined") {
|
|
639
|
+
newData = true;
|
|
640
|
+
} else if (typeof code === "string") {
|
|
641
|
+
newData = data.has_all ? true : data[code] ?? false;
|
|
642
|
+
} else {
|
|
643
|
+
if (code.length === 0) {
|
|
644
|
+
newData = { [code[0]]: true };
|
|
645
|
+
} else {
|
|
646
|
+
newData = permissionCodes.reduce((acc, curr) => {
|
|
647
|
+
acc[curr] = data.has_all ? true : data[curr] ?? false;
|
|
648
|
+
return acc;
|
|
649
|
+
}, {});
|
|
650
|
+
}
|
|
651
|
+
}
|
|
646
652
|
}
|
|
647
653
|
return {
|
|
648
654
|
...rest,
|
|
@@ -919,16 +925,23 @@ var init_GameSelect = __esm({
|
|
|
919
925
|
const { t } = useTranslation();
|
|
920
926
|
const { gameApiV2, gameId, setGameId } = useToolkitsStore((s) => s);
|
|
921
927
|
const { data, isLoading } = useGames();
|
|
922
|
-
const {
|
|
928
|
+
const { cache } = useSWRConfig();
|
|
923
929
|
const filteredData = data?.filter((item) => filter?.(item) ?? true);
|
|
924
930
|
const _options = typeof options === "function" ? options(filteredData) : filteredData?.map((item) => ({
|
|
925
931
|
label: item.name,
|
|
926
932
|
value: gameApiV2 ? item.game_id : item.id
|
|
927
933
|
}));
|
|
928
|
-
const onChange =
|
|
929
|
-
|
|
934
|
+
const onChange = (value) => {
|
|
935
|
+
clearCache();
|
|
930
936
|
setGameId(value);
|
|
931
937
|
};
|
|
938
|
+
const clearCache = () => {
|
|
939
|
+
for (const key of cache.keys()) {
|
|
940
|
+
if (key !== "/api/game/list" && key !== "/api/usystem/game/all") {
|
|
941
|
+
cache.delete(key);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
};
|
|
932
945
|
useEffect(() => {
|
|
933
946
|
if (data && data.length > 0) {
|
|
934
947
|
const firstId = gameApiV2 ? data[0].game_id : data[0].id;
|