Skip to content

Commit

Permalink
fix: web build
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Sep 22, 2024
1 parent 132961c commit eed602f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
1 change: 1 addition & 0 deletions lib/common/deeplink/deeplink.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'win32.dart' if (dart.library.html) 'non_win32.dart';
1 change: 1 addition & 0 deletions lib/common/deeplink/non_win32.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Future<void> registerProtocol(String scheme) async {}
23 changes: 23 additions & 0 deletions lib/common/deeplink/win32.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'dart:io';
import 'package:win32_registry/win32_registry.dart';

Future<void> registerProtocol(String scheme) async {
final String appPath = Platform.resolvedExecutable;

final String protocolRegKey = 'Software\\Classes\\$scheme';
const RegistryValue protocolRegValue = RegistryValue(
'URL Protocol',
RegistryValueType.string,
'',
);
const String protocolCmdRegKey = r'shell\open\command';
final RegistryValue protocolCmdRegValue = RegistryValue(
'',
RegistryValueType.string,
'"$appPath" "%1"',
);

final regKey = Registry.currentUser.createKey(protocolRegKey);
regKey.createValue(protocolRegValue);
regKey.createKey(protocolCmdRegKey).createValue(protocolCmdRegValue);
}
21 changes: 0 additions & 21 deletions lib/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,3 @@ Future<void> _initSystemTray() async {
}
});
}

Future<void> registerProtocol(String scheme) async {
final String appPath = Platform.resolvedExecutable;

final String protocolRegKey = 'Software\\Classes\\$scheme';
const RegistryValue protocolRegValue = RegistryValue(
'URL Protocol',
RegistryValueType.string,
'',
);
const String protocolCmdRegKey = r'shell\open\command';
final RegistryValue protocolCmdRegValue = RegistryValue(
'',
RegistryValueType.string,
'"$appPath" "%1"',
);

final regKey = Registry.currentUser.createKey(protocolRegKey);
regKey.createValue(protocolRegValue);
regKey.createKey(protocolCmdRegKey).createValue(protocolCmdRegValue);
}
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_hive/sentry_hive.dart';
import 'package:system_tray/system_tray.dart';
import 'package:universal_io/io.dart';
import 'package:win32_registry/win32_registry.dart';

import 'bloc/chesed/chesed_bloc.dart';
import 'bloc/client_setting/client_setting_bloc.dart';
Expand All @@ -30,6 +29,7 @@ import 'bloc/netzach/netzach_bloc.dart';
import 'bloc/tiphereth/tiphereth_bloc.dart';
import 'bloc/yesod/yesod_bloc.dart';
import 'common/bloc_observer.dart';
import 'common/deeplink/deeplink.dart';
import 'common/platform.dart';
import 'consts.dart';
import 'l10n/l10n.dart';
Expand Down

0 comments on commit eed602f

Please sign in to comment.