feat(apps/chat): 新增 UI Schema 导航和路由导航工具

This commit is contained in:
zl-q
2026-03-19 00:51:57 +08:00
parent bfc3096199
commit 81cbc14219
8 changed files with 113 additions and 103 deletions
@@ -1,14 +1,23 @@
import '../../../../core/router/app_routes.dart';
typedef RouteNavigator = void Function(String target, {bool replace});
const Set<String> _allowedRoutes = {
'/settings',
'/todo',
'/calendar/dayweek',
'/messages/invites',
AppRoutes.settingsMain,
AppRoutes.todoList,
AppRoutes.todoCreate,
AppRoutes.calendarDayWeek,
AppRoutes.calendarMonth,
AppRoutes.calendarEventCreate,
AppRoutes.messageInviteList,
AppRoutes.contactsList,
AppRoutes.contactsAdd,
};
const List<String> _allowedRoutePrefixes = [
'/calendar/events/',
'/todo/',
'/messages/invites/',
];
class RouteNavigationTool {
@@ -29,17 +38,10 @@ class RouteNavigationTool {
Map<String, dynamic> execute(Map<String, dynamic> args) {
final target = args['target'];
if (target is! String || target.isEmpty) {
return {
'ok': false,
'error': 'target is required',
};
return {'ok': false, 'error': 'target is required'};
}
if (!_isAllowedTarget(target)) {
return {
'ok': false,
'target': target,
'error': 'target is not allowed',
};
return {'ok': false, 'target': target, 'error': 'target is not allowed'};
}
final replace = args['replace'] == true;
final navigator = _navigator;
@@ -52,12 +54,7 @@ class RouteNavigationTool {
};
}
navigator(target, replace: replace);
return {
'ok': true,
'target': target,
'replace': replace,
'applied': true,
};
return {'ok': true, 'target': target, 'replace': replace, 'applied': true};
}
bool _isAllowedTarget(String target) {