Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions lib/ui/pages/settings/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1073,22 +1073,14 @@ class _SettingsPageState extends State<SettingsPage> {
leading: const Icon(Icons.home),
title: const Text('回到 AstrBot 主页'),
subtitle: const Text('切换到 AstrBot 页面'),
onTap: () async {
try {
await _nativeWebViewChannel.invokeMethod('openMainView', {
'url': 'http://127.0.0.1:6185',
'title': 'AstrBot',
'tabIndex': 0,
});
Get.snackbar(
'已跳转',
'AstrBot 页面已打开',
snackPosition: SnackPosition.BOTTOM,
duration: const Duration(seconds: 2),
);
} catch (e) {
debugPrint('返回主页失败: $e');
}
onTap: () {
homeController.navigateToTab.value = 0;
Get.snackbar(
'已跳转',
'正在切换到 AstrBot 页面',
snackPosition: SnackPosition.BOTTOM,
duration: const Duration(seconds: 2),
);
},
),
ListTile(
Expand Down
15 changes: 14 additions & 1 deletion lib/ui/pages/webview/webview_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ class _WebViewPageState extends State<WebViewPage> {
_previousNavItemCount = currentNavItemCount;
}

// 监听设置页点击"返回主页"的导航请求
if (homeController.navigateToTab.value == 0) {
homeController.navigateToTab.value = -1;
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
_openInNativeWebView('http://127.0.0.1:6185', 'AstrBot', tabIndex: 0);
setState(() {
_currentIndex = 0;
});
}
});
}

return AnnotatedRegion<SystemUiOverlayStyle>(
value: const SystemUiOverlayStyle(
statusBarColor: Colors.white,
Expand All @@ -152,7 +165,7 @@ class _WebViewPageState extends State<WebViewPage> {
const TerminalTabView(),

// 设置页面
const SettingsPage(),
const SettingsPage(key: ValueKey('settings')),
],
),
),
Expand Down
Loading