jpush.setAlias导致启动页阻塞 后移至首页中加载

hmxc
张萌 3 years ago
parent 7be2fcbbcb
commit 9415b8e39a

1
.gitignore vendored

@ -30,6 +30,7 @@
/dev/docs/pubspec.yaml /dev/docs/pubspec.yaml
/packages/flutter/coverage/ /packages/flutter/coverage/
version version
/tool/config.dart
# packages file containing multi-root paths # packages file containing multi-root paths
.packages.generated .packages.generated

@ -12,21 +12,16 @@ import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:power_logger/power_logger.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
void main() async { void main() async {
const buildType = const String.fromEnvironment('BUILD_TYPE'); const buildType = const String.fromEnvironment('BUILD_TYPE');
DeveloperUtil.setDev(!(buildType.contains('PRODUCT'))); DeveloperUtil.setDev(!(buildType.contains('PRODUCT')));
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await MainInitialize.initJPush();
///firebase crashlytics initalize ///firebase crashlytics initalize
//await MainInitialize.initFirebase(); //await MainInitialize.initFirebase();
MainInitialize.initTheme();
MainInitialize.initWechat();
MainInitialize.initWebSocket();
await MainInitialize.initJPush();
runApp(MyApp()); runApp(MyApp());
} }
@ -78,7 +73,7 @@ class _MyAppState extends State<MyApp> {
return MediaQuery( return MediaQuery(
// //
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
child: BotToastInit().call(context,child), child: BotToastInit().call(context, child),
); );
}, },
navigatorObservers: [BotToastNavigatorObserver()], navigatorObservers: [BotToastNavigatorObserver()],

@ -27,6 +27,7 @@ import 'package:aku_community/utils/headers.dart';
import 'package:aku_community/utils/login_util.dart'; import 'package:aku_community/utils/login_util.dart';
import 'package:aku_community/widget/animated/OverlayWidget.dart'; import 'package:aku_community/widget/animated/OverlayWidget.dart';
import 'package:aku_community/widget/others/rectIndicator.dart'; import 'package:aku_community/widget/others/rectIndicator.dart';
import 'package:aku_community/widget/others/user_tool.dart';
import 'package:badges/badges.dart'; import 'package:badges/badges.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -34,6 +35,8 @@ import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart'; import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:power_logger/power_logger.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
@ -69,6 +72,15 @@ class _HomePageState extends State<HomePage>
@override @override
void initState() { void initState() {
super.initState(); super.initState();
if (UserTool.userProvider.isLogin) {
try {
JPush().setAlias(UserTool.userProvider.userInfoModel!.id.toString());
LoggerData.addData(
'setAlias ${UserTool.userProvider.userInfoModel!.id} ${DateTime.now()}');
} catch (e) {
LoggerData.addData('${e.toString()} ${DateTime.now()}');
}
}
_scrollController = ScrollController(); _scrollController = ScrollController();
_refreshController = EasyRefreshController(); _refreshController = EasyRefreshController();
} }

