openxiangda 1.0.49 → 1.0.50

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.
@@ -412,6 +412,23 @@ const findPageByIdentity = (pages: PageOption[], identity: string) =>
412
412
  page.dirName === identity,
413
413
  );
414
414
 
415
+ const getRuntimePermission = (route?: BrowserRuntimeRouteResolution | null) => {
416
+ const permission = route?.runtime?.permission;
417
+ return permission && typeof permission === "object"
418
+ ? (permission as { canView?: unknown; message?: unknown })
419
+ : undefined;
420
+ };
421
+
422
+ const isRuntimePermissionDenied = (route?: BrowserRuntimeRouteResolution | null) =>
423
+ getRuntimePermission(route)?.canView === false;
424
+
425
+ const getRuntimePermissionMessage = (route: BrowserRuntimeRouteResolution) =>
426
+ String(
427
+ route.message ||
428
+ getRuntimePermission(route)?.message ||
429
+ "您没有权限访问当前页面",
430
+ );
431
+
415
432
  const RuntimeRouteNotice = ({
416
433
  route,
417
434
  routeError,
@@ -446,6 +463,17 @@ const RuntimeRouteNotice = ({
446
463
 
447
464
  if (!route) return null;
448
465
 
466
+ if (isRuntimePermissionDenied(route)) {
467
+ return (
468
+ <Alert
469
+ type="warning"
470
+ showIcon
471
+ message={getRuntimePermissionMessage(route)}
472
+ style={{ margin: 16 }}
473
+ />
474
+ );
475
+ }
476
+
449
477
  if (route.mode === "builtin-route") {
450
478
  return null;
451
479
  }
@@ -500,11 +528,15 @@ export default function App() {
500
528
  );
501
529
 
502
530
  const shouldBlockLocalMount =
531
+ isRuntimePermissionDenied(routeResolution) ||
503
532
  routeResolution?.mode === "builtin-route" ||
504
533
  routeResolution?.kind === "work-center" ||
505
534
  (routeResolution?.mode === "not-found" &&
506
535
  routeResolution.params?.routeAppType !== undefined);
507
536
  const shouldRenderBuiltinRoute = routeResolution?.mode === "builtin-route";
537
+ const localMountBlockedDescription = isRuntimePermissionDenied(routeResolution)
538
+ ? "当前用户没有权限访问该页面"
539
+ : "当前路由不挂载本地代码页";
508
540
 
509
541
  const handleSelectPage = (value: string) => {
510
542
  setSelectedCode(value);
@@ -774,7 +806,7 @@ export default function App() {
774
806
  <section style={{ minHeight: "calc(100vh - 73px)" }}>
775
807
  {shouldBlockLocalMount ? (
776
808
  <div style={{ padding: 16 }}>
777
- <Empty description="当前路由不挂载本地代码页" />
809
+ <Empty description={localMountBlockedDescription} />
778
810
  </div>
779
811
  ) : !selected && !selectedCode ? (
780
812
  <Spin style={{ margin: 32 }} />