mod: 代码整理

This commit is contained in:
guozhigq
2023-07-25 23:44:09 +08:00
parent 6d9f66c420
commit 7745ea076b
74 changed files with 387 additions and 424 deletions

View File

@ -1,3 +1,5 @@
// ignore_for_file: constant_identifier_names
import 'dart:math';
import 'package:flutter/material.dart';

View File

@ -1,4 +1,6 @@
// 工具函数
// ignore_for_file: non_constant_identifier_names
import 'dart:async';
import 'dart:io';
import 'dart:math';
@ -52,7 +54,7 @@ class Utils {
// 当前时间
int time = (DateTime.now().millisecondsSinceEpoch / 1000).round();
// 对比
int _distance = (time - timeStamp).toInt();
int distance = (time - timeStamp).toInt();
// 当前年日期
String currentYearStr = 'MM月DD日 hh:mm';
String lastYearStr = 'YY年MM月DD日 hh:mm';
@ -65,12 +67,12 @@ class Utils {
toInt: false,
formatType: formatType);
}
if (_distance <= 60) {
if (distance <= 60) {
return '刚刚';
} else if (_distance <= 3600) {
return '${(_distance / 60).floor()}分钟前';
} else if (_distance <= 43200) {
return '${(_distance / 60 / 60).floor()}小时前';
} else if (distance <= 3600) {
return '${(distance / 60).floor()}分钟前';
} else if (distance <= 43200) {
return '${(distance / 60 / 60).floor()}小时前';
} else if (DateTime.fromMillisecondsSinceEpoch(time * 1000).year ==
DateTime.fromMillisecondsSinceEpoch(timeStamp * 1000).year) {
return CustomStamp_str(