react-toolkits 2.13.34 → 2.13.36
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 -1
- package/lib/index.js +13 -8
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
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
|
@@ -633,12 +633,10 @@ function usePermission(code, config) {
|
|
|
633
633
|
permissionCodes.length > 0 ? [url4, body, config] : null,
|
|
634
634
|
(args) => axios2.post(...args).then((response) => response.data.data)
|
|
635
635
|
);
|
|
636
|
-
let newData;
|
|
637
|
-
if (typeof code === "
|
|
638
|
-
newData = true;
|
|
639
|
-
} else if (typeof code === "string") {
|
|
636
|
+
let newData = true;
|
|
637
|
+
if (typeof code === "string") {
|
|
640
638
|
newData = data?.has_all ? true : data?.[code] ?? false;
|
|
641
|
-
} else {
|
|
639
|
+
} else if (Array.isArray(code) && code.length > 0) {
|
|
642
640
|
newData = permissionCodes.reduce((acc, curr) => {
|
|
643
641
|
acc[curr] = data?.has_all ? true : data?.[curr] ?? false;
|
|
644
642
|
return acc;
|
|
@@ -919,16 +917,23 @@ var init_GameSelect = __esm({
|
|
|
919
917
|
const { t } = useTranslation();
|
|
920
918
|
const { gameApiV2, gameId, setGameId } = useToolkitsStore((s) => s);
|
|
921
919
|
const { data, isLoading } = useGames();
|
|
922
|
-
const {
|
|
920
|
+
const { cache } = useSWRConfig();
|
|
923
921
|
const filteredData = data?.filter((item) => filter?.(item) ?? true);
|
|
924
922
|
const _options = typeof options === "function" ? options(filteredData) : filteredData?.map((item) => ({
|
|
925
923
|
label: item.name,
|
|
926
924
|
value: gameApiV2 ? item.game_id : item.id
|
|
927
925
|
}));
|
|
928
|
-
const onChange =
|
|
929
|
-
|
|
926
|
+
const onChange = (value) => {
|
|
927
|
+
clearCache();
|
|
930
928
|
setGameId(value);
|
|
931
929
|
};
|
|
930
|
+
const clearCache = () => {
|
|
931
|
+
for (const key of cache.keys()) {
|
|
932
|
+
if (key !== "/api/game/list" && key !== "/api/usystem/game/all") {
|
|
933
|
+
cache.delete(key);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
};
|
|
932
937
|
useEffect(() => {
|
|
933
938
|
if (data && data.length > 0) {
|
|
934
939
|
const firstId = gameApiV2 ? data[0].game_id : data[0].id;
|