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