From 9415b8e39a7fbc6517de4cfb78940fafe545e29f Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Mon, 22 Nov 2021 16:10:35 +0800 Subject: [PATCH] =?UTF-8?q?jpush.setAlias=E5=AF=BC=E8=87=B4=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E9=A1=B5=E9=98=BB=E5=A1=9E=20=E5=90=8E=E7=A7=BB?= =?UTF-8?q?=E8=87=B3=E9=A6=96=E9=A1=B5=E4=B8=AD=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + lib/main.dart | 9 +- lib/pages/home/home_page.dart | 12 ++ lib/pages/splash/splash_page.dart | 165 ++++++++++++++--------- lib/provider/user_provider.dart | 8 +- lib/utils/websocket/web_socket_util.dart | 3 +- tool/config.dart | 6 +- 7 files changed, 124 insertions(+), 80 deletions(-) diff --git a/.gitignore b/.gitignore index 69906469..5bce8333 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ /dev/docs/pubspec.yaml /packages/flutter/coverage/ version +/tool/config.dart # packages file containing multi-root paths .packages.generated diff --git a/lib/main.dart b/lib/main.dart index a4e36ff2..285b07f4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -12,21 +12,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_screenutil/flutter_screenutil.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'; void main() async { const buildType = const String.fromEnvironment('BUILD_TYPE'); DeveloperUtil.setDev(!(buildType.contains('PRODUCT'))); WidgetsFlutterBinding.ensureInitialized(); + await MainInitialize.initJPush(); ///firebase crashlytics initalize //await MainInitialize.initFirebase(); - MainInitialize.initTheme(); - MainInitialize.initWechat(); - MainInitialize.initWebSocket(); - await MainInitialize.initJPush(); runApp(MyApp()); } @@ -78,7 +73,7 @@ class _MyAppState extends State { return MediaQuery( //设置文字大小不随系统设置改变 data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), - child: BotToastInit().call(context,child), + child: BotToastInit().call(context, child), ); }, navigatorObservers: [BotToastNavigatorObserver()], diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 53a2048d..8e2672b6 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -27,6 +27,7 @@ import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/utils/login_util.dart'; import 'package:aku_community/widget/animated/OverlayWidget.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:flutter/cupertino.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_swiper_null_safety/flutter_swiper_null_safety.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:velocity_x/velocity_x.dart'; @@ -69,6 +72,15 @@ class _HomePageState extends State @override void 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(); _refreshController = EasyRefreshController(); } diff --git a/lib/pages/splash/splash_page.dart b/lib/pages/splash/splash_page.dart index 16ab75fd..ce884f13 100644 --- a/lib/pages/splash/splash_page.dart +++ b/lib/pages/splash/splash_page.dart @@ -1,12 +1,14 @@ import 'dart:io'; 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/privacy_page.dart'; import 'package:aku_community/pages/tab_navigator.dart'; import 'package:aku_community/provider/app_provider.dart'; import 'package:aku_community/provider/user_provider.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:flutter/cupertino.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:power_logger/power_logger.dart'; import 'package:provider/provider.dart'; -import 'package:velocity_x/velocity_x.dart'; - -import 'package:aku_community/utils/headers.dart'; - - class SplashPage extends StatefulWidget { SplashPage({Key? key}) : super(key: key); @@ -132,73 +129,110 @@ class _SplashPageState extends State { await Permission.locationWhenInUse.request(); } await _initOp(); + MainInitialize.initTheme(); + MainInitialize.initWechat(); + MainInitialize.initWebSocket(); Get.offAll(() => TabNavigator()); }); - } @override Widget build(BuildContext context) { return Scaffold( body: Container( - color: Colors.white, child: Stack( - children: [ Align( - alignment: Alignment.topCenter, - child: - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - - - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - - Text('追\n求',style: TextStyle(color:Color(0xFF000000),fontSize: 40.sp,height: 1.15),), - ], + alignment: Alignment.topCenter, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + '追\n求', + style: TextStyle( + color: Color(0xFF000000), + fontSize: 40.sp, + height: 1.15), + ), + ], + ), + margin: EdgeInsets.only(top: 450.w), ), - margin: EdgeInsets.only(top: 450.w), - - ), - 25.wb, - Container( - child: - Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - - Text('更\n便\n捷\n的\n生\n活\n方\n程\n式',style: TextStyle(color:Color(0xFF000000),fontSize: 40.sp,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), - ), + 25.wb, + Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + '更\n便\n捷\n的\n生\n活\n方\n程\n式', + style: TextStyle( + color: Color(0xFF000000), + fontSize: 40.sp, + 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), + ), + ), + ], + )), + 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( alignment: Alignment.bottomCenter, child: Container( @@ -207,11 +241,20 @@ class _SplashPageState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ - Image.asset(R.ASSETS_IMAGES_SPLASH_LOGO_PNG,width: 140.w,height: 140.w,fit: BoxFit.fill,), - - Text('小蜜蜂智慧社区',style: TextStyle(color:Color(0xD9000000),fontSize: 32.sp,fontWeight: FontWeight.bold),), + Image.asset( + R.ASSETS_IMAGES_SPLASH_LOGO_PNG, + width: 140.w, + height: 140.w, + fit: BoxFit.fill, + ), + Text( + '小蜜蜂智慧社区', + style: TextStyle( + color: Color(0xD9000000), + fontSize: 32.sp, + fontWeight: FontWeight.bold), + ), ], - ), ), ) diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 50a3c04a..37772fec 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -66,13 +66,7 @@ class UserProvider extends ChangeNotifier { Future updateProfile() async { _userInfoModel = await SignFunc.getUserInfo(); - if (_userInfoModel != null && !kIsWeb && !Platform.isMacOS) { - try { - await JPush().setAlias(_userInfoModel!.id.toString()); - } catch (e) { - LoggerData.addData(e); - } - } + notifyListeners(); } diff --git a/lib/utils/websocket/web_socket_util.dart b/lib/utils/websocket/web_socket_util.dart index 88ac82ed..2000b812 100644 --- a/lib/utils/websocket/web_socket_util.dart +++ b/lib/utils/websocket/web_socket_util.dart @@ -1,12 +1,11 @@ import 'dart:async'; +import 'package:aku_community/widget/others/user_tool.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:power_logger/power_logger.dart'; import 'package:web_socket_channel/io.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'; enum SOCKETSTATUS { CONNECTED, //已连接 diff --git a/tool/config.dart b/tool/config.dart index 331ca7c6..fa66383e 100644 --- a/tool/config.dart +++ b/tool/config.dart @@ -1,6 +1,6 @@ class Config { ///用户根目录 - static const String homeDir = '/users/datang'; + static const String homeDir = '/users/zhangmeng'; ///包名 static const String packageName = 'aku_community'; @@ -11,9 +11,9 @@ class Config { ///测试包文件夹 static String get apkDevDir => - '/users/datang/team/bee/app/aku_community/dev'; + '/users/zhangmeng/team/bee/app/aku_community/dev'; ///正式包文件夹 static String get apkDir => - '/users/datang/team/bee/app/aku_community/release'; + '/users/zhangmeng/team/bee/app/aku_community/release'; }