You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
631 B
Dart
25 lines
631 B
Dart
2 years ago
|
import 'dart:io';
|
||
|
import 'package:flutter/foundation.dart';
|
||
|
import 'package:isekai_wiki/global.dart';
|
||
|
import 'package:package_info_plus/package_info_plus.dart';
|
||
|
|
||
|
import '../extension/string.dart';
|
||
|
|
||
|
class ApiUtils {
|
||
|
static Future<String> getUserAgent() async {
|
||
|
if (kIsWeb) {
|
||
|
// Web版防止出错
|
||
|
return "";
|
||
|
}
|
||
|
|
||
|
String osName = Platform.operatingSystem.capitalize();
|
||
|
String osVersion = Platform.operatingSystemVersion;
|
||
|
|
||
|
Global.packageInfo ??= await PackageInfo.fromPlatform();
|
||
|
|
||
|
String appVersion = Global.packageInfo!.version;
|
||
|
|
||
|
return "IsekaiWikiApp/$appVersion ($osName $osVersion)";
|
||
|
}
|
||
|
}
|