### 详细变更:
1. **文档与配置**:更新AGENTS.md添加命令超时约束,升级Rive依赖至0.14.7并替换平台插件引用
2. **UI优化**:重构AppInfo页面布局、移除图表冗余配置、锁定部分系统设置项
3. **功能增强**:
- 新增工具面板拖拽状态管理与介绍弹窗
- 新增进度页面编辑/重排/清空用户进度功能
- 新增摇一摇路由作用域拦截逻辑
4. **体验优化**:
- 统一外部链接跳转弹窗,添加文件打开确认逻辑
- 修复设备卡片IP溢出、Android权限声明问题
- 后台任务初始化增加协议校验
5. **代码重构**:拆分工具面板配置、拖拽逻辑与动画参数,优化状态管理代码
6. **工具脚本**:新增协议文件上传脚本
270 lines
9.2 KiB
Dart
270 lines
9.2 KiB
Dart
// ============================================================
|
|
// 闲言APP — 工具中心路由
|
|
// 创建时间: 2026-05-22
|
|
// 更新时间: 2026-05-30
|
|
// 作用: 工具中心、AI聊天、翻译、文件传输、协作相关 GoRoute 定义
|
|
// 上次更新: 新增工具中心设置页路由
|
|
// ============================================================
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import '../../features/discover/presentation/pages/tool/hanzi_tool_page.dart';
|
|
import '../../features/discover/presentation/pages/tool/calc_tool_page.dart';
|
|
import '../../features/discover/presentation/pages/tool/china_colors_page.dart';
|
|
import '../../features/discover/presentation/pages/tool_list_page.dart';
|
|
import '../../features/discover/presentation/pages/tool/ocr_tool_page.dart';
|
|
import '../../features/discover/presentation/pages/tool/pinyin_tool_page.dart';
|
|
import '../../features/discover/presentation/pages/tool_center_settings_page.dart';
|
|
import '../../features/discover/presentation/pages/chat/chat_flow_page.dart';
|
|
import '../../features/discover/models/chat_session.dart';
|
|
import '../../features/discover/presentation/pages/chat/chat_settings_page.dart';
|
|
import '../../features/discover/presentation/pages/chat/hidden_sessions_page.dart';
|
|
import '../../features/discover/presentation/pages/translate/translate_page.dart';
|
|
import '../../features/discover/presentation/pages/translate/translate_settings_page.dart';
|
|
import '../../features/file_transfer/presentation/pages/file_transfer_page.dart';
|
|
import '../../features/file_transfer/presentation/pages/transfer_chat_page.dart';
|
|
import '../../features/file_transfer/presentation/pages/device_pairing_page.dart';
|
|
import '../../features/file_transfer/models/models.dart';
|
|
import '../../features/file_transfer/collaboration/canvas/pages/canvas_page.dart';
|
|
import '../../features/file_transfer/collaboration/clipboard/pages/clipboard_flow_page.dart';
|
|
import '../../features/file_transfer/collaboration/screen_share/pages/screen_share_page.dart';
|
|
import '../utils/ui/page_transitions.dart';
|
|
import 'app_routes.dart';
|
|
|
|
List<GoRoute> buildToolRoutes(GlobalKey<NavigatorState> rootNavigatorKey) => [
|
|
GoRoute(
|
|
path: AppRoutes.hanziTool,
|
|
name: 'hanzi-tool',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) {
|
|
final config = state.extra as HanziToolConfig?;
|
|
if (config == null) {
|
|
return iosSlideTransition(state: state, child: const NotFoundPage());
|
|
}
|
|
return iosSlideTransition(
|
|
state: state,
|
|
child: HanziToolPage(config: config),
|
|
);
|
|
},
|
|
),
|
|
GoRoute(
|
|
path: '/tool/calc',
|
|
name: 'calc-tool',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) {
|
|
final config = state.extra as CalcToolConfig?;
|
|
if (config == null) {
|
|
return iosSlideTransition(state: state, child: const NotFoundPage());
|
|
}
|
|
return iosSlideTransition(
|
|
state: state,
|
|
child: CalcToolPage(config: config),
|
|
);
|
|
},
|
|
),
|
|
GoRoute(
|
|
path: '/tool/china_colors',
|
|
name: 'china-colors',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) =>
|
|
iosSlideTransition(state: state, child: const ChinaColorsPage()),
|
|
),
|
|
GoRoute(
|
|
path: '/tool/list',
|
|
name: 'tool-list',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) {
|
|
final extra = state.extra as Map<String, dynamic>?;
|
|
if (extra == null) {
|
|
return iosSlideTransition(state: state, child: const NotFoundPage());
|
|
}
|
|
return iosSlideTransition(
|
|
state: state,
|
|
child: ToolListPage(
|
|
toolId: extra['toolId'] as String? ?? '',
|
|
title: extra['title'] as String? ?? '',
|
|
emoji: extra['emoji'] as String? ?? '',
|
|
listType: extra['listType'] as String? ?? 'hanzi_search',
|
|
searchType: extra['searchType'] as String?,
|
|
showSearch: extra['showSearch'] as bool? ?? false,
|
|
detailDesc: extra['detailDesc'] as String?,
|
|
),
|
|
);
|
|
},
|
|
),
|
|
GoRoute(
|
|
path: '/tool/ocr',
|
|
name: 'ocr-tool',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) =>
|
|
iosSlideTransition(state: state, child: const OcrToolPage()),
|
|
),
|
|
GoRoute(
|
|
path: '/tool/pinyin',
|
|
name: 'pinyin-tool',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) =>
|
|
iosSlideTransition(state: state, child: const PinyinToolPage()),
|
|
),
|
|
GoRoute(
|
|
path: '/tool/daily-recommend',
|
|
name: 'daily-recommend-tool',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) => iosSlideTransition(
|
|
state: state,
|
|
child: const ToolListPage(
|
|
toolId: 'daily_recommend',
|
|
title: '每日推荐',
|
|
emoji: '🌟',
|
|
listType: 'daily_recommend',
|
|
),
|
|
),
|
|
),
|
|
GoRoute(
|
|
path: '${AppRoutes.chatFlow}/:conversationId',
|
|
name: 'chat-flow',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) {
|
|
final convId = state.pathParameters['conversationId'] ?? 'default';
|
|
return iosSlideTransition(
|
|
state: state,
|
|
child: ChatFlowPage(conversationId: convId),
|
|
);
|
|
},
|
|
),
|
|
GoRoute(
|
|
path: '${AppRoutes.chatSettings}/:conversationId',
|
|
name: 'chat-settings',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) {
|
|
final convId = state.pathParameters['conversationId'] ?? 'default';
|
|
return iosSlideTransition(
|
|
state: state,
|
|
child: ChatSettingsPage(conversationId: convId),
|
|
);
|
|
},
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.hiddenSessions,
|
|
name: 'hidden-sessions',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) =>
|
|
iosSlideTransition(state: state, child: const HiddenSessionsPage()),
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.readlaterChat,
|
|
name: 'readlater-chat',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) => iosSlideTransition(
|
|
state: state,
|
|
child: const ChatFlowPage(
|
|
conversationId: 'readlater',
|
|
sessionType: ChatSessionType.readlater,
|
|
),
|
|
),
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.translate,
|
|
name: 'translate',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) =>
|
|
iosSlideTransition(state: state, child: const TranslatePage()),
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.translateSettings,
|
|
name: 'translate-settings',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) =>
|
|
iosSlideTransition(state: state, child: const TranslateSettingsPage()),
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.fileTransfer,
|
|
name: 'file-transfer',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) =>
|
|
iosSlideTransition(state: state, child: const FileTransferPage()),
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.transferChat,
|
|
name: 'transfer-chat',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) {
|
|
final device = state.extra as TransferDevice?;
|
|
return iosSlideTransition(
|
|
state: state,
|
|
child: TransferChatPage(
|
|
peerDevice:
|
|
device ??
|
|
TransferDevice(
|
|
id: 'unknown',
|
|
alias: '未知设备',
|
|
deviceType: DeviceType.mobile,
|
|
port: 53317,
|
|
pairingMethod: PairingMethod.lan,
|
|
preferredTransport: TransportType.localsendHttp,
|
|
lastSeen: DateTime.now(),
|
|
isOnline: false,
|
|
isVerified: false,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.devicePairing,
|
|
name: 'device-pairing',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) =>
|
|
iosSlideTransition(state: state, child: const DevicePairingPage()),
|
|
),
|
|
GoRoute(
|
|
path: '${AppRoutes.canvas}/:id',
|
|
name: 'canvas',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) {
|
|
final canvasId = state.pathParameters['id'] ?? '';
|
|
final peerDeviceId = state.uri.queryParameters['peerDeviceId'];
|
|
final userId = state.uri.queryParameters['userId'] ?? '';
|
|
return iosSlideTransition(
|
|
state: state,
|
|
child: CanvasPage(
|
|
canvasId: canvasId,
|
|
peerDeviceId: peerDeviceId,
|
|
userId: userId,
|
|
),
|
|
);
|
|
},
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.clipboard,
|
|
name: 'clipboard',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) =>
|
|
iosSlideTransition(state: state, child: const ClipboardFlowPage()),
|
|
),
|
|
GoRoute(
|
|
path: '${AppRoutes.screenShare}/:id',
|
|
name: 'screen-share',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) {
|
|
final sessionId = state.pathParameters['id'] ?? '';
|
|
final peerDeviceId = state.uri.queryParameters['peerDeviceId'];
|
|
return iosSlideTransition(
|
|
state: state,
|
|
child: ScreenSharePage(
|
|
sessionId: sessionId,
|
|
peerDeviceId: peerDeviceId,
|
|
),
|
|
);
|
|
},
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.toolCenterSettings,
|
|
name: 'tool-center-settings',
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
pageBuilder: (context, state) =>
|
|
iosSlideTransition(state: state, child: const ToolCenterSettingsPage()),
|
|
),
|
|
];
|