@ -1,12 +1,14 @@
import 'dart:io'; import 'dart:io';
import 'package:aku_community/const/resource.dart'; import 'package:aku_community/const/resource.dart';
import 'package:aku_community/main_initialize.dart';
import 'package:aku_community/pages/setting_page/agreement_page/agreement_page.dart'; import 'package:aku_community/pages/setting_page/agreement_page/agreement_page.dart';
import 'package:aku_community/pages/setting_page/agreement_page/privacy_page.dart'; import 'package:aku_community/pages/setting_page/agreement_page/privacy_page.dart';
import 'package:aku_community/pages/tab_navigator.dart'; import 'package:aku_community/pages/tab_navigator.dart';
import 'package:aku_community/provider/app_provider.dart'; import 'package:aku_community/provider/app_provider.dart';
import 'package:aku_community/provider/user_provider.dart'; import 'package:aku_community/provider/user_provider.dart';
import 'package:aku_community/utils/developer_util.dart'; import 'package:aku_community/utils/developer_util.dart';
import 'package:aku_community/utils/headers.dart';
import 'package:aku_community/utils/hive_store.dart'; import 'package:aku_community/utils/hive_store.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
@ -19,11 +21,6 @@ import 'package:hive_flutter/hive_flutter.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:power_logger/power_logger.dart'; import 'package:power_logger/power_logger.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:aku_community/utils/headers.dart';
class SplashPage extends StatefulWidget { class SplashPage extends StatefulWidget {
SplashPage({Key? key}) : super(key: key); SplashPage({Key? key}) : super(key: key);
@ -132,73 +129,110 @@ class _SplashPageState extends State<SplashPage> {
await Permission.locationWhenInUse.request(); await Permission.locationWhenInUse.request();
} }
await _initOp(); await _initOp();
MainInitialize.initTheme();
MainInitialize.initWechat();
MainInitialize.initWebSocket();
Get.offAll(() => TabNavigator()); Get.offAll(() => TabNavigator());
}); });
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
body: Container( body: Container(
color: Colors.white, color: Colors.white,
child: Stack( child: Stack(
children: [ children: [
Align( Align(
alignment: Alignment.topCenter, alignment: Alignment.topCenter,
child: child: Row(
Row( mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, children: [
children: [ Container(
Container( child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
child: Column( Text(
mainAxisAlignment: MainAxisAlignment.start, '\n',
children: [ style: TextStyle(
color: Color(0xFF000000),
Text('\n',style: TextStyle(color:Color(0xFF000000),fontSize: 40.sp,height: 1.15),), fontSize: 40.sp,
], height: 1.15),
),
],
),
margin: EdgeInsets.only(top: 450.w),
), ),
margin: EdgeInsets.only(top: 450.w), 25.wb,
Container(
), child: Column(
25.wb, mainAxisAlignment: MainAxisAlignment.start,
Container( children: [
child: Text(
Column( '\n便\n\n\n\n\n\n\n',
mainAxisAlignment: MainAxisAlignment.start, style: TextStyle(
children: [ color: Color(0xFF000000),
fontSize: 40.sp,
Text('\n便\n\n\n\n\n\n\n',style: TextStyle(color:Color(0xFF000000),fontSize: 40.sp,height: 1.15),), height: 1.15),
),
], ],
),
margin: EdgeInsets.only(top: 530.w),
),
25.wb,
Container(
height: 400.w,
width: 2.w,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0x99000000), Color(0x00000000)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter),
borderRadius: BorderRadius.circular(2.w),
),
), ),
margin: EdgeInsets.only(top: 530.w),
),
], 25.wb,
) Container(
height: 400.w,
width: 2.w,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0x99000000), Color(0x00000000)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter),
borderRadius: BorderRadius.circular(2.w),
),
),
],
)),
Positioned(
child: Image.asset(
R.ASSETS_IMAGES_CIRCLE_TEXT_PNG,
width: 61.w,
height: 72.w,
fit: BoxFit.fill,
),
top: 410.w,
left: 275.w,
),
Positioned(
child: Image.asset(
R.ASSETS_IMAGES_CIRCLE_RIGHT_TOP_PNG,
width: 185.w,
height: 249.w,
fit: BoxFit.fill,
),
top: 0.w,
right: 0.w,
),
Positioned(
child: Image.asset(
R.ASSETS_IMAGES_CIRCLE_LEFT_BOTTOM_PNG,
width: 270.w,
height: 504.w,
fit: BoxFit.fill,
),
bottom: 224.w,
left: 0.w,
),
Positioned(
child: Image.asset(
R.ASSETS_IMAGES_CIRCLE_RIGHT_BOTTOM_PNG,
width: 88.w,
height: 180.w,
fit: BoxFit.fill,
),
bottom: 150.w,
right: 0.w,
), ),
Positioned(child: Image.asset(R.ASSETS_IMAGES_CIRCLE_TEXT_PNG,width: 61.w,height: 72.w,fit: BoxFit.fill,),top: 410.w,left: 275.w,),
Positioned(child: Image.asset(R.ASSETS_IMAGES_CIRCLE_RIGHT_TOP_PNG,width: 185.w,height: 249.w,fit: BoxFit.fill,),top: 0.w,right: 0.w,),
Positioned(child: Image.asset(R.ASSETS_IMAGES_CIRCLE_LEFT_BOTTOM_PNG,width: 270.w,height: 504.w,fit: BoxFit.fill,),bottom: 224.w,left: 0.w,),
Positioned(child: Image.asset(R.ASSETS_IMAGES_CIRCLE_RIGHT_BOTTOM_PNG,width: 88.w,height: 180.w,fit: BoxFit.fill,),bottom: 150.w,right: 0.w,),
Align( Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: Container( child: Container(
@ -207,11 +241,20 @@ class _SplashPageState extends State<SplashPage> {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
Image.asset(R.ASSETS_IMAGES_SPLASH_LOGO_PNG,width: 140.w,height: 140.w,fit: BoxFit.fill,), Image.asset(
R.ASSETS_IMAGES_SPLASH_LOGO_PNG,
Text('小蜜蜂智慧社区',style: TextStyle(color:Color(0xD9000000),fontSize: 32.sp,fontWeight: FontWeight.bold),), width: 140.w,
height: 140.w,
fit: BoxFit.fill,
),
Text(
'小蜜蜂智慧社区',
style: TextStyle(
color: Color(0xD9000000),
fontSize: 32.sp,
fontWeight: FontWeight.bold),
),
], ],
), ),
), ),
) )

@ -66,13 +66,7 @@ class UserProvider extends ChangeNotifier {
Future updateProfile() async { Future updateProfile() async {
_userInfoModel = await SignFunc.getUserInfo(); _userInfoModel = await SignFunc.getUserInfo();
if (_userInfoModel != null && !kIsWeb && !Platform.isMacOS) {
try {
await JPush().setAlias(_userInfoModel!.id.toString());
} catch (e) {
LoggerData.addData(e);
}
}
notifyListeners(); notifyListeners();
} }

@ -1,12 +1,11 @@
import 'dart:async'; import 'dart:async';
import 'package:aku_community/widget/others/user_tool.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:power_logger/power_logger.dart'; import 'package:power_logger/power_logger.dart';
import 'package:web_socket_channel/io.dart'; import 'package:web_socket_channel/io.dart';
import 'package:web_socket_channel/web_socket_channel.dart'; import 'package:web_socket_channel/web_socket_channel.dart';
import 'package:aku_community/widget/others/user_tool.dart';
const String baseUri = 'wss://test.kaidalai.cn/websocket/app'; const String baseUri = 'wss://test.kaidalai.cn/websocket/app';
enum SOCKETSTATUS { enum SOCKETSTATUS {
CONNECTED, // CONNECTED, //

@ -1,6 +1,6 @@
class Config { class Config {
/// ///
static const String homeDir = '/users/datang'; static const String homeDir = '/users/zhangmeng';
/// ///
static const String packageName = 'aku_community'; static const String packageName = 'aku_community';
@ -11,9 +11,9 @@ class Config {
/// ///
static String get apkDevDir => static String get apkDevDir =>
'/users/datang/team/bee/app/aku_community/dev'; '/users/zhangmeng/team/bee/app/aku_community/dev';
/// ///
static String get apkDir => static String get apkDir =>
'/users/datang/team/bee/app/aku_community/release'; '/users/zhangmeng/team/bee/app/aku_community/release';
} }

Loading…
Cancel
Save