feat:添加bugly userId 关联,修复错误
This commit is contained in:
parent
f5b28cf6bb
commit
c978444330
@ -1,8 +1,11 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bugly_plugin/flutter_bugly_plugin.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||
import 'package:star_lock/mine/mine/starLockMine_state.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/xs_jPhush.dart';
|
||||
|
||||
@ -14,34 +17,15 @@ import 'starLock_login_state.dart';
|
||||
|
||||
class StarLockLoginLogic extends BaseGetXController {
|
||||
final StarLockLoginState state = StarLockLoginState();
|
||||
final stateMyLogic = Get.put(StarLockMineLogic()).state;
|
||||
final StarLockMineState stateMyLogic = Get.put(StarLockMineLogic()).state;
|
||||
int indexFocusNode = noneFocusNode;
|
||||
static int noneFocusNode = 0;
|
||||
static int emailOrPhoneFocusNode = 1;
|
||||
static int pwdFocusNode = 2;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
// state.emailOrPhoneFocusNode.addListener(() {
|
||||
// if (state.emailOrPhoneFocusNode.hasFocus) {
|
||||
// indexFocusNode = emailOrPhoneFocusNode;
|
||||
// } else {
|
||||
// changeInputFocusNode();
|
||||
// }
|
||||
// });
|
||||
// state.pwdFocusNode.addListener(() {
|
||||
// if (state.pwdFocusNode.hasFocus) {
|
||||
// indexFocusNode = pwdFocusNode;
|
||||
// } else {
|
||||
// changeInputFocusNode();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
//检查焦点状态
|
||||
void changeInputFocusNode() {
|
||||
Future.delayed(Duration(milliseconds: 100), () {
|
||||
Future<void>.delayed(const Duration(milliseconds: 100), () {
|
||||
if (indexFocusNode == noneFocusNode) {
|
||||
return;
|
||||
}
|
||||
@ -53,9 +37,9 @@ class StarLockLoginLogic extends BaseGetXController {
|
||||
});
|
||||
}
|
||||
|
||||
void login() async {
|
||||
var entity = await ApiRepository.to.login(
|
||||
loginType: "1",
|
||||
Future<void> login() async {
|
||||
final LoginEntity entity = await ApiRepository.to.login(
|
||||
loginType: '1',
|
||||
password: state.pwd.value,
|
||||
countryCode: state.countryCode.value,
|
||||
username: state.emailOrPhone.value);
|
||||
@ -67,7 +51,7 @@ class StarLockLoginLogic extends BaseGetXController {
|
||||
// Get.toNamed(Routers.starLockMain);
|
||||
XSJPushProvider().initJPushService();
|
||||
XSJPushProvider().initLocalNotification(false);
|
||||
Get.offNamedUntil(Routers.starLockMain, (route) => false);
|
||||
Get.offNamedUntil(Routers.starLockMain, (Route route) => false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -25,9 +25,9 @@ FutureOr<void> main() async {
|
||||
await _initTranslation();
|
||||
|
||||
// bugly错误日志监控
|
||||
BuglyTool.init(() {
|
||||
runApp(const MyApp());
|
||||
});
|
||||
await BuglyTool.init();
|
||||
|
||||
runApp(const MyApp());
|
||||
|
||||
if (AppPlatform.isAndroid) {
|
||||
const SystemUiOverlayStyle systemUiOverlayStyle =
|
||||
|
||||
@ -5,13 +5,15 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_bugly_plugin/flutter_bugly_plugin.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
import 'package:star_lock/login/login/entity/LoginData.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
|
||||
///
|
||||
/// 错误日志监控
|
||||
///
|
||||
///
|
||||
class BuglyTool {
|
||||
static Future<void> init(Function on) async {
|
||||
static Future<void> init() async {
|
||||
if (F.isProductionEnv) {
|
||||
//生产
|
||||
await FlutterBuglyPlugin.init(
|
||||
@ -26,26 +28,33 @@ class BuglyTool {
|
||||
);
|
||||
}
|
||||
|
||||
//关联用户 id
|
||||
final LoginData? loginData = await Storage.getLoginData();
|
||||
setUserId(loginData?.userid);
|
||||
|
||||
//错误日志监控
|
||||
FlutterError.onError = (FlutterErrorDetails details) async {
|
||||
AppLog.log('error:${details.exception.toString()}',
|
||||
stackTrace: details.stack, error: true);
|
||||
FlutterBuglyPlugin.reportException(
|
||||
exceptionName: details.exception.toString(),
|
||||
reason: details.stack.toString());
|
||||
Zone.current.handleUncaughtError(
|
||||
details.exception, details.stack ?? StackTrace.empty);
|
||||
};
|
||||
|
||||
//错误日志监控
|
||||
PlatformDispatcher.instance.onError = (Object error, StackTrace stack) {
|
||||
AppLog.log('error:$error', stackTrace: stack, error: true);
|
||||
FlutterBuglyPlugin.reportException(
|
||||
exceptionName: error.toString(), reason: stack.toString());
|
||||
AppLog.log('error:$error', stackTrace: stack, error: true);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
//错误日志监控
|
||||
runZonedGuarded<Future<void>>(() async => on(),
|
||||
(Object error, StackTrace stackTrace) async {
|
||||
AppLog.log('error:$error', stackTrace: stackTrace, error: true);
|
||||
});
|
||||
//关联 userid
|
||||
static void setUserId(int? userId) {
|
||||
FlutterBuglyPlugin.setUserIdentifier(
|
||||
userIdentifier: (userId ?? 0).toString());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user