import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:sk_base_mobile/constants/constants.dart'; import 'package:sk_base_mobile/store/resource.store.dart'; import 'package:sk_base_mobile/util/snack_bar.util.dart'; class RouterUtil { static List hasPermissionRoute = [ RouteConfig.hrManage, RouteConfig.inventory, RouteConfig.saleQuotation, ]; // static List whiteList = [RouteConfig.saleQuotationGuide]; static Future toNamed(String routeName, {arguments}) async { //关闭键盘 if (Get.context != null) { FocusScope.of(Get.context!).requestFocus(FocusNode()); } bool isExsited = ResourceService.to.resources .firstWhereOrNull((element) => element.path == routeName) != null; bool hasPermission = isExsited || !hasPermissionRoute.contains(routeName); if (!hasPermission) { SnackBarUtil().info('您没有权限,请联系管理员分配权限,后期将隐藏无权限的菜单'); return null; } return Get.toNamed(routeName, arguments: arguments); } /// 返回 static Future back({T? result}) async { //关闭键盘 if (Get.context != null) { FocusScope.of(Get.context!).requestFocus(FocusNode()); } Get.key.currentState?.pop(result); } }