Add domestic vendor push infrastructure
This commit is contained in:
@@ -18,6 +18,7 @@ import 'package:miaoji_zhang/features/settings/budget_page.dart';
|
||||
import 'package:miaoji_zhang/features/settings/category_manage_page.dart';
|
||||
import 'package:miaoji_zhang/features/settings/companion_page.dart';
|
||||
import 'package:miaoji_zhang/features/settings/me_page.dart';
|
||||
import 'package:miaoji_zhang/features/settings/push_settings_page.dart';
|
||||
import 'package:miaoji_zhang/features/settings/recycle_bin_page.dart';
|
||||
import 'package:miaoji_zhang/features/settings/recognition_batch_page.dart';
|
||||
import 'package:miaoji_zhang/features/settings/legal_document_page.dart';
|
||||
@@ -34,6 +35,7 @@ import 'package:miaoji_zhang/shared/services/recognition_import_service.dart';
|
||||
import 'package:miaoji_zhang/shared/services/screenshot_channel.dart';
|
||||
import 'package:miaoji_zhang/shared/services/sync_service.dart';
|
||||
import 'package:miaoji_zhang/shared/services/session_store.dart';
|
||||
import 'package:miaoji_zhang/shared/services/push_service.dart';
|
||||
import 'package:miaoji_zhang/shared/theme/theme_store.dart';
|
||||
import 'package:miaoji_zhang/shared/update/update_coordinator.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -70,6 +72,10 @@ final router = GoRouter(
|
||||
GoRoute(path: '/budget', builder: (_, __) => const BudgetPage()),
|
||||
GoRoute(path: '/account-data', builder: (_, __) => const AccountDataPage()),
|
||||
GoRoute(path: '/appearance', builder: (_, __) => const AppearancePage()),
|
||||
GoRoute(
|
||||
path: '/notification-settings',
|
||||
builder: (_, __) => const PushSettingsPage(),
|
||||
),
|
||||
GoRoute(path: '/recycle-bin', builder: (_, __) => const RecycleBinPage()),
|
||||
GoRoute(
|
||||
path: '/sync-conflicts',
|
||||
@@ -147,6 +153,7 @@ class _MiaoJiAppState extends State<MiaoJiApp> with WidgetsBindingObserver {
|
||||
onError: _handleScreenshotError,
|
||||
);
|
||||
ScreenshotChannel.onRecognitionAction(_handleRecognitionAction);
|
||||
PushService.instance.setOpenHandler(_handlePushOpen);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -170,6 +177,7 @@ class _MiaoJiAppState extends State<MiaoJiApp> with WidgetsBindingObserver {
|
||||
}
|
||||
await _runSafely(RecognitionImportService.configureNativeContext);
|
||||
await _runSafely(RecognitionImportService.importAutomatic);
|
||||
await _runSafely(PushService.instance.initialize);
|
||||
if (mounted) setState(() {});
|
||||
unawaited(_refreshRemoteState());
|
||||
}
|
||||
@@ -177,6 +185,7 @@ class _MiaoJiAppState extends State<MiaoJiApp> with WidgetsBindingObserver {
|
||||
Future<void> _resumeServices() async {
|
||||
await _runSafely(RecognitionImportService.configureNativeContext);
|
||||
await _runSafely(RecognitionImportService.importAutomatic);
|
||||
await _runSafely(PushService.instance.refresh);
|
||||
unawaited(_refreshRemoteState());
|
||||
}
|
||||
|
||||
@@ -213,6 +222,26 @@ class _MiaoJiAppState extends State<MiaoJiApp> with WidgetsBindingObserver {
|
||||
await RecognitionImportService.handleAction(context, action);
|
||||
}
|
||||
|
||||
Future<void> _handlePushOpen(PushOpen open) async {
|
||||
await Future<void>.delayed(const Duration(milliseconds: 150));
|
||||
final context = _rootNavigatorKey.currentContext;
|
||||
if (!mounted || context == null || !context.mounted) return;
|
||||
if (!SessionStore.instance.isAccount && open.action == 'budget') {
|
||||
router.go('/login', extra: null);
|
||||
return;
|
||||
}
|
||||
switch (open.action) {
|
||||
case 'home':
|
||||
router.go('/home');
|
||||
case 'budget':
|
||||
router.push('/budget');
|
||||
case 'update':
|
||||
await UpdateCoordinator.instance.checkManually(context);
|
||||
case 'none':
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _handleSessionExpired() {
|
||||
final context = _rootNavigatorKey.currentContext;
|
||||
if (context != null && context.mounted) {
|
||||
|
||||
Reference in New Issue
Block a user