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