@gadmin2n/schematics 0.0.84 → 0.0.85
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/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useDynamicResources.tsx
CHANGED
|
@@ -211,6 +211,20 @@ export const useDynamicResources = (): IResourceItem[] => {
|
|
|
211
211
|
const dynamicResources = resultResources;
|
|
212
212
|
const allResources = dynamicResources;
|
|
213
213
|
|
|
214
|
+
// 防御性保护:用户已有角色但算出来 0 个资源,说明 rolePagesData
|
|
215
|
+
// 还没到位(isLoading 误报为 false 时进了这条分支),不要把空结果
|
|
216
|
+
// 永久写入 cachedResources,否则后续真正加载完成后无法重算
|
|
217
|
+
if (allResources.length === 0 && roleNames.length > 0) {
|
|
218
|
+
isComputing = false;
|
|
219
|
+
if (import.meta.env.DEV) {
|
|
220
|
+
console.warn(
|
|
221
|
+
'[useDynamicResources] ⚠️ Skip caching: 0 resources but roles present',
|
|
222
|
+
{ roleNames },
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
|
|
214
228
|
// Cache the result - will be used for all subsequent calls
|
|
215
229
|
cachedResources = allResources;
|
|
216
230
|
isComputing = false;
|
package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useUserPageAccess.ts
CHANGED
|
@@ -333,10 +333,20 @@ export const useUserPageAccess = (): UseUserPageAccessResult => {
|
|
|
333
333
|
if (hasCache && pagesData && rolePagesData) return false;
|
|
334
334
|
if (isRoleLoading) return true;
|
|
335
335
|
if (!pagesData) return true;
|
|
336
|
-
|
|
337
|
-
|
|
336
|
+
// 等待 /role/findMany 返回(roleNames 已拿到但 rolesData 还在路上)
|
|
337
|
+
if (roleNames.length > 0 && !rolesData) return true;
|
|
338
|
+
// 等待 /rolePages/findMany 返回
|
|
339
|
+
if (roleIds.length > 0 && !rolePagesData) return true;
|
|
338
340
|
return false;
|
|
339
|
-
}, [
|
|
341
|
+
}, [
|
|
342
|
+
isRoleLoading,
|
|
343
|
+
pagesData,
|
|
344
|
+
roleNames,
|
|
345
|
+
rolesData,
|
|
346
|
+
roleIds,
|
|
347
|
+
rolePagesData,
|
|
348
|
+
hasCache,
|
|
349
|
+
]);
|
|
340
350
|
|
|
341
351
|
return {
|
|
342
352
|
accessiblePageIds,
|