mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-15 12:53:41 +00:00
feat: support custom tracker url (#59)
This commit is contained in:
1 parent
9ef3405e43
commit
691c2f496e
71 files changed
+2209
-891
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:logger/src/outputs/file_output.dart';
|
||||
|
||||
@@ -7,5 +8,13 @@ import 'util.dart';
|
||||
|
||||
final logger = Logger(
|
||||
printer: PrettyPrinter(),
|
||||
output: Util.isDesktop() ? FileOutput(file: File('log.txt')) : null,
|
||||
output: buildOutput(),
|
||||
);
|
||||
|
||||
buildOutput() {
|
||||
// if is debug mode, output to console
|
||||
if (!kDebugMode && Util.isDesktop()) {
|
||||
return FileOutput(file: File('log.txt'));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
late PackageInfo packageInfo;
|
||||
|
||||
Future<void> initPackageInfo() async {
|
||||
packageInfo = await PackageInfo.fromPlatform();
|
||||
}
|
||||
@@ -3,6 +3,14 @@ import 'dart:io';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class Util {
|
||||
static String buildAbsPath(String dir, String path, String name) {
|
||||
return (dir == "" ? "" : "$dir/") + buildPath(path, name);
|
||||
}
|
||||
|
||||
static String buildPath(String path, String name) {
|
||||
return (path == "" ? "" : "$path/") + name;
|
||||
}
|
||||
|
||||
static String fmtByte(int byte) {
|
||||
if (byte < 1024) {
|
||||
return "$byte B";
|
||||
@@ -15,24 +23,16 @@ class Util {
|
||||
}
|
||||
}
|
||||
|
||||
static String buildPath(String path, String name) {
|
||||
return (path == "" ? "" : "$path/") + name;
|
||||
}
|
||||
|
||||
static String buildAbsPath(String dir, String path, String name) {
|
||||
return (dir == "" ? "" : "$dir/") + buildPath(path, name);
|
||||
}
|
||||
|
||||
static isWeb() {
|
||||
return kIsWeb;
|
||||
}
|
||||
|
||||
static isAndroid() {
|
||||
return !kIsWeb && Platform.isAndroid;
|
||||
}
|
||||
|
||||
static isMacos() {
|
||||
return !kIsWeb && Platform.isMacOS;
|
||||
static isIOS() {
|
||||
return !kIsWeb && Platform.isIOS;
|
||||
}
|
||||
|
||||
static isMobile() {
|
||||
return !kIsWeb && (Platform.isAndroid || Platform.isIOS);
|
||||
}
|
||||
|
||||
static isDesktop() {
|
||||
@@ -42,10 +42,18 @@ class Util {
|
||||
return Platform.isWindows || Platform.isLinux || Platform.isMacOS;
|
||||
}
|
||||
|
||||
static isMacos() {
|
||||
return !kIsWeb && Platform.isMacOS;
|
||||
}
|
||||
|
||||
static isUnix() {
|
||||
if (kIsWeb) {
|
||||
return false;
|
||||
}
|
||||
return !Platform.isWindows;
|
||||
}
|
||||
|
||||
static isWeb() {
|
||||
return kIsWeb;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user