Merge branch 'release_hyx' into release
This commit is contained in:
commit
e8e2ad4479
@ -48,6 +48,16 @@
|
|||||||
<string>123456</string>
|
<string>123456</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
<key>CFBundleURLName</key>
|
||||||
|
<string>weixin</string>
|
||||||
|
<key>CFBundleURLSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>wxbe340095d2b8fd51</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
||||||
|
|||||||
@ -4,38 +4,41 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:star_lock/mine/about/debug/debug_console.dart';
|
import 'package:star_lock/mine/about/debug/debug_console.dart';
|
||||||
|
|
||||||
|
|
||||||
class AppLog {
|
class AppLog {
|
||||||
static bool _printLog = false;
|
static bool _printLog = false;
|
||||||
static bool _onlyError = false;
|
static bool _onlyError = false;
|
||||||
|
|
||||||
static showLog({required bool printLog, bool? onlyError}){
|
static void showLog({required bool printLog, bool? onlyError}) {
|
||||||
_printLog = printLog;
|
_printLog = printLog;
|
||||||
_onlyError = onlyError ?? false;
|
_onlyError = onlyError ?? false;
|
||||||
}
|
}
|
||||||
static log(String msg,{bool? error}){
|
|
||||||
|
static void log(String msg, {StackTrace? stackTrace, bool? error}) {
|
||||||
msg = '${DateTime.now().toIso8601String()} : $msg';
|
msg = '${DateTime.now().toIso8601String()} : $msg';
|
||||||
DebugConsole.info(msg);
|
DebugConsole.info(msg, stackTrace: stackTrace, isErr: error ?? false);
|
||||||
if(!kDebugMode)return;
|
if (!kDebugMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
error = error ?? false;
|
error = error ?? false;
|
||||||
// if(!_printLog)return;
|
// if(!_printLog)return;
|
||||||
// if(_onlyError && !error) return;
|
// if(_onlyError && !error) return;
|
||||||
if(error){
|
if (error) {
|
||||||
msg = '----->>> $msg';
|
msg = '----->>> $msg $stackTrace';
|
||||||
}
|
}
|
||||||
Get.log(msg);
|
Get.log(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppPlatform {
|
class AppPlatform {
|
||||||
static bool isIOS = Platform.isIOS;
|
static bool isIOS = Platform.isIOS;
|
||||||
static bool isAndroid = Platform.isAndroid;
|
static bool isAndroid = Platform.isAndroid;
|
||||||
static String platformString(){
|
|
||||||
|
static String platformString() {
|
||||||
String name = 'unknown';
|
String name = 'unknown';
|
||||||
if(isIOS){
|
if (isIOS) {
|
||||||
name = 'iOS';
|
name = 'iOS';
|
||||||
}
|
}
|
||||||
if(isAndroid){
|
if (isAndroid) {
|
||||||
name = 'Android';
|
name = 'Android';
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
@ -44,50 +47,59 @@ class AppPlatform {
|
|||||||
static String _brand = 'unknown';
|
static String _brand = 'unknown';
|
||||||
static int _sdkInt = 23;
|
static int _sdkInt = 23;
|
||||||
|
|
||||||
static void setBrandString(String brand){
|
static void setBrandString(String brand) {
|
||||||
_brand = brand;
|
_brand = brand;
|
||||||
}
|
}
|
||||||
static String getBrandString()=>_brand;
|
|
||||||
static void setSDKInt(int sdkInt){
|
static String getBrandString() => _brand;
|
||||||
|
|
||||||
|
static void setSDKInt(int sdkInt) {
|
||||||
_sdkInt = sdkInt;
|
_sdkInt = sdkInt;
|
||||||
}
|
}
|
||||||
static bool isSamsung()=>_brand.toLowerCase().contains('samsung');
|
|
||||||
static int getSdkIntValue()=>_sdkInt;
|
|
||||||
static bool onlyCanNetUpgrade()=>isSamsung() && (getSdkIntValue() >= 29);
|
|
||||||
|
|
||||||
|
static bool isSamsung() => _brand.toLowerCase().contains('samsung');
|
||||||
|
|
||||||
|
static int getSdkIntValue() => _sdkInt;
|
||||||
|
|
||||||
|
static bool onlyCanNetUpgrade() => isSamsung() && (getSdkIntValue() >= 29);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppMowerCodes {
|
class AppMowerCodes {
|
||||||
static int idCodeLength(){
|
static int idCodeLength() {
|
||||||
int len = 19;
|
int len = 19;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fenceNameLength = 8;
|
static int fenceNameLength = 8;
|
||||||
static int registerCodeLength = 4;
|
static int registerCodeLength = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppDate {
|
class AppDate {
|
||||||
static String dateString() {
|
static String dateString() {
|
||||||
return '${year()}-${month().toString().padLeft(2,'0')}-${day().toString()
|
return '${year()}-${month().toString().padLeft(2, '0')}-${day().toString().padLeft(2, '0')}';
|
||||||
.padLeft(2,'0')}';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static String calendarString() {
|
static String calendarString() {
|
||||||
String temp = '${year()}${month().toString().padLeft(2,'0')}${day().toString()
|
String temp =
|
||||||
.padLeft(2,'0')}${hour().toString().padLeft(2,'0')}${second()
|
'${year()}${month().toString().padLeft(2, '0')}${day().toString().padLeft(2, '0')}${hour().toString().padLeft(2, '0')}${second().toString().padLeft(2, '0')}';
|
||||||
.toString().padLeft(2,'0')}';
|
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int year()=>DateTime.now().year;
|
static int year() => DateTime.now().year;
|
||||||
static int month()=>DateTime.now().month;
|
|
||||||
static int day()=>DateTime.now().day;
|
|
||||||
static int hour()=>DateTime.now().hour;
|
|
||||||
static int minute()=>DateTime.now().minute;
|
|
||||||
static int second()=>DateTime.now().second;
|
|
||||||
static int weekDay()=>DateTime.now().weekday;
|
|
||||||
static int timeZeroOffset()=>DateTime.now().timeZoneOffset.inHours;
|
|
||||||
|
|
||||||
|
static int month() => DateTime.now().month;
|
||||||
|
|
||||||
|
static int day() => DateTime.now().day;
|
||||||
|
|
||||||
|
static int hour() => DateTime.now().hour;
|
||||||
|
|
||||||
|
static int minute() => DateTime.now().minute;
|
||||||
|
|
||||||
|
static int second() => DateTime.now().second;
|
||||||
|
|
||||||
|
static int weekDay() => DateTime.now().weekday;
|
||||||
|
|
||||||
|
static int timeZeroOffset() => DateTime.now().timeZoneOffset.inHours;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO:错误类型
|
//TODO:错误类型
|
||||||
@ -99,9 +111,9 @@ enum ErrorType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AppErrorCode {
|
class AppErrorCode {
|
||||||
static int errorCode(ErrorType type){
|
static int errorCode(ErrorType type) {
|
||||||
int code = 0;
|
int code = 0;
|
||||||
switch(type){
|
switch (type) {
|
||||||
case ErrorType.modeNotMatch:
|
case ErrorType.modeNotMatch:
|
||||||
code = 1;
|
code = 1;
|
||||||
break;
|
break;
|
||||||
@ -118,8 +130,3 @@ class AppErrorCode {
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,16 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/flavors.dart';
|
import 'package:star_lock/flavors.dart';
|
||||||
import 'package:star_lock/translations/trans_lib.dart';
|
|
||||||
import 'app.dart';
|
|
||||||
import 'package:star_lock/tools/device_info_service.dart';
|
import 'package:star_lock/tools/device_info_service.dart';
|
||||||
import 'package:star_lock/tools/platform_info_services.dart';
|
import 'package:star_lock/tools/platform_info_services.dart';
|
||||||
|
import 'package:star_lock/translations/trans_lib.dart';
|
||||||
|
|
||||||
|
import 'app.dart';
|
||||||
import 'app_settings/app_settings.dart';
|
import 'app_settings/app_settings.dart';
|
||||||
import 'tools/store_service.dart';
|
import 'tools/store_service.dart';
|
||||||
import 'package:get/get.dart';
|
|
||||||
|
|
||||||
// 该文件不可作为编译入口,请查看 flavorizr.yaml 中的说明
|
// 该文件不可作为编译入口,请查看 flavorizr.yaml 中的说明
|
||||||
FutureOr<void> main() async {
|
FutureOr<void> main() async {
|
||||||
@ -19,20 +21,32 @@ FutureOr<void> main() async {
|
|||||||
// 设置国际化信息
|
// 设置国际化信息
|
||||||
await _initTranslation();
|
await _initTranslation();
|
||||||
|
|
||||||
runApp(const MyApp());
|
//错误日志监控
|
||||||
|
FlutterError.onError = (FlutterErrorDetails details) async {
|
||||||
|
AppLog.log('error:${details.exception.toString()}',
|
||||||
|
stackTrace: details.stack, error: true);
|
||||||
|
Zone.current.handleUncaughtError(details.exception, details.stack!);
|
||||||
|
};
|
||||||
|
|
||||||
|
//错误日志监控
|
||||||
|
runZonedGuarded<Future<void>>(() async {
|
||||||
|
runApp(const MyApp());
|
||||||
|
}, (Object error, StackTrace stackTrace) async {
|
||||||
|
AppLog.log('error:$error', stackTrace: stackTrace, error: true);
|
||||||
|
});
|
||||||
|
|
||||||
if (AppPlatform.isAndroid) {
|
if (AppPlatform.isAndroid) {
|
||||||
SystemUiOverlayStyle systemUiOverlayStyle =
|
const SystemUiOverlayStyle systemUiOverlayStyle =
|
||||||
const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
|
SystemUiOverlayStyle(statusBarColor: Colors.transparent);
|
||||||
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
|
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置国际化信息
|
// 设置国际化信息
|
||||||
Future _initTranslation() async => TranslationLoader.loadTranslation(
|
Future _initTranslation() async => TranslationLoader.loadTranslation(
|
||||||
zhSource: "images/lan/lan_zh.json",
|
zhSource: 'images/lan/lan_zh.json',
|
||||||
enSource: "images/lan/lan_en.json",
|
enSource: 'images/lan/lan_en.json',
|
||||||
keySource: "images/lan/lan_keys.json",
|
keySource: 'images/lan/lan_keys.json',
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置包名服务设备信息
|
// 设置包名服务设备信息
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import 'package:star_lock/mine/about/debug/controller.dart';
|
|||||||
import 'package:star_lock/mine/about/debug/log.dart';
|
import 'package:star_lock/mine/about/debug/log.dart';
|
||||||
import 'package:star_lock/mine/about/debug/tile.dart';
|
import 'package:star_lock/mine/about/debug/tile.dart';
|
||||||
|
|
||||||
|
|
||||||
/// # Debug Console
|
/// # Debug Console
|
||||||
///
|
///
|
||||||
/// A console for debugging Flutter apps, and displaying console messages on the widget.
|
/// A console for debugging Flutter apps, and displaying console messages on the widget.
|
||||||
@ -104,10 +103,11 @@ class DebugConsole extends StatefulWidget {
|
|||||||
Object? message, {
|
Object? message, {
|
||||||
DateTime? timestamp,
|
DateTime? timestamp,
|
||||||
StackTrace? stackTrace,
|
StackTrace? stackTrace,
|
||||||
|
bool isErr = false,
|
||||||
}) =>
|
}) =>
|
||||||
log(
|
log(
|
||||||
message,
|
message,
|
||||||
level: DebugConsoleLevel.info,
|
level: isErr ? DebugConsoleLevel.error : DebugConsoleLevel.info,
|
||||||
timestamp: timestamp,
|
timestamp: timestamp,
|
||||||
stackTrace: stackTrace,
|
stackTrace: stackTrace,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -6,9 +6,9 @@ class TranslationLoader {
|
|||||||
static bool get isEn => Get.locale?.languageCode.toLowerCase() == 'en';
|
static bool get isEn => Get.locale?.languageCode.toLowerCase() == 'en';
|
||||||
|
|
||||||
static Map<String,String>
|
static Map<String,String>
|
||||||
_zhMap = {},
|
_zhMap = <String, String>{},
|
||||||
_enMap = {},
|
_enMap = <String, String>{},
|
||||||
_keyMap = {};
|
_keyMap = <String, String>{};
|
||||||
|
|
||||||
static Map<String,String> get zhDic => _zhMap;
|
static Map<String,String> get zhDic => _zhMap;
|
||||||
static Map<String,String> get enDic => _enMap;
|
static Map<String,String> get enDic => _enMap;
|
||||||
@ -16,7 +16,7 @@ class TranslationLoader {
|
|||||||
static LanKeyEntity? _lanKeyEntity;
|
static LanKeyEntity? _lanKeyEntity;
|
||||||
static LanKeyEntity? get lanKeys => _lanKeyEntity;
|
static LanKeyEntity? get lanKeys => _lanKeyEntity;
|
||||||
|
|
||||||
static Future loadTranslation({
|
static Future<void> loadTranslation({
|
||||||
String? zhSource,
|
String? zhSource,
|
||||||
String? enSource,
|
String? enSource,
|
||||||
String? keySource,}) async {
|
String? keySource,}) async {
|
||||||
@ -26,15 +26,15 @@ class TranslationLoader {
|
|||||||
_lanKeyEntity = LanKeyEntity.fromJson(_keyMap);
|
_lanKeyEntity = LanKeyEntity.fromJson(_keyMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<Map<String,String>> _loadJsonFile(String filePath) async => rootBundle.loadString(filePath).then((jsonString){
|
static Future<Map<String,String>> _loadJsonFile(String filePath) async => rootBundle.loadString(filePath).then((String jsonString){
|
||||||
Map<String,dynamic> enJson = jsonDecode(jsonString);
|
final Map<String,dynamic> enJson = jsonDecode(jsonString);
|
||||||
Map<String,String> map = {};
|
final Map<String,String> map = <String, String>{};
|
||||||
enJson.forEach((key, value) {
|
enJson.forEach((String key,dynamic value) {
|
||||||
map[key] = value.toString();
|
map[key] = value.toString();
|
||||||
});
|
});
|
||||||
return map;
|
return map;
|
||||||
}).onError((error, stackTrace){
|
}).onError((Object? error, StackTrace stackTrace){
|
||||||
return Future.value({});
|
return Future<Map<String,String>>.value(<String, String>{});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user