add login client type

This commit is contained in:
2024-02-02 13:14:25 +08:00
parent 6608c0b94e
commit 23abc091ea
12 changed files with 221 additions and 2 deletions

1
lib/platform/device.dart Normal file
View File

@@ -0,0 +1 @@
export './device_other.dart' if (dart.library.html) './device_web.dart';

View File

@@ -0,0 +1,12 @@
import 'dart:io';
String? get device => null;
String? get clientPlatform {
if (Platform.isAndroid) return "android";
if (Platform.isIOS) return "ios";
if (Platform.isLinux) return "linux";
if (Platform.isMacOS) return "macos";
if (Platform.isWindows) return "windows";
return null;
}

View File

@@ -0,0 +1,17 @@
import 'package:ua_parser_js/ua_parser_js.dart';
final _uaParser = UAParser();
String? _device;
String? get device {
if (_device == null) {
final ua = _uaParser.getResult();
_device = ua.browser.name;
if (_device != null && _device!.isNotEmpty) {
_device = "$_device ${ua.browser.version}";
}
}
return _device;
}
String? get clientPlatform => "web";