更新服务器app版本脚本

pull/1/head
张萌 3 years ago
parent 66d67f0996
commit 5cf4452bb8

@ -50,7 +50,7 @@ class _TabNavigatorState extends State<TabNavigator>
flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin(); flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
var android = new AndroidInitializationSettings('@mipmap/ic_launcher'); var android = new AndroidInitializationSettings('@mipmap/ic_launcher');
var iOS = new IOSInitializationSettings(); var iOS = new IOSInitializationSettings();
var initSettings = new InitializationSettings(android: android,iOS: iOS); var initSettings = new InitializationSettings(android: android, iOS: iOS);
flutterLocalNotificationsPlugin.initialize(initSettings); flutterLocalNotificationsPlugin.initialize(initSettings);
//showNotification(); //showNotification();
@ -191,43 +191,41 @@ class _TabNavigatorState extends State<TabNavigator>
4, 4,
), ),
]; ];
return UpdaterPage( return BeeScaffold(
BeeScaffold( body: WillPopScope(
body: WillPopScope( onWillPop: () async {
onWillPop: () async { if (_lastPressed == null ||
if (_lastPressed == null || DateTime.now().difference(_lastPressed!) > Duration(seconds: 1)) {
DateTime.now().difference(_lastPressed!) > Duration(seconds: 1)) { //1
//1 _lastPressed = DateTime.now();
_lastPressed = DateTime.now(); BotToast.showText(text: '再点击一次返回退出');
BotToast.showText(text: '再点击一次返回退出'); return false;
return false; }
} //app
//app WebSocketUtil().closeWebSocket();
WebSocketUtil().closeWebSocket(); return true;
return true; },
}, child: TabBarView(
child: TabBarView( children: _pages,
children: _pages, controller: _tabController,
controller: _tabController, physics: NeverScrollableScrollPhysics(),
physics: NeverScrollableScrollPhysics(), ),
), ),
), bottomNavi: ConstrainedBox(
bottomNavi: ConstrainedBox( constraints: BoxConstraints(maxWidth: 750.w, maxHeight: 146.w),
constraints: BoxConstraints(maxWidth: 750.w, maxHeight: 146.w), child: Container(
child: Container( margin:
margin:
EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
decoration: BoxDecoration( decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: Assets.home.imgTabdi, fit: BoxFit.fitWidth), image: Assets.home.imgTabdi, fit: BoxFit.fitWidth),
color: Colors.transparent), color: Colors.transparent),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: _bottomNav.cast<Widget>().toList(), children: _bottomNav.cast<Widget>().toList(),
),
),
), ),
) ),
),
); );
} }
@ -237,19 +235,24 @@ class _TabNavigatorState extends State<TabNavigator>
} }
//payload //payload
debugPrint('payload:$payload'); debugPrint('payload:$payload');
if(payload == "complete") { if (payload == "complete") {
await showDialog(context: context, builder: (_) => AlertDialog( await showDialog(
title: Text('Notification'), context: context,
content: Text('$payload'), builder: (_) => AlertDialog(
),); title: Text('Notification'),
content: Text('$payload'),
),
);
} }
} }
showNotification() async { showNotification() async {
var android = new AndroidNotificationDetails( var android = new AndroidNotificationDetails(
'channel id', 'channel NAME', 'channel id',
'channel NAME',
priority: Priority.high, priority: Priority.high,
importance: Importance.max,); importance: Importance.max,
);
var iOS = new IOSNotificationDetails(); var iOS = new IOSNotificationDetails();
var platform = new NotificationDetails(android: android, iOS: iOS); var platform = new NotificationDetails(android: android, iOS: iOS);
await flutterLocalNotificationsPlugin.show( await flutterLocalNotificationsPlugin.show(

@ -1,8 +1,8 @@
import 'dart:io'; import 'dart:io';
import 'package:common_utils/common_utils.dart'; import 'package:common_utils/common_utils.dart';
import 'package:dio/dio.dart';
import 'package:grinder/grinder.dart'; import 'package:grinder/grinder.dart';
import 'package:path/path.dart'; import 'package:path/path.dart' hide context;
import 'package:pub_semver/pub_semver.dart'; import 'package:pub_semver/pub_semver.dart';
import 'package:yaml/yaml.dart'; import 'package:yaml/yaml.dart';
@ -10,6 +10,7 @@ import 'config.dart';
import 'version_tool.dart'; import 'version_tool.dart';
part '_build.dart'; part '_build.dart';
part '_project_manage.dart'; part '_project_manage.dart';
main(args) => grind(args); main(args) => grind(args);
@ -68,3 +69,21 @@ Future<String> getVersion() async {
String version = content['version']; String version = content['version'];
return version; return version;
} }
@Task()
Future uploadVersion() async {
TaskArgs args = context.invocation.arguments;
bool force = args.getFlag('f');
var version = await getVersion();
List<String> spVersion = version.split('+');
stdout.write('版本号:' + spVersion[0]+'\n');
stdout.write('构建号:' + spVersion[1]+'\n');
stdout.write('强制更新:' + force.toString()+'\n');
var response =
await Dio().post('http://121.41.26.225:8006/app/version/insert', data: {
'versionNumber': spVersion[0],
'buildNo': spVersion[1],
'forceUpdate': force ? 1 : 2
});
stdout.write(response.data.toString());
}

Loading…
Cancel
Save