mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-25 21:05:52 +08:00
tweaks (#1738)
* feat: edit dm filter * opt: browser * feat: sb userInfo * mod: tvPlayUrl
This commit is contained in:
committed by
GitHub
parent
9754b061dd
commit
bca5b0419c
@@ -124,6 +124,7 @@ abstract class Accounts {
|
||||
}
|
||||
}
|
||||
|
||||
@pragma("vm:prefer-inline")
|
||||
static Account get(AccountType key) {
|
||||
return accountMode[key.index];
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ class AccountManager extends Interceptor {
|
||||
Api.ugcUrl,
|
||||
Api.pgcUrl,
|
||||
Api.pugvUrl,
|
||||
Api.tvPlayUrl,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'dart:math' show pow;
|
||||
|
||||
abstract class DurationUtils {
|
||||
abstract final class DurationUtils {
|
||||
static String formatDuration(num? seconds) {
|
||||
if (seconds == null || seconds == 0) {
|
||||
return '00:00';
|
||||
@@ -30,10 +30,10 @@ abstract class DurationUtils {
|
||||
return duration;
|
||||
}
|
||||
|
||||
static String formatDurationBetween(int startMillis, int endMillis) {
|
||||
int diffMillis = endMillis - startMillis;
|
||||
final duration = Duration(milliseconds: diffMillis);
|
||||
static String formatDurationBetween(int startMillis, int endMillis) =>
|
||||
formatTimeDuration(Duration(milliseconds: endMillis - startMillis));
|
||||
|
||||
static String formatTimeDuration(Duration duration) {
|
||||
final inDays = duration.inDays;
|
||||
final daysLeft = inDays % 365;
|
||||
final years = inDays ~/ 365;
|
||||
@@ -42,14 +42,14 @@ abstract class DurationUtils {
|
||||
final hours = duration.inHours % 24;
|
||||
final minutes = duration.inMinutes % 60;
|
||||
|
||||
var format = '';
|
||||
final format = StringBuffer();
|
||||
|
||||
if (years > 0) format += '$years年';
|
||||
if (months > 0) format += '$months月';
|
||||
if (days > 0) format += '$days天';
|
||||
if (hours > 0) format += '$hours小时';
|
||||
if (minutes > 0) format += '$minutes分钟';
|
||||
if (years > 0) format.write('$years年');
|
||||
if (months > 0) format.write('$months月');
|
||||
if (days > 0) format.write('$days天');
|
||||
if (hours > 0) format.write('$hours小时');
|
||||
if (minutes > 0) format.write('$minutes分钟');
|
||||
|
||||
return format;
|
||||
return format.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/foundation.dart' show kDebugMode, debugPrint;
|
||||
import 'package:get/get_utils/get_utils.dart';
|
||||
|
||||
abstract class NumUtils {
|
||||
abstract final class NumUtils {
|
||||
static final _numRegExp = RegExp(r'([\d\.]+)([千万亿])?');
|
||||
|
||||
static int _getUnit(String? unit) {
|
||||
@@ -59,4 +59,24 @@ abstract class NumUtils {
|
||||
return number.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static String formatPositiveDecimal(int number) {
|
||||
if (number < 1000) return number.toString();
|
||||
|
||||
final numStr = number.toString();
|
||||
final length = numStr.length;
|
||||
final sb = StringBuffer();
|
||||
|
||||
int firstLength = length % 3;
|
||||
if (firstLength == 0) firstLength = 3;
|
||||
|
||||
sb.write(numStr.substring(0, firstLength));
|
||||
for (int i = firstLength; i < length; i += 3) {
|
||||
sb
|
||||
..write(',')
|
||||
..write(numStr.substring(i, i + 3));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user