Merge branch 'dev'
v1.2.4
This commit is contained in:
22
ln_jq_app/lib/common/AuthGuard.dart
Normal file
22
ln_jq_app/lib/common/AuthGuard.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:getx_scaffold/common/index.dart';
|
||||
import 'package:ln_jq_app/pages/login/view.dart';
|
||||
import 'package:ln_jq_app/storage_service.dart';
|
||||
|
||||
class AuthGuard {
|
||||
static bool _handling401 = false;
|
||||
|
||||
static Future<void> handle401(String? message) async {
|
||||
if (_handling401) return;
|
||||
_handling401 = true;
|
||||
|
||||
try {
|
||||
await StorageService.to.clearLoginInfo();
|
||||
Get.offAll(() => const LoginPage());
|
||||
} finally {
|
||||
// 防止意外卡死,可视情况是否延迟重置
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
_handling401 = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,9 @@ class StationModel {
|
||||
final String address;
|
||||
final String price;
|
||||
final String siteStatusName; // 例如 "维修中"
|
||||
final int isSelect; // 新增字段 1是可用 0是不可用
|
||||
final int isSelect; // 1是可用 0是不可用
|
||||
final String startBusiness; // 新增:可预约最早开始时间,如 "06:00:00"
|
||||
final String endBusiness; // 新增:可预约最晚结束时间,如 "22:00:00"
|
||||
|
||||
StationModel({
|
||||
required this.hydrogenId,
|
||||
@@ -13,9 +15,10 @@ class StationModel {
|
||||
required this.price,
|
||||
required this.siteStatusName,
|
||||
required this.isSelect,
|
||||
required this.startBusiness,
|
||||
required this.endBusiness,
|
||||
});
|
||||
|
||||
// 从 JSON map 创建对象的工厂构造函数
|
||||
factory StationModel.fromJson(Map<String, dynamic> json) {
|
||||
return StationModel(
|
||||
hydrogenId: json['hydrogenId'] ?? '',
|
||||
@@ -23,7 +26,9 @@ class StationModel {
|
||||
address: json['address'] ?? '地址未知',
|
||||
price: json['price']?.toString() ?? '0.00',
|
||||
siteStatusName: json['siteStatusName'] ?? '',
|
||||
isSelect: json['isSelect'] as int? ?? 0, // 新增字段的解析,默认为 0
|
||||
isSelect: json['isSelect'] as int? ?? 0,
|
||||
startBusiness: json['startBusiness'] ?? '00:00:00', // 默认全天
|
||||
endBusiness: json['endBusiness'] ?? '23:59:59', // 默认全天
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user